@sphereon/ssi-sdk.vc-status-list-issuer-drivers 0.32.1-next.54 → 0.33.1-feature.vcdm2.4
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/drivers.d.ts +12 -8
- package/dist/drivers.d.ts.map +1 -1
- package/dist/drivers.js +174 -179
- package/dist/drivers.js.map +1 -1
- package/dist/index.js +2 -18
- package/dist/index.js.map +1 -1
- package/dist/status-list-adapters.d.ts +4 -0
- package/dist/status-list-adapters.d.ts.map +1 -0
- package/dist/status-list-adapters.js +37 -0
- package/dist/status-list-adapters.js.map +1 -0
- package/dist/types.d.ts +9 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -2
- package/package.json +11 -11
- package/src/drivers.ts +69 -33
- package/src/status-list-adapters.ts +38 -0
- package/src/types.ts +13 -6
package/dist/drivers.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DataSources } from '@sphereon/ssi-sdk.agent-config';
|
|
2
2
|
import { IAddStatusListEntryArgs, IGetStatusListEntryByCredentialIdArgs, IGetStatusListEntryByIndexArgs, IStatusListEntryEntity, StatusListStore } from '@sphereon/ssi-sdk.data-store';
|
|
3
|
-
import { StatusList2021EntryCredentialStatus,
|
|
4
|
-
import {
|
|
3
|
+
import { StatusList2021EntryCredentialStatus, StatusListOAuthEntryCredentialStatus, StatusListResult } from '@sphereon/ssi-sdk.vc-status-list';
|
|
4
|
+
import { StatusListCredentialIdMode, StatusListDriverType, StatusListType, StatusListCredential } from '@sphereon/ssi-types';
|
|
5
5
|
import { DataSource } from 'typeorm';
|
|
6
6
|
import { IStatusListDriver } from './types';
|
|
7
7
|
export interface StatusListManagementOptions {
|
|
@@ -44,17 +44,20 @@ export declare class AgentDataSourceStatusListDriver implements IStatusListDrive
|
|
|
44
44
|
getOptions(): DriverOptions;
|
|
45
45
|
getType(): StatusListDriverType;
|
|
46
46
|
createStatusList(args: {
|
|
47
|
-
statusListCredential:
|
|
47
|
+
statusListCredential: StatusListCredential;
|
|
48
48
|
correlationId?: string;
|
|
49
49
|
credentialIdMode?: StatusListCredentialIdMode;
|
|
50
|
-
}): Promise<
|
|
50
|
+
}): Promise<StatusListResult>;
|
|
51
51
|
updateStatusList(args: {
|
|
52
|
-
statusListCredential:
|
|
52
|
+
statusListCredential: StatusListCredential;
|
|
53
53
|
correlationId: string;
|
|
54
|
-
|
|
54
|
+
type: StatusListType;
|
|
55
|
+
}): Promise<StatusListResult>;
|
|
55
56
|
deleteStatusList(): Promise<boolean>;
|
|
57
|
+
private isStatusList2021Entity;
|
|
58
|
+
private isOAuthStatusListEntity;
|
|
56
59
|
updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<{
|
|
57
|
-
credentialStatus: StatusList2021EntryCredentialStatus;
|
|
60
|
+
credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus;
|
|
58
61
|
statusListEntry: IStatusListEntryEntity;
|
|
59
62
|
}>;
|
|
60
63
|
getStatusListEntryByCredentialId(args: IGetStatusListEntryByCredentialIdArgs): Promise<IStatusListEntryEntity | undefined>;
|
|
@@ -68,7 +71,8 @@ export declare class AgentDataSourceStatusListDriver implements IStatusListDrive
|
|
|
68
71
|
}): Promise<number>;
|
|
69
72
|
getStatusList(args?: {
|
|
70
73
|
correlationId?: string;
|
|
71
|
-
}): Promise<
|
|
74
|
+
}): Promise<StatusListResult>;
|
|
75
|
+
getStatusLists(): Promise<Array<StatusListResult>>;
|
|
72
76
|
isStatusListIndexInUse(): Promise<boolean>;
|
|
73
77
|
}
|
|
74
78
|
//# sourceMappingURL=drivers.d.ts.map
|
package/dist/drivers.d.ts.map
CHANGED
|
@@ -1 +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,EAC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CAAC;IAgCI,gCAAgC,CAAC,IAAI,EAAE,qCAAqC,GAAG,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC;IAI1H,yBAAyB,CAAC,IAAI,EAAE,8BAA8B,GAAG,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC;IAI5G,2BAA2B,CAAC,IAAI,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;YAUvE,+BAA+B;IAoBvC,mBAAmB,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"}
|
package/dist/drivers.js
CHANGED
|
@@ -1,226 +1,221 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
function getOptions(args) {
|
|
1
|
+
import { DataSources } from '@sphereon/ssi-sdk.agent-config';
|
|
2
|
+
import { StatusListStore, } from '@sphereon/ssi-sdk.data-store';
|
|
3
|
+
import { statusListCredentialToDetails, } from '@sphereon/ssi-sdk.vc-status-list';
|
|
4
|
+
import { StatusListCredentialIdMode, StatusListDriverType } from '@sphereon/ssi-types';
|
|
5
|
+
import { statusListResultToEntity } from './status-list-adapters';
|
|
6
|
+
import { OAuthStatusListEntity, StatusList2021Entity } from '@sphereon/ssi-sdk.data-store/dist/entities/statusList/StatusListEntities';
|
|
7
|
+
export function getOptions(args) {
|
|
20
8
|
return {
|
|
21
9
|
id: args.id,
|
|
22
10
|
correlationId: args.correlationId,
|
|
23
|
-
driverType:
|
|
11
|
+
driverType: StatusListDriverType.AGENT_TYPEORM,
|
|
24
12
|
driverOptions: { dbName: args.dbName },
|
|
25
13
|
};
|
|
26
14
|
}
|
|
27
|
-
function getDriver(args) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
});
|
|
15
|
+
export async function getDriver(args) {
|
|
16
|
+
const dbName = args.dbName ?? args.dataSource?.name;
|
|
17
|
+
if (!dbName) {
|
|
18
|
+
throw Error(`Please provide either a DB name or data source`);
|
|
19
|
+
}
|
|
20
|
+
const dataSources = args.dataSources ?? DataSources.singleInstance();
|
|
21
|
+
return await AgentDataSourceStatusListDriver.init(getOptions({
|
|
22
|
+
...args,
|
|
23
|
+
dbName,
|
|
24
|
+
}), { dataSource: args.dataSource ?? (await dataSources.getDbConnection(dbName)), dataSources });
|
|
37
25
|
}
|
|
38
|
-
class AgentDataSourceStatusListDriver {
|
|
26
|
+
export class AgentDataSourceStatusListDriver {
|
|
27
|
+
_dataSource;
|
|
28
|
+
_statusListStore;
|
|
29
|
+
options;
|
|
30
|
+
_statusListLength;
|
|
39
31
|
constructor(_dataSource, _statusListStore, options) {
|
|
40
32
|
this._dataSource = _dataSource;
|
|
41
33
|
this._statusListStore = _statusListStore;
|
|
42
34
|
this.options = options;
|
|
43
35
|
}
|
|
44
|
-
static init(options, dbArgs) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
dataSource = yield dbArgs.dataSources.getDbConnection(options.driverOptions.dbName);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
dataSource = yield ssi_sdk_agent_config_1.DataSources.singleInstance().getDbConnection(options.driverOptions.dbName);
|
|
63
|
-
}
|
|
36
|
+
static async init(options, dbArgs) {
|
|
37
|
+
if (options.driverType !== StatusListDriverType.AGENT_TYPEORM) {
|
|
38
|
+
throw Error(`TypeORM driver can only be used when the TypeORM driver type is selected in the configuration. Got: ${options.driverType}`);
|
|
39
|
+
}
|
|
40
|
+
else if (!options.driverOptions) {
|
|
41
|
+
throw Error(`TypeORM driver can only be used when the TypeORM options are provided.`);
|
|
42
|
+
}
|
|
43
|
+
let dataSource;
|
|
44
|
+
let statusListStore;
|
|
45
|
+
if (dbArgs?.dataSource) {
|
|
46
|
+
dataSource = dbArgs.dataSource;
|
|
47
|
+
}
|
|
48
|
+
else if (options.driverOptions.dbName) {
|
|
49
|
+
if (dbArgs?.dataSources) {
|
|
50
|
+
dataSource = await dbArgs.dataSources.getDbConnection(options.driverOptions.dbName);
|
|
64
51
|
}
|
|
65
52
|
else {
|
|
66
|
-
|
|
53
|
+
dataSource = await DataSources.singleInstance().getDbConnection(options.driverOptions.dbName);
|
|
67
54
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
return Promise.reject(Error(`Either a datasource or dbName needs to be provided`));
|
|
58
|
+
}
|
|
59
|
+
statusListStore = new StatusListStore(dataSource);
|
|
60
|
+
return new AgentDataSourceStatusListDriver(dataSource, statusListStore, options);
|
|
71
61
|
}
|
|
72
62
|
get dataSource() {
|
|
73
|
-
var _a;
|
|
74
63
|
if (!this._dataSource) {
|
|
75
|
-
throw Error(`Datasource not available yet for ${
|
|
64
|
+
throw Error(`Datasource not available yet for ${this.options.driverOptions?.dbName}`);
|
|
76
65
|
}
|
|
77
66
|
return this._dataSource;
|
|
78
67
|
}
|
|
79
68
|
get statusListStore() {
|
|
80
69
|
if (!this._statusListStore) {
|
|
81
|
-
this._statusListStore = new
|
|
70
|
+
this._statusListStore = new StatusListStore(this.dataSource);
|
|
82
71
|
}
|
|
83
72
|
return this._statusListStore;
|
|
84
73
|
}
|
|
85
74
|
getOptions() {
|
|
86
|
-
|
|
87
|
-
return (_a = this.options.driverOptions) !== null && _a !== void 0 ? _a : {};
|
|
75
|
+
return this.options.driverOptions ?? {};
|
|
88
76
|
}
|
|
89
77
|
getType() {
|
|
90
78
|
return this.options.driverType;
|
|
91
79
|
}
|
|
92
|
-
createStatusList(args) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
correlationId,
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
|
-
});
|
|
111
|
-
if (entity) {
|
|
112
|
-
throw Error(`Status list ${details.id}, correlationId ${args.correlationId} already exists`);
|
|
113
|
-
}
|
|
114
|
-
this._statusListLength = details.length;
|
|
115
|
-
yield this.statusListStore.addStatusList(Object.assign(Object.assign({}, details), { credentialIdMode,
|
|
116
|
-
correlationId, driverType: this.getType() }));
|
|
117
|
-
return details;
|
|
80
|
+
async createStatusList(args) {
|
|
81
|
+
const correlationId = args.correlationId ?? this.options.correlationId;
|
|
82
|
+
if (!correlationId) {
|
|
83
|
+
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');
|
|
84
|
+
}
|
|
85
|
+
const credentialIdMode = args.credentialIdMode ?? StatusListCredentialIdMode.ISSUANCE;
|
|
86
|
+
const details = await statusListCredentialToDetails({ ...args, correlationId, driverType: this.getType() });
|
|
87
|
+
// (StatusListStore does the duplicate entity check)
|
|
88
|
+
await this.statusListStore.addStatusList({
|
|
89
|
+
...details,
|
|
90
|
+
credentialIdMode,
|
|
91
|
+
correlationId,
|
|
92
|
+
driverType: this.getType(),
|
|
118
93
|
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
});
|
|
135
|
-
if (!entity) {
|
|
136
|
-
throw Error(`Status list ${details.id}, correlationId ${args.correlationId} could not be found`);
|
|
137
|
-
}
|
|
138
|
-
yield this.statusListStore.updateStatusList(Object.assign(Object.assign(Object.assign({}, entity), details), { correlationId, driverType: this.getType() }));
|
|
139
|
-
this._statusListLength = details.length;
|
|
140
|
-
return Object.assign(Object.assign({}, entity), details);
|
|
94
|
+
this._statusListLength = details.length;
|
|
95
|
+
return details;
|
|
96
|
+
}
|
|
97
|
+
async updateStatusList(args) {
|
|
98
|
+
const correlationId = args.correlationId ?? this.options.correlationId;
|
|
99
|
+
const details = await statusListCredentialToDetails({ ...args, correlationId, driverType: this.getType() });
|
|
100
|
+
const entity = await (await this.statusListStore.getStatusListRepo(args.type)).findOne({
|
|
101
|
+
where: [
|
|
102
|
+
{
|
|
103
|
+
id: details.id,
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
correlationId,
|
|
107
|
+
},
|
|
108
|
+
],
|
|
141
109
|
});
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
110
|
+
if (!entity) {
|
|
111
|
+
throw Error(`Status list ${details.id}, correlationId ${args.correlationId} could not be found`);
|
|
112
|
+
}
|
|
113
|
+
await this.statusListStore.updateStatusList({
|
|
114
|
+
...entity,
|
|
115
|
+
...details,
|
|
116
|
+
correlationId,
|
|
117
|
+
driverType: this.getType(),
|
|
147
118
|
});
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
119
|
+
this._statusListLength = details.length;
|
|
120
|
+
return { ...entity, ...details };
|
|
121
|
+
}
|
|
122
|
+
async deleteStatusList() {
|
|
123
|
+
await this.statusListStore.removeStatusList({ id: this.options.id, correlationId: this.options.correlationId });
|
|
124
|
+
return Promise.resolve(true);
|
|
125
|
+
}
|
|
126
|
+
isStatusList2021Entity(statusList) {
|
|
127
|
+
return statusList instanceof StatusList2021Entity;
|
|
128
|
+
}
|
|
129
|
+
isOAuthStatusListEntity(statusList) {
|
|
130
|
+
return statusList instanceof OAuthStatusListEntity;
|
|
131
|
+
}
|
|
132
|
+
async updateStatusListEntry(args) {
|
|
133
|
+
const statusList = args.statusList ? args.statusList : statusListResultToEntity(await this.getStatusList());
|
|
134
|
+
const statusListEntry = await this.statusListStore.updateStatusListEntry({ ...args, statusListId: statusList.id });
|
|
135
|
+
if (this.isStatusList2021Entity(statusList)) {
|
|
136
|
+
return {
|
|
137
|
+
credentialStatus: {
|
|
138
|
+
id: `${statusList.id}#${statusListEntry.statusListIndex}`,
|
|
139
|
+
type: 'StatusList2021Entry',
|
|
140
|
+
statusPurpose: statusList.statusPurpose ?? 'revocation',
|
|
141
|
+
statusListIndex: '' + statusListEntry.statusListIndex,
|
|
142
|
+
statusListCredential: statusList.id,
|
|
143
|
+
},
|
|
144
|
+
statusListEntry,
|
|
160
145
|
};
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
146
|
+
}
|
|
147
|
+
else if (this.isOAuthStatusListEntity(statusList)) {
|
|
148
|
+
return {
|
|
149
|
+
credentialStatus: {
|
|
150
|
+
id: `${statusList.id}#${statusListEntry.statusListIndex}`,
|
|
151
|
+
type: 'OAuthStatusListEntry',
|
|
152
|
+
bitsPerStatus: statusList.bitsPerStatus,
|
|
153
|
+
statusListIndex: '' + statusListEntry.statusListIndex,
|
|
154
|
+
statusListCredential: statusList.id,
|
|
155
|
+
expiresAt: statusList.expiresAt,
|
|
156
|
+
},
|
|
157
|
+
statusListEntry,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
throw new Error(`Unsupported status list type: ${typeof statusList}`);
|
|
168
161
|
}
|
|
169
|
-
|
|
170
|
-
return
|
|
171
|
-
return yield this.statusListStore.getStatusListEntryByIndex(args);
|
|
172
|
-
});
|
|
162
|
+
async getStatusListEntryByCredentialId(args) {
|
|
163
|
+
return await this.statusListStore.getStatusListEntryByCredentialId(args);
|
|
173
164
|
}
|
|
174
|
-
|
|
175
|
-
return
|
|
176
|
-
let result = -1;
|
|
177
|
-
let tries = 0;
|
|
178
|
-
while (result < 0) {
|
|
179
|
-
// no tries guard, because we will throw an error when they are exhausted anyway
|
|
180
|
-
result = yield this.getRandomNewStatusListIndexImpl(tries++, args);
|
|
181
|
-
}
|
|
182
|
-
return result;
|
|
183
|
-
});
|
|
165
|
+
async getStatusListEntryByIndex(args) {
|
|
166
|
+
return await this.statusListStore.getStatusListEntryByIndex(args);
|
|
184
167
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
// TODO: Check against DB
|
|
194
|
-
const length = yield this.getStatusListLength(args);
|
|
195
|
-
const statusListIndex = Array.from({ length: 20 }, () => Math.floor(Math.random() * length));
|
|
196
|
-
const available = yield this.statusListStore.availableStatusListEntries(Object.assign(Object.assign({ statusListId }, (correlationId && { correlationId })), { statusListIndex }));
|
|
197
|
-
if (available.length > 0) {
|
|
198
|
-
return available[0]; // doesn't matter we pick the first element, as they are all random anyway
|
|
199
|
-
}
|
|
200
|
-
return -1;
|
|
201
|
-
});
|
|
168
|
+
async getRandomNewStatusListIndex(args) {
|
|
169
|
+
let result = -1;
|
|
170
|
+
let tries = 0;
|
|
171
|
+
while (result < 0) {
|
|
172
|
+
// no tries guard, because we will throw an error when they are exhausted anyway
|
|
173
|
+
result = await this.getRandomNewStatusListIndexImpl(tries++, args);
|
|
174
|
+
}
|
|
175
|
+
return result;
|
|
202
176
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
|
|
177
|
+
async getRandomNewStatusListIndexImpl(tries, args) {
|
|
178
|
+
const statusListId = this.options.id;
|
|
179
|
+
const correlationId = args?.correlationId ?? this.options.correlationId;
|
|
180
|
+
if (tries >= 10) {
|
|
181
|
+
throw Error(`We could not find any random status list index that is available in the statuslist ${statusListId}`);
|
|
182
|
+
}
|
|
183
|
+
// TODO: Check against DB
|
|
184
|
+
const length = await this.getStatusListLength(args);
|
|
185
|
+
const statusListIndex = Array.from({ length: 20 }, () => Math.floor(Math.random() * length));
|
|
186
|
+
const available = await this.statusListStore.availableStatusListEntries({
|
|
187
|
+
statusListId,
|
|
188
|
+
...(correlationId && { correlationId }),
|
|
189
|
+
statusListIndex,
|
|
209
190
|
});
|
|
191
|
+
if (available.length > 0) {
|
|
192
|
+
return available[0]; // doesn't matter we pick the first element, as they are all random anyway
|
|
193
|
+
}
|
|
194
|
+
return -1;
|
|
210
195
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
196
|
+
async getStatusListLength(args) {
|
|
197
|
+
if (!this._statusListLength) {
|
|
198
|
+
this._statusListLength = await this.getStatusList(args).then((details) => details.length);
|
|
199
|
+
}
|
|
200
|
+
return this._statusListLength;
|
|
201
|
+
}
|
|
202
|
+
async getStatusList(args) {
|
|
203
|
+
const id = this.options.id;
|
|
204
|
+
const correlationId = args?.correlationId ?? this.options.correlationId;
|
|
205
|
+
return await this.statusListStore
|
|
206
|
+
.getStatusList({ id, correlationId })
|
|
207
|
+
.then((statusListEntity) => statusListCredentialToDetails({ statusListCredential: statusListEntity.statusListCredential }));
|
|
208
|
+
}
|
|
209
|
+
async getStatusLists() {
|
|
210
|
+
const statusLists = await this.statusListStore.getStatusLists({});
|
|
211
|
+
return Promise.all(statusLists.map(async (statusListEntity) => {
|
|
212
|
+
return statusListCredentialToDetails({
|
|
213
|
+
statusListCredential: statusListEntity.statusListCredential,
|
|
214
|
+
});
|
|
215
|
+
}));
|
|
220
216
|
}
|
|
221
217
|
isStatusListIndexInUse() {
|
|
222
218
|
return Promise.resolve(false);
|
|
223
219
|
}
|
|
224
220
|
}
|
|
225
|
-
exports.AgentDataSourceStatusListDriver = AgentDataSourceStatusListDriver;
|
|
226
221
|
//# sourceMappingURL=drivers.js.map
|
package/dist/drivers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drivers.js","sourceRoot":"","sources":["../src/drivers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"drivers.js","sourceRoot":"","sources":["../src/drivers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAC5D,OAAO,EAOL,eAAe,GAChB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAEL,6BAA6B,GAG9B,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAwC,MAAM,qBAAqB,CAAA;AAG5H,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,0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=== undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
1
|
/**
|
|
18
2
|
* @public
|
|
19
3
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
4
|
+
export * from './types';
|
|
5
|
+
export * from './drivers';
|
|
22
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { OAuthStatusListEntity, StatusList2021Entity } from '@sphereon/ssi-sdk.data-store/dist/entities/statusList/StatusListEntities';
|
|
2
|
+
import { StatusListResult } from '@sphereon/ssi-sdk.vc-status-list';
|
|
3
|
+
export declare function statusListResultToEntity(result: StatusListResult): StatusList2021Entity | OAuthStatusListEntity;
|
|
4
|
+
//# sourceMappingURL=status-list-adapters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-list-adapters.d.ts","sourceRoot":"","sources":["../src/status-list-adapters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,0EAA0E,CAAA;AACtI,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AAEnE,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,gBAAgB,GAAG,oBAAoB,GAAG,qBAAqB,CAiC/G"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { StatusListType } from '@sphereon/ssi-types';
|
|
2
|
+
import { OAuthStatusListEntity, StatusList2021Entity } from '@sphereon/ssi-sdk.data-store/dist/entities/statusList/StatusListEntities';
|
|
3
|
+
export function statusListResultToEntity(result) {
|
|
4
|
+
const baseFields = {
|
|
5
|
+
id: result.id,
|
|
6
|
+
correlationId: result.correlationId,
|
|
7
|
+
driverType: result.driverType,
|
|
8
|
+
credentialIdMode: result.credentialIdMode,
|
|
9
|
+
length: result.length,
|
|
10
|
+
issuer: result.issuer,
|
|
11
|
+
type: result.type,
|
|
12
|
+
proofFormat: result.proofFormat,
|
|
13
|
+
statusListCredential: result.statusListCredential,
|
|
14
|
+
};
|
|
15
|
+
if (result.type === StatusListType.StatusList2021) {
|
|
16
|
+
if (!result.statusList2021) {
|
|
17
|
+
throw new Error('Missing statusList2021 details');
|
|
18
|
+
}
|
|
19
|
+
return Object.assign(new StatusList2021Entity(), {
|
|
20
|
+
...baseFields,
|
|
21
|
+
indexingDirection: result.statusList2021.indexingDirection,
|
|
22
|
+
statusPurpose: result.statusList2021.statusPurpose,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
else if (result.type === StatusListType.OAuthStatusList) {
|
|
26
|
+
if (!result.oauthStatusList) {
|
|
27
|
+
throw new Error('Missing oauthStatusList details');
|
|
28
|
+
}
|
|
29
|
+
return Object.assign(new OAuthStatusListEntity(), {
|
|
30
|
+
...baseFields,
|
|
31
|
+
bitsPerStatus: result.oauthStatusList.bitsPerStatus,
|
|
32
|
+
expiresAt: result.oauthStatusList.expiresAt,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
throw new Error(`Unsupported status list type: ${result.type}`);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=status-list-adapters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-list-adapters.js","sourceRoot":"","sources":["../src/status-list-adapters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,0EAA0E,CAAA;AAGtI,MAAM,UAAU,wBAAwB,CAAC,MAAwB;IAC/D,MAAM,UAAU,GAAG;QACjB,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;QACzC,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,oBAAoB,EAAE,MAAM,CAAC,oBAAoB;KAClD,CAAA;IAED,IAAI,MAAM,CAAC,IAAI,KAAK,cAAc,CAAC,cAAc,EAAE,CAAC;QAClD,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;QACnD,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,oBAAoB,EAAE,EAAE;YAC/C,GAAG,UAAU;YACb,iBAAiB,EAAE,MAAM,CAAC,cAAc,CAAC,iBAAiB;YAC1D,aAAa,EAAE,MAAM,CAAC,cAAc,CAAC,aAAa;SACnD,CAAC,CAAA;IACJ,CAAC;SAAM,IAAI,MAAM,CAAC,IAAI,KAAK,cAAc,CAAC,eAAe,EAAE,CAAC;QAC1D,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;QACpD,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,qBAAqB,EAAE,EAAE;YAChD,GAAG,UAAU;YACb,aAAa,EAAE,MAAM,CAAC,eAAe,CAAC,aAAa;YACnD,SAAS,EAAE,MAAM,CAAC,eAAe,CAAC,SAAS;SAC5C,CAAC,CAAA;IACJ,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,iCAAiC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;AACjE,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution';
|
|
2
2
|
import { IAddStatusListEntryArgs, IGetStatusListEntryByCredentialIdArgs, IGetStatusListEntryByIndexArgs, IStatusListEntryEntity, StatusListStore } from '@sphereon/ssi-sdk.data-store';
|
|
3
|
-
import { IStatusListPlugin, StatusList2021EntryCredentialStatus,
|
|
4
|
-
import {
|
|
3
|
+
import { IStatusListPlugin, StatusList2021EntryCredentialStatus, StatusListOAuthEntryCredentialStatus, StatusListResult } from '@sphereon/ssi-sdk.vc-status-list';
|
|
4
|
+
import { StatusListCredential, StatusListDriverType } from '@sphereon/ssi-types';
|
|
5
5
|
import { IAgentContext, ICredentialIssuer, ICredentialPlugin, ICredentialVerifier, IDataStoreORM, IDIDManager, IKeyManager, IResolver } from '@veramo/core';
|
|
6
6
|
import { DriverOptions } from './drivers';
|
|
7
7
|
export type IRequiredPlugins = IDataStoreORM & IDIDManager & IKeyManager & IIdentifierResolution & ICredentialIssuer & ICredentialVerifier & ICredentialPlugin & IStatusListPlugin & IResolver;
|
|
@@ -14,21 +14,22 @@ export interface IStatusListDriver {
|
|
|
14
14
|
correlationId?: string;
|
|
15
15
|
}): Promise<number>;
|
|
16
16
|
createStatusList(args: {
|
|
17
|
-
statusListCredential:
|
|
17
|
+
statusListCredential: StatusListCredential;
|
|
18
18
|
correlationId?: string;
|
|
19
|
-
}): Promise<
|
|
19
|
+
}): Promise<StatusListResult>;
|
|
20
20
|
getStatusList(args?: {
|
|
21
21
|
correlationId?: string;
|
|
22
|
-
}): Promise<
|
|
22
|
+
}): Promise<StatusListResult>;
|
|
23
|
+
getStatusLists(): Promise<Array<StatusListResult>>;
|
|
23
24
|
updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<{
|
|
24
|
-
credentialStatus: StatusList2021EntryCredentialStatus;
|
|
25
|
+
credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus;
|
|
25
26
|
statusListEntry: IStatusListEntryEntity;
|
|
26
27
|
}>;
|
|
27
28
|
getStatusListEntryByCredentialId(args: IGetStatusListEntryByCredentialIdArgs): Promise<IStatusListEntryEntity | undefined>;
|
|
28
29
|
getStatusListEntryByIndex(args: IGetStatusListEntryByIndexArgs): Promise<IStatusListEntryEntity | undefined>;
|
|
29
30
|
updateStatusList(args: {
|
|
30
|
-
statusListCredential:
|
|
31
|
-
}): Promise<
|
|
31
|
+
statusListCredential: StatusListCredential;
|
|
32
|
+
}): Promise<StatusListResult>;
|
|
32
33
|
deleteStatusList(): Promise<boolean>;
|
|
33
34
|
getRandomNewStatusListIndex(args?: {
|
|
34
35
|
correlationId?: string;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAA;AACnF,OAAO,EACL,uBAAuB,EACvB,qCAAqC,EACrC,8BAA8B,EAC9B,sBAAsB,EACtB,eAAe,EAChB,MAAM,8BAA8B,CAAA;AACrC,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"m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;IAE3E,cAAc,IAAI,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAA;IAElD,qBAAqB,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC;QAC5D,gBAAgB,EAAE,mCAAmC,GAAG,oCAAoC,CAAA;QAC5F,eAAe,EAAE,sBAAsB,CAAA;KACxC,CAAC,CAAA;IAEF,gCAAgC,CAAC,IAAI,EAAE,qCAAqC,GAAG,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC,CAAA;IAE1H,yBAAyB,CAAC,IAAI,EAAE,8BAA8B,GAAG,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC,CAAA;IAE5G,gBAAgB,CAAC,IAAI,EAAE;QAAE,oBAAoB,EAAE,oBAAoB,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAEjG,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;IAEpC,2BAA2B,CAAC,IAAI,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAE/E,sBAAsB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;CAC3C"}
|
package/dist/types.js
CHANGED
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.
|
|
4
|
+
"version": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -10,18 +10,18 @@
|
|
|
10
10
|
"build:clean": "tsc --build --clean && tsc --build"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@sphereon/ssi-express-support": "0.
|
|
14
|
-
"@sphereon/ssi-sdk-ext.did-utils": "0.
|
|
15
|
-
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.
|
|
16
|
-
"@sphereon/ssi-sdk.agent-config": "0.
|
|
17
|
-
"@sphereon/ssi-sdk.core": "0.
|
|
18
|
-
"@sphereon/ssi-sdk.data-store": "0.
|
|
19
|
-
"@sphereon/ssi-sdk.vc-status-list": "0.
|
|
20
|
-
"@sphereon/ssi-types": "0.
|
|
13
|
+
"@sphereon/ssi-express-support": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
14
|
+
"@sphereon/ssi-sdk-ext.did-utils": "0.28.0",
|
|
15
|
+
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.28.0",
|
|
16
|
+
"@sphereon/ssi-sdk.agent-config": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
17
|
+
"@sphereon/ssi-sdk.core": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
18
|
+
"@sphereon/ssi-sdk.data-store": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
19
|
+
"@sphereon/ssi-sdk.vc-status-list": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
20
|
+
"@sphereon/ssi-types": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
21
21
|
"@sphereon/vc-status-list": "7.0.0-next.0",
|
|
22
22
|
"@veramo/core": "4.2.0",
|
|
23
23
|
"debug": "^4.3.5",
|
|
24
|
-
"typeorm": "^0.3.
|
|
24
|
+
"typeorm": "^0.3.21",
|
|
25
25
|
"uint8arrays": "^3.1.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"StatusList2021"
|
|
50
50
|
],
|
|
51
51
|
"nx": {},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "9f634bdb714061141e277508c124b08d626f6036"
|
|
53
53
|
}
|
package/src/drivers.ts
CHANGED
|
@@ -5,12 +5,20 @@ import {
|
|
|
5
5
|
IGetStatusListEntryByIndexArgs,
|
|
6
6
|
IStatusListEntity,
|
|
7
7
|
IStatusListEntryEntity,
|
|
8
|
+
StatusListEntity,
|
|
8
9
|
StatusListStore,
|
|
9
10
|
} from '@sphereon/ssi-sdk.data-store'
|
|
10
|
-
import {
|
|
11
|
-
|
|
11
|
+
import {
|
|
12
|
+
StatusList2021EntryCredentialStatus,
|
|
13
|
+
statusListCredentialToDetails,
|
|
14
|
+
StatusListOAuthEntryCredentialStatus,
|
|
15
|
+
StatusListResult,
|
|
16
|
+
} from '@sphereon/ssi-sdk.vc-status-list'
|
|
17
|
+
import { StatusListCredentialIdMode, StatusListDriverType, StatusListType, StatusListCredential } from '@sphereon/ssi-types'
|
|
12
18
|
import { DataSource } from 'typeorm'
|
|
13
19
|
import { IStatusListDriver } from './types'
|
|
20
|
+
import { statusListResultToEntity } from './status-list-adapters'
|
|
21
|
+
import { OAuthStatusListEntity, StatusList2021Entity } from '@sphereon/ssi-sdk.data-store/dist/entities/statusList/StatusListEntities'
|
|
14
22
|
|
|
15
23
|
export interface StatusListManagementOptions {
|
|
16
24
|
id?: string
|
|
@@ -121,46 +129,37 @@ export class AgentDataSourceStatusListDriver implements IStatusListDriver {
|
|
|
121
129
|
}
|
|
122
130
|
|
|
123
131
|
async createStatusList(args: {
|
|
124
|
-
statusListCredential:
|
|
132
|
+
statusListCredential: StatusListCredential
|
|
125
133
|
correlationId?: string
|
|
126
134
|
credentialIdMode?: StatusListCredentialIdMode
|
|
127
|
-
}): Promise<
|
|
135
|
+
}): Promise<StatusListResult> {
|
|
128
136
|
const correlationId = args.correlationId ?? this.options.correlationId
|
|
129
137
|
if (!correlationId) {
|
|
130
138
|
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')
|
|
131
139
|
}
|
|
132
140
|
const credentialIdMode = args.credentialIdMode ?? StatusListCredentialIdMode.ISSUANCE
|
|
133
141
|
const details = await statusListCredentialToDetails({ ...args, correlationId, driverType: this.getType() })
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
).findOne({
|
|
137
|
-
where: [
|
|
138
|
-
{
|
|
139
|
-
id: details.id,
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
correlationId,
|
|
143
|
-
},
|
|
144
|
-
],
|
|
145
|
-
})
|
|
146
|
-
if (entity) {
|
|
147
|
-
throw Error(`Status list ${details.id}, correlationId ${args.correlationId} already exists`)
|
|
148
|
-
}
|
|
149
|
-
this._statusListLength = details.length
|
|
142
|
+
|
|
143
|
+
// (StatusListStore does the duplicate entity check)
|
|
150
144
|
await this.statusListStore.addStatusList({
|
|
151
145
|
...details,
|
|
152
146
|
credentialIdMode,
|
|
153
147
|
correlationId,
|
|
154
148
|
driverType: this.getType(),
|
|
155
149
|
})
|
|
150
|
+
this._statusListLength = details.length
|
|
156
151
|
return details
|
|
157
152
|
}
|
|
158
153
|
|
|
159
|
-
async updateStatusList(args: {
|
|
154
|
+
async updateStatusList(args: {
|
|
155
|
+
statusListCredential: StatusListCredential
|
|
156
|
+
correlationId: string
|
|
157
|
+
type: StatusListType
|
|
158
|
+
}): Promise<StatusListResult> {
|
|
160
159
|
const correlationId = args.correlationId ?? this.options.correlationId
|
|
161
160
|
const details = await statusListCredentialToDetails({ ...args, correlationId, driverType: this.getType() })
|
|
162
161
|
const entity = await (
|
|
163
|
-
await this.statusListStore.getStatusListRepo()
|
|
162
|
+
await this.statusListStore.getStatusListRepo(args.type)
|
|
164
163
|
).findOne({
|
|
165
164
|
where: [
|
|
166
165
|
{
|
|
@@ -189,21 +188,47 @@ export class AgentDataSourceStatusListDriver implements IStatusListDriver {
|
|
|
189
188
|
return Promise.resolve(true)
|
|
190
189
|
}
|
|
191
190
|
|
|
191
|
+
private isStatusList2021Entity(statusList: StatusListEntity): statusList is StatusList2021Entity {
|
|
192
|
+
return statusList instanceof StatusList2021Entity
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
private isOAuthStatusListEntity(statusList: StatusListEntity): statusList is OAuthStatusListEntity {
|
|
196
|
+
return statusList instanceof OAuthStatusListEntity
|
|
197
|
+
}
|
|
198
|
+
|
|
192
199
|
async updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<{
|
|
193
|
-
credentialStatus: StatusList2021EntryCredentialStatus
|
|
200
|
+
credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus
|
|
194
201
|
statusListEntry: IStatusListEntryEntity
|
|
195
202
|
}> {
|
|
196
|
-
const statusList =
|
|
203
|
+
const statusList: StatusListEntity = args.statusList ? args.statusList : statusListResultToEntity(await this.getStatusList())
|
|
204
|
+
const statusListEntry = await this.statusListStore.updateStatusListEntry({ ...args, statusListId: statusList.id })
|
|
197
205
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
206
|
+
if (this.isStatusList2021Entity(statusList)) {
|
|
207
|
+
return {
|
|
208
|
+
credentialStatus: {
|
|
209
|
+
id: `${statusList.id}#${statusListEntry.statusListIndex}`,
|
|
210
|
+
type: 'StatusList2021Entry',
|
|
211
|
+
statusPurpose: statusList.statusPurpose ?? 'revocation',
|
|
212
|
+
statusListIndex: '' + statusListEntry.statusListIndex,
|
|
213
|
+
statusListCredential: statusList.id,
|
|
214
|
+
},
|
|
215
|
+
statusListEntry,
|
|
216
|
+
}
|
|
217
|
+
} else if (this.isOAuthStatusListEntity(statusList)) {
|
|
218
|
+
return {
|
|
219
|
+
credentialStatus: {
|
|
220
|
+
id: `${statusList.id}#${statusListEntry.statusListIndex}`,
|
|
221
|
+
type: 'OAuthStatusListEntry',
|
|
222
|
+
bitsPerStatus: statusList.bitsPerStatus,
|
|
223
|
+
statusListIndex: '' + statusListEntry.statusListIndex,
|
|
224
|
+
statusListCredential: statusList.id,
|
|
225
|
+
expiresAt: statusList.expiresAt,
|
|
226
|
+
},
|
|
227
|
+
statusListEntry,
|
|
228
|
+
}
|
|
205
229
|
}
|
|
206
|
-
|
|
230
|
+
|
|
231
|
+
throw new Error(`Unsupported status list type: ${typeof statusList}`)
|
|
207
232
|
}
|
|
208
233
|
|
|
209
234
|
async getStatusListEntryByCredentialId(args: IGetStatusListEntryByCredentialIdArgs): Promise<IStatusListEntryEntity | undefined> {
|
|
@@ -251,7 +276,7 @@ export class AgentDataSourceStatusListDriver implements IStatusListDriver {
|
|
|
251
276
|
return this._statusListLength!
|
|
252
277
|
}
|
|
253
278
|
|
|
254
|
-
async getStatusList(args?: { correlationId?: string }): Promise<
|
|
279
|
+
async getStatusList(args?: { correlationId?: string }): Promise<StatusListResult> {
|
|
255
280
|
const id = this.options.id
|
|
256
281
|
const correlationId = args?.correlationId ?? this.options.correlationId
|
|
257
282
|
return await this.statusListStore
|
|
@@ -259,6 +284,17 @@ export class AgentDataSourceStatusListDriver implements IStatusListDriver {
|
|
|
259
284
|
.then((statusListEntity: IStatusListEntity) => statusListCredentialToDetails({ statusListCredential: statusListEntity.statusListCredential! }))
|
|
260
285
|
}
|
|
261
286
|
|
|
287
|
+
async getStatusLists(): Promise<Array<StatusListResult>> {
|
|
288
|
+
const statusLists = await this.statusListStore.getStatusLists({})
|
|
289
|
+
return Promise.all(
|
|
290
|
+
statusLists.map(async (statusListEntity) => {
|
|
291
|
+
return statusListCredentialToDetails({
|
|
292
|
+
statusListCredential: statusListEntity.statusListCredential!,
|
|
293
|
+
})
|
|
294
|
+
}),
|
|
295
|
+
)
|
|
296
|
+
}
|
|
297
|
+
|
|
262
298
|
isStatusListIndexInUse(): Promise<boolean> {
|
|
263
299
|
return Promise.resolve(false)
|
|
264
300
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { StatusListType } from '@sphereon/ssi-types'
|
|
2
|
+
import { OAuthStatusListEntity, StatusList2021Entity } from '@sphereon/ssi-sdk.data-store/dist/entities/statusList/StatusListEntities'
|
|
3
|
+
import { StatusListResult } from '@sphereon/ssi-sdk.vc-status-list'
|
|
4
|
+
|
|
5
|
+
export function statusListResultToEntity(result: StatusListResult): StatusList2021Entity | OAuthStatusListEntity {
|
|
6
|
+
const baseFields = {
|
|
7
|
+
id: result.id,
|
|
8
|
+
correlationId: result.correlationId,
|
|
9
|
+
driverType: result.driverType,
|
|
10
|
+
credentialIdMode: result.credentialIdMode,
|
|
11
|
+
length: result.length,
|
|
12
|
+
issuer: result.issuer,
|
|
13
|
+
type: result.type,
|
|
14
|
+
proofFormat: result.proofFormat,
|
|
15
|
+
statusListCredential: result.statusListCredential,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (result.type === StatusListType.StatusList2021) {
|
|
19
|
+
if (!result.statusList2021) {
|
|
20
|
+
throw new Error('Missing statusList2021 details')
|
|
21
|
+
}
|
|
22
|
+
return Object.assign(new StatusList2021Entity(), {
|
|
23
|
+
...baseFields,
|
|
24
|
+
indexingDirection: result.statusList2021.indexingDirection,
|
|
25
|
+
statusPurpose: result.statusList2021.statusPurpose,
|
|
26
|
+
})
|
|
27
|
+
} else if (result.type === StatusListType.OAuthStatusList) {
|
|
28
|
+
if (!result.oauthStatusList) {
|
|
29
|
+
throw new Error('Missing oauthStatusList details')
|
|
30
|
+
}
|
|
31
|
+
return Object.assign(new OAuthStatusListEntity(), {
|
|
32
|
+
...baseFields,
|
|
33
|
+
bitsPerStatus: result.oauthStatusList.bitsPerStatus,
|
|
34
|
+
expiresAt: result.oauthStatusList.expiresAt,
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
throw new Error(`Unsupported status list type: ${result.type}`)
|
|
38
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -6,8 +6,13 @@ import {
|
|
|
6
6
|
IStatusListEntryEntity,
|
|
7
7
|
StatusListStore,
|
|
8
8
|
} from '@sphereon/ssi-sdk.data-store'
|
|
9
|
-
import {
|
|
10
|
-
|
|
9
|
+
import {
|
|
10
|
+
IStatusListPlugin,
|
|
11
|
+
StatusList2021EntryCredentialStatus,
|
|
12
|
+
StatusListOAuthEntryCredentialStatus,
|
|
13
|
+
StatusListResult,
|
|
14
|
+
} from '@sphereon/ssi-sdk.vc-status-list'
|
|
15
|
+
import { StatusListCredential, StatusListDriverType } from '@sphereon/ssi-types'
|
|
11
16
|
import {
|
|
12
17
|
IAgentContext,
|
|
13
18
|
ICredentialIssuer,
|
|
@@ -40,12 +45,14 @@ export interface IStatusListDriver {
|
|
|
40
45
|
|
|
41
46
|
getStatusListLength(args?: { correlationId?: string }): Promise<number>
|
|
42
47
|
|
|
43
|
-
createStatusList(args: { statusListCredential:
|
|
48
|
+
createStatusList(args: { statusListCredential: StatusListCredential; correlationId?: string }): Promise<StatusListResult>
|
|
49
|
+
|
|
50
|
+
getStatusList(args?: { correlationId?: string }): Promise<StatusListResult>
|
|
44
51
|
|
|
45
|
-
|
|
52
|
+
getStatusLists(): Promise<Array<StatusListResult>>
|
|
46
53
|
|
|
47
54
|
updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<{
|
|
48
|
-
credentialStatus: StatusList2021EntryCredentialStatus
|
|
55
|
+
credentialStatus: StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus
|
|
49
56
|
statusListEntry: IStatusListEntryEntity
|
|
50
57
|
}>
|
|
51
58
|
|
|
@@ -53,7 +60,7 @@ export interface IStatusListDriver {
|
|
|
53
60
|
|
|
54
61
|
getStatusListEntryByIndex(args: IGetStatusListEntryByIndexArgs): Promise<IStatusListEntryEntity | undefined>
|
|
55
62
|
|
|
56
|
-
updateStatusList(args: { statusListCredential:
|
|
63
|
+
updateStatusList(args: { statusListCredential: StatusListCredential }): Promise<StatusListResult>
|
|
57
64
|
|
|
58
65
|
deleteStatusList(): Promise<boolean>
|
|
59
66
|
|