diff --git a/__tests__/createVerifiableCredential.test.ts b/__tests__/createVerifiableCredential.test.ts index 9cc03db20..c4f7eadc8 100644 --- a/__tests__/createVerifiableCredential.test.ts +++ b/__tests__/createVerifiableCredential.test.ts @@ -80,6 +80,6 @@ describe('integration test for creating Verifiable Credentials', () => { proofFormat: 'jwt', }) - expect(verifiableCredential.proof.jwt).toBeTruthy() + expect(verifiableCredential.proof.jwt).toBeDefined() }) }) diff --git a/__tests__/handleMessage.test.ts b/__tests__/handleMessage.test.ts index dba3afddd..50eefcc4b 100644 --- a/__tests__/handleMessage.test.ts +++ b/__tests__/handleMessage.test.ts @@ -23,7 +23,7 @@ import fs from 'fs' let agent: TAgent let dbConnection: Promise -const databaseFile = 'database.sqlite' +const databaseFile = 'database3.sqlite' const JWT = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NkstUiJ9.eyJpYXQiOjE1OTM0NTE3MDAsInR5cGUiOiJzZHIiLCJzdWJqZWN0IjoiZGlkOmV0aHI6cmlua2VieToweDM2MjQ2M2NiZTUyMjhjZTUwMGJlOGUwMzVjZGIyMWI3NzQ1ZjZkYjAiLCJ0YWciOiJzZHItb25lIiwiY2xhaW1zIjpbeyJyZWFzb24iOiJXZSBuZWVkIGl0IiwiY2xhaW1UeXBlIjoibmFtZSIsImVzc2VudGlhbCI6dHJ1ZX1dLCJpc3MiOiJkaWQ6ZXRocjpyaW5rZWJ5OjB4MTM4NGMxZmNlM2Y3MWQ3NjU5NzcwOGY1NGM0ZDEyOGMyNDFkMDBkMiJ9.L-j-gREAuN7DAxDCe1vXJWtMIdmn88HTuTFp2PasTTo_aqvIdGcFtv-rSfvRHkauNq5C3PkXkQWY01VGqpJ-QwE' @@ -97,7 +97,7 @@ describe('integration test for handling messages', () => { proofFormat: 'jwt', }) - expect(verifiableCredential.proof.jwt).toBeTruthy() + expect(verifiableCredential.proof.jwt).toBeDefined() }) it('should save an SDR message', async () => { @@ -136,6 +136,6 @@ describe('integration test for handling messages', () => { proofFormat: 'jwt', }) - expect(verifiableCredential.proof.jwt).toBeTruthy() + expect(verifiableCredential.proof.jwt).toBeDefined() }) }) diff --git a/packages/daf-w3c/src/__tests__/action-handler.test.ts b/packages/daf-w3c/src/__tests__/action-handler.test.ts index 08543499a..52bc87a64 100644 --- a/packages/daf-w3c/src/__tests__/action-handler.test.ts +++ b/packages/daf-w3c/src/__tests__/action-handler.test.ts @@ -10,8 +10,6 @@ const mockDidJwtVc = { createVerifiableCredentialJwt: jest.fn().mockReturnValue('mockVcJwt'), createVerifiablePresentationJwt: jest.fn().mockReturnValue('mockVcJwt'), verifyCredential: jest.fn().mockReturnValue({ payload: {} }), - transformCredentialInput: jest.fn().mockReturnValue('mockTransformedCredential'), - transformPresentationInput: jest.fn().mockReturnValue('mockTransformedPresentation'), normalizeCredential: jest.fn().mockReturnValue('mockCredential'), normalizePresentation: jest.fn().mockReturnValue('mockPresentation'), } @@ -69,7 +67,7 @@ const w3c = new W3c() describe('daf-w3c', () => { it('handles createVerifiableCredential', async () => { const credential: W3CCredential = { - '@context': ['https://www.w3.org/2018/credentials/v1323', 'https://www.w3.org/2020/demo/4342323'], + '@context': ['https://www.w3.org/2018/credentials/v1', 'https://www.w3.org/2020/demo/4342323'], type: ['VerifiableCredential', 'PublicProfile'], issuer: { id: mockIdentity1.did }, issuanceDate: new Date().toISOString(), @@ -94,7 +92,6 @@ describe('daf-w3c', () => { context, ) // TODO Update these after refactoring did-jwt-vc - expect(mockDidJwtVc.transformCredentialInput).toBeCalledWith(credential) expect(context.agent.identityManagerGetIdentity).toBeCalledWith({ did: mockIdentity1.did }) expect(context.agent.dataStoreSaveVerifiableCredential).toBeCalledWith('mockCredential') expect(vc).toEqual('mockCredential') @@ -102,7 +99,7 @@ describe('daf-w3c', () => { it('handles createVerifiablePresentation', async () => { const credential: VerifiableCredential = { - '@context': ['https://www.w3.org/2018/credentials/v1323'], + '@context': ['https://www.w3.org/2018/credentials/v1'], type: ['VerifiableCredential', 'PublicProfile'], issuer: { id: mockIdentity1.did }, issuanceDate: new Date().toISOString(), @@ -122,7 +119,7 @@ describe('daf-w3c', () => { } const presentation: W3CPresentation = { - '@context': ['https://www.w3.org/2018/credentials/v1323'], + '@context': ['https://www.w3.org/2018/credentials/v1'], type: ['VerifiablePresentation'], holder: mockIdentity1.did, verifier: [mockIdentity2.did], @@ -139,7 +136,6 @@ describe('daf-w3c', () => { context, ) - expect(mockDidJwtVc.transformPresentationInput).toBeCalledWith(presentation) expect(context.agent.identityManagerGetIdentity).toBeCalledWith({ did: mockIdentity1.did }) expect(context.agent.dataStoreSaveVerifiablePresentation).toBeCalledWith('mockPresentation') expect(vp).toEqual('mockPresentation') diff --git a/packages/daf-w3c/src/action-handler.ts b/packages/daf-w3c/src/action-handler.ts index 4ebda08ce..ec6093627 100644 --- a/packages/daf-w3c/src/action-handler.ts +++ b/packages/daf-w3c/src/action-handler.ts @@ -67,13 +67,12 @@ export class W3c implements IAgentPlugin { context: IContext, ): Promise { try { - const payload = transformPresentationInput(args.presentation) const identity = await context.agent.identityManagerGetIdentity({ did: args.presentation.holder }) const key = identity.keys.find(k => k.type === 'Secp256k1') - if (!key) throw Error('No signing key') + if (!key) throw Error('No signing key for ' + identity.did) const signer = (data: string) => context.agent.keyManagerSignJWT({ kid: key.kid, data }) debug('Signing VP with', identity.did) - const jwt = await createVerifiablePresentationJwt(payload, { did: identity.did, signer }) + const jwt = await createVerifiablePresentationJwt(args.presentation, { did: identity.did, signer }) debug(jwt) const presentation = normalizePresentation(jwt) if (args.save) { @@ -95,14 +94,13 @@ export class W3c implements IAgentPlugin { context: IContext, ): Promise { try { - const payload = transformCredentialInput(args.credential) const identity = await context.agent.identityManagerGetIdentity({ did: args.credential.issuer.id }) const key = identity.keys.find(k => k.type === 'Secp256k1') - if (!key) throw Error('No signing key') + if (!key) throw Error('No signing key for ' + identity.did) const signer = (data: string) => context.agent.keyManagerSignJWT({ kid: key.kid, data }) debug('Signing VC with', identity.did) - const jwt = await createVerifiableCredentialJwt(payload, { did: identity.did, signer }) + const jwt = await createVerifiableCredentialJwt(args.credential, { did: identity.did, signer }) debug(jwt) const credential = normalizeCredential(jwt) if (args.save) {