-
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: Unique (with hash) VC/VP in ORM results
- Loading branch information
1 parent
8496e99
commit bcfc3e8
Showing
66 changed files
with
2,018 additions
and
575 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
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 was deleted.
Oops, something went wrong.
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,103 @@ | ||
import { TAgent, IIdentityManager, IIdentity, IDataStore } from '../../packages/daf-core/src' | ||
import { IDataStoreORM } from '../../packages/daf-typeorm/src' | ||
import { ICredentialIssuer } from '../../packages/daf-w3c/src' | ||
|
||
type ConfiguredAgent = TAgent<IIdentityManager & ICredentialIssuer & IDataStore & IDataStoreORM> | ||
|
||
export default (testContext: { | ||
getAgent: () => ConfiguredAgent | ||
setup: () => Promise<boolean> | ||
tearDown: () => Promise<boolean> | ||
}) => { | ||
describe('creating Verifiable Credentials', () => { | ||
let agent: ConfiguredAgent | ||
let identity: IIdentity | ||
|
||
beforeAll(() => { | ||
testContext.setup() | ||
agent = testContext.getAgent() | ||
}) | ||
afterAll(testContext.tearDown) | ||
|
||
it('should create identity', async () => { | ||
identity = await agent.identityManagerCreateIdentity({ kms: 'local' }) | ||
expect(identity).toHaveProperty('did') | ||
}) | ||
|
||
it('should create verifiable credential', async () => { | ||
const verifiableCredential = await agent.createVerifiableCredential({ | ||
credential: { | ||
issuer: { id: identity.did }, | ||
'@context': ['https://www.w3.org/2018/credentials/v1'], | ||
type: ['VerifiableCredential'], | ||
issuanceDate: new Date().toISOString(), | ||
credentialSubject: { | ||
id: 'did:web:example.com', | ||
you: 'Rock', | ||
}, | ||
}, | ||
proofFormat: 'jwt', | ||
}) | ||
|
||
expect(verifiableCredential).toHaveProperty('proof.jwt') | ||
|
||
const hash = await agent.dataStoreSaveVerifiableCredential({ verifiableCredential }) | ||
expect(typeof hash).toEqual('string') | ||
|
||
const verifiableCredential2 = await agent.dataStoreGetVerifiableCredential({ hash }) | ||
expect(verifiableCredential).toEqual(verifiableCredential2) | ||
}) | ||
|
||
it('should create verifiable presentation', async () => { | ||
const verifiableCredential = await agent.createVerifiableCredential({ | ||
credential: { | ||
issuer: { id: identity.did }, | ||
'@context': ['https://www.w3.org/2018/credentials/v1'], | ||
type: ['VerifiableCredential'], | ||
issuanceDate: new Date().toISOString(), | ||
credentialSubject: { | ||
id: 'did:web:example.com', | ||
you: 'Rock', | ||
}, | ||
}, | ||
proofFormat: 'jwt', | ||
}) | ||
|
||
const verifiablePresentation = await agent.createVerifiablePresentation({ | ||
presentation: { | ||
holder: identity.did, | ||
verifier: [], | ||
'@context': ['https://www.w3.org/2018/credentials/v1'], | ||
type: ['VerifiablePresentation'], | ||
issuanceDate: new Date().toISOString(), | ||
verifiableCredential: [verifiableCredential], | ||
}, | ||
proofFormat: 'jwt', | ||
}) | ||
|
||
expect(verifiablePresentation).toHaveProperty('proof.jwt') | ||
|
||
const hash = await agent.dataStoreSaveVerifiablePresentation({ verifiablePresentation }) | ||
expect(typeof hash).toEqual('string') | ||
|
||
const verifiablePresentation2 = await agent.dataStoreGetVerifiablePresentation({ hash }) | ||
expect(verifiablePresentation).toEqual(verifiablePresentation2) | ||
}) | ||
|
||
it('should query for credentials', async () => { | ||
const allCredentials = await agent.dataStoreORMGetVerifiableCredentials({}) | ||
expect(allCredentials[0]).toHaveProperty('hash') | ||
expect(allCredentials[0]).toHaveProperty('verifiableCredential') | ||
const credentialCount = await agent.dataStoreORMGetVerifiableCredentialsCount() | ||
expect(allCredentials.length).toEqual(credentialCount) | ||
}) | ||
|
||
it('should query for presentations', async () => { | ||
const allPresentations = await agent.dataStoreORMGetVerifiablePresentations({}) | ||
expect(allPresentations[0]).toHaveProperty('hash') | ||
expect(allPresentations[0]).toHaveProperty('verifiablePresentation') | ||
const presentationCount = await agent.dataStoreORMGetVerifiablePresentationsCount() | ||
expect(allPresentations.length).toEqual(presentationCount) | ||
}) | ||
}) | ||
} |
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,26 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [daf-core](./daf-core.md) > [IDataStore](./daf-core.idatastore.md) > [dataStoreGetMessage](./daf-core.idatastore.datastoregetmessage.md) | ||
|
||
## IDataStore.dataStoreGetMessage() method | ||
|
||
Gets message from the data store | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
dataStoreGetMessage(args: IDataStoreGetMessageArgs): Promise<IMessage>; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| args | [IDataStoreGetMessageArgs](./daf-core.idatastoregetmessageargs.md) | arguments for getting message | | ||
|
||
<b>Returns:</b> | ||
|
||
Promise<[IMessage](./daf-core.imessage.md)<!-- -->> | ||
|
||
a promise that resolves to the message | ||
|
26 changes: 26 additions & 0 deletions
26
docs/api/daf-core.idatastore.datastoregetverifiablecredential.md
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,26 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [daf-core](./daf-core.md) > [IDataStore](./daf-core.idatastore.md) > [dataStoreGetVerifiableCredential](./daf-core.idatastore.datastoregetverifiablecredential.md) | ||
|
||
## IDataStore.dataStoreGetVerifiableCredential() method | ||
|
||
Gets verifiable credential from the data store | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
dataStoreGetVerifiableCredential(args: IDataStoreGetVerifiableCredentialArgs): Promise<VerifiableCredential>; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| args | [IDataStoreGetVerifiableCredentialArgs](./daf-core.idatastoregetverifiablecredentialargs.md) | arguments for getting verifiable credential | | ||
|
||
<b>Returns:</b> | ||
|
||
Promise<[VerifiableCredential](./daf-core.verifiablecredential.md)<!-- -->> | ||
|
||
a promise that resolves to the verifiable credential | ||
|
26 changes: 26 additions & 0 deletions
26
docs/api/daf-core.idatastore.datastoregetverifiablepresentation.md
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,26 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [daf-core](./daf-core.md) > [IDataStore](./daf-core.idatastore.md) > [dataStoreGetVerifiablePresentation](./daf-core.idatastore.datastoregetverifiablepresentation.md) | ||
|
||
## IDataStore.dataStoreGetVerifiablePresentation() method | ||
|
||
Gets verifiable presentation from the data store | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
dataStoreGetVerifiablePresentation(args: IDataStoreGetVerifiablePresentationArgs): Promise<VerifiablePresentation>; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| args | [IDataStoreGetVerifiablePresentationArgs](./daf-core.idatastoregetverifiablepresentationargs.md) | arguments for getting Verifiable Presentation | | ||
|
||
<b>Returns:</b> | ||
|
||
Promise<[VerifiablePresentation](./daf-core.verifiablepresentation.md)<!-- -->> | ||
|
||
a promise that resolves to the Verifiable Presentation | ||
|
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
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,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [daf-core](./daf-core.md) > [IDataStoreGetMessageArgs](./daf-core.idatastoregetmessageargs.md) > [id](./daf-core.idatastoregetmessageargs.id.md) | ||
|
||
## IDataStoreGetMessageArgs.id property | ||
|
||
Required. Message ID | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
id: string; | ||
``` |
Oops, something went wrong.