@sphereon/ssi-sdk.data-store 0.30.1-unstable.4 → 0.30.1
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 +201 -201
- package/README.md +77 -77
- package/dist/contact/ContactStore.d.ts.map +1 -1
- package/dist/digitalCredential/DigitalCredentialStore.d.ts.map +1 -1
- package/dist/eventLogger/EventLoggerStore.d.ts.map +1 -1
- package/dist/issuanceBranding/IssuanceBrandingStore.d.ts.map +1 -1
- package/dist/migrations/internal-migrations-ormconfig.d.ts.map +1 -1
- package/dist/migrations/postgres/1708525189001-CreateDigitalCredential.js +33 -33
- package/dist/migrations/postgres/1708797018115-CreateMachineStateStore.js +16 -16
- package/dist/migrations/postgres/1715761125001-CreateContacts.js +33 -33
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js +12 -12
- package/dist/migrations/sqlite/1708525189002-CreateDigitalCredential.js +32 -32
- package/dist/migrations/sqlite/1708796002272-CreateMachineStateStore.js +15 -15
- package/dist/migrations/sqlite/1710438363002-CreateContacts.js +13 -13
- package/dist/migrations/sqlite/1715761125002-CreateContacts.js +32 -32
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js +9 -9
- package/dist/presentationDefinition/PDStore.d.ts.map +1 -1
- package/dist/utils/SortingUtils.d.ts.map +1 -1
- package/dist/utils/contact/MappingUtils.d.ts.map +1 -1
- package/dist/utils/digitalCredential/MappingUtils.d.ts.map +1 -1
- package/dist/utils/digitalCredential/MappingUtils.js +4 -4
- package/dist/utils/digitalCredential/MappingUtils.js.map +1 -1
- package/dist/utils/presentationDefinition/MappingUtils.js +2 -2
- package/dist/utils/presentationDefinition/MappingUtils.js.map +1 -1
- package/package.json +8 -8
- package/src/__tests__/contact.entities.test.ts +2642 -2642
- package/src/__tests__/contact.store.test.ts +2649 -2649
- package/src/__tests__/digitalCredential.entities.test.ts +274 -274
- package/src/__tests__/digitalCredential.store.test.ts +330 -330
- package/src/__tests__/eventLogger.entities.test.ts +76 -76
- package/src/__tests__/eventLogger.store.test.ts +130 -130
- package/src/__tests__/issuanceBranding.entities.test.ts +846 -846
- package/src/__tests__/issuanceBranding.store.test.ts +1886 -1886
- package/src/__tests__/machineState.entities.test.ts +53 -53
- package/src/__tests__/machineState.store.test.ts +176 -176
- package/src/__tests__/pd-manager.entities.test.ts +73 -73
- package/src/__tests__/pd-manager.store.test.ts +193 -193
- package/src/contact/AbstractContactStore.ts +71 -71
- package/src/contact/ContactStore.ts +768 -768
- package/src/digitalCredential/AbstractDigitalCredentialStore.ts +21 -21
- package/src/digitalCredential/DigitalCredentialStore.ts +189 -189
- package/src/entities/contact/BaseContactEntity.ts +51 -51
- package/src/entities/contact/ConnectionEntity.ts +35 -35
- package/src/entities/contact/ContactMetadataItemEntity.ts +51 -51
- package/src/entities/contact/CorrelationIdentifierEntity.ts +43 -43
- package/src/entities/contact/DidAuthConfigEntity.ts +20 -20
- package/src/entities/contact/ElectronicAddressEntity.ts +70 -70
- package/src/entities/contact/IdentityEntity.ts +107 -107
- package/src/entities/contact/IdentityMetadataItemEntity.ts +48 -48
- package/src/entities/contact/NaturalPersonEntity.ts +44 -44
- package/src/entities/contact/OpenIdConfigEntity.ts +32 -32
- package/src/entities/contact/OrganizationEntity.ts +35 -35
- package/src/entities/contact/PartyEntity.ts +117 -117
- package/src/entities/contact/PartyRelationshipEntity.ts +68 -68
- package/src/entities/contact/PartyTypeEntity.ts +63 -63
- package/src/entities/contact/PhysicalAddressEntity.ts +95 -95
- package/src/entities/digitalCredential/DigitalCredentialEntity.ts +98 -98
- package/src/entities/eventLogger/AuditEventEntity.ts +92 -92
- package/src/entities/issuanceBranding/BackgroundAttributesEntity.ts +42 -42
- package/src/entities/issuanceBranding/BaseLocaleBrandingEntity.ts +87 -87
- package/src/entities/issuanceBranding/CredentialBrandingEntity.ts +79 -79
- package/src/entities/issuanceBranding/CredentialLocaleBrandingEntity.ts +33 -33
- package/src/entities/issuanceBranding/ImageAttributesEntity.ts +57 -57
- package/src/entities/issuanceBranding/ImageDimensionsEntity.ts +22 -22
- package/src/entities/issuanceBranding/IssuerBrandingEntity.ts +73 -73
- package/src/entities/issuanceBranding/IssuerLocaleBrandingEntity.ts +33 -33
- package/src/entities/issuanceBranding/TextAttributesEntity.ts +31 -31
- package/src/entities/machineState/MachineStateInfoEntity.ts +59 -59
- package/src/entities/presentationDefinition/PresentationDefinitionItemEntity.ts +44 -44
- package/src/entities/statusList2021/StatusList2021Entity.ts +96 -96
- package/src/entities/statusList2021/StatusList2021EntryEntity.ts +29 -29
- package/src/eventLogger/AbstractEventLoggerStore.ts +7 -7
- package/src/eventLogger/EventLoggerStore.ts +62 -62
- package/src/index.ts +160 -160
- package/src/issuanceBranding/IssuanceBrandingStore.ts +559 -559
- package/src/machineState/IAbstractMachineStateStore.ts +65 -65
- package/src/machineState/MachineStateStore.ts +149 -149
- package/src/migrations/generic/1-CreateContacts.ts +66 -66
- package/src/migrations/generic/10-CreatePresentationDefinitions.ts +66 -66
- package/src/migrations/generic/2-CreateIssuanceBranding.ts +64 -64
- package/src/migrations/generic/3-CreateContacts.ts +66 -66
- package/src/migrations/generic/4-CreateStatusList.ts +54 -54
- package/src/migrations/generic/5-CreateAuditEvents.ts +66 -66
- package/src/migrations/generic/6-CreateDigitalCredential.ts +66 -66
- package/src/migrations/generic/7-CreateMachineStateStore.ts +66 -66
- package/src/migrations/generic/8-CreateContacts.ts +66 -66
- package/src/migrations/generic/9-CreateContacts.ts +66 -66
- package/src/migrations/generic/index.ts +43 -43
- package/src/migrations/index.ts +10 -10
- package/src/migrations/postgres/1659463079428-CreateContacts.ts +63 -63
- package/src/migrations/postgres/1685628974232-CreateIssuanceBranding.ts +85 -85
- package/src/migrations/postgres/1690925872592-CreateContacts.ts +158 -158
- package/src/migrations/postgres/1693866470001-CreateStatusList.ts +24 -24
- package/src/migrations/postgres/1701634812183-CreateAuditEvents.ts +33 -33
- package/src/migrations/postgres/1708525189001-CreateDigitalCredential.ts +61 -61
- package/src/migrations/postgres/1708797018115-CreateMachineStateStore.ts +29 -29
- package/src/migrations/postgres/1710438363001-CreateContacts.ts +63 -63
- package/src/migrations/postgres/1715761125001-CreateContacts.ts +60 -60
- package/src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts +25 -25
- package/src/migrations/sqlite/1659463069549-CreateContacts.ts +110 -110
- package/src/migrations/sqlite/1685628973231-CreateIssuanceBranding.ts +119 -119
- package/src/migrations/sqlite/1690925872693-CreateContacts.ts +228 -228
- package/src/migrations/sqlite/1693866470000-CreateStatusList.ts +24 -24
- package/src/migrations/sqlite/1701634819487-CreateAuditEvents.ts +15 -15
- package/src/migrations/sqlite/1708525189002-CreateDigitalCredential.ts +46 -46
- package/src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts +28 -28
- package/src/migrations/sqlite/1710438363002-CreateContacts.ts +83 -83
- package/src/migrations/sqlite/1715761125002-CreateContacts.ts +59 -59
- package/src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts +24 -24
- package/src/presentationDefinition/AbstractPDStore.ts +20 -20
- package/src/presentationDefinition/PDStore.ts +185 -185
- package/src/statusList/IStatusListStore.ts +44 -44
- package/src/statusList/StatusListStore.ts +236 -236
- package/src/types/contact/IAbstractContactStore.ts +161 -161
- package/src/types/contact/contact.ts +295 -295
- package/src/types/digitalCredential/IAbstractDigitalCredentialStore.ts +42 -42
- package/src/types/digitalCredential/digitalCredential.ts +102 -102
- package/src/types/eventLogger/IAbstractEventLoggerStore.ts +12 -12
- package/src/types/eventLogger/eventLogger.ts +3 -3
- package/src/types/index.ts +14 -14
- package/src/types/machineState/IAbstractMachineStateStore.ts +68 -68
- package/src/types/presentationDefinition/IAbstractPDStore.ts +25 -25
- package/src/types/presentationDefinition/presentationDefinition.ts +17 -17
- package/src/utils/SortingUtils.ts +16 -16
- package/src/utils/contact/MappingUtils.ts +506 -506
- package/src/utils/digitalCredential/MappingUtils.ts +160 -160
- package/src/utils/hasher.ts +19 -19
- package/src/utils/presentationDefinition/MappingUtils.ts +52 -52
- package/dist/entities/contact/IMetadataEntity.d.ts +0 -8
- package/dist/entities/contact/IMetadataEntity.d.ts.map +0 -1
- package/dist/entities/contact/IMetadataEntity.js +0 -2
- package/dist/entities/contact/IMetadataEntity.js.map +0 -1
- package/dist/migrations/generic/8-CreatePresentationDefinitions.d.ts +0 -7
- package/dist/migrations/generic/8-CreatePresentationDefinitions.d.ts.map +0 -1
- package/dist/migrations/generic/8-CreatePresentationDefinitions.js +0 -78
- package/dist/migrations/generic/8-CreatePresentationDefinitions.js.map +0 -1
|
@@ -1,506 +1,506 @@
|
|
|
1
|
-
import {
|
|
2
|
-
MetadataTypes,
|
|
3
|
-
Connection,
|
|
4
|
-
ConnectionConfig,
|
|
5
|
-
Contact,
|
|
6
|
-
CorrelationIdentifier,
|
|
7
|
-
DidAuthConfig,
|
|
8
|
-
ElectronicAddress,
|
|
9
|
-
Identity,
|
|
10
|
-
MetadataItem,
|
|
11
|
-
NaturalPerson,
|
|
12
|
-
NonPersistedConnection,
|
|
13
|
-
NonPersistedConnectionConfig,
|
|
14
|
-
NonPersistedContact,
|
|
15
|
-
NonPersistedCorrelationIdentifier,
|
|
16
|
-
NonPersistedDidAuthConfig,
|
|
17
|
-
NonPersistedElectronicAddress,
|
|
18
|
-
NonPersistedIdentity,
|
|
19
|
-
NonPersistedMetadataItem,
|
|
20
|
-
NonPersistedNaturalPerson,
|
|
21
|
-
NonPersistedOpenIdConfig,
|
|
22
|
-
NonPersistedOrganization,
|
|
23
|
-
NonPersistedParty,
|
|
24
|
-
NonPersistedPartyRelationship,
|
|
25
|
-
NonPersistedPartyType,
|
|
26
|
-
NonPersistedPhysicalAddress,
|
|
27
|
-
OpenIdConfig,
|
|
28
|
-
Organization,
|
|
29
|
-
Party,
|
|
30
|
-
PartyRelationship,
|
|
31
|
-
PartyType,
|
|
32
|
-
PhysicalAddress,
|
|
33
|
-
} from '../../types'
|
|
34
|
-
import { PartyEntity } from '../../entities/contact/PartyEntity'
|
|
35
|
-
import { IdentityEntity } from '../../entities/contact/IdentityEntity'
|
|
36
|
-
import { ElectronicAddressEntity } from '../../entities/contact/ElectronicAddressEntity'
|
|
37
|
-
import { PartyRelationshipEntity } from '../../entities/contact/PartyRelationshipEntity'
|
|
38
|
-
import { BaseContactEntity } from '../../entities/contact/BaseContactEntity'
|
|
39
|
-
import { NaturalPersonEntity } from '../../entities/contact/NaturalPersonEntity'
|
|
40
|
-
import { OrganizationEntity } from '../../entities/contact/OrganizationEntity'
|
|
41
|
-
import { ConnectionEntity } from '../../entities/contact/ConnectionEntity'
|
|
42
|
-
import { BaseConfigEntity } from '../../entities/contact/BaseConfigEntity'
|
|
43
|
-
import { CorrelationIdentifierEntity } from '../../entities/contact/CorrelationIdentifierEntity'
|
|
44
|
-
import { DidAuthConfigEntity } from '../../entities/contact/DidAuthConfigEntity'
|
|
45
|
-
import { IdentityMetadataItemEntity } from '../../entities/contact/IdentityMetadataItemEntity'
|
|
46
|
-
import { OpenIdConfigEntity } from '../../entities/contact/OpenIdConfigEntity'
|
|
47
|
-
import { PartyTypeEntity } from '../../entities/contact/PartyTypeEntity'
|
|
48
|
-
import { PhysicalAddressEntity } from '../../entities/contact/PhysicalAddressEntity'
|
|
49
|
-
import { ContactMetadataItemEntity } from '../../entities/contact/ContactMetadataItemEntity'
|
|
50
|
-
|
|
51
|
-
export const partyEntityFrom = (party: NonPersistedParty): PartyEntity => {
|
|
52
|
-
const partyEntity: PartyEntity = new PartyEntity()
|
|
53
|
-
partyEntity.uri = party.uri
|
|
54
|
-
partyEntity.identities = party.identities ? party.identities.map((identity: NonPersistedIdentity) => identityEntityFrom(identity)) : []
|
|
55
|
-
partyEntity.electronicAddresses = party.electronicAddresses
|
|
56
|
-
? party.electronicAddresses.map((electronicAddress: NonPersistedElectronicAddress) => electronicAddressEntityFrom(electronicAddress))
|
|
57
|
-
: []
|
|
58
|
-
partyEntity.physicalAddresses = party.physicalAddresses
|
|
59
|
-
? party.physicalAddresses.map((physicalAddress: NonPersistedPhysicalAddress) => physicalAddressEntityFrom(physicalAddress))
|
|
60
|
-
: []
|
|
61
|
-
partyEntity.partyType = partyTypeEntityFrom(party.partyType)
|
|
62
|
-
partyEntity.contact = contactEntityFrom(party.contact)
|
|
63
|
-
partyEntity.ownerId = party.ownerId
|
|
64
|
-
partyEntity.tenantId = party.tenantId
|
|
65
|
-
|
|
66
|
-
return partyEntity
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export const partyFrom = (party: PartyEntity): Party => {
|
|
70
|
-
return {
|
|
71
|
-
id: party.id,
|
|
72
|
-
uri: party.uri,
|
|
73
|
-
roles: [...new Set(party.identities?.flatMap((identity: IdentityEntity) => identity.roles))] ?? [],
|
|
74
|
-
identities: party.identities ? party.identities.map((identity: IdentityEntity) => identityFrom(identity)) : [],
|
|
75
|
-
electronicAddresses: party.electronicAddresses
|
|
76
|
-
? party.electronicAddresses.map((electronicAddress: ElectronicAddressEntity) => electronicAddressFrom(electronicAddress))
|
|
77
|
-
: [],
|
|
78
|
-
physicalAddresses: party.physicalAddresses
|
|
79
|
-
? party.physicalAddresses.map((physicalAddress: PhysicalAddressEntity) => physicalAddressFrom(physicalAddress))
|
|
80
|
-
: [],
|
|
81
|
-
relationships: party.relationships ? party.relationships.map((relationship: PartyRelationshipEntity) => partyRelationshipFrom(relationship)) : [],
|
|
82
|
-
partyType: partyTypeFrom(party.partyType),
|
|
83
|
-
contact: contactFrom(party.contact),
|
|
84
|
-
ownerId: party.ownerId,
|
|
85
|
-
tenantId: party.tenantId,
|
|
86
|
-
createdAt: party.createdAt,
|
|
87
|
-
lastUpdatedAt: party.lastUpdatedAt,
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export const contactEntityFrom = (contact: NonPersistedContact): BaseContactEntity => {
|
|
92
|
-
if (isNaturalPerson(contact)) {
|
|
93
|
-
return naturalPersonEntityFrom(<NonPersistedNaturalPerson>contact)
|
|
94
|
-
} else if (isOrganization(contact)) {
|
|
95
|
-
return organizationEntityFrom(<NonPersistedOrganization>contact)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
throw new Error('Contact not supported')
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export const contactFrom = (contact: BaseContactEntity): Contact => {
|
|
102
|
-
if (isNaturalPerson(contact)) {
|
|
103
|
-
return naturalPersonFrom(<NaturalPersonEntity>contact)
|
|
104
|
-
} else if (isOrganization(contact)) {
|
|
105
|
-
return organizationFrom(<OrganizationEntity>contact)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
throw new Error(`Contact type not supported`)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export const isNaturalPerson = (contact: NonPersistedContact | BaseContactEntity): contact is NonPersistedNaturalPerson | NaturalPersonEntity =>
|
|
112
|
-
'firstName' in contact && 'lastName' in contact
|
|
113
|
-
|
|
114
|
-
export const isOrganization = (contact: NonPersistedContact | BaseContactEntity): contact is NonPersistedOrganization | OrganizationEntity =>
|
|
115
|
-
'legalName' in contact
|
|
116
|
-
|
|
117
|
-
export const connectionEntityFrom = (connection: NonPersistedConnection): ConnectionEntity => {
|
|
118
|
-
const connectionEntity: ConnectionEntity = new ConnectionEntity()
|
|
119
|
-
connectionEntity.type = connection.type
|
|
120
|
-
connectionEntity.config = configEntityFrom(connection.config)
|
|
121
|
-
connectionEntity.ownerId = connection.ownerId
|
|
122
|
-
connectionEntity.tenantId = connection.tenantId
|
|
123
|
-
|
|
124
|
-
return connectionEntity
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export const connectionFrom = (connection: ConnectionEntity): Connection => {
|
|
128
|
-
return {
|
|
129
|
-
id: connection.id,
|
|
130
|
-
type: connection.type,
|
|
131
|
-
ownerId: connection.ownerId,
|
|
132
|
-
tenantId: connection.tenantId,
|
|
133
|
-
config: configFrom(connection.config),
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const configEntityFrom = (config: NonPersistedConnectionConfig): BaseConfigEntity => {
|
|
138
|
-
if (isOpenIdConfig(config)) {
|
|
139
|
-
return openIdConfigEntityFrom(<NonPersistedOpenIdConfig>config)
|
|
140
|
-
} else if (isDidAuthConfig(config)) {
|
|
141
|
-
return didAuthConfigEntityFrom(<NonPersistedDidAuthConfig>config)
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
throw new Error('config type not supported')
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export const correlationIdentifierEntityFrom = (identifier: NonPersistedCorrelationIdentifier): CorrelationIdentifierEntity => {
|
|
148
|
-
const identifierEntity: CorrelationIdentifierEntity = new CorrelationIdentifierEntity()
|
|
149
|
-
identifierEntity.type = identifier.type
|
|
150
|
-
identifierEntity.correlationId = identifier.correlationId
|
|
151
|
-
identifierEntity.ownerId = identifier.ownerId
|
|
152
|
-
identifierEntity.tenantId = identifier.tenantId
|
|
153
|
-
|
|
154
|
-
return identifierEntity
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export const correlationIdentifierFrom = (identifier: CorrelationIdentifierEntity): CorrelationIdentifier => {
|
|
158
|
-
return {
|
|
159
|
-
id: identifier.id,
|
|
160
|
-
type: identifier.type,
|
|
161
|
-
correlationId: identifier.correlationId,
|
|
162
|
-
ownerId: identifier.ownerId,
|
|
163
|
-
tenantId: identifier.tenantId,
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export const didAuthConfigEntityFrom = (config: NonPersistedDidAuthConfig): DidAuthConfigEntity => {
|
|
168
|
-
let identifier: string | undefined = undefined
|
|
169
|
-
if (typeof config.idOpts.identifier === 'string') {
|
|
170
|
-
identifier = config.idOpts.identifier
|
|
171
|
-
} else if (typeof config.idOpts.identifier === 'object') {
|
|
172
|
-
if ('did' in config.idOpts.identifier && typeof config.idOpts.identifier.did === 'string') {
|
|
173
|
-
identifier = config.idOpts.identifier.did
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
if (!identifier) {
|
|
177
|
-
throw Error(`Identifier method ${config.idOpts.method} not yet supported`)
|
|
178
|
-
}
|
|
179
|
-
const didAuthConfig: DidAuthConfigEntity = new DidAuthConfigEntity()
|
|
180
|
-
didAuthConfig.identifier = identifier
|
|
181
|
-
didAuthConfig.redirectUrl = config.redirectUrl
|
|
182
|
-
didAuthConfig.sessionId = config.sessionId
|
|
183
|
-
didAuthConfig.ownerId = config.ownerId
|
|
184
|
-
didAuthConfig.tenantId = config.tenantId
|
|
185
|
-
return didAuthConfig
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export const electronicAddressEntityFrom = (electronicAddress: NonPersistedElectronicAddress): ElectronicAddressEntity => {
|
|
189
|
-
const electronicAddressEntity: ElectronicAddressEntity = new ElectronicAddressEntity()
|
|
190
|
-
electronicAddressEntity.type = electronicAddress.type
|
|
191
|
-
electronicAddressEntity.electronicAddress = electronicAddress.electronicAddress
|
|
192
|
-
electronicAddressEntity.ownerId = electronicAddress.ownerId
|
|
193
|
-
electronicAddressEntity.tenantId = electronicAddress.tenantId
|
|
194
|
-
|
|
195
|
-
return electronicAddressEntity
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export const electronicAddressFrom = (electronicAddress: ElectronicAddressEntity): ElectronicAddress => {
|
|
199
|
-
return {
|
|
200
|
-
id: electronicAddress.id,
|
|
201
|
-
type: electronicAddress.type,
|
|
202
|
-
electronicAddress: electronicAddress.electronicAddress,
|
|
203
|
-
ownerId: electronicAddress.ownerId,
|
|
204
|
-
tenantId: electronicAddress.tenantId,
|
|
205
|
-
createdAt: electronicAddress.createdAt,
|
|
206
|
-
lastUpdatedAt: electronicAddress.lastUpdatedAt,
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
export const physicalAddressEntityFrom = (physicalAddress: NonPersistedPhysicalAddress): PhysicalAddressEntity => {
|
|
211
|
-
const physicalAddressEntity: PhysicalAddressEntity = new PhysicalAddressEntity()
|
|
212
|
-
physicalAddressEntity.type = physicalAddress.type
|
|
213
|
-
physicalAddressEntity.streetName = physicalAddress.streetName
|
|
214
|
-
physicalAddressEntity.streetNumber = physicalAddress.streetNumber
|
|
215
|
-
physicalAddressEntity.postalCode = physicalAddress.postalCode
|
|
216
|
-
physicalAddressEntity.cityName = physicalAddress.cityName
|
|
217
|
-
physicalAddressEntity.provinceName = physicalAddress.provinceName
|
|
218
|
-
physicalAddressEntity.countryCode = physicalAddress.countryCode
|
|
219
|
-
physicalAddressEntity.buildingName = physicalAddress.buildingName
|
|
220
|
-
physicalAddressEntity.ownerId = physicalAddress.ownerId
|
|
221
|
-
physicalAddressEntity.tenantId = physicalAddress.tenantId
|
|
222
|
-
|
|
223
|
-
return physicalAddressEntity
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
export const physicalAddressFrom = (physicalAddress: PhysicalAddressEntity): PhysicalAddress => {
|
|
227
|
-
return {
|
|
228
|
-
id: physicalAddress.id,
|
|
229
|
-
type: physicalAddress.type,
|
|
230
|
-
streetName: physicalAddress.streetName,
|
|
231
|
-
streetNumber: physicalAddress.streetNumber,
|
|
232
|
-
postalCode: physicalAddress.postalCode,
|
|
233
|
-
cityName: physicalAddress.cityName,
|
|
234
|
-
provinceName: physicalAddress.provinceName,
|
|
235
|
-
countryCode: physicalAddress.countryCode,
|
|
236
|
-
buildingName: physicalAddress.buildingName,
|
|
237
|
-
ownerId: physicalAddress.ownerId,
|
|
238
|
-
tenantId: physicalAddress.tenantId,
|
|
239
|
-
createdAt: physicalAddress.createdAt,
|
|
240
|
-
lastUpdatedAt: physicalAddress.lastUpdatedAt,
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
export const identityEntityFrom = (entity: NonPersistedIdentity): IdentityEntity => {
|
|
245
|
-
const identityEntity: IdentityEntity = new IdentityEntity()
|
|
246
|
-
identityEntity.alias = entity.alias
|
|
247
|
-
identityEntity.origin = entity.origin
|
|
248
|
-
identityEntity.ownerId = entity.ownerId
|
|
249
|
-
identityEntity.tenantId = entity.tenantId
|
|
250
|
-
identityEntity.roles = entity.roles
|
|
251
|
-
identityEntity.identifier = correlationIdentifierEntityFrom(entity.identifier)
|
|
252
|
-
identityEntity.connection = entity.connection ? connectionEntityFrom(entity.connection) : undefined
|
|
253
|
-
identityEntity.metadata = entity.metadata
|
|
254
|
-
? entity.metadata.map(identityMetadataItemEntityFrom).filter((entity): entity is IdentityMetadataItemEntity => entity !== undefined)
|
|
255
|
-
: []
|
|
256
|
-
return identityEntity
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
export const identityFrom = (identity: IdentityEntity): Identity => {
|
|
260
|
-
return {
|
|
261
|
-
id: identity.id,
|
|
262
|
-
alias: identity.alias,
|
|
263
|
-
origin: identity.origin,
|
|
264
|
-
roles: identity.roles,
|
|
265
|
-
tenantId: identity.tenantId,
|
|
266
|
-
ownerId: identity.ownerId,
|
|
267
|
-
identifier: correlationIdentifierFrom(identity.identifier),
|
|
268
|
-
...(identity.connection && { connection: connectionFrom(identity.connection) }),
|
|
269
|
-
metadata: identity.metadata ? identity.metadata.map((item: IdentityMetadataItemEntity) => metadataItemFrom(item)) : [],
|
|
270
|
-
createdAt: identity.createdAt,
|
|
271
|
-
lastUpdatedAt: identity.createdAt,
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
const metadataItemEntityFrom = <T extends MetadataTypes, U extends { new (): any }>(
|
|
276
|
-
item: NonPersistedMetadataItem<T>,
|
|
277
|
-
EntityClass: U,
|
|
278
|
-
): InstanceType<U> | undefined => {
|
|
279
|
-
const { label, value } = item
|
|
280
|
-
|
|
281
|
-
if (value === null || value === undefined) {
|
|
282
|
-
return undefined
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
const metadataItemEntity = new EntityClass()
|
|
286
|
-
metadataItemEntity.label = label
|
|
287
|
-
metadataItemEntity.valueType = typeof value
|
|
288
|
-
|
|
289
|
-
switch (typeof value) {
|
|
290
|
-
case 'undefined':
|
|
291
|
-
return undefined
|
|
292
|
-
case 'string':
|
|
293
|
-
metadataItemEntity.stringValue = value
|
|
294
|
-
break
|
|
295
|
-
case 'number':
|
|
296
|
-
metadataItemEntity.numberValue = value
|
|
297
|
-
break
|
|
298
|
-
case 'boolean':
|
|
299
|
-
metadataItemEntity.boolValue = value
|
|
300
|
-
break
|
|
301
|
-
case 'object':
|
|
302
|
-
metadataItemEntity.valueType = Object.prototype.toString.call(value).slice(8, -1)
|
|
303
|
-
if (value instanceof Date) {
|
|
304
|
-
metadataItemEntity.dateValue = value
|
|
305
|
-
} else {
|
|
306
|
-
// For now, we only support / implement not-primitive type Date in the entity
|
|
307
|
-
throw new Error(`Unsupported object type: ${metadataItemEntity.valueType} for value ${value}`)
|
|
308
|
-
}
|
|
309
|
-
break
|
|
310
|
-
}
|
|
311
|
-
return metadataItemEntity
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
export const identityMetadataItemEntityFrom = (item: NonPersistedMetadataItem<MetadataTypes>): IdentityMetadataItemEntity | undefined => {
|
|
315
|
-
return metadataItemEntityFrom(item, IdentityMetadataItemEntity)
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
export const contactMetadataItemEntityFrom = (item: NonPersistedMetadataItem<MetadataTypes>): ContactMetadataItemEntity | undefined => {
|
|
319
|
-
return metadataItemEntityFrom(item, ContactMetadataItemEntity)
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
export const metadataItemFrom = (entity: IdentityMetadataItemEntity | ContactMetadataItemEntity): MetadataItem<MetadataTypes> => {
|
|
323
|
-
const item: Partial<MetadataItem<MetadataTypes>> = {
|
|
324
|
-
id: entity.id,
|
|
325
|
-
label: entity.label,
|
|
326
|
-
}
|
|
327
|
-
switch (entity.valueType) {
|
|
328
|
-
case 'string':
|
|
329
|
-
item.value = entity.stringValue
|
|
330
|
-
break
|
|
331
|
-
case 'number':
|
|
332
|
-
item.value = entity.numberValue
|
|
333
|
-
break
|
|
334
|
-
case 'Date':
|
|
335
|
-
item.value = entity.dateValue
|
|
336
|
-
break
|
|
337
|
-
case 'boolean':
|
|
338
|
-
item.value = entity.boolValue
|
|
339
|
-
break
|
|
340
|
-
default:
|
|
341
|
-
throw new Error(`Unsupported valueType ${entity.valueType}`)
|
|
342
|
-
}
|
|
343
|
-
return item as MetadataItem<MetadataTypes>
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
export const naturalPersonEntityFrom = (naturalPerson: NonPersistedNaturalPerson): NaturalPersonEntity => {
|
|
347
|
-
const naturalPersonEntity: NaturalPersonEntity = new NaturalPersonEntity()
|
|
348
|
-
naturalPersonEntity.firstName = naturalPerson.firstName
|
|
349
|
-
naturalPersonEntity.middleName = naturalPerson.middleName
|
|
350
|
-
naturalPersonEntity.lastName = naturalPerson.lastName
|
|
351
|
-
naturalPersonEntity.displayName = naturalPerson.displayName
|
|
352
|
-
naturalPersonEntity.ownerId = naturalPerson.ownerId
|
|
353
|
-
naturalPersonEntity.tenantId = naturalPerson.tenantId
|
|
354
|
-
naturalPersonEntity.metadata = naturalPerson.metadata
|
|
355
|
-
? naturalPerson.metadata.map(contactMetadataItemEntityFrom).filter((entity): entity is ContactMetadataItemEntity => entity !== undefined)
|
|
356
|
-
: []
|
|
357
|
-
|
|
358
|
-
return naturalPersonEntity
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
export const naturalPersonFrom = (naturalPerson: NaturalPersonEntity): NaturalPerson => {
|
|
362
|
-
return {
|
|
363
|
-
id: naturalPerson.id,
|
|
364
|
-
firstName: naturalPerson.firstName,
|
|
365
|
-
middleName: naturalPerson.middleName,
|
|
366
|
-
lastName: naturalPerson.lastName,
|
|
367
|
-
displayName: naturalPerson.displayName,
|
|
368
|
-
metadata: naturalPerson.metadata ? naturalPerson.metadata.map((item: ContactMetadataItemEntity) => metadataItemFrom(item)) : [],
|
|
369
|
-
ownerId: naturalPerson.ownerId,
|
|
370
|
-
tenantId: naturalPerson.tenantId,
|
|
371
|
-
createdAt: naturalPerson.createdAt,
|
|
372
|
-
lastUpdatedAt: naturalPerson.lastUpdatedAt,
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
export const openIdConfigEntityFrom = (config: NonPersistedOpenIdConfig): OpenIdConfigEntity => {
|
|
377
|
-
const openIdConfig: OpenIdConfigEntity = new OpenIdConfigEntity()
|
|
378
|
-
openIdConfig.clientId = config.clientId
|
|
379
|
-
openIdConfig.clientSecret = config.clientSecret
|
|
380
|
-
openIdConfig.scopes = config.scopes
|
|
381
|
-
openIdConfig.issuer = config.issuer
|
|
382
|
-
openIdConfig.redirectUrl = config.redirectUrl
|
|
383
|
-
openIdConfig.dangerouslyAllowInsecureHttpRequests = config.dangerouslyAllowInsecureHttpRequests
|
|
384
|
-
openIdConfig.clientAuthMethod = config.clientAuthMethod
|
|
385
|
-
openIdConfig.ownerId = config.ownerId
|
|
386
|
-
openIdConfig.tenantId = config.tenantId
|
|
387
|
-
|
|
388
|
-
return openIdConfig
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
export const organizationEntityFrom = (organization: NonPersistedOrganization): OrganizationEntity => {
|
|
392
|
-
const organizationEntity: OrganizationEntity = new OrganizationEntity()
|
|
393
|
-
organizationEntity.legalName = organization.legalName
|
|
394
|
-
organizationEntity.displayName = organization.displayName
|
|
395
|
-
organizationEntity.ownerId = organization.ownerId
|
|
396
|
-
organizationEntity.tenantId = organization.tenantId
|
|
397
|
-
organizationEntity.metadata = organization.metadata
|
|
398
|
-
? organization.metadata.map(contactMetadataItemEntityFrom).filter((entity): entity is ContactMetadataItemEntity => entity !== undefined)
|
|
399
|
-
: []
|
|
400
|
-
|
|
401
|
-
return organizationEntity
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
export const organizationFrom = (organization: OrganizationEntity): Organization => {
|
|
405
|
-
return {
|
|
406
|
-
id: organization.id,
|
|
407
|
-
legalName: organization.legalName,
|
|
408
|
-
displayName: organization.displayName,
|
|
409
|
-
metadata: organization.metadata ? organization.metadata.map((item: ContactMetadataItemEntity) => metadataItemFrom(item)) : [],
|
|
410
|
-
ownerId: organization.ownerId,
|
|
411
|
-
tenantId: organization.tenantId,
|
|
412
|
-
createdAt: organization.createdAt,
|
|
413
|
-
lastUpdatedAt: organization.lastUpdatedAt,
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
export const partyRelationshipEntityFrom = (relationship: NonPersistedPartyRelationship): PartyRelationshipEntity => {
|
|
418
|
-
const partyRelationshipEntity: PartyRelationshipEntity = new PartyRelationshipEntity()
|
|
419
|
-
partyRelationshipEntity.leftId = relationship.leftId
|
|
420
|
-
partyRelationshipEntity.rightId = relationship.rightId
|
|
421
|
-
partyRelationshipEntity.ownerId = relationship.ownerId
|
|
422
|
-
partyRelationshipEntity.tenantId = relationship.tenantId
|
|
423
|
-
return partyRelationshipEntity
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
export const partyRelationshipFrom = (relationship: PartyRelationshipEntity): PartyRelationship => {
|
|
427
|
-
return {
|
|
428
|
-
id: relationship.id,
|
|
429
|
-
leftId: relationship.leftId,
|
|
430
|
-
rightId: relationship.rightId,
|
|
431
|
-
ownerId: relationship.ownerId,
|
|
432
|
-
tenantId: relationship.tenantId,
|
|
433
|
-
createdAt: relationship.createdAt,
|
|
434
|
-
lastUpdatedAt: relationship.lastUpdatedAt,
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
export const partyTypeEntityFrom = (args: NonPersistedPartyType): PartyTypeEntity => {
|
|
439
|
-
const partyTypeEntity: PartyTypeEntity = new PartyTypeEntity()
|
|
440
|
-
if (args.id) {
|
|
441
|
-
partyTypeEntity.id = args.id
|
|
442
|
-
}
|
|
443
|
-
partyTypeEntity.type = args.type
|
|
444
|
-
partyTypeEntity.origin = args.origin
|
|
445
|
-
partyTypeEntity.name = args.name
|
|
446
|
-
partyTypeEntity.description = args.description
|
|
447
|
-
partyTypeEntity.tenantId = args.tenantId
|
|
448
|
-
|
|
449
|
-
return partyTypeEntity
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
export const partyTypeFrom = (partyType: PartyTypeEntity): PartyType => {
|
|
453
|
-
return {
|
|
454
|
-
id: partyType.id,
|
|
455
|
-
type: partyType.type,
|
|
456
|
-
origin: partyType.origin,
|
|
457
|
-
name: partyType.name,
|
|
458
|
-
tenantId: partyType.tenantId,
|
|
459
|
-
description: partyType.description,
|
|
460
|
-
createdAt: partyType.createdAt,
|
|
461
|
-
lastUpdatedAt: partyType.lastUpdatedAt,
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
export const configFrom = (config: BaseConfigEntity): ConnectionConfig => {
|
|
466
|
-
if (isOpenIdConfig(config)) {
|
|
467
|
-
return openIdConfigFrom(<OpenIdConfigEntity>config)
|
|
468
|
-
} else if (isDidAuthConfig(config)) {
|
|
469
|
-
return didAuthConfigFrom(<DidAuthConfigEntity>config)
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
throw new Error('config type not supported')
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
export const openIdConfigFrom = (config: OpenIdConfigEntity): OpenIdConfig => {
|
|
476
|
-
return {
|
|
477
|
-
id: config.id,
|
|
478
|
-
clientId: config.clientId,
|
|
479
|
-
clientSecret: config.clientSecret,
|
|
480
|
-
scopes: config.scopes,
|
|
481
|
-
issuer: config.issuer,
|
|
482
|
-
redirectUrl: config.redirectUrl,
|
|
483
|
-
dangerouslyAllowInsecureHttpRequests: config.dangerouslyAllowInsecureHttpRequests,
|
|
484
|
-
clientAuthMethod: config.clientAuthMethod,
|
|
485
|
-
ownerId: config.ownerId,
|
|
486
|
-
tenantId: config.tenantId,
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
export const didAuthConfigFrom = (config: DidAuthConfigEntity): DidAuthConfig => {
|
|
491
|
-
return {
|
|
492
|
-
id: config.id,
|
|
493
|
-
idOpts: { identifier: config.identifier },
|
|
494
|
-
stateId: '', // FIXME
|
|
495
|
-
redirectUrl: config.redirectUrl,
|
|
496
|
-
sessionId: config.sessionId,
|
|
497
|
-
ownerId: config.ownerId,
|
|
498
|
-
tenantId: config.tenantId,
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
export const isOpenIdConfig = (config: NonPersistedConnectionConfig | BaseConfigEntity): config is OpenIdConfig | OpenIdConfigEntity =>
|
|
503
|
-
'clientSecret' in config && 'issuer' in config && 'redirectUrl' in config
|
|
504
|
-
|
|
505
|
-
export const isDidAuthConfig = (config: NonPersistedConnectionConfig | BaseConfigEntity): config is DidAuthConfig | DidAuthConfigEntity =>
|
|
506
|
-
('identifier' in config || ('idOpts' in config && 'identifier' in config.idOpts)) && 'redirectUrl' in config && 'sessionId' in config
|
|
1
|
+
import {
|
|
2
|
+
MetadataTypes,
|
|
3
|
+
Connection,
|
|
4
|
+
ConnectionConfig,
|
|
5
|
+
Contact,
|
|
6
|
+
CorrelationIdentifier,
|
|
7
|
+
DidAuthConfig,
|
|
8
|
+
ElectronicAddress,
|
|
9
|
+
Identity,
|
|
10
|
+
MetadataItem,
|
|
11
|
+
NaturalPerson,
|
|
12
|
+
NonPersistedConnection,
|
|
13
|
+
NonPersistedConnectionConfig,
|
|
14
|
+
NonPersistedContact,
|
|
15
|
+
NonPersistedCorrelationIdentifier,
|
|
16
|
+
NonPersistedDidAuthConfig,
|
|
17
|
+
NonPersistedElectronicAddress,
|
|
18
|
+
NonPersistedIdentity,
|
|
19
|
+
NonPersistedMetadataItem,
|
|
20
|
+
NonPersistedNaturalPerson,
|
|
21
|
+
NonPersistedOpenIdConfig,
|
|
22
|
+
NonPersistedOrganization,
|
|
23
|
+
NonPersistedParty,
|
|
24
|
+
NonPersistedPartyRelationship,
|
|
25
|
+
NonPersistedPartyType,
|
|
26
|
+
NonPersistedPhysicalAddress,
|
|
27
|
+
OpenIdConfig,
|
|
28
|
+
Organization,
|
|
29
|
+
Party,
|
|
30
|
+
PartyRelationship,
|
|
31
|
+
PartyType,
|
|
32
|
+
PhysicalAddress,
|
|
33
|
+
} from '../../types'
|
|
34
|
+
import { PartyEntity } from '../../entities/contact/PartyEntity'
|
|
35
|
+
import { IdentityEntity } from '../../entities/contact/IdentityEntity'
|
|
36
|
+
import { ElectronicAddressEntity } from '../../entities/contact/ElectronicAddressEntity'
|
|
37
|
+
import { PartyRelationshipEntity } from '../../entities/contact/PartyRelationshipEntity'
|
|
38
|
+
import { BaseContactEntity } from '../../entities/contact/BaseContactEntity'
|
|
39
|
+
import { NaturalPersonEntity } from '../../entities/contact/NaturalPersonEntity'
|
|
40
|
+
import { OrganizationEntity } from '../../entities/contact/OrganizationEntity'
|
|
41
|
+
import { ConnectionEntity } from '../../entities/contact/ConnectionEntity'
|
|
42
|
+
import { BaseConfigEntity } from '../../entities/contact/BaseConfigEntity'
|
|
43
|
+
import { CorrelationIdentifierEntity } from '../../entities/contact/CorrelationIdentifierEntity'
|
|
44
|
+
import { DidAuthConfigEntity } from '../../entities/contact/DidAuthConfigEntity'
|
|
45
|
+
import { IdentityMetadataItemEntity } from '../../entities/contact/IdentityMetadataItemEntity'
|
|
46
|
+
import { OpenIdConfigEntity } from '../../entities/contact/OpenIdConfigEntity'
|
|
47
|
+
import { PartyTypeEntity } from '../../entities/contact/PartyTypeEntity'
|
|
48
|
+
import { PhysicalAddressEntity } from '../../entities/contact/PhysicalAddressEntity'
|
|
49
|
+
import { ContactMetadataItemEntity } from '../../entities/contact/ContactMetadataItemEntity'
|
|
50
|
+
|
|
51
|
+
export const partyEntityFrom = (party: NonPersistedParty): PartyEntity => {
|
|
52
|
+
const partyEntity: PartyEntity = new PartyEntity()
|
|
53
|
+
partyEntity.uri = party.uri
|
|
54
|
+
partyEntity.identities = party.identities ? party.identities.map((identity: NonPersistedIdentity) => identityEntityFrom(identity)) : []
|
|
55
|
+
partyEntity.electronicAddresses = party.electronicAddresses
|
|
56
|
+
? party.electronicAddresses.map((electronicAddress: NonPersistedElectronicAddress) => electronicAddressEntityFrom(electronicAddress))
|
|
57
|
+
: []
|
|
58
|
+
partyEntity.physicalAddresses = party.physicalAddresses
|
|
59
|
+
? party.physicalAddresses.map((physicalAddress: NonPersistedPhysicalAddress) => physicalAddressEntityFrom(physicalAddress))
|
|
60
|
+
: []
|
|
61
|
+
partyEntity.partyType = partyTypeEntityFrom(party.partyType)
|
|
62
|
+
partyEntity.contact = contactEntityFrom(party.contact)
|
|
63
|
+
partyEntity.ownerId = party.ownerId
|
|
64
|
+
partyEntity.tenantId = party.tenantId
|
|
65
|
+
|
|
66
|
+
return partyEntity
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const partyFrom = (party: PartyEntity): Party => {
|
|
70
|
+
return {
|
|
71
|
+
id: party.id,
|
|
72
|
+
uri: party.uri,
|
|
73
|
+
roles: [...new Set(party.identities?.flatMap((identity: IdentityEntity) => identity.roles))] ?? [],
|
|
74
|
+
identities: party.identities ? party.identities.map((identity: IdentityEntity) => identityFrom(identity)) : [],
|
|
75
|
+
electronicAddresses: party.electronicAddresses
|
|
76
|
+
? party.electronicAddresses.map((electronicAddress: ElectronicAddressEntity) => electronicAddressFrom(electronicAddress))
|
|
77
|
+
: [],
|
|
78
|
+
physicalAddresses: party.physicalAddresses
|
|
79
|
+
? party.physicalAddresses.map((physicalAddress: PhysicalAddressEntity) => physicalAddressFrom(physicalAddress))
|
|
80
|
+
: [],
|
|
81
|
+
relationships: party.relationships ? party.relationships.map((relationship: PartyRelationshipEntity) => partyRelationshipFrom(relationship)) : [],
|
|
82
|
+
partyType: partyTypeFrom(party.partyType),
|
|
83
|
+
contact: contactFrom(party.contact),
|
|
84
|
+
ownerId: party.ownerId,
|
|
85
|
+
tenantId: party.tenantId,
|
|
86
|
+
createdAt: party.createdAt,
|
|
87
|
+
lastUpdatedAt: party.lastUpdatedAt,
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export const contactEntityFrom = (contact: NonPersistedContact): BaseContactEntity => {
|
|
92
|
+
if (isNaturalPerson(contact)) {
|
|
93
|
+
return naturalPersonEntityFrom(<NonPersistedNaturalPerson>contact)
|
|
94
|
+
} else if (isOrganization(contact)) {
|
|
95
|
+
return organizationEntityFrom(<NonPersistedOrganization>contact)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
throw new Error('Contact not supported')
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export const contactFrom = (contact: BaseContactEntity): Contact => {
|
|
102
|
+
if (isNaturalPerson(contact)) {
|
|
103
|
+
return naturalPersonFrom(<NaturalPersonEntity>contact)
|
|
104
|
+
} else if (isOrganization(contact)) {
|
|
105
|
+
return organizationFrom(<OrganizationEntity>contact)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
throw new Error(`Contact type not supported`)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export const isNaturalPerson = (contact: NonPersistedContact | BaseContactEntity): contact is NonPersistedNaturalPerson | NaturalPersonEntity =>
|
|
112
|
+
'firstName' in contact && 'lastName' in contact
|
|
113
|
+
|
|
114
|
+
export const isOrganization = (contact: NonPersistedContact | BaseContactEntity): contact is NonPersistedOrganization | OrganizationEntity =>
|
|
115
|
+
'legalName' in contact
|
|
116
|
+
|
|
117
|
+
export const connectionEntityFrom = (connection: NonPersistedConnection): ConnectionEntity => {
|
|
118
|
+
const connectionEntity: ConnectionEntity = new ConnectionEntity()
|
|
119
|
+
connectionEntity.type = connection.type
|
|
120
|
+
connectionEntity.config = configEntityFrom(connection.config)
|
|
121
|
+
connectionEntity.ownerId = connection.ownerId
|
|
122
|
+
connectionEntity.tenantId = connection.tenantId
|
|
123
|
+
|
|
124
|
+
return connectionEntity
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export const connectionFrom = (connection: ConnectionEntity): Connection => {
|
|
128
|
+
return {
|
|
129
|
+
id: connection.id,
|
|
130
|
+
type: connection.type,
|
|
131
|
+
ownerId: connection.ownerId,
|
|
132
|
+
tenantId: connection.tenantId,
|
|
133
|
+
config: configFrom(connection.config),
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const configEntityFrom = (config: NonPersistedConnectionConfig): BaseConfigEntity => {
|
|
138
|
+
if (isOpenIdConfig(config)) {
|
|
139
|
+
return openIdConfigEntityFrom(<NonPersistedOpenIdConfig>config)
|
|
140
|
+
} else if (isDidAuthConfig(config)) {
|
|
141
|
+
return didAuthConfigEntityFrom(<NonPersistedDidAuthConfig>config)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
throw new Error('config type not supported')
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export const correlationIdentifierEntityFrom = (identifier: NonPersistedCorrelationIdentifier): CorrelationIdentifierEntity => {
|
|
148
|
+
const identifierEntity: CorrelationIdentifierEntity = new CorrelationIdentifierEntity()
|
|
149
|
+
identifierEntity.type = identifier.type
|
|
150
|
+
identifierEntity.correlationId = identifier.correlationId
|
|
151
|
+
identifierEntity.ownerId = identifier.ownerId
|
|
152
|
+
identifierEntity.tenantId = identifier.tenantId
|
|
153
|
+
|
|
154
|
+
return identifierEntity
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export const correlationIdentifierFrom = (identifier: CorrelationIdentifierEntity): CorrelationIdentifier => {
|
|
158
|
+
return {
|
|
159
|
+
id: identifier.id,
|
|
160
|
+
type: identifier.type,
|
|
161
|
+
correlationId: identifier.correlationId,
|
|
162
|
+
ownerId: identifier.ownerId,
|
|
163
|
+
tenantId: identifier.tenantId,
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export const didAuthConfigEntityFrom = (config: NonPersistedDidAuthConfig): DidAuthConfigEntity => {
|
|
168
|
+
let identifier: string | undefined = undefined
|
|
169
|
+
if (typeof config.idOpts.identifier === 'string') {
|
|
170
|
+
identifier = config.idOpts.identifier
|
|
171
|
+
} else if (typeof config.idOpts.identifier === 'object') {
|
|
172
|
+
if ('did' in config.idOpts.identifier && typeof config.idOpts.identifier.did === 'string') {
|
|
173
|
+
identifier = config.idOpts.identifier.did
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (!identifier) {
|
|
177
|
+
throw Error(`Identifier method ${config.idOpts.method} not yet supported`)
|
|
178
|
+
}
|
|
179
|
+
const didAuthConfig: DidAuthConfigEntity = new DidAuthConfigEntity()
|
|
180
|
+
didAuthConfig.identifier = identifier
|
|
181
|
+
didAuthConfig.redirectUrl = config.redirectUrl
|
|
182
|
+
didAuthConfig.sessionId = config.sessionId
|
|
183
|
+
didAuthConfig.ownerId = config.ownerId
|
|
184
|
+
didAuthConfig.tenantId = config.tenantId
|
|
185
|
+
return didAuthConfig
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export const electronicAddressEntityFrom = (electronicAddress: NonPersistedElectronicAddress): ElectronicAddressEntity => {
|
|
189
|
+
const electronicAddressEntity: ElectronicAddressEntity = new ElectronicAddressEntity()
|
|
190
|
+
electronicAddressEntity.type = electronicAddress.type
|
|
191
|
+
electronicAddressEntity.electronicAddress = electronicAddress.electronicAddress
|
|
192
|
+
electronicAddressEntity.ownerId = electronicAddress.ownerId
|
|
193
|
+
electronicAddressEntity.tenantId = electronicAddress.tenantId
|
|
194
|
+
|
|
195
|
+
return electronicAddressEntity
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export const electronicAddressFrom = (electronicAddress: ElectronicAddressEntity): ElectronicAddress => {
|
|
199
|
+
return {
|
|
200
|
+
id: electronicAddress.id,
|
|
201
|
+
type: electronicAddress.type,
|
|
202
|
+
electronicAddress: electronicAddress.electronicAddress,
|
|
203
|
+
ownerId: electronicAddress.ownerId,
|
|
204
|
+
tenantId: electronicAddress.tenantId,
|
|
205
|
+
createdAt: electronicAddress.createdAt,
|
|
206
|
+
lastUpdatedAt: electronicAddress.lastUpdatedAt,
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export const physicalAddressEntityFrom = (physicalAddress: NonPersistedPhysicalAddress): PhysicalAddressEntity => {
|
|
211
|
+
const physicalAddressEntity: PhysicalAddressEntity = new PhysicalAddressEntity()
|
|
212
|
+
physicalAddressEntity.type = physicalAddress.type
|
|
213
|
+
physicalAddressEntity.streetName = physicalAddress.streetName
|
|
214
|
+
physicalAddressEntity.streetNumber = physicalAddress.streetNumber
|
|
215
|
+
physicalAddressEntity.postalCode = physicalAddress.postalCode
|
|
216
|
+
physicalAddressEntity.cityName = physicalAddress.cityName
|
|
217
|
+
physicalAddressEntity.provinceName = physicalAddress.provinceName
|
|
218
|
+
physicalAddressEntity.countryCode = physicalAddress.countryCode
|
|
219
|
+
physicalAddressEntity.buildingName = physicalAddress.buildingName
|
|
220
|
+
physicalAddressEntity.ownerId = physicalAddress.ownerId
|
|
221
|
+
physicalAddressEntity.tenantId = physicalAddress.tenantId
|
|
222
|
+
|
|
223
|
+
return physicalAddressEntity
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export const physicalAddressFrom = (physicalAddress: PhysicalAddressEntity): PhysicalAddress => {
|
|
227
|
+
return {
|
|
228
|
+
id: physicalAddress.id,
|
|
229
|
+
type: physicalAddress.type,
|
|
230
|
+
streetName: physicalAddress.streetName,
|
|
231
|
+
streetNumber: physicalAddress.streetNumber,
|
|
232
|
+
postalCode: physicalAddress.postalCode,
|
|
233
|
+
cityName: physicalAddress.cityName,
|
|
234
|
+
provinceName: physicalAddress.provinceName,
|
|
235
|
+
countryCode: physicalAddress.countryCode,
|
|
236
|
+
buildingName: physicalAddress.buildingName,
|
|
237
|
+
ownerId: physicalAddress.ownerId,
|
|
238
|
+
tenantId: physicalAddress.tenantId,
|
|
239
|
+
createdAt: physicalAddress.createdAt,
|
|
240
|
+
lastUpdatedAt: physicalAddress.lastUpdatedAt,
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export const identityEntityFrom = (entity: NonPersistedIdentity): IdentityEntity => {
|
|
245
|
+
const identityEntity: IdentityEntity = new IdentityEntity()
|
|
246
|
+
identityEntity.alias = entity.alias
|
|
247
|
+
identityEntity.origin = entity.origin
|
|
248
|
+
identityEntity.ownerId = entity.ownerId
|
|
249
|
+
identityEntity.tenantId = entity.tenantId
|
|
250
|
+
identityEntity.roles = entity.roles
|
|
251
|
+
identityEntity.identifier = correlationIdentifierEntityFrom(entity.identifier)
|
|
252
|
+
identityEntity.connection = entity.connection ? connectionEntityFrom(entity.connection) : undefined
|
|
253
|
+
identityEntity.metadata = entity.metadata
|
|
254
|
+
? entity.metadata.map(identityMetadataItemEntityFrom).filter((entity): entity is IdentityMetadataItemEntity => entity !== undefined)
|
|
255
|
+
: []
|
|
256
|
+
return identityEntity
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export const identityFrom = (identity: IdentityEntity): Identity => {
|
|
260
|
+
return {
|
|
261
|
+
id: identity.id,
|
|
262
|
+
alias: identity.alias,
|
|
263
|
+
origin: identity.origin,
|
|
264
|
+
roles: identity.roles,
|
|
265
|
+
tenantId: identity.tenantId,
|
|
266
|
+
ownerId: identity.ownerId,
|
|
267
|
+
identifier: correlationIdentifierFrom(identity.identifier),
|
|
268
|
+
...(identity.connection && { connection: connectionFrom(identity.connection) }),
|
|
269
|
+
metadata: identity.metadata ? identity.metadata.map((item: IdentityMetadataItemEntity) => metadataItemFrom(item)) : [],
|
|
270
|
+
createdAt: identity.createdAt,
|
|
271
|
+
lastUpdatedAt: identity.createdAt,
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const metadataItemEntityFrom = <T extends MetadataTypes, U extends { new (): any }>(
|
|
276
|
+
item: NonPersistedMetadataItem<T>,
|
|
277
|
+
EntityClass: U,
|
|
278
|
+
): InstanceType<U> | undefined => {
|
|
279
|
+
const { label, value } = item
|
|
280
|
+
|
|
281
|
+
if (value === null || value === undefined) {
|
|
282
|
+
return undefined
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const metadataItemEntity = new EntityClass()
|
|
286
|
+
metadataItemEntity.label = label
|
|
287
|
+
metadataItemEntity.valueType = typeof value
|
|
288
|
+
|
|
289
|
+
switch (typeof value) {
|
|
290
|
+
case 'undefined':
|
|
291
|
+
return undefined
|
|
292
|
+
case 'string':
|
|
293
|
+
metadataItemEntity.stringValue = value
|
|
294
|
+
break
|
|
295
|
+
case 'number':
|
|
296
|
+
metadataItemEntity.numberValue = value
|
|
297
|
+
break
|
|
298
|
+
case 'boolean':
|
|
299
|
+
metadataItemEntity.boolValue = value
|
|
300
|
+
break
|
|
301
|
+
case 'object':
|
|
302
|
+
metadataItemEntity.valueType = Object.prototype.toString.call(value).slice(8, -1)
|
|
303
|
+
if (value instanceof Date) {
|
|
304
|
+
metadataItemEntity.dateValue = value
|
|
305
|
+
} else {
|
|
306
|
+
// For now, we only support / implement not-primitive type Date in the entity
|
|
307
|
+
throw new Error(`Unsupported object type: ${metadataItemEntity.valueType} for value ${value}`)
|
|
308
|
+
}
|
|
309
|
+
break
|
|
310
|
+
}
|
|
311
|
+
return metadataItemEntity
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export const identityMetadataItemEntityFrom = (item: NonPersistedMetadataItem<MetadataTypes>): IdentityMetadataItemEntity | undefined => {
|
|
315
|
+
return metadataItemEntityFrom(item, IdentityMetadataItemEntity)
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export const contactMetadataItemEntityFrom = (item: NonPersistedMetadataItem<MetadataTypes>): ContactMetadataItemEntity | undefined => {
|
|
319
|
+
return metadataItemEntityFrom(item, ContactMetadataItemEntity)
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export const metadataItemFrom = (entity: IdentityMetadataItemEntity | ContactMetadataItemEntity): MetadataItem<MetadataTypes> => {
|
|
323
|
+
const item: Partial<MetadataItem<MetadataTypes>> = {
|
|
324
|
+
id: entity.id,
|
|
325
|
+
label: entity.label,
|
|
326
|
+
}
|
|
327
|
+
switch (entity.valueType) {
|
|
328
|
+
case 'string':
|
|
329
|
+
item.value = entity.stringValue
|
|
330
|
+
break
|
|
331
|
+
case 'number':
|
|
332
|
+
item.value = entity.numberValue
|
|
333
|
+
break
|
|
334
|
+
case 'Date':
|
|
335
|
+
item.value = entity.dateValue
|
|
336
|
+
break
|
|
337
|
+
case 'boolean':
|
|
338
|
+
item.value = entity.boolValue
|
|
339
|
+
break
|
|
340
|
+
default:
|
|
341
|
+
throw new Error(`Unsupported valueType ${entity.valueType}`)
|
|
342
|
+
}
|
|
343
|
+
return item as MetadataItem<MetadataTypes>
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export const naturalPersonEntityFrom = (naturalPerson: NonPersistedNaturalPerson): NaturalPersonEntity => {
|
|
347
|
+
const naturalPersonEntity: NaturalPersonEntity = new NaturalPersonEntity()
|
|
348
|
+
naturalPersonEntity.firstName = naturalPerson.firstName
|
|
349
|
+
naturalPersonEntity.middleName = naturalPerson.middleName
|
|
350
|
+
naturalPersonEntity.lastName = naturalPerson.lastName
|
|
351
|
+
naturalPersonEntity.displayName = naturalPerson.displayName
|
|
352
|
+
naturalPersonEntity.ownerId = naturalPerson.ownerId
|
|
353
|
+
naturalPersonEntity.tenantId = naturalPerson.tenantId
|
|
354
|
+
naturalPersonEntity.metadata = naturalPerson.metadata
|
|
355
|
+
? naturalPerson.metadata.map(contactMetadataItemEntityFrom).filter((entity): entity is ContactMetadataItemEntity => entity !== undefined)
|
|
356
|
+
: []
|
|
357
|
+
|
|
358
|
+
return naturalPersonEntity
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export const naturalPersonFrom = (naturalPerson: NaturalPersonEntity): NaturalPerson => {
|
|
362
|
+
return {
|
|
363
|
+
id: naturalPerson.id,
|
|
364
|
+
firstName: naturalPerson.firstName,
|
|
365
|
+
middleName: naturalPerson.middleName,
|
|
366
|
+
lastName: naturalPerson.lastName,
|
|
367
|
+
displayName: naturalPerson.displayName,
|
|
368
|
+
metadata: naturalPerson.metadata ? naturalPerson.metadata.map((item: ContactMetadataItemEntity) => metadataItemFrom(item)) : [],
|
|
369
|
+
ownerId: naturalPerson.ownerId,
|
|
370
|
+
tenantId: naturalPerson.tenantId,
|
|
371
|
+
createdAt: naturalPerson.createdAt,
|
|
372
|
+
lastUpdatedAt: naturalPerson.lastUpdatedAt,
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export const openIdConfigEntityFrom = (config: NonPersistedOpenIdConfig): OpenIdConfigEntity => {
|
|
377
|
+
const openIdConfig: OpenIdConfigEntity = new OpenIdConfigEntity()
|
|
378
|
+
openIdConfig.clientId = config.clientId
|
|
379
|
+
openIdConfig.clientSecret = config.clientSecret
|
|
380
|
+
openIdConfig.scopes = config.scopes
|
|
381
|
+
openIdConfig.issuer = config.issuer
|
|
382
|
+
openIdConfig.redirectUrl = config.redirectUrl
|
|
383
|
+
openIdConfig.dangerouslyAllowInsecureHttpRequests = config.dangerouslyAllowInsecureHttpRequests
|
|
384
|
+
openIdConfig.clientAuthMethod = config.clientAuthMethod
|
|
385
|
+
openIdConfig.ownerId = config.ownerId
|
|
386
|
+
openIdConfig.tenantId = config.tenantId
|
|
387
|
+
|
|
388
|
+
return openIdConfig
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
export const organizationEntityFrom = (organization: NonPersistedOrganization): OrganizationEntity => {
|
|
392
|
+
const organizationEntity: OrganizationEntity = new OrganizationEntity()
|
|
393
|
+
organizationEntity.legalName = organization.legalName
|
|
394
|
+
organizationEntity.displayName = organization.displayName
|
|
395
|
+
organizationEntity.ownerId = organization.ownerId
|
|
396
|
+
organizationEntity.tenantId = organization.tenantId
|
|
397
|
+
organizationEntity.metadata = organization.metadata
|
|
398
|
+
? organization.metadata.map(contactMetadataItemEntityFrom).filter((entity): entity is ContactMetadataItemEntity => entity !== undefined)
|
|
399
|
+
: []
|
|
400
|
+
|
|
401
|
+
return organizationEntity
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
export const organizationFrom = (organization: OrganizationEntity): Organization => {
|
|
405
|
+
return {
|
|
406
|
+
id: organization.id,
|
|
407
|
+
legalName: organization.legalName,
|
|
408
|
+
displayName: organization.displayName,
|
|
409
|
+
metadata: organization.metadata ? organization.metadata.map((item: ContactMetadataItemEntity) => metadataItemFrom(item)) : [],
|
|
410
|
+
ownerId: organization.ownerId,
|
|
411
|
+
tenantId: organization.tenantId,
|
|
412
|
+
createdAt: organization.createdAt,
|
|
413
|
+
lastUpdatedAt: organization.lastUpdatedAt,
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
export const partyRelationshipEntityFrom = (relationship: NonPersistedPartyRelationship): PartyRelationshipEntity => {
|
|
418
|
+
const partyRelationshipEntity: PartyRelationshipEntity = new PartyRelationshipEntity()
|
|
419
|
+
partyRelationshipEntity.leftId = relationship.leftId
|
|
420
|
+
partyRelationshipEntity.rightId = relationship.rightId
|
|
421
|
+
partyRelationshipEntity.ownerId = relationship.ownerId
|
|
422
|
+
partyRelationshipEntity.tenantId = relationship.tenantId
|
|
423
|
+
return partyRelationshipEntity
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
export const partyRelationshipFrom = (relationship: PartyRelationshipEntity): PartyRelationship => {
|
|
427
|
+
return {
|
|
428
|
+
id: relationship.id,
|
|
429
|
+
leftId: relationship.leftId,
|
|
430
|
+
rightId: relationship.rightId,
|
|
431
|
+
ownerId: relationship.ownerId,
|
|
432
|
+
tenantId: relationship.tenantId,
|
|
433
|
+
createdAt: relationship.createdAt,
|
|
434
|
+
lastUpdatedAt: relationship.lastUpdatedAt,
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
export const partyTypeEntityFrom = (args: NonPersistedPartyType): PartyTypeEntity => {
|
|
439
|
+
const partyTypeEntity: PartyTypeEntity = new PartyTypeEntity()
|
|
440
|
+
if (args.id) {
|
|
441
|
+
partyTypeEntity.id = args.id
|
|
442
|
+
}
|
|
443
|
+
partyTypeEntity.type = args.type
|
|
444
|
+
partyTypeEntity.origin = args.origin
|
|
445
|
+
partyTypeEntity.name = args.name
|
|
446
|
+
partyTypeEntity.description = args.description
|
|
447
|
+
partyTypeEntity.tenantId = args.tenantId
|
|
448
|
+
|
|
449
|
+
return partyTypeEntity
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
export const partyTypeFrom = (partyType: PartyTypeEntity): PartyType => {
|
|
453
|
+
return {
|
|
454
|
+
id: partyType.id,
|
|
455
|
+
type: partyType.type,
|
|
456
|
+
origin: partyType.origin,
|
|
457
|
+
name: partyType.name,
|
|
458
|
+
tenantId: partyType.tenantId,
|
|
459
|
+
description: partyType.description,
|
|
460
|
+
createdAt: partyType.createdAt,
|
|
461
|
+
lastUpdatedAt: partyType.lastUpdatedAt,
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
export const configFrom = (config: BaseConfigEntity): ConnectionConfig => {
|
|
466
|
+
if (isOpenIdConfig(config)) {
|
|
467
|
+
return openIdConfigFrom(<OpenIdConfigEntity>config)
|
|
468
|
+
} else if (isDidAuthConfig(config)) {
|
|
469
|
+
return didAuthConfigFrom(<DidAuthConfigEntity>config)
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
throw new Error('config type not supported')
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
export const openIdConfigFrom = (config: OpenIdConfigEntity): OpenIdConfig => {
|
|
476
|
+
return {
|
|
477
|
+
id: config.id,
|
|
478
|
+
clientId: config.clientId,
|
|
479
|
+
clientSecret: config.clientSecret,
|
|
480
|
+
scopes: config.scopes,
|
|
481
|
+
issuer: config.issuer,
|
|
482
|
+
redirectUrl: config.redirectUrl,
|
|
483
|
+
dangerouslyAllowInsecureHttpRequests: config.dangerouslyAllowInsecureHttpRequests,
|
|
484
|
+
clientAuthMethod: config.clientAuthMethod,
|
|
485
|
+
ownerId: config.ownerId,
|
|
486
|
+
tenantId: config.tenantId,
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
export const didAuthConfigFrom = (config: DidAuthConfigEntity): DidAuthConfig => {
|
|
491
|
+
return {
|
|
492
|
+
id: config.id,
|
|
493
|
+
idOpts: { identifier: config.identifier },
|
|
494
|
+
stateId: '', // FIXME
|
|
495
|
+
redirectUrl: config.redirectUrl,
|
|
496
|
+
sessionId: config.sessionId,
|
|
497
|
+
ownerId: config.ownerId,
|
|
498
|
+
tenantId: config.tenantId,
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
export const isOpenIdConfig = (config: NonPersistedConnectionConfig | BaseConfigEntity): config is OpenIdConfig | OpenIdConfigEntity =>
|
|
503
|
+
'clientSecret' in config && 'issuer' in config && 'redirectUrl' in config
|
|
504
|
+
|
|
505
|
+
export const isDidAuthConfig = (config: NonPersistedConnectionConfig | BaseConfigEntity): config is DidAuthConfig | DidAuthConfigEntity =>
|
|
506
|
+
('identifier' in config || ('idOpts' in config && 'identifier' in config.idOpts)) && 'redirectUrl' in config && 'sessionId' in config
|