@sphereon/ssi-sdk.vc-status-list-issuer-drivers 0.33.1-feature.vcdm2.tsup.32 → 0.33.1-next.3

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.
@@ -0,0 +1,78 @@
1
+ import { DataSources } from '@sphereon/ssi-sdk.agent-config';
2
+ import { IAddStatusListEntryArgs, IGetStatusListEntryByCredentialIdArgs, IGetStatusListEntryByIndexArgs, IStatusListEntryEntity, StatusListStore } from '@sphereon/ssi-sdk.data-store';
3
+ import { StatusList2021EntryCredentialStatus, StatusListOAuthEntryCredentialStatus, StatusListResult } from '@sphereon/ssi-sdk.vc-status-list';
4
+ import { StatusListCredentialIdMode, StatusListDriverType, StatusListType, StatusListCredential } from '@sphereon/ssi-types';
5
+ import { DataSource } from 'typeorm';
6
+ import { IStatusListDriver } from './types';
7
+ export interface StatusListManagementOptions {
8
+ id?: string;
9
+ correlationId?: string;
10
+ driverType: StatusListDriverType;
11
+ driverOptions?: DriverOptions;
12
+ }
13
+ export type DriverOptions = TypeORMOptions;
14
+ export interface TypeORMOptions {
15
+ dbName?: string;
16
+ }
17
+ export interface FilesystemOptions {
18
+ path: string;
19
+ }
20
+ export declare function getOptions(args: {
21
+ id?: string;
22
+ correlationId?: string;
23
+ dbName: string;
24
+ }): StatusListManagementOptions;
25
+ export declare function getDriver(args: {
26
+ id?: string;
27
+ correlationId?: string;
28
+ dbName?: string;
29
+ dataSource?: DataSource;
30
+ dataSources?: DataSources;
31
+ }): Promise<IStatusListDriver>;
32
+ export declare class AgentDataSourceStatusListDriver implements IStatusListDriver {
33
+ private _dataSource;
34
+ private _statusListStore;
35
+ private options;
36
+ private _statusListLength;
37
+ constructor(_dataSource: DataSource, _statusListStore: StatusListStore, options: StatusListManagementOptions);
38
+ static init(options: StatusListManagementOptions, dbArgs?: {
39
+ dataSources?: DataSources;
40
+ dataSource?: DataSource;
41
+ }): Promise<AgentDataSourceStatusListDriver>;
42
+ get dataSource(): DataSource;
43
+ get statusListStore(): StatusListStore;
44
+ getOptions(): DriverOptions;
45
+ getType(): StatusListDriverType;
46
+ createStatusList(args: {
47
+ statusListCredential: StatusListCredential;
48
+ correlationId?: string;
49
+ credentialIdMode?: StatusListCredentialIdMode;
50
+ }): Promise<StatusListResult>;
51
+ updateStatusList(args: {
52
+ statusListCredential: StatusListCredential;
53
+ correlationId: string;
54
+ type: StatusListType;
55
+ }): Promise<StatusListResult>;
56
+ deleteStatusList(): Promise<boolean>;
57
+ private isStatusList2021Entity;
58
+ private isOAuthStatusListEntity;
59
+ updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<{
60
+ credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus;
61
+ statusListEntry: IStatusListEntryEntity;
62
+ }>;
63
+ getStatusListEntryByCredentialId(args: IGetStatusListEntryByCredentialIdArgs): Promise<IStatusListEntryEntity | undefined>;
64
+ getStatusListEntryByIndex(args: IGetStatusListEntryByIndexArgs): Promise<IStatusListEntryEntity | undefined>;
65
+ getRandomNewStatusListIndex(args?: {
66
+ correlationId?: string;
67
+ }): Promise<number>;
68
+ private getRandomNewStatusListIndexImpl;
69
+ getStatusListLength(args?: {
70
+ correlationId?: string;
71
+ }): Promise<number>;
72
+ getStatusList(args?: {
73
+ correlationId?: string;
74
+ }): Promise<StatusListResult>;
75
+ getStatusLists(): Promise<Array<StatusListResult>>;
76
+ isStatusListIndexInUse(): Promise<boolean>;
77
+ }
78
+ //# sourceMappingURL=drivers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drivers.d.ts","sourceRoot":"","sources":["../src/drivers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAC5D,OAAO,EACL,uBAAuB,EACvB,qCAAqC,EACrC,8BAA8B,EAE9B,sBAAsB,EAEtB,eAAe,EAChB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EACL,mCAAmC,EAEnC,oCAAo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mB,CAAC,IAAI,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAOvE,aAAa,CAAC,IAAI,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAQ3E,cAAc,IAAI,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAWxD,sBAAsB,IAAI,OAAO,CAAC,OAAO,CAAC;CAG3C"}
@@ -0,0 +1,250 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AgentDataSourceStatusListDriver = void 0;
13
+ exports.getOptions = getOptions;
14
+ exports.getDriver = getDriver;
15
+ const ssi_sdk_agent_config_1 = require("@sphereon/ssi-sdk.agent-config");
16
+ const ssi_sdk_data_store_1 = require("@sphereon/ssi-sdk.data-store");
17
+ const ssi_sdk_vc_status_list_1 = require("@sphereon/ssi-sdk.vc-status-list");
18
+ const ssi_types_1 = require("@sphereon/ssi-types");
19
+ const status_list_adapters_1 = require("./status-list-adapters");
20
+ const StatusListEntities_1 = require("@sphereon/ssi-sdk.data-store/dist/entities/statusList/StatusListEntities");
21
+ function getOptions(args) {
22
+ return {
23
+ id: args.id,
24
+ correlationId: args.correlationId,
25
+ driverType: ssi_types_1.StatusListDriverType.AGENT_TYPEORM,
26
+ driverOptions: { dbName: args.dbName },
27
+ };
28
+ }
29
+ function getDriver(args) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ var _a, _b, _c, _d;
32
+ const dbName = (_a = args.dbName) !== null && _a !== void 0 ? _a : (_b = args.dataSource) === null || _b === void 0 ? void 0 : _b.name;
33
+ if (!dbName) {
34
+ throw Error(`Please provide either a DB name or data source`);
35
+ }
36
+ const dataSources = (_c = args.dataSources) !== null && _c !== void 0 ? _c : ssi_sdk_agent_config_1.DataSources.singleInstance();
37
+ return yield AgentDataSourceStatusListDriver.init(getOptions(Object.assign(Object.assign({}, args), { dbName })), { dataSource: (_d = args.dataSource) !== null && _d !== void 0 ? _d : (yield dataSources.getDbConnection(dbName)), dataSources });
38
+ });
39
+ }
40
+ class AgentDataSourceStatusListDriver {
41
+ constructor(_dataSource, _statusListStore, options) {
42
+ this._dataSource = _dataSource;
43
+ this._statusListStore = _statusListStore;
44
+ this.options = options;
45
+ }
46
+ static init(options, dbArgs) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ if (options.driverType !== ssi_types_1.StatusListDriverType.AGENT_TYPEORM) {
49
+ throw Error(`TypeORM driver can only be used when the TypeORM driver type is selected in the configuration. Got: ${options.driverType}`);
50
+ }
51
+ else if (!options.driverOptions) {
52
+ throw Error(`TypeORM driver can only be used when the TypeORM options are provided.`);
53
+ }
54
+ let dataSource;
55
+ let statusListStore;
56
+ if (dbArgs === null || dbArgs === void 0 ? void 0 : dbArgs.dataSource) {
57
+ dataSource = dbArgs.dataSource;
58
+ }
59
+ else if (options.driverOptions.dbName) {
60
+ if (dbArgs === null || dbArgs === void 0 ? void 0 : dbArgs.dataSources) {
61
+ dataSource = yield dbArgs.dataSources.getDbConnection(options.driverOptions.dbName);
62
+ }
63
+ else {
64
+ dataSource = yield ssi_sdk_agent_config_1.DataSources.singleInstance().getDbConnection(options.driverOptions.dbName);
65
+ }
66
+ }
67
+ else {
68
+ return Promise.reject(Error(`Either a datasource or dbName needs to be provided`));
69
+ }
70
+ statusListStore = new ssi_sdk_data_store_1.StatusListStore(dataSource);
71
+ return new AgentDataSourceStatusListDriver(dataSource, statusListStore, options);
72
+ });
73
+ }
74
+ get dataSource() {
75
+ var _a;
76
+ if (!this._dataSource) {
77
+ throw Error(`Datasource not available yet for ${(_a = this.options.driverOptions) === null || _a === void 0 ? void 0 : _a.dbName}`);
78
+ }
79
+ return this._dataSource;
80
+ }
81
+ get statusListStore() {
82
+ if (!this._statusListStore) {
83
+ this._statusListStore = new ssi_sdk_data_store_1.StatusListStore(this.dataSource);
84
+ }
85
+ return this._statusListStore;
86
+ }
87
+ getOptions() {
88
+ var _a;
89
+ return (_a = this.options.driverOptions) !== null && _a !== void 0 ? _a : {};
90
+ }
91
+ getType() {
92
+ return this.options.driverType;
93
+ }
94
+ createStatusList(args) {
95
+ return __awaiter(this, void 0, void 0, function* () {
96
+ var _a, _b;
97
+ const correlationId = (_a = args.correlationId) !== null && _a !== void 0 ? _a : this.options.correlationId;
98
+ if (!correlationId) {
99
+ 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');
100
+ }
101
+ const credentialIdMode = (_b = args.credentialIdMode) !== null && _b !== void 0 ? _b : ssi_types_1.StatusListCredentialIdMode.ISSUANCE;
102
+ const details = yield (0, ssi_sdk_vc_status_list_1.statusListCredentialToDetails)(Object.assign(Object.assign({}, args), { correlationId, driverType: this.getType() }));
103
+ // (StatusListStore does the duplicate entity check)
104
+ yield this.statusListStore.addStatusList(Object.assign(Object.assign({}, details), { credentialIdMode,
105
+ correlationId, driverType: this.getType() }));
106
+ this._statusListLength = details.length;
107
+ return details;
108
+ });
109
+ }
110
+ updateStatusList(args) {
111
+ return __awaiter(this, void 0, void 0, function* () {
112
+ var _a;
113
+ const correlationId = (_a = args.correlationId) !== null && _a !== void 0 ? _a : this.options.correlationId;
114
+ const details = yield (0, ssi_sdk_vc_status_list_1.statusListCredentialToDetails)(Object.assign(Object.assign({}, args), { correlationId, driverType: this.getType() }));
115
+ const entity = yield (yield this.statusListStore.getStatusListRepo(args.type)).findOne({
116
+ where: [
117
+ {
118
+ id: details.id,
119
+ },
120
+ {
121
+ correlationId,
122
+ },
123
+ ],
124
+ });
125
+ if (!entity) {
126
+ throw Error(`Status list ${details.id}, correlationId ${args.correlationId} could not be found`);
127
+ }
128
+ yield this.statusListStore.updateStatusList(Object.assign(Object.assign(Object.assign({}, entity), details), { correlationId, driverType: this.getType() }));
129
+ this._statusListLength = details.length;
130
+ return Object.assign(Object.assign({}, entity), details);
131
+ });
132
+ }
133
+ deleteStatusList() {
134
+ return __awaiter(this, void 0, void 0, function* () {
135
+ yield this.statusListStore.removeStatusList({ id: this.options.id, correlationId: this.options.correlationId });
136
+ return Promise.resolve(true);
137
+ });
138
+ }
139
+ isStatusList2021Entity(statusList) {
140
+ return statusList instanceof StatusListEntities_1.StatusList2021Entity;
141
+ }
142
+ isOAuthStatusListEntity(statusList) {
143
+ return statusList instanceof StatusListEntities_1.OAuthStatusListEntity;
144
+ }
145
+ updateStatusListEntry(args) {
146
+ return __awaiter(this, void 0, void 0, function* () {
147
+ var _a;
148
+ const statusList = args.statusList ? args.statusList : (0, status_list_adapters_1.statusListResultToEntity)(yield this.getStatusList());
149
+ const statusListEntry = yield this.statusListStore.updateStatusListEntry(Object.assign(Object.assign({}, args), { statusListId: statusList.id }));
150
+ if (this.isStatusList2021Entity(statusList)) {
151
+ return {
152
+ credentialStatus: {
153
+ id: `${statusList.id}#${statusListEntry.statusListIndex}`,
154
+ type: 'StatusList2021Entry',
155
+ statusPurpose: (_a = statusList.statusPurpose) !== null && _a !== void 0 ? _a : 'revocation',
156
+ statusListIndex: '' + statusListEntry.statusListIndex,
157
+ statusListCredential: statusList.id,
158
+ },
159
+ statusListEntry,
160
+ };
161
+ }
162
+ else if (this.isOAuthStatusListEntity(statusList)) {
163
+ return {
164
+ credentialStatus: {
165
+ id: `${statusList.id}#${statusListEntry.statusListIndex}`,
166
+ type: 'OAuthStatusListEntry',
167
+ bitsPerStatus: statusList.bitsPerStatus,
168
+ statusListIndex: '' + statusListEntry.statusListIndex,
169
+ statusListCredential: statusList.id,
170
+ expiresAt: statusList.expiresAt,
171
+ },
172
+ statusListEntry,
173
+ };
174
+ }
175
+ throw new Error(`Unsupported status list type: ${typeof statusList}`);
176
+ });
177
+ }
178
+ getStatusListEntryByCredentialId(args) {
179
+ return __awaiter(this, void 0, void 0, function* () {
180
+ return yield this.statusListStore.getStatusListEntryByCredentialId(args);
181
+ });
182
+ }
183
+ getStatusListEntryByIndex(args) {
184
+ return __awaiter(this, void 0, void 0, function* () {
185
+ return yield this.statusListStore.getStatusListEntryByIndex(args);
186
+ });
187
+ }
188
+ getRandomNewStatusListIndex(args) {
189
+ return __awaiter(this, void 0, void 0, function* () {
190
+ let result = -1;
191
+ let tries = 0;
192
+ while (result < 0) {
193
+ // no tries guard, because we will throw an error when they are exhausted anyway
194
+ result = yield this.getRandomNewStatusListIndexImpl(tries++, args);
195
+ }
196
+ return result;
197
+ });
198
+ }
199
+ getRandomNewStatusListIndexImpl(tries, args) {
200
+ return __awaiter(this, void 0, void 0, function* () {
201
+ var _a;
202
+ const statusListId = this.options.id;
203
+ const correlationId = (_a = args === null || args === void 0 ? void 0 : args.correlationId) !== null && _a !== void 0 ? _a : this.options.correlationId;
204
+ if (tries >= 10) {
205
+ throw Error(`We could not find any random status list index that is available in the statuslist ${statusListId}`);
206
+ }
207
+ // TODO: Check against DB
208
+ const length = yield this.getStatusListLength(args);
209
+ const statusListIndex = Array.from({ length: 20 }, () => Math.floor(Math.random() * length));
210
+ const available = yield this.statusListStore.availableStatusListEntries(Object.assign(Object.assign({ statusListId }, (correlationId && { correlationId })), { statusListIndex }));
211
+ if (available.length > 0) {
212
+ return available[0]; // doesn't matter we pick the first element, as they are all random anyway
213
+ }
214
+ return -1;
215
+ });
216
+ }
217
+ getStatusListLength(args) {
218
+ return __awaiter(this, void 0, void 0, function* () {
219
+ if (!this._statusListLength) {
220
+ this._statusListLength = yield this.getStatusList(args).then((details) => details.length);
221
+ }
222
+ return this._statusListLength;
223
+ });
224
+ }
225
+ getStatusList(args) {
226
+ return __awaiter(this, void 0, void 0, function* () {
227
+ var _a;
228
+ const id = this.options.id;
229
+ const correlationId = (_a = args === null || args === void 0 ? void 0 : args.correlationId) !== null && _a !== void 0 ? _a : this.options.correlationId;
230
+ return yield this.statusListStore
231
+ .getStatusList({ id, correlationId })
232
+ .then((statusListEntity) => (0, ssi_sdk_vc_status_list_1.statusListCredentialToDetails)({ statusListCredential: statusListEntity.statusListCredential }));
233
+ });
234
+ }
235
+ getStatusLists() {
236
+ return __awaiter(this, void 0, void 0, function* () {
237
+ const statusLists = yield this.statusListStore.getStatusLists({});
238
+ return Promise.all(statusLists.map((statusListEntity) => __awaiter(this, void 0, void 0, function* () {
239
+ return (0, ssi_sdk_vc_status_list_1.statusListCredentialToDetails)({
240
+ statusListCredential: statusListEntity.statusListCredential,
241
+ });
242
+ })));
243
+ });
244
+ }
245
+ isStatusListIndexInUse() {
246
+ return Promise.resolve(false);
247
+ }
248
+ }
249
+ exports.AgentDataSourceStatusListDriver = AgentDataSourceStatusListDriver;
250
+ //# sourceMappingURL=drivers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drivers.js","sourceRoot":"","sources":["../src/drivers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAuCA,gCAOC;AAED,8BAmBC;AAnED,yEAA4D;AAC5D,qEAQqC;AACrC,6EAKyC;AACzC,mDAA4H;AAG5H,iEAAiE;AACjE,iHAAsI;AAmBtI,SAAgB,UAAU,CAAC,IAA6D;IACtF,OAAO;QACL,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,UAAU,EAAE,gCAAoB,CAAC,aAAa;QAC9C,aAAa,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;KACvC,CAAA;AACH,CAAC;AAED,SAAsB,SAAS,CAAC,IAM/B;;;QACC,MAAM,MAAM,GAAG,MAA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;YAC1B,MAAM,aAAa,GAAG,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,aAAa,mCAAI,IAAI,CAAC,OAAO,CAAC,aAAa,CAAA;YACvE,OAAO,MAAM,IAAI,CAAC,eAAe;iBAC9B,aAAa,CAAC,EAAE,EAAE,EAAE,aAAa,EAAE,CAAC;iBACpC,IAAI,CAAC,CAAC,gBAAmC,EAAE,EAAE,CAAC,IAAA,sDAA6B,EAAC,EAAE,oBAAoB,EAAE,gBAAgB,CAAC,oBAAqB,EAAE,CAAC,CAAC,CAAA;QACnJ,CAAC;KAAA;IAEK,cAAc;;YAClB,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,CAAC,CAAA;YACjE,OAAO,OAAO,CAAC,GAAG,CAChB,WAAW,CAAC,GAAG,CAAC,CAAO,gBAAgB,EAAE,EAAE;gBACzC,OAAO,IAAA,sDAA6B,EAAC;oBACnC,oBAAoB,EAAE,gBAAgB,CAAC,oBAAqB;iBAC7D,CAAC,CAAA;YACJ,CAAC,CAAA,CAAC,CACH,CAAA;QACH,CAAC;KAAA;IAED,sBAAsB;QACpB,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC/B,CAAC;CACF;AAvOD,0EAuOC"}
package/dist/index.d.ts CHANGED
@@ -1,114 +1,6 @@
1
- import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution';
2
- import { StatusListStore, IAddStatusListEntryArgs, IStatusListEntryEntity, IGetStatusListEntryByCredentialIdArgs, IGetStatusListEntryByIndexArgs } from '@sphereon/ssi-sdk.data-store';
3
- import { StatusListResult, StatusList2021EntryCredentialStatus, StatusListOAuthEntryCredentialStatus, IStatusListPlugin } from '@sphereon/ssi-sdk.vc-status-list';
4
- import { StatusListDriverType, StatusListCredential, StatusListCredentialIdMode, StatusListType } from '@sphereon/ssi-types';
5
- import { IDataStoreORM, IDIDManager, IKeyManager, ICredentialIssuer, ICredentialVerifier, ICredentialPlugin, IResolver, IAgentContext } from '@veramo/core';
6
- import { DataSources } from '@sphereon/ssi-sdk.agent-config';
7
- import { DataSource } from 'typeorm';
8
-
9
- interface StatusListManagementOptions {
10
- id?: string;
11
- correlationId?: string;
12
- driverType: StatusListDriverType;
13
- driverOptions?: DriverOptions;
14
- }
15
- type DriverOptions = TypeORMOptions;
16
- interface TypeORMOptions {
17
- dbName?: string;
18
- }
19
- interface FilesystemOptions {
20
- path: string;
21
- }
22
- declare function getOptions(args: {
23
- id?: string;
24
- correlationId?: string;
25
- dbName: string;
26
- }): StatusListManagementOptions;
27
- declare function getDriver(args: {
28
- id?: string;
29
- correlationId?: string;
30
- dbName?: string;
31
- dataSource?: DataSource;
32
- dataSources?: DataSources;
33
- }): Promise<IStatusListDriver>;
34
- declare class AgentDataSourceStatusListDriver implements IStatusListDriver {
35
- private _dataSource;
36
- private _statusListStore;
37
- private options;
38
- private _statusListLength;
39
- constructor(_dataSource: DataSource, _statusListStore: StatusListStore, options: StatusListManagementOptions);
40
- static init(options: StatusListManagementOptions, dbArgs?: {
41
- dataSources?: DataSources;
42
- dataSource?: DataSource;
43
- }): Promise<AgentDataSourceStatusListDriver>;
44
- get dataSource(): DataSource;
45
- get statusListStore(): StatusListStore;
46
- getOptions(): DriverOptions;
47
- getType(): StatusListDriverType;
48
- createStatusList(args: {
49
- statusListCredential: StatusListCredential;
50
- correlationId?: string;
51
- credentialIdMode?: StatusListCredentialIdMode;
52
- }): Promise<StatusListResult>;
53
- updateStatusList(args: {
54
- statusListCredential: StatusListCredential;
55
- correlationId: string;
56
- type: StatusListType;
57
- }): Promise<StatusListResult>;
58
- deleteStatusList(): Promise<boolean>;
59
- private isStatusList2021Entity;
60
- private isOAuthStatusListEntity;
61
- updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<{
62
- credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus;
63
- statusListEntry: IStatusListEntryEntity;
64
- }>;
65
- getStatusListEntryByCredentialId(args: IGetStatusListEntryByCredentialIdArgs): Promise<IStatusListEntryEntity | undefined>;
66
- getStatusListEntryByIndex(args: IGetStatusListEntryByIndexArgs): Promise<IStatusListEntryEntity | undefined>;
67
- getRandomNewStatusListIndex(args?: {
68
- correlationId?: string;
69
- }): Promise<number>;
70
- private getRandomNewStatusListIndexImpl;
71
- getStatusListLength(args?: {
72
- correlationId?: string;
73
- }): Promise<number>;
74
- getStatusList(args?: {
75
- correlationId?: string;
76
- }): Promise<StatusListResult>;
77
- getStatusLists(): Promise<Array<StatusListResult>>;
78
- isStatusListIndexInUse(): Promise<boolean>;
79
- }
80
-
81
- type IRequiredPlugins = IDataStoreORM & IDIDManager & IKeyManager & IIdentifierResolution & ICredentialIssuer & ICredentialVerifier & ICredentialPlugin & IStatusListPlugin & IResolver;
82
- type IRequiredContext = IAgentContext<IRequiredPlugins>;
83
- interface IStatusListDriver {
84
- statusListStore: StatusListStore;
85
- getType(): StatusListDriverType;
86
- getOptions(): DriverOptions;
87
- getStatusListLength(args?: {
88
- correlationId?: string;
89
- }): Promise<number>;
90
- createStatusList(args: {
91
- statusListCredential: StatusListCredential;
92
- correlationId?: string;
93
- }): Promise<StatusListResult>;
94
- getStatusList(args?: {
95
- correlationId?: string;
96
- }): Promise<StatusListResult>;
97
- getStatusLists(): Promise<Array<StatusListResult>>;
98
- updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<{
99
- credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus;
100
- statusListEntry: IStatusListEntryEntity;
101
- }>;
102
- getStatusListEntryByCredentialId(args: IGetStatusListEntryByCredentialIdArgs): Promise<IStatusListEntryEntity | undefined>;
103
- getStatusListEntryByIndex(args: IGetStatusListEntryByIndexArgs): Promise<IStatusListEntryEntity | undefined>;
104
- updateStatusList(args: {
105
- statusListCredential: StatusListCredential;
106
- }): Promise<StatusListResult>;
107
- deleteStatusList(): Promise<boolean>;
108
- getRandomNewStatusListIndex(args?: {
109
- correlationId?: string;
110
- }): Promise<number>;
111
- isStatusListIndexInUse(): Promise<boolean>;
112
- }
113
-
114
- export { AgentDataSourceStatusListDriver, type DriverOptions, type FilesystemOptions, type IRequiredContext, type IRequiredPlugins, type IStatusListDriver, type StatusListManagementOptions, type TypeORMOptions, getDriver, getOptions };
1
+ /**
2
+ * @public
3
+ */
4
+ export * from './types';
5
+ export * from './drivers';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA"}