@sphereon/ssi-sdk.vc-status-list-issuer-drivers 0.34.1-feature.disable.test.8 → 0.34.1-feature.merge.crypto.extensions.modules.34
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 +147 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +171 -47
- package/dist/index.d.ts +171 -47
- package/dist/index.js +149 -66
- package/dist/index.js.map +1 -1
- package/package.json +11 -10
- package/src/drivers.ts +226 -84
- package/src/status-list-adapters.ts +14 -2
- package/src/types.ts +36 -18
package/src/drivers.ts
CHANGED
|
@@ -1,25 +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 {
|
|
22
|
+
BitstringStatusListEntryCredentialStatus,
|
|
23
|
+
IAddStatusListArgs,
|
|
3
24
|
IAddStatusListEntryArgs,
|
|
25
|
+
IBitstringStatusListEntryEntity,
|
|
4
26
|
IGetStatusListEntryByCredentialIdArgs,
|
|
5
27
|
IGetStatusListEntryByIndexArgs,
|
|
6
|
-
IStatusListEntity,
|
|
7
28
|
IStatusListEntryEntity,
|
|
8
29
|
StatusListEntity,
|
|
9
30
|
StatusListStore,
|
|
10
31
|
} from '@sphereon/ssi-sdk.data-store'
|
|
11
32
|
import {
|
|
33
|
+
createCredentialStatusFromStatusList,
|
|
34
|
+
extractCredentialDetails,
|
|
12
35
|
StatusList2021EntryCredentialStatus,
|
|
13
|
-
statusListCredentialToDetails,
|
|
14
36
|
StatusListOAuthEntryCredentialStatus,
|
|
15
37
|
StatusListResult,
|
|
38
|
+
toStatusListDetails,
|
|
16
39
|
} from '@sphereon/ssi-sdk.vc-status-list'
|
|
17
|
-
import { StatusListCredentialIdMode, StatusListDriverType
|
|
40
|
+
import { StatusListCredentialIdMode, StatusListDriverType } from '@sphereon/ssi-types'
|
|
18
41
|
import { DataSource } from 'typeorm'
|
|
19
|
-
import {
|
|
42
|
+
import {
|
|
43
|
+
ICreateStatusListArgs,
|
|
44
|
+
IGetRandomNewStatusListIndexArgs,
|
|
45
|
+
IGetStatusListArgs,
|
|
46
|
+
IGetStatusListLengthArgs,
|
|
47
|
+
IStatusListDriver,
|
|
48
|
+
IUpdateStatusListArgs,
|
|
49
|
+
} from './types'
|
|
20
50
|
import { statusListResultToEntity } from './status-list-adapters'
|
|
21
|
-
import { OAuthStatusListEntity, StatusList2021Entity } from '@sphereon/ssi-sdk.data-store'
|
|
22
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Configuration options for status list management
|
|
54
|
+
*/
|
|
23
55
|
export interface StatusListManagementOptions {
|
|
24
56
|
id?: string
|
|
25
57
|
correlationId?: string
|
|
@@ -29,14 +61,25 @@ export interface StatusListManagementOptions {
|
|
|
29
61
|
|
|
30
62
|
export type DriverOptions = TypeORMOptions
|
|
31
63
|
|
|
64
|
+
/**
|
|
65
|
+
* TypeORM-specific configuration options
|
|
66
|
+
*/
|
|
32
67
|
export interface TypeORMOptions {
|
|
33
68
|
dbName?: string
|
|
34
69
|
}
|
|
35
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Filesystem-specific configuration options
|
|
73
|
+
*/
|
|
36
74
|
export interface FilesystemOptions {
|
|
37
75
|
path: string // The base path where statusList Credentials will be persisted. Should be a folder and thus not include the VC/StatusList itself
|
|
38
76
|
}
|
|
39
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
|
+
*/
|
|
40
83
|
export function getOptions(args: { id?: string; correlationId?: string; dbName: string }): StatusListManagementOptions {
|
|
41
84
|
return {
|
|
42
85
|
id: args.id,
|
|
@@ -46,6 +89,11 @@ export function getOptions(args: { id?: string; correlationId?: string; dbName:
|
|
|
46
89
|
}
|
|
47
90
|
}
|
|
48
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
|
+
*/
|
|
49
97
|
export async function getDriver(args: {
|
|
50
98
|
id?: string
|
|
51
99
|
correlationId?: string
|
|
@@ -67,15 +115,33 @@ export async function getDriver(args: {
|
|
|
67
115
|
)
|
|
68
116
|
}
|
|
69
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
|
+
*/
|
|
70
124
|
export class AgentDataSourceStatusListDriver implements IStatusListDriver {
|
|
71
125
|
private _statusListLength: number | undefined
|
|
72
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
|
+
*/
|
|
73
133
|
constructor(
|
|
74
134
|
private _dataSource: DataSource,
|
|
75
135
|
private _statusListStore: StatusListStore,
|
|
76
136
|
private options: StatusListManagementOptions,
|
|
77
137
|
) {}
|
|
78
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
|
+
*/
|
|
79
145
|
public static async init(
|
|
80
146
|
options: StatusListManagementOptions,
|
|
81
147
|
dbArgs?: {
|
|
@@ -106,6 +172,10 @@ export class AgentDataSourceStatusListDriver implements IStatusListDriver {
|
|
|
106
172
|
return new AgentDataSourceStatusListDriver(dataSource, statusListStore, options)
|
|
107
173
|
}
|
|
108
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Gets the TypeORM DataSource instance
|
|
177
|
+
* @returns DataSource instance for database operations
|
|
178
|
+
*/
|
|
109
179
|
get dataSource(): DataSource {
|
|
110
180
|
if (!this._dataSource) {
|
|
111
181
|
throw Error(`Datasource not available yet for ${this.options.driverOptions?.dbName}`)
|
|
@@ -113,6 +183,10 @@ export class AgentDataSourceStatusListDriver implements IStatusListDriver {
|
|
|
113
183
|
return this._dataSource
|
|
114
184
|
}
|
|
115
185
|
|
|
186
|
+
/**
|
|
187
|
+
* Gets the StatusListStore instance
|
|
188
|
+
* @returns StatusListStore for data persistence operations
|
|
189
|
+
*/
|
|
116
190
|
get statusListStore(): StatusListStore {
|
|
117
191
|
if (!this._statusListStore) {
|
|
118
192
|
this._statusListStore = new StatusListStore(this.dataSource)
|
|
@@ -120,126 +194,158 @@ export class AgentDataSourceStatusListDriver implements IStatusListDriver {
|
|
|
120
194
|
return this._statusListStore
|
|
121
195
|
}
|
|
122
196
|
|
|
197
|
+
/**
|
|
198
|
+
* Gets the driver configuration options
|
|
199
|
+
* @returns DriverOptions configuration
|
|
200
|
+
*/
|
|
123
201
|
getOptions(): DriverOptions {
|
|
124
202
|
return this.options.driverOptions ?? {}
|
|
125
203
|
}
|
|
126
204
|
|
|
205
|
+
/**
|
|
206
|
+
* Gets the driver type
|
|
207
|
+
* @returns StatusListDriverType enum value
|
|
208
|
+
*/
|
|
127
209
|
getType(): StatusListDriverType {
|
|
128
210
|
return this.options.driverType
|
|
129
211
|
}
|
|
130
212
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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> {
|
|
136
219
|
const correlationId = args.correlationId ?? this.options.correlationId
|
|
137
220
|
if (!correlationId) {
|
|
138
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')
|
|
139
222
|
}
|
|
140
223
|
const credentialIdMode = args.credentialIdMode ?? StatusListCredentialIdMode.ISSUANCE
|
|
141
|
-
const details = await statusListCredentialToDetails({ ...args, correlationId, driverType: this.getType() })
|
|
142
224
|
|
|
143
|
-
//
|
|
144
|
-
await
|
|
145
|
-
|
|
146
|
-
|
|
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,
|
|
147
230
|
correlationId,
|
|
148
231
|
driverType: this.getType(),
|
|
149
232
|
})
|
|
150
|
-
|
|
151
|
-
|
|
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
|
|
152
245
|
}
|
|
153
246
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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> {
|
|
159
253
|
const correlationId = args.correlationId ?? this.options.correlationId
|
|
160
|
-
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
{
|
|
166
|
-
id: details.id,
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
correlationId,
|
|
170
|
-
},
|
|
171
|
-
],
|
|
254
|
+
|
|
255
|
+
const extractedDetails = await extractCredentialDetails(args.statusListCredential)
|
|
256
|
+
const entity = await this.statusListStore.getStatusList({
|
|
257
|
+
id: extractedDetails.id,
|
|
258
|
+
correlationId,
|
|
172
259
|
})
|
|
173
260
|
if (!entity) {
|
|
174
|
-
throw Error(`Status list ${
|
|
261
|
+
throw Error(`Status list ${extractedDetails.id}, correlationId ${correlationId} could not be found`)
|
|
175
262
|
}
|
|
176
|
-
|
|
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 = {
|
|
177
273
|
...entity,
|
|
178
274
|
...details,
|
|
179
275
|
correlationId,
|
|
180
276
|
driverType: this.getType(),
|
|
181
|
-
}
|
|
277
|
+
} as IAddStatusListArgs
|
|
278
|
+
|
|
279
|
+
await this.statusListStore.updateStatusList(updateArgs)
|
|
182
280
|
this._statusListLength = details.length
|
|
183
281
|
return { ...entity, ...details }
|
|
184
282
|
}
|
|
185
283
|
|
|
284
|
+
/**
|
|
285
|
+
* Deletes the status list from the database
|
|
286
|
+
* @returns Promise resolving to boolean indicating success
|
|
287
|
+
*/
|
|
186
288
|
async deleteStatusList(): Promise<boolean> {
|
|
187
289
|
await this.statusListStore.removeStatusList({ id: this.options.id, correlationId: this.options.correlationId })
|
|
188
290
|
return Promise.resolve(true)
|
|
189
291
|
}
|
|
190
292
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
return statusList instanceof OAuthStatusListEntity
|
|
197
|
-
}
|
|
198
|
-
|
|
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
|
+
*/
|
|
199
298
|
async updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<{
|
|
200
|
-
credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus
|
|
201
|
-
statusListEntry: IStatusListEntryEntity
|
|
299
|
+
credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus | BitstringStatusListEntryCredentialStatus
|
|
300
|
+
statusListEntry: IStatusListEntryEntity | IBitstringStatusListEntryEntity
|
|
202
301
|
}> {
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
statusListEntry,
|
|
216
|
-
}
|
|
217
|
-
} else if (this.isOAuthStatusListEntity(statusList)) {
|
|
218
|
-
return {
|
|
219
|
-
credentialStatus: {
|
|
220
|
-
id: `${statusList.id}#${statusListEntry.statusListIndex}`,
|
|
221
|
-
type: 'OAuthStatusListEntry',
|
|
222
|
-
bitsPerStatus: statusList.bitsPerStatus,
|
|
223
|
-
statusListIndex: '' + statusListEntry.statusListIndex,
|
|
224
|
-
statusListCredential: statusList.id,
|
|
225
|
-
expiresAt: statusList.expiresAt,
|
|
226
|
-
},
|
|
227
|
-
statusListEntry,
|
|
228
|
-
}
|
|
229
|
-
}
|
|
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
|
+
})
|
|
230
314
|
|
|
231
|
-
|
|
315
|
+
return {
|
|
316
|
+
credentialStatus,
|
|
317
|
+
statusListEntry,
|
|
318
|
+
}
|
|
232
319
|
}
|
|
233
320
|
|
|
234
|
-
|
|
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> {
|
|
235
329
|
return await this.statusListStore.getStatusListEntryByCredentialId(args)
|
|
236
330
|
}
|
|
237
331
|
|
|
238
|
-
|
|
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> {
|
|
239
340
|
return await this.statusListStore.getStatusListEntryByIndex(args)
|
|
240
341
|
}
|
|
241
342
|
|
|
242
|
-
|
|
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> {
|
|
243
349
|
let result = -1
|
|
244
350
|
let tries = 0
|
|
245
351
|
while (result < 0) {
|
|
@@ -249,6 +355,12 @@ export class AgentDataSourceStatusListDriver implements IStatusListDriver {
|
|
|
249
355
|
return result
|
|
250
356
|
}
|
|
251
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
|
+
*/
|
|
252
364
|
private async getRandomNewStatusListIndexImpl(tries: number, args?: { correlationId?: string }): Promise<number> {
|
|
253
365
|
const statusListId = this.options.id
|
|
254
366
|
const correlationId = args?.correlationId ?? this.options.correlationId
|
|
@@ -269,32 +381,62 @@ export class AgentDataSourceStatusListDriver implements IStatusListDriver {
|
|
|
269
381
|
return -1
|
|
270
382
|
}
|
|
271
383
|
|
|
272
|
-
|
|
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> {
|
|
273
390
|
if (!this._statusListLength) {
|
|
274
391
|
this._statusListLength = await this.getStatusList(args).then((details) => details.length)
|
|
275
392
|
}
|
|
276
393
|
return this._statusListLength!
|
|
277
394
|
}
|
|
278
395
|
|
|
279
|
-
|
|
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> {
|
|
280
402
|
const id = this.options.id
|
|
281
403
|
const correlationId = args?.correlationId ?? this.options.correlationId
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
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
|
+
})
|
|
285
415
|
}
|
|
286
416
|
|
|
417
|
+
/**
|
|
418
|
+
* Retrieves all status lists
|
|
419
|
+
* @returns Promise resolving to array of StatusListResult
|
|
420
|
+
*/
|
|
287
421
|
async getStatusLists(): Promise<Array<StatusListResult>> {
|
|
288
422
|
const statusLists = await this.statusListStore.getStatusLists({})
|
|
289
423
|
return Promise.all(
|
|
290
424
|
statusLists.map(async (statusListEntity) => {
|
|
291
|
-
return
|
|
425
|
+
return toStatusListDetails({
|
|
292
426
|
statusListCredential: statusListEntity.statusListCredential!,
|
|
427
|
+
statusListType: statusListEntity.type,
|
|
428
|
+
bitsPerStatus: statusListEntity.bitsPerStatus,
|
|
429
|
+
correlationId: statusListEntity.correlationId,
|
|
430
|
+
driverType: statusListEntity.driverType,
|
|
293
431
|
})
|
|
294
432
|
}),
|
|
295
433
|
)
|
|
296
434
|
}
|
|
297
435
|
|
|
436
|
+
/**
|
|
437
|
+
* Checks if a status list index is currently in use
|
|
438
|
+
* @returns Promise resolving to boolean indicating usage status
|
|
439
|
+
*/
|
|
298
440
|
isStatusListIndexInUse(): Promise<boolean> {
|
|
299
441
|
return Promise.resolve(false)
|
|
300
442
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
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
|
-
export function statusListResultToEntity(result: StatusListResult): StatusList2021Entity | OAuthStatusListEntity {
|
|
5
|
+
export function statusListResultToEntity(result: StatusListResult): StatusList2021Entity | OAuthStatusListEntity | BitstringStatusListEntity {
|
|
6
6
|
const baseFields = {
|
|
7
7
|
id: result.id,
|
|
8
8
|
correlationId: result.correlationId,
|
|
@@ -33,6 +33,18 @@ export function statusListResultToEntity(result: StatusListResult): StatusList20
|
|
|
33
33
|
bitsPerStatus: result.oauthStatusList.bitsPerStatus,
|
|
34
34
|
expiresAt: result.oauthStatusList.expiresAt,
|
|
35
35
|
})
|
|
36
|
+
} else if (result.type === StatusListType.BitstringStatusList) {
|
|
37
|
+
if (!result.bitstringStatusList) {
|
|
38
|
+
throw new Error('Missing bitstringStatusList details')
|
|
39
|
+
}
|
|
40
|
+
return Object.assign(new BitstringStatusListEntity(), {
|
|
41
|
+
...baseFields,
|
|
42
|
+
statusPurpose: result.bitstringStatusList.statusPurpose,
|
|
43
|
+
ttl: result.bitstringStatusList.ttl,
|
|
44
|
+
bitsPerStatus: result.bitstringStatusList.bitsPerStatus,
|
|
45
|
+
validFrom: result.bitstringStatusList.validFrom,
|
|
46
|
+
validUntil: result.bitstringStatusList.validUntil,
|
|
47
|
+
})
|
|
36
48
|
}
|
|
37
49
|
throw new Error(`Unsupported status list type: ${result.type}`)
|
|
38
50
|
}
|
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,
|
|
@@ -12,18 +13,10 @@ import {
|
|
|
12
13
|
StatusListOAuthEntryCredentialStatus,
|
|
13
14
|
StatusListResult,
|
|
14
15
|
} from '@sphereon/ssi-sdk.vc-status-list'
|
|
15
|
-
import { StatusListCredential, StatusListDriverType } from '@sphereon/ssi-types'
|
|
16
|
-
import {
|
|
17
|
-
IAgentContext,
|
|
18
|
-
ICredentialIssuer,
|
|
19
|
-
ICredentialPlugin,
|
|
20
|
-
ICredentialVerifier,
|
|
21
|
-
IDataStoreORM,
|
|
22
|
-
IDIDManager,
|
|
23
|
-
IKeyManager,
|
|
24
|
-
IResolver,
|
|
25
|
-
} 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'
|
|
26
18
|
import { DriverOptions } from './drivers'
|
|
19
|
+
import { IVcdmCredentialPlugin } from '@sphereon/ssi-sdk.credential-vcdm'
|
|
27
20
|
|
|
28
21
|
export type IRequiredPlugins = IDataStoreORM &
|
|
29
22
|
IDIDManager &
|
|
@@ -31,11 +24,36 @@ export type IRequiredPlugins = IDataStoreORM &
|
|
|
31
24
|
IIdentifierResolution &
|
|
32
25
|
ICredentialIssuer &
|
|
33
26
|
ICredentialVerifier &
|
|
34
|
-
|
|
27
|
+
IVcdmCredentialPlugin &
|
|
35
28
|
IStatusListPlugin &
|
|
36
29
|
IResolver
|
|
37
30
|
export type IRequiredContext = IAgentContext<IRequiredPlugins>
|
|
38
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
|
+
|
|
39
57
|
export interface IStatusListDriver {
|
|
40
58
|
statusListStore: StatusListStore
|
|
41
59
|
|
|
@@ -43,16 +61,16 @@ export interface IStatusListDriver {
|
|
|
43
61
|
|
|
44
62
|
getOptions(): DriverOptions
|
|
45
63
|
|
|
46
|
-
getStatusListLength(args?:
|
|
64
|
+
getStatusListLength(args?: IGetStatusListLengthArgs): Promise<number>
|
|
47
65
|
|
|
48
|
-
createStatusList(args:
|
|
66
|
+
createStatusList(args: ICreateStatusListArgs): Promise<StatusListResult>
|
|
49
67
|
|
|
50
|
-
getStatusList(args?:
|
|
68
|
+
getStatusList(args?: IGetStatusListArgs): Promise<StatusListResult>
|
|
51
69
|
|
|
52
70
|
getStatusLists(): Promise<Array<StatusListResult>>
|
|
53
71
|
|
|
54
72
|
updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<{
|
|
55
|
-
credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus
|
|
73
|
+
credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus | BitstringStatusListEntryCredentialStatus
|
|
56
74
|
statusListEntry: IStatusListEntryEntity
|
|
57
75
|
}>
|
|
58
76
|
|
|
@@ -60,11 +78,11 @@ export interface IStatusListDriver {
|
|
|
60
78
|
|
|
61
79
|
getStatusListEntryByIndex(args: IGetStatusListEntryByIndexArgs): Promise<IStatusListEntryEntity | undefined>
|
|
62
80
|
|
|
63
|
-
updateStatusList(args:
|
|
81
|
+
updateStatusList(args: IUpdateStatusListArgs): Promise<StatusListResult>
|
|
64
82
|
|
|
65
83
|
deleteStatusList(): Promise<boolean>
|
|
66
84
|
|
|
67
|
-
getRandomNewStatusListIndex(args?:
|
|
85
|
+
getRandomNewStatusListIndex(args?: IGetRandomNewStatusListIndexArgs): Promise<number>
|
|
68
86
|
|
|
69
87
|
isStatusListIndexInUse(): Promise<boolean>
|
|
70
88
|
}
|