I am trying to use ChainDelegation from the official Dfinity Library, agent-js to be able of making request calls without sign readState manually. So, I create a custom identity which has a method sign
public async sign(blob: BinaryBlob): Promise<BinaryBlob> {
return this._executeWithApp(async (app) => {
console.log('Signing blob tryied 1', app, blob);
const resp: ResponseSign = await app.sign(this.derivePath, Buffer.from(blob), 0);
console.log('Signed blob', resp);
const signatureRS = resp.signatureRS;
if (!signatureRS) {
throw new Error(
`A ledger error happened during signature:\n` +
`Code: ${resp.returnCode}\n` +
`Message: ${JSON.stringify(resp.errorMessage)}\n`,
);
}
if (signatureRS?.byteLength !== 64) {
throw new Error(`Signature must be 64 bytes long (is ${signatureRS.length})`);
}
return blobFromBuffer(new BlobBuffer(signatureRS));
})
}
And for create delegation I do
const pidTargets = targets?.map(target => Principal.fromText(target));
const expiration = new Date(Date.now() + 15 * 60 * 1000);
const delegation = new Delegation(to.toDer(), BigInt(+expiration) * BigInt(1000000), pidTargets);
const signature = await this.ledgerIdentity.sign(delegation.toCBOR() as unknown as BinaryBlob);
When I tried to use it, it fails returning
Message: "Data is invalid : Unexpected data type"
The var signature is a ArrayBuffer type of byteLength 118
I am trying to use ChainDelegation from the official Dfinity Library, agent-js to be able of making request calls without sign readState manually. So, I create a custom identity which has a method sign
And for create delegation I do
When I tried to use it, it fails returning
Message: "Data is invalid : Unexpected data type"
The var signature is a ArrayBuffer type of byteLength 118
:link: zboto Link