Skip to content

Commit

Permalink
feat: Allow supplying signer/verifier
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Jan 13, 2023
1 parent 5e5328b commit b010d7a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ export class SphereonJsonWebSignature2020 extends SphereonLdSignature {
type: this.getSupportedVerificationType(),
controller: controller,
publicKeyJwk,
})
}, {signer: () => signer})

verificationKey.signer = () => signer
// verificationKey.signer = () => signer

const suite = new JsonWebSignature({
key: verificationKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ const getSigner = async (k: any, options = { detached: true }) => {
};

const applyJwa = async (k: any, options?: any) => {
const verifier = await getVerifier(k, options);
const verifier = options?.verifier ? options.verifier : await getVerifier(k, options);
k.verifier = () => verifier as any;
if (k.privateKey) {
const signer = await getSigner(k, options);
const signer = options?.signer ? options.signer : await getSigner(k, options);
k.signer = () => signer as any;
}
return k;
Expand Down Expand Up @@ -184,11 +184,11 @@ export class JsonWebKey {
) => {
const KeyPair = getKeyPairForType(k);
const kp = await KeyPair.from(k as any);
let { detached, header } = options;
let { detached, header, signer, verifier } = options;
if (detached === undefined) {
detached = true;
}
return useJwa(kp, { detached, header });
return useJwa(kp, { detached, header, signer, verifier });
};

public signer!: () => any;
Expand Down

0 comments on commit b010d7a

Please sign in to comment.