diff --git a/__tests__/shared/verifiableDataLD.ts b/__tests__/shared/verifiableDataLD.ts index df113be06..5816b5dcb 100644 --- a/__tests__/shared/verifiableDataLD.ts +++ b/__tests__/shared/verifiableDataLD.ts @@ -289,6 +289,38 @@ export default (testContext: { expect(verifiableCredential).toEqual(verifiableCredential2) }) + it('should create verifiable credential with external context', async () => { + const credential = await agent.createVerifiableCredential({ + credential: { + issuer: { id: pkhIdentifier.did }, + '@context': [ + 'https://www.w3.org/2018/credentials/v1', + 'https://veramo.io/contexts/discord-kudos/v1' + ], + type: ['VerifiableCredential', 'DiscordKudos'], + issuanceDate: new Date().toISOString(), + credentialSubject: { + id: pkhIdentifier.did, + kudos: 'Thank you', + }, + }, + proofFormat: 'lds', + fetchRemoteContexts: true, + }) + + // Check credential: + expect(credential).toHaveProperty('proof') + expect(credential).toHaveProperty('proof.jws') + expect(credential['type']).toEqual(['VerifiableCredential', 'DiscordKudos']) + + const result = await agent.verifyCredential({ + credential, + fetchRemoteContexts: true + }) + expect(result.verified).toBe(true) + + }) + describe('credential verification policies', () => { it('can verify credential at a particular time', async () => { const issuanceDate = '2019-08-19T09:15:20.000Z' // 1566206120 diff --git a/packages/credential-ld/src/action-handler.ts b/packages/credential-ld/src/action-handler.ts index 4cd587dab..3b240afc9 100644 --- a/packages/credential-ld/src/action-handler.ts +++ b/packages/credential-ld/src/action-handler.ts @@ -36,7 +36,7 @@ import { IVerifyPresentationLDArgs, } from './types.js' -const debug = Debug('veramo:w3c:action-handler') +const debug = Debug('veramo:credential-ld:action-handler') /** * A Veramo plugin that implements the {@link ICredentialIssuerLD} methods. @@ -176,7 +176,7 @@ export class CredentialIssuerLD implements IAgentPlugin { identifier.did, signingKey, verificationMethodId, - { ...args.options, now }, + { ...args, now }, context, ) } catch (error) { @@ -200,7 +200,7 @@ export class CredentialIssuerLD implements IAgentPlugin { return this.ldCredentialModule.verifyCredential( credential, args.fetchRemoteContexts || false, - { ...args.options, now }, + { ...args, now }, context, ) } @@ -220,7 +220,7 @@ export class CredentialIssuerLD implements IAgentPlugin { args.challenge, args.domain, args.fetchRemoteContexts || false, - { ...args.options, now }, + { ...args, now }, context, ) }