@sphereon/ssi-sdk.data-store 0.23.5-unstable.88 → 0.24.0

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 (146) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +77 -77
  3. package/dist/index.d.ts +3 -9
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +2 -15
  6. package/dist/index.js.map +1 -1
  7. package/dist/migrations/generic/index.d.ts +0 -2
  8. package/dist/migrations/generic/index.d.ts.map +1 -1
  9. package/dist/migrations/generic/index.js +1 -4
  10. package/dist/migrations/generic/index.js.map +1 -1
  11. package/dist/migrations/index.d.ts +1 -1
  12. package/dist/migrations/index.d.ts.map +1 -1
  13. package/dist/migrations/index.js +1 -2
  14. package/dist/migrations/index.js.map +1 -1
  15. package/dist/migrations/postgres/1690925872592-CreateContacts.js +1 -1
  16. package/dist/migrations/postgres/1690925872592-CreateContacts.js.map +1 -1
  17. package/dist/migrations/postgres/1708525189001-CreateDigitalCredential.js +22 -22
  18. package/dist/migrations/postgres/1708797018115-CreateMachineStateStore.js +16 -16
  19. package/dist/migrations/sqlite/1708525189002-CreateDigitalCredential.js +21 -21
  20. package/dist/migrations/sqlite/1708796002272-CreateMachineStateStore.js +15 -15
  21. package/dist/types/index.d.ts +0 -2
  22. package/dist/types/index.d.ts.map +1 -1
  23. package/dist/types/index.js +0 -2
  24. package/dist/types/index.js.map +1 -1
  25. package/package.json +4 -5
  26. package/src/__tests__/contact.entities.test.ts +2542 -2542
  27. package/src/__tests__/contact.store.test.ts +2471 -2471
  28. package/src/__tests__/digitalCredential.entities.test.ts +254 -254
  29. package/src/__tests__/digitalCredential.store.test.ts +294 -294
  30. package/src/__tests__/eventLogger.entities.test.ts +73 -73
  31. package/src/__tests__/eventLogger.store.test.ts +136 -136
  32. package/src/__tests__/issuanceBranding.entities.test.ts +844 -844
  33. package/src/__tests__/issuanceBranding.store.test.ts +1884 -1884
  34. package/src/__tests__/machineState.entities.test.ts +51 -51
  35. package/src/__tests__/machineState.store.test.ts +174 -174
  36. package/src/contact/AbstractContactStore.ts +71 -71
  37. package/src/contact/ContactStore.ts +723 -723
  38. package/src/digitalCredential/AbstractDigitalCredentialStore.ts +17 -17
  39. package/src/digitalCredential/DigitalCredentialStore.ts +127 -127
  40. package/src/entities/contact/BaseContactEntity.ts +39 -39
  41. package/src/entities/contact/ConnectionEntity.ts +29 -29
  42. package/src/entities/contact/CorrelationIdentifierEntity.ts +37 -37
  43. package/src/entities/contact/DidAuthConfigEntity.ts +14 -14
  44. package/src/entities/contact/ElectronicAddressEntity.ts +63 -63
  45. package/src/entities/contact/IdentityEntity.ts +97 -97
  46. package/src/entities/contact/IdentityMetadataItemEntity.ts +35 -35
  47. package/src/entities/contact/NaturalPersonEntity.ts +38 -38
  48. package/src/entities/contact/OpenIdConfigEntity.ts +26 -26
  49. package/src/entities/contact/OrganizationEntity.ts +34 -34
  50. package/src/entities/contact/PartyEntity.ts +110 -110
  51. package/src/entities/contact/PartyRelationshipEntity.ts +61 -61
  52. package/src/entities/contact/PartyTypeEntity.ts +62 -62
  53. package/src/entities/contact/PhysicalAddressEntity.ts +87 -87
  54. package/src/entities/digitalCredential/DigitalCredentialEntity.ts +64 -64
  55. package/src/entities/eventLogger/AuditEventEntity.ts +99 -99
  56. package/src/entities/issuanceBranding/CredentialBrandingEntity.ts +78 -78
  57. package/src/entities/issuanceBranding/ImageAttributesEntity.ts +57 -57
  58. package/src/entities/issuanceBranding/IssuerBrandingEntity.ts +72 -72
  59. package/src/entities/machineState/MachineStateInfoEntity.ts +58 -58
  60. package/src/entities/statusList2021/StatusList2021Entity.ts +96 -96
  61. package/src/eventLogger/AbstractEventLoggerStore.ts +7 -7
  62. package/src/eventLogger/EventLoggerStore.ts +62 -62
  63. package/src/index.ts +141 -154
  64. package/src/issuanceBranding/IssuanceBrandingStore.ts +559 -559
  65. package/src/machineState/IAbstractMachineStateStore.ts +65 -65
  66. package/src/machineState/MachineStateStore.ts +149 -149
  67. package/src/migrations/generic/1-CreateContacts.ts +66 -66
  68. package/src/migrations/generic/2-CreateIssuanceBranding.ts +64 -64
  69. package/src/migrations/generic/3-CreateContacts.ts +66 -66
  70. package/src/migrations/generic/4-CreateStatusList.ts +54 -54
  71. package/src/migrations/generic/5-CreateAuditEvents.ts +66 -66
  72. package/src/migrations/generic/6-CreateDigitalCredential.ts +66 -66
  73. package/src/migrations/generic/7-CreateMachineStateStore.ts +66 -66
  74. package/src/migrations/generic/index.ts +33 -36
  75. package/src/migrations/index.ts +9 -10
  76. package/src/migrations/postgres/1659463079428-CreateContacts.ts +63 -63
  77. package/src/migrations/postgres/1685628974232-CreateIssuanceBranding.ts +85 -85
  78. package/src/migrations/postgres/1690925872592-CreateContacts.ts +104 -104
  79. package/src/migrations/postgres/1693866470001-CreateStatusList.ts +24 -24
  80. package/src/migrations/postgres/1701634812183-CreateAuditEvents.ts +33 -33
  81. package/src/migrations/postgres/1708525189001-CreateDigitalCredential.ts +44 -44
  82. package/src/migrations/postgres/1708797018115-CreateMachineStateStore.ts +29 -29
  83. package/src/migrations/sqlite/1659463069549-CreateContacts.ts +110 -110
  84. package/src/migrations/sqlite/1685628973231-CreateIssuanceBranding.ts +119 -119
  85. package/src/migrations/sqlite/1690925872693-CreateContacts.ts +161 -161
  86. package/src/migrations/sqlite/1693866470000-CreateStatusList.ts +24 -24
  87. package/src/migrations/sqlite/1701634819487-CreateAuditEvents.ts +15 -15
  88. package/src/migrations/sqlite/1708525189002-CreateDigitalCredential.ts +34 -34
  89. package/src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts +28 -28
  90. package/src/statusList/StatusListStore.ts +237 -237
  91. package/src/types/contact/IAbstractContactStore.ts +161 -161
  92. package/src/types/contact/contact.ts +237 -237
  93. package/src/types/digitalCredential/IAbstractDigitalCredentialStore.ts +37 -37
  94. package/src/types/digitalCredential/digitalCredential.ts +46 -46
  95. package/src/types/eventLogger/IAbstractEventLoggerStore.ts +12 -12
  96. package/src/types/eventLogger/eventLogger.ts +3 -3
  97. package/src/types/index.ts +10 -12
  98. package/src/types/machineState/IAbstractMachineStateStore.ts +68 -68
  99. package/src/utils/SortingUtils.ts +16 -16
  100. package/src/utils/contact/MappingUtils.ts +385 -385
  101. package/src/utils/digitalCredential/MappingUtils.ts +122 -122
  102. package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.d.ts +0 -13
  103. package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.d.ts.map +0 -1
  104. package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.js +0 -71
  105. package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.js.map +0 -1
  106. package/dist/migrations/generic/8-CreatePresentationDefinitions.d.ts +0 -7
  107. package/dist/migrations/generic/8-CreatePresentationDefinitions.d.ts.map +0 -1
  108. package/dist/migrations/generic/8-CreatePresentationDefinitions.js +0 -78
  109. package/dist/migrations/generic/8-CreatePresentationDefinitions.js.map +0 -1
  110. package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.d.ts +0 -7
  111. package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.d.ts.map +0 -1
  112. package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js +0 -40
  113. package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js.map +0 -1
  114. package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.d.ts +0 -7
  115. package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.d.ts.map +0 -1
  116. package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js +0 -37
  117. package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js.map +0 -1
  118. package/dist/pd/AbstractPDStore.d.ts +0 -10
  119. package/dist/pd/AbstractPDStore.d.ts.map +0 -1
  120. package/dist/pd/AbstractPDStore.js +0 -7
  121. package/dist/pd/AbstractPDStore.js.map +0 -1
  122. package/dist/pd/PDStore.d.ts +0 -14
  123. package/dist/pd/PDStore.d.ts.map +0 -1
  124. package/dist/pd/PDStore.js +0 -90
  125. package/dist/pd/PDStore.js.map +0 -1
  126. package/dist/types/pd/IAbstractPDStore.d.ts +0 -14
  127. package/dist/types/pd/IAbstractPDStore.d.ts.map +0 -1
  128. package/dist/types/pd/IAbstractPDStore.js +0 -3
  129. package/dist/types/pd/IAbstractPDStore.js.map +0 -1
  130. package/dist/types/pd/pd.d.ts +0 -15
  131. package/dist/types/pd/pd.d.ts.map +0 -1
  132. package/dist/types/pd/pd.js +0 -3
  133. package/dist/types/pd/pd.js.map +0 -1
  134. package/dist/utils/presentationDefinitions/MappingUtils.d.ts +0 -6
  135. package/dist/utils/presentationDefinitions/MappingUtils.d.ts.map +0 -1
  136. package/dist/utils/presentationDefinitions/MappingUtils.js +0 -50
  137. package/dist/utils/presentationDefinitions/MappingUtils.js.map +0 -1
  138. package/src/entities/presentationDefinitions/PresentationDefinitionItemEntity.ts +0 -41
  139. package/src/migrations/generic/8-CreatePresentationDefinitions.ts +0 -66
  140. package/src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts +0 -24
  141. package/src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts +0 -23
  142. package/src/pd/AbstractPDStore.ts +0 -10
  143. package/src/pd/PDStore.ts +0 -103
  144. package/src/types/pd/IAbstractPDStore.ts +0 -19
  145. package/src/types/pd/pd.ts +0 -16
  146. package/src/utils/presentationDefinitions/MappingUtils.ts +0 -54
