@sphereon/ssi-sdk.data-store 0.30.1-unstable.4 → 0.30.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/README.md +77 -77
- package/dist/contact/ContactStore.d.ts.map +1 -1
- package/dist/digitalCredential/DigitalCredentialStore.d.ts.map +1 -1
- package/dist/eventLogger/EventLoggerStore.d.ts.map +1 -1
- package/dist/issuanceBranding/IssuanceBrandingStore.d.ts.map +1 -1
- package/dist/migrations/internal-migrations-ormconfig.d.ts.map +1 -1
- package/dist/migrations/postgres/1708525189001-CreateDigitalCredential.js +33 -33
- package/dist/migrations/postgres/1708797018115-CreateMachineStateStore.js +16 -16
- package/dist/migrations/postgres/1715761125001-CreateContacts.js +33 -33
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js +12 -12
- package/dist/migrations/sqlite/1708525189002-CreateDigitalCredential.js +32 -32
- package/dist/migrations/sqlite/1708796002272-CreateMachineStateStore.js +15 -15
- package/dist/migrations/sqlite/1710438363002-CreateContacts.js +13 -13
- package/dist/migrations/sqlite/1715761125002-CreateContacts.js +32 -32
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js +9 -9
- package/dist/presentationDefinition/PDStore.d.ts.map +1 -1
- package/dist/utils/SortingUtils.d.ts.map +1 -1
- package/dist/utils/contact/MappingUtils.d.ts.map +1 -1
- package/dist/utils/digitalCredential/MappingUtils.d.ts.map +1 -1
- package/dist/utils/digitalCredential/MappingUtils.js +4 -4
- package/dist/utils/digitalCredential/MappingUtils.js.map +1 -1
- package/dist/utils/presentationDefinition/MappingUtils.js +2 -2
- package/dist/utils/presentationDefinition/MappingUtils.js.map +1 -1
- package/package.json +8 -8
- package/src/__tests__/contact.entities.test.ts +2642 -2642
- package/src/__tests__/contact.store.test.ts +2649 -2649
- package/src/__tests__/digitalCredential.entities.test.ts +274 -274
- package/src/__tests__/digitalCredential.store.test.ts +330 -330
- package/src/__tests__/eventLogger.entities.test.ts +76 -76
- package/src/__tests__/eventLogger.store.test.ts +130 -130
- package/src/__tests__/issuanceBranding.entities.test.ts +846 -846
- package/src/__tests__/issuanceBranding.store.test.ts +1886 -1886
- package/src/__tests__/machineState.entities.test.ts +53 -53
- package/src/__tests__/machineState.store.test.ts +176 -176
- package/src/__tests__/pd-manager.entities.test.ts +73 -73
- package/src/__tests__/pd-manager.store.test.ts +193 -193
- package/src/contact/AbstractContactStore.ts +71 -71
- package/src/contact/ContactStore.ts +768 -768
- package/src/digitalCredential/AbstractDigitalCredentialStore.ts +21 -21
- package/src/digitalCredential/DigitalCredentialStore.ts +189 -189
- package/src/entities/contact/BaseContactEntity.ts +51 -51
- package/src/entities/contact/ConnectionEntity.ts +35 -35
- package/src/entities/contact/ContactMetadataItemEntity.ts +51 -51
- package/src/entities/contact/CorrelationIdentifierEntity.ts +43 -43
- package/src/entities/contact/DidAuthConfigEntity.ts +20 -20
- package/src/entities/contact/ElectronicAddressEntity.ts +70 -70
- package/src/entities/contact/IdentityEntity.ts +107 -107
- package/src/entities/contact/IdentityMetadataItemEntity.ts +48 -48
- package/src/entities/contact/NaturalPersonEntity.ts +44 -44
- package/src/entities/contact/OpenIdConfigEntity.ts +32 -32
- package/src/entities/contact/OrganizationEntity.ts +35 -35
- package/src/entities/contact/PartyEntity.ts +117 -117
- package/src/entities/contact/PartyRelationshipEntity.ts +68 -68
- package/src/entities/contact/PartyTypeEntity.ts +63 -63
- package/src/entities/contact/PhysicalAddressEntity.ts +95 -95
- package/src/entities/digitalCredential/DigitalCredentialEntity.ts +98 -98
- package/src/entities/eventLogger/AuditEventEntity.ts +92 -92
- package/src/entities/issuanceBranding/BackgroundAttributesEntity.ts +42 -42
- package/src/entities/issuanceBranding/BaseLocaleBrandingEntity.ts +87 -87
- package/src/entities/issuanceBranding/CredentialBrandingEntity.ts +79 -79
- package/src/entities/issuanceBranding/CredentialLocaleBrandingEntity.ts +33 -33
- package/src/entities/issuanceBranding/ImageAttributesEntity.ts +57 -57
- package/src/entities/issuanceBranding/ImageDimensionsEntity.ts +22 -22
- package/src/entities/issuanceBranding/IssuerBrandingEntity.ts +73 -73
- package/src/entities/issuanceBranding/IssuerLocaleBrandingEntity.ts +33 -33
- package/src/entities/issuanceBranding/TextAttributesEntity.ts +31 -31
- package/src/entities/machineState/MachineStateInfoEntity.ts +59 -59
- package/src/entities/presentationDefinition/PresentationDefinitionItemEntity.ts +44 -44
- package/src/entities/statusList2021/StatusList2021Entity.ts +96 -96
- package/src/entities/statusList2021/StatusList2021EntryEntity.ts +29 -29
- package/src/eventLogger/AbstractEventLoggerStore.ts +7 -7
- package/src/eventLogger/EventLoggerStore.ts +62 -62
- package/src/index.ts +160 -160
- package/src/issuanceBranding/IssuanceBrandingStore.ts +559 -559
- package/src/machineState/IAbstractMachineStateStore.ts +65 -65
- package/src/machineState/MachineStateStore.ts +149 -149
- package/src/migrations/generic/1-CreateContacts.ts +66 -66
- package/src/migrations/generic/10-CreatePresentationDefinitions.ts +66 -66
- package/src/migrations/generic/2-CreateIssuanceBranding.ts +64 -64
- package/src/migrations/generic/3-CreateContacts.ts +66 -66
- package/src/migrations/generic/4-CreateStatusList.ts +54 -54
- package/src/migrations/generic/5-CreateAuditEvents.ts +66 -66
- package/src/migrations/generic/6-CreateDigitalCredential.ts +66 -66
- package/src/migrations/generic/7-CreateMachineStateStore.ts +66 -66
- package/src/migrations/generic/8-CreateContacts.ts +66 -66
- package/src/migrations/generic/9-CreateContacts.ts +66 -66
- package/src/migrations/generic/index.ts +43 -43
- package/src/migrations/index.ts +10 -10
- package/src/migrations/postgres/1659463079428-CreateContacts.ts +63 -63
- package/src/migrations/postgres/1685628974232-CreateIssuanceBranding.ts +85 -85
- package/src/migrations/postgres/1690925872592-CreateContacts.ts +158 -158
- package/src/migrations/postgres/1693866470001-CreateStatusList.ts +24 -24
- package/src/migrations/postgres/1701634812183-CreateAuditEvents.ts +33 -33
- package/src/migrations/postgres/1708525189001-CreateDigitalCredential.ts +61 -61
- package/src/migrations/postgres/1708797018115-CreateMachineStateStore.ts +29 -29
- package/src/migrations/postgres/1710438363001-CreateContacts.ts +63 -63
- package/src/migrations/postgres/1715761125001-CreateContacts.ts +60 -60
- package/src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts +25 -25
- package/src/migrations/sqlite/1659463069549-CreateContacts.ts +110 -110
- package/src/migrations/sqlite/1685628973231-CreateIssuanceBranding.ts +119 -119
- package/src/migrations/sqlite/1690925872693-CreateContacts.ts +228 -228
- package/src/migrations/sqlite/1693866470000-CreateStatusList.ts +24 -24
- package/src/migrations/sqlite/1701634819487-CreateAuditEvents.ts +15 -15
- package/src/migrations/sqlite/1708525189002-CreateDigitalCredential.ts +46 -46
- package/src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts +28 -28
- package/src/migrations/sqlite/1710438363002-CreateContacts.ts +83 -83
- package/src/migrations/sqlite/1715761125002-CreateContacts.ts +59 -59
- package/src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts +24 -24
- package/src/presentationDefinition/AbstractPDStore.ts +20 -20
- package/src/presentationDefinition/PDStore.ts +185 -185
- package/src/statusList/IStatusListStore.ts +44 -44
- package/src/statusList/StatusListStore.ts +236 -236
- package/src/types/contact/IAbstractContactStore.ts +161 -161
- package/src/types/contact/contact.ts +295 -295
- package/src/types/digitalCredential/IAbstractDigitalCredentialStore.ts +42 -42
- package/src/types/digitalCredential/digitalCredential.ts +102 -102
- package/src/types/eventLogger/IAbstractEventLoggerStore.ts +12 -12
- package/src/types/eventLogger/eventLogger.ts +3 -3
- package/src/types/index.ts +14 -14
- package/src/types/machineState/IAbstractMachineStateStore.ts +68 -68
- package/src/types/presentationDefinition/IAbstractPDStore.ts +25 -25
- package/src/types/presentationDefinition/presentationDefinition.ts +17 -17
- package/src/utils/SortingUtils.ts +16 -16
- package/src/utils/contact/MappingUtils.ts +506 -506
- package/src/utils/digitalCredential/MappingUtils.ts +160 -160
- package/src/utils/hasher.ts +19 -19
- package/src/utils/presentationDefinition/MappingUtils.ts +52 -52
- package/dist/entities/contact/IMetadataEntity.d.ts +0 -8
- package/dist/entities/contact/IMetadataEntity.d.ts.map +0 -1
- package/dist/entities/contact/IMetadataEntity.js +0 -2
- package/dist/entities/contact/IMetadataEntity.js.map +0 -1
- package/dist/migrations/generic/8-CreatePresentationDefinitions.d.ts +0 -7
- package/dist/migrations/generic/8-CreatePresentationDefinitions.d.ts.map +0 -1
- package/dist/migrations/generic/8-CreatePresentationDefinitions.js +0 -78
- package/dist/migrations/generic/8-CreatePresentationDefinitions.js.map +0 -1
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { BaseEntity, BeforeInsert, BeforeUpdate, Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'
|
|
2
|
-
import { IsNotEmpty } from 'class-validator'
|
|
3
|
-
import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
|
|
4
|
-
|
|
5
|
-
@Entity('PresentationDefinitionItem')
|
|
6
|
-
@Index(['version'], { unique: false })
|
|
7
|
-
export class PresentationDefinitionItemEntity extends BaseEntity {
|
|
8
|
-
@PrimaryGeneratedColumn('uuid')
|
|
9
|
-
id!: string
|
|
10
|
-
|
|
11
|
-
@Column({ name: 'definition_id', length: 255, type: 'varchar', nullable: false, unique: false })
|
|
12
|
-
@IsNotEmpty({ message: 'A blank definition id field is not allowed' })
|
|
13
|
-
definitionId!: string
|
|
14
|
-
|
|
15
|
-
@Column({ name: 'version', length: 255, type: 'varchar', nullable: false, unique: false })
|
|
16
|
-
@IsNotEmpty({ message: 'A blank version field is not allowed' })
|
|
17
|
-
version!: string
|
|
18
|
-
|
|
19
|
-
@Column({ name: 'tenant_id', length: 255, type: 'varchar', nullable: true, unique: false })
|
|
20
|
-
tenantId?: string
|
|
21
|
-
|
|
22
|
-
@Column({ name: 'purpose', length: 255, type: 'varchar', nullable: true, unique: false })
|
|
23
|
-
purpose?: string
|
|
24
|
-
|
|
25
|
-
@Column({ name: 'name', length: 255, type: 'varchar', nullable: true, unique: false })
|
|
26
|
-
name?: string
|
|
27
|
-
|
|
28
|
-
@Column({ name: 'definition_payload', type: 'text', nullable: false, unique: false })
|
|
29
|
-
@IsNotEmpty({ message: 'A blank definition payload field is not allowed' })
|
|
30
|
-
definitionPayload!: string
|
|
31
|
-
|
|
32
|
-
@CreateDateColumn({ name: 'created_at', nullable: false, type: typeOrmDateTime() })
|
|
33
|
-
createdAt!: Date
|
|
34
|
-
|
|
35
|
-
@UpdateDateColumn({ name: 'last_updated_at', nullable: false, type: typeOrmDateTime() })
|
|
36
|
-
lastUpdatedAt!: Date
|
|
37
|
-
|
|
38
|
-
// By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
|
|
39
|
-
@BeforeInsert()
|
|
40
|
-
@BeforeUpdate()
|
|
41
|
-
updateUpdatedDate(): void {
|
|
42
|
-
this.lastUpdatedAt = new Date()
|
|
43
|
-
}
|
|
44
|
-
}
|
|
1
|
+
import { BaseEntity, BeforeInsert, BeforeUpdate, Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'
|
|
2
|
+
import { IsNotEmpty } from 'class-validator'
|
|
3
|
+
import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
|
|
4
|
+
|
|
5
|
+
@Entity('PresentationDefinitionItem')
|
|
6
|
+
@Index(['version'], { unique: false })
|
|
7
|
+
export class PresentationDefinitionItemEntity extends BaseEntity {
|
|
8
|
+
@PrimaryGeneratedColumn('uuid')
|
|
9
|
+
id!: string
|
|
10
|
+
|
|
11
|
+
@Column({ name: 'definition_id', length: 255, type: 'varchar', nullable: false, unique: false })
|
|
12
|
+
@IsNotEmpty({ message: 'A blank definition id field is not allowed' })
|
|
13
|
+
definitionId!: string
|
|
14
|
+
|
|
15
|
+
@Column({ name: 'version', length: 255, type: 'varchar', nullable: false, unique: false })
|
|
16
|
+
@IsNotEmpty({ message: 'A blank version field is not allowed' })
|
|
17
|
+
version!: string
|
|
18
|
+
|
|
19
|
+
@Column({ name: 'tenant_id', length: 255, type: 'varchar', nullable: true, unique: false })
|
|
20
|
+
tenantId?: string
|
|
21
|
+
|
|
22
|
+
@Column({ name: 'purpose', length: 255, type: 'varchar', nullable: true, unique: false })
|
|
23
|
+
purpose?: string
|
|
24
|
+
|
|
25
|
+
@Column({ name: 'name', length: 255, type: 'varchar', nullable: true, unique: false })
|
|
26
|
+
name?: string
|
|
27
|
+
|
|
28
|
+
@Column({ name: 'definition_payload', type: 'text', nullable: false, unique: false })
|
|
29
|
+
@IsNotEmpty({ message: 'A blank definition payload field is not allowed' })
|
|
30
|
+
definitionPayload!: string
|
|
31
|
+
|
|
32
|
+
@CreateDateColumn({ name: 'created_at', nullable: false, type: typeOrmDateTime() })
|
|
33
|
+
createdAt!: Date
|
|
34
|
+
|
|
35
|
+
@UpdateDateColumn({ name: 'last_updated_at', nullable: false, type: typeOrmDateTime() })
|
|
36
|
+
lastUpdatedAt!: Date
|
|
37
|
+
|
|
38
|
+
// By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
|
|
39
|
+
@BeforeInsert()
|
|
40
|
+
@BeforeUpdate()
|
|
41
|
+
updateUpdatedDate(): void {
|
|
42
|
+
this.lastUpdatedAt = new Date()
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -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', type: 'integer', 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', type: 'integer', 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,29 +1,29 @@
|
|
|
1
|
-
import { Validate } from 'class-validator'
|
|
2
|
-
import { BaseEntity, Column, Entity, ManyToOne, PrimaryColumn } from 'typeorm'
|
|
3
|
-
import { IsNonEmptyStringConstraint } from '../validators'
|
|
4
|
-
import { StatusListEntity } from './StatusList2021Entity'
|
|
5
|
-
|
|
6
|
-
@Entity('StatusListEntry')
|
|
7
|
-
// @Unique('uq_credential_statuslist', ['statusList', 'credentialId']) // disabled because one prop can be null
|
|
8
|
-
// @Unique('uq_credentialHash_statuslistId', ['statusList', 'credentialHash']) // disabled because one prop can be null
|
|
9
|
-
export class StatusListEntryEntity extends BaseEntity {
|
|
10
|
-
@PrimaryColumn({ name: 'statusListId', type: 'varchar' })
|
|
11
|
-
@ManyToOne(() => StatusListEntity, (statusList) => statusList.statusListEntries)
|
|
12
|
-
statusList!: StatusListEntity
|
|
13
|
-
|
|
14
|
-
@PrimaryColumn({ name: 'statusListIndex', type: 'integer', nullable: false, unique: false })
|
|
15
|
-
@Validate(IsNonEmptyStringConstraint, { message: 'Status list index is required' })
|
|
16
|
-
statusListIndex!: number
|
|
17
|
-
|
|
18
|
-
@Column({ name: 'credentialId', type: 'text', nullable: true })
|
|
19
|
-
credentialId?: string
|
|
20
|
-
|
|
21
|
-
@Column({ name: 'credentialHash', length: 128, type: 'varchar', nullable: true, unique: false })
|
|
22
|
-
credentialHash?: string
|
|
23
|
-
|
|
24
|
-
@Column({ name: 'correlationId', length: 255, type: 'varchar', nullable: true, unique: false })
|
|
25
|
-
correlationId?: string
|
|
26
|
-
|
|
27
|
-
@Column({ name: 'value', length: 50, type: 'varchar', nullable: true, unique: false })
|
|
28
|
-
value?: string
|
|
29
|
-
}
|
|
1
|
+
import { Validate } from 'class-validator'
|
|
2
|
+
import { BaseEntity, Column, Entity, ManyToOne, PrimaryColumn } from 'typeorm'
|
|
3
|
+
import { IsNonEmptyStringConstraint } from '../validators'
|
|
4
|
+
import { StatusListEntity } from './StatusList2021Entity'
|
|
5
|
+
|
|
6
|
+
@Entity('StatusListEntry')
|
|
7
|
+
// @Unique('uq_credential_statuslist', ['statusList', 'credentialId']) // disabled because one prop can be null
|
|
8
|
+
// @Unique('uq_credentialHash_statuslistId', ['statusList', 'credentialHash']) // disabled because one prop can be null
|
|
9
|
+
export class StatusListEntryEntity extends BaseEntity {
|
|
10
|
+
@PrimaryColumn({ name: 'statusListId', type: 'varchar' })
|
|
11
|
+
@ManyToOne(() => StatusListEntity, (statusList) => statusList.statusListEntries)
|
|
12
|
+
statusList!: StatusListEntity
|
|
13
|
+
|
|
14
|
+
@PrimaryColumn({ name: 'statusListIndex', type: 'integer', nullable: false, unique: false })
|
|
15
|
+
@Validate(IsNonEmptyStringConstraint, { message: 'Status list index is required' })
|
|
16
|
+
statusListIndex!: number
|
|
17
|
+
|
|
18
|
+
@Column({ name: 'credentialId', type: 'text', nullable: true })
|
|
19
|
+
credentialId?: string
|
|
20
|
+
|
|
21
|
+
@Column({ name: 'credentialHash', length: 128, type: 'varchar', nullable: true, unique: false })
|
|
22
|
+
credentialHash?: string
|
|
23
|
+
|
|
24
|
+
@Column({ name: 'correlationId', length: 255, type: 'varchar', nullable: true, unique: false })
|
|
25
|
+
correlationId?: string
|
|
26
|
+
|
|
27
|
+
@Column({ name: 'value', length: 50, type: 'varchar', nullable: true, unique: false })
|
|
28
|
+
value?: string
|
|
29
|
+
}
|
|
@@ -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
|
+
}
|