-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Reinstate
credentialStatus
as top level attribute
it needs to exist for presentations as well
- Loading branch information
1 parent
92e285e
commit 4b17689
Showing
7 changed files
with
149 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
packages/daf-w3c/src/__tests__/credentialStatus.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import { W3cActionHandler, ActionTypes, ActionSignW3cVc } from '../index' | ||
import { SimpleSigner } from 'did-jwt' | ||
import { Resolver } from 'did-resolver' | ||
import { ActionSignW3cVp } from '../action-handler' | ||
|
||
const privateKey = 'a285ab66393c5fdda46d6fbad9e27fafd438254ab72ad5acb681a0e9f20f5d7b' | ||
const signerAddress = '0x2036c6cd85692f0fb2c26e6c6b2eced9e4478dfd' | ||
const mockDid: string = `did:ethr:${signerAddress}` | ||
|
||
const mockAgent = { | ||
identityManager: { | ||
getIdentity: async (did: string) => ({ | ||
did: mockDid, | ||
keyByType: async (type: string) => ({ | ||
signer: () => { | ||
return SimpleSigner(privateKey) | ||
}, | ||
}), | ||
}), | ||
}, | ||
didResolver: { | ||
resolve: async (did: string) => { | ||
return { | ||
'@context': 'https://w3id.org/did/v1', | ||
id: 'did:ethr:rinkeby:0x42ba71c59a22a037e54f8d5b13d7b3721daa18c3', | ||
publicKey: [ | ||
{ | ||
id: 'did:ethr:rinkeby:0x42ba71c59a22a037e54f8d5b13d7b3721daa18c3#owner', | ||
type: 'Secp256k1VerificationKey2018', | ||
owner: 'did:ethr:rinkeby:0x42ba71c59a22a037e54f8d5b13d7b3721daa18c3', | ||
ethereumAddress: '0x42ba71c59a22a037e54f8d5b13d7b3721daa18c3', | ||
}, | ||
], | ||
authentication: [ | ||
{ | ||
type: 'Secp256k1SignatureAuthentication2018', | ||
publicKey: 'did:ethr:rinkeby:0x42ba71c59a22a037e54f8d5b13d7b3721daa18c3#owner', | ||
}, | ||
], | ||
} | ||
}, | ||
}, | ||
} | ||
|
||
describe('daf-w3c', () => { | ||
// it('handles signing a presentation with credentialStatus', async () => { | ||
// expect.assertions(1) | ||
|
||
// const actionHandler = new W3cActionHandler() | ||
|
||
// const data = { | ||
// issuer: mockDid, | ||
// audience: 'did:web:uport.me', | ||
// '@context': ['https://www.w3.org/2018/credentials/v1'], | ||
// type: ['VerifiablePresentation'], | ||
// verifiableCredential: ['eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NkstUiJ9.eyJpYXQiOjE1ODU4MTEyNTksInN1YiI6ImRpZDp3ZWI6dXBvcnQubWUiLCJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIl0sImNyZWRlbnRpYWxTdWJqZWN0Ijp7Im5hbWUiOiJCb2IifX0sImlzcyI6ImRpZDpldGhyOnJpbmtlYnk6MHg0MmJhNzFjNTlhMjJhMDM3ZTU0ZjhkNWIxM2Q3YjM3MjFkYWExOGMzIn0.lSuP2V-xr0RaW-M_egBXnhv0cUuM7Vp54wz1A_f3zCXjR7-bcfk1HqvweQsX-m7mXx9J9sn2vNS6YcJhWk2oBAE'], | ||
// credentialStatus: { | ||
// type: 'TestStatusMethod', | ||
// id: 'local' | ||
// } | ||
// } | ||
|
||
// let result = await actionHandler.handleAction( | ||
// { | ||
// type: ActionTypes.signPresentationJwt, | ||
// data, | ||
// } as ActionSignW3cVp, | ||
// mockAgent as any, | ||
// ) | ||
|
||
// console.log("gigel", result) | ||
|
||
// expect(result.credentialStatus).toMatchObject({ type: 'TestStatusMethod', id: 'local' }) | ||
// }) | ||
|
||
it('handles sign.w3c.vc.jwt with credentialStatus', async () => { | ||
// expect.assertions(1) | ||
|
||
const actionHandler = new W3cActionHandler() | ||
|
||
const data = { | ||
issuer: mockDid, | ||
'@context': ['https://www.w3.org/2018/credentials/v1'], | ||
type: ['VerifiableCredential'], | ||
credentialSubject: { | ||
id: 'did:web:uport.me', | ||
you: 'Rock', | ||
}, | ||
credentialStatus: { | ||
type: 'TestStatusMethod', | ||
id: 'local', | ||
}, | ||
} | ||
|
||
let result = await actionHandler.handleAction( | ||
{ | ||
type: ActionTypes.signCredentialJwt, | ||
data, | ||
} as ActionSignW3cVc, | ||
mockAgent as any, | ||
) | ||
|
||
expect(result.credentialStatus).toMatchObject({ type: 'TestStatusMethod', id: 'local' }) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3929,10 +3929,10 @@ [email protected]: | |
dependencies: | ||
streamsearch "0.1.2" | ||
|
||
did-jwt-vc@^0.1.6: | ||
version "0.1.6" | ||
resolved "https://registry.yarnpkg.com/did-jwt-vc/-/did-jwt-vc-0.1.6.tgz#e07900c55bd56f90ab3868d96f03d9ae008fd0a2" | ||
integrity sha512-sRqUlCYKTygJ45aH0A5GSEH76NhCxIRoDIqty+pCu1KhxUbXxJgpY8+TTfffjdlitXZKt3m9Twh4LSCJpW920Q== | ||
did-jwt-vc@0.2.0: | ||
version "0.2.0" | ||
resolved "https://registry.yarnpkg.com/did-jwt-vc/-/did-jwt-vc-0.2.0.tgz#a3592217622d4eccbe1c6b2ea68ba41fe79d7e5d" | ||
integrity sha512-YlIXA3GLryD9nlHOUAzYaU6UMVvZ3103HVBILuGLvRTnE9YVmlfc6nMuYOcIzbgLW2P8pZgIgZsyEFzRdkDRFg== | ||
dependencies: | ||
did-jwt "^4.3.2" | ||
|
||
|