Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mistermoe committed Dec 8, 2023
1 parent c5ce5f3 commit eaefc0d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 8 additions & 2 deletions packages/credentials/src/compact-jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,15 @@ export class CompactJwt {
*/
static async verify(params: VerifyJwtParams) {
const { decoded: decodedJwt, encoded: encodedJwt } = CompactJwt.parse({ compactJwt: params.compactJwt });

// TODO: should really be looking for verificationMethod with authentication verification relationship
const verificationMethod = await CompactJwt.didResolver.dereference({ didUrl: decodedJwt.header.kid! });
if (!utils.isVerificationMethod(verificationMethod)) { // ensure that appropriate verification method was found
const dereferenceResult = await CompactJwt.didResolver.dereference({ didUrl: decodedJwt.header.kid! });
if (dereferenceResult.dereferencingMetadata.error) {
throw new Error(`Failed to resolve ${decodedJwt.header.kid}`);
}

Check warning on line 135 in packages/credentials/src/compact-jwt.ts

View check run for this annotation

Codecov / codecov/patch

packages/credentials/src/compact-jwt.ts#L134-L135

Added lines #L134 - L135 were not covered by tests

const verificationMethod = dereferenceResult.contentStream;
if (!verificationMethod || !utils.isVerificationMethod(verificationMethod)) { // ensure that appropriate verification method was found
throw new Error('Verification failed: Expected kid in JWT header to dereference a DID Document Verification Method');
}

Expand Down
3 changes: 1 addition & 2 deletions packages/dids/src/did-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ export class DidResolver {
*/
async dereference(params: DereferenceParams): Promise<DidDereferenceResult> {
const { didUrl } = params;
const { didDocument, didResolutionMetadata, didDocumentMetadata } = await this.resolve(didUrl);

const { didDocument, didResolutionMetadata = {}, didDocumentMetadata = {} } = await this.resolve(didUrl);
if (didResolutionMetadata.error) {
return {
dereferencingMetadata : didResolutionMetadata,
Expand Down

0 comments on commit eaefc0d

Please sign in to comment.