@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/dist/index.js
CHANGED
|
@@ -3,8 +3,8 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
|
|
4
4
|
// src/drivers.ts
|
|
5
5
|
import { DataSources } from "@sphereon/ssi-sdk.agent-config";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { StatusListStore } from "@sphereon/ssi-sdk.data-store";
|
|
7
|
+
import { createCredentialStatusFromStatusList, extractCredentialDetails, toStatusListDetails } from "@sphereon/ssi-sdk.vc-status-list";
|
|
8
8
|
import { StatusListCredentialIdMode, StatusListDriverType } from "@sphereon/ssi-types";
|
|
9
9
|
|
|
10
10
|
// src/status-list-adapters.ts
|
|
@@ -48,6 +48,7 @@ function statusListResultToEntity(result) {
|
|
|
48
48
|
...baseFields,
|
|
49
49
|
statusPurpose: result.bitstringStatusList.statusPurpose,
|
|
50
50
|
ttl: result.bitstringStatusList.ttl,
|
|
51
|
+
bitsPerStatus: result.bitstringStatusList.bitsPerStatus,
|
|
51
52
|
validFrom: result.bitstringStatusList.validFrom,
|
|
52
53
|
validUntil: result.bitstringStatusList.validUntil
|
|
53
54
|
});
|
|
@@ -91,11 +92,23 @@ var AgentDataSourceStatusListDriver = class _AgentDataSourceStatusListDriver {
|
|
|
91
92
|
_statusListStore;
|
|
92
93
|
options;
|
|
93
94
|
_statusListLength;
|
|
95
|
+
/**
|
|
96
|
+
* Creates a new AgentDataSourceStatusListDriver instance
|
|
97
|
+
* @param _dataSource - TypeORM DataSource for database operations
|
|
98
|
+
* @param _statusListStore - StatusListStore for data persistence
|
|
99
|
+
* @param options - Driver configuration options
|
|
100
|
+
*/
|
|
94
101
|
constructor(_dataSource, _statusListStore, options) {
|
|
95
102
|
this._dataSource = _dataSource;
|
|
96
103
|
this._statusListStore = _statusListStore;
|
|
97
104
|
this.options = options;
|
|
98
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Initializes and creates a new AgentDataSourceStatusListDriver instance
|
|
108
|
+
* @param options - Status list management configuration
|
|
109
|
+
* @param dbArgs - Database connection arguments
|
|
110
|
+
* @returns Promise resolving to initialized driver instance
|
|
111
|
+
*/
|
|
99
112
|
static async init(options, dbArgs) {
|
|
100
113
|
if (options.driverType !== StatusListDriverType.AGENT_TYPEORM) {
|
|
101
114
|
throw Error(`TypeORM driver can only be used when the TypeORM driver type is selected in the configuration. Got: ${options.driverType}`);
|
|
@@ -118,80 +131,105 @@ var AgentDataSourceStatusListDriver = class _AgentDataSourceStatusListDriver {
|
|
|
118
131
|
statusListStore = new StatusListStore(dataSource);
|
|
119
132
|
return new _AgentDataSourceStatusListDriver(dataSource, statusListStore, options);
|
|
120
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Gets the TypeORM DataSource instance
|
|
136
|
+
* @returns DataSource instance for database operations
|
|
137
|
+
*/
|
|
121
138
|
get dataSource() {
|
|
122
139
|
if (!this._dataSource) {
|
|
123
140
|
throw Error(`Datasource not available yet for ${this.options.driverOptions?.dbName}`);
|
|
124
141
|
}
|
|
125
142
|
return this._dataSource;
|
|
126
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* Gets the StatusListStore instance
|
|
146
|
+
* @returns StatusListStore for data persistence operations
|
|
147
|
+
*/
|
|
127
148
|
get statusListStore() {
|
|
128
149
|
if (!this._statusListStore) {
|
|
129
150
|
this._statusListStore = new StatusListStore(this.dataSource);
|
|
130
151
|
}
|
|
131
152
|
return this._statusListStore;
|
|
132
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Gets the driver configuration options
|
|
156
|
+
* @returns DriverOptions configuration
|
|
157
|
+
*/
|
|
133
158
|
getOptions() {
|
|
134
159
|
return this.options.driverOptions ?? {};
|
|
135
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Gets the driver type
|
|
163
|
+
* @returns StatusListDriverType enum value
|
|
164
|
+
*/
|
|
136
165
|
getType() {
|
|
137
166
|
return this.options.driverType;
|
|
138
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Creates a new status list credential and stores it in the database
|
|
170
|
+
* @param args - Status list creation parameters
|
|
171
|
+
* @returns Promise resolving to StatusListResult
|
|
172
|
+
*/
|
|
139
173
|
async createStatusList(args) {
|
|
140
174
|
const correlationId = args.correlationId ?? this.options.correlationId;
|
|
141
175
|
if (!correlationId) {
|
|
142
176
|
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
177
|
}
|
|
144
178
|
const credentialIdMode = args.credentialIdMode ?? StatusListCredentialIdMode.ISSUANCE;
|
|
145
|
-
const
|
|
146
|
-
|
|
179
|
+
const implementationResult = await toStatusListDetails({
|
|
180
|
+
statusListCredential: args.statusListCredential,
|
|
181
|
+
statusListType: args.statusListType,
|
|
182
|
+
bitsPerStatus: args.bitsPerStatus,
|
|
147
183
|
correlationId,
|
|
148
|
-
driverType: this.getType()
|
|
149
|
-
bitsPerStatus: args.bitsPerStatus
|
|
184
|
+
driverType: this.getType()
|
|
150
185
|
});
|
|
151
|
-
|
|
152
|
-
...
|
|
186
|
+
const statusListArgs = {
|
|
187
|
+
...implementationResult,
|
|
153
188
|
credentialIdMode,
|
|
154
189
|
correlationId,
|
|
155
|
-
...args.bitsPerStatus && {
|
|
156
|
-
bitsPerStatus: args.bitsPerStatus
|
|
157
|
-
},
|
|
158
190
|
driverType: this.getType()
|
|
159
|
-
}
|
|
160
|
-
this.
|
|
161
|
-
|
|
191
|
+
};
|
|
192
|
+
await this.statusListStore.addStatusList(statusListArgs);
|
|
193
|
+
this._statusListLength = implementationResult.length;
|
|
194
|
+
return implementationResult;
|
|
162
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Updates an existing status list credential in the database
|
|
198
|
+
* @param args - Status list update parameters
|
|
199
|
+
* @returns Promise resolving to StatusListResult
|
|
200
|
+
*/
|
|
163
201
|
async updateStatusList(args) {
|
|
164
202
|
const correlationId = args.correlationId ?? this.options.correlationId;
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
});
|
|
170
|
-
const entity = await (await this.statusListStore.getStatusListRepo(args.type)).findOne({
|
|
171
|
-
where: [
|
|
172
|
-
{
|
|
173
|
-
id: details.id
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
correlationId
|
|
177
|
-
}
|
|
178
|
-
]
|
|
203
|
+
const extractedDetails = await extractCredentialDetails(args.statusListCredential);
|
|
204
|
+
const entity = await this.statusListStore.getStatusList({
|
|
205
|
+
id: extractedDetails.id,
|
|
206
|
+
correlationId
|
|
179
207
|
});
|
|
180
208
|
if (!entity) {
|
|
181
|
-
throw Error(`Status list ${
|
|
209
|
+
throw Error(`Status list ${extractedDetails.id}, correlationId ${correlationId} could not be found`);
|
|
182
210
|
}
|
|
183
|
-
|
|
211
|
+
entity.statusListCredential = args.statusListCredential;
|
|
212
|
+
const details = await toStatusListDetails({
|
|
213
|
+
extractedDetails,
|
|
214
|
+
statusListEntity: entity
|
|
215
|
+
});
|
|
216
|
+
const updateArgs = {
|
|
184
217
|
...entity,
|
|
185
218
|
...details,
|
|
186
219
|
correlationId,
|
|
187
220
|
driverType: this.getType()
|
|
188
|
-
}
|
|
221
|
+
};
|
|
222
|
+
await this.statusListStore.updateStatusList(updateArgs);
|
|
189
223
|
this._statusListLength = details.length;
|
|
190
224
|
return {
|
|
191
225
|
...entity,
|
|
192
226
|
...details
|
|
193
227
|
};
|
|
194
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* Deletes the status list from the database
|
|
231
|
+
* @returns Promise resolving to boolean indicating success
|
|
232
|
+
*/
|
|
195
233
|
async deleteStatusList() {
|
|
196
234
|
await this.statusListStore.removeStatusList({
|
|
197
235
|
id: this.options.id,
|
|
@@ -199,64 +237,48 @@ var AgentDataSourceStatusListDriver = class _AgentDataSourceStatusListDriver {
|
|
|
199
237
|
});
|
|
200
238
|
return Promise.resolve(true);
|
|
201
239
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
isBitstringStatusListEntity(statusList) {
|
|
209
|
-
return statusList instanceof BitstringStatusListEntity2;
|
|
210
|
-
}
|
|
240
|
+
/**
|
|
241
|
+
* Updates a status list entry and returns the credential status
|
|
242
|
+
* @param args - Status list entry update parameters
|
|
243
|
+
* @returns Promise resolving to credential status and entry
|
|
244
|
+
*/
|
|
211
245
|
async updateStatusListEntry(args) {
|
|
212
|
-
const
|
|
246
|
+
const statusListEntity = statusListResultToEntity(await this.getStatusList());
|
|
213
247
|
const statusListEntry = await this.statusListStore.updateStatusListEntry({
|
|
214
248
|
...args,
|
|
215
|
-
statusListId:
|
|
249
|
+
statusListId: statusListEntity.id
|
|
216
250
|
});
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
statusListEntry
|
|
227
|
-
};
|
|
228
|
-
} else if (this.isOAuthStatusListEntity(statusList)) {
|
|
229
|
-
return {
|
|
230
|
-
credentialStatus: {
|
|
231
|
-
id: `${statusList.id}#${statusListEntry.statusListIndex}`,
|
|
232
|
-
type: "OAuthStatusListEntry",
|
|
233
|
-
bitsPerStatus: statusList.bitsPerStatus,
|
|
234
|
-
statusListIndex: "" + statusListEntry.statusListIndex,
|
|
235
|
-
statusListCredential: statusList.id,
|
|
236
|
-
expiresAt: statusList.expiresAt
|
|
237
|
-
},
|
|
238
|
-
statusListEntry
|
|
239
|
-
};
|
|
240
|
-
} else if (this.isBitstringStatusListEntity(statusList)) {
|
|
241
|
-
return {
|
|
242
|
-
credentialStatus: {
|
|
243
|
-
id: `${statusList.id}#${statusListEntry.statusListIndex}`,
|
|
244
|
-
type: "BitstringStatusListEntry",
|
|
245
|
-
statusPurpose: statusList.statusPurpose,
|
|
246
|
-
statusListIndex: "" + statusListEntry.statusListIndex,
|
|
247
|
-
statusListCredential: statusList.id
|
|
248
|
-
},
|
|
249
|
-
statusListEntry
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
throw new Error(`Unsupported status list type: ${typeof statusList}`);
|
|
251
|
+
const credentialStatus = await createCredentialStatusFromStatusList({
|
|
252
|
+
statusList: statusListEntity,
|
|
253
|
+
statusListEntry,
|
|
254
|
+
statusListIndex: statusListEntry.statusListIndex
|
|
255
|
+
});
|
|
256
|
+
return {
|
|
257
|
+
credentialStatus,
|
|
258
|
+
statusListEntry
|
|
259
|
+
};
|
|
253
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* Retrieves a status list entry by credential ID
|
|
263
|
+
* @param args - Query parameters including credential ID
|
|
264
|
+
* @returns Promise resolving to status list entry or undefined
|
|
265
|
+
*/
|
|
254
266
|
async getStatusListEntryByCredentialId(args) {
|
|
255
267
|
return await this.statusListStore.getStatusListEntryByCredentialId(args);
|
|
256
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* Retrieves a status list entry by index
|
|
271
|
+
* @param args - Query parameters including status list index
|
|
272
|
+
* @returns Promise resolving to status list entry or undefined
|
|
273
|
+
*/
|
|
257
274
|
async getStatusListEntryByIndex(args) {
|
|
258
275
|
return await this.statusListStore.getStatusListEntryByIndex(args);
|
|
259
276
|
}
|
|
277
|
+
/**
|
|
278
|
+
* Generates a random available index for new status list entries
|
|
279
|
+
* @param args - Optional correlation ID parameter
|
|
280
|
+
* @returns Promise resolving to available index number
|
|
281
|
+
*/
|
|
260
282
|
async getRandomNewStatusListIndex(args) {
|
|
261
283
|
let result = -1;
|
|
262
284
|
let tries = 0;
|
|
@@ -265,6 +287,12 @@ var AgentDataSourceStatusListDriver = class _AgentDataSourceStatusListDriver {
|
|
|
265
287
|
}
|
|
266
288
|
return result;
|
|
267
289
|
}
|
|
290
|
+
/**
|
|
291
|
+
* Implementation for generating random status list indices with retry logic
|
|
292
|
+
* @param tries - Number of attempts made
|
|
293
|
+
* @param args - Optional correlation ID parameter
|
|
294
|
+
* @returns Promise resolving to available index or -1 if none found
|
|
295
|
+
*/
|
|
268
296
|
async getRandomNewStatusListIndexImpl(tries, args) {
|
|
269
297
|
const statusListId = this.options.id;
|
|
270
298
|
const correlationId = args?.correlationId ?? this.options.correlationId;
|
|
@@ -287,31 +315,57 @@ var AgentDataSourceStatusListDriver = class _AgentDataSourceStatusListDriver {
|
|
|
287
315
|
}
|
|
288
316
|
return -1;
|
|
289
317
|
}
|
|
318
|
+
/**
|
|
319
|
+
* Gets the length of the status list
|
|
320
|
+
* @param args - Optional correlation ID parameter
|
|
321
|
+
* @returns Promise resolving to status list length
|
|
322
|
+
*/
|
|
290
323
|
async getStatusListLength(args) {
|
|
291
324
|
if (!this._statusListLength) {
|
|
292
325
|
this._statusListLength = await this.getStatusList(args).then((details) => details.length);
|
|
293
326
|
}
|
|
294
327
|
return this._statusListLength;
|
|
295
328
|
}
|
|
329
|
+
/**
|
|
330
|
+
* Retrieves the status list details
|
|
331
|
+
* @param args - Optional correlation ID parameter
|
|
332
|
+
* @returns Promise resolving to StatusListResult
|
|
333
|
+
*/
|
|
296
334
|
async getStatusList(args) {
|
|
297
335
|
const id = this.options.id;
|
|
298
336
|
const correlationId = args?.correlationId ?? this.options.correlationId;
|
|
299
|
-
|
|
337
|
+
const statusListEntity = await this.statusListStore.getStatusList({
|
|
300
338
|
id,
|
|
301
339
|
correlationId
|
|
302
|
-
})
|
|
340
|
+
});
|
|
341
|
+
return await toStatusListDetails({
|
|
303
342
|
statusListCredential: statusListEntity.statusListCredential,
|
|
304
|
-
|
|
305
|
-
|
|
343
|
+
statusListType: statusListEntity.type,
|
|
344
|
+
bitsPerStatus: statusListEntity.bitsPerStatus,
|
|
345
|
+
correlationId: statusListEntity.correlationId,
|
|
346
|
+
driverType: statusListEntity.driverType
|
|
347
|
+
});
|
|
306
348
|
}
|
|
349
|
+
/**
|
|
350
|
+
* Retrieves all status lists
|
|
351
|
+
* @returns Promise resolving to array of StatusListResult
|
|
352
|
+
*/
|
|
307
353
|
async getStatusLists() {
|
|
308
354
|
const statusLists = await this.statusListStore.getStatusLists({});
|
|
309
355
|
return Promise.all(statusLists.map(async (statusListEntity) => {
|
|
310
|
-
return
|
|
311
|
-
statusListCredential: statusListEntity.statusListCredential
|
|
356
|
+
return toStatusListDetails({
|
|
357
|
+
statusListCredential: statusListEntity.statusListCredential,
|
|
358
|
+
statusListType: statusListEntity.type,
|
|
359
|
+
bitsPerStatus: statusListEntity.bitsPerStatus,
|
|
360
|
+
correlationId: statusListEntity.correlationId,
|
|
361
|
+
driverType: statusListEntity.driverType
|
|
312
362
|
});
|
|
313
363
|
}));
|
|
314
364
|
}
|
|
365
|
+
/**
|
|
366
|
+
* Checks if a status list index is currently in use
|
|
367
|
+
* @returns Promise resolving to boolean indicating usage status
|
|
368
|
+
*/
|
|
315
369
|
isStatusListIndexInUse() {
|
|
316
370
|
return Promise.resolve(false);
|
|
317
371
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/drivers.ts","../src/status-list-adapters.ts"],"sourcesContent":["import { DataSources } from '@sphereon/ssi-sdk.agent-config'\nimport {\n BitstringStatusListEntity,\n IAddStatusListEntryArgs,\n IGetStatusListEntryByCredentialIdArgs,\n IGetStatusListEntryByIndexArgs,\n IStatusListEntity,\n IStatusListEntryEntity,\n OAuthStatusListEntity,\n StatusList2021Entity,\n StatusListEntity,\n StatusListStore,\n} from '@sphereon/ssi-sdk.data-store'\nimport {\n BitstringStatusListEntryCredentialStatus,\n StatusList2021EntryCredentialStatus,\n statusListCredentialToDetails,\n StatusListOAuthEntryCredentialStatus,\n StatusListResult,\n} from '@sphereon/ssi-sdk.vc-status-list'\nimport { StatusListCredential, StatusListCredentialIdMode, StatusListDriverType, StatusListType } from '@sphereon/ssi-types'\nimport { DataSource } from 'typeorm'\nimport { IStatusListDriver } from './types'\nimport { statusListResultToEntity } from './status-list-adapters'\n\nexport interface StatusListManagementOptions {\n id?: string\n correlationId?: string\n driverType: StatusListDriverType\n driverOptions?: DriverOptions\n}\n\nexport type DriverOptions = TypeORMOptions\n\nexport interface TypeORMOptions {\n dbName?: string\n}\n\nexport interface FilesystemOptions {\n path: string // The base path where statusList Credentials will be persisted. Should be a folder and thus not include the VC/StatusList itself\n}\n\nexport function getOptions(args: { id?: string; correlationId?: string; dbName: string }): StatusListManagementOptions {\n return {\n id: args.id,\n correlationId: args.correlationId,\n driverType: StatusListDriverType.AGENT_TYPEORM,\n driverOptions: { dbName: args.dbName },\n }\n}\n\nexport async function getDriver(args: {\n id?: string\n correlationId?: string\n dbName?: string\n dataSource?: DataSource\n dataSources?: DataSources\n}): Promise<IStatusListDriver> {\n const dbName = args.dbName ?? args.dataSource?.name\n if (!dbName) {\n throw Error(`Please provide either a DB name or data source`)\n }\n const dataSources = args.dataSources ?? DataSources.singleInstance()\n return await AgentDataSourceStatusListDriver.init(\n getOptions({\n ...args,\n dbName,\n }),\n { dataSource: args.dataSource ?? (await dataSources.getDbConnection(dbName)), dataSources },\n )\n}\n\nexport class AgentDataSourceStatusListDriver implements IStatusListDriver {\n private _statusListLength: number | undefined\n\n constructor(\n private _dataSource: DataSource,\n private _statusListStore: StatusListStore,\n private options: StatusListManagementOptions,\n ) {}\n\n public static async init(\n options: StatusListManagementOptions,\n dbArgs?: {\n dataSources?: DataSources\n dataSource?: DataSource\n },\n ): Promise<AgentDataSourceStatusListDriver> {\n if (options.driverType !== StatusListDriverType.AGENT_TYPEORM) {\n throw Error(`TypeORM driver can only be used when the TypeORM driver type is selected in the configuration. Got: ${options.driverType}`)\n } else if (!options.driverOptions) {\n throw Error(`TypeORM driver can only be used when the TypeORM options are provided.`)\n }\n let dataSource: DataSource\n let statusListStore: StatusListStore\n if (dbArgs?.dataSource) {\n dataSource = dbArgs.dataSource\n } else if (options.driverOptions.dbName) {\n if (dbArgs?.dataSources) {\n dataSource = await dbArgs.dataSources.getDbConnection(options.driverOptions.dbName)\n } else {\n dataSource = await DataSources.singleInstance().getDbConnection(options.driverOptions.dbName)\n }\n } else {\n return Promise.reject(Error(`Either a datasource or dbName needs to be provided`))\n }\n\n statusListStore = new StatusListStore(dataSource)\n return new AgentDataSourceStatusListDriver(dataSource, statusListStore, options)\n }\n\n get dataSource(): DataSource {\n if (!this._dataSource) {\n throw Error(`Datasource not available yet for ${this.options.driverOptions?.dbName}`)\n }\n return this._dataSource\n }\n\n get statusListStore(): StatusListStore {\n if (!this._statusListStore) {\n this._statusListStore = new StatusListStore(this.dataSource)\n }\n return this._statusListStore\n }\n\n getOptions(): DriverOptions {\n return this.options.driverOptions ?? {}\n }\n\n getType(): StatusListDriverType {\n return this.options.driverType\n }\n\n async createStatusList(args: {\n statusListCredential: StatusListCredential\n correlationId?: string\n credentialIdMode?: StatusListCredentialIdMode\n bitsPerStatus?: number\n }): Promise<StatusListResult> {\n const correlationId = args.correlationId ?? this.options.correlationId\n if (!correlationId) {\n 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')\n }\n const credentialIdMode = args.credentialIdMode ?? StatusListCredentialIdMode.ISSUANCE\n const details = await statusListCredentialToDetails({ ...args, correlationId, driverType: this.getType(), bitsPerStatus: args.bitsPerStatus })\n\n // (StatusListStore does the duplicate entity check)\n await this.statusListStore.addStatusList({\n ...details,\n credentialIdMode,\n correlationId,\n ...(args.bitsPerStatus && { bitsPerStatus: args.bitsPerStatus }),\n driverType: this.getType(),\n })\n this._statusListLength = details.length\n return details\n }\n\n async updateStatusList(args: {\n statusListCredential: StatusListCredential\n correlationId: string\n type: StatusListType\n }): Promise<StatusListResult> {\n const correlationId = args.correlationId ?? this.options.correlationId\n const details = await statusListCredentialToDetails({ ...args, correlationId, driverType: this.getType() })\n const entity = await (\n await this.statusListStore.getStatusListRepo(args.type)\n ).findOne({\n where: [\n {\n id: details.id,\n },\n {\n correlationId,\n },\n ],\n })\n if (!entity) {\n throw Error(`Status list ${details.id}, correlationId ${args.correlationId} could not be found`)\n }\n await this.statusListStore.updateStatusList({\n ...entity,\n ...details,\n correlationId,\n driverType: this.getType(),\n })\n this._statusListLength = details.length\n return { ...entity, ...details }\n }\n\n async deleteStatusList(): Promise<boolean> {\n await this.statusListStore.removeStatusList({ id: this.options.id, correlationId: this.options.correlationId })\n return Promise.resolve(true)\n }\n\n private isStatusList2021Entity(statusList: StatusListEntity): statusList is StatusList2021Entity {\n return statusList instanceof StatusList2021Entity\n }\n\n private isOAuthStatusListEntity(statusList: StatusListEntity): statusList is OAuthStatusListEntity {\n return statusList instanceof OAuthStatusListEntity\n }\n\n private isBitstringStatusListEntity(statusList: StatusListEntity): statusList is BitstringStatusListEntity {\n return statusList instanceof BitstringStatusListEntity\n }\n\n async updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<{\n credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus | BitstringStatusListEntryCredentialStatus\n statusListEntry: IStatusListEntryEntity\n }> {\n const statusList: StatusListEntity = args.statusList ? args.statusList : statusListResultToEntity(await this.getStatusList())\n const statusListEntry = await this.statusListStore.updateStatusListEntry({ ...args, statusListId: statusList.id })\n\n if (this.isStatusList2021Entity(statusList)) {\n return {\n credentialStatus: {\n id: `${statusList.id}#${statusListEntry.statusListIndex}`,\n type: 'StatusList2021Entry',\n statusPurpose: statusList.statusPurpose ?? 'revocation',\n statusListIndex: '' + statusListEntry.statusListIndex,\n statusListCredential: statusList.id,\n },\n statusListEntry,\n }\n } else if (this.isOAuthStatusListEntity(statusList)) {\n return {\n credentialStatus: {\n id: `${statusList.id}#${statusListEntry.statusListIndex}`,\n type: 'OAuthStatusListEntry',\n bitsPerStatus: statusList.bitsPerStatus,\n statusListIndex: '' + statusListEntry.statusListIndex,\n statusListCredential: statusList.id,\n expiresAt: statusList.expiresAt,\n },\n statusListEntry,\n }\n } else if (this.isBitstringStatusListEntity(statusList)) {\n return {\n credentialStatus: {\n id: `${statusList.id}#${statusListEntry.statusListIndex}`,\n type: 'BitstringStatusListEntry',\n statusPurpose: statusList.statusPurpose,\n statusListIndex: '' + statusListEntry.statusListIndex,\n statusListCredential: statusList.id,\n } satisfies BitstringStatusListEntryCredentialStatus,\n statusListEntry,\n }\n }\n\n throw new Error(`Unsupported status list type: ${typeof statusList}`)\n }\n\n async getStatusListEntryByCredentialId(args: IGetStatusListEntryByCredentialIdArgs): Promise<IStatusListEntryEntity | undefined> {\n return await this.statusListStore.getStatusListEntryByCredentialId(args)\n }\n\n async getStatusListEntryByIndex(args: IGetStatusListEntryByIndexArgs): Promise<IStatusListEntryEntity | undefined> {\n return await this.statusListStore.getStatusListEntryByIndex(args)\n }\n\n async getRandomNewStatusListIndex(args?: { correlationId?: string }): Promise<number> {\n let result = -1\n let tries = 0\n while (result < 0) {\n // no tries guard, because we will throw an error when they are exhausted anyway\n result = await this.getRandomNewStatusListIndexImpl(tries++, args)\n }\n return result\n }\n\n private async getRandomNewStatusListIndexImpl(tries: number, args?: { correlationId?: string }): Promise<number> {\n const statusListId = this.options.id\n const correlationId = args?.correlationId ?? this.options.correlationId\n if (tries >= 10) {\n throw Error(`We could not find any random status list index that is available in the statuslist ${statusListId}`)\n }\n // TODO: Check against DB\n const length = await this.getStatusListLength(args)\n const statusListIndex = Array.from({ length: 20 }, () => Math.floor(Math.random() * length))\n const available = await this.statusListStore.availableStatusListEntries({\n statusListId,\n ...(correlationId && { correlationId }),\n statusListIndex,\n })\n if (available.length > 0) {\n return available[0] // doesn't matter we pick the first element, as they are all random anyway\n }\n return -1\n }\n\n async getStatusListLength(args?: { correlationId?: string }): Promise<number> {\n if (!this._statusListLength) {\n this._statusListLength = await this.getStatusList(args).then((details) => details.length)\n }\n return this._statusListLength!\n }\n\n async getStatusList(args?: { correlationId?: string }): Promise<StatusListResult> {\n const id = this.options.id\n const correlationId = args?.correlationId ?? this.options.correlationId\n return await this.statusListStore.getStatusList({ id, correlationId }).then((statusListEntity: IStatusListEntity) =>\n statusListCredentialToDetails({\n statusListCredential: statusListEntity.statusListCredential!,\n bitsPerStatus: statusListEntity.bitsPerStatus,\n }),\n )\n }\n\n async getStatusLists(): Promise<Array<StatusListResult>> {\n const statusLists = await this.statusListStore.getStatusLists({})\n return Promise.all(\n statusLists.map(async (statusListEntity) => {\n return statusListCredentialToDetails({\n statusListCredential: statusListEntity.statusListCredential!,\n })\n }),\n )\n }\n\n isStatusListIndexInUse(): Promise<boolean> {\n return Promise.resolve(false)\n }\n}\n","import { StatusListType } from '@sphereon/ssi-types'\nimport { BitstringStatusListEntity, OAuthStatusListEntity, StatusList2021Entity } from '@sphereon/ssi-sdk.data-store'\nimport { StatusListResult } from '@sphereon/ssi-sdk.vc-status-list'\n\nexport function statusListResultToEntity(result: StatusListResult): StatusList2021Entity | OAuthStatusListEntity | BitstringStatusListEntity {\n const baseFields = {\n id: result.id,\n correlationId: result.correlationId,\n driverType: result.driverType,\n credentialIdMode: result.credentialIdMode,\n length: result.length,\n issuer: result.issuer,\n type: result.type,\n proofFormat: result.proofFormat,\n statusListCredential: result.statusListCredential,\n }\n\n if (result.type === StatusListType.StatusList2021) {\n if (!result.statusList2021) {\n throw new Error('Missing statusList2021 details')\n }\n return Object.assign(new StatusList2021Entity(), {\n ...baseFields,\n indexingDirection: result.statusList2021.indexingDirection,\n statusPurpose: result.statusList2021.statusPurpose,\n })\n } else if (result.type === StatusListType.OAuthStatusList) {\n if (!result.oauthStatusList) {\n throw new Error('Missing oauthStatusList details')\n }\n return Object.assign(new OAuthStatusListEntity(), {\n ...baseFields,\n bitsPerStatus: result.oauthStatusList.bitsPerStatus,\n expiresAt: result.oauthStatusList.expiresAt,\n })\n } else if (result.type === StatusListType.BitstringStatusList) {\n if (!result.bitstringStatusList) {\n throw new Error('Missing bitstringStatusList details')\n }\n return Object.assign(new BitstringStatusListEntity(), {\n ...baseFields,\n statusPurpose: result.bitstringStatusList.statusPurpose,\n ttl: result.bitstringStatusList.ttl,\n validFrom: result.bitstringStatusList.validFrom,\n validUntil: result.bitstringStatusList.validUntil,\n })\n }\n throw new Error(`Unsupported status list type: ${result.type}`)\n}\n"],"mappings":";;;;AAAA,SAASA,mBAAmB;AAC5B,SACEC,6BAAAA,4BAMAC,yBAAAA,wBACAC,wBAAAA,uBAEAC,uBACK;AACP,SAGEC,qCAGK;AACP,SAA+BC,4BAA4BC,4BAA4C;;;ACpBvG,SAASC,sBAAsB;AAC/B,SAASC,2BAA2BC,uBAAuBC,4BAA4B;AAGhF,SAASC,yBAAyBC,QAAwB;AAC/D,QAAMC,aAAa;IACjBC,IAAIF,OAAOE;IACXC,eAAeH,OAAOG;IACtBC,YAAYJ,OAAOI;IACnBC,kBAAkBL,OAAOK;IACzBC,QAAQN,OAAOM;IACfC,QAAQP,OAAOO;IACfC,MAAMR,OAAOQ;IACbC,aAAaT,OAAOS;IACpBC,sBAAsBV,OAAOU;EAC/B;AAEA,MAAIV,OAAOQ,SAASG,eAAeC,gBAAgB;AACjD,QAAI,CAACZ,OAAOa,gBAAgB;AAC1B,YAAM,IAAIC,MAAM,gCAAA;IAClB;AACA,WAAOC,OAAOC,OAAO,IAAIC,qBAAAA,GAAwB;MAC/C,GAAGhB;MACHiB,mBAAmBlB,OAAOa,eAAeK;MACzCC,eAAenB,OAAOa,eAAeM;IACvC,CAAA;EACF,WAAWnB,OAAOQ,SAASG,eAAeS,iBAAiB;AACzD,QAAI,CAACpB,OAAOqB,iBAAiB;AAC3B,YAAM,IAAIP,MAAM,iCAAA;IAClB;AACA,WAAOC,OAAOC,OAAO,IAAIM,sBAAAA,GAAyB;MAChD,GAAGrB;MACHsB,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AiBjB;MACvC3B,eAAe4C,iBAAiB5C;IAClC,CAAA,CAAA;EAEJ;EAEA,MAAM6C,iBAAmD;AACvD,UAAMC,cAAc,MAAM,KAAKzD,gBAAgBwD,eAAe,CAAC,CAAA;AAC/D,WAAOvD,QAAQyD,IACbD,YAAYE,IAAI,OAAOJ,qBAAAA;AACrB,aAAO7C,8BAA8B;QACnC4B,sBAAsBiB,iBAAiBjB;MACzC,CAAA;IACF,CAAA,CAAA;EAEJ;EAEAsB,yBAA2C;AACzC,WAAO3D,QAAQqB,QAAQ,KAAA;EACzB;AACF;","names":["DataSources","BitstringStatusListEntity","OAuthStatusListEntity","StatusList2021Entity","StatusListStore","statusListCredentialToDetails","StatusListCredentialIdMode","StatusListDriverType","StatusListType","BitstringStatusListEntity","OAuthStatusListEntity","StatusList2021Entity","statusListResultToEntity","result","baseFields","id","correlationId","driverType","credentialIdMode","length","issuer","type","proofFormat","statusListCredential","StatusListType","StatusList2021","statusList2021","Error","Object","assign","StatusList2021Entity","indexingDirection","statusPurpose","OAuthStatusList","oauthStatusList","OAuthStatusListEntity","bitsPerStatus","expiresAt","BitstringStatusList","bitstringStatusList","BitstringStatusListEntity","ttl","validFrom","validUntil","getOptions","args","id","correlationId","driverType","StatusListDriverType","AGENT_TYPEORM","driverOptions","dbName","getDriver","dataSource","name","Error","dataSources","DataSources","singleInstance","AgentDataSourceStatusListDriver","init","getDbConnection","_statusListLength","constructor","_dataSource","_statusListStore","options","dbArgs","statusListStore","Promise","reject","StatusListStore","getType","createStatusList","credentialIdMode","StatusListCredentialIdMode","ISSUANCE","details","statusListCredentialToDetails","bitsPerStatus","addStatusList","length","updateStatusList","entity","getStatusListRepo","type","findOne","where","deleteStatusList","removeStatusList","resolve","isStatusList2021Entity","statusList","StatusList2021Entity","isOAuthStatusListEntity","OAuthStatusListEntity","isBitstringStatusListEntity","BitstringStatusListEntity","updateStatusListEntry","statusListResultToEntity","getStatusList","statusListEntry","statusListId","credentialStatus","statusListIndex","statusPurpose","statusListCredential","expiresAt","getStatusListEntryByCredentialId","getStatusListEntryByIndex","getRandomNewStatusListIndex","result","tries","getRandomNewStatusListIndexImpl","getStatusListLength","Array","from","Math","floor","random","available","availableStatusListEntries","then","statusListEntity","getStatusLists","statusLists","all","map","isStatusListIndexInUse"]}
|
|
1
|
+
{"version":3,"sources":["../src/drivers.ts","../src/status-list-adapters.ts"],"sourcesContent":["/**\n * StatusList Driver Implementation for TypeORM/Agent Data Sources\n *\n * This module provides the database-backed implementation of the IStatusListDriver interface,\n * handling persistence and retrieval of status list credentials and entries using TypeORM.\n * It delegates status list format-specific operations to the functions layer while managing\n * database interactions, driver configuration, and entity lifecycle.\n *\n * Key responsibilities:\n * - Database connection and store management\n * - Status list CRUD operations\n * - Status list entry management\n * - Random index generation for new entries\n * - Integration with multiple data sources\n *\n * @author Sphereon International B.V.\n * @since 2024\n */\n\nimport { DataSources } from '@sphereon/ssi-sdk.agent-config'\nimport {\n BitstringStatusListEntryCredentialStatus,\n IAddStatusListArgs,\n IAddStatusListEntryArgs,\n IBitstringStatusListEntryEntity,\n IGetStatusListEntryByCredentialIdArgs,\n IGetStatusListEntryByIndexArgs,\n IStatusListEntryEntity,\n StatusListEntity,\n StatusListStore,\n} from '@sphereon/ssi-sdk.data-store'\nimport {\n createCredentialStatusFromStatusList,\n extractCredentialDetails,\n StatusList2021EntryCredentialStatus,\n StatusListOAuthEntryCredentialStatus,\n StatusListResult,\n toStatusListDetails,\n} from '@sphereon/ssi-sdk.vc-status-list'\nimport { StatusListCredentialIdMode, StatusListDriverType } from '@sphereon/ssi-types'\nimport { DataSource } from 'typeorm'\nimport {\n ICreateStatusListArgs,\n IGetRandomNewStatusListIndexArgs,\n IGetStatusListArgs,\n IGetStatusListLengthArgs,\n IStatusListDriver,\n IUpdateStatusListArgs,\n} from './types'\nimport { statusListResultToEntity } from './status-list-adapters'\n\n/**\n * Configuration options for status list management\n */\nexport interface StatusListManagementOptions {\n id?: string\n correlationId?: string\n driverType: StatusListDriverType\n driverOptions?: DriverOptions\n}\n\nexport type DriverOptions = TypeORMOptions\n\n/**\n * TypeORM-specific configuration options\n */\nexport interface TypeORMOptions {\n dbName?: string\n}\n\n/**\n * Filesystem-specific configuration options\n */\nexport interface FilesystemOptions {\n path: string // The base path where statusList Credentials will be persisted. Should be a folder and thus not include the VC/StatusList itself\n}\n\n/**\n * Creates status list management options for TypeORM driver\n * @param args - Configuration parameters including id, correlationId, and database name\n * @returns StatusListManagementOptions configured for TypeORM\n */\nexport function getOptions(args: { id?: string; correlationId?: string; dbName: string }): StatusListManagementOptions {\n return {\n id: args.id,\n correlationId: args.correlationId,\n driverType: StatusListDriverType.AGENT_TYPEORM,\n driverOptions: { dbName: args.dbName },\n }\n}\n\n/**\n * Creates and initializes a status list driver instance\n * @param args - Configuration parameters including database connection details\n * @returns Promise resolving to initialized IStatusListDriver instance\n */\nexport async function getDriver(args: {\n id?: string\n correlationId?: string\n dbName?: string\n dataSource?: DataSource\n dataSources?: DataSources\n}): Promise<IStatusListDriver> {\n const dbName = args.dbName ?? args.dataSource?.name\n if (!dbName) {\n throw Error(`Please provide either a DB name or data source`)\n }\n const dataSources = args.dataSources ?? DataSources.singleInstance()\n return await AgentDataSourceStatusListDriver.init(\n getOptions({\n ...args,\n dbName,\n }),\n { dataSource: args.dataSource ?? (await dataSources.getDbConnection(dbName)), dataSources },\n )\n}\n\n/**\n * TypeORM-based implementation of the IStatusListDriver interface\n *\n * Manages status list credentials and entries using a TypeORM data source.\n * Handles database operations while delegating format-specific logic to the functions layer.\n */\nexport class AgentDataSourceStatusListDriver implements IStatusListDriver {\n private _statusListLength: number | undefined\n\n /**\n * Creates a new AgentDataSourceStatusListDriver instance\n * @param _dataSource - TypeORM DataSource for database operations\n * @param _statusListStore - StatusListStore for data persistence\n * @param options - Driver configuration options\n */\n constructor(\n private _dataSource: DataSource,\n private _statusListStore: StatusListStore,\n private options: StatusListManagementOptions,\n ) {}\n\n /**\n * Initializes and creates a new AgentDataSourceStatusListDriver instance\n * @param options - Status list management configuration\n * @param dbArgs - Database connection arguments\n * @returns Promise resolving to initialized driver instance\n */\n public static async init(\n options: StatusListManagementOptions,\n dbArgs?: {\n dataSources?: DataSources\n dataSource?: DataSource\n },\n ): Promise<AgentDataSourceStatusListDriver> {\n if (options.driverType !== StatusListDriverType.AGENT_TYPEORM) {\n throw Error(`TypeORM driver can only be used when the TypeORM driver type is selected in the configuration. Got: ${options.driverType}`)\n } else if (!options.driverOptions) {\n throw Error(`TypeORM driver can only be used when the TypeORM options are provided.`)\n }\n let dataSource: DataSource\n let statusListStore: StatusListStore\n if (dbArgs?.dataSource) {\n dataSource = dbArgs.dataSource\n } else if (options.driverOptions.dbName) {\n if (dbArgs?.dataSources) {\n dataSource = await dbArgs.dataSources.getDbConnection(options.driverOptions.dbName)\n } else {\n dataSource = await DataSources.singleInstance().getDbConnection(options.driverOptions.dbName)\n }\n } else {\n return Promise.reject(Error(`Either a datasource or dbName needs to be provided`))\n }\n\n statusListStore = new StatusListStore(dataSource)\n return new AgentDataSourceStatusListDriver(dataSource, statusListStore, options)\n }\n\n /**\n * Gets the TypeORM DataSource instance\n * @returns DataSource instance for database operations\n */\n get dataSource(): DataSource {\n if (!this._dataSource) {\n throw Error(`Datasource not available yet for ${this.options.driverOptions?.dbName}`)\n }\n return this._dataSource\n }\n\n /**\n * Gets the StatusListStore instance\n * @returns StatusListStore for data persistence operations\n */\n get statusListStore(): StatusListStore {\n if (!this._statusListStore) {\n this._statusListStore = new StatusListStore(this.dataSource)\n }\n return this._statusListStore\n }\n\n /**\n * Gets the driver configuration options\n * @returns DriverOptions configuration\n */\n getOptions(): DriverOptions {\n return this.options.driverOptions ?? {}\n }\n\n /**\n * Gets the driver type\n * @returns StatusListDriverType enum value\n */\n getType(): StatusListDriverType {\n return this.options.driverType\n }\n\n /**\n * Creates a new status list credential and stores it in the database\n * @param args - Status list creation parameters\n * @returns Promise resolving to StatusListResult\n */\n async createStatusList(args: ICreateStatusListArgs): Promise<StatusListResult> {\n const correlationId = args.correlationId ?? this.options.correlationId\n if (!correlationId) {\n 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')\n }\n const credentialIdMode = args.credentialIdMode ?? StatusListCredentialIdMode.ISSUANCE\n\n // Convert credential to implementation details using CREATE/READ context\n const implementationResult = await toStatusListDetails({\n statusListCredential: args.statusListCredential,\n statusListType: args.statusListType,\n bitsPerStatus: args.bitsPerStatus,\n correlationId,\n driverType: this.getType(),\n })\n\n // Add driver-specific fields to create complete entity\n const statusListArgs = {\n ...implementationResult,\n credentialIdMode,\n correlationId,\n driverType: this.getType(),\n } as IAddStatusListArgs\n\n await this.statusListStore.addStatusList(statusListArgs)\n this._statusListLength = implementationResult.length\n return implementationResult\n }\n\n /**\n * Updates an existing status list credential in the database\n * @param args - Status list update parameters\n * @returns Promise resolving to StatusListResult\n */\n async updateStatusList(args: IUpdateStatusListArgs): Promise<StatusListResult> {\n const correlationId = args.correlationId ?? this.options.correlationId\n\n const extractedDetails = await extractCredentialDetails(args.statusListCredential)\n const entity = await this.statusListStore.getStatusList({\n id: extractedDetails.id,\n correlationId,\n })\n if (!entity) {\n throw Error(`Status list ${extractedDetails.id}, correlationId ${correlationId} could not be found`)\n }\n\n entity.statusListCredential = args.statusListCredential\n\n const details = await toStatusListDetails({\n extractedDetails,\n statusListEntity: entity,\n })\n\n // Merge details with existing entity and driver properties\n const updateArgs = {\n ...entity,\n ...details,\n correlationId,\n driverType: this.getType(),\n } as IAddStatusListArgs\n\n await this.statusListStore.updateStatusList(updateArgs)\n this._statusListLength = details.length\n return { ...entity, ...details }\n }\n\n /**\n * Deletes the status list from the database\n * @returns Promise resolving to boolean indicating success\n */\n async deleteStatusList(): Promise<boolean> {\n await this.statusListStore.removeStatusList({ id: this.options.id, correlationId: this.options.correlationId })\n return Promise.resolve(true)\n }\n\n /**\n * Updates a status list entry and returns the credential status\n * @param args - Status list entry update parameters\n * @returns Promise resolving to credential status and entry\n */\n async updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<{\n credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus | BitstringStatusListEntryCredentialStatus\n statusListEntry: IStatusListEntryEntity | IBitstringStatusListEntryEntity\n }> {\n // Get status list entity\n const statusListEntity: StatusListEntity = statusListResultToEntity(await this.getStatusList())\n\n // Update the entry in the store\n const statusListEntry = await this.statusListStore.updateStatusListEntry({ ...args, statusListId: statusListEntity.id })\n\n // Use implementation to create the credential status - this moves type-specific logic to implementations\n const credentialStatus = await createCredentialStatusFromStatusList({\n statusList: statusListEntity,\n statusListEntry,\n statusListIndex: statusListEntry.statusListIndex,\n })\n\n return {\n credentialStatus,\n statusListEntry,\n }\n }\n\n /**\n * Retrieves a status list entry by credential ID\n * @param args - Query parameters including credential ID\n * @returns Promise resolving to status list entry or undefined\n */\n async getStatusListEntryByCredentialId(\n args: IGetStatusListEntryByCredentialIdArgs,\n ): Promise<IStatusListEntryEntity | IBitstringStatusListEntryEntity | undefined> {\n return await this.statusListStore.getStatusListEntryByCredentialId(args)\n }\n\n /**\n * Retrieves a status list entry by index\n * @param args - Query parameters including status list index\n * @returns Promise resolving to status list entry or undefined\n */\n async getStatusListEntryByIndex(\n args: IGetStatusListEntryByIndexArgs,\n ): Promise<IStatusListEntryEntity | IBitstringStatusListEntryEntity | undefined> {\n return await this.statusListStore.getStatusListEntryByIndex(args)\n }\n\n /**\n * Generates a random available index for new status list entries\n * @param args - Optional correlation ID parameter\n * @returns Promise resolving to available index number\n */\n async getRandomNewStatusListIndex(args?: IGetRandomNewStatusListIndexArgs): Promise<number> {\n let result = -1\n let tries = 0\n while (result < 0) {\n // no tries guard, because we will throw an error when they are exhausted anyway\n result = await this.getRandomNewStatusListIndexImpl(tries++, args)\n }\n return result\n }\n\n /**\n * Implementation for generating random status list indices with retry logic\n * @param tries - Number of attempts made\n * @param args - Optional correlation ID parameter\n * @returns Promise resolving to available index or -1 if none found\n */\n private async getRandomNewStatusListIndexImpl(tries: number, args?: { correlationId?: string }): Promise<number> {\n const statusListId = this.options.id\n const correlationId = args?.correlationId ?? this.options.correlationId\n if (tries >= 10) {\n throw Error(`We could not find any random status list index that is available in the statuslist ${statusListId}`)\n }\n // TODO: Check against DB\n const length = await this.getStatusListLength(args)\n const statusListIndex = Array.from({ length: 20 }, () => Math.floor(Math.random() * length))\n const available = await this.statusListStore.availableStatusListEntries({\n statusListId,\n ...(correlationId && { correlationId }),\n statusListIndex,\n })\n if (available.length > 0) {\n return available[0] // doesn't matter we pick the first element, as they are all random anyway\n }\n return -1\n }\n\n /**\n * Gets the length of the status list\n * @param args - Optional correlation ID parameter\n * @returns Promise resolving to status list length\n */\n async getStatusListLength(args?: IGetStatusListLengthArgs): Promise<number> {\n if (!this._statusListLength) {\n this._statusListLength = await this.getStatusList(args).then((details) => details.length)\n }\n return this._statusListLength!\n }\n\n /**\n * Retrieves the status list details\n * @param args - Optional correlation ID parameter\n * @returns Promise resolving to StatusListResult\n */\n async getStatusList(args?: IGetStatusListArgs): Promise<StatusListResult> {\n const id = this.options.id\n const correlationId = args?.correlationId ?? this.options.correlationId\n\n const statusListEntity = await this.statusListStore.getStatusList({ id, correlationId })\n\n // Convert entity to result using CREATE/READ context\n return await toStatusListDetails({\n statusListCredential: statusListEntity.statusListCredential!,\n statusListType: statusListEntity.type,\n bitsPerStatus: statusListEntity.bitsPerStatus,\n correlationId: statusListEntity.correlationId,\n driverType: statusListEntity.driverType,\n })\n }\n\n /**\n * Retrieves all status lists\n * @returns Promise resolving to array of StatusListResult\n */\n async getStatusLists(): Promise<Array<StatusListResult>> {\n const statusLists = await this.statusListStore.getStatusLists({})\n return Promise.all(\n statusLists.map(async (statusListEntity) => {\n return toStatusListDetails({\n statusListCredential: statusListEntity.statusListCredential!,\n statusListType: statusListEntity.type,\n bitsPerStatus: statusListEntity.bitsPerStatus,\n correlationId: statusListEntity.correlationId,\n driverType: statusListEntity.driverType,\n })\n }),\n )\n }\n\n /**\n * Checks if a status list index is currently in use\n * @returns Promise resolving to boolean indicating usage status\n */\n isStatusListIndexInUse(): Promise<boolean> {\n return Promise.resolve(false)\n }\n}\n","import { StatusListType } from '@sphereon/ssi-types'\nimport { BitstringStatusListEntity, OAuthStatusListEntity, StatusList2021Entity } from '@sphereon/ssi-sdk.data-store'\nimport { StatusListResult } from '@sphereon/ssi-sdk.vc-status-list'\n\nexport function statusListResultToEntity(result: StatusListResult): StatusList2021Entity | OAuthStatusListEntity | BitstringStatusListEntity {\n const baseFields = {\n id: result.id,\n correlationId: result.correlationId,\n driverType: result.driverType,\n credentialIdMode: result.credentialIdMode,\n length: result.length,\n issuer: result.issuer,\n type: result.type,\n proofFormat: result.proofFormat,\n statusListCredential: result.statusListCredential,\n }\n\n if (result.type === StatusListType.StatusList2021) {\n if (!result.statusList2021) {\n throw new Error('Missing statusList2021 details')\n }\n return Object.assign(new StatusList2021Entity(), {\n ...baseFields,\n indexingDirection: result.statusList2021.indexingDirection,\n statusPurpose: result.statusList2021.statusPurpose,\n })\n } else if (result.type === StatusListType.OAuthStatusList) {\n if (!result.oauthStatusList) {\n throw new Error('Missing oauthStatusList details')\n }\n return Object.assign(new OAuthStatusListEntity(), {\n ...baseFields,\n bitsPerStatus: result.oauthStatusList.bitsPerStatus,\n expiresAt: result.oauthStatusList.expiresAt,\n })\n } else if (result.type === StatusListType.BitstringStatusList) {\n if (!result.bitstringStatusList) {\n throw new Error('Missing bitstringStatusList details')\n }\n return Object.assign(new BitstringStatusListEntity(), {\n ...baseFields,\n statusPurpose: result.bitstringStatusList.statusPurpose,\n ttl: result.bitstringStatusList.ttl,\n bitsPerStatus: result.bitstringStatusList.bitsPerStatus,\n validFrom: result.bitstringStatusList.validFrom,\n validUntil: result.bitstringStatusList.validUntil,\n })\n }\n throw new Error(`Unsupported status list type: ${result.type}`)\n}\n"],"mappings":";;;;AAmBA,SAASA,mBAAmB;AAC5B,SASEC,uBACK;AACP,SACEC,sCACAC,0BAIAC,2BACK;AACP,SAASC,4BAA4BC,4BAA4B;;;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AAO,MAAM+B,oBAAoB;MAC/BC,sBAAsBY,iBAAiBZ;MACvCC,gBAAgBW,iBAAiB4B;MACjCtC,eAAeU,iBAAiBV;MAChClC,eAAe4C,iBAAiB5C;MAChCC,YAAY2C,iBAAiB3C;IAC/B,CAAA;EACF;;;;;EAMA,MAAMwE,iBAAmD;AACvD,UAAMC,cAAc,MAAM,KAAKrD,gBAAgBoD,eAAe,CAAC,CAAA;AAC/D,WAAOnD,QAAQqD,IACbD,YAAYE,IAAI,OAAOhC,qBAAAA;AACrB,aAAOb,oBAAoB;QACzBC,sBAAsBY,iBAAiBZ;QACvCC,gBAAgBW,iBAAiB4B;QACjCtC,eAAeU,iBAAiBV;QAChClC,eAAe4C,iBAAiB5C;QAChCC,YAAY2C,iBAAiB3C;MAC/B,CAAA;IACF,CAAA,CAAA;EAEJ;;;;;EAMA4E,yBAA2C;AACzC,WAAOvD,QAAQ0B,QAAQ,KAAA;EACzB;AACF;","names":["DataSources","StatusListStore","createCredentialStatusFromStatusList","extractCredentialDetails","toStatusListDetails","StatusListCredentialIdMode","StatusListDriverType","StatusListType","BitstringStatusListEntity","OAuthStatusListEntity","StatusList2021Entity","statusListResultToEntity","result","baseFields","id","correlationId","driverType","credentialIdMode","length","issuer","type","proofFormat","statusListCredential","StatusListType","StatusList2021","statusList2021","Error","Object","assign","StatusList2021Entity","indexingDirection","statusPurpose","OAuthStatusList","oauthStatusList","OAuthStatusListEntity","bitsPerStatus","expiresAt","BitstringStatusList","bitstringStatusList","BitstringStatusListEntity","ttl","validFrom","validUntil","getOptions","args","id","correlationId","driverType","StatusListDriverType","AGENT_TYPEORM","driverOptions","dbName","getDriver","dataSource","name","Error","dataSources","DataSources","singleInstance","AgentDataSourceStatusListDriver","init","getDbConnection","_statusListLength","_dataSource","_statusListStore","options","dbArgs","statusListStore","Promise","reject","StatusListStore","getType","createStatusList","credentialIdMode","StatusListCredentialIdMode","ISSUANCE","implementationResult","toStatusListDetails","statusListCredential","statusListType","bitsPerStatus","statusListArgs","addStatusList","length","updateStatusList","extractedDetails","extractCredentialDetails","entity","getStatusList","details","statusListEntity","updateArgs","deleteStatusList","removeStatusList","resolve","updateStatusListEntry","statusListResultToEntity","statusListEntry","statusListId","credentialStatus","createCredentialStatusFromStatusList","statusList","statusListIndex","getStatusListEntryByCredentialId","getStatusListEntryByIndex","getRandomNewStatusListIndex","result","tries","getRandomNewStatusListIndexImpl","getStatusListLength","Array","from","Math","floor","random","available","availableStatusListEntries","then","type","getStatusLists","statusLists","all","map","isStatusListIndexInUse"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.vc-status-list-issuer-drivers",
|
|
3
3
|
"description": "Sphereon SSI-SDK plugin for Status List management, like StatusList2021. Issuer drivers module",
|
|
4
|
-
"version": "0.34.1-
|
|
4
|
+
"version": "0.34.1-next.29+2593a430",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
@@ -22,14 +22,15 @@
|
|
|
22
22
|
"build": "tsup --config ../../tsup.config.ts --tsconfig ../../tsconfig.tsup.json"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@sphereon/ssi-express-support": "0.34.1-
|
|
26
|
-
"@sphereon/ssi-sdk-ext.did-utils": "0.29.
|
|
27
|
-
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.29.
|
|
28
|
-
"@sphereon/ssi-sdk.agent-config": "0.34.1-
|
|
29
|
-
"@sphereon/ssi-sdk.core": "0.34.1-
|
|
30
|
-
"@sphereon/ssi-sdk.
|
|
31
|
-
"@sphereon/ssi-sdk.
|
|
32
|
-
"@sphereon/ssi-
|
|
25
|
+
"@sphereon/ssi-express-support": "0.34.1-next.29+2593a430",
|
|
26
|
+
"@sphereon/ssi-sdk-ext.did-utils": "0.29.1-next.3",
|
|
27
|
+
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.29.1-next.3",
|
|
28
|
+
"@sphereon/ssi-sdk.agent-config": "0.34.1-next.29+2593a430",
|
|
29
|
+
"@sphereon/ssi-sdk.core": "0.34.1-next.29+2593a430",
|
|
30
|
+
"@sphereon/ssi-sdk.credential-vcdm": "0.34.1-next.29+2593a430",
|
|
31
|
+
"@sphereon/ssi-sdk.data-store": "0.34.1-next.29+2593a430",
|
|
32
|
+
"@sphereon/ssi-sdk.vc-status-list": "0.34.1-next.29+2593a430",
|
|
33
|
+
"@sphereon/ssi-types": "0.34.1-next.29+2593a430",
|
|
33
34
|
"@sphereon/vc-status-list": "7.0.0-next.0",
|
|
34
35
|
"@veramo/core": "4.2.0",
|
|
35
36
|
"debug": "^4.3.5",
|
|
@@ -60,5 +61,5 @@
|
|
|
60
61
|
"SSI",
|
|
61
62
|
"StatusList2021"
|
|
62
63
|
],
|
|
63
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "2593a430ac4faca47b620a3e12b297899518f2af"
|
|
64
65
|
}
|