Skip to content

Commit

Permalink
refactor: use full json web key
Browse files Browse the repository at this point in the history
Signed-off-by: Nam Hoang <[email protected]>
  • Loading branch information
namhoang1604 committed Nov 23, 2023
1 parent 376d345 commit 07fa67a
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/MerkleDisclosureProof2021.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ export class MerkleDisclosureProof2021 {
proof.rootNonce = merkleProof.rootNonce;

// produce compact jws
const k = await (this.key as any).useJwa({
detached: false,
header: {
// we don't need this here, but we will need it when multi message JWS is possible.
// kid: this.key.id,
},
});
const signer = k.signer();
// const k = await (this.key as any).useJwa({
// detached: true,
// header: {
// // we don't need this here, but we will need it when multi message JWS is possible.
// // kid: this.key.id,
// },
// });
const signer = this.key.signer();
const signature = await signer.sign({
data: Buffer.from(merkleProof.root, 'hex').toString('base64'),
});
Expand Down Expand Up @@ -175,6 +175,7 @@ export class MerkleDisclosureProof2021 {
proof: { ...proof },
};

delete documentWithProof.proof['@context'];
delete documentWithProof.proof.proofs;
delete documentWithProof.proof.jws;

Expand Down Expand Up @@ -250,13 +251,13 @@ export class MerkleDisclosureProof2021 {
return framed;
}

const key: any = await JsonWebKey.from(framed);
return key.useJwa({
detached: false,
header: {
// we don't need this here, but we will need it when multi message JWS is possible.
// kid: this.key.id,
},
});
return JsonWebKey.from(framed, { detached: false });
// return key.useJwa({
// detached: true,
// header: {
// // we don't need this here, but we will need it when multi message JWS is possible.
// // kid: this.key.id,
// },
// });
}
}

0 comments on commit 07fa67a

Please sign in to comment.