@@ -1,72 +1,72 @@
1
- import {
2
- BaseEntity,
3
- BeforeInsert,
4
- BeforeUpdate,
5
- Column,
6
- CreateDateColumn,
7
- Entity,
8
- Index,
9
- OneToMany,
10
- PrimaryGeneratedColumn,
11
- UpdateDateColumn,
12
- } from 'typeorm'
13
- import { ArrayMinSize, IsNotEmpty, validate, ValidationError } from 'class-validator'
14
- import { IssuerLocaleBrandingEntity, issuerLocaleBrandingEntityFrom } from './IssuerLocaleBrandingEntity'
15
- import { IBasicIssuerBranding, IBasicIssuerLocaleBranding } from '../../types'
16
-
17
- @Entity('IssuerBranding')
18
- @Index('IDX_IssuerBrandingEntity_issuerCorrelationId', ['issuerCorrelationId'])
19
- export class IssuerBrandingEntity extends BaseEntity {
20
- @PrimaryGeneratedColumn('uuid')
21
- id!: string
22
-
23
- @Column({ name: 'issuerCorrelationId', length: 255, nullable: false, unique: true })
24
- @IsNotEmpty({ message: 'Blank issuerCorrelationIds are not allowed' })
25
- issuerCorrelationId!: string
26
-
27
- @OneToMany(
28
- () => IssuerLocaleBrandingEntity,
29
- (issuerLocaleBrandingEntity: IssuerLocaleBrandingEntity) => issuerLocaleBrandingEntity.issuerBranding,
30
- {
31
- cascade: true,
32
- onDelete: 'CASCADE',
33
- eager: true,
34
- nullable: false,
35
- },
36
- )
37
- @ArrayMinSize(1, { message: 'localeBranding cannot be empty' })
38
- localeBranding!: Array<IssuerLocaleBrandingEntity>
39
-
40
- @CreateDateColumn({ name: 'created_at', nullable: false })
41
- createdAt!: Date
42
-
43
- @UpdateDateColumn({ name: 'last_updated_at', nullable: false })
44
- lastUpdatedAt!: Date
45
-
46
- // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
47
- @BeforeInsert()
48
- @BeforeUpdate()
49
- updateUpdatedDate(): void {
50
- this.lastUpdatedAt = new Date()
51
- }
52
-
53
- @BeforeInsert()
54
- @BeforeUpdate()
55
- async validate(): Promise<undefined> {
56
- const validation: Array<ValidationError> = await validate(this)
57
- if (validation.length > 0) {
58
- return Promise.reject(Error(Object.values(validation[0].constraints!)[0]))
59
- }
60
- return
61
- }
62
- }
63
-
64
- export const issuerBrandingEntityFrom = (args: IBasicIssuerBranding): IssuerBrandingEntity => {
65
- const issuerBrandingEntity: IssuerBrandingEntity = new IssuerBrandingEntity()
66
- issuerBrandingEntity.issuerCorrelationId = args.issuerCorrelationId
67
- issuerBrandingEntity.localeBranding = args.localeBranding.map((localeBranding: IBasicIssuerLocaleBranding) =>
68
- issuerLocaleBrandingEntityFrom(localeBranding),
69
- )
70
-
71
- return issuerBrandingEntity
72
- }
1
+ import {
2
+ BaseEntity,
3
+ BeforeInsert,
4
+ BeforeUpdate,
5
+ Column,
6
+ CreateDateColumn,
7
+ Entity,
8
+ Index,
9
+ OneToMany,
10
+ PrimaryGeneratedColumn,
11
+ UpdateDateColumn,
12
+ } from 'typeorm'
13
+ import { ArrayMinSize, IsNotEmpty, validate, ValidationError } from 'class-validator'
14
+ import { IssuerLocaleBrandingEntity, issuerLocaleBrandingEntityFrom } from './IssuerLocaleBrandingEntity'
15
+ import { IBasicIssuerBranding, IBasicIssuerLocaleBranding } from '../../types'
16
+
17
+ @Entity('IssuerBranding')
18
+ @Index('IDX_IssuerBrandingEntity_issuerCorrelationId', ['issuerCorrelationId'])
19
+ export class IssuerBrandingEntity extends BaseEntity {
20
+ @PrimaryGeneratedColumn('uuid')
21
+ id!: string
22
+
23
+ @Column({ name: 'issuerCorrelationId', length: 255, nullable: false, unique: true })
24
+ @IsNotEmpty({ message: 'Blank issuerCorrelationIds are not allowed' })
25
+ issuerCorrelationId!: string
26
+
27
+ @OneToMany(
28
+ () => IssuerLocaleBrandingEntity,
29
+ (issuerLocaleBrandingEntity: IssuerLocaleBrandingEntity) => issuerLocaleBrandingEntity.issuerBranding,
30
+ {
31
+ cascade: true,
32
+ onDelete: 'CASCADE',
33
+ eager: true,
34
+ nullable: false,
35
+ },
36
+ )
37
+ @ArrayMinSize(1, { message: 'localeBranding cannot be empty' })
38
+ localeBranding!: Array<IssuerLocaleBrandingEntity>
39
+
40
+ @CreateDateColumn({ name: 'created_at', nullable: false })
41
+ createdAt!: Date
42
+
43
+ @UpdateDateColumn({ name: 'last_updated_at', nullable: false })
44
+ lastUpdatedAt!: Date
45
+
46
+ // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
47
+ @BeforeInsert()
48
+ @BeforeUpdate()
49
+ updateUpdatedDate(): void {
50
+ this.lastUpdatedAt = new Date()
51
+ }
52
+
53
+ @BeforeInsert()
54
+ @BeforeUpdate()
55
+ async validate(): Promise<undefined> {
56
+ const validation: Array<ValidationError> = await validate(this)
57
+ if (validation.length > 0) {
58
+ return Promise.reject(Error(Object.values(validation[0].constraints!)[0]))
59
+ }
60
+ return
61
+ }
62
+ }
63
+
64
+ export const issuerBrandingEntityFrom = (args: IBasicIssuerBranding): IssuerBrandingEntity => {
65
+ const issuerBrandingEntity: IssuerBrandingEntity = new IssuerBrandingEntity()
66
+ issuerBrandingEntity.issuerCorrelationId = args.issuerCorrelationId
67
+ issuerBrandingEntity.localeBranding = args.localeBranding.map((localeBranding: IBasicIssuerLocaleBranding) =>
68
+ issuerLocaleBrandingEntityFrom(localeBranding),
69
+ )
70
+
71
+ return issuerBrandingEntity
72
+ }
@@ -1,58 +1,58 @@
1
- import { BaseEntity, Column, CreateDateColumn, Entity, PrimaryColumn, UpdateDateColumn } from 'typeorm'
2
-
3
- /**
4
- * @class MachineStateInfoEntity
5
- * Represents a machine state. It allows to continue a machine at a later point in time at the point it was left of
6
- *
7
- * @param {string} instanceId - The instance ID of the machine state.
8
- * @param {string} [sessionId] - The session ID of the machine state. (optional)
9
- * @param {string} machineName - The name of the machine.
10
- * @param {string} [latestStateName] - The name of the latest state. (optional)
11
- * @param {string} latestEventType - The type of the latest event.
12
- * @param {string} state - The current state of the machine.
13
- * @param {Date} createdAt - The date and time when the machine state was created.
14
- * @param {Date} updatedAt - The date and time when the machine state was last updated.
15
- * @param {number} updatedCount - The number of times the machine state has been updated.
16
- * @param {Date} [expiresAt] - The date and time when the machine state expires. (optional)
17
- * @param {Date} [completedAt] - The date and time when the machine state was completed. (optional)
18
- * @param {string} [tenantId] - The ID of the tenant associated with the machine state. (optional)
19
- */
20
- @Entity('MachineStateInfoEntity')
21
- export class MachineStateInfoEntity extends BaseEntity {
22
- @PrimaryColumn({ name: 'instance_id', type: 'varchar', nullable: false })
23
- instanceId!: string
24
-
25
- @Column({ name: 'session_id', type: 'varchar', nullable: true })
26
- sessionId?: string
27
-
28
- // Xstate moved to name instead of instanceId for V5. Also makes more sense
29
- @Column({ name: 'machine_name', type: 'varchar', nullable: false })
30
- machineName!: string
31
-
32
- @Column({ name: 'latest_state_name', type: 'varchar', nullable: true })
33
- latestStateName?: string
34
-
35
- @Column({ name: 'latest_event_type', type: 'varchar', nullable: false })
36
- latestEventType!: string
37
-
38
- @Column({ name: 'state', type: 'text', nullable: false })
39
- state!: string
40
-
41
- @CreateDateColumn({ name: 'created_at', type: 'datetime', nullable: false })
42
- createdAt!: Date
43
-
44
- @UpdateDateColumn({ name: 'updated_at', type: 'datetime', nullable: false })
45
- updatedAt!: Date
46
-
47
- @Column({ name: 'updated_count', type: 'integer', nullable: false })
48
- updatedCount!: number
49
-
50
- @Column({ name: 'expires_at', type: 'datetime', nullable: true })
51
- expiresAt?: Date
52
-
53
- @Column({ name: 'completed_at', type: 'datetime', nullable: true })
54
- completedAt?: Date
55
-
56
- @Column({ name: 'tenant_id', type: 'varchar', nullable: true })
57
- tenantId?: string
58
- }
1
+ import { BaseEntity, Column, CreateDateColumn, Entity, PrimaryColumn, UpdateDateColumn } from 'typeorm'
2
+
3
+ /**
4
+ * @class MachineStateInfoEntity
5
+ * Represents a machine state. It allows to continue a machine at a later point in time at the point it was left of
6
+ *
7
+ * @param {string} instanceId - The instance ID of the machine state.
8
+ * @param {string} [sessionId] - The session ID of the machine state. (optional)
9
+ * @param {string} machineName - The name of the machine.
10
+ * @param {string} [latestStateName] - The name of the latest state. (optional)
11
+ * @param {string} latestEventType - The type of the latest event.
12
+ * @param {string} state - The current state of the machine.
13
+ * @param {Date} createdAt - The date and time when the machine state was created.
14
+ * @param {Date} updatedAt - The date and time when the machine state was last updated.
15
+ * @param {number} updatedCount - The number of times the machine state has been updated.
16
+ * @param {Date} [expiresAt] - The date and time when the machine state expires. (optional)
17
+ * @param {Date} [completedAt] - The date and time when the machine state was completed. (optional)
18
+ * @param {string} [tenantId] - The ID of the tenant associated with the machine state. (optional)
19
+ */
20
+ @Entity('MachineStateInfoEntity')
21
+ export class MachineStateInfoEntity extends BaseEntity {
22
+ @PrimaryColumn({ name: 'instance_id', type: 'varchar', nullable: false })
23
+ instanceId!: string
24
+
25
+ @Column({ name: 'session_id', type: 'varchar', nullable: true })
26
+ sessionId?: string
27
+
28
+ // Xstate moved to name instead of instanceId for V5. Also makes more sense
29
+ @Column({ name: 'machine_name', type: 'varchar', nullable: false })
30
+ machineName!: string
31
+
32
+ @Column({ name: 'latest_state_name', type: 'varchar', nullable: true })
33
+ latestStateName?: string
34
+
35
+ @Column({ name: 'latest_event_type', type: 'varchar', nullable: false })
36
+ latestEventType!: string
37
+
38
+ @Column({ name: 'state', type: 'text', nullable: false })
39
+ state!: string
40
+
41
+ @CreateDateColumn({ name: 'created_at', type: 'datetime', nullable: false })
42
+ createdAt!: Date
43
+
44
+ @UpdateDateColumn({ name: 'updated_at', type: 'datetime', nullable: false })
45
+ updatedAt!: Date
46
+
47
+ @Column({ name: 'updated_count', type: 'integer', nullable: false })
48
+ updatedCount!: number
49
+
50
+ @Column({ name: 'expires_at', type: 'datetime', nullable: true })
51
+ expiresAt?: Date
52
+
53
+ @Column({ name: 'completed_at', type: 'datetime', nullable: true })
54
+ completedAt?: Date
55
+
56
+ @Column({ name: 'tenant_id', type: 'varchar', nullable: true })
57
+ tenantId?: string
58
+ }
@@ -1,96 +1,96 @@
1
- import {
2
- IIssuer,
3
- JwtDecodedVerifiableCredential,
4
- StatusListCredentialIdMode,
5
- StatusListDriverType,
6
- StatusListIndexingDirection,
7
- StatusListType,
8
- StatusPurpose2021,
9
- W3CVerifiableCredential,
10
- } from '@sphereon/ssi-types'
11
- import { ProofFormat } from '@veramo/core'
12
- import { BaseEntity, Column, Entity, OneToMany, PrimaryColumn, Unique } from 'typeorm'
13
- import { StatusListEntryEntity } from './StatusList2021EntryEntity'
14
-
15
- @Entity('StatusList')
16
- @Unique('UQ_correlationId', ['correlationId'])
17
- export class StatusListEntity extends BaseEntity {
18
- @PrimaryColumn({ name: 'id', type: 'varchar' })
19
- id!: string
20
-
21
- @Column({ name: 'correlationId', type: 'varchar', nullable: false })
22
- correlationId!: string
23
-
24
- @Column({ name: 'length', nullable: false, unique: false })
25
- length!: number
26
-
27
- @Column({
28
- name: 'issuer',
29
- type: 'text',
30
- nullable: false,
31
- unique: false,
32
- transformer: {
33
- from(value: string): string | IIssuer {
34
- if (value?.trim()?.startsWith('{')) {
35
- return JSON.parse(value)
36
- }
37
- return value
38
- },
39
- to(value: string | IIssuer): string {
40
- if (typeof value === 'string') {
41
- return value
42
- }
43
- return JSON.stringify(value)
44
- },
45
- },
46
- })
47
- issuer!: string | IIssuer
48
-
49
- @Column('simple-enum', { name: 'type', enum: StatusListType, nullable: false, default: StatusListType.StatusList2021 })
50
- type!: StatusListType
51
-
52
- @Column('simple-enum', { name: 'driverType', enum: StatusListDriverType, nullable: false, default: StatusListDriverType.AGENT_TYPEORM })
53
- driverType!: StatusListDriverType
54
-
55
- @Column('simple-enum', {
56
- name: 'credentialIdMode',
57
- enum: StatusListCredentialIdMode,
58
- nullable: false,
59
- default: StatusListCredentialIdMode.ISSUANCE,
60
- })
61
- credentialIdMode!: StatusListCredentialIdMode
62
-
63
- @Column({ type: 'varchar', name: 'proofFormat', enum: ['lds', 'jwt'], nullable: false, default: 'lds' })
64
- proofFormat!: ProofFormat
65
-
66
- @Column({ type: 'varchar', name: 'indexingDirection', enum: ['rightToLeft'], nullable: false, default: 'rightToLeft' })
67
- indexingDirection!: StatusListIndexingDirection
68
-
69
- @Column({ type: 'varchar', name: 'statusPurpose', nullable: false, default: 'revocation' })
70
- statusPurpose!: StatusPurpose2021
71
-
72
- @Column({
73
- name: 'statusListCredential',
74
- type: 'text',
75
- nullable: true,
76
- unique: false,
77
- transformer: {
78
- from(value: string): W3CVerifiableCredential | JwtDecodedVerifiableCredential {
79
- if (value?.startsWith('ey')) {
80
- return value
81
- }
82
- return JSON.parse(value)
83
- },
84
- to(value: W3CVerifiableCredential | JwtDecodedVerifiableCredential): string {
85
- if (typeof value === 'string') {
86
- return value
87
- }
88
- return JSON.stringify(value)
89
- },
90
- },
91
- })
92
- statusListCredential?: W3CVerifiableCredential | JwtDecodedVerifiableCredential
93
-
94
- @OneToMany((type) => StatusListEntryEntity, (entry) => entry.statusList)
95
- statusListEntries!: StatusListEntryEntity[]
96
- }
1
+ import {
2
+ IIssuer,
3
+ JwtDecodedVerifiableCredential,
4
+ StatusListCredentialIdMode,
5
+ StatusListDriverType,
6
+ StatusListIndexingDirection,
7
+ StatusListType,
8
+ StatusPurpose2021,
9
+ W3CVerifiableCredential,
10
+ } from '@sphereon/ssi-types'
11
+ import { ProofFormat } from '@veramo/core'
12
+ import { BaseEntity, Column, Entity, OneToMany, PrimaryColumn, Unique } from 'typeorm'
13
+ import { StatusListEntryEntity } from './StatusList2021EntryEntity'
14
+
15
+ @Entity('StatusList')
16
+ @Unique('UQ_correlationId', ['correlationId'])
17
+ export class StatusListEntity extends BaseEntity {
18
+ @PrimaryColumn({ name: 'id', type: 'varchar' })
19
+ id!: string
20
+
21
+ @Column({ name: 'correlationId', type: 'varchar', nullable: false })
22
+ correlationId!: string
23
+
24
+ @Column({ name: 'length', nullable: false, unique: false })
25
+ length!: number
26
+
27
+ @Column({
28
+ name: 'issuer',
29
+ type: 'text',
30
+ nullable: false,
31
+ unique: false,
32
+ transformer: {
33
+ from(value: string): string | IIssuer {
34
+ if (value?.trim()?.startsWith('{')) {
35
+ return JSON.parse(value)
36
+ }
37
+ return value
38
+ },
39
+ to(value: string | IIssuer): string {
40
+ if (typeof value === 'string') {
41
+ return value
42
+ }
43
+ return JSON.stringify(value)
44
+ },
45
+ },
46
+ })
47
+ issuer!: string | IIssuer
48
+
49
+ @Column('simple-enum', { name: 'type', enum: StatusListType, nullable: false, default: StatusListType.StatusList2021 })
50
+ type!: StatusListType
51
+
52
+ @Column('simple-enum', { name: 'driverType', enum: StatusListDriverType, nullable: false, default: StatusListDriverType.AGENT_TYPEORM })
53
+ driverType!: StatusListDriverType
54
+
55
+ @Column('simple-enum', {
56
+ name: 'credentialIdMode',
57
+ enum: StatusListCredentialIdMode,
58
+ nullable: false,
59
+ default: StatusListCredentialIdMode.ISSUANCE,
60
+ })
61
+ credentialIdMode!: StatusListCredentialIdMode
62
+
63
+ @Column({ type: 'varchar', name: 'proofFormat', enum: ['lds', 'jwt'], nullable: false, default: 'lds' })
64
+ proofFormat!: ProofFormat
65
+
66
+ @Column({ type: 'varchar', name: 'indexingDirection', enum: ['rightToLeft'], nullable: false, default: 'rightToLeft' })
67
+ indexingDirection!: StatusListIndexingDirection
68
+
69
+ @Column({ type: 'varchar', name: 'statusPurpose', nullable: false, default: 'revocation' })
70
+ statusPurpose!: StatusPurpose2021
71
+
72
+ @Column({
73
+ name: 'statusListCredential',
74
+ type: 'text',
75
+ nullable: true,
76
+ unique: false,
77
+ transformer: {
78
+ from(value: string): W3CVerifiableCredential | JwtDecodedVerifiableCredential {
79
+ if (value?.startsWith('ey')) {
80
+ return value
81
+ }
82
+ return JSON.parse(value)
83
+ },
84
+ to(value: W3CVerifiableCredential | JwtDecodedVerifiableCredential): string {
85
+ if (typeof value === 'string') {
86
+ return value
87
+ }
88
+ return JSON.stringify(value)
89
+ },
90
+ },
91
+ })
92
+ statusListCredential?: W3CVerifiableCredential | JwtDecodedVerifiableCredential
93
+
94
+ @OneToMany((type) => StatusListEntryEntity, (entry) => entry.statusList)
95
+ statusListEntries!: StatusListEntryEntity[]
96
+ }
@@ -1,7 +1,7 @@
1
- import { GetAuditEventsArgs, StoreAuditEventArgs } from '../types'
2
- import { AuditLoggingEvent } from '@sphereon/ssi-sdk.core'
3
-
4
- export abstract class AbstractEventLoggerStore {
5
- abstract getAuditEvents(args: GetAuditEventsArgs): Promise<Array<AuditLoggingEvent>>
6
- abstract storeAuditEvent(args: StoreAuditEventArgs): Promise<AuditLoggingEvent>
7
- }
1
+ import { GetAuditEventsArgs, StoreAuditEventArgs } from '../types'
2
+ import { AuditLoggingEvent } from '@sphereon/ssi-sdk.core'
3
+
4
+ export abstract class AbstractEventLoggerStore {
5
+ abstract getAuditEvents(args: GetAuditEventsArgs): Promise<Array<AuditLoggingEvent>>
6
+ abstract storeAuditEvent(args: StoreAuditEventArgs): Promise<AuditLoggingEvent>
7
+ }
@@ -1,62 +1,62 @@
1
- import Debug, { Debugger } from 'debug'
2
- import { DataSource } from 'typeorm'
3
- import { AuditLoggingEvent } from '@sphereon/ssi-sdk.core'
4
- import { OrPromise } from '@sphereon/ssi-types'
5
- import { AbstractEventLoggerStore } from './AbstractEventLoggerStore'
6
- import { AuditEventEntity, auditEventEntityFrom } from '../entities/eventLogger/AuditEventEntity'
7
- import { GetAuditEventsArgs, StoreAuditEventArgs } from '../types'
8
-
9
- const debug: Debugger = Debug('sphereon:ssi-sdk:event-store')
10
-
11
- export class EventLoggerStore extends AbstractEventLoggerStore {
12
- private readonly dbConnection: OrPromise<DataSource>
13
-
14
- constructor(dbConnection: OrPromise<DataSource>) {
15
- super()
16
- this.dbConnection = dbConnection
17
- }
18
-
19
- getAuditEvents = async (args?: GetAuditEventsArgs): Promise<Array<AuditLoggingEvent>> => {
20
- const connection: DataSource = await this.dbConnection // TODO apply everywhere
21
- debug('Getting audit events', args)
22
- const result: Array<AuditEventEntity> = await connection.getRepository(AuditEventEntity).find({
23
- ...(args?.filter && { where: args?.filter }),
24
- })
25
-
26
- return result.map((event: AuditEventEntity) => this.auditEventFrom(event))
27
- }
28
-
29
- storeAuditEvent = async (args: StoreAuditEventArgs): Promise<AuditLoggingEvent> => {
30
- const { event } = args
31
-
32
- const auditEventEntity: AuditEventEntity = auditEventEntityFrom(event)
33
- const connection: DataSource = await this.dbConnection
34
- debug('Storing audit event', auditEventEntity)
35
- const createdResult: AuditEventEntity = await connection.getRepository(AuditEventEntity).save(auditEventEntity)
36
-
37
- return this.auditEventFrom(createdResult)
38
- }
39
-
40
- private auditEventFrom = (event: AuditEventEntity): AuditLoggingEvent => {
41
- return {
42
- id: event.id,
43
- description: event.description,
44
- timestamp: event.timestamp,
45
- level: event.level,
46
- correlationId: event.correlationId,
47
- actionType: event.actionType,
48
- actionSubType: event.actionSubType,
49
- initiatorType: event.initiatorType,
50
- partyAlias: event.partyAlias,
51
- partyCorrelationId: event.partyCorrelationId,
52
- partyCorrelationType: event.partyCorrelationType,
53
- subSystemType: event.subSystemType,
54
- system: event.system,
55
- systemAlias: event.systemAlias,
56
- systemCorrelationId: event.systemCorrelationId,
57
- systemCorrelationIdType: event.systemCorrelationIdType,
58
- ...(event.data && { data: JSON.parse(event.data) }),
59
- ...(event.diagnosticData && { diagnosticData: JSON.parse(event.diagnosticData) }),
60
- }
61
- }
62
- }
1
+ import Debug, { Debugger } from 'debug'
2
+ import { DataSource } from 'typeorm'
3
+ import { AuditLoggingEvent } from '@sphereon/ssi-sdk.core'
4
+ import { OrPromise } from '@sphereon/ssi-types'
5
+ import { AbstractEventLoggerStore } from './AbstractEventLoggerStore'
6
+ import { AuditEventEntity, auditEventEntityFrom } from '../entities/eventLogger/AuditEventEntity'
7
+ import { GetAuditEventsArgs, StoreAuditEventArgs } from '../types'
8
+
9
+ const debug: Debugger = Debug('sphereon:ssi-sdk:event-store')
10
+
11
+ export class EventLoggerStore extends AbstractEventLoggerStore {
12
+ private readonly dbConnection: OrPromise<DataSource>
13
+
14
+ constructor(dbConnection: OrPromise<DataSource>) {
15
+ super()
16
+ this.dbConnection = dbConnection
17
+ }
18
+
19
+ getAuditEvents = async (args?: GetAuditEventsArgs): Promise<Array<AuditLoggingEvent>> => {
20
+ const connection: DataSource = await this.dbConnection // TODO apply everywhere
21
+ debug('Getting audit events', args)
22
+ const result: Array<AuditEventEntity> = await connection.getRepository(AuditEventEntity).find({
23
+ ...(args?.filter && { where: args?.filter }),
24
+ })
25
+
26
+ return result.map((event: AuditEventEntity) => this.auditEventFrom(event))
27
+ }
28
+
29
+ storeAuditEvent = async (args: StoreAuditEventArgs): Promise<AuditLoggingEvent> => {
30
+ const { event } = args
31
+
32
+ const auditEventEntity: AuditEventEntity = auditEventEntityFrom(event)
33
+ const connection: DataSource = await this.dbConnection
34
+ debug('Storing audit event', auditEventEntity)
35
+ const createdResult: AuditEventEntity = await connection.getRepository(AuditEventEntity).save(auditEventEntity)
36
+
37
+ return this.auditEventFrom(createdResult)
38
+ }
39
+
40
+ private auditEventFrom = (event: AuditEventEntity): AuditLoggingEvent => {
41
+ return {
42
+ id: event.id,
43
+ description: event.description,
44
+ timestamp: event.timestamp,
45
+ level: event.level,
46
+ correlationId: event.correlationId,
47
+ actionType: event.actionType,
48
+ actionSubType: event.actionSubType,
49
+ initiatorType: event.initiatorType,
50
+ partyAlias: event.partyAlias,
51
+ partyCorrelationId: event.partyCorrelationId,
52
+ partyCorrelationType: event.partyCorrelationType,
53
+ subSystemType: event.subSystemType,
54
+ system: event.system,
55
+ systemAlias: event.systemAlias,
56
+ systemCorrelationId: event.systemCorrelationId,
57
+ systemCorrelationIdType: event.systemCorrelationIdType,
58
+ ...(event.data && { data: JSON.parse(event.data) }),
59
+ ...(event.diagnosticData && { diagnosticData: JSON.parse(event.diagnosticData) }),
60
+ }
61
+ }
62
+ }