@sphereon/ssi-sdk.data-store 0.34.1-feature.FIDES.1.274 → 0.34.1-feature.IDK.11.48
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,20 +1,20 @@
|
|
|
1
|
+
import { type OrPromise } from '@sphereon/ssi-types'
|
|
2
|
+
import { DataSource, In, Repository } from 'typeorm'
|
|
3
|
+
import { AbstractPDStore } from './AbstractPDStore'
|
|
4
|
+
import Debug from 'debug'
|
|
1
5
|
import type {
|
|
2
|
-
DcqlQueryItem,
|
|
3
|
-
DcqlQueryItemFilter,
|
|
4
6
|
DeleteDefinitionArgs,
|
|
5
7
|
DeleteDefinitionsArgs,
|
|
6
8
|
GetDefinitionArgs,
|
|
7
9
|
GetDefinitionsArgs,
|
|
8
10
|
HasDefinitionArgs,
|
|
9
11
|
HasDefinitionsArgs,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
import { DcqlQueryItemEntity } from '../entities/presentationDefinition/DcqlQueryItemEntity'
|
|
17
|
-
import { dcqlQueryEntityItemFrom, dcqlQueryItemFrom } from '../utils/presentationDefinition/MappingUtils'
|
|
12
|
+
NonPersistedPresentationDefinitionItem,
|
|
13
|
+
PresentationDefinitionItem,
|
|
14
|
+
PresentationDefinitionItemFilter,
|
|
15
|
+
} from '../types'
|
|
16
|
+
import { PresentationDefinitionItemEntity } from '../entities/presentationDefinition/PresentationDefinitionItemEntity'
|
|
17
|
+
import { presentationDefinitionEntityItemFrom, presentationDefinitionItemFrom } from '../utils/presentationDefinition/MappingUtils'
|
|
18
18
|
|
|
19
19
|
const debug: Debug.Debugger = Debug('sphereon:ssi-sdk:pd-store')
|
|
20
20
|
|
|
@@ -26,22 +26,22 @@ export class PDStore extends AbstractPDStore {
|
|
|
26
26
|
this.dbConnection = dbConnection
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
getDefinition = async (args: GetDefinitionArgs): Promise<
|
|
29
|
+
getDefinition = async (args: GetDefinitionArgs): Promise<PresentationDefinitionItem> => {
|
|
30
30
|
const { itemId } = args ?? {}
|
|
31
|
-
const pdRepository = (await this.dbConnection).getRepository(
|
|
32
|
-
const result:
|
|
31
|
+
const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity)
|
|
32
|
+
const result: PresentationDefinitionItemEntity | null = await pdRepository.findOne({
|
|
33
33
|
where: { id: itemId },
|
|
34
34
|
})
|
|
35
35
|
if (!result) {
|
|
36
36
|
return Promise.reject(Error(`No presentation definition item found for id: ${itemId}`))
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
return
|
|
39
|
+
return presentationDefinitionItemFrom(result)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
hasDefinition = async (args: HasDefinitionArgs): Promise<boolean> => {
|
|
43
43
|
const { itemId } = args ?? {}
|
|
44
|
-
const pdRepository = (await this.dbConnection).getRepository(
|
|
44
|
+
const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity)
|
|
45
45
|
|
|
46
46
|
const resultCount: number = await pdRepository.count({
|
|
47
47
|
where: { id: itemId },
|
|
@@ -52,7 +52,7 @@ export class PDStore extends AbstractPDStore {
|
|
|
52
52
|
|
|
53
53
|
hasDefinitions = async (args: HasDefinitionsArgs): Promise<boolean> => {
|
|
54
54
|
const { filter } = args
|
|
55
|
-
const pdRepository = (await this.dbConnection).getRepository(
|
|
55
|
+
const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity)
|
|
56
56
|
|
|
57
57
|
const resultCount: number = await pdRepository.count({
|
|
58
58
|
...(filter && { where: cleanFilter(filter) }),
|
|
@@ -60,67 +60,67 @@ export class PDStore extends AbstractPDStore {
|
|
|
60
60
|
return resultCount > 0
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
getDefinitions = async (args: GetDefinitionsArgs): Promise<Array<
|
|
63
|
+
getDefinitions = async (args: GetDefinitionsArgs): Promise<Array<PresentationDefinitionItem>> => {
|
|
64
64
|
const { filter } = args
|
|
65
|
-
const pdRepository = (await this.dbConnection).getRepository(
|
|
65
|
+
const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity)
|
|
66
66
|
const initialResult = await this.findIds(pdRepository, filter)
|
|
67
|
-
const result: Array<
|
|
67
|
+
const result: Array<PresentationDefinitionItemEntity> = await pdRepository.find({
|
|
68
68
|
where: {
|
|
69
|
-
id: In(initialResult.map((entity:
|
|
69
|
+
id: In(initialResult.map((entity: PresentationDefinitionItemEntity) => entity.id)),
|
|
70
70
|
},
|
|
71
71
|
order: {
|
|
72
72
|
version: 'DESC',
|
|
73
73
|
},
|
|
74
74
|
})
|
|
75
75
|
|
|
76
|
-
return result.map((entity:
|
|
76
|
+
return result.map((entity: PresentationDefinitionItemEntity) => presentationDefinitionItemFrom(entity))
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
addDefinition = async (item:
|
|
80
|
-
const pdRepository = (await this.dbConnection).getRepository(
|
|
79
|
+
addDefinition = async (item: NonPersistedPresentationDefinitionItem): Promise<PresentationDefinitionItem> => {
|
|
80
|
+
const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity)
|
|
81
81
|
|
|
82
|
-
const entity:
|
|
82
|
+
const entity: PresentationDefinitionItemEntity = presentationDefinitionEntityItemFrom(item)
|
|
83
83
|
debug('Adding presentation definition entity', item)
|
|
84
|
-
const result:
|
|
84
|
+
const result: PresentationDefinitionItemEntity = await pdRepository.save(entity, {
|
|
85
85
|
transaction: true,
|
|
86
86
|
})
|
|
87
87
|
|
|
88
|
-
return
|
|
88
|
+
return presentationDefinitionItemFrom(result)
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
updateDefinition = async (item:
|
|
92
|
-
const pdRepository = (await this.dbConnection).getRepository(
|
|
91
|
+
updateDefinition = async (item: PresentationDefinitionItem): Promise<PresentationDefinitionItem> => {
|
|
92
|
+
const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity)
|
|
93
93
|
|
|
94
|
-
const result:
|
|
94
|
+
const result: PresentationDefinitionItemEntity | null = await pdRepository.findOne({
|
|
95
95
|
where: { id: item.id },
|
|
96
96
|
})
|
|
97
97
|
if (!result) {
|
|
98
98
|
return Promise.reject(Error(`No presentation definition entity found for id: ${item.id}`))
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
const updatedEntity: Partial<
|
|
101
|
+
const updatedEntity: Partial<PresentationDefinitionItemEntity> = {
|
|
102
102
|
...result,
|
|
103
103
|
}
|
|
104
104
|
updatedEntity.tenantId = item.tenantId
|
|
105
|
-
updatedEntity.
|
|
105
|
+
updatedEntity.definitionId = item.definitionId!
|
|
106
106
|
updatedEntity.version = item.version
|
|
107
107
|
updatedEntity.name = item.name
|
|
108
108
|
updatedEntity.purpose = item.purpose
|
|
109
|
-
updatedEntity.
|
|
109
|
+
updatedEntity.definitionPayload = JSON.stringify(item.definitionPayload!)
|
|
110
110
|
|
|
111
111
|
debug('Updating presentation definition entity', updatedEntity)
|
|
112
|
-
const updateResult:
|
|
112
|
+
const updateResult: PresentationDefinitionItemEntity = await pdRepository.save(updatedEntity, {
|
|
113
113
|
transaction: true,
|
|
114
114
|
})
|
|
115
115
|
|
|
116
|
-
return
|
|
116
|
+
return presentationDefinitionItemFrom(updateResult)
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
deleteDefinition = async (args: DeleteDefinitionArgs): Promise<void> => {
|
|
120
120
|
const { itemId } = args
|
|
121
121
|
|
|
122
|
-
const pdRepository = (await this.dbConnection).getRepository(
|
|
123
|
-
const entity:
|
|
122
|
+
const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity)
|
|
123
|
+
const entity: PresentationDefinitionItemEntity | null = await pdRepository.findOne({
|
|
124
124
|
where: { id: itemId },
|
|
125
125
|
})
|
|
126
126
|
|
|
@@ -134,12 +134,12 @@ export class PDStore extends AbstractPDStore {
|
|
|
134
134
|
|
|
135
135
|
deleteDefinitions = async (args: DeleteDefinitionsArgs): Promise<number> => {
|
|
136
136
|
const { filter } = args
|
|
137
|
-
const pdRepository = (await this.dbConnection).getRepository(
|
|
137
|
+
const pdRepository = (await this.dbConnection).getRepository(PresentationDefinitionItemEntity)
|
|
138
138
|
const initialResult = await this.findIds(pdRepository, filter)
|
|
139
139
|
|
|
140
|
-
const result: Array<
|
|
140
|
+
const result: Array<PresentationDefinitionItemEntity> = await pdRepository.find({
|
|
141
141
|
where: {
|
|
142
|
-
id: In(initialResult.map((entity:
|
|
142
|
+
id: In(initialResult.map((entity: PresentationDefinitionItemEntity) => entity.id)),
|
|
143
143
|
},
|
|
144
144
|
})
|
|
145
145
|
|
|
@@ -151,9 +151,9 @@ export class PDStore extends AbstractPDStore {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
findIds = async (
|
|
154
|
-
pdRepository: Repository<
|
|
155
|
-
filter: Array<
|
|
156
|
-
): Promise<Array<
|
|
154
|
+
pdRepository: Repository<PresentationDefinitionItemEntity>,
|
|
155
|
+
filter: Array<PresentationDefinitionItemFilter> | undefined,
|
|
156
|
+
): Promise<Array<PresentationDefinitionItemEntity>> => {
|
|
157
157
|
const idFilters = filter?.map((f) => f.id).filter((id) => id !== undefined && id !== null)
|
|
158
158
|
if (idFilters && idFilters.length > 0 && idFilters.length === filter?.length) {
|
|
159
159
|
return await pdRepository.find({
|
|
@@ -167,15 +167,15 @@ export class PDStore extends AbstractPDStore {
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
const cleanFilter = (filter: Array<
|
|
170
|
+
const cleanFilter = (filter: Array<PresentationDefinitionItemFilter> | undefined): Array<PresentationDefinitionItemFilter> | undefined => {
|
|
171
171
|
if (filter === undefined) {
|
|
172
172
|
return undefined
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
return filter.map((item) => {
|
|
176
|
-
const cleanedItem:
|
|
176
|
+
const cleanedItem: PresentationDefinitionItemFilter = {}
|
|
177
177
|
for (const key in item) {
|
|
178
|
-
const value = item[key as keyof
|
|
178
|
+
const value = item[key as keyof PresentationDefinitionItemFilter]
|
|
179
179
|
if (value !== undefined) {
|
|
180
180
|
;(cleanedItem as any)[key] = value
|
|
181
181
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { BitstringStatusListEntryEntity } from '../entities/statusList/BitstringStatusListEntryEntity'
|
|
2
1
|
import { StatusListEntryEntity } from '../entities/statusList/StatusList2021EntryEntity'
|
|
3
2
|
import type {
|
|
4
3
|
IAddStatusListArgs,
|
|
@@ -15,6 +14,7 @@ import type {
|
|
|
15
14
|
IUpdateStatusListIndexArgs,
|
|
16
15
|
} from '../types'
|
|
17
16
|
import { IStatusListEntity, IStatusListEntryEntity } from '../types'
|
|
17
|
+
import { BitstringStatusListEntryEntity } from '../entities/statusList/BitstringStatusListEntryEntity'
|
|
18
18
|
|
|
19
19
|
export interface IStatusListStore {
|
|
20
20
|
getStatusList(args: IGetStatusListArgs): Promise<IStatusListEntity | IBitstringStatusListEntity>
|
|
@@ -1,9 +1,9 @@
|
|
|
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 { BitstringStatusListEntryEntity } from '../entities/statusList/BitstringStatusListEntryEntity'
|
|
5
|
-
import { StatusListEntryEntity } from '../entities/statusList/StatusList2021EntryEntity'
|
|
6
4
|
import { BitstringStatusListEntity, OAuthStatusListEntity, StatusList2021Entity, StatusListEntity } from '../entities/statusList/StatusListEntities'
|
|
5
|
+
import { StatusListEntryEntity } from '../entities/statusList/StatusList2021EntryEntity'
|
|
6
|
+
import { BitstringStatusListEntryEntity } from '../entities/statusList/BitstringStatusListEntryEntity'
|
|
7
7
|
import {
|
|
8
8
|
IAddStatusListArgs,
|
|
9
9
|
IAddStatusListEntryArgs,
|
|
@@ -20,8 +20,8 @@ import {
|
|
|
20
20
|
IStatusListEntryEntity,
|
|
21
21
|
IUpdateStatusListIndexArgs,
|
|
22
22
|
} from '../types'
|
|
23
|
-
import { statusListEntityFrom, statusListFrom } from '../utils/statusList/MappingUtils'
|
|
24
23
|
import type { IStatusListStore } from './IStatusListStore'
|
|
24
|
+
import { statusListEntityFrom, statusListFrom } from '../utils/statusList/MappingUtils'
|
|
25
25
|
|
|
26
26
|
const debug = Debug('sphereon:ssi-sdk:data-store:status-list')
|
|
27
27
|
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ElectronicAddress,
|
|
3
|
+
Identity,
|
|
4
|
+
NonPersistedContact,
|
|
5
|
+
NonPersistedElectronicAddress,
|
|
6
|
+
NonPersistedIdentity,
|
|
7
|
+
NonPersistedPartyType,
|
|
8
|
+
NonPersistedPhysicalAddress,
|
|
9
|
+
PartialElectronicAddress,
|
|
10
|
+
PartialIdentity,
|
|
11
|
+
PartialParty,
|
|
12
|
+
PartialPartyRelationship,
|
|
13
|
+
PartialPartyType,
|
|
14
|
+
PartialPhysicalAddress,
|
|
15
|
+
Party,
|
|
16
|
+
PartyOrigin,
|
|
17
|
+
PartyRelationship,
|
|
18
|
+
PartyType,
|
|
19
|
+
PartyTypeType,
|
|
20
|
+
PhysicalAddress,
|
|
21
|
+
} from './contact'
|
|
22
|
+
|
|
23
|
+
export type FindPartyArgs = Array<PartialParty>
|
|
24
|
+
export type FindIdentityArgs = Array<PartialIdentity>
|
|
25
|
+
export type FindPartyTypeArgs = Array<PartialPartyType>
|
|
26
|
+
export type FindRelationshipArgs = Array<PartialPartyRelationship>
|
|
27
|
+
export type FindElectronicAddressArgs = Array<PartialElectronicAddress>
|
|
28
|
+
export type FindPhysicalAddressArgs = Array<PartialPhysicalAddress>
|
|
29
|
+
|
|
30
|
+
export type GetPartyArgs = {
|
|
31
|
+
partyId: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type GetPartiesArgs = {
|
|
35
|
+
filter?: FindPartyArgs
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type AddPartyArgs = {
|
|
39
|
+
uri?: string
|
|
40
|
+
partyType: NonPersistedPartyType
|
|
41
|
+
contact: NonPersistedContact
|
|
42
|
+
identities?: Array<NonPersistedIdentity>
|
|
43
|
+
electronicAddresses?: Array<NonPersistedElectronicAddress>
|
|
44
|
+
physicalAddresses?: Array<NonPersistedPhysicalAddress>
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type UpdatePartyArgs = {
|
|
48
|
+
party: Omit<Party, 'identities' | 'electronicAddresses' | 'partyType' | 'createdAt' | 'lastUpdatedAt'>
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type RemovePartyArgs = {
|
|
52
|
+
partyId: string
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type GetIdentityArgs = {
|
|
56
|
+
identityId: string
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export type GetIdentitiesArgs = {
|
|
60
|
+
filter?: FindIdentityArgs
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type AddIdentityArgs = {
|
|
64
|
+
partyId: string
|
|
65
|
+
identity: NonPersistedIdentity
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type UpdateIdentityArgs = {
|
|
69
|
+
identity: Identity
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export type RemoveIdentityArgs = {
|
|
73
|
+
identityId: string
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export type RemoveRelationshipArgs = {
|
|
77
|
+
relationshipId: string
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export type AddRelationshipArgs = {
|
|
81
|
+
leftId: string
|
|
82
|
+
rightId: string
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export type GetRelationshipArgs = {
|
|
86
|
+
relationshipId: string
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export type GetRelationshipsArgs = {
|
|
90
|
+
filter: FindRelationshipArgs
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export type UpdateRelationshipArgs = {
|
|
94
|
+
relationship: Omit<PartyRelationship, 'createdAt' | 'lastUpdatedAt'>
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export type AddPartyTypeArgs = {
|
|
98
|
+
type: PartyTypeType
|
|
99
|
+
origin: PartyOrigin
|
|
100
|
+
name: string
|
|
101
|
+
tenantId: string
|
|
102
|
+
description?: string
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export type GetPartyTypeArgs = {
|
|
106
|
+
partyTypeId: string
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export type GetPartyTypesArgs = {
|
|
110
|
+
filter?: FindPartyTypeArgs
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export type UpdatePartyTypeArgs = {
|
|
114
|
+
partyType: Omit<PartyType, 'createdAt' | 'lastUpdatedAt'>
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export type RemovePartyTypeArgs = {
|
|
118
|
+
partyTypeId: string
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export type GetElectronicAddressArgs = {
|
|
122
|
+
electronicAddressId: string
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export type GetElectronicAddressesArgs = {
|
|
126
|
+
filter?: FindElectronicAddressArgs
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export type AddElectronicAddressArgs = {
|
|
130
|
+
partyId: string
|
|
131
|
+
electronicAddress: NonPersistedElectronicAddress
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export type UpdateElectronicAddressArgs = {
|
|
135
|
+
electronicAddress: ElectronicAddress
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export type RemoveElectronicAddressArgs = {
|
|
139
|
+
electronicAddressId: string
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export type GetPhysicalAddressArgs = {
|
|
143
|
+
physicalAddressId: string
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export type GetPhysicalAddressesArgs = {
|
|
147
|
+
filter?: FindPhysicalAddressArgs
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export type AddPhysicalAddressArgs = {
|
|
151
|
+
partyId: string
|
|
152
|
+
physicalAddress: NonPersistedPhysicalAddress
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export type UpdatePhysicalAddressArgs = {
|
|
156
|
+
physicalAddress: PhysicalAddress
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export type RemovePhysicalAddressArgs = {
|
|
160
|
+
physicalAddressId: string
|
|
161
|
+
}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { ManagedIdentifierOptsOrResult } from '@sphereon/ssi-sdk-ext.identifier-resolution'
|
|
2
|
+
import { IIdentifier } from '@veramo/core'
|
|
3
|
+
import { IIssuerLocaleBranding } from '../issuanceBranding/issuanceBranding'
|
|
4
|
+
import { CredentialRole } from '../digitalCredential'
|
|
5
|
+
|
|
6
|
+
export type MetadataTypes = string | number | Date | boolean | undefined
|
|
7
|
+
|
|
8
|
+
export interface IMetadataEntity {
|
|
9
|
+
// TODO move to types
|
|
10
|
+
label: string
|
|
11
|
+
stringValue?: string
|
|
12
|
+
numberValue?: number
|
|
13
|
+
dateValue?: Date
|
|
14
|
+
boolValue?: boolean
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type Party = {
|
|
18
|
+
id: string
|
|
19
|
+
uri?: string
|
|
20
|
+
roles: Array<CredentialRole>
|
|
21
|
+
ownerId?: string
|
|
22
|
+
tenantId?: string
|
|
23
|
+
identities: Array<Identity>
|
|
24
|
+
electronicAddresses: Array<ElectronicAddress>
|
|
25
|
+
physicalAddresses: Array<PhysicalAddress>
|
|
26
|
+
contact: Contact
|
|
27
|
+
partyType: PartyType
|
|
28
|
+
/**
|
|
29
|
+
* TODO: Integrate branding logic here in the future. What we should do is make the issuance branding plugin part of the contact-manager and retrieve any branding there is.
|
|
30
|
+
*
|
|
31
|
+
* Currently, we are only defining the branding type within the SDK without implementing the associated logic. This is because:
|
|
32
|
+
* 1. We are combining two types from the SSI-SDK to create a new type that will be used across multiple places in the wallets (web & mobile).
|
|
33
|
+
* 2. While it makes sense to have this combined type in the SDK, the logic to support database connections for these types is complex. The types belong to different modules, and we don't use them together currently.
|
|
34
|
+
* 3. Implementing the full logic now would require significant changes and cross-module interactions, which we don't have the time to address at present.
|
|
35
|
+
*
|
|
36
|
+
* For now, we are defining the type here and will use it in the mobile wallet has the logic for it. This is a temporary solution until we have the resources to integrate the branding logic fully.
|
|
37
|
+
*/
|
|
38
|
+
branding?: IIssuerLocaleBranding
|
|
39
|
+
relationships: Array<PartyRelationship>
|
|
40
|
+
createdAt: Date
|
|
41
|
+
lastUpdatedAt: Date
|
|
42
|
+
}
|
|
43
|
+
export type NonPersistedParty = Omit<
|
|
44
|
+
Party,
|
|
45
|
+
| 'id'
|
|
46
|
+
| 'identities'
|
|
47
|
+
| 'electronicAddresses'
|
|
48
|
+
| 'physicalAddresses'
|
|
49
|
+
| 'contact'
|
|
50
|
+
| 'roles'
|
|
51
|
+
| 'partyType'
|
|
52
|
+
| 'relationships'
|
|
53
|
+
| 'createdAt'
|
|
54
|
+
| 'lastUpdatedAt'
|
|
55
|
+
> & {
|
|
56
|
+
identities?: Array<NonPersistedIdentity>
|
|
57
|
+
electronicAddresses?: Array<NonPersistedElectronicAddress>
|
|
58
|
+
physicalAddresses?: Array<NonPersistedPhysicalAddress>
|
|
59
|
+
contact: NonPersistedContact
|
|
60
|
+
partyType: NonPersistedPartyType
|
|
61
|
+
relationships?: Array<NonPersistedPartyRelationship>
|
|
62
|
+
}
|
|
63
|
+
export type PartialParty = Partial<
|
|
64
|
+
Omit<Party, 'identities' | 'electronicAddresses' | 'physicalAddresses' | 'contact' | 'partyType' | 'relationships'>
|
|
65
|
+
> & {
|
|
66
|
+
identities?: PartialIdentity
|
|
67
|
+
electronicAddresses?: PartialElectronicAddress
|
|
68
|
+
physicalAddresses?: PartialPhysicalAddress
|
|
69
|
+
contact?: PartialContact
|
|
70
|
+
partyType?: PartialPartyType
|
|
71
|
+
relationships?: PartialPartyRelationship
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type Identity = {
|
|
75
|
+
id: string
|
|
76
|
+
alias: string
|
|
77
|
+
ownerId?: string
|
|
78
|
+
tenantId?: string
|
|
79
|
+
origin: IdentityOrigin
|
|
80
|
+
roles: Array<CredentialRole>
|
|
81
|
+
identifier: CorrelationIdentifier
|
|
82
|
+
connection?: Connection
|
|
83
|
+
metadata?: Array<MetadataItem<MetadataTypes>>
|
|
84
|
+
createdAt: Date
|
|
85
|
+
lastUpdatedAt: Date
|
|
86
|
+
}
|
|
87
|
+
export type NonPersistedIdentity = Omit<Identity, 'id' | 'identifier' | 'connection' | 'metadata' | 'origin' | 'createdAt' | 'lastUpdatedAt'> & {
|
|
88
|
+
origin: IdentityOrigin
|
|
89
|
+
identifier: NonPersistedCorrelationIdentifier
|
|
90
|
+
connection?: NonPersistedConnection
|
|
91
|
+
metadata?: Array<NonPersistedMetadataItem<MetadataTypes>>
|
|
92
|
+
}
|
|
93
|
+
export type PartialIdentity = Partial<Omit<Identity, 'identifier' | 'connection' | 'metadata' | 'origin' | 'roles'>> & {
|
|
94
|
+
identifier?: PartialCorrelationIdentifier
|
|
95
|
+
connection?: PartialConnection
|
|
96
|
+
metadata?: PartialMetadataItem<MetadataTypes> // Usage: FindIdentityArgs = Array<PartialIdentity>
|
|
97
|
+
origin?: IdentityOrigin
|
|
98
|
+
roles?: CredentialRole
|
|
99
|
+
partyId?: string
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export type MetadataItem<T extends MetadataTypes> = {
|
|
103
|
+
id: string
|
|
104
|
+
label: string
|
|
105
|
+
value: T
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export type NonPersistedMetadataItem<T extends MetadataTypes> = Omit<MetadataItem<T>, 'id'>
|
|
109
|
+
export type PartialMetadataItem<T extends MetadataTypes> = Partial<MetadataItem<T>>
|
|
110
|
+
|
|
111
|
+
export type CorrelationIdentifier = {
|
|
112
|
+
id: string
|
|
113
|
+
ownerId?: string
|
|
114
|
+
tenantId?: string
|
|
115
|
+
type: CorrelationIdentifierType
|
|
116
|
+
correlationId: string
|
|
117
|
+
}
|
|
118
|
+
export type NonPersistedCorrelationIdentifier = Omit<CorrelationIdentifier, 'id'>
|
|
119
|
+
export type PartialCorrelationIdentifier = Partial<CorrelationIdentifier>
|
|
120
|
+
|
|
121
|
+
export type Connection = {
|
|
122
|
+
id: string
|
|
123
|
+
ownerId?: string
|
|
124
|
+
tenantId?: string
|
|
125
|
+
type: ConnectionType
|
|
126
|
+
config: ConnectionConfig
|
|
127
|
+
}
|
|
128
|
+
export type NonPersistedConnection = Omit<Connection, 'id' | 'config'> & {
|
|
129
|
+
config: NonPersistedConnectionConfig
|
|
130
|
+
}
|
|
131
|
+
export type PartialConnection = Partial<Omit<Connection, 'config'>> & {
|
|
132
|
+
config: PartialConnectionConfig
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export type OpenIdConfig = {
|
|
136
|
+
id: string
|
|
137
|
+
clientId: string
|
|
138
|
+
clientSecret: string
|
|
139
|
+
ownerId?: string
|
|
140
|
+
tenantId?: string
|
|
141
|
+
scopes: Array<string>
|
|
142
|
+
issuer: string
|
|
143
|
+
redirectUrl: string
|
|
144
|
+
dangerouslyAllowInsecureHttpRequests: boolean
|
|
145
|
+
clientAuthMethod: 'basic' | 'post' | undefined
|
|
146
|
+
}
|
|
147
|
+
export type NonPersistedOpenIdConfig = Omit<OpenIdConfig, 'id'>
|
|
148
|
+
export type PartialOpenIdConfig = Partial<OpenIdConfig>
|
|
149
|
+
|
|
150
|
+
export type DidAuthConfig = {
|
|
151
|
+
id: string
|
|
152
|
+
idOpts: ManagedIdentifierOptsOrResult
|
|
153
|
+
stateId: string
|
|
154
|
+
ownerId?: string
|
|
155
|
+
tenantId?: string
|
|
156
|
+
redirectUrl: string
|
|
157
|
+
sessionId: string
|
|
158
|
+
}
|
|
159
|
+
export type NonPersistedDidAuthConfig = Omit<DidAuthConfig, 'id'>
|
|
160
|
+
export type PartialDidAuthConfig = Partial<Omit<DidAuthConfig, 'identifier'>> & {
|
|
161
|
+
identifier: Partial<IIdentifier> // TODO, we need to create partials for sub types in IIdentifier
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export type ConnectionConfig = OpenIdConfig | DidAuthConfig
|
|
165
|
+
export type NonPersistedConnectionConfig = NonPersistedDidAuthConfig | NonPersistedOpenIdConfig
|
|
166
|
+
export type PartialConnectionConfig = PartialOpenIdConfig | PartialDidAuthConfig
|
|
167
|
+
|
|
168
|
+
export type NaturalPerson = {
|
|
169
|
+
id: string
|
|
170
|
+
firstName: string
|
|
171
|
+
lastName: string
|
|
172
|
+
middleName?: string
|
|
173
|
+
displayName: string
|
|
174
|
+
metadata?: Array<MetadataItem<MetadataTypes>>
|
|
175
|
+
ownerId?: string
|
|
176
|
+
tenantId?: string
|
|
177
|
+
createdAt: Date
|
|
178
|
+
lastUpdatedAt: Date
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export type NonPersistedNaturalPerson = Omit<NaturalPerson, 'id' | 'createdAt' | 'lastUpdatedAt'>
|
|
182
|
+
|
|
183
|
+
export type PartialNaturalPerson = Partial<Omit<NaturalPerson, 'metadata'>> & {
|
|
184
|
+
metadata?: PartialMetadataItem<MetadataTypes>
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export type Organization = {
|
|
188
|
+
id: string
|
|
189
|
+
legalName: string
|
|
190
|
+
displayName: string
|
|
191
|
+
metadata?: Array<MetadataItem<MetadataTypes>>
|
|
192
|
+
ownerId?: string
|
|
193
|
+
tenantId?: string
|
|
194
|
+
createdAt: Date
|
|
195
|
+
lastUpdatedAt: Date
|
|
196
|
+
}
|
|
197
|
+
export type NonPersistedOrganization = Omit<Organization, 'id' | 'createdAt' | 'lastUpdatedAt'>
|
|
198
|
+
export type PartialOrganization = Partial<Omit<Organization, 'metadata'>> & {
|
|
199
|
+
metadata?: PartialMetadataItem<MetadataTypes>
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export type Contact = NaturalPerson | Organization
|
|
203
|
+
export type NonPersistedContact = NonPersistedNaturalPerson | NonPersistedOrganization
|
|
204
|
+
export type PartialContact = PartialNaturalPerson | PartialOrganization
|
|
205
|
+
|
|
206
|
+
export type PartyType = {
|
|
207
|
+
id: string
|
|
208
|
+
type: PartyTypeType
|
|
209
|
+
origin: PartyOrigin
|
|
210
|
+
name: string
|
|
211
|
+
tenantId: string
|
|
212
|
+
description?: string
|
|
213
|
+
createdAt: Date
|
|
214
|
+
lastUpdatedAt: Date
|
|
215
|
+
}
|
|
216
|
+
export type NonPersistedPartyType = Omit<PartyType, 'id' | 'createdAt' | 'lastUpdatedAt'> & {
|
|
217
|
+
id?: string
|
|
218
|
+
}
|
|
219
|
+
export type PartialPartyType = Partial<PartyType>
|
|
220
|
+
|
|
221
|
+
export type PartyRelationship = {
|
|
222
|
+
id: string
|
|
223
|
+
leftId: string
|
|
224
|
+
rightId: string
|
|
225
|
+
ownerId?: string
|
|
226
|
+
tenantId?: string
|
|
227
|
+
createdAt: Date
|
|
228
|
+
lastUpdatedAt: Date
|
|
229
|
+
}
|
|
230
|
+
export type NonPersistedPartyRelationship = Omit<PartyRelationship, 'id' | 'createdAt' | 'lastUpdatedAt'>
|
|
231
|
+
export type PartialPartyRelationship = Partial<PartyRelationship>
|
|
232
|
+
|
|
233
|
+
export type ElectronicAddress = {
|
|
234
|
+
id: string
|
|
235
|
+
type: ElectronicAddressType
|
|
236
|
+
electronicAddress: string
|
|
237
|
+
ownerId?: string
|
|
238
|
+
tenantId?: string
|
|
239
|
+
createdAt: Date
|
|
240
|
+
lastUpdatedAt: Date
|
|
241
|
+
}
|
|
242
|
+
export type NonPersistedElectronicAddress = Omit<ElectronicAddress, 'id' | 'createdAt' | 'lastUpdatedAt'>
|
|
243
|
+
export type PartialElectronicAddress = Partial<ElectronicAddress> & {
|
|
244
|
+
partyId?: string
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export type PhysicalAddress = {
|
|
248
|
+
id: string
|
|
249
|
+
type: PhysicalAddressType
|
|
250
|
+
streetName: string
|
|
251
|
+
streetNumber: string
|
|
252
|
+
postalCode: string
|
|
253
|
+
cityName: string
|
|
254
|
+
provinceName: string
|
|
255
|
+
countryCode: string
|
|
256
|
+
buildingName?: string
|
|
257
|
+
ownerId?: string
|
|
258
|
+
tenantId?: string
|
|
259
|
+
createdAt: Date
|
|
260
|
+
lastUpdatedAt: Date
|
|
261
|
+
}
|
|
262
|
+
export type NonPersistedPhysicalAddress = Omit<PhysicalAddress, 'id' | 'createdAt' | 'lastUpdatedAt'>
|
|
263
|
+
export type PartialPhysicalAddress = Partial<PhysicalAddress> & {
|
|
264
|
+
partyId?: string
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export type ElectronicAddressType = 'email' | 'phone'
|
|
268
|
+
|
|
269
|
+
export type PhysicalAddressType = 'home' | 'visit' | 'postal'
|
|
270
|
+
|
|
271
|
+
export enum ConnectionType {
|
|
272
|
+
OPENID_CONNECT = 'OIDC',
|
|
273
|
+
SIOPv2 = 'SIOPv2',
|
|
274
|
+
SIOPv2_OpenID4VP = 'SIOPv2+OpenID4VP',
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export enum CorrelationIdentifierType {
|
|
278
|
+
DID = 'did',
|
|
279
|
+
URL = 'url',
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export enum PartyTypeType {
|
|
283
|
+
NATURAL_PERSON = 'naturalPerson',
|
|
284
|
+
ORGANIZATION = 'organization',
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export enum PartyOrigin {
|
|
288
|
+
INTERNAL = 'INTERNAL',
|
|
289
|
+
EXTERNAL = 'EXTERNAL',
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export enum IdentityOrigin {
|
|
293
|
+
INTERNAL = 'INTERNAL',
|
|
294
|
+
EXTERNAL = 'EXTERNAL',
|
|
295
|
+
}
|