From fb1b429c6708ae2d06d1e2ce43e82b81dbf298ba Mon Sep 17 00:00:00 2001 From: Phoebe Lew Date: Wed, 29 Nov 2023 00:26:36 +0000 Subject: [PATCH] resolve did:dht in VCs --- packages/credentials/src/verifiable-credential.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/credentials/src/verifiable-credential.ts b/packages/credentials/src/verifiable-credential.ts index 0fc754f5d..cc86aa1e2 100644 --- a/packages/credentials/src/verifiable-credential.ts +++ b/packages/credentials/src/verifiable-credential.ts @@ -8,7 +8,7 @@ import { v4 as uuidv4 } from 'uuid'; import { getCurrentXmlSchema112Timestamp } from './utils.js'; import { Convert } from '@web5/common'; import { verifyJWT } from 'did-jwt'; -import { DidIonMethod, DidKeyMethod, DidResolver } from '@web5/dids'; +import { DidDhtMethod, DidIonMethod, DidKeyMethod, DidResolver } from '@web5/dids'; import { SsiValidator } from './validators.js'; export const DEFAULT_CONTEXT = 'https://www.w3.org/2018/credentials/v1'; @@ -62,7 +62,7 @@ type DecodedVcJwt = { signature: string } -const didResolver = new DidResolver({ didResolvers: [DidIonMethod, DidKeyMethod] }); +const didResolver = new DidResolver({ didResolvers: [DidIonMethod, DidKeyMethod, DidDhtMethod] }); class TbdResolver implements Resolvable { async resolve(didUrl: string): Promise { @@ -213,10 +213,14 @@ export class VerifiableCredential { throw new Error('Signature verification failed: Expected JWS header to contain alg and kid'); } + const verificationResponse = await verifyJWT(vcJwt, { resolver: tbdResolver }); + console.log('hiii'); + + if (!verificationResponse.verified) { throw new Error('VC JWT could not be verified. Reason: ' + JSON.stringify(verificationResponse)); }