@sphereon/ssi-sdk.data-store 0.34.0 → 0.34.1-feature.SSISDK.17.bitstring.sl.7
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 +906 -446
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -5
- package/dist/index.d.ts +40 -5
- package/dist/index.js +848 -388
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/__tests__/statusList.entities.test.ts +58 -1
- package/src/__tests__/statusList.store.test.ts +63 -1
- package/src/entities/statusList/BitstringStatusListEntryEntity.ts +82 -0
- package/src/entities/statusList/StatusList2021EntryEntity.ts +2 -2
- package/src/entities/statusList/StatusListEntities.ts +47 -5
- package/src/index.ts +12 -2
- package/src/migrations/generic/12-CreateBitstringStatusList.ts +52 -0
- package/src/migrations/generic/index.ts +2 -1
- package/src/migrations/postgres/1741895823000-CreateBitstringStatusList.ts +54 -0
- package/src/migrations/sqlite/1741895823001-CreateBitstringStatusList.ts +102 -0
- package/src/statusList/StatusListStore.ts +4 -2
- package/src/types/index.ts +1 -0
- package/src/types/statusList/bitstringTypes.ts +7 -0
- package/src/types/statusList/statusList.ts +12 -2
- package/src/utils/statusList/MappingUtils.ts +40 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.data-store",
|
|
3
|
-
"version": "0.34.
|
|
3
|
+
"version": "0.34.1-feature.SSISDK.17.bitstring.sl.7+eb4b995a",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"@sphereon/pex": "5.0.0-unstable.28",
|
|
31
31
|
"@sphereon/ssi-sdk-ext.did-utils": "0.29.0",
|
|
32
32
|
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.29.0",
|
|
33
|
-
"@sphereon/ssi-sdk.agent-config": "0.34.
|
|
34
|
-
"@sphereon/ssi-sdk.core": "0.34.
|
|
35
|
-
"@sphereon/ssi-types": "0.34.
|
|
33
|
+
"@sphereon/ssi-sdk.agent-config": "0.34.1-feature.SSISDK.17.bitstring.sl.7+eb4b995a",
|
|
34
|
+
"@sphereon/ssi-sdk.core": "0.34.1-feature.SSISDK.17.bitstring.sl.7+eb4b995a",
|
|
35
|
+
"@sphereon/ssi-types": "0.34.1-feature.SSISDK.17.bitstring.sl.7+eb4b995a",
|
|
36
36
|
"@veramo/core": "4.2.0",
|
|
37
37
|
"@veramo/utils": "4.2.0",
|
|
38
38
|
"blakejs": "^1.2.1",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"PostgreSQL",
|
|
66
66
|
"Contact Store"
|
|
67
67
|
],
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "eb4b995abb68a5aee39ad40c3ee996f2e1dff8da"
|
|
69
69
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataSource } from 'typeorm'
|
|
2
2
|
import { DataSources } from '@sphereon/ssi-sdk.agent-config'
|
|
3
|
-
import { DataStoreStatusListEntities, StatusListEntryEntity } from '../index'
|
|
3
|
+
import { BitstringStatusListEntity, BitstringStatusListEntryEntity, 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,6 +18,8 @@ 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'],
|
|
21
23
|
}).initialize()
|
|
22
24
|
await dbConnection.runMigrations()
|
|
23
25
|
expect(await dbConnection.showMigrations()).toBeFalsy()
|
|
@@ -214,4 +216,59 @@ describe('Status list entities tests', () => {
|
|
|
214
216
|
})
|
|
215
217
|
expect(foundEntry).toBeNull()
|
|
216
218
|
})
|
|
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.bitsPerStatus = 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.bitsPerStatus).toEqual(statusList.bitsPerStatus)
|
|
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.bitsPerStatus = 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.bitsPerStatus).toEqual(entry.bitsPerStatus)
|
|
272
|
+
expect(fromDb.statusReference).toEqual(entry.statusReference)
|
|
273
|
+
})
|
|
217
274
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataSource } from 'typeorm'
|
|
2
2
|
import { DataSources } from '@sphereon/ssi-sdk.agent-config'
|
|
3
|
-
import { DataStoreStatusListEntities } from '../index'
|
|
3
|
+
import { DataStoreStatusListEntities, IBitstringStatusListEntity } from '../index'
|
|
4
4
|
import { DataStoreStatusListMigrations } from '../migrations'
|
|
5
5
|
import { StatusListStore } from '../statusList/StatusListStore'
|
|
6
6
|
import { IOAuthStatusListEntity, IStatusList2021Entity, IStatusListEntryEntity } from '../types'
|
|
@@ -230,4 +230,66 @@ 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
|
+
bitsPerStatus: 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
|
+
})
|
|
233
295
|
})
|
|
@@ -0,0 +1,82 @@
|
|
|
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 { BitstringStatus } from '../../types/statusList/bitstringTypes'
|
|
6
|
+
|
|
7
|
+
@Entity('BitstringStatusListEntry')
|
|
8
|
+
export class BitstringStatusListEntryEntity extends BaseEntity {
|
|
9
|
+
@PrimaryColumn({ name: 'statusListId', type: 'varchar', nullable: false, unique: false })
|
|
10
|
+
@Validate(IsNonEmptyStringConstraint, { message: 'Status list id is required' })
|
|
11
|
+
statusListId!: string
|
|
12
|
+
|
|
13
|
+
@PrimaryColumn({ name: 'statusListIndex', type: 'integer', nullable: false, unique: false })
|
|
14
|
+
statusListIndex!: number
|
|
15
|
+
|
|
16
|
+
@ManyToOne(() => BitstringStatusListEntity, (statusList) => statusList.statusListEntries)
|
|
17
|
+
@JoinColumn({ name: 'statusListId' })
|
|
18
|
+
statusList!: BitstringStatusListEntity
|
|
19
|
+
|
|
20
|
+
@Column({ name: 'credentialId', type: 'text', nullable: true })
|
|
21
|
+
credentialId?: string
|
|
22
|
+
|
|
23
|
+
@Column({ name: 'credentialHash', length: 128, type: 'varchar', nullable: true, unique: false })
|
|
24
|
+
credentialHash?: string
|
|
25
|
+
|
|
26
|
+
@Column({ name: 'correlationId', length: 255, type: 'varchar', nullable: true, unique: false })
|
|
27
|
+
entryCorrelationId?: string
|
|
28
|
+
|
|
29
|
+
@Column({ type: 'varchar', name: 'statusPurpose', nullable: false })
|
|
30
|
+
statusPurpose!: string
|
|
31
|
+
|
|
32
|
+
@Column({ type: 'integer', name: 'bitsPerStatus', nullable: true, default: 1 })
|
|
33
|
+
bitsPerStatus?: number
|
|
34
|
+
|
|
35
|
+
@Column({
|
|
36
|
+
type: 'text',
|
|
37
|
+
name: 'statusMessage',
|
|
38
|
+
nullable: true,
|
|
39
|
+
transformer: {
|
|
40
|
+
from(value: string): Array<BitstringStatus> | undefined {
|
|
41
|
+
if (!value) {
|
|
42
|
+
return undefined
|
|
43
|
+
}
|
|
44
|
+
return JSON.parse(value)
|
|
45
|
+
},
|
|
46
|
+
to(value: Array<BitstringStatus> | undefined): string | undefined {
|
|
47
|
+
if (!value) {
|
|
48
|
+
return undefined
|
|
49
|
+
}
|
|
50
|
+
return JSON.stringify(value)
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
statusMessage?: Array<BitstringStatus>
|
|
55
|
+
|
|
56
|
+
@Column({
|
|
57
|
+
type: 'text',
|
|
58
|
+
name: 'statusReference',
|
|
59
|
+
nullable: true,
|
|
60
|
+
transformer: {
|
|
61
|
+
from(value: string): string | string[] | undefined {
|
|
62
|
+
if (!value) {
|
|
63
|
+
return undefined
|
|
64
|
+
}
|
|
65
|
+
if (value.startsWith('[')) {
|
|
66
|
+
return JSON.parse(value)
|
|
67
|
+
}
|
|
68
|
+
return value
|
|
69
|
+
},
|
|
70
|
+
to(value: string | string[] | undefined): string | undefined {
|
|
71
|
+
if (!value) {
|
|
72
|
+
return undefined
|
|
73
|
+
}
|
|
74
|
+
if (Array.isArray(value)) {
|
|
75
|
+
return JSON.stringify(value)
|
|
76
|
+
}
|
|
77
|
+
return value
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
})
|
|
81
|
+
statusReference?: string | string[]
|
|
82
|
+
}
|
|
@@ -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 { StatusListEntity } from './StatusListEntities'
|
|
4
|
+
import { StatusList2021Entity, 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(() => StatusList2021Entity, (statusList) => statusList.statusListEntries)
|
|
19
19
|
@JoinColumn({ name: 'statusListId' })
|
|
20
20
|
statusList!: StatusListEntity
|
|
21
21
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
type CredentialProofFormat,
|
|
2
3
|
type IIssuer,
|
|
3
4
|
type StatusListCredential,
|
|
4
5
|
StatusListCredentialIdMode,
|
|
@@ -6,12 +7,14 @@ import {
|
|
|
6
7
|
type StatusListIndexingDirection,
|
|
7
8
|
StatusListType,
|
|
8
9
|
type StatusPurpose2021,
|
|
9
|
-
type CredentialProofFormat,
|
|
10
10
|
} from '@sphereon/ssi-types'
|
|
11
|
+
|
|
11
12
|
import typeorm from 'typeorm'
|
|
12
|
-
const { BaseEntity, ChildEntity, Column, Entity, OneToMany, PrimaryColumn, TableInheritance, Unique } = typeorm
|
|
13
13
|
import { StatusListEntryEntity } from './StatusList2021EntryEntity'
|
|
14
14
|
import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
|
|
15
|
+
import { BitstringStatusListEntryEntity } from './BitstringStatusListEntryEntity'
|
|
16
|
+
|
|
17
|
+
const { BaseEntity, ChildEntity, Column, Entity, OneToMany, PrimaryColumn, TableInheritance, Unique } = typeorm
|
|
15
18
|
|
|
16
19
|
@Entity('StatusList')
|
|
17
20
|
@Unique('UQ_correlationId', ['correlationId'])
|
|
@@ -88,9 +91,6 @@ export abstract class StatusListEntity extends BaseEntity {
|
|
|
88
91
|
},
|
|
89
92
|
})
|
|
90
93
|
statusListCredential?: StatusListCredential
|
|
91
|
-
|
|
92
|
-
@OneToMany((type) => StatusListEntryEntity, (entry) => entry.statusList)
|
|
93
|
-
statusListEntries!: StatusListEntryEntity[]
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
@ChildEntity(StatusListType.StatusList2021)
|
|
@@ -106,6 +106,9 @@ export class StatusList2021Entity extends StatusListEntity {
|
|
|
106
106
|
|
|
107
107
|
@Column({ type: 'varchar', name: 'statusPurpose', nullable: false, default: 'revocation' })
|
|
108
108
|
statusPurpose!: StatusPurpose2021
|
|
109
|
+
|
|
110
|
+
@OneToMany((type) => StatusListEntryEntity, (entry) => entry.statusList)
|
|
111
|
+
statusListEntries!: StatusListEntryEntity[]
|
|
109
112
|
}
|
|
110
113
|
|
|
111
114
|
@ChildEntity(StatusListType.OAuthStatusList)
|
|
@@ -115,3 +118,42 @@ export class OAuthStatusListEntity extends StatusListEntity {
|
|
|
115
118
|
@Column({ name: 'expiresAt', nullable: true, type: typeOrmDateTime() })
|
|
116
119
|
expiresAt?: Date
|
|
117
120
|
}
|
|
121
|
+
|
|
122
|
+
@ChildEntity(StatusListType.BitstringStatusList)
|
|
123
|
+
export class BitstringStatusListEntity extends StatusListEntity {
|
|
124
|
+
@Column({
|
|
125
|
+
type: 'varchar',
|
|
126
|
+
name: 'statusPurpose',
|
|
127
|
+
nullable: false,
|
|
128
|
+
transformer: {
|
|
129
|
+
from(value: string): string | string[] {
|
|
130
|
+
if (value?.includes(',')) {
|
|
131
|
+
return value.split(',').map((v) => v.trim() as string)
|
|
132
|
+
}
|
|
133
|
+
return value as string
|
|
134
|
+
},
|
|
135
|
+
to(value: string | string[]): string {
|
|
136
|
+
if (Array.isArray(value)) {
|
|
137
|
+
return value.join(',')
|
|
138
|
+
}
|
|
139
|
+
return value
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
})
|
|
143
|
+
statusPurpose!: string | string[]
|
|
144
|
+
|
|
145
|
+
@Column({ type: 'integer', name: 'bitsPerStatus', nullable: false })
|
|
146
|
+
bitsPerStatus?: number
|
|
147
|
+
|
|
148
|
+
@Column({ name: 'validFrom', nullable: true, type: typeOrmDateTime() })
|
|
149
|
+
validFrom?: Date
|
|
150
|
+
|
|
151
|
+
@Column({ name: 'validUntil', nullable: true, type: typeOrmDateTime() })
|
|
152
|
+
validUntil?: Date
|
|
153
|
+
|
|
154
|
+
@Column({ type: 'integer', name: 'ttl', nullable: true })
|
|
155
|
+
ttl?: number
|
|
156
|
+
|
|
157
|
+
@OneToMany((type) => BitstringStatusListEntryEntity, (entry) => entry.statusList)
|
|
158
|
+
statusListEntries!: BitstringStatusListEntryEntity[]
|
|
159
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -16,8 +16,9 @@ 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 { OAuthStatusListEntity, StatusList2021Entity, StatusListEntity } from './entities/statusList/StatusListEntities'
|
|
19
|
+
import { BitstringStatusListEntity, OAuthStatusListEntity, StatusList2021Entity, StatusListEntity } from './entities/statusList/StatusListEntities'
|
|
20
20
|
import { StatusListEntryEntity } from './entities/statusList/StatusList2021EntryEntity'
|
|
21
|
+
import { BitstringStatusListEntryEntity } from './entities/statusList/BitstringStatusListEntryEntity'
|
|
21
22
|
import { MachineStateInfoEntity } from './entities/machineState/MachineStateInfoEntity'
|
|
22
23
|
// import { IStatusListEntity, IStatusListEntryEntity } from './types.'
|
|
23
24
|
import { PartyRelationshipEntity } from './entities/contact/PartyRelationshipEntity'
|
|
@@ -100,7 +101,14 @@ export const DataStoreIssuanceBrandingEntities = [
|
|
|
100
101
|
|
|
101
102
|
export const DataStorePresentationDefinitionEntities = [PresentationDefinitionItemEntity]
|
|
102
103
|
|
|
103
|
-
export const DataStoreStatusListEntities = [
|
|
104
|
+
export const DataStoreStatusListEntities = [
|
|
105
|
+
StatusListEntity,
|
|
106
|
+
StatusList2021Entity,
|
|
107
|
+
OAuthStatusListEntity,
|
|
108
|
+
BitstringStatusListEntity,
|
|
109
|
+
BitstringStatusListEntryEntity,
|
|
110
|
+
StatusListEntryEntity,
|
|
111
|
+
]
|
|
104
112
|
|
|
105
113
|
export const DataStoreEventLoggerEntities = [AuditEventEntity]
|
|
106
114
|
|
|
@@ -143,8 +151,10 @@ export {
|
|
|
143
151
|
PhysicalAddressEntity,
|
|
144
152
|
StatusListEntity,
|
|
145
153
|
StatusListEntryEntity,
|
|
154
|
+
BitstringStatusListEntryEntity,
|
|
146
155
|
OAuthStatusListEntity,
|
|
147
156
|
StatusList2021Entity,
|
|
157
|
+
BitstringStatusListEntity,
|
|
148
158
|
AuditEventEntity,
|
|
149
159
|
DigitalCredentialEntity,
|
|
150
160
|
MachineStateInfoEntity,
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
}
|
|
@@ -9,6 +9,7 @@ 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'
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* The migrations array that SHOULD be used when initializing a TypeORM database connection.
|
|
@@ -26,7 +27,7 @@ export const DataStoreContactMigrations = [
|
|
|
26
27
|
CreateContacts1715761125000,
|
|
27
28
|
]
|
|
28
29
|
export const DataStoreIssuanceBrandingMigrations = [CreateIssuanceBranding1659463079429, FixCredentialClaimsReferencesUuid1741895822987]
|
|
29
|
-
export const DataStoreStatusListMigrations = [CreateStatusList1693866470000]
|
|
30
|
+
export const DataStoreStatusListMigrations = [CreateStatusList1693866470000, CreateBitstringStatusList1741895823000]
|
|
30
31
|
export const DataStoreEventLoggerMigrations = [CreateAuditEvents1701635835330]
|
|
31
32
|
export const DataStoreDigitalCredentialMigrations = [CreateDigitalCredential1708525189000]
|
|
32
33
|
export const DataStoreMachineStateMigrations = [CreateMachineStateStore1708098041262]
|
|
@@ -0,0 +1,54 @@
|
|
|
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 "bitsPerStatus" 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
|
+
"bitsPerStatus" 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 "bitsPerStatus"`)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
export class CreateBitstringStatusListSqlite1741895823001 implements MigrationInterface {
|
|
4
|
+
name = 'CreateBitstringStatusList1741895823000'
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
// Update StatusList table to include BitstringStatusList type and columns
|
|
8
|
+
await queryRunner.query(`
|
|
9
|
+
CREATE TABLE "temporary_StatusList" (
|
|
10
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
11
|
+
"correlationId" varchar NOT NULL,
|
|
12
|
+
"length" integer NOT NULL,
|
|
13
|
+
"issuer" text NOT NULL,
|
|
14
|
+
"type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList', 'BitstringStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
|
|
15
|
+
"driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
|
|
16
|
+
"credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
|
|
17
|
+
"proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
|
|
18
|
+
"indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
|
|
19
|
+
"statusPurpose" varchar,
|
|
20
|
+
"statusListCredential" text,
|
|
21
|
+
"expiresAt" datetime,
|
|
22
|
+
"bitsPerStatus" integer DEFAULT (1),
|
|
23
|
+
"ttl" integer,
|
|
24
|
+
"validFrom" datetime,
|
|
25
|
+
"validUntil" datetime,
|
|
26
|
+
CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
|
|
27
|
+
)
|
|
28
|
+
`)
|
|
29
|
+
|
|
30
|
+
await queryRunner.query(`
|
|
31
|
+
INSERT INTO "temporary_StatusList"(
|
|
32
|
+
"id", "correlationId", "length", "issuer", "type", "driverType",
|
|
33
|
+
"credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
|
|
34
|
+
"statusListCredential", "bitsPerStatus", "expiresAt"
|
|
35
|
+
)
|
|
36
|
+
SELECT
|
|
37
|
+
"id", "correlationId", "length", "issuer", "type", "driverType",
|
|
38
|
+
"credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
|
|
39
|
+
"statusListCredential", "bitsPerStatus", "expiresAt"
|
|
40
|
+
FROM "StatusList"
|
|
41
|
+
`)
|
|
42
|
+
|
|
43
|
+
await queryRunner.query(`DROP TABLE "StatusList"`)
|
|
44
|
+
await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`)
|
|
45
|
+
|
|
46
|
+
// Create BitstringStatusListEntry table
|
|
47
|
+
await queryRunner.query(`
|
|
48
|
+
CREATE TABLE "BitstringStatusListEntry" (
|
|
49
|
+
"statusListId" varchar NOT NULL,
|
|
50
|
+
"statusListIndex" integer NOT NULL,
|
|
51
|
+
"credentialId" text,
|
|
52
|
+
"credentialHash" varchar(128),
|
|
53
|
+
"correlationId" varchar(255),
|
|
54
|
+
"statusPurpose" varchar NOT NULL,
|
|
55
|
+
"bitsPerStatus" integer DEFAULT (1),
|
|
56
|
+
"statusMessage" text,
|
|
57
|
+
"statusReference" text,
|
|
58
|
+
PRIMARY KEY ("statusListId", "statusListIndex")
|
|
59
|
+
)
|
|
60
|
+
`)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
64
|
+
await queryRunner.query(`DROP TABLE "BitstringStatusListEntry"`)
|
|
65
|
+
|
|
66
|
+
await queryRunner.query(`
|
|
67
|
+
CREATE TABLE "temporary_StatusList" (
|
|
68
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
69
|
+
"correlationId" varchar NOT NULL,
|
|
70
|
+
"length" integer NOT NULL,
|
|
71
|
+
"issuer" text NOT NULL,
|
|
72
|
+
"type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
|
|
73
|
+
"driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
|
|
74
|
+
"credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
|
|
75
|
+
"proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt') ) NOT NULL DEFAULT ('lds'),
|
|
76
|
+
"indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
|
|
77
|
+
"statusPurpose" varchar,
|
|
78
|
+
"statusListCredential" text,
|
|
79
|
+
"bitsPerStatus" integer,
|
|
80
|
+
"expiresAt" datetime,
|
|
81
|
+
CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
|
|
82
|
+
)
|
|
83
|
+
`)
|
|
84
|
+
|
|
85
|
+
await queryRunner.query(`
|
|
86
|
+
INSERT INTO "temporary_StatusList"(
|
|
87
|
+
"id", "correlationId", "length", "issuer", "type", "driverType",
|
|
88
|
+
"credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
|
|
89
|
+
"statusListCredential", "bitsPerStatus", "expiresAt"
|
|
90
|
+
)
|
|
91
|
+
SELECT
|
|
92
|
+
"id", "correlationId", "length", "issuer",
|
|
93
|
+
CASE WHEN "type" = 'BitstringStatusList' THEN 'StatusList2021' ELSE "type" END,
|
|
94
|
+
"driverType", "credentialIdMode", "proofFormat", "indexingDirection",
|
|
95
|
+
"statusPurpose", "statusListCredential", "bitsPerStatus", "expiresAt"
|
|
96
|
+
FROM "StatusList"
|
|
97
|
+
`)
|
|
98
|
+
|
|
99
|
+
await queryRunner.query(`DROP TABLE "StatusList"`)
|
|
100
|
+
await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -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 { OAuthStatusListEntity, StatusList2021Entity, StatusListEntity } from '../entities/statusList/StatusListEntities'
|
|
4
|
+
import { BitstringStatusListEntity, OAuthStatusListEntity, StatusList2021Entity, StatusListEntity } from '../entities/statusList/StatusListEntities'
|
|
5
5
|
import { StatusListEntryEntity } from '../entities/statusList/StatusList2021EntryEntity'
|
|
6
6
|
import type {
|
|
7
7
|
IAddStatusListArgs,
|
|
@@ -45,7 +45,7 @@ export class StatusListStore implements IStatusListStore {
|
|
|
45
45
|
const results = (
|
|
46
46
|
await repo.find({
|
|
47
47
|
where: {
|
|
48
|
-
statusList,
|
|
48
|
+
statusListId: statusList.id,
|
|
49
49
|
statusListIndex: In(statusListIndex),
|
|
50
50
|
},
|
|
51
51
|
})
|
|
@@ -268,6 +268,8 @@ 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)
|
|
271
273
|
default:
|
|
272
274
|
return dataSource.getRepository(StatusListEntity)
|
|
273
275
|
}
|
package/src/types/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './presentationDefinition/presentationDefinition'
|
|
|
6
6
|
export * from './presentationDefinition/IAbstractPDStore'
|
|
7
7
|
export * from './validation/validation'
|
|
8
8
|
export * from './statusList/statusList'
|
|
9
|
+
export * from './statusList/bitstringTypes'
|
|
9
10
|
export * from './statusList/IAbstractStatusListStore'
|
|
10
11
|
export * from './eventLogger/IAbstractEventLoggerStore'
|
|
11
12
|
export * from './eventLogger/eventLogger'
|