@sphereon/ssi-sdk.data-store 0.34.1-feature.FIDES.1.274 → 0.34.1-feature.IDK.11.49
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 +3844 -3819
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1270 -339
- package/dist/index.d.ts +1270 -339
- package/dist/index.js +3791 -3766
- package/dist/index.js.map +1 -1
- package/package.json +8 -9
- package/src/__tests__/contact.entities.test.ts +10 -4
- package/src/__tests__/contact.store.test.ts +6 -11
- package/src/__tests__/digitalCredential.entities.test.ts +6 -13
- package/src/__tests__/digitalCredential.store.test.ts +6 -6
- package/src/__tests__/eventLogger.entities.test.ts +3 -3
- package/src/__tests__/eventLogger.store.test.ts +4 -9
- package/src/__tests__/issuanceBranding.entities.test.ts +2 -2
- package/src/__tests__/issuanceBranding.store.test.ts +3 -3
- package/src/__tests__/machineState.entities.test.ts +1 -1
- package/src/__tests__/machineState.store.test.ts +1 -1
- package/src/__tests__/pd-manager.entities.test.ts +98 -27
- package/src/__tests__/pd-manager.store.test.ts +101 -151
- package/src/__tests__/statusList.entities.test.ts +4 -4
- package/src/__tests__/statusList.store.test.ts +3 -3
- package/src/contact/AbstractContactStore.ts +71 -0
- package/src/contact/ContactStore.ts +35 -35
- package/src/digitalCredential/AbstractDigitalCredentialStore.ts +21 -0
- package/src/digitalCredential/DigitalCredentialStore.ts +7 -6
- package/src/entities/contact/BaseConfigEntity.ts +2 -2
- package/src/entities/contact/BaseContactEntity.ts +5 -4
- package/src/entities/contact/ConnectionEntity.ts +4 -4
- package/src/entities/contact/ContactMetadataItemEntity.ts +4 -3
- package/src/entities/contact/CorrelationIdentifierEntity.ts +4 -3
- package/src/entities/contact/DidAuthConfigEntity.ts +2 -1
- package/src/entities/contact/ElectronicAddressEntity.ts +5 -15
- package/src/entities/contact/IdentityEntity.ts +11 -12
- package/src/entities/contact/IdentityMetadataItemEntity.ts +3 -3
- package/src/entities/contact/NaturalPersonEntity.ts +5 -5
- package/src/entities/contact/OrganizationEntity.ts +1 -1
- package/src/entities/contact/PartyEntity.ts +7 -7
- package/src/entities/contact/PartyRelationshipEntity.ts +8 -8
- package/src/entities/contact/PartyTypeEntity.ts +4 -4
- package/src/entities/contact/PhysicalAddressEntity.ts +3 -3
- package/src/entities/digitalCredential/DigitalCredentialEntity.ts +3 -4
- package/src/entities/eventLogger/AuditEventEntity.ts +2 -2
- package/src/entities/issuanceBranding/BackgroundAttributesEntity.ts +2 -2
- package/src/entities/issuanceBranding/BaseLocaleBrandingEntity.ts +7 -6
- package/src/entities/issuanceBranding/CredentialBrandingEntity.ts +2 -2
- package/src/entities/issuanceBranding/CredentialClaimsEntity.ts +2 -2
- package/src/entities/issuanceBranding/CredentialLocaleBrandingEntity.ts +2 -2
- package/src/entities/issuanceBranding/ImageAttributesEntity.ts +2 -2
- package/src/entities/issuanceBranding/IssuerBrandingEntity.ts +2 -2
- package/src/entities/issuanceBranding/IssuerLocaleBrandingEntity.ts +3 -3
- package/src/entities/issuanceBranding/TextAttributesEntity.ts +1 -1
- package/src/entities/machineState/MachineStateInfoEntity.ts +1 -1
- package/src/entities/presentationDefinition/{DcqlQueryItemEntity.ts → PresentationDefinitionItemEntity.ts} +14 -10
- package/src/entities/statusList/BitstringStatusListEntryEntity.ts +1 -1
- package/src/entities/statusList/StatusListEntities.ts +4 -3
- package/src/eventLogger/AbstractEventLoggerStore.ts +9 -0
- package/src/eventLogger/EventLoggerStore.ts +2 -2
- package/src/index.ts +26 -21
- package/src/issuanceBranding/AbstractIssuanceBrandingStore.ts +41 -0
- package/src/issuanceBranding/IssuanceBrandingStore.ts +25 -25
- package/src/machineState/IAbstractMachineStateStore.ts +65 -0
- package/src/machineState/MachineStateStore.ts +7 -7
- package/src/migrations/generic/1-CreateContacts.ts +1 -1
- package/src/migrations/generic/10-CreatePresentationDefinitions.ts +1 -1
- package/src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts +2 -2
- package/src/migrations/generic/12-CreateBitstringStatusList.ts +2 -32
- package/src/migrations/generic/2-CreateIssuanceBranding.ts +1 -1
- package/src/migrations/generic/3-CreateContacts.ts +2 -2
- package/src/migrations/generic/4-CreateStatusList.ts +1 -1
- package/src/migrations/generic/5-CreateAuditEvents.ts +2 -2
- package/src/migrations/generic/6-CreateDigitalCredential.ts +1 -1
- package/src/migrations/generic/7-CreateMachineStateStore.ts +1 -1
- package/src/migrations/generic/8-CreateContacts.ts +1 -1
- package/src/migrations/generic/9-CreateContacts.ts +1 -1
- package/src/migrations/generic/index.ts +5 -10
- package/src/migrations/postgres/1659463079428-CreateContacts.ts +1 -1
- package/src/migrations/postgres/1685628974232-CreateIssuanceBranding.ts +1 -1
- package/src/migrations/postgres/1690925872592-CreateContacts.ts +1 -1
- package/src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts +1 -1
- package/src/migrations/postgres/1737110469001-UpdateStatusList.ts +1 -1
- package/src/migrations/postgres/1741895823000-CreateBitstringStatusList.ts +2 -15
- package/src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts +1 -1
- package/src/presentationDefinition/AbstractPDStore.ts +20 -0
- package/src/presentationDefinition/PDStore.ts +45 -45
- package/src/statusList/IStatusListStore.ts +1 -1
- package/src/statusList/StatusListStore.ts +3 -3
- package/src/types/contact/IAbstractContactStore.ts +161 -0
- package/src/types/contact/contact.ts +295 -0
- package/src/types/contact/index.ts +2 -0
- package/src/types/digitalCredential/IAbstractDigitalCredentialStore.ts +43 -0
- package/src/types/digitalCredential/enums.ts +70 -0
- package/src/types/digitalCredential/index.ts +3 -0
- package/src/types/digitalCredential/types.ts +39 -0
- package/src/types/eventLogger/IAbstractEventLoggerStore.ts +22 -0
- package/src/types/eventLogger/eventLogger.ts +4 -0
- package/src/types/index.ts +12 -0
- package/src/types/issuanceBranding/IAbstractIssuanceBrandingStore.ts +85 -0
- package/src/types/issuanceBranding/issuanceBranding.ts +138 -0
- package/src/types/machineState/IAbstractMachineStateStore.ts +68 -0
- package/src/types/presentationDefinition/IAbstractPDStore.ts +25 -0
- package/src/types/presentationDefinition/presentationDefinition.ts +19 -0
- package/src/types/statusList/IAbstractStatusListStore.ts +9 -9
- package/src/types/validation/validation.ts +3 -0
- package/src/utils/ValidatorUtils.ts +1 -1
- package/src/utils/contact/MappingUtils.ts +10 -10
- package/src/utils/digitalCredential/MappingUtils.ts +21 -3
- package/src/utils/eventLogger/MappingUtils.ts +2 -2
- package/src/utils/issuanceBranding/MappingUtils.ts +13 -13
- package/src/utils/presentationDefinition/MappingUtils.ts +22 -31
- package/src/utils/statusList/MappingUtils.ts +1 -1
- package/src/migrations/generic/13-CreateDcqlQueryItem.ts +0 -67
- package/src/migrations/postgres/1726588800000-CreateDcqlQueryItem.ts +0 -25
- package/src/migrations/sqlite/1726617600000-CreateDcqlQueryItem.ts +0 -24
|
@@ -1,46 +1,8 @@
|
|
|
1
1
|
import { DataSources } from '@sphereon/ssi-sdk.agent-config'
|
|
2
|
-
import { DcqlQuery } from 'dcql'
|
|
3
2
|
import { DataSource } from 'typeorm'
|
|
3
|
+
import { DataStorePresentationDefinitionEntities, DataStorePresentationDefinitionMigrations, PDStore } from '../index'
|
|
4
|
+
import { GetDefinitionsArgs, NonPersistedPresentationDefinitionItem, PresentationDefinitionItem } from '../types'
|
|
4
5
|
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 '@sphereon/ssi-sdk.data-store-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
|
-
}
|
|
44
6
|
|
|
45
7
|
describe('PDStore tests', (): void => {
|
|
46
8
|
let dbConnection: DataSource
|
|
@@ -66,148 +28,136 @@ describe('PDStore tests', (): void => {
|
|
|
66
28
|
await dbConnection.destroy()
|
|
67
29
|
})
|
|
68
30
|
|
|
69
|
-
it('should
|
|
31
|
+
it('should check if definition exists', async (): Promise<void> => {
|
|
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> => {
|
|
70
75
|
const itemId = 'unknownDefinitionId'
|
|
71
76
|
|
|
72
77
|
await expect(pdStore.getDefinition({ itemId })).rejects.toThrow(`No presentation definition item found for id: ${itemId}`)
|
|
73
78
|
})
|
|
74
79
|
|
|
75
|
-
it('should get all
|
|
76
|
-
const definition1:
|
|
77
|
-
|
|
80
|
+
it('should get all definitions', async (): Promise<void> => {
|
|
81
|
+
const definition1: NonPersistedPresentationDefinitionItem = {
|
|
82
|
+
definitionId: 'definition1',
|
|
78
83
|
version: '1.0',
|
|
79
|
-
|
|
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
|
-
},
|
|
84
|
+
definitionPayload: { id: 'definition1', input_descriptors: [] },
|
|
94
85
|
}
|
|
95
|
-
const savedDefinition1:
|
|
86
|
+
const savedDefinition1: PresentationDefinitionItem = await pdStore.addDefinition(definition1)
|
|
96
87
|
expect(savedDefinition1).toBeDefined()
|
|
97
88
|
|
|
98
|
-
const definition2:
|
|
99
|
-
|
|
89
|
+
const definition2: NonPersistedPresentationDefinitionItem = {
|
|
90
|
+
definitionId: 'definition2',
|
|
100
91
|
version: '1.0',
|
|
101
|
-
|
|
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
|
-
},
|
|
92
|
+
definitionPayload: { id: 'definition2', input_descriptors: [] },
|
|
116
93
|
}
|
|
117
|
-
const savedDefinition2:
|
|
94
|
+
const savedDefinition2: PresentationDefinitionItem = await pdStore.addDefinition(definition2)
|
|
118
95
|
expect(savedDefinition2).toBeDefined()
|
|
119
96
|
|
|
120
|
-
const result: Array<
|
|
97
|
+
const result: Array<PresentationDefinitionItem> = await pdStore.getDefinitions({})
|
|
121
98
|
|
|
122
99
|
expect(result).toBeDefined()
|
|
123
100
|
expect(result.length).toEqual(2)
|
|
124
101
|
})
|
|
125
102
|
|
|
126
|
-
it('should
|
|
127
|
-
const definition:
|
|
128
|
-
|
|
103
|
+
it('should get definitions by filter', async (): Promise<void> => {
|
|
104
|
+
const definition: NonPersistedPresentationDefinitionItem = {
|
|
105
|
+
definitionId: 'definition1',
|
|
129
106
|
version: '1.0',
|
|
130
|
-
|
|
107
|
+
definitionPayload: { id: 'definition1', input_descriptors: [] },
|
|
131
108
|
}
|
|
132
|
-
const savedDefinition:
|
|
109
|
+
const savedDefinition: PresentationDefinitionItem = await pdStore.addDefinition(definition)
|
|
133
110
|
expect(savedDefinition).toBeDefined()
|
|
134
111
|
|
|
135
|
-
const
|
|
136
|
-
|
|
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,
|
|
112
|
+
const args: GetDefinitionsArgs = {
|
|
113
|
+
filter: [{ definitionId: 'definition1' }],
|
|
153
114
|
}
|
|
115
|
+
const result: Array<PresentationDefinitionItem> = await pdStore.getDefinitions(args)
|
|
154
116
|
|
|
155
|
-
|
|
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')
|
|
117
|
+
expect(result.length).toEqual(1)
|
|
162
118
|
})
|
|
163
119
|
|
|
164
|
-
it('should
|
|
165
|
-
const definition:
|
|
166
|
-
|
|
120
|
+
it('should add definition', async (): Promise<void> => {
|
|
121
|
+
const definition: NonPersistedPresentationDefinitionItem = {
|
|
122
|
+
definitionId: 'definition1',
|
|
167
123
|
version: '1.0',
|
|
168
|
-
|
|
124
|
+
definitionPayload: { id: 'definition1', input_descriptors: [] },
|
|
169
125
|
}
|
|
170
126
|
|
|
171
|
-
const
|
|
172
|
-
expect(savedDefinition).toBeDefined()
|
|
173
|
-
|
|
174
|
-
const result: DcqlQueryItem = await pdStore.getDefinition({ itemId: savedDefinition.id })
|
|
127
|
+
const result: PresentationDefinitionItem = await pdStore.addDefinition(definition)
|
|
175
128
|
|
|
176
129
|
expect(result).toBeDefined()
|
|
177
|
-
expect(result.
|
|
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)
|
|
130
|
+
expect(result.definitionId).toEqual(definition.definitionId)
|
|
183
131
|
})
|
|
184
132
|
|
|
185
|
-
it('should
|
|
186
|
-
const definition:
|
|
187
|
-
|
|
133
|
+
it('should update definition', async (): Promise<void> => {
|
|
134
|
+
const definition: NonPersistedPresentationDefinitionItem = {
|
|
135
|
+
definitionId: 'definition1',
|
|
188
136
|
version: '1.0',
|
|
189
|
-
|
|
137
|
+
definitionPayload: { id: 'definition1', input_descriptors: [] },
|
|
190
138
|
}
|
|
191
|
-
const savedDefinition:
|
|
139
|
+
const savedDefinition: PresentationDefinitionItem = await pdStore.addDefinition(definition)
|
|
192
140
|
expect(savedDefinition).toBeDefined()
|
|
193
141
|
|
|
194
|
-
const
|
|
195
|
-
|
|
142
|
+
const updatedDefinition: PresentationDefinitionItem = {
|
|
143
|
+
...savedDefinition,
|
|
144
|
+
version: '1.1',
|
|
196
145
|
}
|
|
197
|
-
const result: Array<DcqlQueryItem> = await pdStore.getDefinitions(args)
|
|
198
146
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
147
|
+
await pdStore.updateDefinition(updatedDefinition)
|
|
148
|
+
const result: PresentationDefinitionItem = await pdStore.getDefinition({ itemId: savedDefinition.id })
|
|
149
|
+
|
|
150
|
+
expect(result).toBeDefined()
|
|
151
|
+
expect(result.version).toEqual('1.1')
|
|
202
152
|
})
|
|
203
153
|
|
|
204
|
-
it('should delete
|
|
205
|
-
const definition:
|
|
206
|
-
|
|
154
|
+
it('should delete definition', async (): Promise<void> => {
|
|
155
|
+
const definition: NonPersistedPresentationDefinitionItem = {
|
|
156
|
+
definitionId: 'definition1',
|
|
207
157
|
version: '1.0',
|
|
208
|
-
|
|
158
|
+
definitionPayload: { id: 'definition1', input_descriptors: [] },
|
|
209
159
|
}
|
|
210
|
-
const savedDefinition:
|
|
160
|
+
const savedDefinition: PresentationDefinitionItem = await pdStore.addDefinition(definition)
|
|
211
161
|
expect(savedDefinition).toBeDefined()
|
|
212
162
|
|
|
213
163
|
await pdStore.deleteDefinition({ itemId: savedDefinition.id })
|
|
@@ -217,28 +167,28 @@ describe('PDStore tests', (): void => {
|
|
|
217
167
|
)
|
|
218
168
|
})
|
|
219
169
|
|
|
220
|
-
it('should delete
|
|
221
|
-
const definition1:
|
|
222
|
-
|
|
170
|
+
it('should delete definitions by filter', async (): Promise<void> => {
|
|
171
|
+
const definition1: NonPersistedPresentationDefinitionItem = {
|
|
172
|
+
definitionId: 'definition1',
|
|
223
173
|
version: '1.0',
|
|
224
|
-
|
|
174
|
+
definitionPayload: { id: 'definition1', input_descriptors: [] },
|
|
225
175
|
}
|
|
226
|
-
const savedDefinition1:
|
|
176
|
+
const savedDefinition1: PresentationDefinitionItem = await pdStore.addDefinition(definition1)
|
|
227
177
|
expect(savedDefinition1).toBeDefined()
|
|
228
178
|
|
|
229
|
-
const definition2:
|
|
230
|
-
|
|
179
|
+
const definition2: NonPersistedPresentationDefinitionItem = {
|
|
180
|
+
definitionId: 'definition2',
|
|
231
181
|
version: '1.0',
|
|
232
|
-
|
|
182
|
+
definitionPayload: { id: 'definition2', input_descriptors: [] },
|
|
233
183
|
}
|
|
234
|
-
const savedDefinition2:
|
|
184
|
+
const savedDefinition2: PresentationDefinitionItem = await pdStore.addDefinition(definition2)
|
|
235
185
|
expect(savedDefinition2).toBeDefined()
|
|
236
186
|
|
|
237
|
-
const filter = { filter: [{
|
|
187
|
+
const filter = { filter: [{ definitionId: 'definition1' }] }
|
|
238
188
|
await pdStore.deleteDefinitions(filter)
|
|
239
189
|
|
|
240
|
-
const remainingDefinitions: Array<
|
|
190
|
+
const remainingDefinitions: Array<PresentationDefinitionItem> = await pdStore.getDefinitions({})
|
|
241
191
|
expect(remainingDefinitions.length).toEqual(1)
|
|
242
|
-
expect(remainingDefinitions[0].
|
|
192
|
+
expect(remainingDefinitions[0].definitionId).toEqual('definition2')
|
|
243
193
|
})
|
|
244
194
|
})
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { DataSources } from '@sphereon/ssi-sdk.agent-config'
|
|
2
|
-
import { IIssuer, StatusListCredentialIdMode, StatusListDriverType } from '@sphereon/ssi-types'
|
|
3
1
|
import { DataSource } from 'typeorm'
|
|
4
|
-
import {
|
|
5
|
-
import { OAuthStatusListEntity, StatusList2021Entity } from '../entities/statusList/StatusListEntities'
|
|
2
|
+
import { DataSources } from '@sphereon/ssi-sdk.agent-config'
|
|
6
3
|
import { BitstringStatusListEntity, BitstringStatusListEntryEntity, DataStoreStatusListEntities, StatusListEntryEntity } from '../index'
|
|
7
4
|
import { DataStoreStatusListMigrations } from '../migrations'
|
|
5
|
+
import { OAuthStatusListEntity, StatusList2021Entity } from '../entities/statusList/StatusListEntities'
|
|
6
|
+
import { IIssuer, StatusListCredentialIdMode, StatusListDriverType } from '@sphereon/ssi-types'
|
|
7
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
8
8
|
|
|
9
9
|
describe('Status list entities tests', () => {
|
|
10
10
|
let dbConnection: DataSource
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { DataSources } from '@sphereon/ssi-sdk.agent-config'
|
|
2
|
-
import { StatusListCredentialIdMode, StatusListDriverType, StatusListType } from '@sphereon/ssi-types'
|
|
3
1
|
import { DataSource } from 'typeorm'
|
|
4
|
-
import {
|
|
2
|
+
import { DataSources } from '@sphereon/ssi-sdk.agent-config'
|
|
5
3
|
import { DataStoreStatusListEntities, IBitstringStatusListEntity } from '../index'
|
|
6
4
|
import { DataStoreStatusListMigrations } from '../migrations'
|
|
7
5
|
import { StatusListStore } from '../statusList/StatusListStore'
|
|
8
6
|
import { IOAuthStatusListEntity, IStatusList2021Entity, IStatusListEntryEntity } from '../types'
|
|
7
|
+
import { StatusListCredentialIdMode, StatusListDriverType, StatusListType } from '@sphereon/ssi-types'
|
|
8
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
9
9
|
|
|
10
10
|
describe('Status list store tests', () => {
|
|
11
11
|
let dbConnection: DataSource
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AddElectronicAddressArgs,
|
|
3
|
+
AddIdentityArgs,
|
|
4
|
+
AddPartyArgs,
|
|
5
|
+
AddPartyTypeArgs,
|
|
6
|
+
AddPhysicalAddressArgs,
|
|
7
|
+
AddRelationshipArgs,
|
|
8
|
+
ElectronicAddress,
|
|
9
|
+
GetElectronicAddressArgs,
|
|
10
|
+
GetElectronicAddressesArgs,
|
|
11
|
+
GetIdentitiesArgs,
|
|
12
|
+
GetIdentityArgs,
|
|
13
|
+
GetPartiesArgs,
|
|
14
|
+
GetPartyArgs,
|
|
15
|
+
GetPartyTypeArgs,
|
|
16
|
+
GetPartyTypesArgs,
|
|
17
|
+
GetPhysicalAddressArgs,
|
|
18
|
+
GetPhysicalAddressesArgs,
|
|
19
|
+
GetRelationshipArgs,
|
|
20
|
+
GetRelationshipsArgs,
|
|
21
|
+
Identity,
|
|
22
|
+
Party,
|
|
23
|
+
PartyRelationship,
|
|
24
|
+
PartyType,
|
|
25
|
+
PhysicalAddress,
|
|
26
|
+
RemoveElectronicAddressArgs,
|
|
27
|
+
RemoveIdentityArgs,
|
|
28
|
+
RemovePartyArgs,
|
|
29
|
+
RemovePartyTypeArgs,
|
|
30
|
+
RemovePhysicalAddressArgs,
|
|
31
|
+
RemoveRelationshipArgs,
|
|
32
|
+
UpdateElectronicAddressArgs,
|
|
33
|
+
UpdateIdentityArgs,
|
|
34
|
+
UpdatePartyArgs,
|
|
35
|
+
UpdatePartyTypeArgs,
|
|
36
|
+
UpdatePhysicalAddressArgs,
|
|
37
|
+
UpdateRelationshipArgs,
|
|
38
|
+
} from '../types'
|
|
39
|
+
|
|
40
|
+
export abstract class AbstractContactStore {
|
|
41
|
+
abstract getParty(args: GetPartyArgs): Promise<Party>
|
|
42
|
+
abstract getParties(args?: GetPartiesArgs): Promise<Array<Party>>
|
|
43
|
+
abstract addParty(args: AddPartyArgs): Promise<Party>
|
|
44
|
+
abstract updateParty(args: UpdatePartyArgs): Promise<Party>
|
|
45
|
+
abstract removeParty(args: RemovePartyArgs): Promise<void>
|
|
46
|
+
abstract getIdentity(args: GetIdentityArgs): Promise<Identity>
|
|
47
|
+
abstract getIdentities(args?: GetIdentitiesArgs): Promise<Array<Identity>>
|
|
48
|
+
abstract addIdentity(args: AddIdentityArgs): Promise<Identity>
|
|
49
|
+
abstract updateIdentity(args: UpdateIdentityArgs): Promise<Identity>
|
|
50
|
+
abstract removeIdentity(args: RemoveIdentityArgs): Promise<void>
|
|
51
|
+
abstract getRelationship(args: GetRelationshipArgs): Promise<PartyRelationship>
|
|
52
|
+
abstract getRelationships(args?: GetRelationshipsArgs): Promise<Array<PartyRelationship>>
|
|
53
|
+
abstract addRelationship(args: AddRelationshipArgs): Promise<PartyRelationship>
|
|
54
|
+
abstract updateRelationship(args: UpdateRelationshipArgs): Promise<PartyRelationship>
|
|
55
|
+
abstract removeRelationship(args: RemoveRelationshipArgs): Promise<void>
|
|
56
|
+
abstract getPartyType(args: GetPartyTypeArgs): Promise<PartyType>
|
|
57
|
+
abstract getPartyTypes(args?: GetPartyTypesArgs): Promise<Array<PartyType>>
|
|
58
|
+
abstract addPartyType(args: AddPartyTypeArgs): Promise<PartyType>
|
|
59
|
+
abstract updatePartyType(args: UpdatePartyTypeArgs): Promise<PartyType>
|
|
60
|
+
abstract removePartyType(args: RemovePartyTypeArgs): Promise<void>
|
|
61
|
+
abstract getElectronicAddress(args: GetElectronicAddressArgs): Promise<ElectronicAddress>
|
|
62
|
+
abstract getElectronicAddresses(args?: GetElectronicAddressesArgs): Promise<Array<ElectronicAddress>>
|
|
63
|
+
abstract addElectronicAddress(args: AddElectronicAddressArgs): Promise<ElectronicAddress>
|
|
64
|
+
abstract updateElectronicAddress(args: UpdateElectronicAddressArgs): Promise<ElectronicAddress>
|
|
65
|
+
abstract removeElectronicAddress(args: RemoveElectronicAddressArgs): Promise<void>
|
|
66
|
+
abstract getPhysicalAddress(args: GetPhysicalAddressArgs): Promise<PhysicalAddress>
|
|
67
|
+
abstract getPhysicalAddresses(args?: GetPhysicalAddressesArgs): Promise<Array<PhysicalAddress>>
|
|
68
|
+
abstract addPhysicalAddress(args: AddPhysicalAddressArgs): Promise<PhysicalAddress>
|
|
69
|
+
abstract updatePhysicalAddress(args: UpdatePhysicalAddressArgs): Promise<PhysicalAddress>
|
|
70
|
+
abstract removePhysicalAddress(args: RemovePhysicalAddressArgs): Promise<void>
|
|
71
|
+
}
|
|
@@ -1,5 +1,37 @@
|
|
|
1
|
+
import { OrPromise } from '@sphereon/ssi-types'
|
|
2
|
+
import { BaseEntity, DataSource, type FindOptionsWhere, In, type Repository } from 'typeorm'
|
|
3
|
+
import Debug from 'debug'
|
|
4
|
+
import { AbstractContactStore } from './AbstractContactStore'
|
|
5
|
+
import { PartyEntity } from '../entities/contact/PartyEntity'
|
|
6
|
+
import { IdentityEntity } from '../entities/contact/IdentityEntity'
|
|
7
|
+
import { IdentityMetadataItemEntity } from '../entities/contact/IdentityMetadataItemEntity'
|
|
8
|
+
import { CorrelationIdentifierEntity } from '../entities/contact/CorrelationIdentifierEntity'
|
|
9
|
+
import { ConnectionEntity } from '../entities/contact/ConnectionEntity'
|
|
10
|
+
import { BaseConfigEntity } from '../entities/contact/BaseConfigEntity'
|
|
11
|
+
import { PartyRelationshipEntity } from '../entities/contact/PartyRelationshipEntity'
|
|
12
|
+
import { PartyTypeEntity } from '../entities/contact/PartyTypeEntity'
|
|
13
|
+
import { BaseContactEntity } from '../entities/contact/BaseContactEntity'
|
|
14
|
+
import { ElectronicAddressEntity } from '../entities/contact/ElectronicAddressEntity'
|
|
15
|
+
import { PhysicalAddressEntity } from '../entities/contact/PhysicalAddressEntity'
|
|
16
|
+
import {
|
|
17
|
+
electronicAddressEntityFrom,
|
|
18
|
+
electronicAddressFrom,
|
|
19
|
+
identityEntityFrom,
|
|
20
|
+
identityFrom,
|
|
21
|
+
isDidAuthConfig,
|
|
22
|
+
isNaturalPerson,
|
|
23
|
+
isOpenIdConfig,
|
|
24
|
+
isOrganization,
|
|
25
|
+
partyEntityFrom,
|
|
26
|
+
partyFrom,
|
|
27
|
+
partyRelationshipEntityFrom,
|
|
28
|
+
partyRelationshipFrom,
|
|
29
|
+
partyTypeEntityFrom,
|
|
30
|
+
partyTypeFrom,
|
|
31
|
+
physicalAddressEntityFrom,
|
|
32
|
+
physicalAddressFrom,
|
|
33
|
+
} from '../utils/contact/MappingUtils'
|
|
1
34
|
import {
|
|
2
|
-
AbstractContactStore,
|
|
3
35
|
AddElectronicAddressArgs,
|
|
4
36
|
AddIdentityArgs,
|
|
5
37
|
AddPartyArgs,
|
|
@@ -21,8 +53,8 @@ import {
|
|
|
21
53
|
GetPhysicalAddressesArgs,
|
|
22
54
|
GetRelationshipArgs,
|
|
23
55
|
GetRelationshipsArgs,
|
|
24
|
-
Identity,
|
|
25
56
|
IMetadataEntity,
|
|
57
|
+
Identity,
|
|
26
58
|
MetadataItem,
|
|
27
59
|
MetadataTypes,
|
|
28
60
|
NonPersistedConnectionConfig,
|
|
@@ -44,39 +76,7 @@ import {
|
|
|
44
76
|
UpdatePartyTypeArgs,
|
|
45
77
|
UpdatePhysicalAddressArgs,
|
|
46
78
|
UpdateRelationshipArgs,
|
|
47
|
-
} from '
|
|
48
|
-
import { OrPromise } from '@sphereon/ssi-types'
|
|
49
|
-
import Debug from 'debug'
|
|
50
|
-
import { BaseEntity, DataSource, type FindOptionsWhere, In, type Repository } from 'typeorm'
|
|
51
|
-
import { BaseConfigEntity } from '../entities/contact/BaseConfigEntity'
|
|
52
|
-
import { BaseContactEntity } from '../entities/contact/BaseContactEntity'
|
|
53
|
-
import { ConnectionEntity } from '../entities/contact/ConnectionEntity'
|
|
54
|
-
import { CorrelationIdentifierEntity } from '../entities/contact/CorrelationIdentifierEntity'
|
|
55
|
-
import { ElectronicAddressEntity } from '../entities/contact/ElectronicAddressEntity'
|
|
56
|
-
import { IdentityEntity } from '../entities/contact/IdentityEntity'
|
|
57
|
-
import { IdentityMetadataItemEntity } from '../entities/contact/IdentityMetadataItemEntity'
|
|
58
|
-
import { PartyEntity } from '../entities/contact/PartyEntity'
|
|
59
|
-
import { PartyRelationshipEntity } from '../entities/contact/PartyRelationshipEntity'
|
|
60
|
-
import { PartyTypeEntity } from '../entities/contact/PartyTypeEntity'
|
|
61
|
-
import { PhysicalAddressEntity } from '../entities/contact/PhysicalAddressEntity'
|
|
62
|
-
import {
|
|
63
|
-
electronicAddressEntityFrom,
|
|
64
|
-
electronicAddressFrom,
|
|
65
|
-
identityEntityFrom,
|
|
66
|
-
identityFrom,
|
|
67
|
-
isDidAuthConfig,
|
|
68
|
-
isNaturalPerson,
|
|
69
|
-
isOpenIdConfig,
|
|
70
|
-
isOrganization,
|
|
71
|
-
partyEntityFrom,
|
|
72
|
-
partyFrom,
|
|
73
|
-
partyRelationshipEntityFrom,
|
|
74
|
-
partyRelationshipFrom,
|
|
75
|
-
partyTypeEntityFrom,
|
|
76
|
-
partyTypeFrom,
|
|
77
|
-
physicalAddressEntityFrom,
|
|
78
|
-
physicalAddressFrom,
|
|
79
|
-
} from '../utils/contact/MappingUtils'
|
|
79
|
+
} from '../types'
|
|
80
80
|
|
|
81
81
|
const debug: Debug.Debugger = Debug('sphereon:ssi-sdk:contact-store')
|
|
82
82
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AddCredentialArgs,
|
|
3
|
+
DigitalCredential,
|
|
4
|
+
GetCredentialArgs,
|
|
5
|
+
GetCredentialsArgs,
|
|
6
|
+
GetCredentialsResponse,
|
|
7
|
+
RemoveCredentialArgs,
|
|
8
|
+
UpdateCredentialStateArgs,
|
|
9
|
+
} from '../types'
|
|
10
|
+
|
|
11
|
+
export abstract class AbstractDigitalCredentialStore {
|
|
12
|
+
abstract getCredential(args: GetCredentialArgs): Promise<DigitalCredential>
|
|
13
|
+
|
|
14
|
+
abstract getCredentials(args?: GetCredentialsArgs): Promise<GetCredentialsResponse>
|
|
15
|
+
|
|
16
|
+
abstract addCredential(args: AddCredentialArgs): Promise<DigitalCredential>
|
|
17
|
+
|
|
18
|
+
abstract updateCredentialState(args: UpdateCredentialStateArgs): Promise<DigitalCredential>
|
|
19
|
+
|
|
20
|
+
abstract removeCredential(args: RemoveCredentialArgs): Promise<boolean>
|
|
21
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { AbstractDigitalCredentialStore } from './AbstractDigitalCredentialStore'
|
|
1
2
|
import {
|
|
2
|
-
AbstractDigitalCredentialStore,
|
|
3
3
|
AddCredentialArgs,
|
|
4
|
+
CredentialRole,
|
|
4
5
|
CredentialStateType,
|
|
5
6
|
DigitalCredential,
|
|
6
7
|
GetCredentialArgs,
|
|
@@ -9,13 +10,13 @@ import {
|
|
|
9
10
|
NonPersistedDigitalCredential,
|
|
10
11
|
RemoveCredentialArgs,
|
|
11
12
|
UpdateCredentialStateArgs,
|
|
12
|
-
} from '
|
|
13
|
-
import {
|
|
14
|
-
import Debug from 'debug'
|
|
13
|
+
} from '../types'
|
|
14
|
+
import { OrPromise } from '@sphereon/ssi-types'
|
|
15
15
|
import { DataSource, type FindOptionsOrder, type FindOptionsWhere, Repository } from 'typeorm'
|
|
16
|
+
import Debug from 'debug'
|
|
17
|
+
import { DigitalCredentialEntity } from '../entities/digitalCredential/DigitalCredentialEntity'
|
|
16
18
|
|
|
17
19
|
import { digitalCredentialFrom, digitalCredentialsFrom, nonPersistedDigitalCredentialEntityFromAddArgs } from '../../src'
|
|
18
|
-
import { DigitalCredentialEntity } from '../entities/digitalCredential/DigitalCredentialEntity'
|
|
19
20
|
import { parseAndValidateOrderOptions } from '../utils/SortingUtils'
|
|
20
21
|
|
|
21
22
|
const debug: Debug.Debugger = Debug('sphereon:ssi-sdk:credential-store')
|
|
@@ -77,7 +78,7 @@ export class DigitalCredentialStore extends AbstractDigitalCredentialStore {
|
|
|
77
78
|
return false
|
|
78
79
|
}
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
let query: FindOptionsWhere<DigitalCredentialEntity> = {}
|
|
81
82
|
|
|
82
83
|
if ('id' in args) {
|
|
83
84
|
query.id = args.id
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import typeorm from 'typeorm'
|
|
2
|
+
const { BaseEntity, Entity, JoinColumn, OneToOne, PrimaryGeneratedColumn, TableInheritance } = typeorm
|
|
3
3
|
import { ConnectionEntity } from './ConnectionEntity'
|
|
4
4
|
|
|
5
5
|
@Entity('BaseConfig')
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import typeorm from 'typeorm'
|
|
2
|
+
const {
|
|
3
3
|
BaseEntity,
|
|
4
4
|
BeforeInsert,
|
|
5
5
|
BeforeUpdate,
|
|
@@ -11,9 +11,10 @@ import {
|
|
|
11
11
|
PrimaryGeneratedColumn,
|
|
12
12
|
TableInheritance,
|
|
13
13
|
UpdateDateColumn,
|
|
14
|
-
}
|
|
15
|
-
import {
|
|
14
|
+
} = typeorm
|
|
15
|
+
import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
|
|
16
16
|
import { PartyEntity } from './PartyEntity'
|
|
17
|
+
import { ContactMetadataItemEntity } from './ContactMetadataItemEntity'
|
|
17
18
|
|
|
18
19
|
@Entity('BaseContact')
|
|
19
20
|
@TableInheritance({ column: { type: 'varchar', name: 'type' } })
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import typeorm from 'typeorm'
|
|
2
|
+
const { Entity, Column, PrimaryGeneratedColumn, OneToOne, JoinColumn, BaseEntity } = typeorm
|
|
4
3
|
import { BaseConfigEntity } from './BaseConfigEntity'
|
|
5
|
-
import {
|
|
4
|
+
import { ConnectionType } from '../../types'
|
|
6
5
|
import { IdentityEntity } from './IdentityEntity'
|
|
7
6
|
import { OpenIdConfigEntity } from './OpenIdConfigEntity'
|
|
7
|
+
import { DidAuthConfigEntity } from './DidAuthConfigEntity'
|
|
8
8
|
|
|
9
9
|
@Entity('Connection')
|
|
10
10
|
export class ConnectionEntity extends BaseEntity {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import typeorm from 'typeorm'
|
|
2
|
+
const { Entity, Column, PrimaryGeneratedColumn, BaseEntity, ManyToOne, BeforeInsert, BeforeUpdate } = typeorm
|
|
3
|
+
import { IMetadataEntity, ValidationConstraint } from '../../types'
|
|
1
4
|
import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
|
|
2
|
-
import {
|
|
5
|
+
import { BaseContactEntity } from './BaseContactEntity'
|
|
3
6
|
import { IsNotEmpty, validate, ValidationError } from 'class-validator'
|
|
4
|
-
import { BaseEntity, BeforeInsert, BeforeUpdate, Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'
|
|
5
7
|
import { getConstraint } from '../../utils/ValidatorUtils'
|
|
6
|
-
import { BaseContactEntity } from './BaseContactEntity'
|
|
7
8
|
|
|
8
9
|
@Entity('ContactMetadata')
|
|
9
10
|
export class ContactMetadataItemEntity extends BaseEntity implements IMetadataEntity {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import typeorm from 'typeorm'
|
|
2
|
+
const { Entity, Column, PrimaryGeneratedColumn, BaseEntity, OneToOne, JoinColumn, BeforeInsert, BeforeUpdate } = typeorm
|
|
3
|
+
import { CorrelationIdentifierType, ValidationConstraint } from '../../types'
|
|
4
|
+
import { IdentityEntity } from './IdentityEntity'
|
|
2
5
|
import { IsNotEmpty, validate, ValidationError } from 'class-validator'
|
|
3
|
-
import { BaseEntity, BeforeInsert, BeforeUpdate, Column, Entity, JoinColumn, OneToOne, PrimaryGeneratedColumn } from 'typeorm'
|
|
4
6
|
import { getConstraint } from '../../utils/ValidatorUtils'
|
|
5
|
-
import { IdentityEntity } from './IdentityEntity'
|
|
6
7
|
|
|
7
8
|
@Entity('CorrelationIdentifier')
|
|
8
9
|
export class CorrelationIdentifierEntity extends BaseEntity {
|