@sphereon/ssi-sdk.data-store 0.23.4 → 0.23.5-unstable.13

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.
Files changed (35) hide show
  1. package/dist/contact/ContactStore.js +10 -10
  2. package/dist/contact/ContactStore.js.map +1 -1
  3. package/dist/entities/contact/ConnectionEntity.d.ts +2 -2
  4. package/dist/entities/contact/ConnectionEntity.d.ts.map +1 -1
  5. package/dist/entities/contact/ConnectionEntity.js +1 -1
  6. package/dist/entities/contact/ConnectionEntity.js.map +1 -1
  7. package/dist/entities/contact/CorrelationIdentifierEntity.d.ts +2 -2
  8. package/dist/entities/contact/CorrelationIdentifierEntity.js +1 -1
  9. package/dist/entities/contact/IdentityEntity.d.ts +2 -2
  10. package/dist/entities/contact/PartyTypeEntity.d.ts +2 -2
  11. package/dist/entities/contact/PartyTypeEntity.js +1 -1
  12. package/dist/entities/issuanceBranding/ImageAttributesEntity.js +2 -2
  13. package/dist/entities/issuanceBranding/ImageAttributesEntity.js.map +1 -1
  14. package/dist/migrations/postgres/1685628974232-CreateIssuanceBranding.js +1 -1
  15. package/dist/migrations/postgres/1685628974232-CreateIssuanceBranding.js.map +1 -1
  16. package/dist/migrations/sqlite/1685628973231-CreateIssuanceBranding.js +3 -3
  17. package/dist/migrations/sqlite/1685628973231-CreateIssuanceBranding.js.map +1 -1
  18. package/dist/types/contact/IAbstractContactStore.d.ts +2 -2
  19. package/dist/types/contact/contact.d.ts +14 -14
  20. package/dist/types/contact/contact.d.ts.map +1 -1
  21. package/dist/types/contact/contact.js +25 -25
  22. package/dist/types/contact/contact.js.map +1 -1
  23. package/package.json +4 -4
  24. package/src/__tests__/contact.entities.test.ts +141 -141
  25. package/src/__tests__/contact.store.test.ts +195 -195
  26. package/src/contact/ContactStore.ts +15 -15
  27. package/src/entities/contact/ConnectionEntity.ts +3 -3
  28. package/src/entities/contact/CorrelationIdentifierEntity.ts +3 -3
  29. package/src/entities/contact/IdentityEntity.ts +2 -2
  30. package/src/entities/contact/PartyTypeEntity.ts +3 -3
  31. package/src/entities/issuanceBranding/ImageAttributesEntity.ts +2 -2
  32. package/src/migrations/postgres/1685628974232-CreateIssuanceBranding.ts +1 -1
  33. package/src/migrations/sqlite/1685628973231-CreateIssuanceBranding.ts +3 -3
  34. package/src/types/contact/IAbstractContactStore.ts +2 -2
  35. package/src/types/contact/contact.ts +15 -15
