@sphereon/ssi-sdk.data-store 0.24.0 → 0.24.1-next.98
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 +8 -0
- 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 +6 -0
- 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,15 @@
|
|
|
1
1
|
import { DataSource, FindOptionsWhere } from 'typeorm'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
contactMetadataItemEntityFrom,
|
|
4
|
+
DataStoreContactEntities,
|
|
5
|
+
DataStoreMigrations,
|
|
6
|
+
identityMetadataItemEntityFrom,
|
|
7
|
+
IdentityOrigin,
|
|
8
|
+
CredentialRole,
|
|
9
|
+
MetadataTypes,
|
|
10
|
+
PartyOrigin,
|
|
11
|
+
partyTypeFrom,
|
|
12
|
+
} from '../index'
|
|
3
13
|
import { BaseContactEntity } from '../entities/contact/BaseContactEntity'
|
|
4
14
|
import { ConnectionEntity } from '../entities/contact/ConnectionEntity'
|
|
5
15
|
import { CorrelationIdentifierEntity } from '../entities/contact/CorrelationIdentifierEntity'
|
|
@@ -17,7 +27,6 @@ import { PhysicalAddressEntity } from '../entities/contact/PhysicalAddressEntity
|
|
|
17
27
|
import {
|
|
18
28
|
ConnectionType,
|
|
19
29
|
CorrelationIdentifierType,
|
|
20
|
-
IdentityRole,
|
|
21
30
|
NaturalPerson,
|
|
22
31
|
NonPersistedConnection,
|
|
23
32
|
NonPersistedDidAuthConfig,
|
|
@@ -45,6 +54,7 @@ import {
|
|
|
45
54
|
partyTypeEntityFrom,
|
|
46
55
|
physicalAddressEntityFrom,
|
|
47
56
|
} from '../utils/contact/MappingUtils'
|
|
57
|
+
import { ContactMetadataItemEntity } from '../entities/contact/ContactMetadataItemEntity'
|
|
48
58
|
|
|
49
59
|
// TODO write test adding two contacts reusing the same contactType
|
|
50
60
|
|
|
@@ -412,7 +422,8 @@ describe('Database entities tests', (): void => {
|
|
|
412
422
|
const alias = 'non_unique_alias'
|
|
413
423
|
const identity1: NonPersistedIdentity = {
|
|
414
424
|
alias,
|
|
415
|
-
|
|
425
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
426
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
416
427
|
identifier: {
|
|
417
428
|
type: CorrelationIdentifierType.DID,
|
|
418
429
|
correlationId: 'unique_correlationId1',
|
|
@@ -423,7 +434,8 @@ describe('Database entities tests', (): void => {
|
|
|
423
434
|
|
|
424
435
|
const identity2: NonPersistedIdentity = {
|
|
425
436
|
alias: alias,
|
|
426
|
-
|
|
437
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
438
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
427
439
|
identifier: {
|
|
428
440
|
type: CorrelationIdentifierType.DID,
|
|
429
441
|
correlationId: 'unique_correlationId2',
|
|
@@ -439,7 +451,8 @@ describe('Database entities tests', (): void => {
|
|
|
439
451
|
const correlationId = 'non_unique_correlationId'
|
|
440
452
|
const identity1: NonPersistedIdentity = {
|
|
441
453
|
alias: 'unique_alias1',
|
|
442
|
-
|
|
454
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
455
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
443
456
|
identifier: {
|
|
444
457
|
type: CorrelationIdentifierType.DID,
|
|
445
458
|
correlationId,
|
|
@@ -450,7 +463,8 @@ describe('Database entities tests', (): void => {
|
|
|
450
463
|
|
|
451
464
|
const identity2: NonPersistedIdentity = {
|
|
452
465
|
alias: 'unique_alias2',
|
|
453
|
-
|
|
466
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
467
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
454
468
|
identifier: {
|
|
455
469
|
type: CorrelationIdentifierType.DID,
|
|
456
470
|
correlationId,
|
|
@@ -466,7 +480,8 @@ describe('Database entities tests', (): void => {
|
|
|
466
480
|
const correlationId = 'example_did'
|
|
467
481
|
const identity: NonPersistedIdentity = {
|
|
468
482
|
alias: correlationId,
|
|
469
|
-
|
|
483
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
484
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
470
485
|
identifier: {
|
|
471
486
|
type: CorrelationIdentifierType.DID,
|
|
472
487
|
correlationId,
|
|
@@ -495,7 +510,8 @@ describe('Database entities tests', (): void => {
|
|
|
495
510
|
it('should throw error when saving identity with blank alias', async (): Promise<void> => {
|
|
496
511
|
const identity: NonPersistedIdentity = {
|
|
497
512
|
alias: '',
|
|
498
|
-
|
|
513
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
514
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
499
515
|
identifier: {
|
|
500
516
|
type: CorrelationIdentifierType.DID,
|
|
501
517
|
correlationId: 'example_did',
|
|
@@ -510,7 +526,8 @@ describe('Database entities tests', (): void => {
|
|
|
510
526
|
it('should throw error when saving identity with blank correlation id', async (): Promise<void> => {
|
|
511
527
|
const identity: NonPersistedIdentity = {
|
|
512
528
|
alias: 'example_did',
|
|
513
|
-
|
|
529
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
530
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
514
531
|
identifier: {
|
|
515
532
|
type: CorrelationIdentifierType.DID,
|
|
516
533
|
correlationId: '',
|
|
@@ -526,7 +543,8 @@ describe('Database entities tests', (): void => {
|
|
|
526
543
|
const correlationId = 'example_did'
|
|
527
544
|
const identity: NonPersistedIdentity = {
|
|
528
545
|
alias: correlationId,
|
|
529
|
-
|
|
546
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
547
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
530
548
|
identifier: {
|
|
531
549
|
type: CorrelationIdentifierType.DID,
|
|
532
550
|
correlationId,
|
|
@@ -544,33 +562,12 @@ describe('Database entities tests', (): void => {
|
|
|
544
562
|
await expect(dbConnection.getRepository(IdentityEntity).save(identityEntity)).rejects.toThrowError('Blank metadata labels are not allowed')
|
|
545
563
|
})
|
|
546
564
|
|
|
547
|
-
it('should throw error when saving identity with blank metadata value', async (): Promise<void> => {
|
|
548
|
-
const correlationId = 'example_did'
|
|
549
|
-
const identity: NonPersistedIdentity = {
|
|
550
|
-
alias: correlationId,
|
|
551
|
-
roles: [IdentityRole.ISSUER, IdentityRole.VERIFIER],
|
|
552
|
-
identifier: {
|
|
553
|
-
type: CorrelationIdentifierType.DID,
|
|
554
|
-
correlationId,
|
|
555
|
-
},
|
|
556
|
-
metadata: [
|
|
557
|
-
{
|
|
558
|
-
label: 'example_label',
|
|
559
|
-
value: '',
|
|
560
|
-
},
|
|
561
|
-
],
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
const identityEntity: IdentityEntity = identityEntityFrom(identity)
|
|
565
|
-
|
|
566
|
-
await expect(dbConnection.getRepository(IdentityEntity).save(identityEntity)).rejects.toThrowError('Blank metadata values are not allowed')
|
|
567
|
-
})
|
|
568
|
-
|
|
569
565
|
it('Should save identity with openid connection to database', async (): Promise<void> => {
|
|
570
566
|
const correlationId = 'example.com'
|
|
571
567
|
const identity: NonPersistedIdentity = {
|
|
572
568
|
alias: correlationId,
|
|
573
|
-
|
|
569
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
570
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
574
571
|
identifier: {
|
|
575
572
|
type: CorrelationIdentifierType.URL,
|
|
576
573
|
correlationId,
|
|
@@ -615,7 +612,8 @@ describe('Database entities tests', (): void => {
|
|
|
615
612
|
const correlationId = 'example.com'
|
|
616
613
|
const identity: NonPersistedIdentity = {
|
|
617
614
|
alias: correlationId,
|
|
618
|
-
|
|
615
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
616
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
619
617
|
identifier: {
|
|
620
618
|
type: CorrelationIdentifierType.URL,
|
|
621
619
|
correlationId,
|
|
@@ -828,7 +826,8 @@ describe('Database entities tests', (): void => {
|
|
|
828
826
|
const correlationId = 'relation_example.com'
|
|
829
827
|
const identity: NonPersistedIdentity = {
|
|
830
828
|
alias: correlationId,
|
|
831
|
-
|
|
829
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
830
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
832
831
|
identifier: {
|
|
833
832
|
type: CorrelationIdentifierType.URL,
|
|
834
833
|
correlationId,
|
|
@@ -988,7 +987,8 @@ describe('Database entities tests', (): void => {
|
|
|
988
987
|
const correlationId = 'relation_example.com'
|
|
989
988
|
const identity: NonPersistedIdentity = {
|
|
990
989
|
alias: correlationId,
|
|
991
|
-
|
|
990
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
991
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
992
992
|
identifier: {
|
|
993
993
|
type: CorrelationIdentifierType.URL,
|
|
994
994
|
correlationId,
|
|
@@ -1089,7 +1089,8 @@ describe('Database entities tests', (): void => {
|
|
|
1089
1089
|
const correlationId = 'relation_example.com'
|
|
1090
1090
|
const identity: NonPersistedIdentity = {
|
|
1091
1091
|
alias: correlationId,
|
|
1092
|
-
|
|
1092
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
1093
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
1093
1094
|
identifier: {
|
|
1094
1095
|
type: CorrelationIdentifierType.URL,
|
|
1095
1096
|
correlationId,
|
|
@@ -1212,7 +1213,8 @@ describe('Database entities tests', (): void => {
|
|
|
1212
1213
|
const correlationId = 'example_did'
|
|
1213
1214
|
const identity: NonPersistedIdentity = {
|
|
1214
1215
|
alias: correlationId,
|
|
1215
|
-
|
|
1216
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
1217
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
1216
1218
|
identifier: {
|
|
1217
1219
|
type: CorrelationIdentifierType.DID,
|
|
1218
1220
|
correlationId,
|
|
@@ -1238,7 +1240,8 @@ describe('Database entities tests', (): void => {
|
|
|
1238
1240
|
const correlationId = 'example_did'
|
|
1239
1241
|
const identity: NonPersistedIdentity = {
|
|
1240
1242
|
alias: correlationId,
|
|
1241
|
-
|
|
1243
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
1244
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
1242
1245
|
identifier: {
|
|
1243
1246
|
type: CorrelationIdentifierType.DID,
|
|
1244
1247
|
correlationId,
|
|
@@ -1379,7 +1382,8 @@ describe('Database entities tests', (): void => {
|
|
|
1379
1382
|
const correlationId = 'example_did'
|
|
1380
1383
|
const identity: NonPersistedIdentity = {
|
|
1381
1384
|
alias: correlationId,
|
|
1382
|
-
|
|
1385
|
+
origin: IdentityOrigin.EXTERNAL,
|
|
1386
|
+
roles: [CredentialRole.ISSUER, CredentialRole.VERIFIER],
|
|
1383
1387
|
identifier: {
|
|
1384
1388
|
type: CorrelationIdentifierType.DID,
|
|
1385
1389
|
correlationId,
|
|
@@ -1403,12 +1407,11 @@ describe('Database entities tests', (): void => {
|
|
|
1403
1407
|
|
|
1404
1408
|
it('Should enforce unique type and tenant id combination when saving party type', async (): Promise<void> => {
|
|
1405
1409
|
const tenantId = 'non_unique_value'
|
|
1406
|
-
const name = 'non_unique_value'
|
|
1407
1410
|
const partyType1: NonPersistedPartyType = {
|
|
1408
1411
|
type: PartyTypeType.NATURAL_PERSON,
|
|
1409
1412
|
origin: PartyOrigin.EXTERNAL,
|
|
1410
1413
|
tenantId,
|
|
1411
|
-
name,
|
|
1414
|
+
name: 'example_party_type_name1',
|
|
1412
1415
|
}
|
|
1413
1416
|
|
|
1414
1417
|
const partyTypeEntity1: PartyTypeEntity = partyTypeEntityFrom(partyType1)
|
|
@@ -1420,7 +1423,7 @@ describe('Database entities tests', (): void => {
|
|
|
1420
1423
|
type: PartyTypeType.NATURAL_PERSON,
|
|
1421
1424
|
origin: PartyOrigin.INTERNAL,
|
|
1422
1425
|
tenantId,
|
|
1423
|
-
name,
|
|
1426
|
+
name: 'example_party_type_name2',
|
|
1424
1427
|
}
|
|
1425
1428
|
|
|
1426
1429
|
const partyTypeEntity2: PartyTypeEntity = partyTypeEntityFrom(partyType2)
|
|
@@ -2198,7 +2201,7 @@ describe('Database entities tests', (): void => {
|
|
|
2198
2201
|
|
|
2199
2202
|
const party: NonPersistedParty = {
|
|
2200
2203
|
uri: 'example.com',
|
|
2201
|
-
partyType: savedPartyType,
|
|
2204
|
+
partyType: partyTypeFrom(savedPartyType),
|
|
2202
2205
|
contact: {
|
|
2203
2206
|
firstName: 'example_first_name',
|
|
2204
2207
|
middleName: 'example_middle_name',
|
|
@@ -2539,4 +2542,86 @@ describe('Database entities tests', (): void => {
|
|
|
2539
2542
|
'Blank country codes are not allowed',
|
|
2540
2543
|
)
|
|
2541
2544
|
})
|
|
2545
|
+
|
|
2546
|
+
it('Should save identity metadata item to database', async (): Promise<void> => {
|
|
2547
|
+
const metadataItem = {
|
|
2548
|
+
label: 'example_label',
|
|
2549
|
+
value: 'example_value',
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2552
|
+
const identityMetadataItemEntity = identityMetadataItemEntityFrom(metadataItem)
|
|
2553
|
+
|
|
2554
|
+
await dbConnection.getRepository(IdentityMetadataItemEntity).save(identityMetadataItemEntity!)
|
|
2555
|
+
|
|
2556
|
+
const fromDb = await dbConnection.getRepository(IdentityMetadataItemEntity).findOne({
|
|
2557
|
+
where: { label: metadataItem.label },
|
|
2558
|
+
})
|
|
2559
|
+
|
|
2560
|
+
expect(fromDb).toBeDefined()
|
|
2561
|
+
expect(fromDb?.label).toEqual(metadataItem.label)
|
|
2562
|
+
expect(fromDb?.stringValue).toEqual(metadataItem.value)
|
|
2563
|
+
})
|
|
2564
|
+
|
|
2565
|
+
it('Should throw error when saving identity metadata item with blank label', async (): Promise<void> => {
|
|
2566
|
+
const metadataItem = {
|
|
2567
|
+
label: '',
|
|
2568
|
+
value: 'example_value',
|
|
2569
|
+
}
|
|
2570
|
+
|
|
2571
|
+
const identityMetadataItemEntity = identityMetadataItemEntityFrom(metadataItem)
|
|
2572
|
+
|
|
2573
|
+
await expect(dbConnection.getRepository(IdentityMetadataItemEntity).save(identityMetadataItemEntity!)).rejects.toThrowError(
|
|
2574
|
+
'Blank metadata labels are not allowed',
|
|
2575
|
+
)
|
|
2576
|
+
})
|
|
2577
|
+
|
|
2578
|
+
it('Should throw error when saving identity metadata item with unsupported object type', async (): Promise<void> => {
|
|
2579
|
+
const metadataItem = {
|
|
2580
|
+
label: 'example_label',
|
|
2581
|
+
value: { unsupported: 'object' } as unknown as MetadataTypes, // Force not to have MetadataTypes
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
expect(() => identityMetadataItemEntityFrom(metadataItem)).toThrowError('Unsupported object type: Object for value [object Object]')
|
|
2585
|
+
})
|
|
2586
|
+
|
|
2587
|
+
it('Should save contact metadata item to database', async (): Promise<void> => {
|
|
2588
|
+
const metadataItem = {
|
|
2589
|
+
label: 'example_label',
|
|
2590
|
+
value: 'example_value',
|
|
2591
|
+
}
|
|
2592
|
+
|
|
2593
|
+
const contactMetadataItemEntity = contactMetadataItemEntityFrom(metadataItem)
|
|
2594
|
+
|
|
2595
|
+
await dbConnection.getRepository(ContactMetadataItemEntity).save(contactMetadataItemEntity!)
|
|
2596
|
+
|
|
2597
|
+
const fromDb = await dbConnection.getRepository(ContactMetadataItemEntity).findOne({
|
|
2598
|
+
where: { label: metadataItem.label },
|
|
2599
|
+
})
|
|
2600
|
+
|
|
2601
|
+
expect(fromDb).toBeDefined()
|
|
2602
|
+
expect(fromDb?.label).toEqual(metadataItem.label)
|
|
2603
|
+
expect(fromDb?.stringValue).toEqual(metadataItem.value)
|
|
2604
|
+
})
|
|
2605
|
+
|
|
2606
|
+
it('Should throw error when saving contact metadata item with blank label', async (): Promise<void> => {
|
|
2607
|
+
const metadataItem = {
|
|
2608
|
+
label: '',
|
|
2609
|
+
value: 'example_value',
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
const contactMetadataItemEntity = contactMetadataItemEntityFrom(metadataItem)
|
|
2613
|
+
|
|
2614
|
+
await expect(dbConnection.getRepository(ContactMetadataItemEntity).save(contactMetadataItemEntity!)).rejects.toThrowError(
|
|
2615
|
+
'Blank metadata labels are not allowed',
|
|
2616
|
+
)
|
|
2617
|
+
})
|
|
2618
|
+
|
|
2619
|
+
it('Should throw error when saving contact metadata item with unsupported object type', async (): Promise<void> => {
|
|
2620
|
+
const metadataItem = {
|
|
2621
|
+
label: 'example_label',
|
|
2622
|
+
value: { unsupported: 'object' } as unknown as MetadataTypes, // Force not to have MetadataTypes
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
expect(() => contactMetadataItemEntityFrom(metadataItem)).toThrowError('Unsupported object type: Object for value [object Object]')
|
|
2626
|
+
})
|
|
2542
2627
|
})
|