Skip to content

Commit

Permalink
Merge pull request #282 from docknetwork/fix/should-not-sign-kvac-pre…
Browse files Browse the repository at this point in the history
…sentations

skip signing presentations with kvac credentials
  • Loading branch information
maycon-mello authored Aug 29, 2024
2 parents f04ccce + 31dfbe0 commit 04ba8c3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/wasm/src/services/credential/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export function isKvacCredential(credential) {
);
}

export function isAnnonymousCredential(credential) {
return isBBSPlusCredential(credential) || isKvacCredential(credential);
}

class CredentialService {
constructor() {
this.name = serviceName;
Expand Down Expand Up @@ -103,19 +107,19 @@ class CredentialService {
validation.createPresentation(params);
const {credentials, keyDoc, challenge, id, domain} = params;
const vp = new VerifiablePresentation(id);
let isBBS;
let shouldSkipSigning = false;
for (const signedVC of credentials) {
vp.addCredential(signedVC);
isBBS = isBBS || isBBSPlusCredential(signedVC);
shouldSkipSigning = shouldSkipSigning || isAnnonymousCredential(signedVC);
}

if (!isBBS) {
if (!shouldSkipSigning) {
vp.setHolder(keyDoc.controller);
}

keyDoc.keypair = keyDocToKeypair(keyDoc, getDock());

if (isBBS) {
if (shouldSkipSigning) {
return vp.toJSON();
}

Expand Down

0 comments on commit 04ba8c3

Please sign in to comment.