@@ -38,8 +38,8 @@ import {
38
38
  AddPartyTypeArgs,
39
39
  AddPhysicalAddressArgs,
40
40
  AddRelationshipArgs,
41
- ConnectionTypeEnum,
42
- CorrelationIdentifierEnum,
41
+ ConnectionType,
42
+ CorrelationIdentifierType,
43
43
  ElectronicAddress,
44
44
  GetElectronicAddressArgs,
45
45
  GetElectronicAddressesArgs,
@@ -59,7 +59,7 @@ import {
59
59
  Party,
60
60
  PartyRelationship,
61
61
  PartyType,
62
- PartyTypeEnum,
62
+ PartyTypeType,
63
63
  PhysicalAddress,
64
64
  RemoveElectronicAddressArgs,
65
65
  RemoveIdentityArgs,
@@ -126,9 +126,9 @@ export class ContactStore extends AbstractContactStore {
126
126
  }
127
127
 
128
128
  for (const identity of identities ?? []) {
129
- if (identity.identifier.type === CorrelationIdentifierEnum.URL) {
129
+ if (identity.identifier.type === CorrelationIdentifierType.URL) {
130
130
  if (!identity.connection) {
131
- return Promise.reject(Error(`Identity with correlation type ${CorrelationIdentifierEnum.URL} should contain a connection`))
131
+ return Promise.reject(Error(`Identity with correlation type ${CorrelationIdentifierType.URL} should contain a connection`))
132
132
  }
133
133
 
134
134
  if (!this.hasCorrectConnectionConfig(identity.connection.type, identity.connection.config)) {
@@ -235,9 +235,9 @@ export class ContactStore extends AbstractContactStore {
235
235
  return Promise.reject(Error(`No party found for id: ${partyId}`))
236
236
  }
237
237
 
238
- if (identity.identifier.type === CorrelationIdentifierEnum.URL) {
238
+ if (identity.identifier.type === CorrelationIdentifierType.URL) {
239
239
  if (!identity.connection) {
240
- return Promise.reject(Error(`Identity with correlation type ${CorrelationIdentifierEnum.URL} should contain a connection`))
240
+ return Promise.reject(Error(`Identity with correlation type ${CorrelationIdentifierType.URL} should contain a connection`))
241
241
  }
242
242
 
243
243
  if (!this.hasCorrectConnectionConfig(identity.connection.type, identity.connection.config)) {
@@ -266,9 +266,9 @@ export class ContactStore extends AbstractContactStore {
266
266
  return Promise.reject(Error(`No identity found for id: ${identity.id}`))
267
267
  }
268
268
 
269
- if (identity.identifier.type === CorrelationIdentifierEnum.URL) {
269
+ if (identity.identifier.type === CorrelationIdentifierType.URL) {
270
270
  if (!identity.connection) {
271
- return Promise.reject(Error(`Identity with correlation type ${CorrelationIdentifierEnum.URL} should contain a connection`))
271
+ return Promise.reject(Error(`Identity with correlation type ${CorrelationIdentifierType.URL} should contain a connection`))
272
272
  }
273
273
 
274
274
  if (!this.hasCorrectConnectionConfig(identity.connection.type, identity.connection.config)) {
@@ -622,22 +622,22 @@ export class ContactStore extends AbstractContactStore {
622
622
  await physicalAddressRepository.delete(physicalAddressId)
623
623
  }
624
624
 
625
- private hasCorrectConnectionConfig(type: ConnectionTypeEnum, config: NonPersistedConnectionConfig): boolean {
625
+ private hasCorrectConnectionConfig(type: ConnectionType, config: NonPersistedConnectionConfig): boolean {
626
626
  switch (type) {
627
- case ConnectionTypeEnum.OPENID_CONNECT:
627
+ case ConnectionType.OPENID_CONNECT:
628
628
  return isOpenIdConfig(config)
629
- case ConnectionTypeEnum.SIOPv2:
629
+ case ConnectionType.SIOPv2:
630
630
  return isDidAuthConfig(config)
631
631
  default:
632
632
  throw new Error('Connection type not supported')
633
633
  }
634
634
  }
635
635
 
636
- private hasCorrectPartyType(type: PartyTypeEnum, contact: NonPersistedContact): boolean {
636
+ private hasCorrectPartyType(type: PartyTypeType, contact: NonPersistedContact): boolean {
637
637
  switch (type) {
638
- case PartyTypeEnum.NATURAL_PERSON:
638
+ case PartyTypeType.NATURAL_PERSON:
639
639
  return isNaturalPerson(contact)
640
- case PartyTypeEnum.ORGANIZATION:
640
+ case PartyTypeType.ORGANIZATION:
641
641
  return isOrganization(contact)
642
642
  default:
643
643
  throw new Error('Party type not supported')
@@ -1,6 +1,6 @@
1
1
  import { Entity, Column, PrimaryGeneratedColumn, OneToOne, JoinColumn, BaseEntity } from 'typeorm'
2
2
  import { BaseConfigEntity } from './BaseConfigEntity'
3
- import { ConnectionTypeEnum } from '../../types'
3
+ import { ConnectionType } from '../../types'
4
4
  import { IdentityEntity } from './IdentityEntity'
5
5
  import { OpenIdConfigEntity } from './OpenIdConfigEntity'
6
6
  import { DidAuthConfigEntity } from './DidAuthConfigEntity'
@@ -10,8 +10,8 @@ export class ConnectionEntity extends BaseEntity {
10
10
  @PrimaryGeneratedColumn('uuid')
11
11
  id!: string
12
12
 
13
- @Column('simple-enum', { name: 'type', enum: ConnectionTypeEnum, nullable: false })
14
- type!: ConnectionTypeEnum
13
+ @Column('simple-enum', { name: 'type', enum: ConnectionType, nullable: false })
14
+ type!: ConnectionType
15
15
 
16
16
  @OneToOne(() => BaseConfigEntity, (config: OpenIdConfigEntity | DidAuthConfigEntity) => config.connection, {
17
17
  cascade: true,
@@ -1,5 +1,5 @@
1
1
  import { Entity, Column, PrimaryGeneratedColumn, BaseEntity, OneToOne, JoinColumn, BeforeInsert, BeforeUpdate } from 'typeorm'
2
- import { CorrelationIdentifierEnum, ValidationConstraint } from '../../types'
2
+ import { CorrelationIdentifierType, ValidationConstraint } from '../../types'
3
3
  import { IdentityEntity } from './IdentityEntity'
4
4
  import { IsNotEmpty, validate, ValidationError } from 'class-validator'
5
5
  import { getConstraint } from '../../utils/ValidatorUtils'
@@ -9,8 +9,8 @@ export class CorrelationIdentifierEntity extends BaseEntity {
9
9
  @PrimaryGeneratedColumn('uuid')
10
10
  id!: string
11
11
 
12
- @Column('simple-enum', { name: 'type', enum: CorrelationIdentifierEnum, nullable: false })
13
- type!: CorrelationIdentifierEnum
12
+ @Column('simple-enum', { name: 'type', enum: CorrelationIdentifierType, nullable: false })
13
+ type!: CorrelationIdentifierType
14
14
 
15
15
  @Column('text', { name: 'correlation_id', nullable: false, unique: true })
16
16
  @IsNotEmpty({ message: 'Blank correlation ids are not allowed' })
@@ -16,7 +16,7 @@ import { IsNotEmpty, validate, ValidationError } from 'class-validator'
16
16
  import { CorrelationIdentifierEntity } from './CorrelationIdentifierEntity'
17
17
  import { ConnectionEntity } from './ConnectionEntity'
18
18
  import { IdentityMetadataItemEntity } from './IdentityMetadataItemEntity'
19
- import { IdentityRoleEnum, ValidationConstraint } from '../../types'
19
+ import { IdentityRoleType, ValidationConstraint } from '../../types'
20
20
  import { PartyEntity } from './PartyEntity'
21
21
  import { getConstraint } from '../../utils/ValidatorUtils'
22
22
 
@@ -35,7 +35,7 @@ export class IdentityEntity extends BaseEntity {
35
35
  alias!: string
36
36
 
37
37
  @Column('simple-array', { name: 'roles', nullable: false })
38
- roles!: Array<IdentityRoleEnum>
38
+ roles!: Array<IdentityRoleType>
39
39
 
40
40
  @OneToOne(() => CorrelationIdentifierEntity, (identifier: CorrelationIdentifierEntity) => identifier.identity, {
41
41
  cascade: true,
@@ -1,6 +1,6 @@
1
1
  import { BeforeInsert, BeforeUpdate, Column, CreateDateColumn, Entity, Index, OneToMany, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'
2
2
  import { PartyEntity } from './PartyEntity'
3
- import { PartyOrigin, PartyTypeEnum, ValidationConstraint } from '../../types'
3
+ import { PartyOrigin, PartyTypeType, ValidationConstraint } from '../../types'
4
4
  import { IsNotEmpty, Validate, validate, ValidationError } from 'class-validator'
5
5
  import { IsNonEmptyStringConstraint } from '../validators'
6
6
  import { getConstraint } from '../../utils/ValidatorUtils'
@@ -11,8 +11,8 @@ export class PartyTypeEntity {
11
11
  @PrimaryGeneratedColumn('uuid')
12
12
  id!: string
13
13
 
14
- @Column('simple-enum', { name: 'type', enum: PartyTypeEnum, nullable: false, unique: false })
15
- type!: PartyTypeEnum
14
+ @Column('simple-enum', { name: 'type', enum: PartyTypeType, nullable: false, unique: false })
15
+ type!: PartyTypeType
16
16
 
17
17
  @Column('simple-enum', { name: 'origin', enum: PartyOrigin, default: 'external', nullable: false, unique: false })
18
18
  origin!: PartyOrigin
@@ -9,11 +9,11 @@ export class ImageAttributesEntity extends BaseEntity {
9
9
  @PrimaryGeneratedColumn('uuid')
10
10
  id!: string
11
11
 
12
- @Column({ name: 'uri', length: 255, nullable: true, unique: false })
12
+ @Column({ name: 'uri', nullable: true, unique: false })
13
13
  @Validate(IsNonEmptyStringConstraint, { message: 'Blank image uri are not allowed' })
14
14
  uri?: string
15
15
 
16
- @Column({ name: 'dataUri', length: 255, nullable: true, unique: false })
16
+ @Column({ name: 'dataUri', nullable: true, unique: false })
17
17
  @Validate(IsNonEmptyStringConstraint, { message: 'Blank image data uri are not allowed' })
18
18
  dataUri?: string
19
19
 
@@ -10,7 +10,7 @@ export class CreateIssuanceBranding1685628974232 implements MigrationInterface {
10
10
  `CREATE TABLE "ImageDimensions" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "width" integer NOT NULL, "height" integer NOT NULL, CONSTRAINT "PK_ImageDimensions_id" PRIMARY KEY ("id"))`,
11
11
  )
12
12
  await queryRunner.query(
13
- `CREATE TABLE "ImageAttributes" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "uri" character varying(255), "dataUri" character varying(255), "mediaType" character varying(255), "alt" character varying(255), "dimensionsId" uuid, CONSTRAINT "UQ_dimensionsId" UNIQUE ("dimensionsId"), CONSTRAINT "PK_ImageAttributes_id" PRIMARY KEY ("id"))`,
13
+ `CREATE TABLE "ImageAttributes" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "uri" character varying, "dataUri" character varying, "mediaType" character varying(255), "alt" character varying(255), "dimensionsId" uuid, CONSTRAINT "UQ_dimensionsId" UNIQUE ("dimensionsId"), CONSTRAINT "PK_ImageAttributes_id" PRIMARY KEY ("id"))`,
14
14
  )
15
15
  await queryRunner.query(
16
16
  `CREATE TABLE "BackgroundAttributes" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "color" character varying(255), "imageId" uuid, CONSTRAINT "UQ_imageId" UNIQUE ("imageId"), CONSTRAINT "PK_BackgroundAttributes_id" PRIMARY KEY ("id"))`,
@@ -6,7 +6,7 @@ export class CreateIssuanceBranding1685628973231 implements MigrationInterface {
6
6
  public async up(queryRunner: QueryRunner): Promise<void> {
7
7
  await queryRunner.query(`CREATE TABLE "ImageDimensions" ("id" varchar PRIMARY KEY NOT NULL, "width" integer NOT NULL, "height" integer NOT NULL)`)
8
8
  await queryRunner.query(
9
- `CREATE TABLE "ImageAttributes" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar(255), "dataUri" varchar(255), "mediaType" varchar(255), "alt" varchar(255), "dimensionsId" varchar, CONSTRAINT "UQ_dimensionsId" UNIQUE ("dimensionsId"))`,
9
+ `CREATE TABLE "ImageAttributes" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar, "dataUri" varchar, "mediaType" varchar(255), "alt" varchar(255), "dimensionsId" varchar, CONSTRAINT "UQ_dimensionsId" UNIQUE ("dimensionsId"))`,
10
10
  )
11
11
  await queryRunner.query(
12
12
  `CREATE TABLE "BackgroundAttributes" ("id" varchar PRIMARY KEY NOT NULL, "color" varchar(255), "imageId" varchar, CONSTRAINT "UQ_imageId" UNIQUE ("imageId"))`,
@@ -32,7 +32,7 @@ export class CreateIssuanceBranding1685628973231 implements MigrationInterface {
32
32
  )
33
33
  await queryRunner.query(`CREATE INDEX "IDX_IssuerBrandingEntity_issuerCorrelationId" ON "IssuerBranding" ("issuerCorrelationId")`)
34
34
  await queryRunner.query(
35
- `CREATE TABLE "temporary_ImageAttributes" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar(255), "dataUri" varchar(255), "mediaType" varchar(255), "alt" varchar(255), "dimensionsId" varchar, CONSTRAINT "UQ_dimensionsId" UNIQUE ("dimensionsId"), CONSTRAINT "FK_ImageAttributes_dimensionsId" FOREIGN KEY ("dimensionsId") REFERENCES "ImageDimensions" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`,
35
+ `CREATE TABLE "temporary_ImageAttributes" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar, "dataUri" varchar, "mediaType" varchar(255), "alt" varchar(255), "dimensionsId" varchar, CONSTRAINT "UQ_dimensionsId" UNIQUE ("dimensionsId"), CONSTRAINT "FK_ImageAttributes_dimensionsId" FOREIGN KEY ("dimensionsId") REFERENCES "ImageDimensions" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`,
36
36
  )
37
37
  await queryRunner.query(
38
38
  `INSERT INTO "temporary_ImageAttributes"("id", "uri", "dataUri", "mediaType", "alt", "dimensionsId") SELECT "id", "uri", "dataUri", "mediaType", "alt", "dimensionsId" FROM "ImageAttributes"`,
@@ -96,7 +96,7 @@ export class CreateIssuanceBranding1685628973231 implements MigrationInterface {
96
96
  await queryRunner.query(`DROP TABLE "temporary_BackgroundAttributes"`)
97
97
  await queryRunner.query(`ALTER TABLE "ImageAttributes" RENAME TO "temporary_ImageAttributes"`)
98
98
  await queryRunner.query(
99
- `CREATE TABLE "ImageAttributes" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar(255), "dataUri" varchar(255), "mediaType" varchar(255), "alt" varchar(255), "dimensionsId" varchar, CONSTRAINT "UQ_dimensionsId" UNIQUE ("dimensionsId"))`,
99
+ `CREATE TABLE "ImageAttributes" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar, "dataUri" varchar, "mediaType" varchar(255), "alt" varchar(255), "dimensionsId" varchar, CONSTRAINT "UQ_dimensionsId" UNIQUE ("dimensionsId"))`,
100
100
  )
101
101
  await queryRunner.query(
102
102
  `INSERT INTO "ImageAttributes"("id", "uri", "dataUri", "mediaType", "alt", "dimensionsId") SELECT "id", "uri", "dataUri", "mediaType", "alt", "dimensionsId" FROM "ImageAttributes"`,
@@ -16,7 +16,7 @@ import {
16
16
  PartyOrigin,
17
17
  PartyRelationship,
18
18
  PartyType,
19
- PartyTypeEnum,
19
+ PartyTypeType,
20
20
  PhysicalAddress,
21
21
  } from './contact'
22
22
 
@@ -95,7 +95,7 @@ export type UpdateRelationshipArgs = {
95
95
  }
96
96
 
97
97
  export type AddPartyTypeArgs = {
98
- type: PartyTypeEnum
98
+ type: PartyTypeType
99
99
  origin: PartyOrigin
100
100
  name: string
101
101
  tenantId: string
@@ -3,7 +3,7 @@ import { IIdentifier } from '@veramo/core'
3
3
  export type Party = {
4
4
  id: string
5
5
  uri?: string
6
- roles: Array<IdentityRoleEnum>
6
+ roles: Array<IdentityRoleType>
7
7
  identities: Array<Identity>
8
8
  electronicAddresses: Array<ElectronicAddress>
9
9
  physicalAddresses: Array<PhysicalAddress>
@@ -47,7 +47,7 @@ export type PartialParty = Partial<
47
47
  export type Identity = {
48
48
  id: string
49
49
  alias: string
50
- roles: Array<IdentityRoleEnum>
50
+ roles: Array<IdentityRoleType>
51
51
  identifier: CorrelationIdentifier
52
52
  connection?: Connection
53
53
  metadata?: Array<MetadataItem>
@@ -63,7 +63,7 @@ export type PartialIdentity = Partial<Omit<Identity, 'identifier' | 'connection'
63
63
  identifier?: PartialCorrelationIdentifier
64
64
  connection?: PartialConnection
65
65
  metadata?: PartialMetadataItem
66
- roles?: IdentityRoleEnum
66
+ roles?: IdentityRoleType
67
67
  partyId?: string
68
68
  }
69
69
 
@@ -77,7 +77,7 @@ export type PartialMetadataItem = Partial<MetadataItem>
77
77
 
78
78
  export type CorrelationIdentifier = {
79
79
  id: string
80
- type: CorrelationIdentifierEnum
80
+ type: CorrelationIdentifierType
81
81
  correlationId: string
82
82
  }
83
83
  export type NonPersistedCorrelationIdentifier = Omit<CorrelationIdentifier, 'id'>
@@ -85,7 +85,7 @@ export type PartialCorrelationIdentifier = Partial<CorrelationIdentifier>
85
85
 
86
86
  export type Connection = {
87
87
  id: string
88
- type: ConnectionTypeEnum
88
+ type: ConnectionType
89
89
  config: ConnectionConfig
90
90
  }
91
91
  export type NonPersistedConnection = Omit<Connection, 'id' | 'config'> & {
@@ -150,14 +150,9 @@ export type Contact = NaturalPerson | Organization
150
150
  export type NonPersistedContact = NonPersistedNaturalPerson | NonPersistedOrganization
151
151
  export type PartialContact = PartialNaturalPerson | PartialOrganization
152
152
 
153
- export enum PartyOrigin {
154
- internal = 'internal',
155
- external = 'external',
156
- }
157
-
158
153
  export type PartyType = {
159
154
  id: string
160
- type: PartyTypeEnum
155
+ type: PartyTypeType
161
156
  origin: PartyOrigin
162
157
  name: string
163
158
  tenantId: string
@@ -214,24 +209,29 @@ export type ElectronicAddressType = 'email' | 'phone'
214
209
 
215
210
  export type PhysicalAddressType = 'home' | 'visit' | 'postal'
216
211
 
217
- export enum IdentityRoleEnum {
212
+ export enum IdentityRoleType {
218
213
  ISSUER = 'issuer',
219
214
  VERIFIER = 'verifier',
220
215
  HOLDER = 'holder',
221
216
  }
222
217
 
223
- export enum ConnectionTypeEnum {
218
+ export enum ConnectionType {
224
219
  OPENID_CONNECT = 'OIDC',
225
220
  SIOPv2 = 'SIOPv2',
226
221
  SIOPv2_OpenID4VP = 'SIOPv2+OpenID4VP',
227
222
  }
228
223
 
229
- export enum CorrelationIdentifierEnum {
224
+ export enum CorrelationIdentifierType {
230
225
  DID = 'did',
231
226
  URL = 'url',
232
227
  }
233
228
 
234
- export enum PartyTypeEnum {
229
+ export enum PartyTypeType {
235
230
  NATURAL_PERSON = 'naturalPerson',
236
231
  ORGANIZATION = 'organization',
237
232
  }
233
+
234
+ export enum PartyOrigin {
235
+ INTERNAL = 'internal',
236
+ EXTERNAL = 'external',
237
+ }