Skip to content

Commit

Permalink
resolve did:dht in VCs
Browse files Browse the repository at this point in the history
  • Loading branch information
phoebe-lew committed Nov 29, 2023
1 parent 34b915d commit fb1b429
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/credentials/src/verifiable-credential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<DIDResolutionResult> {
Expand Down Expand Up @@ -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));
}
Expand Down

0 comments on commit fb1b429

Please sign in to comment.