@sphereon/ssi-sdk.data-store 0.34.1-next.3 → 0.34.1-next.322
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 +3377 -2924
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +357 -1203
- package/dist/index.d.ts +357 -1203
- package/dist/index.js +3300 -2847
- package/dist/index.js.map +1 -1
- package/package.json +10 -9
- package/src/__tests__/contact.entities.test.ts +4 -10
- package/src/__tests__/contact.store.test.ts +11 -6
- package/src/__tests__/digitalCredential.entities.test.ts +13 -6
- 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 +9 -4
- 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 +27 -98
- package/src/__tests__/pd-manager.store.test.ts +151 -101
- package/src/__tests__/statusList.entities.test.ts +61 -4
- package/src/__tests__/statusList.store.test.ts +67 -4
- package/src/contact/ContactStore.ts +35 -35
- package/src/digitalCredential/DigitalCredentialStore.ts +6 -7
- package/src/entities/contact/BaseConfigEntity.ts +2 -2
- package/src/entities/contact/BaseContactEntity.ts +4 -5
- package/src/entities/contact/ConnectionEntity.ts +4 -4
- package/src/entities/contact/ContactMetadataItemEntity.ts +3 -4
- package/src/entities/contact/CorrelationIdentifierEntity.ts +3 -4
- package/src/entities/contact/DidAuthConfigEntity.ts +1 -2
- package/src/entities/contact/ElectronicAddressEntity.ts +15 -5
- package/src/entities/contact/IdentityEntity.ts +12 -11
- 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 +4 -3
- package/src/entities/eventLogger/AuditEventEntity.ts +2 -2
- package/src/entities/issuanceBranding/BackgroundAttributesEntity.ts +2 -2
- package/src/entities/issuanceBranding/BaseLocaleBrandingEntity.ts +6 -7
- 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/{PresentationDefinitionItemEntity.ts → DcqlQueryItemEntity.ts} +10 -14
- package/src/entities/statusList/BitstringStatusListEntryEntity.ts +60 -0
- package/src/entities/statusList/StatusList2021EntryEntity.ts +4 -3
- package/src/entities/statusList/StatusListEntities.ts +55 -7
- package/src/eventLogger/EventLoggerStore.ts +2 -2
- package/src/index.ts +31 -26
- package/src/issuanceBranding/IssuanceBrandingStore.ts +25 -25
- 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 +82 -0
- package/src/migrations/generic/13-CreateDcqlQueryItem.ts +67 -0
- 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 +10 -4
- 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/1726588800000-CreateDcqlQueryItem.ts +25 -0
- package/src/migrations/postgres/1737110469001-UpdateStatusList.ts +1 -1
- package/src/migrations/postgres/1741895823000-CreateBitstringStatusList.ts +67 -0
- package/src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts +1 -1
- package/src/migrations/sqlite/1726617600000-CreateDcqlQueryItem.ts +24 -0
- package/src/migrations/sqlite/1741895823001-CreateBitstringStatusList.ts +145 -0
- package/src/presentationDefinition/PDStore.ts +45 -45
- package/src/statusList/IStatusListStore.ts +14 -11
- package/src/statusList/StatusListStore.ts +74 -36
- package/src/types/index.ts +0 -12
- package/src/types/statusList/IAbstractStatusListStore.ts +55 -5
- package/src/types/statusList/statusList.ts +50 -2
- package/src/utils/ValidatorUtils.ts +1 -1
- package/src/utils/contact/MappingUtils.ts +10 -10
- package/src/utils/digitalCredential/MappingUtils.ts +3 -21
- package/src/utils/eventLogger/MappingUtils.ts +2 -2
- package/src/utils/issuanceBranding/MappingUtils.ts +13 -13
- package/src/utils/presentationDefinition/MappingUtils.ts +31 -22
- package/src/utils/statusList/MappingUtils.ts +71 -30
- package/src/contact/AbstractContactStore.ts +0 -71
- package/src/digitalCredential/AbstractDigitalCredentialStore.ts +0 -21
- package/src/eventLogger/AbstractEventLoggerStore.ts +0 -9
- package/src/issuanceBranding/AbstractIssuanceBrandingStore.ts +0 -41
- package/src/machineState/IAbstractMachineStateStore.ts +0 -65
- package/src/presentationDefinition/AbstractPDStore.ts +0 -20
- package/src/types/contact/IAbstractContactStore.ts +0 -161
- package/src/types/contact/contact.ts +0 -295
- package/src/types/contact/index.ts +0 -2
- package/src/types/digitalCredential/IAbstractDigitalCredentialStore.ts +0 -43
- package/src/types/digitalCredential/enums.ts +0 -70
- package/src/types/digitalCredential/index.ts +0 -3
- package/src/types/digitalCredential/types.ts +0 -39
- package/src/types/eventLogger/IAbstractEventLoggerStore.ts +0 -22
- package/src/types/eventLogger/eventLogger.ts +0 -4
- package/src/types/issuanceBranding/IAbstractIssuanceBrandingStore.ts +0 -85
- package/src/types/issuanceBranding/issuanceBranding.ts +0 -138
- package/src/types/machineState/IAbstractMachineStateStore.ts +0 -68
- package/src/types/presentationDefinition/IAbstractPDStore.ts +0 -25
- package/src/types/presentationDefinition/presentationDefinition.ts +0 -19
- package/src/types/validation/validation.ts +0 -3
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { type OrPromise, StatusListType } from '@sphereon/ssi-types'
|
|
2
2
|
import Debug from 'debug'
|
|
3
3
|
import { DataSource, In, type Repository } from 'typeorm'
|
|
4
|
-
import {
|
|
4
|
+
import { BitstringStatusListEntryEntity } from '../entities/statusList/BitstringStatusListEntryEntity'
|
|
5
5
|
import { StatusListEntryEntity } from '../entities/statusList/StatusList2021EntryEntity'
|
|
6
|
-
import
|
|
6
|
+
import { BitstringStatusListEntity, OAuthStatusListEntity, StatusList2021Entity, StatusListEntity } from '../entities/statusList/StatusListEntities'
|
|
7
|
+
import {
|
|
7
8
|
IAddStatusListArgs,
|
|
8
9
|
IAddStatusListEntryArgs,
|
|
10
|
+
IBitstringStatusListEntity,
|
|
11
|
+
IBitstringStatusListEntryEntity,
|
|
9
12
|
IGetStatusListArgs,
|
|
10
13
|
IGetStatusListEntriesArgs,
|
|
11
14
|
IGetStatusListEntryByCredentialIdArgs,
|
|
@@ -17,8 +20,8 @@ import type {
|
|
|
17
20
|
IStatusListEntryEntity,
|
|
18
21
|
IUpdateStatusListIndexArgs,
|
|
19
22
|
} from '../types'
|
|
20
|
-
import type { IStatusListStore } from './IStatusListStore'
|
|
21
23
|
import { statusListEntityFrom, statusListFrom } from '../utils/statusList/MappingUtils'
|
|
24
|
+
import type { IStatusListStore } from './IStatusListStore'
|
|
22
25
|
|
|
23
26
|
const debug = Debug('sphereon:ssi-sdk:data-store:status-list')
|
|
24
27
|
|
|
@@ -41,11 +44,11 @@ export class StatusListStore implements IStatusListStore {
|
|
|
41
44
|
async availableStatusListEntries(args: IStatusListEntryAvailableArgs): Promise<number[]> {
|
|
42
45
|
const statusListIndex = Array.isArray(args.statusListIndex) ? args.statusListIndex : [args.statusListIndex]
|
|
43
46
|
const statusList = await this.getStatusList({ ...args, id: args.statusListId })
|
|
44
|
-
const repo = await this.getStatusListEntryRepo()
|
|
47
|
+
const repo = await this.getStatusListEntryRepo(statusList.type)
|
|
45
48
|
const results = (
|
|
46
49
|
await repo.find({
|
|
47
50
|
where: {
|
|
48
|
-
statusList,
|
|
51
|
+
statusListId: statusList.id,
|
|
49
52
|
statusListIndex: In(statusListIndex),
|
|
50
53
|
},
|
|
51
54
|
})
|
|
@@ -53,33 +56,42 @@ export class StatusListStore implements IStatusListStore {
|
|
|
53
56
|
return statusListIndex.filter((index) => !results.includes(index))
|
|
54
57
|
}
|
|
55
58
|
|
|
56
|
-
async addStatusListEntry(args: IAddStatusListEntryArgs): Promise<IStatusListEntryEntity> {
|
|
57
|
-
|
|
59
|
+
async addStatusListEntry(args: IAddStatusListEntryArgs): Promise<IStatusListEntryEntity | IBitstringStatusListEntryEntity> {
|
|
60
|
+
if (!args.statusListId) {
|
|
61
|
+
throw new Error('statusListId is required')
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const statusList = await this.getStatusList({ id: args.statusListId })
|
|
65
|
+
return await (await this.getStatusListEntryRepo(statusList.type)).save(args)
|
|
58
66
|
}
|
|
59
67
|
|
|
60
|
-
async updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<IStatusListEntryEntity> {
|
|
61
|
-
const statusListId = args.statusListId
|
|
68
|
+
async updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<IStatusListEntryEntity | IBitstringStatusListEntryEntity> {
|
|
69
|
+
const statusListId = args.statusListId
|
|
70
|
+
if (!statusListId) {
|
|
71
|
+
throw new Error('statusListId is required')
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const statusList = await this.getStatusList({ id: statusListId })
|
|
62
75
|
const result = await this.getStatusListEntryByIndex({ ...args, statusListId, errorOnNotFound: false })
|
|
63
76
|
const updatedEntry: Partial<IStatusListEntryEntity> = {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
credentialId: args.credentialId,
|
|
77
|
+
...result,
|
|
78
|
+
...args,
|
|
79
|
+
statusListId,
|
|
68
80
|
}
|
|
69
81
|
|
|
70
82
|
const updStatusListId = result?.statusListId ?? statusListId
|
|
71
83
|
const updateResult = await (
|
|
72
|
-
await this.getStatusListEntryRepo()
|
|
84
|
+
await this.getStatusListEntryRepo(statusList.type)
|
|
73
85
|
).upsert(
|
|
74
86
|
{ ...(result ?? { statusListId: updStatusListId, statusListIndex: args.statusListIndex }), ...updatedEntry },
|
|
75
87
|
{ conflictPaths: ['statusList', 'statusListIndex'] },
|
|
76
88
|
)
|
|
77
|
-
|
|
89
|
+
debug(updateResult)
|
|
78
90
|
return (await this.getStatusListEntryByIndex({
|
|
79
91
|
...args,
|
|
80
92
|
statusListId: updStatusListId,
|
|
81
93
|
errorOnNotFound: true,
|
|
82
|
-
}))
|
|
94
|
+
}))!
|
|
83
95
|
}
|
|
84
96
|
|
|
85
97
|
async getStatusListEntryByIndex({
|
|
@@ -88,7 +100,7 @@ export class StatusListStore implements IStatusListStore {
|
|
|
88
100
|
statusListIndex,
|
|
89
101
|
entryCorrelationId,
|
|
90
102
|
errorOnNotFound,
|
|
91
|
-
}: IGetStatusListEntryByIndexArgs): Promise<StatusListEntryEntity | undefined> {
|
|
103
|
+
}: IGetStatusListEntryByIndexArgs): Promise<StatusListEntryEntity | BitstringStatusListEntryEntity | undefined> {
|
|
92
104
|
if (!statusListId && !statusListCorrelationId) {
|
|
93
105
|
throw Error(`Cannot get statusList entry without either a statusList id or statusListCorrelationId`)
|
|
94
106
|
}
|
|
@@ -97,8 +109,12 @@ export class StatusListStore implements IStatusListStore {
|
|
|
97
109
|
throw Error(`Cannot get statusList entry without either a statusListIndex or entryCorrelationId`)
|
|
98
110
|
}
|
|
99
111
|
|
|
112
|
+
const statusList = statusListId
|
|
113
|
+
? await this.getStatusList({ id: statusListId })
|
|
114
|
+
: await this.getStatusList({ correlationId: statusListCorrelationId })
|
|
115
|
+
|
|
100
116
|
const result = await (
|
|
101
|
-
await this.getStatusListEntryRepo()
|
|
117
|
+
await this.getStatusListEntryRepo(statusList.type)
|
|
102
118
|
).findOne({
|
|
103
119
|
where: {
|
|
104
120
|
...(statusListId && { statusListId }),
|
|
@@ -118,7 +134,9 @@ export class StatusListStore implements IStatusListStore {
|
|
|
118
134
|
return result ?? undefined
|
|
119
135
|
}
|
|
120
136
|
|
|
121
|
-
async getStatusListEntryByCredentialId(
|
|
137
|
+
async getStatusListEntryByCredentialId(
|
|
138
|
+
args: IGetStatusListEntryByCredentialIdArgs,
|
|
139
|
+
): Promise<StatusListEntryEntity | BitstringStatusListEntryEntity | undefined> {
|
|
122
140
|
const credentialId = args.credentialId
|
|
123
141
|
if (!credentialId) {
|
|
124
142
|
throw Error('Can only get a credential by credentialId when a credentialId is supplied')
|
|
@@ -132,8 +150,8 @@ export class StatusListStore implements IStatusListStore {
|
|
|
132
150
|
...(args.entryCorrelationId && { correlationId: args.entryCorrelationId }),
|
|
133
151
|
credentialId,
|
|
134
152
|
}
|
|
135
|
-
|
|
136
|
-
const result = await (await this.getStatusListEntryRepo()).findOne({ where })
|
|
153
|
+
debug(`Entries: ${JSON.stringify(await (await this.getStatusListEntryRepo(statusList.type)).find(), null, 2)}`)
|
|
154
|
+
const result = await (await this.getStatusListEntryRepo(statusList.type)).findOne({ where })
|
|
137
155
|
|
|
138
156
|
if (!result && args.errorOnNotFound) {
|
|
139
157
|
throw Error(`Could not find status list credential id ${credentialId} for status list id ${statusList.id}`)
|
|
@@ -149,8 +167,12 @@ export class StatusListStore implements IStatusListStore {
|
|
|
149
167
|
error = true
|
|
150
168
|
}
|
|
151
169
|
if (!error) {
|
|
170
|
+
const statusList = await this.getStatusList({
|
|
171
|
+
id: args.statusListId,
|
|
172
|
+
correlationId: args.statusListCorrelationId,
|
|
173
|
+
})
|
|
152
174
|
const result = await (
|
|
153
|
-
await this.getStatusListEntryRepo()
|
|
175
|
+
await this.getStatusListEntryRepo(statusList.type)
|
|
154
176
|
).delete({
|
|
155
177
|
...(args.statusListId && { statusList: args.statusListId }),
|
|
156
178
|
...(args.entryCorrelationId && { correlationId: args.entryCorrelationId }),
|
|
@@ -169,10 +191,11 @@ export class StatusListStore implements IStatusListStore {
|
|
|
169
191
|
error = true
|
|
170
192
|
}
|
|
171
193
|
if (error) {
|
|
172
|
-
console.
|
|
194
|
+
console.error(`Could not delete statusList ${args.statusListId} entry by index ${args.statusListIndex}`)
|
|
173
195
|
} else {
|
|
196
|
+
const statusList = await this.getStatusList({ id: args.statusListId })
|
|
174
197
|
const result = await (
|
|
175
|
-
await this.getStatusListEntryRepo()
|
|
198
|
+
await this.getStatusListEntryRepo(statusList.type)
|
|
176
199
|
).delete({
|
|
177
200
|
...(args.statusListId && { statusList: args.statusListId }),
|
|
178
201
|
...(args.entryCorrelationId && { correlationId: args.entryCorrelationId }),
|
|
@@ -183,12 +206,14 @@ export class StatusListStore implements IStatusListStore {
|
|
|
183
206
|
return !error
|
|
184
207
|
}
|
|
185
208
|
|
|
186
|
-
async getStatusListEntries(args: IGetStatusListEntriesArgs): Promise<
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
209
|
+
async getStatusListEntries(args: IGetStatusListEntriesArgs): Promise<Array<IStatusListEntryEntity | IBitstringStatusListEntryEntity>> {
|
|
210
|
+
const statusList = await this.getStatusList({ id: args.statusListId })
|
|
211
|
+
const results = await (
|
|
212
|
+
await this.getStatusListEntryRepo(statusList.type)
|
|
213
|
+
).find({
|
|
214
|
+
where: { ...args?.filter, statusList: args.statusListId },
|
|
215
|
+
})
|
|
216
|
+
return results as Array<IStatusListEntryEntity | IBitstringStatusListEntryEntity>
|
|
192
217
|
}
|
|
193
218
|
|
|
194
219
|
private async getStatusListEntity(args: IGetStatusListArgs): Promise<StatusListEntity> {
|
|
@@ -208,7 +233,12 @@ export class StatusListStore implements IStatusListStore {
|
|
|
208
233
|
return result
|
|
209
234
|
}
|
|
210
235
|
|
|
211
|
-
async
|
|
236
|
+
async getStatusList(args: IGetStatusListArgs): Promise<IStatusListEntity | IBitstringStatusListEntity> {
|
|
237
|
+
const entity = await this.getStatusListEntity(args)
|
|
238
|
+
return statusListFrom(entity) as IStatusListEntity | IBitstringStatusListEntity
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
async getStatusLists(args: IGetStatusListsArgs): Promise<Array<IStatusListEntity | IBitstringStatusListEntity>> {
|
|
212
242
|
const result = await (
|
|
213
243
|
await this.getStatusListRepo()
|
|
214
244
|
).find({
|
|
@@ -219,7 +249,7 @@ export class StatusListStore implements IStatusListStore {
|
|
|
219
249
|
return []
|
|
220
250
|
}
|
|
221
251
|
|
|
222
|
-
return result.map((entity) => statusListFrom(entity))
|
|
252
|
+
return result.map((entity) => statusListFrom(entity) as IStatusListEntity | IBitstringStatusListEntity)
|
|
223
253
|
}
|
|
224
254
|
|
|
225
255
|
async addStatusList(args: IAddStatusListArgs): Promise<IStatusListEntity> {
|
|
@@ -240,7 +270,7 @@ export class StatusListStore implements IStatusListStore {
|
|
|
240
270
|
return statusListFrom(createdResult)
|
|
241
271
|
}
|
|
242
272
|
|
|
243
|
-
async updateStatusList(args: IUpdateStatusListIndexArgs): Promise<IStatusListEntity> {
|
|
273
|
+
async updateStatusList(args: IUpdateStatusListIndexArgs): Promise<IStatusListEntity | IBitstringStatusListEntity> {
|
|
244
274
|
const result = await this.getStatusList(args)
|
|
245
275
|
debug('Updating status list', result)
|
|
246
276
|
const entity = statusListEntityFrom(args)
|
|
@@ -251,7 +281,7 @@ export class StatusListStore implements IStatusListStore {
|
|
|
251
281
|
async removeStatusList(args: IRemoveStatusListArgs): Promise<boolean> {
|
|
252
282
|
const result = await this.getStatusListEntity(args)
|
|
253
283
|
|
|
254
|
-
await (await this.getStatusListEntryRepo()).delete({ statusListId: result.id })
|
|
284
|
+
await (await this.getStatusListEntryRepo(result.type)).delete({ statusListId: result.id })
|
|
255
285
|
const deletedEntity = await (await this.getStatusListRepo()).remove(result)
|
|
256
286
|
|
|
257
287
|
return Boolean(deletedEntity)
|
|
@@ -268,12 +298,20 @@ export class StatusListStore implements IStatusListStore {
|
|
|
268
298
|
return dataSource.getRepository(StatusList2021Entity)
|
|
269
299
|
case StatusListType.OAuthStatusList:
|
|
270
300
|
return dataSource.getRepository(OAuthStatusListEntity)
|
|
301
|
+
case StatusListType.BitstringStatusList:
|
|
302
|
+
return dataSource.getRepository(BitstringStatusListEntity)
|
|
271
303
|
default:
|
|
272
304
|
return dataSource.getRepository(StatusListEntity)
|
|
273
305
|
}
|
|
274
306
|
}
|
|
275
307
|
|
|
276
|
-
async getStatusListEntryRepo(): Promise<Repository<StatusListEntryEntity>> {
|
|
277
|
-
|
|
308
|
+
async getStatusListEntryRepo(type?: StatusListType): Promise<Repository<StatusListEntryEntity | BitstringStatusListEntryEntity>> {
|
|
309
|
+
const dataSource = await this.getDS()
|
|
310
|
+
switch (type) {
|
|
311
|
+
case StatusListType.BitstringStatusList:
|
|
312
|
+
return dataSource.getRepository(BitstringStatusListEntryEntity)
|
|
313
|
+
default:
|
|
314
|
+
return dataSource.getRepository(StatusListEntryEntity)
|
|
315
|
+
}
|
|
278
316
|
}
|
|
279
317
|
}
|
package/src/types/index.ts
CHANGED
|
@@ -1,14 +1,2 @@
|
|
|
1
|
-
export * from './issuanceBranding/issuanceBranding'
|
|
2
|
-
export * from './issuanceBranding/IAbstractIssuanceBrandingStore'
|
|
3
|
-
export * from './contact/contact'
|
|
4
|
-
export * from './contact/IAbstractContactStore'
|
|
5
|
-
export * from './presentationDefinition/presentationDefinition'
|
|
6
|
-
export * from './presentationDefinition/IAbstractPDStore'
|
|
7
|
-
export * from './validation/validation'
|
|
8
1
|
export * from './statusList/statusList'
|
|
9
2
|
export * from './statusList/IAbstractStatusListStore'
|
|
10
|
-
export * from './eventLogger/IAbstractEventLoggerStore'
|
|
11
|
-
export * from './eventLogger/eventLogger'
|
|
12
|
-
export * from './machineState/IAbstractMachineStateStore'
|
|
13
|
-
export * from './digitalCredential'
|
|
14
|
-
export * from './digitalCredential/IAbstractDigitalCredentialStore'
|
|
@@ -1,7 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CredentialProofFormat,
|
|
3
|
+
IIssuer,
|
|
4
|
+
StatusListCredential,
|
|
5
|
+
StatusListCredentialIdMode,
|
|
6
|
+
StatusListDriverType,
|
|
7
|
+
StatusListIndexingDirection,
|
|
8
|
+
StatusListType,
|
|
9
|
+
StatusPurpose2021,
|
|
10
|
+
} from '@sphereon/ssi-types'
|
|
1
11
|
import { FindOptionsWhere } from 'typeorm'
|
|
2
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
BitstringStatusPurpose,
|
|
14
|
+
IBitstringStatusListEntryEntity,
|
|
15
|
+
IOAuthStatusListEntity,
|
|
16
|
+
IStatusList2021Entity,
|
|
17
|
+
IStatusListEntryEntity,
|
|
18
|
+
} from './statusList'
|
|
3
19
|
|
|
4
|
-
export type FindStatusListArgs = FindOptionsWhere<IStatusList2021Entity | IOAuthStatusListEntity>[]
|
|
20
|
+
export type FindStatusListArgs = FindOptionsWhere<IStatusList2021Entity | IOAuthStatusListEntity>[] // TODO export our own FindOptionsWhere
|
|
5
21
|
export type FindStatusListEntryArgs = FindOptionsWhere<IStatusListEntryEntity>[] | FindOptionsWhere<IStatusListEntryEntity>
|
|
6
22
|
|
|
7
23
|
export interface IStatusListEntryAvailableArgs {
|
|
@@ -30,7 +46,7 @@ export interface IGetStatusListEntriesArgs {
|
|
|
30
46
|
filter?: FindStatusListEntryArgs
|
|
31
47
|
}
|
|
32
48
|
|
|
33
|
-
export type IAddStatusListEntryArgs = IStatusListEntryEntity
|
|
49
|
+
export type IAddStatusListEntryArgs = IStatusListEntryEntity | IBitstringStatusListEntryEntity
|
|
34
50
|
|
|
35
51
|
export interface IGetStatusListArgs {
|
|
36
52
|
id?: string
|
|
@@ -43,6 +59,40 @@ export interface IGetStatusListsArgs {
|
|
|
43
59
|
filter?: FindStatusListArgs
|
|
44
60
|
}
|
|
45
61
|
|
|
46
|
-
|
|
62
|
+
interface IBaseStatusListArgs {
|
|
63
|
+
id: string
|
|
64
|
+
correlationId: string
|
|
65
|
+
driverType: StatusListDriverType
|
|
66
|
+
credentialIdMode: StatusListCredentialIdMode
|
|
67
|
+
length: number
|
|
68
|
+
issuer: string | IIssuer
|
|
69
|
+
type: StatusListType
|
|
70
|
+
proofFormat: CredentialProofFormat
|
|
71
|
+
statusListCredential?: StatusListCredential
|
|
72
|
+
bitsPerStatus?: number
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type IStatusList2021Args = IBaseStatusListArgs & {
|
|
76
|
+
type: StatusListType.StatusList2021
|
|
77
|
+
indexingDirection: StatusListIndexingDirection
|
|
78
|
+
statusPurpose: StatusPurpose2021
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export type IOAuthStatusListArgs = IBaseStatusListArgs & {
|
|
82
|
+
type: StatusListType.OAuthStatusList
|
|
83
|
+
bitsPerStatus: number
|
|
84
|
+
expiresAt?: Date
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type IBitstringStatusListArgs = IBaseStatusListArgs & {
|
|
88
|
+
type: StatusListType.BitstringStatusList
|
|
89
|
+
statusPurpose: BitstringStatusPurpose | BitstringStatusPurpose[]
|
|
90
|
+
bitsPerStatus?: number
|
|
91
|
+
validFrom?: Date
|
|
92
|
+
validUntil?: Date
|
|
93
|
+
ttl?: number
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export type IAddStatusListArgs = IStatusList2021Args | IOAuthStatusListArgs | IBitstringStatusListArgs
|
|
47
97
|
|
|
48
|
-
export type IUpdateStatusListIndexArgs =
|
|
98
|
+
export type IUpdateStatusListIndexArgs = IAddStatusListArgs
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
+
type CredentialProofFormat,
|
|
3
|
+
type ICredentialStatus,
|
|
2
4
|
IIssuer,
|
|
5
|
+
RequireOneOf,
|
|
3
6
|
StatusListCredential,
|
|
4
7
|
StatusListCredentialIdMode,
|
|
5
8
|
StatusListDriverType,
|
|
6
9
|
StatusListIndexingDirection,
|
|
7
10
|
StatusListType,
|
|
8
11
|
StatusPurpose2021,
|
|
9
|
-
type CredentialProofFormat,
|
|
10
|
-
RequireOneOf,
|
|
11
12
|
} from '@sphereon/ssi-types'
|
|
12
13
|
import { StatusListEntity } from '../../entities/statusList/StatusListEntities'
|
|
13
14
|
|
|
@@ -21,6 +22,7 @@ export interface IStatusListEntity {
|
|
|
21
22
|
type: StatusListType
|
|
22
23
|
proofFormat: CredentialProofFormat
|
|
23
24
|
statusListCredential?: StatusListCredential
|
|
25
|
+
bitsPerStatus?: number
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
export interface IStatusList2021Entity extends IStatusListEntity {
|
|
@@ -33,6 +35,14 @@ export interface IOAuthStatusListEntity extends IStatusListEntity {
|
|
|
33
35
|
expiresAt?: Date
|
|
34
36
|
}
|
|
35
37
|
|
|
38
|
+
export interface IBitstringStatusListEntity extends IStatusListEntity {
|
|
39
|
+
statusPurpose: BitstringStatusPurpose | Array<BitstringStatusPurpose>
|
|
40
|
+
bitsPerStatus?: number
|
|
41
|
+
validFrom?: Date
|
|
42
|
+
validUntil?: Date
|
|
43
|
+
ttl?: number
|
|
44
|
+
}
|
|
45
|
+
|
|
36
46
|
export type IStatusListEntryEntity = RequireOneOf<
|
|
37
47
|
{
|
|
38
48
|
statusList: StatusListEntity
|
|
@@ -45,3 +55,41 @@ export type IStatusListEntryEntity = RequireOneOf<
|
|
|
45
55
|
},
|
|
46
56
|
'statusList' | 'statusListId'
|
|
47
57
|
>
|
|
58
|
+
|
|
59
|
+
export type BitstringStatusPurpose = 'revocation' | 'suspension' | 'refresh' | 'message' | string // From vc-bitstring-status-lists without pulling in the whole dep for just this one type
|
|
60
|
+
|
|
61
|
+
export type BitstringStatusMessage = {
|
|
62
|
+
status: string
|
|
63
|
+
message?: string
|
|
64
|
+
[x: string]: any
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface BitstringStatusListEntryCredentialStatus extends ICredentialStatus {
|
|
68
|
+
type: 'BitstringStatusListEntry'
|
|
69
|
+
statusPurpose: BitstringStatusPurpose | Array<BitstringStatusPurpose>
|
|
70
|
+
statusListIndex: string
|
|
71
|
+
statusListCredential: string
|
|
72
|
+
bitsPerStatus?: number
|
|
73
|
+
statusMessage?: Array<BitstringStatusMessage>
|
|
74
|
+
statusReference?: string | Array<string>
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type BitstringStatusListArgs = {
|
|
78
|
+
statusPurpose: BitstringStatusPurpose
|
|
79
|
+
bitsPerStatus: number
|
|
80
|
+
ttl?: number
|
|
81
|
+
validFrom?: Date
|
|
82
|
+
validUntil?: Date
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface IBitstringStatusListEntryEntity {
|
|
86
|
+
statusListId: string
|
|
87
|
+
statusListIndex: number
|
|
88
|
+
credentialId?: string
|
|
89
|
+
credentialHash?: string
|
|
90
|
+
entryCorrelationId?: string
|
|
91
|
+
statusPurpose: string
|
|
92
|
+
bitsPerStatus?: number
|
|
93
|
+
statusMessage?: Array<BitstringStatusMessage>
|
|
94
|
+
statusReference?: string | Array<string>
|
|
95
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { type ValidationConstraint } from '@sphereon/ssi-sdk.data-store-types'
|
|
1
2
|
import { ValidationError } from 'class-validator'
|
|
2
|
-
import { type ValidationConstraint } from '../types'
|
|
3
3
|
|
|
4
4
|
export const getConstraint = (validation: ValidationError): ValidationConstraint | undefined => {
|
|
5
5
|
if (validation.children && validation.children.length > 0) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
MetadataTypes,
|
|
3
2
|
Connection,
|
|
4
3
|
ConnectionConfig,
|
|
5
4
|
Contact,
|
|
@@ -8,6 +7,7 @@ import type {
|
|
|
8
7
|
ElectronicAddress,
|
|
9
8
|
Identity,
|
|
10
9
|
MetadataItem,
|
|
10
|
+
MetadataTypes,
|
|
11
11
|
NaturalPerson,
|
|
12
12
|
NonPersistedConnection,
|
|
13
13
|
NonPersistedConnectionConfig,
|
|
@@ -30,23 +30,23 @@ import type {
|
|
|
30
30
|
PartyRelationship,
|
|
31
31
|
PartyType,
|
|
32
32
|
PhysicalAddress,
|
|
33
|
-
} from '
|
|
34
|
-
import {
|
|
35
|
-
import { IdentityEntity } from '../../entities/contact/IdentityEntity'
|
|
36
|
-
import { ElectronicAddressEntity } from '../../entities/contact/ElectronicAddressEntity'
|
|
37
|
-
import { PartyRelationshipEntity } from '../../entities/contact/PartyRelationshipEntity'
|
|
33
|
+
} from '@sphereon/ssi-sdk.data-store-types'
|
|
34
|
+
import { BaseConfigEntity } from '../../entities/contact/BaseConfigEntity'
|
|
38
35
|
import { BaseContactEntity } from '../../entities/contact/BaseContactEntity'
|
|
39
|
-
import { NaturalPersonEntity } from '../../entities/contact/NaturalPersonEntity'
|
|
40
|
-
import { OrganizationEntity } from '../../entities/contact/OrganizationEntity'
|
|
41
36
|
import { ConnectionEntity } from '../../entities/contact/ConnectionEntity'
|
|
42
|
-
import {
|
|
37
|
+
import { ContactMetadataItemEntity } from '../../entities/contact/ContactMetadataItemEntity'
|
|
43
38
|
import { CorrelationIdentifierEntity } from '../../entities/contact/CorrelationIdentifierEntity'
|
|
44
39
|
import { DidAuthConfigEntity } from '../../entities/contact/DidAuthConfigEntity'
|
|
40
|
+
import { ElectronicAddressEntity } from '../../entities/contact/ElectronicAddressEntity'
|
|
41
|
+
import { IdentityEntity } from '../../entities/contact/IdentityEntity'
|
|
45
42
|
import { IdentityMetadataItemEntity } from '../../entities/contact/IdentityMetadataItemEntity'
|
|
43
|
+
import { NaturalPersonEntity } from '../../entities/contact/NaturalPersonEntity'
|
|
46
44
|
import { OpenIdConfigEntity } from '../../entities/contact/OpenIdConfigEntity'
|
|
45
|
+
import { OrganizationEntity } from '../../entities/contact/OrganizationEntity'
|
|
46
|
+
import { PartyEntity } from '../../entities/contact/PartyEntity'
|
|
47
|
+
import { PartyRelationshipEntity } from '../../entities/contact/PartyRelationshipEntity'
|
|
47
48
|
import { PartyTypeEntity } from '../../entities/contact/PartyTypeEntity'
|
|
48
49
|
import { PhysicalAddressEntity } from '../../entities/contact/PhysicalAddressEntity'
|
|
49
|
-
import { ContactMetadataItemEntity } from '../../entities/contact/ContactMetadataItemEntity'
|
|
50
50
|
import { replaceNullWithUndefined } from '../FormattingUtils'
|
|
51
51
|
|
|
52
52
|
export const partyEntityFrom = (party: NonPersistedParty): PartyEntity => {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { defaultHasher } from '@sphereon/ssi-sdk.core'
|
|
2
|
+
import type { AddCredentialArgs, DigitalCredential, NonPersistedDigitalCredential } from '@sphereon/ssi-sdk.data-store-types'
|
|
3
|
+
import { CredentialDocumentFormat, DocumentType, RegulationType } from '@sphereon/ssi-sdk.data-store-types'
|
|
1
4
|
import {
|
|
2
5
|
CredentialMapper,
|
|
3
6
|
DocumentFormat,
|
|
@@ -10,10 +13,7 @@ import {
|
|
|
10
13
|
} from '@sphereon/ssi-types'
|
|
11
14
|
import { computeEntryHash } from '@veramo/utils'
|
|
12
15
|
import { DigitalCredentialEntity } from '../../entities/digitalCredential/DigitalCredentialEntity'
|
|
13
|
-
import type { AddCredentialArgs, DigitalCredential, NonPersistedDigitalCredential } from '../../types'
|
|
14
|
-
import { CredentialDocumentFormat, DocumentType, RegulationType } from '../../types'
|
|
15
16
|
import { replaceNullWithUndefined } from '../FormattingUtils'
|
|
16
|
-
import { defaultHasher } from '@sphereon/ssi-sdk.core'
|
|
17
17
|
|
|
18
18
|
function determineDocumentType(raw: string): DocumentType {
|
|
19
19
|
const rawDocument = parseRawDocument(raw)
|
|
@@ -51,24 +51,6 @@ export function parseRawDocument(raw: string): OriginalVerifiableCredential | Or
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export function ensureRawDocument(input: string | object): string {
|
|
55
|
-
if (typeof input === 'string') {
|
|
56
|
-
if (isHex(input) || ObjectUtils.isBase64(input)) {
|
|
57
|
-
// mso_mdoc
|
|
58
|
-
return input
|
|
59
|
-
} else if (CredentialMapper.isJwtEncoded(input) || CredentialMapper.isSdJwtEncoded(input)) {
|
|
60
|
-
return input
|
|
61
|
-
}
|
|
62
|
-
throw Error('Unknown input to be mapped as rawDocument')
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
try {
|
|
66
|
-
return JSON.stringify(input)
|
|
67
|
-
} catch (e) {
|
|
68
|
-
throw new Error(`Can't stringify to a raw credential: ${input}`)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
54
|
function determineCredentialDocumentFormat(documentFormat: DocumentFormat): CredentialDocumentFormat {
|
|
73
55
|
switch (documentFormat) {
|
|
74
56
|
case DocumentFormat.JSONLD:
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ActivityLoggingEvent, AuditLoggingEvent } from '@sphereon/ssi-sdk.core'
|
|
2
|
+
import type { NonPersistedActivityLoggingEvent, NonPersistedAuditLoggingEvent } from '@sphereon/ssi-sdk.data-store-types'
|
|
2
3
|
import { LoggingEventType } from '@sphereon/ssi-types'
|
|
3
|
-
import { replaceNullWithUndefined } from '../FormattingUtils'
|
|
4
4
|
import { AuditEventEntity } from '../../entities/eventLogger/AuditEventEntity'
|
|
5
|
-
import
|
|
5
|
+
import { replaceNullWithUndefined } from '../FormattingUtils'
|
|
6
6
|
|
|
7
7
|
export const auditEventFrom = (event: AuditEventEntity): AuditLoggingEvent => {
|
|
8
8
|
const result: AuditLoggingEvent = {
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import { replaceNullWithUndefined } from '../FormattingUtils'
|
|
2
|
-
import { isEmptyString } from '../../entities/validators'
|
|
3
|
-
import { CredentialBrandingEntity } from '../../entities/issuanceBranding/CredentialBrandingEntity'
|
|
4
|
-
import { BaseLocaleBrandingEntity } from '../../entities/issuanceBranding/BaseLocaleBrandingEntity'
|
|
5
|
-
import { IssuerBrandingEntity } from '../../entities/issuanceBranding/IssuerBrandingEntity'
|
|
6
|
-
import { ImageAttributesEntity } from '../../entities/issuanceBranding/ImageAttributesEntity'
|
|
7
|
-
import { BackgroundAttributesEntity } from '../../entities/issuanceBranding/BackgroundAttributesEntity'
|
|
8
|
-
import { TextAttributesEntity } from '../../entities/issuanceBranding/TextAttributesEntity'
|
|
9
|
-
import { IssuerLocaleBrandingEntity } from '../../entities/issuanceBranding/IssuerLocaleBrandingEntity'
|
|
10
|
-
import { CredentialLocaleBrandingEntity } from '../../entities/issuanceBranding/CredentialLocaleBrandingEntity'
|
|
11
|
-
import { ImageDimensionsEntity } from '../../entities/issuanceBranding/ImageDimensionsEntity'
|
|
12
|
-
import { CredentialClaimsEntity } from '../../entities/issuanceBranding/CredentialClaimsEntity'
|
|
13
1
|
import type {
|
|
14
2
|
IBasicBackgroundAttributes,
|
|
15
3
|
IBasicCredentialBranding,
|
|
@@ -23,7 +11,19 @@ import type {
|
|
|
23
11
|
ICredentialBranding,
|
|
24
12
|
IIssuerBranding,
|
|
25
13
|
ILocaleBranding,
|
|
26
|
-
} from '
|
|
14
|
+
} from '@sphereon/ssi-sdk.data-store-types'
|
|
15
|
+
import { BackgroundAttributesEntity } from '../../entities/issuanceBranding/BackgroundAttributesEntity'
|
|
16
|
+
import { BaseLocaleBrandingEntity } from '../../entities/issuanceBranding/BaseLocaleBrandingEntity'
|
|
17
|
+
import { CredentialBrandingEntity } from '../../entities/issuanceBranding/CredentialBrandingEntity'
|
|
18
|
+
import { CredentialClaimsEntity } from '../../entities/issuanceBranding/CredentialClaimsEntity'
|
|
19
|
+
import { CredentialLocaleBrandingEntity } from '../../entities/issuanceBranding/CredentialLocaleBrandingEntity'
|
|
20
|
+
import { ImageAttributesEntity } from '../../entities/issuanceBranding/ImageAttributesEntity'
|
|
21
|
+
import { ImageDimensionsEntity } from '../../entities/issuanceBranding/ImageDimensionsEntity'
|
|
22
|
+
import { IssuerBrandingEntity } from '../../entities/issuanceBranding/IssuerBrandingEntity'
|
|
23
|
+
import { IssuerLocaleBrandingEntity } from '../../entities/issuanceBranding/IssuerLocaleBrandingEntity'
|
|
24
|
+
import { TextAttributesEntity } from '../../entities/issuanceBranding/TextAttributesEntity'
|
|
25
|
+
import { isEmptyString } from '../../entities/validators'
|
|
26
|
+
import { replaceNullWithUndefined } from '../FormattingUtils'
|
|
27
27
|
|
|
28
28
|
export const credentialBrandingFrom = (credentialBranding: CredentialBrandingEntity): ICredentialBranding => {
|
|
29
29
|
const result: ICredentialBranding = {
|
|
@@ -1,58 +1,67 @@
|
|
|
1
|
-
import { PresentationDefinitionItemEntity } from '../../entities/presentationDefinition/PresentationDefinitionItemEntity'
|
|
2
1
|
import type { IPresentationDefinition } from '@sphereon/pex'
|
|
3
|
-
import type {
|
|
2
|
+
import type { DcqlQueryItem, NonPersistedDcqlQueryItem, PartialDcqlQueryItem } from '@sphereon/ssi-sdk.data-store-types'
|
|
4
3
|
import * as blakepkg from 'blakejs'
|
|
4
|
+
import { DcqlQuery } from 'dcql'
|
|
5
|
+
import { DcqlQueryItemEntity } from '../../entities/presentationDefinition/DcqlQueryItemEntity'
|
|
5
6
|
import { replaceNullWithUndefined } from '../FormattingUtils'
|
|
6
|
-
import type { DcqlQueryREST } from '@sphereon/ssi-types'
|
|
7
7
|
|
|
8
|
-
export const
|
|
9
|
-
const result:
|
|
8
|
+
export const dcqlQueryItemFrom = (entity: DcqlQueryItemEntity): DcqlQueryItem => {
|
|
9
|
+
const result: DcqlQueryItem = {
|
|
10
10
|
id: entity.id,
|
|
11
11
|
tenantId: entity.tenantId,
|
|
12
|
-
|
|
12
|
+
queryId: entity.queryId,
|
|
13
13
|
version: entity.version,
|
|
14
14
|
name: entity.name,
|
|
15
15
|
purpose: entity.purpose,
|
|
16
|
-
|
|
17
|
-
dcqlPayload: JSON.parse(entity.dcqlPayload) as DcqlQueryREST,
|
|
16
|
+
query: DcqlQuery.parse(JSON.parse(entity.query)),
|
|
18
17
|
createdAt: entity.createdAt,
|
|
19
18
|
lastUpdatedAt: entity.lastUpdatedAt,
|
|
20
19
|
}
|
|
21
20
|
|
|
21
|
+
if (result.query) {
|
|
22
|
+
DcqlQuery.validate(result.query)
|
|
23
|
+
}
|
|
22
24
|
return replaceNullWithUndefined(result)
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
export const
|
|
26
|
-
const entity = new
|
|
27
|
+
export const dcqlQueryEntityItemFrom = (item: NonPersistedDcqlQueryItem): DcqlQueryItemEntity => {
|
|
28
|
+
const entity = new DcqlQueryItemEntity()
|
|
27
29
|
|
|
28
30
|
entity.tenantId = item.tenantId
|
|
29
|
-
entity.
|
|
31
|
+
entity.queryId = item.queryId!
|
|
30
32
|
entity.version = item.version
|
|
31
33
|
entity.name = item.name
|
|
32
34
|
entity.purpose = item.purpose
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
if (item.query) {
|
|
36
|
+
const dcqlQuery = DcqlQuery.parse(item.query)
|
|
37
|
+
DcqlQuery.validate(dcqlQuery)
|
|
38
|
+
entity.query = JSON.stringify(item.query)
|
|
39
|
+
}
|
|
35
40
|
return entity
|
|
36
41
|
}
|
|
37
42
|
|
|
38
|
-
function hashPayload(payload: IPresentationDefinition): string {
|
|
43
|
+
function hashPayload(payload: IPresentationDefinition | DcqlQuery): string {
|
|
39
44
|
return blakepkg.blake2bHex(JSON.stringify(payload))
|
|
40
45
|
}
|
|
41
46
|
|
|
42
|
-
export function isPresentationDefinitionEqual(base:
|
|
47
|
+
export function isPresentationDefinitionEqual(base: PartialDcqlQueryItem, compare: PartialDcqlQueryItem): boolean {
|
|
43
48
|
if (
|
|
44
|
-
base.
|
|
45
|
-
base.tenantId
|
|
49
|
+
base.queryId !== compare.queryId ||
|
|
50
|
+
base.tenantId !== compare.tenantId ||
|
|
46
51
|
base.version !== compare.version ||
|
|
47
|
-
base.name
|
|
48
|
-
base.purpose
|
|
52
|
+
base.name !== compare.name ||
|
|
53
|
+
base.purpose !== compare.purpose
|
|
49
54
|
) {
|
|
50
55
|
return false
|
|
51
56
|
}
|
|
52
57
|
|
|
53
|
-
if (base.
|
|
54
|
-
|
|
58
|
+
if (base.query && compare.query) {
|
|
59
|
+
if (hashPayload(base.query) !== hashPayload(compare.query)) {
|
|
60
|
+
return false
|
|
61
|
+
}
|
|
62
|
+
} else if (base.query || compare.query) {
|
|
63
|
+
return false
|
|
55
64
|
}
|
|
56
65
|
|
|
57
|
-
return
|
|
66
|
+
return true
|
|
58
67
|
}
|