@sphereon/ssi-sdk.data-store 0.34.1-feature.SSISDK.17.bitstring.sl.2 → 0.34.1-next.5
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/dist/index.cjs +498 -958
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -38
- package/dist/index.d.ts +6 -38
- package/dist/index.js +387 -847
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/__tests__/statusList.entities.test.ts +1 -58
- package/src/__tests__/statusList.store.test.ts +1 -63
- package/src/entities/statusList/StatusList2021EntryEntity.ts +2 -2
- package/src/entities/statusList/StatusListEntities.ts +5 -48
- package/src/index.ts +2 -12
- package/src/migrations/generic/index.ts +1 -2
- package/src/statusList/StatusListStore.ts +1 -3
- package/src/types/statusList/statusList.ts +2 -17
- package/src/utils/statusList/MappingUtils.ts +2 -36
- package/src/entities/statusList/BitstringStatusListEntryEntity.ts +0 -83
- package/src/migrations/generic/12-CreateBitstringStatusList.ts +0 -52
- package/src/migrations/postgres/1741895823000-CreateBitstringStatusList.ts +0 -54
- package/src/migrations/sqlite/1741895823001-CreateBitstringStatusList.ts +0 -103
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.data-store",
|
|
3
|
-
"version": "0.34.1-
|
|
3
|
+
"version": "0.34.1-next.5+34a84d73",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@sphereon/kmp-mdoc-core": "0.2.0-SNAPSHOT.26",
|
|
30
30
|
"@sphereon/pex": "5.0.0-unstable.28",
|
|
31
|
-
"@sphereon/ssi-sdk-ext.did-utils": "0.29.
|
|
32
|
-
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.29.
|
|
33
|
-
"@sphereon/ssi-sdk.agent-config": "0.34.1-
|
|
34
|
-
"@sphereon/ssi-sdk.core": "0.34.1-
|
|
35
|
-
"@sphereon/ssi-types": "0.34.1-
|
|
31
|
+
"@sphereon/ssi-sdk-ext.did-utils": "0.29.1-next.3",
|
|
32
|
+
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.29.1-next.3",
|
|
33
|
+
"@sphereon/ssi-sdk.agent-config": "0.34.1-next.5+34a84d73",
|
|
34
|
+
"@sphereon/ssi-sdk.core": "0.34.1-next.5+34a84d73",
|
|
35
|
+
"@sphereon/ssi-types": "0.34.1-next.5+34a84d73",
|
|
36
36
|
"@veramo/core": "4.2.0",
|
|
37
37
|
"@veramo/utils": "4.2.0",
|
|
38
38
|
"blakejs": "^1.2.1",
|
|
39
|
-
"class-validator": "
|
|
39
|
+
"class-validator": "0.14.1",
|
|
40
40
|
"dcql": "0.2.19",
|
|
41
41
|
"debug": "^4.3.5",
|
|
42
42
|
"typeorm": "0.3.20"
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"PostgreSQL",
|
|
66
66
|
"Contact Store"
|
|
67
67
|
],
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "34a84d731d3c2185e5b392d48dea9574d2674781"
|
|
69
69
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataSource } from 'typeorm'
|
|
2
2
|
import { DataSources } from '@sphereon/ssi-sdk.agent-config'
|
|
3
|
-
import {
|
|
3
|
+
import { DataStoreStatusListEntities, StatusListEntryEntity } from '../index'
|
|
4
4
|
import { DataStoreStatusListMigrations } from '../migrations'
|
|
5
5
|
import { OAuthStatusListEntity, StatusList2021Entity } from '../entities/statusList/StatusListEntities'
|
|
6
6
|
import { IIssuer, StatusListCredentialIdMode, StatusListDriverType } from '@sphereon/ssi-types'
|
|
@@ -18,8 +18,6 @@ describe('Status list entities tests', () => {
|
|
|
18
18
|
migrations: DataStoreStatusListMigrations,
|
|
19
19
|
synchronize: false,
|
|
20
20
|
entities: [...DataStoreStatusListEntities],
|
|
21
|
-
logger: 'advanced-console',
|
|
22
|
-
logging: ['query', 'error', 'schema', 'warn', 'info', 'log', 'migration'],
|
|
23
21
|
}).initialize()
|
|
24
22
|
await dbConnection.runMigrations()
|
|
25
23
|
expect(await dbConnection.showMigrations()).toBeFalsy()
|
|
@@ -216,59 +214,4 @@ describe('Status list entities tests', () => {
|
|
|
216
214
|
})
|
|
217
215
|
expect(foundEntry).toBeNull()
|
|
218
216
|
})
|
|
219
|
-
|
|
220
|
-
it('should save bitstring status list to database', async () => {
|
|
221
|
-
const statusList = new BitstringStatusListEntity()
|
|
222
|
-
statusList.id = 'bitstring-list-1'
|
|
223
|
-
statusList.correlationId = 'correlation-bitstring-1'
|
|
224
|
-
statusList.driverType = StatusListDriverType.AGENT_TYPEORM
|
|
225
|
-
statusList.length = 131072
|
|
226
|
-
statusList.credentialIdMode = StatusListCredentialIdMode.ISSUANCE
|
|
227
|
-
statusList.proofFormat = 'lds'
|
|
228
|
-
statusList.statusPurpose = 'revocation'
|
|
229
|
-
statusList.statusSize = 1
|
|
230
|
-
statusList.ttl = 3600000
|
|
231
|
-
statusList.validFrom = new Date('2024-01-01T00:00:00Z')
|
|
232
|
-
statusList.validUntil = new Date('2025-01-01T00:00:00Z')
|
|
233
|
-
statusList.issuer = 'did:example:789'
|
|
234
|
-
|
|
235
|
-
const fromDb = await dbConnection.getRepository(BitstringStatusListEntity).save(statusList)
|
|
236
|
-
expect(fromDb).toBeDefined()
|
|
237
|
-
expect(fromDb.id).toEqual(statusList.id)
|
|
238
|
-
expect(fromDb.statusPurpose).toEqual(statusList.statusPurpose)
|
|
239
|
-
expect(fromDb.statusSize).toEqual(statusList.statusSize)
|
|
240
|
-
expect(fromDb.ttl).toEqual(statusList.ttl)
|
|
241
|
-
expect(fromDb.validFrom).toEqual(statusList.validFrom)
|
|
242
|
-
expect(fromDb.validUntil).toEqual(statusList.validUntil)
|
|
243
|
-
})
|
|
244
|
-
|
|
245
|
-
it('should save bitstring status list entry to database', async () => {
|
|
246
|
-
const statusList = new BitstringStatusListEntity()
|
|
247
|
-
statusList.id = 'bitstring-list-1'
|
|
248
|
-
statusList.correlationId = 'correlation-bitstring-1'
|
|
249
|
-
statusList.driverType = StatusListDriverType.AGENT_TYPEORM
|
|
250
|
-
statusList.length = 131072
|
|
251
|
-
statusList.credentialIdMode = StatusListCredentialIdMode.ISSUANCE
|
|
252
|
-
statusList.proofFormat = 'lds'
|
|
253
|
-
statusList.statusPurpose = 'revocation'
|
|
254
|
-
statusList.issuer = 'did:example:789'
|
|
255
|
-
|
|
256
|
-
await dbConnection.getRepository(BitstringStatusListEntity).save(statusList)
|
|
257
|
-
|
|
258
|
-
const entry = new BitstringStatusListEntryEntity()
|
|
259
|
-
entry.statusList = statusList
|
|
260
|
-
entry.statusListIndex = 42
|
|
261
|
-
entry.credentialId = 'bitstring-credential-1'
|
|
262
|
-
entry.credentialHash = 'bitstring-hash-1'
|
|
263
|
-
entry.statusPurpose = 'revocation'
|
|
264
|
-
entry.statusSize = 1
|
|
265
|
-
entry.statusReference = 'https://example.org/status-ref'
|
|
266
|
-
|
|
267
|
-
const fromDb = await dbConnection.getRepository(BitstringStatusListEntryEntity).save(entry)
|
|
268
|
-
expect(fromDb).toBeDefined()
|
|
269
|
-
expect(fromDb.statusListIndex).toEqual(entry.statusListIndex)
|
|
270
|
-
expect(fromDb.statusPurpose).toEqual(entry.statusPurpose)
|
|
271
|
-
expect(fromDb.statusSize).toEqual(entry.statusSize)
|
|
272
|
-
expect(fromDb.statusReference).toEqual(entry.statusReference)
|
|
273
|
-
})
|
|
274
217
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataSource } from 'typeorm'
|
|
2
2
|
import { DataSources } from '@sphereon/ssi-sdk.agent-config'
|
|
3
|
-
import { DataStoreStatusListEntities
|
|
3
|
+
import { DataStoreStatusListEntities } from '../index'
|
|
4
4
|
import { DataStoreStatusListMigrations } from '../migrations'
|
|
5
5
|
import { StatusListStore } from '../statusList/StatusListStore'
|
|
6
6
|
import { IOAuthStatusListEntity, IStatusList2021Entity, IStatusListEntryEntity } from '../types'
|
|
@@ -230,66 +230,4 @@ describe('Status list store tests', () => {
|
|
|
230
230
|
|
|
231
231
|
await expect(statusListStore.getStatusList({ id: statusList.id })).rejects.toThrow(`No status list found for id ${statusList.id}`)
|
|
232
232
|
})
|
|
233
|
-
|
|
234
|
-
it('should store bitstring status list', async () => {
|
|
235
|
-
const statusList: IBitstringStatusListEntity = {
|
|
236
|
-
id: 'bitstring-list-1',
|
|
237
|
-
correlationId: 'correlation-bitstring-1',
|
|
238
|
-
driverType: StatusListDriverType.AGENT_TYPEORM,
|
|
239
|
-
length: 131072,
|
|
240
|
-
credentialIdMode: StatusListCredentialIdMode.ISSUANCE,
|
|
241
|
-
type: StatusListType.BitstringStatusList,
|
|
242
|
-
proofFormat: 'lds',
|
|
243
|
-
statusPurpose: 'revocation',
|
|
244
|
-
statusSize: 1,
|
|
245
|
-
ttl: 3600000,
|
|
246
|
-
validFrom: new Date('2024-01-01T00:00:00Z'),
|
|
247
|
-
validUntil: new Date('2025-01-01T00:00:00Z'),
|
|
248
|
-
issuer: 'did:example:789',
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
const result = await statusListStore.addStatusList(statusList)
|
|
252
|
-
expect(result).toBeDefined()
|
|
253
|
-
expect(result.id).toEqual(statusList.id)
|
|
254
|
-
expect((result as IBitstringStatusListEntity).statusPurpose).toEqual(statusList.statusPurpose)
|
|
255
|
-
expect((result as IBitstringStatusListEntity).ttl).toEqual(statusList.ttl)
|
|
256
|
-
})
|
|
257
|
-
|
|
258
|
-
it('should store and retrieve all three types of status lists', async () => {
|
|
259
|
-
const statusList2021: IStatusList2021Entity = {
|
|
260
|
-
id: 'test-list-1',
|
|
261
|
-
correlationId: 'correlation-1',
|
|
262
|
-
driverType: StatusListDriverType.AGENT_TYPEORM,
|
|
263
|
-
length: 100000,
|
|
264
|
-
credentialIdMode: StatusListCredentialIdMode.ISSUANCE,
|
|
265
|
-
type: StatusListType.StatusList2021,
|
|
266
|
-
proofFormat: 'jwt',
|
|
267
|
-
statusPurpose: 'revocation',
|
|
268
|
-
indexingDirection: 'rightToLeft',
|
|
269
|
-
issuer: 'did:example:123',
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
const bitstringStatusList: IBitstringStatusListEntity = {
|
|
273
|
-
id: 'bitstring-list-1',
|
|
274
|
-
correlationId: 'correlation-bitstring-1',
|
|
275
|
-
driverType: StatusListDriverType.AGENT_TYPEORM,
|
|
276
|
-
length: 131072,
|
|
277
|
-
credentialIdMode: StatusListCredentialIdMode.ISSUANCE,
|
|
278
|
-
type: StatusListType.BitstringStatusList,
|
|
279
|
-
proofFormat: 'lds',
|
|
280
|
-
statusPurpose: 'suspension',
|
|
281
|
-
ttl: 3600000,
|
|
282
|
-
issuer: 'did:example:789',
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
await statusListStore.addStatusList(statusList2021)
|
|
286
|
-
await statusListStore.addStatusList(bitstringStatusList)
|
|
287
|
-
|
|
288
|
-
const found2021 = await statusListStore.getStatusList({ id: statusList2021.id })
|
|
289
|
-
const foundBitstring = await statusListStore.getStatusList({ id: bitstringStatusList.id })
|
|
290
|
-
|
|
291
|
-
expect(found2021.type).toEqual(StatusListType.StatusList2021)
|
|
292
|
-
expect(foundBitstring.type).toEqual(StatusListType.BitstringStatusList)
|
|
293
|
-
expect((foundBitstring as IBitstringStatusListEntity).statusPurpose).toEqual('suspension')
|
|
294
|
-
})
|
|
295
233
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Validate } from 'class-validator'
|
|
2
2
|
import { BaseEntity, Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from 'typeorm'
|
|
3
3
|
import { IsNonEmptyStringConstraint } from '../validators'
|
|
4
|
-
import {
|
|
4
|
+
import { StatusListEntity } from './StatusListEntities'
|
|
5
5
|
|
|
6
6
|
@Entity('StatusListEntry')
|
|
7
7
|
// @Unique('uq_credential_statuslist', ['statusList', 'credentialId']) // disabled because one prop can be null
|
|
@@ -15,7 +15,7 @@ export class StatusListEntryEntity extends BaseEntity {
|
|
|
15
15
|
@Validate(IsNonEmptyStringConstraint, { message: 'Status list index is required' })
|
|
16
16
|
statusListIndex!: number
|
|
17
17
|
|
|
18
|
-
@ManyToOne(() =>
|
|
18
|
+
@ManyToOne(() => StatusListEntity, (statusList) => statusList.statusListEntries)
|
|
19
19
|
@JoinColumn({ name: 'statusListId' })
|
|
20
20
|
statusList!: StatusListEntity
|
|
21
21
|
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
BitstringStatusPurpose,
|
|
3
|
-
type CredentialProofFormat,
|
|
4
2
|
type IIssuer,
|
|
5
3
|
type StatusListCredential,
|
|
6
4
|
StatusListCredentialIdMode,
|
|
@@ -8,14 +6,12 @@ import {
|
|
|
8
6
|
type StatusListIndexingDirection,
|
|
9
7
|
StatusListType,
|
|
10
8
|
type StatusPurpose2021,
|
|
9
|
+
type CredentialProofFormat,
|
|
11
10
|
} from '@sphereon/ssi-types'
|
|
12
|
-
|
|
13
11
|
import typeorm from 'typeorm'
|
|
12
|
+
const { BaseEntity, ChildEntity, Column, Entity, OneToMany, PrimaryColumn, TableInheritance, Unique } = typeorm
|
|
14
13
|
import { StatusListEntryEntity } from './StatusList2021EntryEntity'
|
|
15
14
|
import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
|
|
16
|
-
import { BitstringStatusListEntryEntity } from './BitstringStatusListEntryEntity'
|
|
17
|
-
|
|
18
|
-
const { BaseEntity, ChildEntity, Column, Entity, OneToMany, PrimaryColumn, TableInheritance, Unique } = typeorm
|
|
19
15
|
|
|
20
16
|
@Entity('StatusList')
|
|
21
17
|
@Unique('UQ_correlationId', ['correlationId'])
|
|
@@ -92,6 +88,9 @@ export abstract class StatusListEntity extends BaseEntity {
|
|
|
92
88
|
},
|
|
93
89
|
})
|
|
94
90
|
statusListCredential?: StatusListCredential
|
|
91
|
+
|
|
92
|
+
@OneToMany((type) => StatusListEntryEntity, (entry) => entry.statusList)
|
|
93
|
+
statusListEntries!: StatusListEntryEntity[]
|
|
95
94
|
}
|
|
96
95
|
|
|
97
96
|
@ChildEntity(StatusListType.StatusList2021)
|
|
@@ -107,9 +106,6 @@ export class StatusList2021Entity extends StatusListEntity {
|
|
|
107
106
|
|
|
108
107
|
@Column({ type: 'varchar', name: 'statusPurpose', nullable: false, default: 'revocation' })
|
|
109
108
|
statusPurpose!: StatusPurpose2021
|
|
110
|
-
|
|
111
|
-
@OneToMany((type) => StatusListEntryEntity, (entry) => entry.statusList)
|
|
112
|
-
statusListEntries!: StatusListEntryEntity[]
|
|
113
109
|
}
|
|
114
110
|
|
|
115
111
|
@ChildEntity(StatusListType.OAuthStatusList)
|
|
@@ -119,42 +115,3 @@ export class OAuthStatusListEntity extends StatusListEntity {
|
|
|
119
115
|
@Column({ name: 'expiresAt', nullable: true, type: typeOrmDateTime() })
|
|
120
116
|
expiresAt?: Date
|
|
121
117
|
}
|
|
122
|
-
|
|
123
|
-
@ChildEntity(StatusListType.BitstringStatusList)
|
|
124
|
-
export class BitstringStatusListEntity extends StatusListEntity {
|
|
125
|
-
@Column({
|
|
126
|
-
type: 'varchar',
|
|
127
|
-
name: 'statusPurpose',
|
|
128
|
-
nullable: false,
|
|
129
|
-
transformer: {
|
|
130
|
-
from(value: string): BitstringStatusPurpose | BitstringStatusPurpose[] {
|
|
131
|
-
if (value?.includes(',')) {
|
|
132
|
-
return value.split(',').map((v) => v.trim() as BitstringStatusPurpose)
|
|
133
|
-
}
|
|
134
|
-
return value as BitstringStatusPurpose
|
|
135
|
-
},
|
|
136
|
-
to(value: BitstringStatusPurpose | BitstringStatusPurpose[]): string {
|
|
137
|
-
if (Array.isArray(value)) {
|
|
138
|
-
return value.join(',')
|
|
139
|
-
}
|
|
140
|
-
return value
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
})
|
|
144
|
-
statusPurpose!: BitstringStatusPurpose | BitstringStatusPurpose[]
|
|
145
|
-
|
|
146
|
-
@Column({ type: 'integer', name: 'statusSize', nullable: true, default: 1 })
|
|
147
|
-
statusSize?: number
|
|
148
|
-
|
|
149
|
-
@Column({ name: 'validFrom', nullable: true, type: typeOrmDateTime() })
|
|
150
|
-
validFrom?: Date
|
|
151
|
-
|
|
152
|
-
@Column({ name: 'validUntil', nullable: true, type: typeOrmDateTime() })
|
|
153
|
-
validUntil?: Date
|
|
154
|
-
|
|
155
|
-
@Column({ type: 'integer', name: 'ttl', nullable: true })
|
|
156
|
-
ttl?: number
|
|
157
|
-
|
|
158
|
-
@OneToMany((type) => BitstringStatusListEntryEntity, (entry) => entry.statusList)
|
|
159
|
-
statusListEntries!: BitstringStatusListEntryEntity[]
|
|
160
|
-
}
|
package/src/index.ts
CHANGED
|
@@ -16,9 +16,8 @@ import { ImageDimensionsEntity } from './entities/issuanceBranding/ImageDimensio
|
|
|
16
16
|
import { IssuerLocaleBrandingEntity } from './entities/issuanceBranding/IssuerLocaleBrandingEntity'
|
|
17
17
|
import { IssuerBrandingEntity } from './entities/issuanceBranding/IssuerBrandingEntity'
|
|
18
18
|
import { TextAttributesEntity } from './entities/issuanceBranding/TextAttributesEntity'
|
|
19
|
-
import {
|
|
19
|
+
import { OAuthStatusListEntity, StatusList2021Entity, StatusListEntity } from './entities/statusList/StatusListEntities'
|
|
20
20
|
import { StatusListEntryEntity } from './entities/statusList/StatusList2021EntryEntity'
|
|
21
|
-
import { BitstringStatusListEntryEntity } from './entities/statusList/BitstringStatusListEntryEntity'
|
|
22
21
|
import { MachineStateInfoEntity } from './entities/machineState/MachineStateInfoEntity'
|
|
23
22
|
// import { IStatusListEntity, IStatusListEntryEntity } from './types.'
|
|
24
23
|
import { PartyRelationshipEntity } from './entities/contact/PartyRelationshipEntity'
|
|
@@ -101,14 +100,7 @@ export const DataStoreIssuanceBrandingEntities = [
|
|
|
101
100
|
|
|
102
101
|
export const DataStorePresentationDefinitionEntities = [PresentationDefinitionItemEntity]
|
|
103
102
|
|
|
104
|
-
export const DataStoreStatusListEntities = [
|
|
105
|
-
StatusListEntity,
|
|
106
|
-
StatusList2021Entity,
|
|
107
|
-
OAuthStatusListEntity,
|
|
108
|
-
BitstringStatusListEntity,
|
|
109
|
-
BitstringStatusListEntryEntity,
|
|
110
|
-
StatusListEntryEntity,
|
|
111
|
-
]
|
|
103
|
+
export const DataStoreStatusListEntities = [StatusListEntity, StatusList2021Entity, OAuthStatusListEntity, StatusListEntryEntity]
|
|
112
104
|
|
|
113
105
|
export const DataStoreEventLoggerEntities = [AuditEventEntity]
|
|
114
106
|
|
|
@@ -151,10 +143,8 @@ export {
|
|
|
151
143
|
PhysicalAddressEntity,
|
|
152
144
|
StatusListEntity,
|
|
153
145
|
StatusListEntryEntity,
|
|
154
|
-
BitstringStatusListEntryEntity,
|
|
155
146
|
OAuthStatusListEntity,
|
|
156
147
|
StatusList2021Entity,
|
|
157
|
-
BitstringStatusListEntity,
|
|
158
148
|
AuditEventEntity,
|
|
159
149
|
DigitalCredentialEntity,
|
|
160
150
|
MachineStateInfoEntity,
|
|
@@ -9,7 +9,6 @@ import { CreateContacts1708525189000 } from './8-CreateContacts'
|
|
|
9
9
|
import { CreateContacts1715761125000 } from './9-CreateContacts'
|
|
10
10
|
import { CreatePresentationDefinitions1716533767523 } from './10-CreatePresentationDefinitions'
|
|
11
11
|
import { FixCredentialClaimsReferencesUuid1741895822987 } from './11-FixCredentialClaimsReferenceUuid'
|
|
12
|
-
import { CreateBitstringStatusList1741895823000 } from './12-CreateBitstringStatusList'
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* The migrations array that SHOULD be used when initializing a TypeORM database connection.
|
|
@@ -27,7 +26,7 @@ export const DataStoreContactMigrations = [
|
|
|
27
26
|
CreateContacts1715761125000,
|
|
28
27
|
]
|
|
29
28
|
export const DataStoreIssuanceBrandingMigrations = [CreateIssuanceBranding1659463079429, FixCredentialClaimsReferencesUuid1741895822987]
|
|
30
|
-
export const DataStoreStatusListMigrations = [CreateStatusList1693866470000
|
|
29
|
+
export const DataStoreStatusListMigrations = [CreateStatusList1693866470000]
|
|
31
30
|
export const DataStoreEventLoggerMigrations = [CreateAuditEvents1701635835330]
|
|
32
31
|
export const DataStoreDigitalCredentialMigrations = [CreateDigitalCredential1708525189000]
|
|
33
32
|
export const DataStoreMachineStateMigrations = [CreateMachineStateStore1708098041262]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type OrPromise, StatusListType } from '@sphereon/ssi-types'
|
|
2
2
|
import Debug from 'debug'
|
|
3
3
|
import { DataSource, In, type Repository } from 'typeorm'
|
|
4
|
-
import {
|
|
4
|
+
import { OAuthStatusListEntity, StatusList2021Entity, StatusListEntity } from '../entities/statusList/StatusListEntities'
|
|
5
5
|
import { StatusListEntryEntity } from '../entities/statusList/StatusList2021EntryEntity'
|
|
6
6
|
import type {
|
|
7
7
|
IAddStatusListArgs,
|
|
@@ -268,8 +268,6 @@ export class StatusListStore implements IStatusListStore {
|
|
|
268
268
|
return dataSource.getRepository(StatusList2021Entity)
|
|
269
269
|
case StatusListType.OAuthStatusList:
|
|
270
270
|
return dataSource.getRepository(OAuthStatusListEntity)
|
|
271
|
-
case StatusListType.BitstringStatusList:
|
|
272
|
-
return dataSource.getRepository(BitstringStatusListEntity)
|
|
273
271
|
default:
|
|
274
272
|
return dataSource.getRepository(StatusListEntity)
|
|
275
273
|
}
|
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
-
BitstringStatusPurpose,
|
|
3
|
-
type CredentialProofFormat,
|
|
4
2
|
IIssuer,
|
|
5
|
-
RequireOneOf,
|
|
6
3
|
StatusListCredential,
|
|
7
4
|
StatusListCredentialIdMode,
|
|
8
5
|
StatusListDriverType,
|
|
9
6
|
StatusListIndexingDirection,
|
|
10
7
|
StatusListType,
|
|
11
8
|
StatusPurpose2021,
|
|
9
|
+
type CredentialProofFormat,
|
|
10
|
+
RequireOneOf,
|
|
12
11
|
} from '@sphereon/ssi-types'
|
|
13
12
|
import { StatusListEntity } from '../../entities/statusList/StatusListEntities'
|
|
14
13
|
|
|
15
|
-
export type BitstringStatus = {
|
|
16
|
-
status: string
|
|
17
|
-
message?: string
|
|
18
|
-
[x: string]: any
|
|
19
|
-
}
|
|
20
|
-
|
|
21
14
|
export interface IStatusListEntity {
|
|
22
15
|
id: string
|
|
23
16
|
correlationId: string
|
|
@@ -40,14 +33,6 @@ export interface IOAuthStatusListEntity extends IStatusListEntity {
|
|
|
40
33
|
expiresAt?: Date
|
|
41
34
|
}
|
|
42
35
|
|
|
43
|
-
export interface IBitstringStatusListEntity extends IStatusListEntity {
|
|
44
|
-
statusPurpose: BitstringStatusPurpose | BitstringStatusPurpose[]
|
|
45
|
-
statusSize?: number
|
|
46
|
-
validFrom?: Date
|
|
47
|
-
validUntil?: Date
|
|
48
|
-
ttl?: number
|
|
49
|
-
}
|
|
50
|
-
|
|
51
36
|
export type IStatusListEntryEntity = RequireOneOf<
|
|
52
37
|
{
|
|
53
38
|
statusList: StatusListEntity
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
BitstringStatusListEntity,
|
|
4
|
-
OAuthStatusListEntity,
|
|
5
|
-
StatusList2021Entity,
|
|
6
|
-
StatusListEntity,
|
|
7
|
-
} from '../../entities/statusList/StatusListEntities'
|
|
1
|
+
import { IOAuthStatusListEntity, IStatusList2021Entity, IStatusListEntity } from '../../types'
|
|
2
|
+
import { OAuthStatusListEntity, StatusList2021Entity, StatusListEntity } from '../../entities/statusList/StatusListEntities'
|
|
8
3
|
import { StatusListType } from '@sphereon/ssi-types'
|
|
9
4
|
import { replaceNullWithUndefined } from '../FormattingUtils'
|
|
10
5
|
|
|
@@ -37,23 +32,6 @@ export const statusListEntityFrom = (args: IStatusListEntity): StatusListEntity
|
|
|
37
32
|
return entity
|
|
38
33
|
}
|
|
39
34
|
|
|
40
|
-
if (args.type === StatusListType.BitstringStatusList) {
|
|
41
|
-
const entity = new BitstringStatusListEntity()
|
|
42
|
-
const bitstringsl = args as IBitstringStatusListEntity
|
|
43
|
-
entity.statusPurpose = bitstringsl.statusPurpose
|
|
44
|
-
entity.statusSize = bitstringsl.statusSize
|
|
45
|
-
entity.validFrom = bitstringsl.validFrom
|
|
46
|
-
entity.validUntil = bitstringsl.validUntil
|
|
47
|
-
entity.ttl = bitstringsl.ttl
|
|
48
|
-
setBaseFields(entity, args)
|
|
49
|
-
Object.defineProperty(entity, 'type', {
|
|
50
|
-
value: StatusListType.BitstringStatusList,
|
|
51
|
-
enumerable: true,
|
|
52
|
-
configurable: true,
|
|
53
|
-
})
|
|
54
|
-
return entity
|
|
55
|
-
}
|
|
56
|
-
|
|
57
35
|
throw new Error(`Invalid status list type ${args.type}`)
|
|
58
36
|
}
|
|
59
37
|
|
|
@@ -78,18 +56,6 @@ export const statusListFrom = (entity: StatusListEntity): IStatusListEntity => {
|
|
|
78
56
|
return replaceNullWithUndefined(result)
|
|
79
57
|
}
|
|
80
58
|
|
|
81
|
-
if (entity instanceof BitstringStatusListEntity) {
|
|
82
|
-
const result: IBitstringStatusListEntity = {
|
|
83
|
-
...getBaseFields(entity),
|
|
84
|
-
type: StatusListType.BitstringStatusList,
|
|
85
|
-
statusPurpose: entity.statusPurpose,
|
|
86
|
-
statusSize: entity.statusSize,
|
|
87
|
-
validFrom: entity.validFrom,
|
|
88
|
-
validUntil: entity.validUntil,
|
|
89
|
-
ttl: entity.ttl,
|
|
90
|
-
}
|
|
91
|
-
return replaceNullWithUndefined(result)
|
|
92
|
-
}
|
|
93
59
|
throw new Error(`Invalid status list type ${typeof entity}`)
|
|
94
60
|
}
|
|
95
61
|
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { Validate } from 'class-validator'
|
|
2
|
-
import { BaseEntity, Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from 'typeorm'
|
|
3
|
-
import { IsNonEmptyStringConstraint } from '../validators'
|
|
4
|
-
import { BitstringStatusListEntity } from './StatusListEntities'
|
|
5
|
-
import { BitstringStatusPurpose } from '@sphereon/ssi-types'
|
|
6
|
-
import { BitstringStatus } from '../../types'
|
|
7
|
-
|
|
8
|
-
@Entity('BitstringStatusListEntry')
|
|
9
|
-
export class BitstringStatusListEntryEntity extends BaseEntity {
|
|
10
|
-
@PrimaryColumn({ name: 'statusListId', type: 'varchar', nullable: false, unique: false })
|
|
11
|
-
@Validate(IsNonEmptyStringConstraint, { message: 'Status list id is required' })
|
|
12
|
-
statusListId!: string
|
|
13
|
-
|
|
14
|
-
@PrimaryColumn({ name: 'statusListIndex', type: 'integer', nullable: false, unique: false })
|
|
15
|
-
statusListIndex!: number
|
|
16
|
-
|
|
17
|
-
@ManyToOne(() => BitstringStatusListEntity, (statusList) => statusList.statusListEntries)
|
|
18
|
-
@JoinColumn({ name: 'statusListId' })
|
|
19
|
-
statusList!: BitstringStatusListEntity
|
|
20
|
-
|
|
21
|
-
@Column({ name: 'credentialId', type: 'text', nullable: true })
|
|
22
|
-
credentialId?: string
|
|
23
|
-
|
|
24
|
-
@Column({ name: 'credentialHash', length: 128, type: 'varchar', nullable: true, unique: false })
|
|
25
|
-
credentialHash?: string
|
|
26
|
-
|
|
27
|
-
@Column({ name: 'correlationId', length: 255, type: 'varchar', nullable: true, unique: false })
|
|
28
|
-
entryCorrelationId?: string
|
|
29
|
-
|
|
30
|
-
@Column({ type: 'varchar', name: 'statusPurpose', nullable: false })
|
|
31
|
-
statusPurpose!: BitstringStatusPurpose
|
|
32
|
-
|
|
33
|
-
@Column({ type: 'integer', name: 'statusSize', nullable: true, default: 1 })
|
|
34
|
-
statusSize?: number
|
|
35
|
-
|
|
36
|
-
@Column({
|
|
37
|
-
type: 'text',
|
|
38
|
-
name: 'statusMessage',
|
|
39
|
-
nullable: true,
|
|
40
|
-
transformer: {
|
|
41
|
-
from(value: string): Array<BitstringStatus> | undefined {
|
|
42
|
-
if (!value) {
|
|
43
|
-
return undefined
|
|
44
|
-
}
|
|
45
|
-
return JSON.parse(value)
|
|
46
|
-
},
|
|
47
|
-
to(value: Array<BitstringStatus> | undefined): string | undefined {
|
|
48
|
-
if (!value) {
|
|
49
|
-
return undefined
|
|
50
|
-
}
|
|
51
|
-
return JSON.stringify(value)
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
})
|
|
55
|
-
statusMessage?: Array<BitstringStatus>
|
|
56
|
-
|
|
57
|
-
@Column({
|
|
58
|
-
type: 'text',
|
|
59
|
-
name: 'statusReference',
|
|
60
|
-
nullable: true,
|
|
61
|
-
transformer: {
|
|
62
|
-
from(value: string): string | string[] | undefined {
|
|
63
|
-
if (!value) {
|
|
64
|
-
return undefined
|
|
65
|
-
}
|
|
66
|
-
if (value.startsWith('[')) {
|
|
67
|
-
return JSON.parse(value)
|
|
68
|
-
}
|
|
69
|
-
return value
|
|
70
|
-
},
|
|
71
|
-
to(value: string | string[] | undefined): string | undefined {
|
|
72
|
-
if (!value) {
|
|
73
|
-
return undefined
|
|
74
|
-
}
|
|
75
|
-
if (Array.isArray(value)) {
|
|
76
|
-
return JSON.stringify(value)
|
|
77
|
-
}
|
|
78
|
-
return value
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
})
|
|
82
|
-
statusReference?: string | string[]
|
|
83
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { DatabaseType, MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
-
import Debug from 'debug'
|
|
3
|
-
import { CreateBitstringStatusListPG1741895823000 } from '../postgres/1741895823000-CreateBitstringStatusList'
|
|
4
|
-
import { CreateBitstringStatusListSqlite1741895823001 } from '../sqlite/1741895823001-CreateBitstringStatusList'
|
|
5
|
-
|
|
6
|
-
const debug: Debug.Debugger = Debug('sphereon:ssi-sdk:migrations')
|
|
7
|
-
|
|
8
|
-
export class CreateBitstringStatusList1741895823000 implements MigrationInterface {
|
|
9
|
-
name = 'CreateBitstringStatusList1741895823000'
|
|
10
|
-
|
|
11
|
-
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
12
|
-
debug('migration: creating bitstring status list tables')
|
|
13
|
-
const dbType: DatabaseType = queryRunner.connection.driver.options.type
|
|
14
|
-
switch (dbType) {
|
|
15
|
-
case 'postgres': {
|
|
16
|
-
const mig = new CreateBitstringStatusListPG1741895823000()
|
|
17
|
-
await mig.up(queryRunner)
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
case 'sqlite':
|
|
21
|
-
case 'expo':
|
|
22
|
-
case 'react-native': {
|
|
23
|
-
const mig = new CreateBitstringStatusListSqlite1741895823001()
|
|
24
|
-
await mig.up(queryRunner)
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
default:
|
|
28
|
-
return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`)
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
33
|
-
debug('migration: dropping bitstring status list tables')
|
|
34
|
-
const dbType: DatabaseType = queryRunner.connection.driver.options.type
|
|
35
|
-
switch (dbType) {
|
|
36
|
-
case 'postgres': {
|
|
37
|
-
const mig = new CreateBitstringStatusListPG1741895823000()
|
|
38
|
-
await mig.down(queryRunner)
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
case 'sqlite':
|
|
42
|
-
case 'expo':
|
|
43
|
-
case 'react-native': {
|
|
44
|
-
const mig = new CreateBitstringStatusListSqlite1741895823001()
|
|
45
|
-
await mig.down(queryRunner)
|
|
46
|
-
return
|
|
47
|
-
}
|
|
48
|
-
default:
|
|
49
|
-
return Promise.reject(`Migrations only supported for sqlite and postgres. Was ${dbType}`)
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
export class CreateBitstringStatusListPG1741895823000 implements MigrationInterface {
|
|
4
|
-
name = 'CreateBitstringStatusList1741895823000'
|
|
5
|
-
|
|
6
|
-
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
-
// Add BitstringStatusList columns to StatusList table
|
|
8
|
-
await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "statusSize" integer DEFAULT 1`)
|
|
9
|
-
await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "ttl" integer`)
|
|
10
|
-
await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "validFrom" TIMESTAMP`)
|
|
11
|
-
await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "validUntil" TIMESTAMP`)
|
|
12
|
-
|
|
13
|
-
// Update type enum constraint to include BitstringStatusList
|
|
14
|
-
await queryRunner.query(`ALTER TABLE "StatusList" DROP CONSTRAINT IF EXISTS "CHK_StatusList_type"`)
|
|
15
|
-
await queryRunner.query(
|
|
16
|
-
`ALTER TABLE "StatusList" ADD CONSTRAINT "CHK_StatusList_type" CHECK ("type" IN ('StatusList2021', 'OAuthStatusList', 'BitstringStatusList'))`,
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
// Create BitstringStatusListEntry table
|
|
20
|
-
await queryRunner.query(`
|
|
21
|
-
CREATE TABLE "BitstringStatusListEntry" (
|
|
22
|
-
"statusListId" character varying NOT NULL,
|
|
23
|
-
"statusListIndex" integer NOT NULL,
|
|
24
|
-
"credentialId" text,
|
|
25
|
-
"credentialHash" character varying(128),
|
|
26
|
-
"correlationId" character varying(255),
|
|
27
|
-
"statusPurpose" character varying NOT NULL,
|
|
28
|
-
"statusSize" integer DEFAULT 1,
|
|
29
|
-
"statusMessage" text,
|
|
30
|
-
"statusReference" text,
|
|
31
|
-
CONSTRAINT "PK_BitstringStatusListEntry" PRIMARY KEY ("statusListId", "statusListIndex")
|
|
32
|
-
)
|
|
33
|
-
`)
|
|
34
|
-
|
|
35
|
-
await queryRunner.query(`
|
|
36
|
-
ALTER TABLE "BitstringStatusListEntry"
|
|
37
|
-
ADD CONSTRAINT "FK_BitstringStatusListEntry_statusListId"
|
|
38
|
-
FOREIGN KEY ("statusListId") REFERENCES "StatusList"("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
39
|
-
`)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
43
|
-
await queryRunner.query(`ALTER TABLE "BitstringStatusListEntry" DROP CONSTRAINT "FK_BitstringStatusListEntry_statusListId"`)
|
|
44
|
-
await queryRunner.query(`DROP TABLE "BitstringStatusListEntry"`)
|
|
45
|
-
|
|
46
|
-
await queryRunner.query(`ALTER TABLE "StatusList" DROP CONSTRAINT "CHK_StatusList_type"`)
|
|
47
|
-
await queryRunner.query(`ALTER TABLE "StatusList" ADD CONSTRAINT "CHK_StatusList_type" CHECK ("type" IN ('StatusList2021', 'OAuthStatusList'))`)
|
|
48
|
-
|
|
49
|
-
await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "validUntil"`)
|
|
50
|
-
await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "validFrom"`)
|
|
51
|
-
await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "ttl"`)
|
|
52
|
-
await queryRunner.query(`ALTER TABLE "StatusList" DROP COLUMN "statusSize"`)
|
|
53
|
-
}
|
|
54
|
-
}
|