Skip to content

Commit

Permalink
feat: statuslist2021 functions
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Sep 2, 2023
1 parent 1408e15 commit 61729f3
Show file tree
Hide file tree
Showing 16 changed files with 215 additions and 174 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"@veramo/url-handler": "4.2.0",
"@sphereon/ssi-types": "workspace:^",
"@sphereon/ssi-sdk.core": "workspace:^",
"@sphereon/ssi-sdk-ext.did-provider-key": "0.14.0",
"@sphereon/ssi-sdk-ext.did-provider-key": "0.14.1-next.3",
"@noble/hashes": "1.2.0",
"did-jwt": "6.11.6",
"did-jwt-vc": "3.1.3",
Expand Down
8 changes: 4 additions & 4 deletions packages/oid4vci-issuer-rest-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
"@sphereon/did-uni-client": "^0.6.0",
"@sphereon/pex": "2.1.0",
"@sphereon/pex-models": "^2.0.3",
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.14.0",
"@sphereon/ssi-sdk-ext.key-manager": "0.14.0",
"@sphereon/ssi-sdk-ext.key-utils": "0.14.0",
"@sphereon/ssi-sdk-ext.kms-local": "0.14.0",
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.14.1-next.3",
"@sphereon/ssi-sdk-ext.key-manager": "0.14.1-next.3",
"@sphereon/ssi-sdk-ext.key-utils": "0.14.1-next.3",
"@sphereon/ssi-sdk-ext.kms-local": "0.14.1-next.3",
"@sphereon/ssi-sdk.data-store": "workspace:^",
"@sphereon/ssi-sdk.vc-handler-ld-local": "workspace:^",
"@types/body-parser": "^1.19.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/oid4vci-issuer-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"dependencies": {
"@sphereon/oid4vci-common": "0.7.0",
"@sphereon/ssi-sdk-ext.did-utils": "0.14.0",
"@sphereon/ssi-sdk-ext.did-utils": "0.14.1-next.3",
"@sphereon/ssi-sdk.kv-store-temp": "workspace:^",
"@types/uuid": "^9.0.1",
"@veramo/core": "4.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/oid4vci-issuer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@sphereon/oid4vci-common": "0.7.0",
"@sphereon/oid4vci-issuer": "0.7.0",
"@sphereon/ssi-sdk-ext.did-utils": "0.14.0",
"@sphereon/ssi-sdk-ext.did-utils": "0.14.1-next.3",
"@sphereon/ssi-sdk.core": "workspace:^",
"@sphereon/ssi-sdk.kv-store-temp": "workspace:^",
"@sphereon/ssi-sdk.oid4vci-issuer-store": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion packages/presentation-exchange/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@sphereon/pex": "2.1.0",
"@sphereon/pex-models": "^2.0.3",
"@sphereon/ssi-sdk-ext.did-utils": "0.14.0",
"@sphereon/ssi-sdk-ext.did-utils": "0.14.1-next.3",
"@sphereon/ssi-sdk.kv-store-temp": "workspace:^",
"@sphereon/ssi-types": "workspace:^",
"@veramo/core": "4.2.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/siopv2-oid4vp-op-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@sphereon/did-auth-siop": "0.3.2-unstable.8",
"@sphereon/pex": "2.1.0",
"@sphereon/pex-models": "2.0.2",
"@sphereon/ssi-sdk-ext.did-utils": "0.14.0",
"@sphereon/ssi-sdk-ext.did-utils": "0.14.1-next.3",
"@sphereon/ssi-sdk.core": "workspace:^",
"@sphereon/ssi-sdk.presentation-exchange": "workspace:^",
"@sphereon/ssi-types": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion packages/siopv2-oid4vp-rp-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@sphereon/did-auth-siop": "0.3.2-unstable.8",
"@sphereon/pex": "2.1.0",
"@sphereon/ssi-sdk-ext.did-utils": "0.14.0",
"@sphereon/ssi-sdk-ext.did-utils": "0.14.1-next.3",
"@sphereon/ssi-sdk.core": "workspace:^",
"@sphereon/ssi-sdk.kv-store-temp": "workspace:^",
"@sphereon/ssi-sdk.presentation-exchange": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion packages/siopv2-oid4vp-rp-rest-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@sphereon/did-uni-client": "^0.6.0",
"@sphereon/pex": "2.1.0",
"@sphereon/pex-models": "^2.0.3",
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.14.0",
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.14.1-next.3",
"@sphereon/ssi-sdk.data-store": "workspace:^",
"@sphereon/ssi-sdk.vc-handler-ld-local": "workspace:^",
"@types/body-parser": "^1.19.2",
Expand Down
10 changes: 5 additions & 5 deletions packages/uni-resolver-registrar-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
},
"dependencies": {
"@sphereon/ssi-express-support": "workspace:^",
"@sphereon/ssi-sdk-ext.did-utils": "0.14.0",
"@sphereon/ssi-sdk-ext.key-manager": "0.14.0",
"@sphereon/ssi-sdk-ext.key-utils": "0.14.0",
"@sphereon/ssi-sdk-ext.did-utils": "0.14.1-next.3",
"@sphereon/ssi-sdk-ext.key-manager": "0.14.1-next.3",
"@sphereon/ssi-sdk-ext.key-utils": "0.14.1-next.3",
"@sphereon/ssi-sdk.core": "workspace:^",
"@sphereon/ssi-types": "workspace:^",
"@veramo/core": "4.2.0",
Expand All @@ -31,8 +31,8 @@
},
"devDependencies": {
"@sphereon/did-uni-client": "^0.6.0",
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.14.0",
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.14.0",
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.14.1-next.3",
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.14.1-next.3",
"@sphereon/ssi-sdk.data-store": "workspace:^",
"@sphereon/ssi-sdk.vc-handler-ld-local": "workspace:^",
"@types/body-parser": "^1.19.2",
Expand Down
12 changes: 6 additions & 6 deletions packages/vc-handler-ld-local/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"@noble/hashes": "^1.2.0",
"@sphereon/ed25519-signature-2018": "0.7.0-unstable.6",
"@sphereon/isomorphic-webcrypto": "^2.4.0-unstable.4",
"@sphereon/ssi-sdk-ext.did-utils": "0.14.0",
"@sphereon/ssi-sdk-ext.key-utils": "0.14.0",
"@sphereon/ssi-sdk-ext.did-utils": "0.14.1-next.3",
"@sphereon/ssi-sdk-ext.key-utils": "0.14.1-next.3",
"@sphereon/ssi-sdk.vc-status-list": "workspace:^",
"@sphereon/ssi-sdk.core": "workspace:^",
"@sphereon/ssi-types": "workspace:^",
Expand All @@ -53,10 +53,10 @@
},
"devDependencies": {
"@sphereon/did-uni-client": "^0.6.0",
"@sphereon/ssi-sdk-ext.did-provider-key": "0.14.0",
"@sphereon/ssi-sdk-ext.did-provider-lto": "0.14.0",
"@sphereon/ssi-sdk-ext.key-manager": "0.14.0",
"@sphereon/ssi-sdk-ext.kms-local": "0.14.0",
"@sphereon/ssi-sdk-ext.did-provider-key": "0.14.1-next.3",
"@sphereon/ssi-sdk-ext.did-provider-lto": "0.14.1-next.3",
"@sphereon/ssi-sdk-ext.key-manager": "0.14.1-next.3",
"@sphereon/ssi-sdk-ext.kms-local": "0.14.1-next.3",
"@sphereon/ssi-sdk.agent-config": "workspace:^",
"@transmute/lds-ecdsa-secp256k1-recovery2020": "^0.0.7",
"@types/nock": "^11.1.0",
Expand Down
165 changes: 102 additions & 63 deletions packages/vc-handler-ld-local/src/__tests__/statuslist.test.ts
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)



})
})
4 changes: 2 additions & 2 deletions packages/vc-status-list/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@sphereon/ssi-sdk.vc-status-list",
"description": "Sphereon SSI-SDK plugin for Status List management, like StatusList2021.",
"version": "0.14.0",
"version": "0.14.1-next.3",
"source": "src/index.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -12,7 +12,7 @@
"dependencies": {
"@digitalcredentials/vc-status-list": "^5.0.2",
"@veramo/core": "4.2.0",
"@sphereon/ssi-sdk-ext.did-utils": "^0.14.0",
"@sphereon/ssi-sdk-ext.did-utils": "^0.14.1-next.3",
"@sphereon/ssi-types": "workspace:^",
"debug": "^4.3.4",
"uint8arrays": "^3.1.1"
Expand Down
6 changes: 3 additions & 3 deletions packages/vc-status-list/src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export async function simpleCheckStatusFromStatusListCredential(args: {
} else if (args.id && args.id !== id) {
throw Error(`Status list id ${id} did not match required supplied id: ${args.id}`)
}
if (!type || !type.includes(requestedType)) {
if (!type || !(type.includes(requestedType) || type.includes(requestedType + 'Credential'))) {
throw Error(`Credential type ${JSON.stringify(type)} does not contain requested type ${requestedType}`)
}
// @ts-ignore
Expand Down Expand Up @@ -186,7 +186,7 @@ export async function updateStatusListFromEncodedList(
return {
encodedList,
statusListCredential,
length: statusList.length,
length: statusList.length - 1,
type,
proofFormat,
id,
Expand Down Expand Up @@ -238,7 +238,7 @@ function getAssertedStatusListType(type?: StatusListType) {
}

function getAssertedValue<T>(name: string, value: T): NonNullable<T> {
if (!value) {
if (value === undefined || value === null) {
throw Error(`Missing required ${name} value`)
}
return value
Expand Down
4 changes: 2 additions & 2 deletions packages/w3c-vc-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
},
"devDependencies": {
"@sphereon/did-uni-client": "^0.6.0",
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.14.0",
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.14.0",
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.14.1-next.3",
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.14.1-next.3",
"@sphereon/ssi-sdk.data-store": "workspace:^",
"@sphereon/ssi-sdk.vc-handler-ld-local": "workspace:^",
"@types/body-parser": "^1.19.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/web3-provider-headless/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"web3-validator": "^2.0.0"
},
"devDependencies": {
"@sphereon/ssi-sdk-ext.key-manager": "^0.14.0",
"@sphereon/ssi-sdk-ext.kms-local": "^0.14.0",
"@sphereon/ssi-sdk-ext.key-manager": "^0.14.1-next.3",
"@sphereon/ssi-sdk-ext.kms-local": "^0.14.1-next.3",
"@types/body-parser": "^1.19.2",
"@types/cors": "^2.8.13",
"@types/dotenv-flow": "^3.2.0",
Expand Down
Loading

0 comments on commit 61729f3

Please sign in to comment.