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