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