-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
215 additions
and
174 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 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
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
165 changes: 102 additions & 63 deletions
165
packages/vc-handler-ld-local/src/__tests__/statuslist.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 |
---|---|---|
@@ -1,76 +1,115 @@ | ||
import { createAgent, ICredentialPlugin, IDIDManager, IIdentifier, IKeyManager, IResolver, TAgent } from '@veramo/core' | ||
import { CredentialPlugin, ICredentialIssuer } from '@veramo/credential-w3c' | ||
import { DIDManager, MemoryDIDStore } from '@veramo/did-manager' | ||
import { getDidKeyResolver, SphereonKeyDidProvider } from '@sphereon/ssi-sdk-ext.did-provider-key' | ||
import { DIDResolverPlugin } from '@veramo/did-resolver' | ||
import { SphereonKeyManager } from '@sphereon/ssi-sdk-ext.key-manager' | ||
import { SphereonKeyManagementSystem } from '@sphereon/ssi-sdk-ext.kms-local' | ||
import { MemoryKeyStore, MemoryPrivateKeyStore } from '@veramo/key-manager' | ||
import { Resolver } from 'did-resolver' | ||
import {createAgent, ICredentialPlugin, IDIDManager, IIdentifier, IKeyManager, IResolver, TAgent} from '@veramo/core' | ||
import {CredentialPlugin, ICredentialIssuer} from '@veramo/credential-w3c' | ||
import {DIDManager, MemoryDIDStore} from '@veramo/did-manager' | ||
import {getDidKeyResolver, SphereonKeyDidProvider} from '@sphereon/ssi-sdk-ext.did-provider-key' | ||
import {DIDResolverPlugin} from '@veramo/did-resolver' | ||
import {SphereonKeyManager} from '@sphereon/ssi-sdk-ext.key-manager' | ||
import {SphereonKeyManagementSystem} from '@sphereon/ssi-sdk-ext.kms-local' | ||
import {MemoryKeyStore, MemoryPrivateKeyStore} from '@veramo/key-manager' | ||
import {Resolver} from 'did-resolver' | ||
// @ts-ignore | ||
import nock from 'nock' | ||
import { createNewStatusList } from '@sphereon/ssi-sdk.vc-status-list' | ||
import { | ||
createNewStatusList, | ||
simpleCheckStatusFromStatusListCredential, | ||
updateStatusListFromStatusListCredential | ||
} from '@sphereon/ssi-sdk.vc-status-list' | ||
import {CredentialHandlerLDLocal} from "../agent"; | ||
import {LdDefaultContexts} from "../ld-default-contexts"; | ||
import {SphereonEd25519Signature2018, SphereonEd25519Signature2020} from "../suites"; | ||
import {ICredentialHandlerLDLocal, MethodNames} from "../types"; | ||
|
||
jest.setTimeout(100000) | ||
|
||
describe.skip('Status list', () => { | ||
let didKeyIdentifier: IIdentifier | ||
let agent: TAgent<IResolver & IKeyManager & IDIDManager & ICredentialPlugin & ICredentialIssuer & ICredentialHandlerLDLocal> | ||
describe('Status list', () => { | ||
let didKeyIdentifier: IIdentifier | ||
let agent: TAgent<IResolver & IKeyManager & IDIDManager & ICredentialPlugin & ICredentialIssuer & ICredentialHandlerLDLocal> | ||
|
||
// jest.setTimeout(1000000) | ||
beforeAll(async () => { | ||
agent = createAgent({ | ||
plugins: [ | ||
new SphereonKeyManager({ | ||
store: new MemoryKeyStore(), | ||
kms: { | ||
local: new SphereonKeyManagementSystem(new MemoryPrivateKeyStore()), | ||
}, | ||
}), | ||
new DIDManager({ | ||
providers: { | ||
'did:key': new SphereonKeyDidProvider({ defaultKms: 'local' }), | ||
}, | ||
store: new MemoryDIDStore(), | ||
defaultProvider: 'did:key', | ||
}), | ||
new DIDResolverPlugin({ | ||
resolver: new Resolver({ | ||
...getDidKeyResolver(), | ||
}), | ||
}), | ||
new CredentialPlugin(), | ||
new CredentialHandlerLDLocal({ | ||
contextMaps: [LdDefaultContexts], | ||
suites: [new SphereonEd25519Signature2018(), new SphereonEd25519Signature2020()], | ||
bindingOverrides: new Map([ | ||
// Bindings to test overrides of credential-ld plugin methods | ||
['createVerifiableCredentialLD', MethodNames.createVerifiableCredentialLDLocal], | ||
['createVerifiablePresentationLD', MethodNames.createVerifiablePresentationLDLocal], | ||
// We test the verify methods by using the LDLocal versions directly in the tests | ||
]), | ||
}), | ||
], | ||
// jest.setTimeout(1000000) | ||
beforeAll(async () => { | ||
agent = createAgent({ | ||
plugins: [ | ||
new SphereonKeyManager({ | ||
store: new MemoryKeyStore(), | ||
kms: { | ||
local: new SphereonKeyManagementSystem(new MemoryPrivateKeyStore()), | ||
}, | ||
}), | ||
new DIDManager({ | ||
providers: { | ||
'did:key': new SphereonKeyDidProvider({defaultKms: 'local'}), | ||
}, | ||
store: new MemoryDIDStore(), | ||
defaultProvider: 'did:key', | ||
}), | ||
new DIDResolverPlugin({ | ||
resolver: new Resolver({ | ||
...getDidKeyResolver(), | ||
}), | ||
}), | ||
new CredentialPlugin(), | ||
new CredentialHandlerLDLocal({ | ||
contextMaps: [LdDefaultContexts], | ||
suites: [new SphereonEd25519Signature2018(), new SphereonEd25519Signature2020()], | ||
bindingOverrides: new Map([ | ||
// Bindings to test overrides of credential-ld plugin methods | ||
['createVerifiableCredentialLD', MethodNames.createVerifiableCredentialLDLocal], | ||
['createVerifiablePresentationLD', MethodNames.createVerifiablePresentationLDLocal], | ||
// We test the verify methods by using the LDLocal versions directly in the tests | ||
]), | ||
}), | ||
], | ||
}) | ||
didKeyIdentifier = await agent.didManagerCreate() | ||
}) | ||
didKeyIdentifier = await agent.didManagerCreate() | ||
}) | ||
|
||
it('create a new status list', async () => { | ||
const statusList = await createNewStatusList( | ||
{ statusPurpose: 'revocation', proofFormat: 'lds', id: 'http://localhost:9543/list1', issuer: didKeyIdentifier.did, length: 99999 }, | ||
{ agent } | ||
) | ||
expect(statusList).toBeDefined() | ||
expect(statusList.id).toEqual('http://localhost:9543/list1') | ||
expect(statusList.encodedList).toBeDefined() | ||
expect(statusList.issuer).toEqual(didKeyIdentifier.did) | ||
expect(statusList.length).toEqual(99999) | ||
expect(statusList.indexingDirection).toEqual('rightToLeft') | ||
expect(statusList.proofFormat).toEqual('lds') | ||
expect(statusList.statusListCredential).toBeDefined() | ||
}) | ||
it('create a new status list', async () => { | ||
const statusList = await createNewStatusList( | ||
{statusPurpose: 'revocation', proofFormat: 'lds', id: 'http://localhost:9543/list1', issuer: didKeyIdentifier.did, length: 99999}, | ||
{agent} | ||
) | ||
expect(statusList).toBeDefined() | ||
expect(statusList.id).toEqual('http://localhost:9543/list1') | ||
expect(statusList.encodedList).toBeDefined() | ||
expect(statusList.issuer).toEqual(didKeyIdentifier.did) | ||
expect(statusList.length).toEqual(99999) | ||
expect(statusList.indexingDirection).toEqual('rightToLeft') | ||
expect(statusList.proofFormat).toEqual('lds') | ||
expect(statusList.statusListCredential).toBeDefined() | ||
}) | ||
|
||
it('Update a status list', async () => { | ||
const initialList = await createNewStatusList( | ||
{statusPurpose: 'revocation', proofFormat: 'lds', id: 'http://localhost:9543/list2', issuer: didKeyIdentifier.did, length: 99999}, | ||
{agent} | ||
) | ||
expect(initialList).toBeDefined() | ||
|
||
let statusList = await updateStatusListFromStatusListCredential({statusListCredential: initialList.statusListCredential, index: 2, value: true}, {agent}) | ||
statusList = await updateStatusListFromStatusListCredential({statusListCredential: statusList.statusListCredential, index: 4, value: true}, {agent}) | ||
|
||
|
||
expect(statusList.id).toEqual('http://localhost:9543/list2') | ||
expect(statusList.encodedList).toBeDefined() | ||
expect(statusList.issuer).toEqual(didKeyIdentifier.did) | ||
expect(statusList.length).toEqual(99999) | ||
expect(statusList.indexingDirection).toEqual('rightToLeft') | ||
expect(statusList.proofFormat).toEqual('lds') | ||
expect(statusList.statusListCredential).toBeDefined() | ||
expect(statusList.statusListCredential).not.toEqual(initialList.statusListCredential) | ||
|
||
const result2 = await simpleCheckStatusFromStatusListCredential({statusListCredential: statusList.statusListCredential, statusListIndex: "2" }) | ||
expect(result2).toEqual(true) | ||
const result3 = await simpleCheckStatusFromStatusListCredential({statusListCredential: statusList.statusListCredential, statusListIndex: "3" }) | ||
expect(result3).toEqual(false) | ||
const result4 = await simpleCheckStatusFromStatusListCredential({statusListCredential: statusList.statusListCredential, statusListIndex: "4" }) | ||
expect(result4).toEqual(true) | ||
|
||
statusList = await updateStatusListFromStatusListCredential({statusListCredential: statusList.statusListCredential, index: 4, value: false}, {agent}) | ||
const result4Updated = await simpleCheckStatusFromStatusListCredential({statusListCredential: statusList.statusListCredential, statusListIndex: "4" }) | ||
expect(result4Updated).toEqual(false) | ||
|
||
|
||
|
||
}) | ||
}) |
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
Oops, something went wrong.