@sphereon/ssi-sdk.vc-status-list-issuer-drivers 0.34.1-feature.SSISDK.17.bitstring.sl.2 → 0.34.1-feature.SSISDK.17.bitstring.sl.25
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 +144 -87
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +170 -47
- package/dist/index.d.ts +170 -47
- package/dist/index.js +139 -82
- package/dist/index.js.map +1 -1
- package/package.json +11 -10
- package/src/drivers.ts +225 -100
- package/src/status-list-adapters.ts +2 -3
- package/src/types.ts +35 -18
package/src/drivers.ts
CHANGED
|
@@ -1,27 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StatusList Driver Implementation for TypeORM/Agent Data Sources
|
|
3
|
+
*
|
|
4
|
+
* This module provides the database-backed implementation of the IStatusListDriver interface,
|
|
5
|
+
* handling persistence and retrieval of status list credentials and entries using TypeORM.
|
|
6
|
+
* It delegates status list format-specific operations to the functions layer while managing
|
|
7
|
+
* database interactions, driver configuration, and entity lifecycle.
|
|
8
|
+
*
|
|
9
|
+
* Key responsibilities:
|
|
10
|
+
* - Database connection and store management
|
|
11
|
+
* - Status list CRUD operations
|
|
12
|
+
* - Status list entry management
|
|
13
|
+
* - Random index generation for new entries
|
|
14
|
+
* - Integration with multiple data sources
|
|
15
|
+
*
|
|
16
|
+
* @author Sphereon International B.V.
|
|
17
|
+
* @since 2024
|
|
18
|
+
*/
|
|
19
|
+
|
|
1
20
|
import { DataSources } from '@sphereon/ssi-sdk.agent-config'
|
|
2
21
|
import {
|
|
3
|
-
|
|
22
|
+
BitstringStatusListEntryCredentialStatus,
|
|
23
|
+
IAddStatusListArgs,
|
|
4
24
|
IAddStatusListEntryArgs,
|
|
25
|
+
IBitstringStatusListEntryEntity,
|
|
5
26
|
IGetStatusListEntryByCredentialIdArgs,
|
|
6
27
|
IGetStatusListEntryByIndexArgs,
|
|
7
|
-
IStatusListEntity,
|
|
8
28
|
IStatusListEntryEntity,
|
|
9
29
|
StatusListEntity,
|
|
10
30
|
StatusListStore,
|
|
11
31
|
} from '@sphereon/ssi-sdk.data-store'
|
|
12
32
|
import {
|
|
13
|
-
|
|
33
|
+
createCredentialStatusFromStatusList,
|
|
34
|
+
extractCredentialDetails,
|
|
14
35
|
StatusList2021EntryCredentialStatus,
|
|
15
|
-
statusListCredentialToDetails,
|
|
16
36
|
StatusListOAuthEntryCredentialStatus,
|
|
17
37
|
StatusListResult,
|
|
38
|
+
toStatusListDetails,
|
|
18
39
|
} from '@sphereon/ssi-sdk.vc-status-list'
|
|
19
|
-
import { StatusListCredentialIdMode, StatusListDriverType
|
|
40
|
+
import { StatusListCredentialIdMode, StatusListDriverType } from '@sphereon/ssi-types'
|
|
20
41
|
import { DataSource } from 'typeorm'
|
|
21
|
-
import {
|
|
42
|
+
import {
|
|
43
|
+
ICreateStatusListArgs,
|
|
44
|
+
IGetRandomNewStatusListIndexArgs,
|
|
45
|
+
IGetStatusListArgs,
|
|
46
|
+
IGetStatusListLengthArgs,
|
|
47
|
+
IStatusListDriver,
|
|
48
|
+
IUpdateStatusListArgs,
|
|
49
|
+
} from './types'
|
|
22
50
|
import { statusListResultToEntity } from './status-list-adapters'
|
|
23
|
-
import { OAuthStatusListEntity, StatusList2021Entity } from '@sphereon/ssi-sdk.data-store'
|
|
24
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Configuration options for status list management
|
|
54
|
+
*/
|
|
25
55
|
export interface StatusListManagementOptions {
|
|
26
56
|
id?: string
|
|
27
57
|
correlationId?: string
|
|
@@ -31,14 +61,25 @@ export interface StatusListManagementOptions {
|
|
|
31
61
|
|
|
32
62
|
export type DriverOptions = TypeORMOptions
|
|
33
63
|
|
|
64
|
+
/**
|
|
65
|
+
* TypeORM-specific configuration options
|
|
66
|
+
*/
|
|
34
67
|
export interface TypeORMOptions {
|
|
35
68
|
dbName?: string
|
|
36
69
|
}
|
|
37
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Filesystem-specific configuration options
|
|
73
|
+
*/
|
|
38
74
|
export interface FilesystemOptions {
|
|
39
75
|
path: string // The base path where statusList Credentials will be persisted. Should be a folder and thus not include the VC/StatusList itself
|
|
40
76
|
}
|
|
41
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Creates status list management options for TypeORM driver
|
|
80
|
+
* @param args - Configuration parameters including id, correlationId, and database name
|
|
81
|
+
* @returns StatusListManagementOptions configured for TypeORM
|
|
82
|
+
*/
|
|
42
83
|
export function getOptions(args: { id?: string; correlationId?: string; dbName: string }): StatusListManagementOptions {
|
|
43
84
|
return {
|
|
44
85
|
id: args.id,
|
|
@@ -48,6 +89,11 @@ export function getOptions(args: { id?: string; correlationId?: string; dbName:
|
|
|
48
89
|
}
|
|
49
90
|
}
|
|
50
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Creates and initializes a status list driver instance
|
|
94
|
+
* @param args - Configuration parameters including database connection details
|
|
95
|
+
* @returns Promise resolving to initialized IStatusListDriver instance
|
|
96
|
+
*/
|
|
51
97
|
export async function getDriver(args: {
|
|
52
98
|
id?: string
|
|
53
99
|
correlationId?: string
|
|
@@ -69,15 +115,33 @@ export async function getDriver(args: {
|
|
|
69
115
|
)
|
|
70
116
|
}
|
|
71
117
|
|
|
118
|
+
/**
|
|
119
|
+
* TypeORM-based implementation of the IStatusListDriver interface
|
|
120
|
+
*
|
|
121
|
+
* Manages status list credentials and entries using a TypeORM data source.
|
|
122
|
+
* Handles database operations while delegating format-specific logic to the functions layer.
|
|
123
|
+
*/
|
|
72
124
|
export class AgentDataSourceStatusListDriver implements IStatusListDriver {
|
|
73
125
|
private _statusListLength: number | undefined
|
|
74
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Creates a new AgentDataSourceStatusListDriver instance
|
|
129
|
+
* @param _dataSource - TypeORM DataSource for database operations
|
|
130
|
+
* @param _statusListStore - StatusListStore for data persistence
|
|
131
|
+
* @param options - Driver configuration options
|
|
132
|
+
*/
|
|
75
133
|
constructor(
|
|
76
134
|
private _dataSource: DataSource,
|
|
77
135
|
private _statusListStore: StatusListStore,
|
|
78
136
|
private options: StatusListManagementOptions,
|
|
79
137
|
) {}
|
|
80
138
|
|
|
139
|
+
/**
|
|
140
|
+
* Initializes and creates a new AgentDataSourceStatusListDriver instance
|
|
141
|
+
* @param options - Status list management configuration
|
|
142
|
+
* @param dbArgs - Database connection arguments
|
|
143
|
+
* @returns Promise resolving to initialized driver instance
|
|
144
|
+
*/
|
|
81
145
|
public static async init(
|
|
82
146
|
options: StatusListManagementOptions,
|
|
83
147
|
dbArgs?: {
|
|
@@ -108,6 +172,10 @@ export class AgentDataSourceStatusListDriver implements IStatusListDriver {
|
|
|
108
172
|
return new AgentDataSourceStatusListDriver(dataSource, statusListStore, options)
|
|
109
173
|
}
|
|
110
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Gets the TypeORM DataSource instance
|
|
177
|
+
* @returns DataSource instance for database operations
|
|
178
|
+
*/
|
|
111
179
|
get dataSource(): DataSource {
|
|
112
180
|
if (!this._dataSource) {
|
|
113
181
|
throw Error(`Datasource not available yet for ${this.options.driverOptions?.dbName}`)
|
|
@@ -115,6 +183,10 @@ export class AgentDataSourceStatusListDriver implements IStatusListDriver {
|
|
|
115
183
|
return this._dataSource
|
|
116
184
|
}
|
|
117
185
|
|
|
186
|
+
/**
|
|
187
|
+
* Gets the StatusListStore instance
|
|
188
|
+
* @returns StatusListStore for data persistence operations
|
|
189
|
+
*/
|
|
118
190
|
get statusListStore(): StatusListStore {
|
|
119
191
|
if (!this._statusListStore) {
|
|
120
192
|
this._statusListStore = new StatusListStore(this.dataSource)
|
|
@@ -122,141 +194,158 @@ export class AgentDataSourceStatusListDriver implements IStatusListDriver {
|
|
|
122
194
|
return this._statusListStore
|
|
123
195
|
}
|
|
124
196
|
|
|
197
|
+
/**
|
|
198
|
+
* Gets the driver configuration options
|
|
199
|
+
* @returns DriverOptions configuration
|
|
200
|
+
*/
|
|
125
201
|
getOptions(): DriverOptions {
|
|
126
202
|
return this.options.driverOptions ?? {}
|
|
127
203
|
}
|
|
128
204
|
|
|
205
|
+
/**
|
|
206
|
+
* Gets the driver type
|
|
207
|
+
* @returns StatusListDriverType enum value
|
|
208
|
+
*/
|
|
129
209
|
getType(): StatusListDriverType {
|
|
130
210
|
return this.options.driverType
|
|
131
211
|
}
|
|
132
212
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
213
|
+
/**
|
|
214
|
+
* Creates a new status list credential and stores it in the database
|
|
215
|
+
* @param args - Status list creation parameters
|
|
216
|
+
* @returns Promise resolving to StatusListResult
|
|
217
|
+
*/
|
|
218
|
+
async createStatusList(args: ICreateStatusListArgs): Promise<StatusListResult> {
|
|
138
219
|
const correlationId = args.correlationId ?? this.options.correlationId
|
|
139
220
|
if (!correlationId) {
|
|
140
221
|
throw Error('Either a correlationId needs to be set as an option, or it needs to be provided when creating a status list. None found')
|
|
141
222
|
}
|
|
142
223
|
const credentialIdMode = args.credentialIdMode ?? StatusListCredentialIdMode.ISSUANCE
|
|
143
|
-
const details = await statusListCredentialToDetails({ ...args, correlationId, driverType: this.getType() })
|
|
144
224
|
|
|
145
|
-
//
|
|
146
|
-
await
|
|
147
|
-
|
|
148
|
-
|
|
225
|
+
// Convert credential to implementation details using CREATE/READ context
|
|
226
|
+
const implementationResult = await toStatusListDetails({
|
|
227
|
+
statusListCredential: args.statusListCredential,
|
|
228
|
+
statusListType: args.statusListType,
|
|
229
|
+
bitsPerStatus: args.bitsPerStatus,
|
|
149
230
|
correlationId,
|
|
150
231
|
driverType: this.getType(),
|
|
151
232
|
})
|
|
152
|
-
|
|
153
|
-
|
|
233
|
+
|
|
234
|
+
// Add driver-specific fields to create complete entity
|
|
235
|
+
const statusListArgs = {
|
|
236
|
+
...implementationResult,
|
|
237
|
+
credentialIdMode,
|
|
238
|
+
correlationId,
|
|
239
|
+
driverType: this.getType(),
|
|
240
|
+
} as IAddStatusListArgs
|
|
241
|
+
|
|
242
|
+
await this.statusListStore.addStatusList(statusListArgs)
|
|
243
|
+
this._statusListLength = implementationResult.length
|
|
244
|
+
return implementationResult
|
|
154
245
|
}
|
|
155
246
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
247
|
+
/**
|
|
248
|
+
* Updates an existing status list credential in the database
|
|
249
|
+
* @param args - Status list update parameters
|
|
250
|
+
* @returns Promise resolving to StatusListResult
|
|
251
|
+
*/
|
|
252
|
+
async updateStatusList(args: IUpdateStatusListArgs): Promise<StatusListResult> {
|
|
161
253
|
const correlationId = args.correlationId ?? this.options.correlationId
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
{
|
|
168
|
-
id: details.id,
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
correlationId,
|
|
172
|
-
},
|
|
173
|
-
],
|
|
254
|
+
|
|
255
|
+
const extractedDetails = await extractCredentialDetails(args.statusListCredential)
|
|
256
|
+
const entity = await this.statusListStore.getStatusList({
|
|
257
|
+
id: extractedDetails.id,
|
|
258
|
+
correlationId,
|
|
174
259
|
})
|
|
175
260
|
if (!entity) {
|
|
176
|
-
throw Error(`Status list ${
|
|
261
|
+
throw Error(`Status list ${extractedDetails.id}, correlationId ${correlationId} could not be found`)
|
|
177
262
|
}
|
|
178
|
-
|
|
263
|
+
|
|
264
|
+
entity.statusListCredential = args.statusListCredential
|
|
265
|
+
|
|
266
|
+
const details = await toStatusListDetails({
|
|
267
|
+
extractedDetails,
|
|
268
|
+
statusListEntity: entity,
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
// Merge details with existing entity and driver properties
|
|
272
|
+
const updateArgs = {
|
|
179
273
|
...entity,
|
|
180
274
|
...details,
|
|
181
275
|
correlationId,
|
|
182
276
|
driverType: this.getType(),
|
|
183
|
-
}
|
|
277
|
+
} as IAddStatusListArgs
|
|
278
|
+
|
|
279
|
+
await this.statusListStore.updateStatusList(updateArgs)
|
|
184
280
|
this._statusListLength = details.length
|
|
185
281
|
return { ...entity, ...details }
|
|
186
282
|
}
|
|
187
283
|
|
|
284
|
+
/**
|
|
285
|
+
* Deletes the status list from the database
|
|
286
|
+
* @returns Promise resolving to boolean indicating success
|
|
287
|
+
*/
|
|
188
288
|
async deleteStatusList(): Promise<boolean> {
|
|
189
289
|
await this.statusListStore.removeStatusList({ id: this.options.id, correlationId: this.options.correlationId })
|
|
190
290
|
return Promise.resolve(true)
|
|
191
291
|
}
|
|
192
292
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
return statusList instanceof OAuthStatusListEntity
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
private isBitstringStatusListEntity(statusList: StatusListEntity): statusList is BitstringStatusListEntity {
|
|
202
|
-
return statusList instanceof BitstringStatusListEntity
|
|
203
|
-
}
|
|
204
|
-
|
|
293
|
+
/**
|
|
294
|
+
* Updates a status list entry and returns the credential status
|
|
295
|
+
* @param args - Status list entry update parameters
|
|
296
|
+
* @returns Promise resolving to credential status and entry
|
|
297
|
+
*/
|
|
205
298
|
async updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<{
|
|
206
299
|
credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus | BitstringStatusListEntryCredentialStatus
|
|
207
|
-
statusListEntry: IStatusListEntryEntity
|
|
300
|
+
statusListEntry: IStatusListEntryEntity | IBitstringStatusListEntryEntity
|
|
208
301
|
}> {
|
|
209
|
-
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
statusListEntry,
|
|
222
|
-
}
|
|
223
|
-
} else if (this.isOAuthStatusListEntity(statusList)) {
|
|
224
|
-
return {
|
|
225
|
-
credentialStatus: {
|
|
226
|
-
id: `${statusList.id}#${statusListEntry.statusListIndex}`,
|
|
227
|
-
type: 'OAuthStatusListEntry',
|
|
228
|
-
bitsPerStatus: statusList.bitsPerStatus,
|
|
229
|
-
statusListIndex: '' + statusListEntry.statusListIndex,
|
|
230
|
-
statusListCredential: statusList.id,
|
|
231
|
-
expiresAt: statusList.expiresAt,
|
|
232
|
-
},
|
|
233
|
-
statusListEntry,
|
|
234
|
-
}
|
|
235
|
-
} else if (this.isBitstringStatusListEntity(statusList)) {
|
|
236
|
-
return {
|
|
237
|
-
credentialStatus: {
|
|
238
|
-
id: `${statusList.id}#${statusListEntry.statusListIndex}`,
|
|
239
|
-
type: 'BitstringStatusListEntry',
|
|
240
|
-
statusPurpose: statusList.statusPurpose,
|
|
241
|
-
statusListIndex: '' + statusListEntry.statusListIndex,
|
|
242
|
-
statusListCredential: statusList.id,
|
|
243
|
-
} satisfies BitstringStatusListEntryCredentialStatus,
|
|
244
|
-
statusListEntry,
|
|
245
|
-
}
|
|
246
|
-
}
|
|
302
|
+
// Get status list entity
|
|
303
|
+
const statusListEntity: StatusListEntity = statusListResultToEntity(await this.getStatusList())
|
|
304
|
+
|
|
305
|
+
// Update the entry in the store
|
|
306
|
+
const statusListEntry = await this.statusListStore.updateStatusListEntry({ ...args, statusListId: statusListEntity.id })
|
|
307
|
+
|
|
308
|
+
// Use implementation to create the credential status - this moves type-specific logic to implementations
|
|
309
|
+
const credentialStatus = await createCredentialStatusFromStatusList({
|
|
310
|
+
statusList: statusListEntity,
|
|
311
|
+
statusListEntry,
|
|
312
|
+
statusListIndex: statusListEntry.statusListIndex,
|
|
313
|
+
})
|
|
247
314
|
|
|
248
|
-
|
|
315
|
+
return {
|
|
316
|
+
credentialStatus,
|
|
317
|
+
statusListEntry,
|
|
318
|
+
}
|
|
249
319
|
}
|
|
250
320
|
|
|
251
|
-
|
|
321
|
+
/**
|
|
322
|
+
* Retrieves a status list entry by credential ID
|
|
323
|
+
* @param args - Query parameters including credential ID
|
|
324
|
+
* @returns Promise resolving to status list entry or undefined
|
|
325
|
+
*/
|
|
326
|
+
async getStatusListEntryByCredentialId(
|
|
327
|
+
args: IGetStatusListEntryByCredentialIdArgs,
|
|
328
|
+
): Promise<IStatusListEntryEntity | IBitstringStatusListEntryEntity | undefined> {
|
|
252
329
|
return await this.statusListStore.getStatusListEntryByCredentialId(args)
|
|
253
330
|
}
|
|
254
331
|
|
|
255
|
-
|
|
332
|
+
/**
|
|
333
|
+
* Retrieves a status list entry by index
|
|
334
|
+
* @param args - Query parameters including status list index
|
|
335
|
+
* @returns Promise resolving to status list entry or undefined
|
|
336
|
+
*/
|
|
337
|
+
async getStatusListEntryByIndex(
|
|
338
|
+
args: IGetStatusListEntryByIndexArgs,
|
|
339
|
+
): Promise<IStatusListEntryEntity | IBitstringStatusListEntryEntity | undefined> {
|
|
256
340
|
return await this.statusListStore.getStatusListEntryByIndex(args)
|
|
257
341
|
}
|
|
258
342
|
|
|
259
|
-
|
|
343
|
+
/**
|
|
344
|
+
* Generates a random available index for new status list entries
|
|
345
|
+
* @param args - Optional correlation ID parameter
|
|
346
|
+
* @returns Promise resolving to available index number
|
|
347
|
+
*/
|
|
348
|
+
async getRandomNewStatusListIndex(args?: IGetRandomNewStatusListIndexArgs): Promise<number> {
|
|
260
349
|
let result = -1
|
|
261
350
|
let tries = 0
|
|
262
351
|
while (result < 0) {
|
|
@@ -266,6 +355,12 @@ export class AgentDataSourceStatusListDriver implements IStatusListDriver {
|
|
|
266
355
|
return result
|
|
267
356
|
}
|
|
268
357
|
|
|
358
|
+
/**
|
|
359
|
+
* Implementation for generating random status list indices with retry logic
|
|
360
|
+
* @param tries - Number of attempts made
|
|
361
|
+
* @param args - Optional correlation ID parameter
|
|
362
|
+
* @returns Promise resolving to available index or -1 if none found
|
|
363
|
+
*/
|
|
269
364
|
private async getRandomNewStatusListIndexImpl(tries: number, args?: { correlationId?: string }): Promise<number> {
|
|
270
365
|
const statusListId = this.options.id
|
|
271
366
|
const correlationId = args?.correlationId ?? this.options.correlationId
|
|
@@ -286,32 +381,62 @@ export class AgentDataSourceStatusListDriver implements IStatusListDriver {
|
|
|
286
381
|
return -1
|
|
287
382
|
}
|
|
288
383
|
|
|
289
|
-
|
|
384
|
+
/**
|
|
385
|
+
* Gets the length of the status list
|
|
386
|
+
* @param args - Optional correlation ID parameter
|
|
387
|
+
* @returns Promise resolving to status list length
|
|
388
|
+
*/
|
|
389
|
+
async getStatusListLength(args?: IGetStatusListLengthArgs): Promise<number> {
|
|
290
390
|
if (!this._statusListLength) {
|
|
291
391
|
this._statusListLength = await this.getStatusList(args).then((details) => details.length)
|
|
292
392
|
}
|
|
293
393
|
return this._statusListLength!
|
|
294
394
|
}
|
|
295
395
|
|
|
296
|
-
|
|
396
|
+
/**
|
|
397
|
+
* Retrieves the status list details
|
|
398
|
+
* @param args - Optional correlation ID parameter
|
|
399
|
+
* @returns Promise resolving to StatusListResult
|
|
400
|
+
*/
|
|
401
|
+
async getStatusList(args?: IGetStatusListArgs): Promise<StatusListResult> {
|
|
297
402
|
const id = this.options.id
|
|
298
403
|
const correlationId = args?.correlationId ?? this.options.correlationId
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
404
|
+
|
|
405
|
+
const statusListEntity = await this.statusListStore.getStatusList({ id, correlationId })
|
|
406
|
+
|
|
407
|
+
// Convert entity to result using CREATE/READ context
|
|
408
|
+
return await toStatusListDetails({
|
|
409
|
+
statusListCredential: statusListEntity.statusListCredential!,
|
|
410
|
+
statusListType: statusListEntity.type,
|
|
411
|
+
bitsPerStatus: statusListEntity.bitsPerStatus,
|
|
412
|
+
correlationId: statusListEntity.correlationId,
|
|
413
|
+
driverType: statusListEntity.driverType,
|
|
414
|
+
})
|
|
302
415
|
}
|
|
303
416
|
|
|
417
|
+
/**
|
|
418
|
+
* Retrieves all status lists
|
|
419
|
+
* @returns Promise resolving to array of StatusListResult
|
|
420
|
+
*/
|
|
304
421
|
async getStatusLists(): Promise<Array<StatusListResult>> {
|
|
305
422
|
const statusLists = await this.statusListStore.getStatusLists({})
|
|
306
423
|
return Promise.all(
|
|
307
424
|
statusLists.map(async (statusListEntity) => {
|
|
308
|
-
return
|
|
425
|
+
return toStatusListDetails({
|
|
309
426
|
statusListCredential: statusListEntity.statusListCredential!,
|
|
427
|
+
statusListType: statusListEntity.type,
|
|
428
|
+
bitsPerStatus: statusListEntity.bitsPerStatus,
|
|
429
|
+
correlationId: statusListEntity.correlationId,
|
|
430
|
+
driverType: statusListEntity.driverType,
|
|
310
431
|
})
|
|
311
432
|
}),
|
|
312
433
|
)
|
|
313
434
|
}
|
|
314
435
|
|
|
436
|
+
/**
|
|
437
|
+
* Checks if a status list index is currently in use
|
|
438
|
+
* @returns Promise resolving to boolean indicating usage status
|
|
439
|
+
*/
|
|
315
440
|
isStatusListIndexInUse(): Promise<boolean> {
|
|
316
441
|
return Promise.resolve(false)
|
|
317
442
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { StatusListType } from '@sphereon/ssi-types'
|
|
2
|
-
import { OAuthStatusListEntity, StatusList2021Entity } from '@sphereon/ssi-sdk.data-store'
|
|
2
|
+
import { BitstringStatusListEntity, OAuthStatusListEntity, StatusList2021Entity } from '@sphereon/ssi-sdk.data-store'
|
|
3
3
|
import { StatusListResult } from '@sphereon/ssi-sdk.vc-status-list'
|
|
4
4
|
|
|
5
|
-
import { BitstringStatusListEntity } from '@sphereon/ssi-sdk.data-store'
|
|
6
|
-
|
|
7
5
|
export function statusListResultToEntity(result: StatusListResult): StatusList2021Entity | OAuthStatusListEntity | BitstringStatusListEntity {
|
|
8
6
|
const baseFields = {
|
|
9
7
|
id: result.id,
|
|
@@ -43,6 +41,7 @@ export function statusListResultToEntity(result: StatusListResult): StatusList20
|
|
|
43
41
|
...baseFields,
|
|
44
42
|
statusPurpose: result.bitstringStatusList.statusPurpose,
|
|
45
43
|
ttl: result.bitstringStatusList.ttl,
|
|
44
|
+
bitsPerStatus: result.bitstringStatusList.bitsPerStatus,
|
|
46
45
|
validFrom: result.bitstringStatusList.validFrom,
|
|
47
46
|
validUntil: result.bitstringStatusList.validUntil,
|
|
48
47
|
})
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution'
|
|
2
2
|
import {
|
|
3
|
+
BitstringStatusListEntryCredentialStatus,
|
|
3
4
|
IAddStatusListEntryArgs,
|
|
4
5
|
IGetStatusListEntryByCredentialIdArgs,
|
|
5
6
|
IGetStatusListEntryByIndexArgs,
|
|
@@ -7,24 +8,15 @@ import {
|
|
|
7
8
|
StatusListStore,
|
|
8
9
|
} from '@sphereon/ssi-sdk.data-store'
|
|
9
10
|
import {
|
|
10
|
-
BitstringStatusListEntryCredentialStatus,
|
|
11
11
|
IStatusListPlugin,
|
|
12
12
|
StatusList2021EntryCredentialStatus,
|
|
13
13
|
StatusListOAuthEntryCredentialStatus,
|
|
14
14
|
StatusListResult,
|
|
15
15
|
} from '@sphereon/ssi-sdk.vc-status-list'
|
|
16
|
-
import { StatusListCredential, StatusListDriverType } from '@sphereon/ssi-types'
|
|
17
|
-
import {
|
|
18
|
-
IAgentContext,
|
|
19
|
-
ICredentialIssuer,
|
|
20
|
-
ICredentialPlugin,
|
|
21
|
-
ICredentialVerifier,
|
|
22
|
-
IDataStoreORM,
|
|
23
|
-
IDIDManager,
|
|
24
|
-
IKeyManager,
|
|
25
|
-
IResolver,
|
|
26
|
-
} from '@veramo/core'
|
|
16
|
+
import { StatusListCredential, StatusListCredentialIdMode, StatusListDriverType, StatusListType } from '@sphereon/ssi-types'
|
|
17
|
+
import { IAgentContext, ICredentialIssuer, ICredentialVerifier, IDataStoreORM, IDIDManager, IKeyManager, IResolver } from '@veramo/core'
|
|
27
18
|
import { DriverOptions } from './drivers'
|
|
19
|
+
import { IVcdmCredentialPlugin } from '@sphereon/ssi-sdk.credential-vcdm'
|
|
28
20
|
|
|
29
21
|
export type IRequiredPlugins = IDataStoreORM &
|
|
30
22
|
IDIDManager &
|
|
@@ -32,11 +24,36 @@ export type IRequiredPlugins = IDataStoreORM &
|
|
|
32
24
|
IIdentifierResolution &
|
|
33
25
|
ICredentialIssuer &
|
|
34
26
|
ICredentialVerifier &
|
|
35
|
-
|
|
27
|
+
IVcdmCredentialPlugin &
|
|
36
28
|
IStatusListPlugin &
|
|
37
29
|
IResolver
|
|
38
30
|
export type IRequiredContext = IAgentContext<IRequiredPlugins>
|
|
39
31
|
|
|
32
|
+
export interface ICreateStatusListArgs {
|
|
33
|
+
statusListType: StatusListType
|
|
34
|
+
statusListCredential: StatusListCredential
|
|
35
|
+
credentialIdMode?: StatusListCredentialIdMode
|
|
36
|
+
correlationId?: string
|
|
37
|
+
bitsPerStatus?: number
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface IGetStatusListArgs {
|
|
41
|
+
correlationId?: string
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface IGetStatusListLengthArgs {
|
|
45
|
+
correlationId?: string
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface IUpdateStatusListArgs {
|
|
49
|
+
statusListCredential: StatusListCredential
|
|
50
|
+
correlationId: string
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface IGetRandomNewStatusListIndexArgs {
|
|
54
|
+
correlationId?: string
|
|
55
|
+
}
|
|
56
|
+
|
|
40
57
|
export interface IStatusListDriver {
|
|
41
58
|
statusListStore: StatusListStore
|
|
42
59
|
|
|
@@ -44,11 +61,11 @@ export interface IStatusListDriver {
|
|
|
44
61
|
|
|
45
62
|
getOptions(): DriverOptions
|
|
46
63
|
|
|
47
|
-
getStatusListLength(args?:
|
|
64
|
+
getStatusListLength(args?: IGetStatusListLengthArgs): Promise<number>
|
|
48
65
|
|
|
49
|
-
createStatusList(args:
|
|
66
|
+
createStatusList(args: ICreateStatusListArgs): Promise<StatusListResult>
|
|
50
67
|
|
|
51
|
-
getStatusList(args?:
|
|
68
|
+
getStatusList(args?: IGetStatusListArgs): Promise<StatusListResult>
|
|
52
69
|
|
|
53
70
|
getStatusLists(): Promise<Array<StatusListResult>>
|
|
54
71
|
|
|
@@ -61,11 +78,11 @@ export interface IStatusListDriver {
|
|
|
61
78
|
|
|
62
79
|
getStatusListEntryByIndex(args: IGetStatusListEntryByIndexArgs): Promise<IStatusListEntryEntity | undefined>
|
|
63
80
|
|
|
64
|
-
updateStatusList(args:
|
|
81
|
+
updateStatusList(args: IUpdateStatusListArgs): Promise<StatusListResult>
|
|
65
82
|
|
|
66
83
|
deleteStatusList(): Promise<boolean>
|
|
67
84
|
|
|
68
|
-
getRandomNewStatusListIndex(args?:
|
|
85
|
+
getRandomNewStatusListIndex(args?: IGetRandomNewStatusListIndexArgs): Promise<number>
|
|
69
86
|
|
|
70
87
|
isStatusListIndexInUse(): Promise<boolean>
|
|
71
88
|
}
|