Skip to content

Commit

Permalink
Also update calls to encodeEntry.
Browse files Browse the repository at this point in the history
  • Loading branch information
sgwilym committed May 20, 2024
1 parent 793e220 commit 4245837
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 36 deletions.
42 changes: 9 additions & 33 deletions src/meadowcap/meadowcap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,22 +475,14 @@ Deno.test("isAuthorisedWrite", async () => {
};

const encodedEntry = encodeEntry({
namespaceScheme: ecdsaScheme.encodings.publicKey,
subspaceScheme: ecdsaScheme.encodings.publicKey,
encodeNamespace: ecdsaScheme.encodings.publicKey.encode,
encodeSubspace: ecdsaScheme.encodings.publicKey.encode,
pathScheme: {
maxComponentCount: 3,
maxComponentLength: 4,
maxPathLength: 10,
},
payloadScheme: {
encode: (buffer: ArrayBuffer) => new Uint8Array(buffer),
decode: (enc: Uint8Array) => enc.buffer,
encodedLength: () => 32,
decodeStream: () => {
// Not used here.
return Promise.resolve(new Uint8Array());
},
},
encodePayload: (buffer: ArrayBuffer) => new Uint8Array(buffer),
}, entry);

const signature = await ecdsaScheme.signatures.sign(
Expand Down Expand Up @@ -523,22 +515,14 @@ Deno.test("isAuthorisedWrite", async () => {
};

const encodedEntry = encodeEntry({
namespaceScheme: ecdsaScheme.encodings.publicKey,
subspaceScheme: ecdsaScheme.encodings.publicKey,
encodeNamespace: ecdsaScheme.encodings.publicKey.encode,
encodeSubspace: ecdsaScheme.encodings.publicKey.encode,
pathScheme: {
maxComponentCount: 3,
maxComponentLength: 4,
maxPathLength: 10,
},
payloadScheme: {
encode: (buffer: ArrayBuffer) => new Uint8Array(buffer),
decode: (enc: Uint8Array) => enc.buffer,
encodedLength: () => 32,
decodeStream: () => {
// Not used here.
return Promise.resolve(new Uint8Array());
},
},
encodePayload: (buffer: ArrayBuffer) => new Uint8Array(buffer),
}, entry);

const signature = await ecdsaScheme.signatures.sign(
Expand Down Expand Up @@ -571,22 +555,14 @@ Deno.test("isAuthorisedWrite", async () => {
};

const encodedEntry = encodeEntry({
namespaceScheme: ecdsaScheme.encodings.publicKey,
subspaceScheme: ecdsaScheme.encodings.publicKey,
encodeNamespace: ecdsaScheme.encodings.publicKey.encode,
encodeSubspace: ecdsaScheme.encodings.publicKey.encode,
pathScheme: {
maxComponentCount: 3,
maxComponentLength: 4,
maxPathLength: 10,
},
payloadScheme: {
encode: (buffer: ArrayBuffer) => new Uint8Array(buffer),
decode: (enc: Uint8Array) => enc.buffer,
encodedLength: () => 32,
decodeStream: () => {
// Not used here.
return Promise.resolve(new Uint8Array());
},
},
encodePayload: (buffer: ArrayBuffer) => new Uint8Array(buffer),
}, entry);

const signature = await ecdsaScheme.signatures.sign(
Expand Down
7 changes: 4 additions & 3 deletions src/meadowcap/meadowcap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,11 @@ export class Meadowcap<
const receiver = this.getCapReceiver(token.capability);

const encodedEntry = encodeEntry({
namespaceScheme: this.params.namespaceKeypairScheme.encodings.publicKey,
encodeNamespace:
this.params.namespaceKeypairScheme.encodings.publicKey.encode,
pathScheme: this.params.pathScheme,
subspaceScheme: this.params.userScheme.encodings.publicKey,
payloadScheme: this.params.payloadScheme,
encodeSubspace: this.params.userScheme.encodings.publicKey.encode,
encodePayload: this.params.payloadScheme.encode,
}, entry);

return this.params.userScheme.signatures.verify(
Expand Down

0 comments on commit 4245837

Please sign in to comment.