@sphereon/ssi-sdk.data-store 0.24.0 → 0.24.1-next.100
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/LICENSE +1 -1
- package/dist/contact/ContactStore.d.ts +3 -0
- package/dist/contact/ContactStore.d.ts.map +1 -1
- package/dist/contact/ContactStore.js +84 -48
- package/dist/contact/ContactStore.js.map +1 -1
- package/dist/entities/contact/BaseContactEntity.d.ts +2 -0
- package/dist/entities/contact/BaseContactEntity.d.ts.map +1 -1
- package/dist/entities/contact/BaseContactEntity.js +12 -3
- package/dist/entities/contact/BaseContactEntity.js.map +1 -1
- package/dist/entities/contact/ConnectionEntity.d.ts +2 -0
- package/dist/entities/contact/ConnectionEntity.d.ts.map +1 -1
- package/dist/entities/contact/ConnectionEntity.js +8 -0
- package/dist/entities/contact/ConnectionEntity.js.map +1 -1
- package/dist/entities/contact/ContactMetadataItemEntity.d.ts +14 -0
- package/dist/entities/contact/ContactMetadataItemEntity.d.ts.map +1 -0
- package/dist/entities/contact/ContactMetadataItemEntity.js +88 -0
- package/dist/entities/contact/ContactMetadataItemEntity.js.map +1 -0
- package/dist/entities/contact/CorrelationIdentifierEntity.d.ts +2 -0
- package/dist/entities/contact/CorrelationIdentifierEntity.d.ts.map +1 -1
- package/dist/entities/contact/CorrelationIdentifierEntity.js +8 -0
- package/dist/entities/contact/CorrelationIdentifierEntity.js.map +1 -1
- package/dist/entities/contact/DidAuthConfigEntity.d.ts +2 -0
- package/dist/entities/contact/DidAuthConfigEntity.d.ts.map +1 -1
- package/dist/entities/contact/DidAuthConfigEntity.js +8 -0
- package/dist/entities/contact/DidAuthConfigEntity.js.map +1 -1
- package/dist/entities/contact/ElectronicAddressEntity.d.ts +2 -0
- package/dist/entities/contact/ElectronicAddressEntity.d.ts.map +1 -1
- package/dist/entities/contact/ElectronicAddressEntity.js +8 -0
- package/dist/entities/contact/ElectronicAddressEntity.js.map +1 -1
- package/dist/entities/contact/IMetadataEntity.d.ts +8 -0
- package/dist/entities/contact/IMetadataEntity.d.ts.map +1 -0
- package/dist/entities/contact/IMetadataEntity.js +2 -0
- package/dist/entities/contact/IMetadataEntity.js.map +1 -0
- package/dist/entities/contact/IdentityEntity.d.ts +5 -2
- package/dist/entities/contact/IdentityEntity.d.ts.map +1 -1
- package/dist/entities/contact/IdentityEntity.js +13 -0
- package/dist/entities/contact/IdentityEntity.js.map +1 -1
- package/dist/entities/contact/IdentityMetadataItemEntity.d.ts +6 -2
- package/dist/entities/contact/IdentityMetadataItemEntity.d.ts.map +1 -1
- package/dist/entities/contact/IdentityMetadataItemEntity.js +19 -3
- package/dist/entities/contact/IdentityMetadataItemEntity.js.map +1 -1
- package/dist/entities/contact/NaturalPersonEntity.d.ts +2 -0
- package/dist/entities/contact/NaturalPersonEntity.d.ts.map +1 -1
- package/dist/entities/contact/NaturalPersonEntity.js +8 -0
- package/dist/entities/contact/NaturalPersonEntity.js.map +1 -1
- package/dist/entities/contact/OpenIdConfigEntity.d.ts +2 -0
- package/dist/entities/contact/OpenIdConfigEntity.d.ts.map +1 -1
- package/dist/entities/contact/OpenIdConfigEntity.js +8 -0
- package/dist/entities/contact/OpenIdConfigEntity.js.map +1 -1
- package/dist/entities/contact/OrganizationEntity.d.ts +2 -0
- package/dist/entities/contact/OrganizationEntity.d.ts.map +1 -1
- package/dist/entities/contact/OrganizationEntity.js +8 -0
- package/dist/entities/contact/OrganizationEntity.js.map +1 -1
- package/dist/entities/contact/PartyEntity.d.ts +2 -0
- package/dist/entities/contact/PartyEntity.d.ts.map +1 -1
- package/dist/entities/contact/PartyEntity.js +8 -0
- package/dist/entities/contact/PartyEntity.js.map +1 -1
- package/dist/entities/contact/PartyRelationshipEntity.d.ts +2 -0
- package/dist/entities/contact/PartyRelationshipEntity.d.ts.map +1 -1
- package/dist/entities/contact/PartyRelationshipEntity.js +8 -0
- package/dist/entities/contact/PartyRelationshipEntity.js.map +1 -1
- package/dist/entities/contact/PartyTypeEntity.js +4 -4
- package/dist/entities/contact/PartyTypeEntity.js.map +1 -1
- package/dist/entities/contact/PhysicalAddressEntity.d.ts +2 -0
- package/dist/entities/contact/PhysicalAddressEntity.d.ts.map +1 -1
- package/dist/entities/contact/PhysicalAddressEntity.js +10 -1
- package/dist/entities/contact/PhysicalAddressEntity.js.map +1 -1
- package/dist/entities/presentationDefinition/PresentationDefinitionItemEntity.d.ts +14 -0
- package/dist/entities/presentationDefinition/PresentationDefinitionItemEntity.d.ts.map +1 -0
- package/dist/entities/presentationDefinition/PresentationDefinitionItemEntity.js +74 -0
- package/dist/entities/presentationDefinition/PresentationDefinitionItemEntity.js.map +1 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/dist/migrations/generic/10-CreatePresentationDefinitions.d.ts +7 -0
- package/dist/migrations/generic/10-CreatePresentationDefinitions.d.ts.map +1 -0
- package/dist/migrations/generic/10-CreatePresentationDefinitions.js +78 -0
- package/dist/migrations/generic/10-CreatePresentationDefinitions.js.map +1 -0
- package/dist/migrations/generic/8-CreateContacts.d.ts +7 -0
- package/dist/migrations/generic/8-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/generic/8-CreateContacts.js +78 -0
- package/dist/migrations/generic/8-CreateContacts.js.map +1 -0
- package/dist/migrations/generic/9-CreateContacts.d.ts +7 -0
- package/dist/migrations/generic/9-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/generic/9-CreateContacts.js +78 -0
- package/dist/migrations/generic/9-CreateContacts.js.map +1 -0
- package/dist/migrations/generic/index.d.ts +2 -0
- package/dist/migrations/generic/index.d.ts.map +1 -1
- package/dist/migrations/generic/index.js +12 -2
- package/dist/migrations/generic/index.js.map +1 -1
- package/dist/migrations/index.d.ts +1 -1
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +2 -1
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/postgres/1690925872592-CreateContacts.d.ts.map +1 -1
- package/dist/migrations/postgres/1690925872592-CreateContacts.js +40 -3
- package/dist/migrations/postgres/1690925872592-CreateContacts.js.map +1 -1
- package/dist/migrations/postgres/1710438363001-CreateContacts.d.ts +7 -0
- package/dist/migrations/postgres/1710438363001-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/postgres/1710438363001-CreateContacts.js +63 -0
- package/dist/migrations/postgres/1710438363001-CreateContacts.js.map +1 -0
- package/dist/migrations/postgres/1715761125001-CreateContacts.d.ts +7 -0
- package/dist/migrations/postgres/1715761125001-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/postgres/1715761125001-CreateContacts.js +74 -0
- package/dist/migrations/postgres/1715761125001-CreateContacts.js.map +1 -0
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.d.ts +7 -0
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.d.ts.map +1 -0
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js +41 -0
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js.map +1 -0
- package/dist/migrations/sqlite/1690925872693-CreateContacts.d.ts.map +1 -1
- package/dist/migrations/sqlite/1690925872693-CreateContacts.js +40 -3
- package/dist/migrations/sqlite/1690925872693-CreateContacts.js.map +1 -1
- package/dist/migrations/sqlite/1710438363002-CreateContacts.d.ts +7 -0
- package/dist/migrations/sqlite/1710438363002-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/sqlite/1710438363002-CreateContacts.js +79 -0
- package/dist/migrations/sqlite/1710438363002-CreateContacts.js.map +1 -0
- package/dist/migrations/sqlite/1715761125002-CreateContacts.d.ts +7 -0
- package/dist/migrations/sqlite/1715761125002-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/sqlite/1715761125002-CreateContacts.js +73 -0
- package/dist/migrations/sqlite/1715761125002-CreateContacts.js.map +1 -0
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.d.ts +7 -0
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.d.ts.map +1 -0
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js +38 -0
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js.map +1 -0
- package/dist/presentationDefinition/AbstractPDStore.d.ts +12 -0
- package/dist/presentationDefinition/AbstractPDStore.d.ts.map +1 -0
- package/dist/presentationDefinition/AbstractPDStore.js +7 -0
- package/dist/presentationDefinition/AbstractPDStore.js.map +1 -0
- package/dist/presentationDefinition/PDStore.d.ts +19 -0
- package/dist/presentationDefinition/PDStore.d.ts.map +1 -0
- package/dist/presentationDefinition/PDStore.js +152 -0
- package/dist/presentationDefinition/PDStore.js.map +1 -0
- package/dist/types/contact/contact.d.ts +51 -15
- package/dist/types/contact/contact.d.ts.map +1 -1
- package/dist/types/contact/contact.js +12 -7
- package/dist/types/contact/contact.js.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/presentationDefinition/IAbstractPDStore.d.ts +17 -0
- package/dist/types/presentationDefinition/IAbstractPDStore.d.ts.map +1 -0
- package/dist/types/presentationDefinition/IAbstractPDStore.js +3 -0
- package/dist/types/presentationDefinition/IAbstractPDStore.js.map +1 -0
- package/dist/types/presentationDefinition/presentationDefinition.d.ts +16 -0
- package/dist/types/presentationDefinition/presentationDefinition.d.ts.map +1 -0
- package/dist/types/presentationDefinition/presentationDefinition.js +3 -0
- package/dist/types/presentationDefinition/presentationDefinition.js.map +1 -0
- package/dist/utils/contact/MappingUtils.d.ts +6 -4
- package/dist/utils/contact/MappingUtils.d.ts.map +1 -1
- package/dist/utils/contact/MappingUtils.js +128 -18
- package/dist/utils/contact/MappingUtils.js.map +1 -1
- package/dist/utils/presentationDefinition/MappingUtils.d.ts +6 -0
- package/dist/utils/presentationDefinition/MappingUtils.d.ts.map +1 -0
- package/dist/utils/presentationDefinition/MappingUtils.js +48 -0
- package/dist/utils/presentationDefinition/MappingUtils.js.map +1 -0
- package/package.json +7 -4
- package/src/__tests__/contact.entities.test.ts +129 -44
- package/src/__tests__/contact.store.test.ts +205 -29
- package/src/__tests__/pd-manager.entities.test.ts +71 -0
- package/src/__tests__/pd-manager.store.test.ts +191 -0
- package/src/contact/ContactStore.ts +74 -30
- package/src/entities/contact/BaseContactEntity.ts +11 -0
- package/src/entities/contact/ConnectionEntity.ts +6 -0
- package/src/entities/contact/ContactMetadataItemEntity.ts +50 -0
- package/src/entities/contact/CorrelationIdentifierEntity.ts +6 -0
- package/src/entities/contact/DidAuthConfigEntity.ts +6 -0
- package/src/entities/contact/ElectronicAddressEntity.ts +6 -0
- package/src/entities/contact/IMetadataEntity.ts +7 -0
- package/src/entities/contact/IdentityEntity.ts +11 -2
- package/src/entities/contact/IdentityMetadataItemEntity.ts +16 -4
- package/src/entities/contact/NaturalPersonEntity.ts +6 -0
- package/src/entities/contact/OpenIdConfigEntity.ts +6 -0
- package/src/entities/contact/OrganizationEntity.ts +6 -0
- package/src/entities/contact/PartyEntity.ts +6 -0
- package/src/entities/contact/PartyRelationshipEntity.ts +6 -0
- package/src/entities/contact/PartyTypeEntity.ts +4 -4
- package/src/entities/contact/PhysicalAddressEntity.ts +9 -2
- package/src/entities/presentationDefinition/PresentationDefinitionItemEntity.ts +43 -0
- package/src/index.ts +13 -0
- package/src/migrations/generic/10-CreatePresentationDefinitions.ts +66 -0
- package/src/migrations/generic/8-CreateContacts.ts +66 -0
- package/src/migrations/generic/9-CreateContacts.ts +66 -0
- package/src/migrations/generic/index.ts +11 -1
- package/src/migrations/index.ts +1 -0
- package/src/migrations/postgres/1690925872592-CreateContacts.ts +59 -5
- package/src/migrations/postgres/1710438363001-CreateContacts.ts +63 -0
- package/src/migrations/postgres/1715761125001-CreateContacts.ts +60 -0
- package/src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts +25 -0
- package/src/migrations/sqlite/1690925872693-CreateContacts.ts +70 -3
- package/src/migrations/sqlite/1710438363002-CreateContacts.ts +83 -0
- package/src/migrations/sqlite/1715761125002-CreateContacts.ts +59 -0
- package/src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts +24 -0
- package/src/presentationDefinition/AbstractPDStore.ts +20 -0
- package/src/presentationDefinition/PDStore.ts +185 -0
- package/src/types/contact/contact.ts +56 -15
- package/src/types/index.ts +2 -0
- package/src/types/presentationDefinition/IAbstractPDStore.ts +25 -0
- package/src/types/presentationDefinition/presentationDefinition.ts +17 -0
- package/src/utils/contact/MappingUtils.ts +135 -19
- package/src/utils/presentationDefinition/MappingUtils.ts +52 -0
package/src/types/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './issuanceBranding/issuanceBranding'
|
|
2
2
|
export * from './issuanceBranding/IAbstractIssuanceBrandingStore'
|
|
3
3
|
export * from './contact/contact'
|
|
4
|
+
export * from './presentationDefinition/presentationDefinition'
|
|
5
|
+
export * from './presentationDefinition/IAbstractPDStore'
|
|
4
6
|
export * from './contact/IAbstractContactStore'
|
|
5
7
|
export * from './validation/validation'
|
|
6
8
|
export * from './statusList/statusList'
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { NonPersistedPresentationDefinitionItem, PresentationDefinitionItem, PresentationDefinitionItemFilter } from './presentationDefinition'
|
|
2
|
+
|
|
3
|
+
export type FindDefinitionArgs = Array<PresentationDefinitionItemFilter>
|
|
4
|
+
|
|
5
|
+
export type GetDefinitionArgs = {
|
|
6
|
+
itemId: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type HasDefinitionArgs = GetDefinitionArgs
|
|
10
|
+
|
|
11
|
+
export type GetDefinitionsArgs = {
|
|
12
|
+
filter?: FindDefinitionArgs
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type HasDefinitionsArgs = GetDefinitionsArgs
|
|
16
|
+
|
|
17
|
+
export type AddDefinitionArgs = NonPersistedPresentationDefinitionItem
|
|
18
|
+
|
|
19
|
+
export type UpdateDefinitionArgs = PresentationDefinitionItem
|
|
20
|
+
|
|
21
|
+
export type DeleteDefinitionArgs = {
|
|
22
|
+
itemId: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type DeleteDefinitionsArgs = GetDefinitionsArgs
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IPresentationDefinition } from '@sphereon/pex'
|
|
2
|
+
|
|
3
|
+
export type PresentationDefinitionItem = {
|
|
4
|
+
id: string
|
|
5
|
+
definitionId: string
|
|
6
|
+
tenantId?: string
|
|
7
|
+
version: string
|
|
8
|
+
name?: string
|
|
9
|
+
purpose?: string
|
|
10
|
+
definitionPayload: IPresentationDefinition
|
|
11
|
+
createdAt: Date
|
|
12
|
+
lastUpdatedAt: Date
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type NonPersistedPresentationDefinitionItem = Omit<PresentationDefinitionItem, 'id' | 'createdAt' | 'lastUpdatedAt'>
|
|
16
|
+
export type PartialPresentationDefinitionItem = Partial<PresentationDefinitionItem>
|
|
17
|
+
export type PresentationDefinitionItemFilter = Partial<Omit<PresentationDefinitionItem, 'definitionPayload'>> // TODO add logic to linearize & hash definitionPayload into a separate column so we can filter on it?
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
MetadataTypes,
|
|
2
3
|
Connection,
|
|
3
4
|
ConnectionConfig,
|
|
4
5
|
Contact,
|
|
@@ -28,7 +29,7 @@ import {
|
|
|
28
29
|
Party,
|
|
29
30
|
PartyRelationship,
|
|
30
31
|
PartyType,
|
|
31
|
-
PhysicalAddress
|
|
32
|
+
PhysicalAddress
|
|
32
33
|
} from '../../types'
|
|
33
34
|
import { PartyEntity } from '../../entities/contact/PartyEntity'
|
|
34
35
|
import { IdentityEntity } from '../../entities/contact/IdentityEntity'
|
|
@@ -45,6 +46,7 @@ import { IdentityMetadataItemEntity } from '../../entities/contact/IdentityMetad
|
|
|
45
46
|
import { OpenIdConfigEntity } from '../../entities/contact/OpenIdConfigEntity'
|
|
46
47
|
import { PartyTypeEntity } from '../../entities/contact/PartyTypeEntity'
|
|
47
48
|
import { PhysicalAddressEntity } from '../../entities/contact/PhysicalAddressEntity'
|
|
49
|
+
import { ContactMetadataItemEntity } from '../../entities/contact/ContactMetadataItemEntity'
|
|
48
50
|
|
|
49
51
|
export const partyEntityFrom = (party: NonPersistedParty): PartyEntity => {
|
|
50
52
|
const partyEntity: PartyEntity = new PartyEntity()
|
|
@@ -58,6 +60,8 @@ export const partyEntityFrom = (party: NonPersistedParty): PartyEntity => {
|
|
|
58
60
|
: []
|
|
59
61
|
partyEntity.partyType = partyTypeEntityFrom(party.partyType)
|
|
60
62
|
partyEntity.contact = contactEntityFrom(party.contact)
|
|
63
|
+
partyEntity.ownerId = party.ownerId
|
|
64
|
+
partyEntity.tenantId = party.tenantId
|
|
61
65
|
|
|
62
66
|
return partyEntity
|
|
63
67
|
}
|
|
@@ -77,6 +81,8 @@ export const partyFrom = (party: PartyEntity): Party => {
|
|
|
77
81
|
relationships: party.relationships ? party.relationships.map((relationship: PartyRelationshipEntity) => partyRelationshipFrom(relationship)) : [],
|
|
78
82
|
partyType: partyTypeFrom(party.partyType),
|
|
79
83
|
contact: contactFrom(party.contact),
|
|
84
|
+
ownerId: party.ownerId,
|
|
85
|
+
tenantId: party.tenantId,
|
|
80
86
|
createdAt: party.createdAt,
|
|
81
87
|
lastUpdatedAt: party.lastUpdatedAt,
|
|
82
88
|
}
|
|
@@ -112,6 +118,8 @@ export const connectionEntityFrom = (connection: NonPersistedConnection): Connec
|
|
|
112
118
|
const connectionEntity: ConnectionEntity = new ConnectionEntity()
|
|
113
119
|
connectionEntity.type = connection.type
|
|
114
120
|
connectionEntity.config = configEntityFrom(connection.config)
|
|
121
|
+
connectionEntity.ownerId = connection.ownerId
|
|
122
|
+
connectionEntity.tenantId = connection.tenantId
|
|
115
123
|
|
|
116
124
|
return connectionEntity
|
|
117
125
|
}
|
|
@@ -120,6 +128,8 @@ export const connectionFrom = (connection: ConnectionEntity): Connection => {
|
|
|
120
128
|
return {
|
|
121
129
|
id: connection.id,
|
|
122
130
|
type: connection.type,
|
|
131
|
+
ownerId: connection.ownerId,
|
|
132
|
+
tenantId: connection.tenantId,
|
|
123
133
|
config: configFrom(connection.config),
|
|
124
134
|
}
|
|
125
135
|
}
|
|
@@ -138,6 +148,8 @@ export const correlationIdentifierEntityFrom = (identifier: NonPersistedCorrelat
|
|
|
138
148
|
const identifierEntity: CorrelationIdentifierEntity = new CorrelationIdentifierEntity()
|
|
139
149
|
identifierEntity.type = identifier.type
|
|
140
150
|
identifierEntity.correlationId = identifier.correlationId
|
|
151
|
+
identifierEntity.ownerId = identifier.ownerId
|
|
152
|
+
identifierEntity.tenantId = identifier.tenantId
|
|
141
153
|
|
|
142
154
|
return identifierEntity
|
|
143
155
|
}
|
|
@@ -147,6 +159,8 @@ export const correlationIdentifierFrom = (identifier: CorrelationIdentifierEntit
|
|
|
147
159
|
id: identifier.id,
|
|
148
160
|
type: identifier.type,
|
|
149
161
|
correlationId: identifier.correlationId,
|
|
162
|
+
ownerId: identifier.ownerId,
|
|
163
|
+
tenantId: identifier.tenantId,
|
|
150
164
|
}
|
|
151
165
|
}
|
|
152
166
|
|
|
@@ -155,7 +169,8 @@ export const didAuthConfigEntityFrom = (config: NonPersistedDidAuthConfig): DidA
|
|
|
155
169
|
didAuthConfig.identifier = config.identifier.did
|
|
156
170
|
didAuthConfig.redirectUrl = config.redirectUrl
|
|
157
171
|
didAuthConfig.sessionId = config.sessionId
|
|
158
|
-
|
|
172
|
+
didAuthConfig.ownerId = config.ownerId
|
|
173
|
+
didAuthConfig.tenantId = config.tenantId
|
|
159
174
|
return didAuthConfig
|
|
160
175
|
}
|
|
161
176
|
|
|
@@ -163,6 +178,8 @@ export const electronicAddressEntityFrom = (electronicAddress: NonPersistedElect
|
|
|
163
178
|
const electronicAddressEntity: ElectronicAddressEntity = new ElectronicAddressEntity()
|
|
164
179
|
electronicAddressEntity.type = electronicAddress.type
|
|
165
180
|
electronicAddressEntity.electronicAddress = electronicAddress.electronicAddress
|
|
181
|
+
electronicAddressEntity.ownerId = electronicAddress.ownerId
|
|
182
|
+
electronicAddressEntity.tenantId = electronicAddress.tenantId
|
|
166
183
|
|
|
167
184
|
return electronicAddressEntity
|
|
168
185
|
}
|
|
@@ -172,6 +189,8 @@ export const electronicAddressFrom = (electronicAddress: ElectronicAddressEntity
|
|
|
172
189
|
id: electronicAddress.id,
|
|
173
190
|
type: electronicAddress.type,
|
|
174
191
|
electronicAddress: electronicAddress.electronicAddress,
|
|
192
|
+
ownerId: electronicAddress.ownerId,
|
|
193
|
+
tenantId: electronicAddress.tenantId,
|
|
175
194
|
createdAt: electronicAddress.createdAt,
|
|
176
195
|
lastUpdatedAt: electronicAddress.lastUpdatedAt,
|
|
177
196
|
}
|
|
@@ -187,6 +206,8 @@ export const physicalAddressEntityFrom = (physicalAddress: NonPersistedPhysicalA
|
|
|
187
206
|
physicalAddressEntity.provinceName = physicalAddress.provinceName
|
|
188
207
|
physicalAddressEntity.countryCode = physicalAddress.countryCode
|
|
189
208
|
physicalAddressEntity.buildingName = physicalAddress.buildingName
|
|
209
|
+
physicalAddressEntity.ownerId = physicalAddress.ownerId
|
|
210
|
+
physicalAddressEntity.tenantId = physicalAddress.tenantId
|
|
190
211
|
|
|
191
212
|
return physicalAddressEntity
|
|
192
213
|
}
|
|
@@ -202,19 +223,27 @@ export const physicalAddressFrom = (physicalAddress: PhysicalAddressEntity): Phy
|
|
|
202
223
|
provinceName: physicalAddress.provinceName,
|
|
203
224
|
countryCode: physicalAddress.countryCode,
|
|
204
225
|
buildingName: physicalAddress.buildingName,
|
|
226
|
+
ownerId: physicalAddress.ownerId,
|
|
227
|
+
tenantId: physicalAddress.tenantId,
|
|
205
228
|
createdAt: physicalAddress.createdAt,
|
|
206
229
|
lastUpdatedAt: physicalAddress.lastUpdatedAt,
|
|
207
230
|
}
|
|
208
231
|
}
|
|
209
232
|
|
|
210
|
-
export const identityEntityFrom = (
|
|
233
|
+
export const identityEntityFrom = (entity: NonPersistedIdentity): IdentityEntity => {
|
|
211
234
|
const identityEntity: IdentityEntity = new IdentityEntity()
|
|
212
|
-
identityEntity.alias =
|
|
213
|
-
identityEntity.
|
|
214
|
-
identityEntity.
|
|
215
|
-
identityEntity.
|
|
216
|
-
identityEntity.
|
|
217
|
-
|
|
235
|
+
identityEntity.alias = entity.alias
|
|
236
|
+
identityEntity.origin = entity.origin
|
|
237
|
+
identityEntity.ownerId = entity.ownerId
|
|
238
|
+
identityEntity.tenantId = entity.tenantId
|
|
239
|
+
identityEntity.roles = entity.roles
|
|
240
|
+
identityEntity.identifier = correlationIdentifierEntityFrom(entity.identifier)
|
|
241
|
+
identityEntity.connection = entity.connection ? connectionEntityFrom(entity.connection) : undefined
|
|
242
|
+
identityEntity.metadata = entity.metadata
|
|
243
|
+
? entity.metadata
|
|
244
|
+
.map(identityMetadataItemEntityFrom)
|
|
245
|
+
.filter((entity): entity is IdentityMetadataItemEntity => entity !== undefined)
|
|
246
|
+
: []
|
|
218
247
|
return identityEntity
|
|
219
248
|
}
|
|
220
249
|
|
|
@@ -222,7 +251,10 @@ export const identityFrom = (identity: IdentityEntity): Identity => {
|
|
|
222
251
|
return {
|
|
223
252
|
id: identity.id,
|
|
224
253
|
alias: identity.alias,
|
|
254
|
+
origin: identity.origin,
|
|
225
255
|
roles: identity.roles,
|
|
256
|
+
tenantId: identity.tenantId,
|
|
257
|
+
ownerId: identity.ownerId,
|
|
226
258
|
identifier: correlationIdentifierFrom(identity.identifier),
|
|
227
259
|
...(identity.connection && { connection: connectionFrom(identity.connection) }),
|
|
228
260
|
metadata: identity.metadata ? identity.metadata.map((item: IdentityMetadataItemEntity) => metadataItemFrom(item)) : [],
|
|
@@ -231,20 +263,75 @@ export const identityFrom = (identity: IdentityEntity): Identity => {
|
|
|
231
263
|
}
|
|
232
264
|
}
|
|
233
265
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
266
|
+
const metadataItemEntityFrom = <T extends MetadataTypes, U extends { new (): any }>(
|
|
267
|
+
item: NonPersistedMetadataItem<T>,
|
|
268
|
+
EntityClass: U,
|
|
269
|
+
): InstanceType<U> | undefined => {
|
|
270
|
+
const { label, value } = item
|
|
271
|
+
|
|
272
|
+
if (value === null || value === undefined) {
|
|
273
|
+
return undefined
|
|
274
|
+
}
|
|
238
275
|
|
|
276
|
+
const metadataItemEntity = new EntityClass()
|
|
277
|
+
metadataItemEntity.label = label
|
|
278
|
+
metadataItemEntity.valueType = typeof value
|
|
279
|
+
|
|
280
|
+
switch (typeof value) {
|
|
281
|
+
case 'undefined':
|
|
282
|
+
return undefined
|
|
283
|
+
case 'string':
|
|
284
|
+
metadataItemEntity.stringValue = value
|
|
285
|
+
break
|
|
286
|
+
case 'number':
|
|
287
|
+
metadataItemEntity.numberValue = value
|
|
288
|
+
break
|
|
289
|
+
case 'boolean':
|
|
290
|
+
metadataItemEntity.boolValue = value
|
|
291
|
+
break
|
|
292
|
+
case 'object':
|
|
293
|
+
metadataItemEntity.valueType = Object.prototype.toString.call(value).slice(8, -1)
|
|
294
|
+
if (value instanceof Date) {
|
|
295
|
+
metadataItemEntity.dateValue = value
|
|
296
|
+
} else {
|
|
297
|
+
// For now, we only support / implement not-primitive type Date in the entity
|
|
298
|
+
throw new Error(`Unsupported object type: ${metadataItemEntity.valueType} for value ${value}`)
|
|
299
|
+
}
|
|
300
|
+
break
|
|
301
|
+
}
|
|
239
302
|
return metadataItemEntity
|
|
240
303
|
}
|
|
241
304
|
|
|
242
|
-
export const
|
|
243
|
-
return
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
305
|
+
export const identityMetadataItemEntityFrom = (item: NonPersistedMetadataItem<MetadataTypes>): IdentityMetadataItemEntity | undefined => {
|
|
306
|
+
return metadataItemEntityFrom(item, IdentityMetadataItemEntity)
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export const contactMetadataItemEntityFrom = (item: NonPersistedMetadataItem<MetadataTypes>): ContactMetadataItemEntity | undefined => {
|
|
310
|
+
return metadataItemEntityFrom(item, ContactMetadataItemEntity)
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export const metadataItemFrom = (entity: IdentityMetadataItemEntity | ContactMetadataItemEntity): MetadataItem<MetadataTypes> => {
|
|
314
|
+
const item: Partial<MetadataItem<MetadataTypes>> = {
|
|
315
|
+
id: entity.id,
|
|
316
|
+
label: entity.label,
|
|
317
|
+
}
|
|
318
|
+
switch (entity.valueType) {
|
|
319
|
+
case 'string':
|
|
320
|
+
item.value = entity.stringValue
|
|
321
|
+
break
|
|
322
|
+
case 'number':
|
|
323
|
+
item.value = entity.numberValue
|
|
324
|
+
break
|
|
325
|
+
case 'Date':
|
|
326
|
+
item.value = entity.dateValue
|
|
327
|
+
break
|
|
328
|
+
case 'boolean':
|
|
329
|
+
item.value = entity.boolValue
|
|
330
|
+
break
|
|
331
|
+
default:
|
|
332
|
+
throw new Error(`Unsupported valueType ${entity.valueType}`)
|
|
247
333
|
}
|
|
334
|
+
return item as MetadataItem<MetadataTypes>
|
|
248
335
|
}
|
|
249
336
|
|
|
250
337
|
export const naturalPersonEntityFrom = (naturalPerson: NonPersistedNaturalPerson): NaturalPersonEntity => {
|
|
@@ -253,6 +340,13 @@ export const naturalPersonEntityFrom = (naturalPerson: NonPersistedNaturalPerson
|
|
|
253
340
|
naturalPersonEntity.middleName = naturalPerson.middleName
|
|
254
341
|
naturalPersonEntity.lastName = naturalPerson.lastName
|
|
255
342
|
naturalPersonEntity.displayName = naturalPerson.displayName
|
|
343
|
+
naturalPersonEntity.ownerId = naturalPerson.ownerId
|
|
344
|
+
naturalPersonEntity.tenantId = naturalPerson.tenantId
|
|
345
|
+
naturalPersonEntity.metadata = naturalPerson.metadata
|
|
346
|
+
? naturalPerson.metadata
|
|
347
|
+
.map(contactMetadataItemEntityFrom)
|
|
348
|
+
.filter((entity): entity is ContactMetadataItemEntity => entity !== undefined)
|
|
349
|
+
: []
|
|
256
350
|
|
|
257
351
|
return naturalPersonEntity
|
|
258
352
|
}
|
|
@@ -264,6 +358,9 @@ export const naturalPersonFrom = (naturalPerson: NaturalPersonEntity): NaturalPe
|
|
|
264
358
|
middleName: naturalPerson.middleName,
|
|
265
359
|
lastName: naturalPerson.lastName,
|
|
266
360
|
displayName: naturalPerson.displayName,
|
|
361
|
+
metadata: naturalPerson.metadata ? naturalPerson.metadata.map((item: ContactMetadataItemEntity) => metadataItemFrom(item)) : [],
|
|
362
|
+
ownerId: naturalPerson.ownerId,
|
|
363
|
+
tenantId: naturalPerson.tenantId,
|
|
267
364
|
createdAt: naturalPerson.createdAt,
|
|
268
365
|
lastUpdatedAt: naturalPerson.lastUpdatedAt,
|
|
269
366
|
}
|
|
@@ -278,6 +375,8 @@ export const openIdConfigEntityFrom = (config: NonPersistedOpenIdConfig): OpenId
|
|
|
278
375
|
openIdConfig.redirectUrl = config.redirectUrl
|
|
279
376
|
openIdConfig.dangerouslyAllowInsecureHttpRequests = config.dangerouslyAllowInsecureHttpRequests
|
|
280
377
|
openIdConfig.clientAuthMethod = config.clientAuthMethod
|
|
378
|
+
openIdConfig.ownerId = config.ownerId
|
|
379
|
+
openIdConfig.tenantId = config.tenantId
|
|
281
380
|
|
|
282
381
|
return openIdConfig
|
|
283
382
|
}
|
|
@@ -286,6 +385,13 @@ export const organizationEntityFrom = (organization: NonPersistedOrganization):
|
|
|
286
385
|
const organizationEntity: OrganizationEntity = new OrganizationEntity()
|
|
287
386
|
organizationEntity.legalName = organization.legalName
|
|
288
387
|
organizationEntity.displayName = organization.displayName
|
|
388
|
+
organizationEntity.ownerId = organization.ownerId
|
|
389
|
+
organizationEntity.tenantId = organization.tenantId
|
|
390
|
+
organizationEntity.metadata = organization.metadata
|
|
391
|
+
? organization.metadata
|
|
392
|
+
.map(contactMetadataItemEntityFrom)
|
|
393
|
+
.filter((entity): entity is ContactMetadataItemEntity => entity !== undefined)
|
|
394
|
+
: []
|
|
289
395
|
|
|
290
396
|
return organizationEntity
|
|
291
397
|
}
|
|
@@ -295,6 +401,9 @@ export const organizationFrom = (organization: OrganizationEntity): Organization
|
|
|
295
401
|
id: organization.id,
|
|
296
402
|
legalName: organization.legalName,
|
|
297
403
|
displayName: organization.displayName,
|
|
404
|
+
metadata: organization.metadata ? organization.metadata.map((item: ContactMetadataItemEntity) => metadataItemFrom(item)) : [],
|
|
405
|
+
ownerId: organization.ownerId,
|
|
406
|
+
tenantId: organization.tenantId,
|
|
298
407
|
createdAt: organization.createdAt,
|
|
299
408
|
lastUpdatedAt: organization.lastUpdatedAt,
|
|
300
409
|
}
|
|
@@ -304,7 +413,8 @@ export const partyRelationshipEntityFrom = (relationship: NonPersistedPartyRelat
|
|
|
304
413
|
const partyRelationshipEntity: PartyRelationshipEntity = new PartyRelationshipEntity()
|
|
305
414
|
partyRelationshipEntity.leftId = relationship.leftId
|
|
306
415
|
partyRelationshipEntity.rightId = relationship.rightId
|
|
307
|
-
|
|
416
|
+
partyRelationshipEntity.ownerId = relationship.ownerId
|
|
417
|
+
partyRelationshipEntity.tenantId = relationship.tenantId
|
|
308
418
|
return partyRelationshipEntity
|
|
309
419
|
}
|
|
310
420
|
|
|
@@ -313,6 +423,8 @@ export const partyRelationshipFrom = (relationship: PartyRelationshipEntity): Pa
|
|
|
313
423
|
id: relationship.id,
|
|
314
424
|
leftId: relationship.leftId,
|
|
315
425
|
rightId: relationship.rightId,
|
|
426
|
+
ownerId: relationship.ownerId,
|
|
427
|
+
tenantId: relationship.tenantId,
|
|
316
428
|
createdAt: relationship.createdAt,
|
|
317
429
|
lastUpdatedAt: relationship.lastUpdatedAt,
|
|
318
430
|
}
|
|
@@ -365,6 +477,8 @@ export const openIdConfigFrom = (config: OpenIdConfigEntity): OpenIdConfig => {
|
|
|
365
477
|
redirectUrl: config.redirectUrl,
|
|
366
478
|
dangerouslyAllowInsecureHttpRequests: config.dangerouslyAllowInsecureHttpRequests,
|
|
367
479
|
clientAuthMethod: config.clientAuthMethod,
|
|
480
|
+
ownerId: config.ownerId,
|
|
481
|
+
tenantId: config.tenantId,
|
|
368
482
|
}
|
|
369
483
|
}
|
|
370
484
|
|
|
@@ -375,6 +489,8 @@ export const didAuthConfigFrom = (config: DidAuthConfigEntity): DidAuthConfig =>
|
|
|
375
489
|
stateId: '', // FIXME
|
|
376
490
|
redirectUrl: config.redirectUrl,
|
|
377
491
|
sessionId: config.sessionId,
|
|
492
|
+
ownerId: config.ownerId,
|
|
493
|
+
tenantId: config.tenantId,
|
|
378
494
|
}
|
|
379
495
|
}
|
|
380
496
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { PresentationDefinitionItemEntity } from '../../entities/presentationDefinition/PresentationDefinitionItemEntity'
|
|
2
|
+
import { IPresentationDefinition } from '@sphereon/pex'
|
|
3
|
+
import { NonPersistedPresentationDefinitionItem, PartialPresentationDefinitionItem, PresentationDefinitionItem } from '../../types'
|
|
4
|
+
import { blake2bHex } from 'blakejs'
|
|
5
|
+
|
|
6
|
+
export const presentationDefinitionItemFrom = (entity: PresentationDefinitionItemEntity): PresentationDefinitionItem => {
|
|
7
|
+
return {
|
|
8
|
+
id: entity.id,
|
|
9
|
+
tenantId: entity.tenantId,
|
|
10
|
+
definitionId: entity.definitionId,
|
|
11
|
+
version: entity.version,
|
|
12
|
+
name: entity.name,
|
|
13
|
+
purpose: entity.purpose,
|
|
14
|
+
definitionPayload: JSON.parse(entity.definitionPayload) as IPresentationDefinition,
|
|
15
|
+
createdAt: entity.createdAt,
|
|
16
|
+
lastUpdatedAt: entity.lastUpdatedAt,
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const presentationDefinitionEntityItemFrom = (item: NonPersistedPresentationDefinitionItem): PresentationDefinitionItemEntity => {
|
|
21
|
+
const entity = new PresentationDefinitionItemEntity()
|
|
22
|
+
|
|
23
|
+
entity.tenantId = item.tenantId
|
|
24
|
+
entity.definitionId = item.definitionId!
|
|
25
|
+
entity.version = item.version
|
|
26
|
+
entity.name = item.name
|
|
27
|
+
entity.purpose = item.purpose
|
|
28
|
+
entity.definitionPayload = JSON.stringify(item.definitionPayload!)
|
|
29
|
+
return entity
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function hashPayload(payload: IPresentationDefinition): string {
|
|
33
|
+
return blake2bHex(JSON.stringify(payload))
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function isPresentationDefinitionEqual(base: PartialPresentationDefinitionItem, compare: PartialPresentationDefinitionItem): boolean {
|
|
37
|
+
if (
|
|
38
|
+
base.definitionId !== compare.definitionId ||
|
|
39
|
+
base.tenantId != compare.tenantId ||
|
|
40
|
+
base.version !== compare.version ||
|
|
41
|
+
base.name != compare.name ||
|
|
42
|
+
base.purpose != compare.purpose
|
|
43
|
+
) {
|
|
44
|
+
return false
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (base.definitionPayload && compare.definitionPayload) {
|
|
48
|
+
return hashPayload(base.definitionPayload) === hashPayload(compare.definitionPayload)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return false
|
|
52
|
+
}
|