@sphereon/ssi-sdk.vc-status-list-issuer-drivers 0.34.1-feature.SSISDK.17.bitstring.sl.2 → 0.34.1-next.5

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 CHANGED
@@ -28,15 +28,14 @@ __export(index_exports, {
28
28
  module.exports = __toCommonJS(index_exports);
29
29
 
30
30
  // src/drivers.ts
31
- var import_ssi_sdk3 = require("@sphereon/ssi-sdk.agent-config");
32
- var import_ssi_sdk4 = require("@sphereon/ssi-sdk.data-store");
33
- var import_ssi_sdk5 = require("@sphereon/ssi-sdk.vc-status-list");
31
+ var import_ssi_sdk2 = require("@sphereon/ssi-sdk.agent-config");
32
+ var import_ssi_sdk3 = require("@sphereon/ssi-sdk.data-store");
33
+ var import_ssi_sdk4 = require("@sphereon/ssi-sdk.vc-status-list");
34
34
  var import_ssi_types2 = require("@sphereon/ssi-types");
35
35
 
36
36
  // src/status-list-adapters.ts
37
37
  var import_ssi_types = require("@sphereon/ssi-types");
38
38
  var import_ssi_sdk = require("@sphereon/ssi-sdk.data-store");
39
- var import_ssi_sdk2 = require("@sphereon/ssi-sdk.data-store");
40
39
  function statusListResultToEntity(result) {
41
40
  const baseFields = {
42
41
  id: result.id,
@@ -67,24 +66,13 @@ function statusListResultToEntity(result) {
67
66
  bitsPerStatus: result.oauthStatusList.bitsPerStatus,
68
67
  expiresAt: result.oauthStatusList.expiresAt
69
68
  });
70
- } else if (result.type === import_ssi_types.StatusListType.BitstringStatusList) {
71
- if (!result.bitstringStatusList) {
72
- throw new Error("Missing bitstringStatusList details");
73
- }
74
- return Object.assign(new import_ssi_sdk2.BitstringStatusListEntity(), {
75
- ...baseFields,
76
- statusPurpose: result.bitstringStatusList.statusPurpose,
77
- ttl: result.bitstringStatusList.ttl,
78
- validFrom: result.bitstringStatusList.validFrom,
79
- validUntil: result.bitstringStatusList.validUntil
80
- });
81
69
  }
82
70
  throw new Error(`Unsupported status list type: ${result.type}`);
83
71
  }
84
72
  __name(statusListResultToEntity, "statusListResultToEntity");
85
73
 
86
74
  // src/drivers.ts
87
- var import_ssi_sdk6 = require("@sphereon/ssi-sdk.data-store");
75
+ var import_ssi_sdk5 = require("@sphereon/ssi-sdk.data-store");
88
76
  function getOptions(args) {
89
77
  return {
90
78
  id: args.id,
@@ -101,7 +89,7 @@ async function getDriver(args) {
101
89
  if (!dbName) {
102
90
  throw Error(`Please provide either a DB name or data source`);
103
91
  }
104
- const dataSources = args.dataSources ?? import_ssi_sdk3.DataSources.singleInstance();
92
+ const dataSources = args.dataSources ?? import_ssi_sdk2.DataSources.singleInstance();
105
93
  return await AgentDataSourceStatusListDriver.init(getOptions({
106
94
  ...args,
107
95
  dbName
@@ -138,12 +126,12 @@ var AgentDataSourceStatusListDriver = class _AgentDataSourceStatusListDriver {
138
126
  if (dbArgs?.dataSources) {
139
127
  dataSource = await dbArgs.dataSources.getDbConnection(options.driverOptions.dbName);
140
128
  } else {
141
- dataSource = await import_ssi_sdk3.DataSources.singleInstance().getDbConnection(options.driverOptions.dbName);
129
+ dataSource = await import_ssi_sdk2.DataSources.singleInstance().getDbConnection(options.driverOptions.dbName);
142
130
  }
143
131
  } else {
144
132
  return Promise.reject(Error(`Either a datasource or dbName needs to be provided`));
145
133
  }
146
- statusListStore = new import_ssi_sdk4.StatusListStore(dataSource);
134
+ statusListStore = new import_ssi_sdk3.StatusListStore(dataSource);
147
135
  return new _AgentDataSourceStatusListDriver(dataSource, statusListStore, options);
148
136
  }
149
137
  get dataSource() {
@@ -154,7 +142,7 @@ var AgentDataSourceStatusListDriver = class _AgentDataSourceStatusListDriver {
154
142
  }
155
143
  get statusListStore() {
156
144
  if (!this._statusListStore) {
157
- this._statusListStore = new import_ssi_sdk4.StatusListStore(this.dataSource);
145
+ this._statusListStore = new import_ssi_sdk3.StatusListStore(this.dataSource);
158
146
  }
159
147
  return this._statusListStore;
160
148
  }
@@ -170,7 +158,7 @@ var AgentDataSourceStatusListDriver = class _AgentDataSourceStatusListDriver {
170
158
  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");
171
159
  }
172
160
  const credentialIdMode = args.credentialIdMode ?? import_ssi_types2.StatusListCredentialIdMode.ISSUANCE;
173
- const details = await (0, import_ssi_sdk5.statusListCredentialToDetails)({
161
+ const details = await (0, import_ssi_sdk4.statusListCredentialToDetails)({
174
162
  ...args,
175
163
  correlationId,
176
164
  driverType: this.getType()
@@ -186,7 +174,7 @@ var AgentDataSourceStatusListDriver = class _AgentDataSourceStatusListDriver {
186
174
  }
187
175
  async updateStatusList(args) {
188
176
  const correlationId = args.correlationId ?? this.options.correlationId;
189
- const details = await (0, import_ssi_sdk5.statusListCredentialToDetails)({
177
+ const details = await (0, import_ssi_sdk4.statusListCredentialToDetails)({
190
178
  ...args,
191
179
  correlationId,
192
180
  driverType: this.getType()
@@ -224,13 +212,10 @@ var AgentDataSourceStatusListDriver = class _AgentDataSourceStatusListDriver {
224
212
  return Promise.resolve(true);
225
213
  }
226
214
  isStatusList2021Entity(statusList) {
227
- return statusList instanceof import_ssi_sdk6.StatusList2021Entity;
215
+ return statusList instanceof import_ssi_sdk5.StatusList2021Entity;
228
216
  }
229
217
  isOAuthStatusListEntity(statusList) {
230
- return statusList instanceof import_ssi_sdk6.OAuthStatusListEntity;
231
- }
232
- isBitstringStatusListEntity(statusList) {
233
- return statusList instanceof import_ssi_sdk4.BitstringStatusListEntity;
218
+ return statusList instanceof import_ssi_sdk5.OAuthStatusListEntity;
234
219
  }
235
220
  async updateStatusListEntry(args) {
236
221
  const statusList = args.statusList ? args.statusList : statusListResultToEntity(await this.getStatusList());
@@ -261,17 +246,6 @@ var AgentDataSourceStatusListDriver = class _AgentDataSourceStatusListDriver {
261
246
  },
262
247
  statusListEntry
263
248
  };
264
- } else if (this.isBitstringStatusListEntity(statusList)) {
265
- return {
266
- credentialStatus: {
267
- id: `${statusList.id}#${statusListEntry.statusListIndex}`,
268
- type: "BitstringStatusListEntry",
269
- statusPurpose: statusList.statusPurpose,
270
- statusListIndex: "" + statusListEntry.statusListIndex,
271
- statusListCredential: statusList.id
272
- },
273
- statusListEntry
274
- };
275
249
  }
276
250
  throw new Error(`Unsupported status list type: ${typeof statusList}`);
277
251
  }
@@ -323,14 +297,14 @@ var AgentDataSourceStatusListDriver = class _AgentDataSourceStatusListDriver {
323
297
  return await this.statusListStore.getStatusList({
324
298
  id,
325
299
  correlationId
326
- }).then((statusListEntity) => (0, import_ssi_sdk5.statusListCredentialToDetails)({
300
+ }).then((statusListEntity) => (0, import_ssi_sdk4.statusListCredentialToDetails)({
327
301
  statusListCredential: statusListEntity.statusListCredential
328
302
  }));
329
303
  }
330
304
  async getStatusLists() {
331
305
  const statusLists = await this.statusListStore.getStatusLists({});
332
306
  return Promise.all(statusLists.map(async (statusListEntity) => {
333
- return (0, import_ssi_sdk5.statusListCredentialToDetails)({
307
+ return (0, import_ssi_sdk4.statusListCredentialToDetails)({
334
308
  statusListCredential: statusListEntity.statusListCredential
335
309
  });
336
310
  }));
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/drivers.ts","../src/status-list-adapters.ts"],"sourcesContent":["/**\n * @public\n */\nexport * from './types'\nexport * from './drivers'\n","import { DataSources } from '@sphereon/ssi-sdk.agent-config'\nimport {\n BitstringStatusListEntity,\n IAddStatusListEntryArgs,\n IGetStatusListEntryByCredentialIdArgs,\n IGetStatusListEntryByIndexArgs,\n IStatusListEntity,\n IStatusListEntryEntity,\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 { StatusListCredentialIdMode, StatusListDriverType, StatusListType, StatusListCredential } from '@sphereon/ssi-types'\nimport { DataSource } from 'typeorm'\nimport { IStatusListDriver } from './types'\nimport { statusListResultToEntity } from './status-list-adapters'\nimport { OAuthStatusListEntity, StatusList2021Entity } from '@sphereon/ssi-sdk.data-store'\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 }): 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() })\n\n // (StatusListStore does the duplicate entity check)\n await this.statusListStore.addStatusList({\n ...details,\n credentialIdMode,\n correlationId,\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\n .getStatusList({ id, correlationId })\n .then((statusListEntity: IStatusListEntity) => statusListCredentialToDetails({ statusListCredential: statusListEntity.statusListCredential! }))\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 { OAuthStatusListEntity, StatusList2021Entity } from '@sphereon/ssi-sdk.data-store'\nimport { StatusListResult } from '@sphereon/ssi-sdk.vc-status-list'\n\nimport { BitstringStatusListEntity } from '@sphereon/ssi-sdk.data-store'\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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k","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","import_ssi_sdk","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","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","bitsPerStatus","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/index.ts","../src/drivers.ts","../src/status-list-adapters.ts"],"sourcesContent":["/**\n * @public\n */\nexport * from './types'\nexport * from './drivers'\n","import { DataSources } from '@sphereon/ssi-sdk.agent-config'\nimport {\n IAddStatusListEntryArgs,\n IGetStatusListEntryByCredentialIdArgs,\n IGetStatusListEntryByIndexArgs,\n IStatusListEntity,\n IStatusListEntryEntity,\n StatusListEntity,\n StatusListStore,\n} from '@sphereon/ssi-sdk.data-store'\nimport {\n StatusList2021EntryCredentialStatus,\n statusListCredentialToDetails,\n StatusListOAuthEntryCredentialStatus,\n StatusListResult,\n} from '@sphereon/ssi-sdk.vc-status-list'\nimport { StatusListCredentialIdMode, StatusListDriverType, StatusListType, StatusListCredential } from '@sphereon/ssi-types'\nimport { DataSource } from 'typeorm'\nimport { IStatusListDriver } from './types'\nimport { statusListResultToEntity } from './status-list-adapters'\nimport { OAuthStatusListEntity, StatusList2021Entity } from '@sphereon/ssi-sdk.data-store'\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 }): 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() })\n\n // (StatusListStore does the duplicate entity check)\n await this.statusListStore.addStatusList({\n ...details,\n credentialIdMode,\n correlationId,\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 async updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<{\n credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus\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 }\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\n .getStatusList({ id, correlationId })\n .then((statusListEntity: IStatusListEntity) => statusListCredentialToDetails({ statusListCredential: statusListEntity.statusListCredential! }))\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 { 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 {\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 }\n throw new Error(`Unsupported status list type: ${result.type}`)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;ACAA,IAAAA,kBAA4B;AAC5B,IAAAA,kBAQO;AACP,IAAAA,kBAKO;AACP,IAAAC,oBAAuG;;;AChBvG,uBAA+B;AAC/B,qBAA4D;AAGrD,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,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nCyB,sBAAsBkB,iBAAiBlB;MACzC,CAAA;IACF,CAAA,CAAA;EAEJ;EAEAuB,yBAA2C;AACzC,WAAOzD,QAAQoB,QAAQ,KAAA;EACzB;AACF;","names":["import_ssi_sdk","import_ssi_types","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","import_ssi_sdk","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","details","statusListCredentialToDetails","addStatusList","length","updateStatusList","entity","getStatusListRepo","type","findOne","where","deleteStatusList","removeStatusList","resolve","isStatusList2021Entity","statusList","StatusList2021Entity","isOAuthStatusListEntity","OAuthStatusListEntity","updateStatusListEntry","statusListResultToEntity","getStatusList","statusListEntry","statusListId","credentialStatus","statusListIndex","statusPurpose","statusListCredential","bitsPerStatus","expiresAt","getStatusListEntryByCredentialId","getStatusListEntryByIndex","getRandomNewStatusListIndex","result","tries","getRandomNewStatusListIndexImpl","getStatusListLength","Array","from","Math","floor","random","available","availableStatusListEntries","then","statusListEntity","getStatusLists","statusLists","all","map","isStatusListIndexInUse"]}
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution';
2
2
  import { StatusListStore, IAddStatusListEntryArgs, IStatusListEntryEntity, IGetStatusListEntryByCredentialIdArgs, IGetStatusListEntryByIndexArgs } from '@sphereon/ssi-sdk.data-store';
3
- import { StatusListResult, StatusList2021EntryCredentialStatus, StatusListOAuthEntryCredentialStatus, BitstringStatusListEntryCredentialStatus, IStatusListPlugin } from '@sphereon/ssi-sdk.vc-status-list';
3
+ import { StatusListResult, StatusList2021EntryCredentialStatus, StatusListOAuthEntryCredentialStatus, IStatusListPlugin } from '@sphereon/ssi-sdk.vc-status-list';
4
4
  import { StatusListDriverType, StatusListCredential, StatusListCredentialIdMode, StatusListType } from '@sphereon/ssi-types';
5
5
  import { IDataStoreORM, IDIDManager, IKeyManager, ICredentialIssuer, ICredentialVerifier, ICredentialPlugin, IResolver, IAgentContext } from '@veramo/core';
6
6
  import { DataSources } from '@sphereon/ssi-sdk.agent-config';
@@ -58,9 +58,8 @@ declare class AgentDataSourceStatusListDriver implements IStatusListDriver {
58
58
  deleteStatusList(): Promise<boolean>;
59
59
  private isStatusList2021Entity;
60
60
  private isOAuthStatusListEntity;
61
- private isBitstringStatusListEntity;
62
61
  updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<{
63
- credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus | BitstringStatusListEntryCredentialStatus;
62
+ credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus;
64
63
  statusListEntry: IStatusListEntryEntity;
65
64
  }>;
66
65
  getStatusListEntryByCredentialId(args: IGetStatusListEntryByCredentialIdArgs): Promise<IStatusListEntryEntity | undefined>;
@@ -97,7 +96,7 @@ interface IStatusListDriver {
97
96
  }): Promise<StatusListResult>;
98
97
  getStatusLists(): Promise<Array<StatusListResult>>;
99
98
  updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<{
100
- credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus | BitstringStatusListEntryCredentialStatus;
99
+ credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus;
101
100
  statusListEntry: IStatusListEntryEntity;
102
101
  }>;
103
102
  getStatusListEntryByCredentialId(args: IGetStatusListEntryByCredentialIdArgs): Promise<IStatusListEntryEntity | undefined>;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution';
2
2
  import { StatusListStore, IAddStatusListEntryArgs, IStatusListEntryEntity, IGetStatusListEntryByCredentialIdArgs, IGetStatusListEntryByIndexArgs } from '@sphereon/ssi-sdk.data-store';
3
- import { StatusListResult, StatusList2021EntryCredentialStatus, StatusListOAuthEntryCredentialStatus, BitstringStatusListEntryCredentialStatus, IStatusListPlugin } from '@sphereon/ssi-sdk.vc-status-list';
3
+ import { StatusListResult, StatusList2021EntryCredentialStatus, StatusListOAuthEntryCredentialStatus, IStatusListPlugin } from '@sphereon/ssi-sdk.vc-status-list';
4
4
  import { StatusListDriverType, StatusListCredential, StatusListCredentialIdMode, StatusListType } from '@sphereon/ssi-types';
5
5
  import { IDataStoreORM, IDIDManager, IKeyManager, ICredentialIssuer, ICredentialVerifier, ICredentialPlugin, IResolver, IAgentContext } from '@veramo/core';
6
6
  import { DataSources } from '@sphereon/ssi-sdk.agent-config';
@@ -58,9 +58,8 @@ declare class AgentDataSourceStatusListDriver implements IStatusListDriver {
58
58
  deleteStatusList(): Promise<boolean>;
59
59
  private isStatusList2021Entity;
60
60
  private isOAuthStatusListEntity;
61
- private isBitstringStatusListEntity;
62
61
  updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<{
63
- credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus | BitstringStatusListEntryCredentialStatus;
62
+ credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus;
64
63
  statusListEntry: IStatusListEntryEntity;
65
64
  }>;
66
65
  getStatusListEntryByCredentialId(args: IGetStatusListEntryByCredentialIdArgs): Promise<IStatusListEntryEntity | undefined>;
@@ -97,7 +96,7 @@ interface IStatusListDriver {
97
96
  }): Promise<StatusListResult>;
98
97
  getStatusLists(): Promise<Array<StatusListResult>>;
99
98
  updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<{
100
- credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus | BitstringStatusListEntryCredentialStatus;
99
+ credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus;
101
100
  statusListEntry: IStatusListEntryEntity;
102
101
  }>;
103
102
  getStatusListEntryByCredentialId(args: IGetStatusListEntryByCredentialIdArgs): Promise<IStatusListEntryEntity | undefined>;
package/dist/index.js CHANGED
@@ -3,14 +3,13 @@ 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 { BitstringStatusListEntity as BitstringStatusListEntity2, StatusListStore } from "@sphereon/ssi-sdk.data-store";
6
+ import { StatusListStore } from "@sphereon/ssi-sdk.data-store";
7
7
  import { statusListCredentialToDetails } 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
11
11
  import { StatusListType } from "@sphereon/ssi-types";
12
12
  import { OAuthStatusListEntity, StatusList2021Entity } from "@sphereon/ssi-sdk.data-store";
13
- import { BitstringStatusListEntity } from "@sphereon/ssi-sdk.data-store";
14
13
  function statusListResultToEntity(result) {
15
14
  const baseFields = {
16
15
  id: result.id,
@@ -41,17 +40,6 @@ function statusListResultToEntity(result) {
41
40
  bitsPerStatus: result.oauthStatusList.bitsPerStatus,
42
41
  expiresAt: result.oauthStatusList.expiresAt
43
42
  });
44
- } else if (result.type === StatusListType.BitstringStatusList) {
45
- if (!result.bitstringStatusList) {
46
- throw new Error("Missing bitstringStatusList details");
47
- }
48
- return Object.assign(new BitstringStatusListEntity(), {
49
- ...baseFields,
50
- statusPurpose: result.bitstringStatusList.statusPurpose,
51
- ttl: result.bitstringStatusList.ttl,
52
- validFrom: result.bitstringStatusList.validFrom,
53
- validUntil: result.bitstringStatusList.validUntil
54
- });
55
43
  }
56
44
  throw new Error(`Unsupported status list type: ${result.type}`);
57
45
  }
@@ -203,9 +191,6 @@ var AgentDataSourceStatusListDriver = class _AgentDataSourceStatusListDriver {
203
191
  isOAuthStatusListEntity(statusList) {
204
192
  return statusList instanceof OAuthStatusListEntity2;
205
193
  }
206
- isBitstringStatusListEntity(statusList) {
207
- return statusList instanceof BitstringStatusListEntity2;
208
- }
209
194
  async updateStatusListEntry(args) {
210
195
  const statusList = args.statusList ? args.statusList : statusListResultToEntity(await this.getStatusList());
211
196
  const statusListEntry = await this.statusListStore.updateStatusListEntry({
@@ -235,17 +220,6 @@ var AgentDataSourceStatusListDriver = class _AgentDataSourceStatusListDriver {
235
220
  },
236
221
  statusListEntry
237
222
  };
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
- },
247
- statusListEntry
248
- };
249
223
  }
250
224
  throw new Error(`Unsupported status list type: ${typeof statusList}`);
251
225
  }
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 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 { StatusListCredentialIdMode, StatusListDriverType, StatusListType, StatusListCredential } from '@sphereon/ssi-types'\nimport { DataSource } from 'typeorm'\nimport { IStatusListDriver } from './types'\nimport { statusListResultToEntity } from './status-list-adapters'\nimport { OAuthStatusListEntity, StatusList2021Entity } from '@sphereon/ssi-sdk.data-store'\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 }): 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() })\n\n // (StatusListStore does the duplicate entity check)\n await this.statusListStore.addStatusList({\n ...details,\n credentialIdMode,\n correlationId,\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\n .getStatusList({ id, correlationId })\n .then((statusListEntity: IStatusListEntity) => statusListCredentialToDetails({ statusListCredential: statusListEntity.statusListCredential! }))\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 { OAuthStatusListEntity, StatusList2021Entity } from '@sphereon/ssi-sdk.data-store'\nimport { StatusListResult } from '@sphereon/ssi-sdk.vc-status-list'\n\nimport { BitstringStatusListEntity } from '@sphereon/ssi-sdk.data-store'\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,4BAOAC,uBACK;AACP,SAGEC,qCAGK;AACP,SAASC,4BAA4BC,4BAAkE;;;AClBvG,SAASC,sBAAsB;AAC/B,SAASC,uBAAuBC,4BAA4B;AAG5D,SAASC,iCAAiC;AAEnC,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,eAAevB,OAAOqB,gBAAgBE;MACtCC,WAAWxB,OAAOqB,gBAAgBG;IACpC,CAAA;EACF,WAAWxB,OAAOQ,SAASG,eAAec,qBAAqB;AAC7D,QAAI,CAACzB,OAAO0B,qBAAqB;AAC/B,YAAM,IAAIZ,MAAM,qCAAA;IAClB;AACA,WAAOC,OAAOC,OAAO,IAAIW,0BAAAA,GAA6B;MACpD,GAAG1B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zC,WAAO3D,QAAQoB,QAAQ,KAAA;EACzB;AACF;","names":["DataSources","BitstringStatusListEntity","StatusListStore","statusListCredentialToDetails","StatusListCredentialIdMode","StatusListDriverType","StatusListType","OAuthStatusListEntity","StatusList2021Entity","BitstringStatusListEntity","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","OAuthStatusListEntity","StatusList2021Entity","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","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","bitsPerStatus","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":["import { DataSources } from '@sphereon/ssi-sdk.agent-config'\nimport {\n IAddStatusListEntryArgs,\n IGetStatusListEntryByCredentialIdArgs,\n IGetStatusListEntryByIndexArgs,\n IStatusListEntity,\n IStatusListEntryEntity,\n StatusListEntity,\n StatusListStore,\n} from '@sphereon/ssi-sdk.data-store'\nimport {\n StatusList2021EntryCredentialStatus,\n statusListCredentialToDetails,\n StatusListOAuthEntryCredentialStatus,\n StatusListResult,\n} from '@sphereon/ssi-sdk.vc-status-list'\nimport { StatusListCredentialIdMode, StatusListDriverType, StatusListType, StatusListCredential } from '@sphereon/ssi-types'\nimport { DataSource } from 'typeorm'\nimport { IStatusListDriver } from './types'\nimport { statusListResultToEntity } from './status-list-adapters'\nimport { OAuthStatusListEntity, StatusList2021Entity } from '@sphereon/ssi-sdk.data-store'\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 }): 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() })\n\n // (StatusListStore does the duplicate entity check)\n await this.statusListStore.addStatusList({\n ...details,\n credentialIdMode,\n correlationId,\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 async updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<{\n credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus\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 }\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\n .getStatusList({ id, correlationId })\n .then((statusListEntity: IStatusListEntity) => statusListCredentialToDetails({ statusListCredential: statusListEntity.statusListCredential! }))\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 { 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 {\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 }\n throw new Error(`Unsupported status list type: ${result.type}`)\n}\n"],"mappings":";;;;AAAA,SAASA,mBAAmB;AAC5B,SAOEC,uBACK;AACP,SAEEC,qCAGK;AACP,SAASC,4BAA4BC,4BAAkE;;;AChBvG,SAASC,sBAAsB;AAC/B,SAASC,uBAAuBC,4BAA4B;AAGrD,SAASC,yBAAyBC,QAAwB;AAC/D,QAAMC,aAAa;IACjBC,IAAIF,OAAOE;IACXC,eAAeH,OAAOG;IAC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UAAMC,cAAc,MAAM,KAAKvD,gBAAgBsD,eAAe,CAAC,CAAA;AAC/D,WAAOrD,QAAQuD,IACbD,YAAYE,IAAI,OAAOJ,qBAAAA;AACrB,aAAO3C,8BAA8B;QACnCyB,sBAAsBkB,iBAAiBlB;MACzC,CAAA;IACF,CAAA,CAAA;EAEJ;EAEAuB,yBAA2C;AACzC,WAAOzD,QAAQoB,QAAQ,KAAA;EACzB;AACF;","names":["DataSources","StatusListStore","statusListCredentialToDetails","StatusListCredentialIdMode","StatusListDriverType","StatusListType","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","OAuthStatusListEntity","StatusList2021Entity","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","details","statusListCredentialToDetails","addStatusList","length","updateStatusList","entity","getStatusListRepo","type","findOne","where","deleteStatusList","removeStatusList","resolve","isStatusList2021Entity","statusList","StatusList2021Entity","isOAuthStatusListEntity","OAuthStatusListEntity","updateStatusListEntry","statusListResultToEntity","getStatusList","statusListEntry","statusListId","credentialStatus","statusListIndex","statusPurpose","statusListCredential","bitsPerStatus","expiresAt","getStatusListEntryByCredentialId","getStatusListEntryByIndex","getRandomNewStatusListIndex","result","tries","getRandomNewStatusListIndexImpl","getStatusListLength","Array","from","Math","floor","random","available","availableStatusListEntries","then","statusListEntity","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-feature.SSISDK.17.bitstring.sl.2+0a0992f6",
4
+ "version": "0.34.1-next.5+34a84d73",
5
5
  "source": "src/index.ts",
6
6
  "type": "module",
7
7
  "main": "./dist/index.cjs",
@@ -22,14 +22,14 @@
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-feature.SSISDK.17.bitstring.sl.2+0a0992f6",
26
- "@sphereon/ssi-sdk-ext.did-utils": "0.29.0",
27
- "@sphereon/ssi-sdk-ext.identifier-resolution": "0.29.0",
28
- "@sphereon/ssi-sdk.agent-config": "0.34.1-feature.SSISDK.17.bitstring.sl.2+0a0992f6",
29
- "@sphereon/ssi-sdk.core": "0.34.1-feature.SSISDK.17.bitstring.sl.2+0a0992f6",
30
- "@sphereon/ssi-sdk.data-store": "0.34.1-feature.SSISDK.17.bitstring.sl.2+0a0992f6",
31
- "@sphereon/ssi-sdk.vc-status-list": "0.34.1-feature.SSISDK.17.bitstring.sl.2+0a0992f6",
32
- "@sphereon/ssi-types": "0.34.1-feature.SSISDK.17.bitstring.sl.2+0a0992f6",
25
+ "@sphereon/ssi-express-support": "0.34.1-next.5+34a84d73",
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.5+34a84d73",
29
+ "@sphereon/ssi-sdk.core": "0.34.1-next.5+34a84d73",
30
+ "@sphereon/ssi-sdk.data-store": "0.34.1-next.5+34a84d73",
31
+ "@sphereon/ssi-sdk.vc-status-list": "0.34.1-next.5+34a84d73",
32
+ "@sphereon/ssi-types": "0.34.1-next.5+34a84d73",
33
33
  "@sphereon/vc-status-list": "7.0.0-next.0",
34
34
  "@veramo/core": "4.2.0",
35
35
  "debug": "^4.3.5",
@@ -60,5 +60,5 @@
60
60
  "SSI",
61
61
  "StatusList2021"
62
62
  ],
63
- "gitHead": "0a0992f6323610a12e82716b1d80a2eedf4b4669"
63
+ "gitHead": "34a84d731d3c2185e5b392d48dea9574d2674781"
64
64
  }
package/src/drivers.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { DataSources } from '@sphereon/ssi-sdk.agent-config'
2
2
  import {
3
- BitstringStatusListEntity,
4
3
  IAddStatusListEntryArgs,
5
4
  IGetStatusListEntryByCredentialIdArgs,
6
5
  IGetStatusListEntryByIndexArgs,
@@ -10,7 +9,6 @@ import {
10
9
  StatusListStore,
11
10
  } from '@sphereon/ssi-sdk.data-store'
12
11
  import {
13
- BitstringStatusListEntryCredentialStatus,
14
12
  StatusList2021EntryCredentialStatus,
15
13
  statusListCredentialToDetails,
16
14
  StatusListOAuthEntryCredentialStatus,
@@ -198,12 +196,8 @@ export class AgentDataSourceStatusListDriver implements IStatusListDriver {
198
196
  return statusList instanceof OAuthStatusListEntity
199
197
  }
200
198
 
201
- private isBitstringStatusListEntity(statusList: StatusListEntity): statusList is BitstringStatusListEntity {
202
- return statusList instanceof BitstringStatusListEntity
203
- }
204
-
205
199
  async updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<{
206
- credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus | BitstringStatusListEntryCredentialStatus
200
+ credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus
207
201
  statusListEntry: IStatusListEntryEntity
208
202
  }> {
209
203
  const statusList: StatusListEntity = args.statusList ? args.statusList : statusListResultToEntity(await this.getStatusList())
@@ -232,17 +226,6 @@ export class AgentDataSourceStatusListDriver implements IStatusListDriver {
232
226
  },
233
227
  statusListEntry,
234
228
  }
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
229
  }
247
230
 
248
231
  throw new Error(`Unsupported status list type: ${typeof statusList}`)
@@ -2,9 +2,7 @@ import { StatusListType } from '@sphereon/ssi-types'
2
2
  import { 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
- export function statusListResultToEntity(result: StatusListResult): StatusList2021Entity | OAuthStatusListEntity | BitstringStatusListEntity {
5
+ export function statusListResultToEntity(result: StatusListResult): StatusList2021Entity | OAuthStatusListEntity {
8
6
  const baseFields = {
9
7
  id: result.id,
10
8
  correlationId: result.correlationId,
@@ -35,17 +33,6 @@ export function statusListResultToEntity(result: StatusListResult): StatusList20
35
33
  bitsPerStatus: result.oauthStatusList.bitsPerStatus,
36
34
  expiresAt: result.oauthStatusList.expiresAt,
37
35
  })
38
- } else if (result.type === StatusListType.BitstringStatusList) {
39
- if (!result.bitstringStatusList) {
40
- throw new Error('Missing bitstringStatusList details')
41
- }
42
- return Object.assign(new BitstringStatusListEntity(), {
43
- ...baseFields,
44
- statusPurpose: result.bitstringStatusList.statusPurpose,
45
- ttl: result.bitstringStatusList.ttl,
46
- validFrom: result.bitstringStatusList.validFrom,
47
- validUntil: result.bitstringStatusList.validUntil,
48
- })
49
36
  }
50
37
  throw new Error(`Unsupported status list type: ${result.type}`)
51
38
  }
package/src/types.ts CHANGED
@@ -7,7 +7,6 @@ import {
7
7
  StatusListStore,
8
8
  } from '@sphereon/ssi-sdk.data-store'
9
9
  import {
10
- BitstringStatusListEntryCredentialStatus,
11
10
  IStatusListPlugin,
12
11
  StatusList2021EntryCredentialStatus,
13
12
  StatusListOAuthEntryCredentialStatus,
@@ -53,7 +52,7 @@ export interface IStatusListDriver {
53
52
  getStatusLists(): Promise<Array<StatusListResult>>
54
53
 
55
54
  updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<{
56
- credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus | BitstringStatusListEntryCredentialStatus
55
+ credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus
57
56
  statusListEntry: IStatusListEntryEntity
58
57
  }>
59
58