@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataSource } from 'typeorm'
|
|
2
|
-
import { DataStoreContactEntities, DataStoreMigrations, PartyOrigin } from '../index'
|
|
2
|
+
import { DataStoreContactEntities, DataStoreMigrations, IdentityOrigin, MetadataItem, MetadataTypes, PartyOrigin } from '../index'
|
|
3
3
|
import { ContactStore } from '../contact/ContactStore'
|
|
4
4
|
import {
|
|
5
5
|
CorrelationIdentifierType,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
GetPhysicalAddressesArgs,
|
|
11
11
|
GetRelationshipsArgs,
|
|
12
12
|
Identity,
|
|
13
|
-
|
|
13
|
+
CredentialRole,
|
|
14
14
|
NaturalPerson,
|
|
15
15
|
NonPersistedElectronicAddress,
|
|
16
16
|
NonPersistedIdentity,
|
|
@@ -49,6 +49,157 @@ describe('Contact store tests', (): void => {
|
|
|
49
49
|
await (await dbConnection).destroy()
|
|
50
50
|
})
|
|
51
51
|
|
|
52
|
+
it('should get party by contact metadata', async (): Promise<void> => {
|
|
53
|
+
const dateOfBirth = new Date(2016, 0, 5)
|
|
54
|
+
const party: NonPersistedParty = {
|
|
55
|
+
uri: 'example.com',
|
|
56
|
+
partyType: {
|
|
57
|
+
type: PartyTypeType.NATURAL_PERSON,
|
|
58
|
+
tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
|
|
59
|
+
name: 'example_name',
|
|
60
|
+
origin: PartyOrigin.EXTERNAL,
|
|
61
|
+
},
|
|
62
|
+
contact: {
|
|
63
|
+
firstName: 'example_first_name',
|
|
64
|
+
middleName: 'example_middle_name',
|
|
65
|
+
lastName: 'example_last_name',
|
|
66
|
+
metadata: [
|
|
67
|
+
{ label: 'grade', value: '5th' },
|
|
68
|
+
{ label: 'dateOfBirth', value: dateOfBirth },
|
|
69
|
+
] as Array<MetadataItem<MetadataTypes>>,
|
|
70
|
+
displayName: 'example_display_name',
|
|
71
|
+
},
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const savedParty: Party = await contactStore.addParty(party)
|
|
75
|
+
expect(savedParty).toBeDefined()
|
|
76
|
+
|
|
77
|
+
const singleResult: Party = await contactStore.getParty({ partyId: savedParty.id })
|
|
78
|
+
expect(singleResult).toBeDefined()
|
|
79
|
+
|
|
80
|
+
const args: GetPartiesArgs = {
|
|
81
|
+
filter: [{ contact: { metadata: { label: 'dateOfBirth', value: dateOfBirth } } }],
|
|
82
|
+
}
|
|
83
|
+
const result: Array<Party> = await contactStore.getParties(args)
|
|
84
|
+
expect(result).toBeDefined()
|
|
85
|
+
expect(result.length).toEqual(1)
|
|
86
|
+
expect(result[0]).toBeDefined()
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it('should get a party by identity metadata', async (): Promise<void> => {
|
|
90
|
+
const party: NonPersistedParty = {
|
|
91
|
+
uri: 'example.com',
|
|
92
|
+
partyType: {
|
|
93
|
+
type: PartyTypeType.NATURAL_PERSON,
|
|
94
|
+
tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
|
|
95
|
+
name: 'example_name',
|
|
96
|
+
origin: PartyOrigin.EXTERNAL,
|
|
97
|
+
},
|
|
98
|
+
contact: {
|
|
99
|
+
firstName: 'example_first_name',
|
|
100
|
+
middleName: 'example_middle_name',
|
|
101
|
+
lastName: 'example_last_name',
|
|
102
|
+
displayName: 'example_display_name',
|
|
103
|
+
},
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const savedParty: Party = await contactStore.addParty(party)
|
|
107
|
+
expect(savedParty).toBeDefined()
|
|
108
|
+
|
|
109
|
+
const identity: NonPersistedIdentity = {
|
|
110
|
+
alias: 'test_alias',
|
|
111
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
112
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
113
|
+
identifier: {
|
|
114
|
+
type: CorrelationIdentifierType.DID,
|
|
115
|
+
correlationId: 'example_did',
|
|
116
|
+
},
|
|
117
|
+
metadata: [
|
|
118
|
+
{
|
|
119
|
+
label: 'label1',
|
|
120
|
+
value: 'example_value',
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
label: 'label2',
|
|
124
|
+
value: 'example_value',
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
}
|
|
128
|
+
const savedIdentity: Identity = await contactStore.addIdentity({ partyId: savedParty.id, identity: identity })
|
|
129
|
+
expect(savedIdentity).toBeDefined()
|
|
130
|
+
|
|
131
|
+
const args: GetPartiesArgs = {
|
|
132
|
+
filter: [{ identities: { metadata: { label: 'label1', value: 'example_value' } } }],
|
|
133
|
+
}
|
|
134
|
+
const result: Array<Party> = await contactStore.getParties(args)
|
|
135
|
+
expect(result).toBeDefined()
|
|
136
|
+
expect(result.length).toEqual(1)
|
|
137
|
+
expect(result[0]).toBeDefined()
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
it('should get party by both contact and identity metadata', async (): Promise<void> => {
|
|
141
|
+
const example_date = new Date(2016, 0, 5)
|
|
142
|
+
const party: NonPersistedParty = {
|
|
143
|
+
uri: 'example.com',
|
|
144
|
+
partyType: {
|
|
145
|
+
type: PartyTypeType.NATURAL_PERSON,
|
|
146
|
+
tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
|
|
147
|
+
name: 'example_name',
|
|
148
|
+
origin: PartyOrigin.EXTERNAL,
|
|
149
|
+
},
|
|
150
|
+
contact: {
|
|
151
|
+
firstName: 'example_first_name',
|
|
152
|
+
middleName: 'example_middle_name',
|
|
153
|
+
lastName: 'example_last_name',
|
|
154
|
+
displayName: 'example_display_name',
|
|
155
|
+
metadata: [
|
|
156
|
+
{ label: 'label1', value: 'example_value' },
|
|
157
|
+
{ label: 'label2', value: example_date },
|
|
158
|
+
] as Array<MetadataItem<MetadataTypes>>,
|
|
159
|
+
},
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const savedParty: Party = await contactStore.addParty(party)
|
|
163
|
+
expect(savedParty).toBeDefined()
|
|
164
|
+
|
|
165
|
+
const identity: NonPersistedIdentity = {
|
|
166
|
+
alias: 'test_alias',
|
|
167
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
168
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
169
|
+
identifier: {
|
|
170
|
+
type: CorrelationIdentifierType.DID,
|
|
171
|
+
correlationId: 'example_did',
|
|
172
|
+
},
|
|
173
|
+
metadata: [
|
|
174
|
+
{
|
|
175
|
+
label: 'label3',
|
|
176
|
+
value: 'example_value',
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
label: 'label4',
|
|
180
|
+
value: 'example_value',
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
}
|
|
184
|
+
const savedIdentity: Identity = await contactStore.addIdentity({ partyId: savedParty.id, identity: identity })
|
|
185
|
+
expect(savedIdentity).toBeDefined()
|
|
186
|
+
|
|
187
|
+
const args: GetPartiesArgs = {
|
|
188
|
+
filter: [
|
|
189
|
+
{
|
|
190
|
+
contact: { metadata: { label: 'label2', value: example_date } },
|
|
191
|
+
identities: { metadata: { label: 'label3', value: 'example_value' } },
|
|
192
|
+
},
|
|
193
|
+
],
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const result: Array<Party> = await contactStore.getParties(args)
|
|
197
|
+
|
|
198
|
+
expect(result).toBeDefined()
|
|
199
|
+
expect(result.length).toEqual(1)
|
|
200
|
+
expect(result[0]).toBeDefined()
|
|
201
|
+
})
|
|
202
|
+
|
|
52
203
|
it('should get party by id', async (): Promise<void> => {
|
|
53
204
|
const party: NonPersistedParty = {
|
|
54
205
|
uri: 'example.com',
|
|
@@ -189,7 +340,8 @@ describe('Contact store tests', (): void => {
|
|
|
189
340
|
identities: [
|
|
190
341
|
{
|
|
191
342
|
alias: 'test_alias1',
|
|
192
|
-
|
|
343
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
344
|
+
roles: [CredentialRole.ISSUER],
|
|
193
345
|
identifier: {
|
|
194
346
|
type: CorrelationIdentifierType.DID,
|
|
195
347
|
correlationId: 'example_did1',
|
|
@@ -197,7 +349,8 @@ describe('Contact store tests', (): void => {
|
|
|
197
349
|
},
|
|
198
350
|
{
|
|
199
351
|
alias: 'test_alias2',
|
|
200
|
-
|
|
352
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
353
|
+
roles: [CredentialRole.VERIFIER],
|
|
201
354
|
identifier: {
|
|
202
355
|
type: CorrelationIdentifierType.DID,
|
|
203
356
|
correlationId: 'example_did2',
|
|
@@ -205,7 +358,8 @@ describe('Contact store tests', (): void => {
|
|
|
205
358
|
},
|
|
206
359
|
{
|
|
207
360
|
alias: 'test_alias3',
|
|
208
|
-
|
|
361
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
362
|
+
roles: [CredentialRole.HOLDER],
|
|
209
363
|
identifier: {
|
|
210
364
|
type: CorrelationIdentifierType.DID,
|
|
211
365
|
correlationId: 'example_did3',
|
|
@@ -413,7 +567,8 @@ describe('Contact store tests', (): void => {
|
|
|
413
567
|
identities: [
|
|
414
568
|
{
|
|
415
569
|
alias: 'test_alias1',
|
|
416
|
-
|
|
570
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
571
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
417
572
|
identifier: {
|
|
418
573
|
type: CorrelationIdentifierType.DID,
|
|
419
574
|
correlationId: 'example_did1',
|
|
@@ -421,7 +576,8 @@ describe('Contact store tests', (): void => {
|
|
|
421
576
|
},
|
|
422
577
|
{
|
|
423
578
|
alias: 'test_alias2',
|
|
424
|
-
|
|
579
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
580
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
425
581
|
identifier: {
|
|
426
582
|
type: CorrelationIdentifierType.DID,
|
|
427
583
|
correlationId: 'example_did2',
|
|
@@ -457,7 +613,8 @@ describe('Contact store tests', (): void => {
|
|
|
457
613
|
identities: [
|
|
458
614
|
{
|
|
459
615
|
alias: 'test_alias1',
|
|
460
|
-
|
|
616
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
617
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
461
618
|
identifier: {
|
|
462
619
|
type: CorrelationIdentifierType.URL,
|
|
463
620
|
correlationId: 'example_did1',
|
|
@@ -465,7 +622,8 @@ describe('Contact store tests', (): void => {
|
|
|
465
622
|
},
|
|
466
623
|
{
|
|
467
624
|
alias: 'test_alias2',
|
|
468
|
-
|
|
625
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
626
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
469
627
|
identifier: {
|
|
470
628
|
type: CorrelationIdentifierType.DID,
|
|
471
629
|
correlationId: 'example_did2',
|
|
@@ -498,7 +656,8 @@ describe('Contact store tests', (): void => {
|
|
|
498
656
|
|
|
499
657
|
const identity1: NonPersistedIdentity = {
|
|
500
658
|
alias: 'test_alias1',
|
|
501
|
-
|
|
659
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
660
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
502
661
|
identifier: {
|
|
503
662
|
type: CorrelationIdentifierType.DID,
|
|
504
663
|
correlationId: 'example_did1',
|
|
@@ -509,7 +668,8 @@ describe('Contact store tests', (): void => {
|
|
|
509
668
|
|
|
510
669
|
const identity2: NonPersistedIdentity = {
|
|
511
670
|
alias: 'test_alias2',
|
|
512
|
-
|
|
671
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
672
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
513
673
|
identifier: {
|
|
514
674
|
type: CorrelationIdentifierType.DID,
|
|
515
675
|
correlationId: 'example_did2',
|
|
@@ -589,7 +749,8 @@ describe('Contact store tests', (): void => {
|
|
|
589
749
|
|
|
590
750
|
const identity: NonPersistedIdentity = {
|
|
591
751
|
alias: 'test_alias',
|
|
592
|
-
|
|
752
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
753
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
593
754
|
identifier: {
|
|
594
755
|
type: CorrelationIdentifierType.DID,
|
|
595
756
|
correlationId: 'example_did',
|
|
@@ -624,7 +785,8 @@ describe('Contact store tests', (): void => {
|
|
|
624
785
|
|
|
625
786
|
const identity: NonPersistedIdentity = {
|
|
626
787
|
alias: 'test_alias',
|
|
627
|
-
|
|
788
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
789
|
+
roles: [CredentialRole.HOLDER],
|
|
628
790
|
identifier: {
|
|
629
791
|
type: CorrelationIdentifierType.DID,
|
|
630
792
|
correlationId: 'example_did',
|
|
@@ -665,7 +827,8 @@ describe('Contact store tests', (): void => {
|
|
|
665
827
|
|
|
666
828
|
const identity1: NonPersistedIdentity = {
|
|
667
829
|
alias: 'test_alias1',
|
|
668
|
-
|
|
830
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
831
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
669
832
|
identifier: {
|
|
670
833
|
type: CorrelationIdentifierType.DID,
|
|
671
834
|
correlationId: 'example_did1',
|
|
@@ -676,7 +839,8 @@ describe('Contact store tests', (): void => {
|
|
|
676
839
|
|
|
677
840
|
const identity2: NonPersistedIdentity = {
|
|
678
841
|
alias: 'test_alias2',
|
|
679
|
-
|
|
842
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
843
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
680
844
|
identifier: {
|
|
681
845
|
type: CorrelationIdentifierType.DID,
|
|
682
846
|
correlationId: 'example_did2',
|
|
@@ -715,7 +879,8 @@ describe('Contact store tests', (): void => {
|
|
|
715
879
|
|
|
716
880
|
const identity1: NonPersistedIdentity = {
|
|
717
881
|
alias: 'test_alias1',
|
|
718
|
-
|
|
882
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
883
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
719
884
|
identifier: {
|
|
720
885
|
type: CorrelationIdentifierType.DID,
|
|
721
886
|
correlationId: 'example_did1',
|
|
@@ -726,7 +891,8 @@ describe('Contact store tests', (): void => {
|
|
|
726
891
|
|
|
727
892
|
const identity2: NonPersistedIdentity = {
|
|
728
893
|
alias: 'test_alias2',
|
|
729
|
-
|
|
894
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
895
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
730
896
|
identifier: {
|
|
731
897
|
type: CorrelationIdentifierType.DID,
|
|
732
898
|
correlationId: 'example_did2',
|
|
@@ -762,7 +928,8 @@ describe('Contact store tests', (): void => {
|
|
|
762
928
|
const alias = 'test_alias1'
|
|
763
929
|
const identity1: NonPersistedIdentity = {
|
|
764
930
|
alias,
|
|
765
|
-
|
|
931
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
932
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
766
933
|
identifier: {
|
|
767
934
|
type: CorrelationIdentifierType.DID,
|
|
768
935
|
correlationId: 'example_did1',
|
|
@@ -773,7 +940,8 @@ describe('Contact store tests', (): void => {
|
|
|
773
940
|
|
|
774
941
|
const identity2: NonPersistedIdentity = {
|
|
775
942
|
alias: 'test_alias2',
|
|
776
|
-
|
|
943
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
944
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
777
945
|
identifier: {
|
|
778
946
|
type: CorrelationIdentifierType.DID,
|
|
779
947
|
correlationId: 'example_did2',
|
|
@@ -813,7 +981,8 @@ describe('Contact store tests', (): void => {
|
|
|
813
981
|
const alias = 'test_alias1'
|
|
814
982
|
const identity1: NonPersistedIdentity = {
|
|
815
983
|
alias,
|
|
816
|
-
|
|
984
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
985
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
817
986
|
identifier: {
|
|
818
987
|
type: CorrelationIdentifierType.DID,
|
|
819
988
|
correlationId: 'example_did1',
|
|
@@ -833,7 +1002,7 @@ describe('Contact store tests', (): void => {
|
|
|
833
1002
|
expect(savedIdentity1).toBeDefined()
|
|
834
1003
|
|
|
835
1004
|
const args: GetIdentitiesArgs = {
|
|
836
|
-
filter: [{ metadata: { label: 'label1' } }],
|
|
1005
|
+
filter: [{ metadata: { label: 'label1', value: 'example_value' } }],
|
|
837
1006
|
}
|
|
838
1007
|
|
|
839
1008
|
const result: Array<Identity> = await contactStore.getIdentities(args)
|
|
@@ -863,7 +1032,8 @@ describe('Contact store tests', (): void => {
|
|
|
863
1032
|
|
|
864
1033
|
const identity: NonPersistedIdentity = {
|
|
865
1034
|
alias: 'test_alias',
|
|
866
|
-
|
|
1035
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
1036
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
867
1037
|
identifier: {
|
|
868
1038
|
type: CorrelationIdentifierType.DID,
|
|
869
1039
|
correlationId: 'example_did',
|
|
@@ -904,7 +1074,8 @@ describe('Contact store tests', (): void => {
|
|
|
904
1074
|
const correlationId = 'missing_connection_example'
|
|
905
1075
|
const identity: NonPersistedIdentity = {
|
|
906
1076
|
alias: correlationId,
|
|
907
|
-
|
|
1077
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
1078
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
908
1079
|
identifier: {
|
|
909
1080
|
type: CorrelationIdentifierType.URL,
|
|
910
1081
|
correlationId,
|
|
@@ -938,7 +1109,8 @@ describe('Contact store tests', (): void => {
|
|
|
938
1109
|
const correlationId = 'missing_connection_example'
|
|
939
1110
|
const identity: NonPersistedIdentity = {
|
|
940
1111
|
alias: correlationId,
|
|
941
|
-
|
|
1112
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
1113
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER, CredentialRole.HOLDER],
|
|
942
1114
|
identifier: {
|
|
943
1115
|
type: CorrelationIdentifierType.DID,
|
|
944
1116
|
correlationId,
|
|
@@ -973,7 +1145,8 @@ describe('Contact store tests', (): void => {
|
|
|
973
1145
|
|
|
974
1146
|
const identity: NonPersistedIdentity = {
|
|
975
1147
|
alias: 'example_did',
|
|
976
|
-
|
|
1148
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
1149
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
977
1150
|
identifier: {
|
|
978
1151
|
type: CorrelationIdentifierType.DID,
|
|
979
1152
|
correlationId: 'example_did',
|
|
@@ -1008,7 +1181,8 @@ describe('Contact store tests', (): void => {
|
|
|
1008
1181
|
identities: [
|
|
1009
1182
|
{
|
|
1010
1183
|
alias: 'test_alias1',
|
|
1011
|
-
|
|
1184
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
1185
|
+
roles: [CredentialRole.VERIFIER],
|
|
1012
1186
|
identifier: {
|
|
1013
1187
|
type: CorrelationIdentifierType.DID,
|
|
1014
1188
|
correlationId: 'example_did1',
|
|
@@ -1016,7 +1190,8 @@ describe('Contact store tests', (): void => {
|
|
|
1016
1190
|
},
|
|
1017
1191
|
{
|
|
1018
1192
|
alias: 'test_alias2',
|
|
1019
|
-
|
|
1193
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
1194
|
+
roles: [CredentialRole.ISSUER],
|
|
1020
1195
|
identifier: {
|
|
1021
1196
|
type: CorrelationIdentifierType.DID,
|
|
1022
1197
|
correlationId: 'example_did2',
|
|
@@ -1024,7 +1199,8 @@ describe('Contact store tests', (): void => {
|
|
|
1024
1199
|
},
|
|
1025
1200
|
{
|
|
1026
1201
|
alias: 'test_alias3',
|
|
1027
|
-
|
|
1202
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
1203
|
+
roles: [CredentialRole.HOLDER],
|
|
1028
1204
|
identifier: {
|
|
1029
1205
|
type: CorrelationIdentifierType.DID,
|
|
1030
1206
|
correlationId: 'example_did3',
|
|
@@ -1038,7 +1214,7 @@ describe('Contact store tests', (): void => {
|
|
|
1038
1214
|
|
|
1039
1215
|
expect(result.roles).toBeDefined()
|
|
1040
1216
|
expect(result.roles.length).toEqual(3)
|
|
1041
|
-
expect(result.roles).toEqual([
|
|
1217
|
+
expect(result.roles).toEqual([CredentialRole.VERIFIER, CredentialRole.ISSUER, CredentialRole.HOLDER])
|
|
1042
1218
|
})
|
|
1043
1219
|
|
|
1044
1220
|
it('should add relationship', async (): Promise<void> => {
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { DataSource } from 'typeorm'
|
|
2
|
+
import { PresentationDefinitionItemEntity } from '../entities/presentationDefinition/PresentationDefinitionItemEntity'
|
|
3
|
+
import { DataStorePresentationDefinitionMigrations } from '../migrations'
|
|
4
|
+
import { DataStorePresentationDefinitionEntities } from '../index'
|
|
5
|
+
|
|
6
|
+
describe('PresentationDefinitionItemEntity tests', (): void => {
|
|
7
|
+
let dbConnection: DataSource
|
|
8
|
+
|
|
9
|
+
beforeEach(async (): Promise<void> => {
|
|
10
|
+
dbConnection = await new DataSource({
|
|
11
|
+
type: 'sqlite',
|
|
12
|
+
database: ':memory:',
|
|
13
|
+
logging: ['info'],
|
|
14
|
+
synchronize: true,
|
|
15
|
+
migrationsRun: false,
|
|
16
|
+
migrations: DataStorePresentationDefinitionMigrations,
|
|
17
|
+
entities: DataStorePresentationDefinitionEntities,
|
|
18
|
+
}).initialize()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
afterEach(async (): Promise<void> => {
|
|
22
|
+
await dbConnection.destroy()
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('should create and retrieve PresentationDefinitionItemEntity', async (): Promise<void> => {
|
|
26
|
+
const repository = dbConnection.getRepository(PresentationDefinitionItemEntity)
|
|
27
|
+
const entity = new PresentationDefinitionItemEntity()
|
|
28
|
+
entity.definitionId = 'definition1'
|
|
29
|
+
entity.version = '1.0'
|
|
30
|
+
entity.definitionPayload = JSON.stringify({ id: 'definition1', input_descriptors: [] })
|
|
31
|
+
|
|
32
|
+
const savedEntity = await repository.save(entity)
|
|
33
|
+
expect(savedEntity).toBeDefined()
|
|
34
|
+
expect(savedEntity.id).toBeDefined()
|
|
35
|
+
|
|
36
|
+
const retrievedEntity = await repository.findOneBy({ id: savedEntity.id })
|
|
37
|
+
expect(retrievedEntity).toBeDefined()
|
|
38
|
+
expect(retrievedEntity!.definitionId).toEqual('definition1')
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('should update PresentationDefinitionItemEntity', async (): Promise<void> => {
|
|
42
|
+
const repository = dbConnection.getRepository(PresentationDefinitionItemEntity)
|
|
43
|
+
const entity = new PresentationDefinitionItemEntity()
|
|
44
|
+
entity.definitionId = 'definition1'
|
|
45
|
+
entity.version = '1.0'
|
|
46
|
+
entity.definitionPayload = JSON.stringify({ id: 'definition1', input_descriptors: [] })
|
|
47
|
+
|
|
48
|
+
const savedEntity = await repository.save(entity)
|
|
49
|
+
expect(savedEntity).toBeDefined()
|
|
50
|
+
|
|
51
|
+
savedEntity.version = '1.1'
|
|
52
|
+
const updatedEntity = await repository.save(savedEntity)
|
|
53
|
+
expect(updatedEntity).toBeDefined()
|
|
54
|
+
expect(updatedEntity.version).toEqual('1.1')
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('should delete PresentationDefinitionItemEntity', async (): Promise<void> => {
|
|
58
|
+
const repository = dbConnection.getRepository(PresentationDefinitionItemEntity)
|
|
59
|
+
const entity = new PresentationDefinitionItemEntity()
|
|
60
|
+
entity.definitionId = 'definition1'
|
|
61
|
+
entity.version = '1.0'
|
|
62
|
+
entity.definitionPayload = JSON.stringify({ id: 'definition1', input_descriptors: [] })
|
|
63
|
+
|
|
64
|
+
const savedEntity = await repository.save(entity)
|
|
65
|
+
expect(savedEntity).toBeDefined()
|
|
66
|
+
|
|
67
|
+
await repository.delete(savedEntity.id)
|
|
68
|
+
const retrievedEntity = await repository.findOneBy({ id: savedEntity.id })
|
|
69
|
+
expect(retrievedEntity).toBeNull()
|
|
70
|
+
})
|
|
71
|
+
})
|