@sphereon/ssi-sdk.data-store 0.34.1-feature.SSISDK.26.RP.58 → 0.34.1-feature.SSISDK.45.189
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1616 -1477
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +187 -194
- package/dist/index.d.ts +187 -194
- package/dist/index.js +1582 -1443
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/__tests__/contact.entities.test.ts +2 -2
- package/src/__tests__/contact.store.test.ts +1 -1
- package/src/__tests__/digitalCredential.entities.test.ts +2 -1
- package/src/__tests__/digitalCredential.store.test.ts +5 -5
- package/src/__tests__/pd-manager.entities.test.ts +27 -98
- package/src/__tests__/pd-manager.store.test.ts +151 -101
- package/src/digitalCredential/DigitalCredentialStore.ts +9 -9
- package/src/entities/contact/IdentityEntity.ts +2 -1
- package/src/entities/digitalCredential/DigitalCredentialEntity.ts +2 -1
- package/src/entities/presentationDefinition/{PresentationDefinitionItemEntity.ts → DcqlQueryItemEntity.ts} +8 -12
- package/src/index.ts +3 -3
- package/src/migrations/generic/12-CreateBitstringStatusList.ts +32 -2
- package/src/migrations/generic/13-CreateDcqlQueryItem.ts +67 -0
- package/src/migrations/generic/index.ts +10 -5
- package/src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts +1 -1
- package/src/migrations/postgres/1726588800000-CreateDcqlQueryItem.ts +25 -0
- package/src/migrations/postgres/1737110469001-UpdateStatusList.ts +1 -1
- package/src/migrations/postgres/1741895823000-CreateBitstringStatusList.ts +15 -2
- package/src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts +1 -1
- package/src/migrations/sqlite/1726617600000-CreateDcqlQueryItem.ts +24 -0
- package/src/presentationDefinition/AbstractPDStore.ts +5 -5
- package/src/presentationDefinition/PDStore.ts +40 -40
- package/src/types/contact/contact.ts +1 -1
- package/src/types/digitalCredential/IAbstractDigitalCredentialStore.ts +2 -1
- package/src/types/digitalCredential/enums.ts +0 -7
- package/src/types/digitalCredential/types.ts +2 -1
- package/src/types/presentationDefinition/IAbstractPDStore.ts +5 -5
- package/src/types/presentationDefinition/presentationDefinition.ts +8 -9
- package/src/utils/presentationDefinition/MappingUtils.ts +31 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.data-store",
|
|
3
|
-
"version": "0.34.1-feature.SSISDK.
|
|
3
|
+
"version": "0.34.1-feature.SSISDK.45.189+b7e0c23f",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -28,16 +28,16 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@sphereon/kmp-mdoc-core": "0.2.0-SNAPSHOT.26",
|
|
30
30
|
"@sphereon/pex": "5.0.0-unstable.28",
|
|
31
|
-
"@sphereon/ssi-sdk-ext.did-utils": "0.34.1-feature.SSISDK.
|
|
32
|
-
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.34.1-feature.SSISDK.
|
|
33
|
-
"@sphereon/ssi-sdk.agent-config": "0.34.1-feature.SSISDK.
|
|
34
|
-
"@sphereon/ssi-sdk.core": "0.34.1-feature.SSISDK.
|
|
35
|
-
"@sphereon/ssi-types": "0.34.1-feature.SSISDK.
|
|
31
|
+
"@sphereon/ssi-sdk-ext.did-utils": "0.34.1-feature.SSISDK.45.189+b7e0c23f",
|
|
32
|
+
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.34.1-feature.SSISDK.45.189+b7e0c23f",
|
|
33
|
+
"@sphereon/ssi-sdk.agent-config": "0.34.1-feature.SSISDK.45.189+b7e0c23f",
|
|
34
|
+
"@sphereon/ssi-sdk.core": "0.34.1-feature.SSISDK.45.189+b7e0c23f",
|
|
35
|
+
"@sphereon/ssi-types": "0.34.1-feature.SSISDK.45.189+b7e0c23f",
|
|
36
36
|
"@veramo/core": "4.2.0",
|
|
37
37
|
"@veramo/utils": "4.2.0",
|
|
38
38
|
"blakejs": "^1.2.1",
|
|
39
39
|
"class-validator": "0.14.1",
|
|
40
|
-
"dcql": "0.
|
|
40
|
+
"dcql": "1.0.1",
|
|
41
41
|
"debug": "^4.3.5",
|
|
42
42
|
"typeorm": "0.3.20"
|
|
43
43
|
},
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"PostgreSQL",
|
|
66
66
|
"Contact Store"
|
|
67
67
|
],
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "b7e0c23f77ccaa650fc21d52315e28de54f38188"
|
|
69
69
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { getDID } from '@sphereon/ssi-sdk-ext.did-utils'
|
|
2
2
|
import { DataSources } from '@sphereon/ssi-sdk.agent-config'
|
|
3
|
+
import { CredentialRole } from '@sphereon/ssi-types'
|
|
3
4
|
import { DataSource, FindOptionsWhere } from 'typeorm'
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
4
6
|
import { BaseContactEntity } from '../entities/contact/BaseContactEntity'
|
|
5
7
|
import { ConnectionEntity } from '../entities/contact/ConnectionEntity'
|
|
6
8
|
import { ContactMetadataItemEntity } from '../entities/contact/ContactMetadataItemEntity'
|
|
@@ -18,7 +20,6 @@ import { PartyTypeEntity } from '../entities/contact/PartyTypeEntity'
|
|
|
18
20
|
import { PhysicalAddressEntity } from '../entities/contact/PhysicalAddressEntity'
|
|
19
21
|
import {
|
|
20
22
|
contactMetadataItemEntityFrom,
|
|
21
|
-
CredentialRole,
|
|
22
23
|
DataStoreContactEntities,
|
|
23
24
|
DataStoreMigrations,
|
|
24
25
|
identityMetadataItemEntityFrom,
|
|
@@ -57,7 +58,6 @@ import {
|
|
|
57
58
|
partyTypeEntityFrom,
|
|
58
59
|
physicalAddressEntityFrom,
|
|
59
60
|
} from '../utils/contact/MappingUtils'
|
|
60
|
-
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
61
61
|
// TODO write test adding two contacts reusing the same contactType
|
|
62
62
|
|
|
63
63
|
describe('Database entities tests', (): void => {
|
|
@@ -4,7 +4,6 @@ import { ConnectionType, DataStoreContactEntities, DataStoreMigrations, Identity
|
|
|
4
4
|
import { ContactStore } from '../contact/ContactStore'
|
|
5
5
|
import {
|
|
6
6
|
CorrelationIdentifierType,
|
|
7
|
-
CredentialRole,
|
|
8
7
|
ElectronicAddress,
|
|
9
8
|
GetElectronicAddressesArgs,
|
|
10
9
|
GetIdentitiesArgs,
|
|
@@ -27,6 +26,7 @@ import {
|
|
|
27
26
|
PhysicalAddress,
|
|
28
27
|
} from '../types'
|
|
29
28
|
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
29
|
+
import { CredentialRole } from "@sphereon/ssi-types"
|
|
30
30
|
|
|
31
31
|
describe('Contact store tests', (): void => {
|
|
32
32
|
let dbConnection: DataSource
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DataSources } from '@sphereon/ssi-sdk.agent-config'
|
|
2
|
+
import { CredentialRole } from '@sphereon/ssi-types'
|
|
2
3
|
import { DataSource } from 'typeorm'
|
|
3
|
-
import {
|
|
4
|
+
import { DataStoreDigitalCredentialEntities } from '../index'
|
|
4
5
|
import { DataStoreDigitalCredentialMigrations } from '../migrations'
|
|
5
6
|
import { DigitalCredentialEntity } from '../entities/digitalCredential/DigitalCredentialEntity'
|
|
6
7
|
import { computeEntryHash } from '@veramo/utils'
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { DataSources } from '@sphereon/ssi-sdk.agent-config'
|
|
2
|
-
import {
|
|
2
|
+
import { defaultHasher } from '@sphereon/ssi-sdk.core'
|
|
3
|
+
import { CredentialRole, IVerifiablePresentation } from '@sphereon/ssi-types'
|
|
3
4
|
import { DataSource } from 'typeorm'
|
|
4
|
-
import {
|
|
5
|
-
import { CredentialRole, DataStoreDigitalCredentialEntities } from '../index'
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
6
6
|
import { DigitalCredentialStore } from '../digitalCredential/DigitalCredentialStore'
|
|
7
|
+
import { DataStoreDigitalCredentialEntities } from '../index'
|
|
8
|
+
import { DataStoreDigitalCredentialMigrations } from '../migrations'
|
|
7
9
|
import {
|
|
8
10
|
AddCredentialArgs,
|
|
9
11
|
CredentialCorrelationType,
|
|
@@ -14,8 +16,6 @@ import {
|
|
|
14
16
|
GetCredentialsArgs,
|
|
15
17
|
GetCredentialsResponse,
|
|
16
18
|
} from '../types'
|
|
17
|
-
import { defaultHasher } from '@sphereon/ssi-sdk.core'
|
|
18
|
-
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
19
19
|
|
|
20
20
|
describe('Database entities tests', (): void => {
|
|
21
21
|
let dbConnection: DataSource
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { DataSources } from '@sphereon/ssi-sdk.agent-config'
|
|
2
2
|
import { DataSource } from 'typeorm'
|
|
3
|
-
import { PresentationDefinitionItemEntity } from '../entities/presentationDefinition/PresentationDefinitionItemEntity'
|
|
4
|
-
import { DataStorePresentationDefinitionMigrations } from '../migrations'
|
|
5
|
-
import { DataStorePresentationDefinitionEntities } from '../index'
|
|
6
3
|
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
4
|
+
import { DcqlQueryItemEntity } from '../entities/presentationDefinition/DcqlQueryItemEntity'
|
|
5
|
+
import { DataStorePresentationDefinitionEntities } from '../index'
|
|
6
|
+
import { DataStorePresentationDefinitionMigrations } from '../migrations'
|
|
7
|
+
import { SAMPLE_DCQL_QUERY_IMPORT } from './pd-manager.store.test'
|
|
7
8
|
|
|
8
|
-
describe('
|
|
9
|
+
describe('DcqlQueryItemEntity tests', (): void => {
|
|
9
10
|
let dbConnection: DataSource
|
|
10
11
|
|
|
11
12
|
beforeEach(async (): Promise<void> => {
|
|
@@ -25,59 +26,34 @@ describe('PresentationDefinitionItemEntity tests', (): void => {
|
|
|
25
26
|
await dbConnection.destroy()
|
|
26
27
|
})
|
|
27
28
|
|
|
28
|
-
it('should create and retrieve
|
|
29
|
-
const repository = dbConnection.getRepository(
|
|
30
|
-
const entity = new
|
|
31
|
-
entity.
|
|
29
|
+
it('should create and retrieve DcqlQueryItemEntity', async (): Promise<void> => {
|
|
30
|
+
const repository = dbConnection.getRepository(DcqlQueryItemEntity)
|
|
31
|
+
const entity = new DcqlQueryItemEntity()
|
|
32
|
+
entity.queryId = 'ajax-club'
|
|
32
33
|
entity.version = '1.0'
|
|
33
|
-
entity.
|
|
34
|
-
entity.dcqlPayload = JSON.stringify({
|
|
35
|
-
credentials: [
|
|
36
|
-
{
|
|
37
|
-
id: 'credential1',
|
|
38
|
-
format: 'jwt_vc',
|
|
39
|
-
claims: [
|
|
40
|
-
{
|
|
41
|
-
namespace: 'test',
|
|
42
|
-
claim_name: 'testClaim',
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
})
|
|
34
|
+
entity.query = JSON.stringify(SAMPLE_DCQL_QUERY_IMPORT.query)
|
|
48
35
|
|
|
49
36
|
const savedEntity = await repository.save(entity)
|
|
50
37
|
expect(savedEntity).toBeDefined()
|
|
51
38
|
expect(savedEntity.id).toBeDefined()
|
|
52
|
-
expect(savedEntity.
|
|
39
|
+
expect(savedEntity.query).toBeDefined()
|
|
53
40
|
|
|
54
41
|
const retrievedEntity = await repository.findOneBy({ id: savedEntity.id })
|
|
55
42
|
expect(retrievedEntity).toBeDefined()
|
|
56
|
-
expect(retrievedEntity!.
|
|
57
|
-
const parsedDcql = JSON.parse(retrievedEntity!.
|
|
58
|
-
expect(parsedDcql.credentials[0].id).toEqual('
|
|
43
|
+
expect(retrievedEntity!.query).toBeDefined()
|
|
44
|
+
const parsedDcql = JSON.parse(retrievedEntity!.query)
|
|
45
|
+
expect(parsedDcql.credentials[0].id).toEqual('clubcard-v1')
|
|
46
|
+
expect(parsedDcql.credentials[0].format).toEqual('dc+sd-jwt')
|
|
47
|
+
expect(parsedDcql.credentials[0].meta.vct_values).toContain('clubcard-v1')
|
|
48
|
+
expect(parsedDcql.credentials[0].claims).toHaveLength(4)
|
|
59
49
|
})
|
|
60
50
|
|
|
61
|
-
it('should update
|
|
62
|
-
const repository = dbConnection.getRepository(
|
|
63
|
-
const entity = new
|
|
64
|
-
entity.
|
|
51
|
+
it('should update DcqlQueryItemEntity dcql query', async (): Promise<void> => {
|
|
52
|
+
const repository = dbConnection.getRepository(DcqlQueryItemEntity)
|
|
53
|
+
const entity = new DcqlQueryItemEntity()
|
|
54
|
+
entity.queryId = 'ajax-club'
|
|
65
55
|
entity.version = '1.0'
|
|
66
|
-
entity.
|
|
67
|
-
entity.dcqlPayload = JSON.stringify({
|
|
68
|
-
credentials: [
|
|
69
|
-
{
|
|
70
|
-
id: 'credential1',
|
|
71
|
-
format: 'jwt_vc',
|
|
72
|
-
claims: [
|
|
73
|
-
{
|
|
74
|
-
namespace: 'test',
|
|
75
|
-
claim_name: 'testClaim',
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
})
|
|
56
|
+
entity.query = JSON.stringify(SAMPLE_DCQL_QUERY_IMPORT.query)
|
|
81
57
|
|
|
82
58
|
const savedEntity = await repository.save(entity)
|
|
83
59
|
expect(savedEntity).toBeDefined()
|
|
@@ -85,67 +61,20 @@ describe('PresentationDefinitionItemEntity tests', (): void => {
|
|
|
85
61
|
const updatedDcql = {
|
|
86
62
|
credentials: [
|
|
87
63
|
{
|
|
88
|
-
id: '
|
|
64
|
+
id: 'updated-clubcard',
|
|
89
65
|
format: 'jwt_vc',
|
|
90
66
|
claims: [
|
|
91
67
|
{
|
|
92
|
-
|
|
93
|
-
claim_name: 'updatedClaim',
|
|
68
|
+
path: ['name'],
|
|
94
69
|
},
|
|
95
70
|
],
|
|
96
71
|
},
|
|
97
72
|
],
|
|
98
73
|
}
|
|
99
|
-
savedEntity.
|
|
74
|
+
savedEntity.query = JSON.stringify(updatedDcql)
|
|
100
75
|
const updatedEntity = await repository.save(savedEntity)
|
|
101
76
|
expect(updatedEntity).toBeDefined()
|
|
102
|
-
expect(JSON.parse(updatedEntity.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
it('should create and retrieve PresentationDefinitionItemEntity', async (): Promise<void> => {
|
|
106
|
-
const repository = dbConnection.getRepository(PresentationDefinitionItemEntity)
|
|
107
|
-
const entity = new PresentationDefinitionItemEntity()
|
|
108
|
-
entity.definitionId = 'definition1'
|
|
109
|
-
entity.version = '1.0'
|
|
110
|
-
entity.definitionPayload = JSON.stringify({ id: 'definition1', input_descriptors: [] })
|
|
111
|
-
|
|
112
|
-
const savedEntity = await repository.save(entity)
|
|
113
|
-
expect(savedEntity).toBeDefined()
|
|
114
|
-
expect(savedEntity.id).toBeDefined()
|
|
115
|
-
|
|
116
|
-
const retrievedEntity = await repository.findOneBy({ id: savedEntity.id })
|
|
117
|
-
expect(retrievedEntity).toBeDefined()
|
|
118
|
-
expect(retrievedEntity!.definitionId).toEqual('definition1')
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
it('should update PresentationDefinitionItemEntity', async (): Promise<void> => {
|
|
122
|
-
const repository = dbConnection.getRepository(PresentationDefinitionItemEntity)
|
|
123
|
-
const entity = new PresentationDefinitionItemEntity()
|
|
124
|
-
entity.definitionId = 'definition1'
|
|
125
|
-
entity.version = '1.0'
|
|
126
|
-
entity.definitionPayload = JSON.stringify({ id: 'definition1', input_descriptors: [] })
|
|
127
|
-
|
|
128
|
-
const savedEntity = await repository.save(entity)
|
|
129
|
-
expect(savedEntity).toBeDefined()
|
|
130
|
-
|
|
131
|
-
savedEntity.version = '1.1'
|
|
132
|
-
const updatedEntity = await repository.save(savedEntity)
|
|
133
|
-
expect(updatedEntity).toBeDefined()
|
|
134
|
-
expect(updatedEntity.version).toEqual('1.1')
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
it('should delete PresentationDefinitionItemEntity', async (): Promise<void> => {
|
|
138
|
-
const repository = dbConnection.getRepository(PresentationDefinitionItemEntity)
|
|
139
|
-
const entity = new PresentationDefinitionItemEntity()
|
|
140
|
-
entity.definitionId = 'definition1'
|
|
141
|
-
entity.version = '1.0'
|
|
142
|
-
entity.definitionPayload = JSON.stringify({ id: 'definition1', input_descriptors: [] })
|
|
143
|
-
|
|
144
|
-
const savedEntity = await repository.save(entity)
|
|
145
|
-
expect(savedEntity).toBeDefined()
|
|
146
|
-
|
|
147
|
-
await repository.delete(savedEntity.id)
|
|
148
|
-
const retrievedEntity = await repository.findOneBy({ id: savedEntity.id })
|
|
149
|
-
expect(retrievedEntity).toBeNull()
|
|
77
|
+
expect(JSON.parse(updatedEntity.query).credentials[0].id).toEqual('updated-clubcard')
|
|
78
|
+
expect(JSON.parse(updatedEntity.query).credentials[0].format).toEqual('jwt_vc')
|
|
150
79
|
})
|
|
151
80
|
})
|
|
@@ -1,8 +1,46 @@
|
|
|
1
1
|
import { DataSources } from '@sphereon/ssi-sdk.agent-config'
|
|
2
|
+
import { DcqlQuery } from 'dcql'
|
|
2
3
|
import { DataSource } from 'typeorm'
|
|
3
|
-
import { DataStorePresentationDefinitionEntities, DataStorePresentationDefinitionMigrations, PDStore } from '../index'
|
|
4
|
-
import { GetDefinitionsArgs, NonPersistedPresentationDefinitionItem, PresentationDefinitionItem } from '../types'
|
|
5
4
|
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
5
|
+
import {
|
|
6
|
+
DataStorePresentationDefinitionEntities,
|
|
7
|
+
DataStorePresentationDefinitionMigrations,
|
|
8
|
+
type DeleteDefinitionsArgs,
|
|
9
|
+
ImportDcqlQueryItem,
|
|
10
|
+
PDStore,
|
|
11
|
+
} from '../index'
|
|
12
|
+
import { DcqlQueryItem, GetDefinitionsArgs, NonPersistedDcqlQueryItem } from '../types'
|
|
13
|
+
|
|
14
|
+
export const SAMPLE_DCQL_QUERY_IMPORT: ImportDcqlQueryItem = {
|
|
15
|
+
queryId: 'ajax-club',
|
|
16
|
+
query: {
|
|
17
|
+
credentials: [
|
|
18
|
+
{
|
|
19
|
+
id: 'clubcard-v1',
|
|
20
|
+
format: 'dc+sd-jwt',
|
|
21
|
+
require_cryptographic_holder_binding: true,
|
|
22
|
+
multiple: false,
|
|
23
|
+
meta: {
|
|
24
|
+
vct_values: ['clubcard-v1'],
|
|
25
|
+
},
|
|
26
|
+
claims: [
|
|
27
|
+
{
|
|
28
|
+
path: ['personData', 'name'],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
path: ['personData', 'birthDate'],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
path: ['membershipData', 'membershipId'],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
path: ['membershipData', 'season'],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
}
|
|
6
44
|
|
|
7
45
|
describe('PDStore tests', (): void => {
|
|
8
46
|
let dbConnection: DataSource
|
|
@@ -28,136 +66,148 @@ describe('PDStore tests', (): void => {
|
|
|
28
66
|
await dbConnection.destroy()
|
|
29
67
|
})
|
|
30
68
|
|
|
31
|
-
it('should
|
|
32
|
-
const definition: NonPersistedPresentationDefinitionItem = {
|
|
33
|
-
definitionId: 'definition1',
|
|
34
|
-
version: '1.0',
|
|
35
|
-
definitionPayload: { id: 'definition1', input_descriptors: [] },
|
|
36
|
-
}
|
|
37
|
-
const savedDefinition: PresentationDefinitionItem = await pdStore.addDefinition(definition)
|
|
38
|
-
expect(savedDefinition).toBeDefined()
|
|
39
|
-
|
|
40
|
-
const exists: boolean = await pdStore.hasDefinition({ itemId: savedDefinition.id })
|
|
41
|
-
|
|
42
|
-
expect(exists).toBeTruthy()
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it('should check if definitions exist by filter', async (): Promise<void> => {
|
|
46
|
-
const definition: NonPersistedPresentationDefinitionItem = {
|
|
47
|
-
definitionId: 'definition1',
|
|
48
|
-
version: '1.0',
|
|
49
|
-
definitionPayload: { id: 'definition1', input_descriptors: [] },
|
|
50
|
-
}
|
|
51
|
-
const savedDefinition: PresentationDefinitionItem = await pdStore.addDefinition(definition)
|
|
52
|
-
expect(savedDefinition).toBeDefined()
|
|
53
|
-
|
|
54
|
-
const exists: boolean = await pdStore.hasDefinitions({ filter: [{ definitionId: 'definition1' }] })
|
|
55
|
-
|
|
56
|
-
expect(exists).toBeTruthy()
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it('should get definition by id', async (): Promise<void> => {
|
|
60
|
-
const definition: NonPersistedPresentationDefinitionItem = {
|
|
61
|
-
definitionId: 'definition1',
|
|
62
|
-
version: '1.0',
|
|
63
|
-
definitionPayload: { id: 'definition1', input_descriptors: [] },
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const savedDefinition: PresentationDefinitionItem = await pdStore.addDefinition(definition)
|
|
67
|
-
expect(savedDefinition).toBeDefined()
|
|
68
|
-
|
|
69
|
-
const result: PresentationDefinitionItem = await pdStore.getDefinition({ itemId: savedDefinition.id })
|
|
70
|
-
|
|
71
|
-
expect(result).toBeDefined()
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
it('should throw error when getting definition with unknown id', async (): Promise<void> => {
|
|
69
|
+
it('should throw error when getting query with unknown id', async (): Promise<void> => {
|
|
75
70
|
const itemId = 'unknownDefinitionId'
|
|
76
71
|
|
|
77
72
|
await expect(pdStore.getDefinition({ itemId })).rejects.toThrow(`No presentation definition item found for id: ${itemId}`)
|
|
78
73
|
})
|
|
79
74
|
|
|
80
|
-
it('should get all
|
|
81
|
-
const definition1:
|
|
82
|
-
|
|
75
|
+
it('should get all queries', async (): Promise<void> => {
|
|
76
|
+
const definition1: NonPersistedDcqlQueryItem = {
|
|
77
|
+
queryId: 'definition1',
|
|
83
78
|
version: '1.0',
|
|
84
|
-
|
|
79
|
+
query: {
|
|
80
|
+
credentials: [
|
|
81
|
+
{
|
|
82
|
+
id: 'id-card-v1',
|
|
83
|
+
format: 'dc+sd-jwt',
|
|
84
|
+
require_cryptographic_holder_binding: true,
|
|
85
|
+
multiple: false,
|
|
86
|
+
claims: [
|
|
87
|
+
{
|
|
88
|
+
path: ['name'],
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
85
94
|
}
|
|
86
|
-
const savedDefinition1:
|
|
95
|
+
const savedDefinition1: DcqlQueryItem = await pdStore.addDefinition(definition1)
|
|
87
96
|
expect(savedDefinition1).toBeDefined()
|
|
88
97
|
|
|
89
|
-
const definition2:
|
|
90
|
-
|
|
98
|
+
const definition2: NonPersistedDcqlQueryItem = {
|
|
99
|
+
queryId: 'definition2',
|
|
91
100
|
version: '1.0',
|
|
92
|
-
|
|
101
|
+
query: {
|
|
102
|
+
credentials: [
|
|
103
|
+
{
|
|
104
|
+
id: 'driver-license-v1',
|
|
105
|
+
format: 'dc+sd-jwt',
|
|
106
|
+
require_cryptographic_holder_binding: true,
|
|
107
|
+
multiple: false,
|
|
108
|
+
claims: [
|
|
109
|
+
{
|
|
110
|
+
path: ['dateOfBirth'],
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
},
|
|
93
116
|
}
|
|
94
|
-
const savedDefinition2:
|
|
117
|
+
const savedDefinition2: DcqlQueryItem = await pdStore.addDefinition(definition2)
|
|
95
118
|
expect(savedDefinition2).toBeDefined()
|
|
96
119
|
|
|
97
|
-
const result: Array<
|
|
120
|
+
const result: Array<DcqlQueryItem> = await pdStore.getDefinitions({})
|
|
98
121
|
|
|
99
122
|
expect(result).toBeDefined()
|
|
100
123
|
expect(result.length).toEqual(2)
|
|
101
124
|
})
|
|
102
125
|
|
|
103
|
-
it('should
|
|
104
|
-
const definition:
|
|
105
|
-
|
|
126
|
+
it('should update dcql query', async (): Promise<void> => {
|
|
127
|
+
const definition: NonPersistedDcqlQueryItem = {
|
|
128
|
+
queryId: SAMPLE_DCQL_QUERY_IMPORT.queryId,
|
|
106
129
|
version: '1.0',
|
|
107
|
-
|
|
130
|
+
query: SAMPLE_DCQL_QUERY_IMPORT.query,
|
|
108
131
|
}
|
|
109
|
-
const savedDefinition:
|
|
132
|
+
const savedDefinition: DcqlQueryItem = await pdStore.addDefinition(definition)
|
|
110
133
|
expect(savedDefinition).toBeDefined()
|
|
111
134
|
|
|
112
|
-
const
|
|
113
|
-
|
|
135
|
+
const updatedDcqlQuery = DcqlQuery.parse({
|
|
136
|
+
credentials: [
|
|
137
|
+
{
|
|
138
|
+
id: 'updated-clubcard',
|
|
139
|
+
format: 'dc+sd-jwt',
|
|
140
|
+
claims: [
|
|
141
|
+
{
|
|
142
|
+
path: ['name'],
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
const updatedDefinition: DcqlQueryItem = {
|
|
150
|
+
...savedDefinition,
|
|
151
|
+
version: '1.1',
|
|
152
|
+
query: updatedDcqlQuery,
|
|
114
153
|
}
|
|
115
|
-
const result: Array<PresentationDefinitionItem> = await pdStore.getDefinitions(args)
|
|
116
154
|
|
|
117
|
-
|
|
155
|
+
await pdStore.updateDefinition(updatedDefinition)
|
|
156
|
+
const result: DcqlQueryItem = await pdStore.getDefinition({ itemId: savedDefinition.id })
|
|
157
|
+
|
|
158
|
+
expect(result).toBeDefined()
|
|
159
|
+
expect(result.version).toEqual('1.1')
|
|
160
|
+
expect(result.query?.credentials[0].id).toEqual('updated-clubcard')
|
|
161
|
+
expect(result.query?.credentials[0].format).toEqual('dc+sd-jwt')
|
|
118
162
|
})
|
|
119
163
|
|
|
120
|
-
it('should
|
|
121
|
-
const definition:
|
|
122
|
-
|
|
164
|
+
it('should get dcql queries by id', async (): Promise<void> => {
|
|
165
|
+
const definition: NonPersistedDcqlQueryItem = {
|
|
166
|
+
queryId: SAMPLE_DCQL_QUERY_IMPORT.queryId,
|
|
123
167
|
version: '1.0',
|
|
124
|
-
|
|
168
|
+
query: SAMPLE_DCQL_QUERY_IMPORT.query,
|
|
125
169
|
}
|
|
126
170
|
|
|
127
|
-
const
|
|
171
|
+
const savedDefinition: DcqlQueryItem = await pdStore.addDefinition(definition)
|
|
172
|
+
expect(savedDefinition).toBeDefined()
|
|
173
|
+
|
|
174
|
+
const result: DcqlQueryItem = await pdStore.getDefinition({ itemId: savedDefinition.id })
|
|
128
175
|
|
|
129
176
|
expect(result).toBeDefined()
|
|
130
|
-
expect(result.
|
|
177
|
+
expect(result.query).toBeDefined()
|
|
178
|
+
expect(result.query.credentials[0].format).toBe('dc+sd-jwt')
|
|
179
|
+
if (result.query.credentials[0].format === 'dc+sd-jwt') {
|
|
180
|
+
expect(result.query.credentials[0].meta?.vct_values).toContain('clubcard-v1')
|
|
181
|
+
}
|
|
182
|
+
expect(result.query.credentials[0].claims).toHaveLength(4)
|
|
131
183
|
})
|
|
132
184
|
|
|
133
|
-
it('should
|
|
134
|
-
const definition:
|
|
135
|
-
|
|
185
|
+
it('should get dcql queries by filter', async (): Promise<void> => {
|
|
186
|
+
const definition: NonPersistedDcqlQueryItem = {
|
|
187
|
+
queryId: SAMPLE_DCQL_QUERY_IMPORT.queryId,
|
|
136
188
|
version: '1.0',
|
|
137
|
-
|
|
189
|
+
query: SAMPLE_DCQL_QUERY_IMPORT.query,
|
|
138
190
|
}
|
|
139
|
-
const savedDefinition:
|
|
191
|
+
const savedDefinition: DcqlQueryItem = await pdStore.addDefinition(definition)
|
|
140
192
|
expect(savedDefinition).toBeDefined()
|
|
141
193
|
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
version: '1.1',
|
|
194
|
+
const args: GetDefinitionsArgs = {
|
|
195
|
+
filter: [{ queryId: 'ajax-club' }],
|
|
145
196
|
}
|
|
197
|
+
const result: Array<DcqlQueryItem> = await pdStore.getDefinitions(args)
|
|
146
198
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
expect(result).toBeDefined()
|
|
151
|
-
expect(result.version).toEqual('1.1')
|
|
199
|
+
expect(result.length).toEqual(1)
|
|
200
|
+
expect(result[0].query).toBeDefined()
|
|
201
|
+
expect(result[0].query.credentials[0].id).toEqual('clubcard-v1')
|
|
152
202
|
})
|
|
153
203
|
|
|
154
|
-
it('should delete
|
|
155
|
-
const definition:
|
|
156
|
-
|
|
204
|
+
it('should delete dcql query', async (): Promise<void> => {
|
|
205
|
+
const definition: NonPersistedDcqlQueryItem = {
|
|
206
|
+
queryId: 'definition1',
|
|
157
207
|
version: '1.0',
|
|
158
|
-
|
|
208
|
+
query: SAMPLE_DCQL_QUERY_IMPORT.query,
|
|
159
209
|
}
|
|
160
|
-
const savedDefinition:
|
|
210
|
+
const savedDefinition: DcqlQueryItem = await pdStore.addDefinition(definition)
|
|
161
211
|
expect(savedDefinition).toBeDefined()
|
|
162
212
|
|
|
163
213
|
await pdStore.deleteDefinition({ itemId: savedDefinition.id })
|
|
@@ -167,28 +217,28 @@ describe('PDStore tests', (): void => {
|
|
|
167
217
|
)
|
|
168
218
|
})
|
|
169
219
|
|
|
170
|
-
it('should delete
|
|
171
|
-
const definition1:
|
|
172
|
-
|
|
220
|
+
it('should delete dcql queries by filter', async (): Promise<void> => {
|
|
221
|
+
const definition1: NonPersistedDcqlQueryItem = {
|
|
222
|
+
queryId: 'definition1',
|
|
173
223
|
version: '1.0',
|
|
174
|
-
|
|
224
|
+
query: SAMPLE_DCQL_QUERY_IMPORT.query,
|
|
175
225
|
}
|
|
176
|
-
const savedDefinition1:
|
|
226
|
+
const savedDefinition1: DcqlQueryItem = await pdStore.addDefinition(definition1)
|
|
177
227
|
expect(savedDefinition1).toBeDefined()
|
|
178
228
|
|
|
179
|
-
const definition2:
|
|
180
|
-
|
|
229
|
+
const definition2: NonPersistedDcqlQueryItem = {
|
|
230
|
+
queryId: 'definition2',
|
|
181
231
|
version: '1.0',
|
|
182
|
-
|
|
232
|
+
query: SAMPLE_DCQL_QUERY_IMPORT.query,
|
|
183
233
|
}
|
|
184
|
-
const savedDefinition2:
|
|
234
|
+
const savedDefinition2: DcqlQueryItem = await pdStore.addDefinition(definition2)
|
|
185
235
|
expect(savedDefinition2).toBeDefined()
|
|
186
236
|
|
|
187
|
-
const filter = { filter: [{
|
|
237
|
+
const filter = { filter: [{ queryId: 'definition1' }] } satisfies DeleteDefinitionsArgs
|
|
188
238
|
await pdStore.deleteDefinitions(filter)
|
|
189
239
|
|
|
190
|
-
const remainingDefinitions: Array<
|
|
240
|
+
const remainingDefinitions: Array<DcqlQueryItem> = await pdStore.getDefinitions({})
|
|
191
241
|
expect(remainingDefinitions.length).toEqual(1)
|
|
192
|
-
expect(remainingDefinitions[0].
|
|
242
|
+
expect(remainingDefinitions[0].queryId).toEqual('definition2')
|
|
193
243
|
})
|
|
194
244
|
})
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CredentialRole, OrPromise } from '@sphereon/ssi-types'
|
|
2
|
+
import Debug from 'debug'
|
|
3
|
+
import { DataSource, type FindOptionsOrder, type FindOptionsWhere, Repository } from 'typeorm'
|
|
4
|
+
|
|
5
|
+
import { digitalCredentialFrom, digitalCredentialsFrom, nonPersistedDigitalCredentialEntityFromAddArgs } from '../../src'
|
|
6
|
+
import { DigitalCredentialEntity } from '../entities/digitalCredential/DigitalCredentialEntity'
|
|
2
7
|
import {
|
|
3
8
|
AddCredentialArgs,
|
|
4
|
-
CredentialRole,
|
|
5
9
|
CredentialStateType,
|
|
6
10
|
DigitalCredential,
|
|
7
11
|
GetCredentialArgs,
|
|
@@ -11,14 +15,10 @@ import {
|
|
|
11
15
|
RemoveCredentialArgs,
|
|
12
16
|
UpdateCredentialStateArgs,
|
|
13
17
|
} from '../types'
|
|
14
|
-
import { OrPromise } from '@sphereon/ssi-types'
|
|
15
|
-
import { DataSource, type FindOptionsOrder, type FindOptionsWhere, Repository } from 'typeorm'
|
|
16
|
-
import Debug from 'debug'
|
|
17
|
-
import { DigitalCredentialEntity } from '../entities/digitalCredential/DigitalCredentialEntity'
|
|
18
|
-
|
|
19
|
-
import { digitalCredentialFrom, digitalCredentialsFrom, nonPersistedDigitalCredentialEntityFromAddArgs } from '../../src'
|
|
20
18
|
import { parseAndValidateOrderOptions } from '../utils/SortingUtils'
|
|
21
19
|
|
|
20
|
+
import { AbstractDigitalCredentialStore } from './AbstractDigitalCredentialStore'
|
|
21
|
+
|
|
22
22
|
const debug: Debug.Debugger = Debug('sphereon:ssi-sdk:credential-store')
|
|
23
23
|
|
|
24
24
|
export class DigitalCredentialStore extends AbstractDigitalCredentialStore {
|
|
@@ -78,7 +78,7 @@ export class DigitalCredentialStore extends AbstractDigitalCredentialStore {
|
|
|
78
78
|
return false
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
const query: FindOptionsWhere<DigitalCredentialEntity> = {}
|
|
82
82
|
|
|
83
83
|
if ('id' in args) {
|
|
84
84
|
query.id = args.id
|
|
@@ -17,7 +17,8 @@ import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
|
|
|
17
17
|
import { CorrelationIdentifierEntity } from './CorrelationIdentifierEntity'
|
|
18
18
|
import { ConnectionEntity } from './ConnectionEntity'
|
|
19
19
|
import { IdentityMetadataItemEntity } from './IdentityMetadataItemEntity'
|
|
20
|
-
import {
|
|
20
|
+
import { IdentityOrigin, ValidationConstraint } from '../../types'
|
|
21
|
+
import { CredentialRole } from '@sphereon/ssi-types'
|
|
21
22
|
import { PartyEntity } from './PartyEntity'
|
|
22
23
|
import { getConstraint } from '../../utils/ValidatorUtils'
|
|
23
24
|
|