@sphereon/ssi-sdk.vc-status-list-issuer-rest-api 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/api-functions.d.ts +2 -1
- package/dist/api-functions.d.ts.map +1 -1
- package/dist/api-functions.js +221 -118
- package/dist/api-functions.js.map +1 -1
- package/dist/index.js +3 -19
- package/dist/index.js.map +1 -1
- package/dist/statuslist-management-api-server.d.ts.map +1 -1
- package/dist/statuslist-management-api-server.js +22 -25
- package/dist/statuslist-management-api-server.js.map +1 -1
- package/dist/types.d.ts +15 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +10 -2
- package/dist/types.js.map +1 -1
- package/package.json +17 -16
- package/src/api-functions.ts +217 -71
- package/src/statuslist-management-api-server.ts +4 -2
- package/src/types.ts +18 -1
package/dist/api-functions.d.ts
CHANGED
|
@@ -3,5 +3,6 @@ import { ICredentialStatusListEndpointOpts, IRequiredContext, IW3CredentialStatu
|
|
|
3
3
|
export declare function createNewStatusListEndpoint(router: Router, context: IRequiredContext, opts: ICredentialStatusListEndpointOpts): void;
|
|
4
4
|
export declare function getStatusListCredentialEndpoint(router: Router, context: IRequiredContext, opts: ICredentialStatusListEndpointOpts): void;
|
|
5
5
|
export declare function getStatusListCredentialIndexStatusEndpoint(router: Router, context: IRequiredContext, opts: ICredentialStatusListEndpointOpts): void;
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function getStatusListCredentialIndexStatusEndpointLegacy(router: Router, context: IRequiredContext, opts: ICredentialStatusListEndpointOpts): void;
|
|
7
|
+
export declare function updateStatusEndpoint(router: Router, context: IRequiredContext, opts: IW3CredentialStatusEndpointOpts): void;
|
|
7
8
|
//# sourceMappingURL=api-functions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-functions.d.ts","sourceRoot":"","sources":["../src/api-functions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api-functions.d.ts","sourceRoot":"","sources":["../src/api-functions.ts"],"names":[],"mappings":"AASA,OAAO,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAA;AACnD,OAAO,EAEL,iCAAiC,EACjC,gBAAgB,EAChB,+BAA+B,EAIhC,MAAM,SAAS,CAAA;AAmChB,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,iCAAiC,QAoB7H;AAED,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,iCAAiC,QAsBjI;AAED,wBAAgB,0CAA0C,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,iCAAiC,QA4E5I;AAED,wBAAgB,gDAAgD,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,iCAAiC,QA0DlJ;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,+BAA+B,QAgGpH"}
|
package/dist/api-functions.js
CHANGED
|
@@ -1,88 +1,155 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
import { checkAuth, sendErrorResponse } from '@sphereon/ssi-express-support';
|
|
2
|
+
import { checkStatusIndexFromStatusListCredential, updateStatusIndexFromStatusListCredential, } from '@sphereon/ssi-sdk.vc-status-list';
|
|
3
|
+
import { getDriver } from '@sphereon/ssi-sdk.vc-status-list-issuer-drivers';
|
|
4
|
+
import Debug from 'debug';
|
|
5
|
+
import { EntryIdType, StatusListIdType, } from './types';
|
|
6
|
+
import { StatusListType } from '@sphereon/ssi-types';
|
|
7
|
+
const debug = Debug('sphereon:ssi-sdk:status-list');
|
|
8
|
+
function sendStatuslistResponse(details, statuslistPayload, response) {
|
|
9
|
+
let payload;
|
|
10
|
+
switch (details.proofFormat) {
|
|
11
|
+
case 'jwt':
|
|
12
|
+
case 'cbor':
|
|
13
|
+
payload = Buffer.from(statuslistPayload, 'ascii');
|
|
14
|
+
break;
|
|
15
|
+
default:
|
|
16
|
+
payload = statuslistPayload;
|
|
17
|
+
}
|
|
18
|
+
return response.status(200).setHeader('Content-Type', details.statuslistContentType).send(payload);
|
|
19
|
+
}
|
|
20
|
+
function buildStatusListId(request) {
|
|
21
|
+
const protocol = request.headers['x-forwarded-proto']?.toString() ?? request.protocol;
|
|
22
|
+
let host = request.headers['x-forwarded-host']?.toString() ?? request.get('host');
|
|
23
|
+
const forwardedPort = request.headers['x-forwarded-port']?.toString();
|
|
24
|
+
if (forwardedPort && !(protocol === 'https' && forwardedPort === '443') && !(protocol === 'http' && forwardedPort === '80')) {
|
|
25
|
+
host += `:${forwardedPort}`;
|
|
26
|
+
}
|
|
27
|
+
const forwardedPrefix = request.headers['x-forwarded-prefix']?.toString() ?? '';
|
|
28
|
+
return `${protocol}://${host}${forwardedPrefix}${request.originalUrl.split('?')[0].replace(/\/status\/index\/.*/, '')}`;
|
|
29
|
+
}
|
|
30
|
+
export function createNewStatusListEndpoint(router, context, opts) {
|
|
31
|
+
if (opts?.enabled === false) {
|
|
27
32
|
console.log(`Create new status list endpoint is disabled`);
|
|
28
33
|
return;
|
|
29
34
|
}
|
|
30
|
-
const path =
|
|
31
|
-
router.post(path,
|
|
35
|
+
const path = opts?.path ?? '/status-lists';
|
|
36
|
+
router.post(path, checkAuth(opts?.endpoint), async (request, response) => {
|
|
32
37
|
try {
|
|
33
38
|
const statusListArgs = request.body.statusList;
|
|
34
39
|
if (!statusListArgs) {
|
|
35
|
-
return
|
|
40
|
+
return sendErrorResponse(response, 400, 'No statusList details supplied');
|
|
36
41
|
}
|
|
37
|
-
const
|
|
38
|
-
|
|
42
|
+
const details = await context.agent.slCreateStatusList(statusListArgs);
|
|
43
|
+
const statuslistPayload = details.statusListCredential;
|
|
44
|
+
return sendStatuslistResponse(details, statuslistPayload, response);
|
|
39
45
|
}
|
|
40
46
|
catch (e) {
|
|
41
|
-
return
|
|
47
|
+
return sendErrorResponse(response, 500, e.message, e);
|
|
42
48
|
}
|
|
43
|
-
})
|
|
49
|
+
});
|
|
44
50
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const protocol = (_b = (_a = request.headers['x-forwarded-proto']) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : request.protocol;
|
|
48
|
-
let host = (_d = (_c = request.headers['x-forwarded-host']) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : request.get('host');
|
|
49
|
-
const forwardedPort = (_e = request.headers['x-forwarded-port']) === null || _e === void 0 ? void 0 : _e.toString();
|
|
50
|
-
if (forwardedPort && !(protocol === 'https' && forwardedPort === '443') && !(protocol === 'http' && forwardedPort === '80')) {
|
|
51
|
-
host += `:${forwardedPort}`;
|
|
52
|
-
}
|
|
53
|
-
return `${protocol}://${host}${request.originalUrl}`;
|
|
54
|
-
};
|
|
55
|
-
function getStatusListCredentialEndpoint(router, context, opts) {
|
|
56
|
-
var _a;
|
|
57
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
51
|
+
export function getStatusListCredentialEndpoint(router, context, opts) {
|
|
52
|
+
if (opts?.enabled === false) {
|
|
58
53
|
console.log(`Get statusList credential endpoint is disabled`);
|
|
59
54
|
return;
|
|
60
55
|
}
|
|
61
|
-
const path =
|
|
62
|
-
router.get(path,
|
|
63
|
-
var _a, _b, _c, _d;
|
|
56
|
+
const path = opts?.path ?? '/status-lists/:index';
|
|
57
|
+
router.get(path, checkAuth(opts?.endpoint), async (request, response) => {
|
|
64
58
|
try {
|
|
65
59
|
//todo: Check index against correlationId first. Then match originalUrl against statusList id
|
|
66
|
-
const correlationId =
|
|
67
|
-
const
|
|
68
|
-
const
|
|
60
|
+
//const correlationId = request.query.correlationId?.toString() ?? request.params.index?.toString() ?? request.originalUrl TODO I so not get these
|
|
61
|
+
const correlationId = request.query.correlationId?.toString();
|
|
62
|
+
const driver = await getDriver({
|
|
63
|
+
...(correlationId ? { correlationId } : { id: buildStatusListId(request) }),
|
|
64
|
+
dbName: opts.dbName,
|
|
65
|
+
});
|
|
66
|
+
const details = await driver.getStatusList();
|
|
67
|
+
const statuslistPayload = details.statusListCredential;
|
|
68
|
+
return sendStatuslistResponse(details, statuslistPayload, response);
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
return sendErrorResponse(response, 500, e.message, e);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export function getStatusListCredentialIndexStatusEndpoint(router, context, opts) {
|
|
76
|
+
if (opts?.enabled === false) {
|
|
77
|
+
console.log(`Get statusList credential index status endpoint is disabled`);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const path = opts?.path ?? '/status-lists/:statusListId/status/entry-by-id/:entryId';
|
|
81
|
+
router.get(path, checkAuth(opts?.endpoint), async (request, response) => {
|
|
82
|
+
try {
|
|
83
|
+
const statusListIdType = request.query.statusListIdType ?? StatusListIdType.StatusListId;
|
|
84
|
+
const entryIdType = request.query.entryIdType ?? EntryIdType.StatusListIndex;
|
|
85
|
+
let statusListIndex;
|
|
86
|
+
let entityCorrelationId;
|
|
87
|
+
let statusListId;
|
|
88
|
+
let statusListCorrelationId;
|
|
89
|
+
if (entryIdType === EntryIdType.StatusListIndex) {
|
|
90
|
+
try {
|
|
91
|
+
statusListIndex = Number.parseInt(request.params.entryId);
|
|
92
|
+
if (!statusListIndex || statusListIndex < 0) {
|
|
93
|
+
return sendErrorResponse(response, 400, `Please provide a proper statusListIndex`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
return sendErrorResponse(response, 400, `Please provide a proper statusListIndex`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
entityCorrelationId = request.params.entryId;
|
|
102
|
+
}
|
|
103
|
+
if (statusListIdType === StatusListIdType.StatusListId) {
|
|
104
|
+
statusListId = request.params.statusListId;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
statusListCorrelationId = request.params.statusListId;
|
|
108
|
+
}
|
|
109
|
+
const driver = await getDriver({
|
|
110
|
+
...(statusListCorrelationId ? { correlationId: statusListCorrelationId } : { id: statusListId }),
|
|
111
|
+
dbName: opts.dbName,
|
|
112
|
+
});
|
|
113
|
+
const details = await driver.getStatusList();
|
|
114
|
+
if (statusListIndex && statusListIndex > details.length) {
|
|
115
|
+
return sendErrorResponse(response, 400, `Please provide a proper statusListIndex`);
|
|
116
|
+
}
|
|
117
|
+
let entry = await driver.getStatusListEntryByIndex({
|
|
118
|
+
statusListId: details.id,
|
|
119
|
+
...(entityCorrelationId ? { correlationId: entityCorrelationId } : { statusListIndex }),
|
|
120
|
+
errorOnNotFound: false,
|
|
121
|
+
});
|
|
122
|
+
const type = details.type === StatusListType.StatusList2021 ? 'StatusList2021Entry' : details.type;
|
|
123
|
+
const resultStatusIndex = entry?.statusListIndex ?? statusListIndex ?? 0;
|
|
124
|
+
const status = await checkStatusIndexFromStatusListCredential({
|
|
125
|
+
statusListCredential: details.statusListCredential,
|
|
126
|
+
...(details.type === StatusListType.StatusList2021 ? { statusPurpose: details.statusList2021?.statusPurpose } : {}),
|
|
127
|
+
type,
|
|
128
|
+
id: details.id,
|
|
129
|
+
statusListIndex: resultStatusIndex,
|
|
130
|
+
});
|
|
131
|
+
if (!entry) {
|
|
132
|
+
entry = {
|
|
133
|
+
statusListId: details.id,
|
|
134
|
+
value: '0',
|
|
135
|
+
statusListIndex: resultStatusIndex,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
69
138
|
response.statusCode = 200;
|
|
70
|
-
return response.
|
|
139
|
+
return response.json({ ...entry, status });
|
|
71
140
|
}
|
|
72
141
|
catch (e) {
|
|
73
|
-
return
|
|
142
|
+
return sendErrorResponse(response, 500, e.message, e);
|
|
74
143
|
}
|
|
75
|
-
})
|
|
144
|
+
});
|
|
76
145
|
}
|
|
77
|
-
function
|
|
78
|
-
|
|
79
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
146
|
+
export function getStatusListCredentialIndexStatusEndpointLegacy(router, context, opts) {
|
|
147
|
+
if (opts?.enabled === false) {
|
|
80
148
|
console.log(`Get statusList credential index status endpoint is disabled`);
|
|
81
149
|
return;
|
|
82
150
|
}
|
|
83
|
-
const path =
|
|
84
|
-
router.get(path,
|
|
85
|
-
var _a, _b, _c, _d;
|
|
151
|
+
const path = opts?.path ?? '/status-lists/:index/status/index/:statusListIndex';
|
|
152
|
+
router.get(path, checkAuth(opts?.endpoint), async (request, response) => {
|
|
86
153
|
try {
|
|
87
154
|
//todo: Check index against correlationId first. Then match originalUrl against statusList id
|
|
88
155
|
const statusListIndexStr = request.params.statusListIndex;
|
|
@@ -91,104 +158,140 @@ function getStatusListCredentialIndexStatusEndpoint(router, context, opts) {
|
|
|
91
158
|
statusListIndex = Number.parseInt(statusListIndexStr);
|
|
92
159
|
}
|
|
93
160
|
catch (error) {
|
|
94
|
-
return
|
|
161
|
+
return sendErrorResponse(response, 400, `Please provide a proper statusListIndex`);
|
|
95
162
|
}
|
|
96
163
|
if (!statusListIndex || statusListIndex < 0) {
|
|
97
|
-
return
|
|
164
|
+
return sendErrorResponse(response, 400, `Please provide a proper statusListIndex`);
|
|
98
165
|
}
|
|
99
|
-
const correlationId =
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
correlationId,
|
|
166
|
+
//const correlationId = request.query.correlationId?.toString() ?? request.params.index?.toString() ?? request.originalUrl TODO I so not get these
|
|
167
|
+
const statusListCorrelationId = request.query.correlationId?.toString();
|
|
168
|
+
const driver = await getDriver({
|
|
169
|
+
...(statusListCorrelationId ? { correlationId: statusListCorrelationId } : { id: buildStatusListId(request) }),
|
|
103
170
|
dbName: opts.dbName,
|
|
104
171
|
});
|
|
105
|
-
const details =
|
|
172
|
+
const details = await driver.getStatusList();
|
|
106
173
|
if (statusListIndex > details.length) {
|
|
107
|
-
return
|
|
174
|
+
return sendErrorResponse(response, 400, `Please provide a proper statusListIndex`);
|
|
108
175
|
}
|
|
109
|
-
|
|
110
|
-
|
|
176
|
+
const entityCorrelationId = request.query.entityCorrelationId?.toString();
|
|
177
|
+
let entry = await driver.getStatusListEntryByIndex({
|
|
111
178
|
statusListId: details.id,
|
|
112
|
-
correlationId:
|
|
179
|
+
...(entityCorrelationId ? { correlationId: entityCorrelationId } : { statusListIndex: statusListIndex }),
|
|
113
180
|
errorOnNotFound: false,
|
|
114
181
|
});
|
|
115
|
-
const
|
|
182
|
+
const type = details.type === StatusListType.StatusList2021 ? 'StatusList2021Entry' : details.type;
|
|
183
|
+
const status = await checkStatusIndexFromStatusListCredential({
|
|
184
|
+
statusListCredential: details.statusListCredential,
|
|
185
|
+
...(details.type === StatusListType.StatusList2021 ? { statusPurpose: details.statusList2021?.statusPurpose } : {}),
|
|
186
|
+
type,
|
|
187
|
+
id: details.id,
|
|
188
|
+
statusListIndex,
|
|
189
|
+
});
|
|
116
190
|
if (!entry) {
|
|
117
191
|
// The fact we have nothing on it means the status is okay
|
|
118
192
|
entry = {
|
|
119
|
-
|
|
193
|
+
statusListId: details.id,
|
|
120
194
|
value: '0',
|
|
121
195
|
statusListIndex,
|
|
122
196
|
};
|
|
123
197
|
}
|
|
124
198
|
response.statusCode = 200;
|
|
125
|
-
return response.
|
|
199
|
+
return response.json({ ...entry, status });
|
|
126
200
|
}
|
|
127
201
|
catch (e) {
|
|
128
|
-
return
|
|
202
|
+
return sendErrorResponse(response, 500, e.message, e);
|
|
129
203
|
}
|
|
130
|
-
})
|
|
204
|
+
});
|
|
131
205
|
}
|
|
132
|
-
function
|
|
133
|
-
|
|
134
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
206
|
+
export function updateStatusEndpoint(router, context, opts) {
|
|
207
|
+
if (opts?.enabled === false) {
|
|
135
208
|
console.log(`Update credential status endpoint is disabled`);
|
|
136
209
|
return;
|
|
137
210
|
}
|
|
138
|
-
router.post(
|
|
139
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
211
|
+
router.post(opts?.path ?? '/credentials/status', checkAuth(opts?.endpoint), async (request, response) => {
|
|
140
212
|
try {
|
|
141
213
|
debug(JSON.stringify(request.body, null, 2));
|
|
142
214
|
const updateRequest = request.body;
|
|
143
|
-
const statusListId =
|
|
144
|
-
const statusListCorrelationId =
|
|
145
|
-
const entryCorrelationId =
|
|
146
|
-
const credentialId = updateRequest.credentialId;
|
|
215
|
+
const statusListId = updateRequest.statusListId ?? request.query.statusListId?.toString() ?? opts.statusListId; // TODO why query params when we have a JSON body ??
|
|
216
|
+
const statusListCorrelationId = updateRequest.statusListCorrelationId ?? request.query.statusListrelationId?.toString() ?? opts.correlationId;
|
|
217
|
+
const entryCorrelationId = updateRequest.entryCorrelationId ?? request.query.entryCorrelationId?.toString();
|
|
147
218
|
// TODO: Move mostly to driver
|
|
148
|
-
if (!
|
|
149
|
-
return
|
|
219
|
+
if (!statusListId && !statusListCorrelationId) {
|
|
220
|
+
return sendErrorResponse(response, 400, 'No statusList id or correlation Id provided or deduced for the API or in the request');
|
|
150
221
|
}
|
|
151
222
|
else if (!updateRequest.credentialStatus || updateRequest.credentialStatus.length === 0) {
|
|
152
|
-
return
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
const driver = yield (0, ssi_sdk_vc_status_list_issuer_drivers_1.getDriver)({ id: statusListId, correlationId: statusListCorrelationId, dbName: opts.dbName });
|
|
158
|
-
// unfortunately the W3C API works by credentialId. Which means you will have to map listIndices during issuance
|
|
159
|
-
const statusListEntry = yield driver.getStatusListEntryByCredentialId({
|
|
160
|
-
statusListId,
|
|
161
|
-
statusListCorrelationId,
|
|
162
|
-
entryCorrelationId,
|
|
163
|
-
credentialId,
|
|
164
|
-
errorOnNotFound: true,
|
|
223
|
+
return sendErrorResponse(response, 400, 'No statusList updates supplied');
|
|
224
|
+
}
|
|
225
|
+
const driver = await getDriver({
|
|
226
|
+
...(statusListCorrelationId ? { correlationId: statusListCorrelationId } : { id: buildStatusListId(request) }),
|
|
227
|
+
dbName: opts.dbName,
|
|
165
228
|
});
|
|
229
|
+
let statusListResult = await driver.getStatusList();
|
|
230
|
+
// Get status list entry based on request type
|
|
231
|
+
let statusListEntry;
|
|
232
|
+
if ('credentialId' in updateRequest) {
|
|
233
|
+
if (!updateRequest.credentialId) {
|
|
234
|
+
return sendErrorResponse(response, 400, 'No credentialId supplied');
|
|
235
|
+
}
|
|
236
|
+
// unfortunately the W3C API works by credentialId. Which means you will have to map listIndices during issuance
|
|
237
|
+
statusListEntry = await driver.getStatusListEntryByCredentialId({
|
|
238
|
+
statusListId,
|
|
239
|
+
statusListCorrelationId,
|
|
240
|
+
entryCorrelationId,
|
|
241
|
+
credentialId: updateRequest.credentialId,
|
|
242
|
+
errorOnNotFound: true,
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
statusListEntry = await driver.getStatusListEntryByIndex({
|
|
247
|
+
...(statusListResult.id && { statusListId: statusListResult.id }),
|
|
248
|
+
...(statusListResult.correlationId && { statusListCorrelationId: statusListResult.correlationId }),
|
|
249
|
+
...(entryCorrelationId ? { entryCorrelationId } : { statusListIndex: updateRequest.statusListIndex }),
|
|
250
|
+
errorOnNotFound: true,
|
|
251
|
+
});
|
|
252
|
+
}
|
|
166
253
|
if (!statusListEntry) {
|
|
167
|
-
|
|
254
|
+
const identifier = 'credentialId' in updateRequest ? updateRequest.credentialId : `index ${updateRequest.statusListIndex}`;
|
|
255
|
+
return sendErrorResponse(response, 404, `Status list entry for ${identifier} not found for ${statusListId}`);
|
|
168
256
|
}
|
|
169
|
-
|
|
170
|
-
let details = yield driver.getStatusList();
|
|
171
|
-
let statusListCredential = details.statusListCredential;
|
|
257
|
+
let statusListCredential = statusListResult.statusListCredential;
|
|
172
258
|
for (const updateItem of updateRequest.credentialStatus) {
|
|
173
|
-
if (updateItem.type && updateItem.type !== 'StatusList2021') {
|
|
174
|
-
return (0, ssi_express_support_1.sendErrorResponse)(response, 400, `Only the optional type 'StatusList2021' is currently supported`);
|
|
175
|
-
}
|
|
176
259
|
if (!updateItem.status) {
|
|
177
|
-
return
|
|
260
|
+
return sendErrorResponse(response, 400, `Required 'status' value was missing in the credentialStatus array`);
|
|
261
|
+
}
|
|
262
|
+
let value = '1';
|
|
263
|
+
if (updateItem.status === '0' || updateItem.status.toLowerCase() === 'false') {
|
|
264
|
+
value = '0';
|
|
265
|
+
}
|
|
266
|
+
else if (updateItem.status !== '1' && updateItem.status.toLowerCase() !== 'true') {
|
|
267
|
+
if (updateItem.type === StatusListType.StatusList2021) {
|
|
268
|
+
// 2021 only allows 0 and 1
|
|
269
|
+
return sendErrorResponse(response, 400, `Invalid 'status' value in the credentialStatus array: ${updateItem.status}`);
|
|
270
|
+
}
|
|
271
|
+
else if (parseInt(updateItem.status) < 0 || parseInt(updateItem.status) > 255) {
|
|
272
|
+
return sendErrorResponse(response, 400, `Invalid 'status' value in the credentialStatus array: ${updateItem.status}`);
|
|
273
|
+
}
|
|
274
|
+
value = `${parseInt(updateItem.status)}`;
|
|
178
275
|
}
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
276
|
+
const updStatusListId = statusListId ?? statusListEntry.statusList?.id; // When input was statusListCorrelationId the statusList id should come from statusListEntry
|
|
277
|
+
if (!updStatusListId) {
|
|
278
|
+
return sendErrorResponse(response, 400, 'statuslist id could not be determined');
|
|
279
|
+
}
|
|
280
|
+
await driver.updateStatusListEntry({ ...statusListEntry, statusListId: updStatusListId, value });
|
|
182
281
|
// todo: optimize. We are now creating a new VC for every item passed in. Probably wise to look at DB as well
|
|
183
|
-
|
|
184
|
-
|
|
282
|
+
statusListResult = await updateStatusIndexFromStatusListCredential({
|
|
283
|
+
statusListCredential: statusListCredential,
|
|
284
|
+
statusListIndex: statusListEntry.statusListIndex,
|
|
285
|
+
value: parseInt(value),
|
|
286
|
+
keyRef: opts.keyRef,
|
|
287
|
+
}, context);
|
|
288
|
+
statusListResult = await driver.updateStatusList({ statusListCredential: statusListResult.statusListCredential });
|
|
185
289
|
}
|
|
186
|
-
|
|
187
|
-
return response.send(details.statusListCredential);
|
|
290
|
+
return sendStatuslistResponse(statusListResult, statusListResult.statusListCredential, response);
|
|
188
291
|
}
|
|
189
292
|
catch (e) {
|
|
190
|
-
return
|
|
293
|
+
return sendErrorResponse(response, 500, e.message, e);
|
|
191
294
|
}
|
|
192
|
-
})
|
|
295
|
+
});
|
|
193
296
|
}
|
|
194
297
|
//# sourceMappingURL=api-functions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-functions.js","sourceRoot":"","sources":["../src/api-functions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAaA,kEAmBC;AAcD,0EAkBC;AAED,gGAmDC;AACD,0DAqEC;AA3LD,uEAA4E;AAC5E,6EAIyC;AACzC,2GAA2E;AAC3E,kDAAyB;AAIzB,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,8BAA8B,CAAC,CAAA;AAEnD,SAAgB,2BAA2B,CAAC,MAAc,EAAE,OAAyB,EAAE,IAAuC;;IAC5H,IAAI,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,MAAK,KAAK,EAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAA;QAC1D,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use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === 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
|
-
|
|
22
|
-
|
|
4
|
+
export * from './statuslist-management-api-server';
|
|
5
|
+
export * from './types';
|
|
6
|
+
export * from './api-functions';
|
|
23
7
|
//# 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,oCAAoC,CAAA;AAClD,cAAc,SAAS,CAAA;AACvB,cAAc,iBAAiB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statuslist-management-api-server.d.ts","sourceRoot":"","sources":["../src/statuslist-management-api-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAExF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAO,OAAO,EAAE,EAAE,OAAO,EAAU,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"statuslist-management-api-server.d.ts","sourceRoot":"","sources":["../src/statuslist-management-api-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAExF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAO,OAAO,EAAE,EAAE,OAAO,EAAU,MAAM,SAAS,CAAA;AAQlD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iDAAiD,CAAA;AAElF,qBAAa,6BAA6B;IACxC,IAAI,MAAM,IAAI,OAAO,CAAC,MAAM,CAE3B;IAED,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;IACjD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;gBAEpB,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC,gBAAgB,GAAG,iBAAiB,CAAC,CAAC;QAAC,cAAc,EAAE,cAAc,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE;IAiChI,IAAI,KAAK,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAEpC;IAED,IAAI,IAAI,IAAI,eAAe,GAAG,SAAS,CAEtC;IAED,IAAI,OAAO,IAAI,OAAO,CAErB;CACF"}
|
|
@@ -1,44 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
exports.StatuslistManagementApiServer = void 0;
|
|
7
|
-
const ssi_express_support_1 = require("@sphereon/ssi-express-support");
|
|
8
|
-
const ssi_sdk_core_1 = require("@sphereon/ssi-sdk.core");
|
|
9
|
-
const express_1 = __importDefault(require("express"));
|
|
10
|
-
const api_functions_1 = require("./api-functions");
|
|
11
|
-
class StatuslistManagementApiServer {
|
|
1
|
+
import { copyGlobalAuthToEndpoint } from '@sphereon/ssi-express-support';
|
|
2
|
+
import { agentContext } from '@sphereon/ssi-sdk.core';
|
|
3
|
+
import express from 'express';
|
|
4
|
+
import { createNewStatusListEndpoint, getStatusListCredentialEndpoint, getStatusListCredentialIndexStatusEndpoint, getStatusListCredentialIndexStatusEndpointLegacy, updateStatusEndpoint, } from './api-functions';
|
|
5
|
+
export class StatuslistManagementApiServer {
|
|
12
6
|
get router() {
|
|
13
7
|
return this._router;
|
|
14
8
|
}
|
|
9
|
+
_express;
|
|
10
|
+
_agent;
|
|
11
|
+
_opts;
|
|
12
|
+
_router;
|
|
15
13
|
constructor(args) {
|
|
16
|
-
var _a, _b, _c, _d;
|
|
17
14
|
const { agent, opts } = args;
|
|
18
15
|
this._agent = agent;
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
if (opts?.endpointOpts?.globalAuth) {
|
|
17
|
+
copyGlobalAuthToEndpoint({ opts, key: 'vcApiCredentialStatus' });
|
|
18
|
+
copyGlobalAuthToEndpoint({ opts, key: 'createStatusList' });
|
|
19
|
+
copyGlobalAuthToEndpoint({ opts, key: 'getStatusList' });
|
|
23
20
|
}
|
|
24
21
|
this._opts = opts;
|
|
25
22
|
this._express = args.expressSupport.express;
|
|
26
|
-
this._router =
|
|
27
|
-
const context =
|
|
28
|
-
const features =
|
|
23
|
+
this._router = express.Router();
|
|
24
|
+
const context = agentContext(agent);
|
|
25
|
+
const features = opts?.enableFeatures ?? ['status-list-management', 'status-list-hosting', 'w3c-vc-api-credential-status'];
|
|
29
26
|
console.log(`Status List API enabled, with features: ${JSON.stringify(features)}`);
|
|
30
27
|
// Credential Status (List) endpoints
|
|
31
28
|
if (features.includes('status-list-management')) {
|
|
32
|
-
|
|
29
|
+
createNewStatusListEndpoint(this.router, context, opts.endpointOpts.createStatusList);
|
|
33
30
|
}
|
|
34
31
|
if (features.includes('status-list-hosting')) {
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
getStatusListCredentialEndpoint(this.router, context, opts.endpointOpts.getStatusList);
|
|
33
|
+
getStatusListCredentialIndexStatusEndpoint(this.router, context, opts.endpointOpts.getStatusList);
|
|
34
|
+
getStatusListCredentialIndexStatusEndpointLegacy(this.router, context, opts.endpointOpts.getStatusList);
|
|
37
35
|
}
|
|
38
36
|
if (features.includes('w3c-vc-api-credential-status')) {
|
|
39
|
-
(
|
|
37
|
+
updateStatusEndpoint(this.router, context, opts.endpointOpts.vcApiCredentialStatus);
|
|
40
38
|
}
|
|
41
|
-
this._express.use(
|
|
39
|
+
this._express.use(opts?.endpointOpts?.basePath ?? '', this.router);
|
|
42
40
|
}
|
|
43
41
|
get agent() {
|
|
44
42
|
return this._agent;
|
|
@@ -50,7 +48,6 @@ class StatuslistManagementApiServer {
|
|
|
50
48
|
return this._express;
|
|
51
49
|
}
|
|
52
50
|
}
|
|
53
|
-
exports.StatuslistManagementApiServer = StatuslistManagementApiServer;
|
|
54
51
|
/*
|
|
55
52
|
function copyGlobalAuthToEndpoint(opts: IStatusListOpts, key: string) {
|
|
56
53
|
if (opts?.endpointOpts?.globalAuth) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statuslist-management-api-server.js","sourceRoot":"","sources":["../src/statuslist-management-api-server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"statuslist-management-api-server.js","sourceRoot":"","sources":["../src/statuslist-management-api-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAkB,MAAM,+BAA+B,CAAA;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAIrD,OAAO,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AAC;YAChD,2BAA2B,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAA;QACvF,CAAC;QACD,IAAI,QAAQ,CAAC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,CAAC;YAC7C,+BAA+B,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAA;YACtF,0CAA0C,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAA;YACjG,gDAAgD,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAA;QACzG,CAAC;QACD,IAAI,QAAQ,CAAC,QAAQ,CAAC,8BAA8B,CAAC,EAAE,CAAC;YACtD,oBAAoB,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAA;QACrF,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,EAAE,QAAQ,IAAI,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IACpE,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;CACF;AAED;;;;;;;;;;;;EAYE"}
|
package/dist/types.d.ts
CHANGED
|
@@ -24,8 +24,13 @@ export interface IW3CredentialStatusEndpointOpts extends ICredentialStatusListEn
|
|
|
24
24
|
correlationId?: string;
|
|
25
25
|
keyRef?: string;
|
|
26
26
|
}
|
|
27
|
-
export interface UpdateCredentialStatusRequest {
|
|
27
|
+
export interface UpdateW3cCredentialStatusRequest extends UpdateCredentialStatusRequest {
|
|
28
28
|
credentialId: string;
|
|
29
|
+
}
|
|
30
|
+
export interface UpdateIndexedCredentialStatusRequest extends UpdateCredentialStatusRequest {
|
|
31
|
+
statusListIndex?: number;
|
|
32
|
+
}
|
|
33
|
+
interface UpdateCredentialStatusRequest {
|
|
29
34
|
credentialStatus: UpdateCredentialStatusItem[];
|
|
30
35
|
statusListId?: string;
|
|
31
36
|
statusListCorrelationId?: string;
|
|
@@ -35,4 +40,13 @@ export interface UpdateCredentialStatusItem {
|
|
|
35
40
|
type?: StatusListType;
|
|
36
41
|
status: string;
|
|
37
42
|
}
|
|
43
|
+
export declare enum StatusListIdType {
|
|
44
|
+
StatusListId = "StatusListId",
|
|
45
|
+
StatusListCorrelationId = "StatusListCorrelationId"
|
|
46
|
+
}
|
|
47
|
+
export declare enum EntryIdType {
|
|
48
|
+
StatusListIndex = "StatusListIndex",
|
|
49
|
+
EntryCorrelationId = "StatusListCorrelationId"
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
38
52
|
//# sourceMappingURL=types.d.ts.map
|
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,eAAe,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iDAAiD,CAAA;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAE5C,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC,gBAAgB,GAAG,iBAAiB,CAAC,CAAA;AAElF,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,uBAAuB,CAAA;IACrC,cAAc,CAAC,EAAE,k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;IACtD,gBAAgB,EAAE,iCAAiC,CAAA;IACnD,aAAa,EAAE,iCAAiC,CAAA;CACjD;AAED,MAAM,MAAM,kBAAkB,GAAG,8BAA8B,GAAG,wBAAwB,GAAG,qBAAqB,CAAA;AAElH,MAAM,WAAW,iCAAkC,SAAQ,mBAAmB;IAC5E,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,+BAAgC,SAAQ,iCAAiC;IACxF,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,gCAAiC,SAAQ,6BAA6B;IACrF,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,oCAAqC,SAAQ,6BAA6B;IACzF,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED,UAAU,6BAA6B;IACrC,gBAAgB,EAAE,0BAA0B,EAAE,CAAA;IAC9C,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,MAAM,WAAW,0BAA0B;IACzC,IAAI,CAAC,EAAE,cAAc,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,oBAAY,gBAAgB;IAC1B,YAAY,iBAAiB;IAC7B,uBAAuB,4BAA4B;CACpD;AAED,oBAAY,WAAW;IACrB,eAAe,oBAAoB;IACnC,kBAAkB,4BAA4B;CAC/C"}
|
package/dist/types.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export var StatusListIdType;
|
|
2
|
+
(function (StatusListIdType) {
|
|
3
|
+
StatusListIdType["StatusListId"] = "StatusListId";
|
|
4
|
+
StatusListIdType["StatusListCorrelationId"] = "StatusListCorrelationId";
|
|
5
|
+
})(StatusListIdType || (StatusListIdType = {}));
|
|
6
|
+
export var EntryIdType;
|
|
7
|
+
(function (EntryIdType) {
|
|
8
|
+
EntryIdType["StatusListIndex"] = "StatusListIndex";
|
|
9
|
+
EntryIdType["EntryCorrelationId"] = "StatusListCorrelationId";
|
|
10
|
+
})(EntryIdType || (EntryIdType = {}));
|
|
3
11
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAqDA,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,iDAA6B,CAAA;IAC7B,uEAAmD,CAAA;AACrD,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B;AAED,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,kDAAmC,CAAA;IACnC,6DAA8C,CAAA;AAChD,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.vc-status-list-issuer-rest-api",
|
|
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",
|
|
@@ -12,30 +12,31 @@
|
|
|
12
12
|
"start:dev2": "node --experimental-specifier-resolution=node --loader ts-node/esm __tests__/agent.ts"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@sphereon/ssi-express-support": "0.
|
|
16
|
-
"@sphereon/ssi-sdk-ext.did-utils": "0.
|
|
17
|
-
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.
|
|
18
|
-
"@sphereon/ssi-sdk.
|
|
19
|
-
"@sphereon/ssi-sdk.
|
|
20
|
-
"@sphereon/ssi-sdk.
|
|
21
|
-
"@sphereon/ssi-sdk.vc-status-list
|
|
22
|
-
"@sphereon/ssi-
|
|
15
|
+
"@sphereon/ssi-express-support": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
16
|
+
"@sphereon/ssi-sdk-ext.did-utils": "0.28.0",
|
|
17
|
+
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.28.0",
|
|
18
|
+
"@sphereon/ssi-sdk-ext.jwt-service": "0.28.0",
|
|
19
|
+
"@sphereon/ssi-sdk.core": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
20
|
+
"@sphereon/ssi-sdk.data-store": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
21
|
+
"@sphereon/ssi-sdk.vc-status-list": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
22
|
+
"@sphereon/ssi-sdk.vc-status-list-issuer-drivers": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
23
|
+
"@sphereon/ssi-types": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
23
24
|
"@sphereon/vc-status-list": "7.0.0-next.0",
|
|
24
25
|
"@veramo/core": "4.2.0",
|
|
25
26
|
"debug": "^4.3.5",
|
|
26
27
|
"express": "^4.19.2",
|
|
27
|
-
"reflect-metadata": "
|
|
28
|
-
"typeorm": "^0.3.
|
|
28
|
+
"reflect-metadata": "0.2.2",
|
|
29
|
+
"typeorm": "^0.3.21",
|
|
29
30
|
"uint8arrays": "^3.1.1",
|
|
30
31
|
"uuid": "^9.0.1"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@sphereon/did-uni-client": "^0.6.3",
|
|
34
|
-
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.
|
|
35
|
-
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.
|
|
36
|
-
"@sphereon/ssi-sdk.agent-config": "0.
|
|
35
|
+
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.28.0",
|
|
36
|
+
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.28.0",
|
|
37
|
+
"@sphereon/ssi-sdk.agent-config": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
37
38
|
"@sphereon/ssi-sdk.data-store": "workspace:*",
|
|
38
|
-
"@sphereon/ssi-sdk.vc-handler-ld-local": "0.
|
|
39
|
+
"@sphereon/ssi-sdk.vc-handler-ld-local": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
39
40
|
"@types/body-parser": "^1.19.5",
|
|
40
41
|
"@types/cookie-parser": "^1.4.7",
|
|
41
42
|
"@types/cors": "^2.8.17",
|
|
@@ -79,5 +80,5 @@
|
|
|
79
80
|
"StatusList2021"
|
|
80
81
|
],
|
|
81
82
|
"nx": {},
|
|
82
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "9f634bdb714061141e277508c124b08d626f6036"
|
|
83
84
|
}
|
package/src/api-functions.ts
CHANGED
|
@@ -2,15 +2,55 @@ import { checkAuth, sendErrorResponse } from '@sphereon/ssi-express-support'
|
|
|
2
2
|
import {
|
|
3
3
|
checkStatusIndexFromStatusListCredential,
|
|
4
4
|
CreateNewStatusListFuncArgs,
|
|
5
|
+
StatusListResult,
|
|
5
6
|
updateStatusIndexFromStatusListCredential,
|
|
6
7
|
} from '@sphereon/ssi-sdk.vc-status-list'
|
|
7
8
|
import { getDriver } from '@sphereon/ssi-sdk.vc-status-list-issuer-drivers'
|
|
8
9
|
import Debug from 'debug'
|
|
9
10
|
import { Request, Response, Router } from 'express'
|
|
10
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
EntryIdType,
|
|
13
|
+
ICredentialStatusListEndpointOpts,
|
|
14
|
+
IRequiredContext,
|
|
15
|
+
IW3CredentialStatusEndpointOpts,
|
|
16
|
+
StatusListIdType,
|
|
17
|
+
UpdateIndexedCredentialStatusRequest,
|
|
18
|
+
UpdateW3cCredentialStatusRequest,
|
|
19
|
+
} from './types'
|
|
20
|
+
import { StatusListCredential, StatusListType } from '@sphereon/ssi-types'
|
|
21
|
+
import { IStatusListEntryEntity } from '@sphereon/ssi-sdk.data-store'
|
|
11
22
|
|
|
12
23
|
const debug = Debug('sphereon:ssi-sdk:status-list')
|
|
13
24
|
|
|
25
|
+
function sendStatuslistResponse(details: StatusListResult, statuslistPayload: StatusListCredential, response: Response) {
|
|
26
|
+
let payload: Buffer | StatusListCredential
|
|
27
|
+
|
|
28
|
+
switch (details.proofFormat) {
|
|
29
|
+
case 'jwt':
|
|
30
|
+
case 'cbor':
|
|
31
|
+
payload = Buffer.from(statuslistPayload as string, 'ascii')
|
|
32
|
+
break
|
|
33
|
+
default:
|
|
34
|
+
payload = statuslistPayload
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return response.status(200).setHeader('Content-Type', details.statuslistContentType).send(payload)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function buildStatusListId(request: Request): string {
|
|
41
|
+
const protocol = request.headers['x-forwarded-proto']?.toString() ?? request.protocol
|
|
42
|
+
let host = request.headers['x-forwarded-host']?.toString() ?? request.get('host')
|
|
43
|
+
const forwardedPort = request.headers['x-forwarded-port']?.toString()
|
|
44
|
+
|
|
45
|
+
if (forwardedPort && !(protocol === 'https' && forwardedPort === '443') && !(protocol === 'http' && forwardedPort === '80')) {
|
|
46
|
+
host += `:${forwardedPort}`
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const forwardedPrefix = request.headers['x-forwarded-prefix']?.toString() ?? ''
|
|
50
|
+
|
|
51
|
+
return `${protocol}://${host}${forwardedPrefix}${request.originalUrl.split('?')[0].replace(/\/status\/index\/.*/, '')}`
|
|
52
|
+
}
|
|
53
|
+
|
|
14
54
|
export function createNewStatusListEndpoint(router: Router, context: IRequiredContext, opts: ICredentialStatusListEndpointOpts) {
|
|
15
55
|
if (opts?.enabled === false) {
|
|
16
56
|
console.log(`Create new status list endpoint is disabled`)
|
|
@@ -24,26 +64,15 @@ export function createNewStatusListEndpoint(router: Router, context: IRequiredCo
|
|
|
24
64
|
if (!statusListArgs) {
|
|
25
65
|
return sendErrorResponse(response, 400, 'No statusList details supplied')
|
|
26
66
|
}
|
|
27
|
-
const
|
|
28
|
-
|
|
67
|
+
const details = await context.agent.slCreateStatusList(statusListArgs)
|
|
68
|
+
const statuslistPayload = details.statusListCredential
|
|
69
|
+
return sendStatuslistResponse(details, statuslistPayload, response)
|
|
29
70
|
} catch (e) {
|
|
30
|
-
return sendErrorResponse(response, 500, e
|
|
71
|
+
return sendErrorResponse(response, 500, (e as Error).message, e)
|
|
31
72
|
}
|
|
32
73
|
})
|
|
33
74
|
}
|
|
34
75
|
|
|
35
|
-
const buildStatusListId = (request: Request): string => {
|
|
36
|
-
const protocol = request.headers['x-forwarded-proto']?.toString() ?? request.protocol
|
|
37
|
-
let host = request.headers['x-forwarded-host']?.toString() ?? request.get('host')
|
|
38
|
-
const forwardedPort = request.headers['x-forwarded-port']?.toString()
|
|
39
|
-
|
|
40
|
-
if (forwardedPort && !(protocol === 'https' && forwardedPort === '443') && !(protocol === 'http' && forwardedPort === '80')) {
|
|
41
|
-
host += `:${forwardedPort}`
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return `${protocol}://${host}${request.originalUrl}`
|
|
45
|
-
}
|
|
46
|
-
|
|
47
76
|
export function getStatusListCredentialEndpoint(router: Router, context: IRequiredContext, opts: ICredentialStatusListEndpointOpts) {
|
|
48
77
|
if (opts?.enabled === false) {
|
|
49
78
|
console.log(`Get statusList credential endpoint is disabled`)
|
|
@@ -53,13 +82,17 @@ export function getStatusListCredentialEndpoint(router: Router, context: IRequir
|
|
|
53
82
|
router.get(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {
|
|
54
83
|
try {
|
|
55
84
|
//todo: Check index against correlationId first. Then match originalUrl against statusList id
|
|
56
|
-
const correlationId = request.query.correlationId?.toString() ?? request.params.index?.toString() ?? request.originalUrl
|
|
57
|
-
const
|
|
85
|
+
//const correlationId = request.query.correlationId?.toString() ?? request.params.index?.toString() ?? request.originalUrl TODO I so not get these
|
|
86
|
+
const correlationId = request.query.correlationId?.toString()
|
|
87
|
+
const driver = await getDriver({
|
|
88
|
+
...(correlationId ? { correlationId } : { id: buildStatusListId(request) }),
|
|
89
|
+
dbName: opts.dbName,
|
|
90
|
+
})
|
|
58
91
|
const details = await driver.getStatusList()
|
|
59
|
-
|
|
60
|
-
return
|
|
92
|
+
const statuslistPayload = details.statusListCredential
|
|
93
|
+
return sendStatuslistResponse(details, statuslistPayload, response)
|
|
61
94
|
} catch (e) {
|
|
62
|
-
return sendErrorResponse(response, 500, e
|
|
95
|
+
return sendErrorResponse(response, 500, (e as Error).message, e)
|
|
63
96
|
}
|
|
64
97
|
})
|
|
65
98
|
}
|
|
@@ -69,6 +102,84 @@ export function getStatusListCredentialIndexStatusEndpoint(router: Router, conte
|
|
|
69
102
|
console.log(`Get statusList credential index status endpoint is disabled`)
|
|
70
103
|
return
|
|
71
104
|
}
|
|
105
|
+
|
|
106
|
+
const path = opts?.path ?? '/status-lists/:statusListId/status/entry-by-id/:entryId'
|
|
107
|
+
router.get(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {
|
|
108
|
+
try {
|
|
109
|
+
const statusListIdType = (request.query.statusListIdType as StatusListIdType) ?? StatusListIdType.StatusListId
|
|
110
|
+
const entryIdType = (request.query.entryIdType as EntryIdType) ?? EntryIdType.StatusListIndex
|
|
111
|
+
|
|
112
|
+
let statusListIndex: number | undefined
|
|
113
|
+
let entityCorrelationId: string | undefined
|
|
114
|
+
let statusListId: string | undefined
|
|
115
|
+
let statusListCorrelationId: string | undefined
|
|
116
|
+
|
|
117
|
+
if (entryIdType === EntryIdType.StatusListIndex) {
|
|
118
|
+
try {
|
|
119
|
+
statusListIndex = Number.parseInt(request.params.entryId)
|
|
120
|
+
if (!statusListIndex || statusListIndex < 0) {
|
|
121
|
+
return sendErrorResponse(response, 400, `Please provide a proper statusListIndex`)
|
|
122
|
+
}
|
|
123
|
+
} catch (error) {
|
|
124
|
+
return sendErrorResponse(response, 400, `Please provide a proper statusListIndex`)
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
entityCorrelationId = request.params.entryId
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (statusListIdType === StatusListIdType.StatusListId) {
|
|
131
|
+
statusListId = request.params.statusListId
|
|
132
|
+
} else {
|
|
133
|
+
statusListCorrelationId = request.params.statusListId
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const driver = await getDriver({
|
|
137
|
+
...(statusListCorrelationId ? { correlationId: statusListCorrelationId } : { id: statusListId }),
|
|
138
|
+
dbName: opts.dbName,
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
const details = await driver.getStatusList()
|
|
142
|
+
if (statusListIndex && statusListIndex > details.length) {
|
|
143
|
+
return sendErrorResponse(response, 400, `Please provide a proper statusListIndex`)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
let entry = await driver.getStatusListEntryByIndex({
|
|
147
|
+
statusListId: details.id,
|
|
148
|
+
...(entityCorrelationId ? { correlationId: entityCorrelationId } : { statusListIndex }),
|
|
149
|
+
errorOnNotFound: false,
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
const type = details.type === StatusListType.StatusList2021 ? 'StatusList2021Entry' : details.type
|
|
153
|
+
const resultStatusIndex = entry?.statusListIndex ?? statusListIndex ?? 0
|
|
154
|
+
const status = await checkStatusIndexFromStatusListCredential({
|
|
155
|
+
statusListCredential: details.statusListCredential,
|
|
156
|
+
...(details.type === StatusListType.StatusList2021 ? { statusPurpose: details.statusList2021?.statusPurpose } : {}),
|
|
157
|
+
type,
|
|
158
|
+
id: details.id,
|
|
159
|
+
statusListIndex: resultStatusIndex,
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
if (!entry) {
|
|
163
|
+
entry = {
|
|
164
|
+
statusListId: details.id,
|
|
165
|
+
value: '0',
|
|
166
|
+
statusListIndex: resultStatusIndex,
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
response.statusCode = 200
|
|
171
|
+
return response.json({ ...entry, status })
|
|
172
|
+
} catch (e) {
|
|
173
|
+
return sendErrorResponse(response, 500, (e as Error).message, e)
|
|
174
|
+
}
|
|
175
|
+
})
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function getStatusListCredentialIndexStatusEndpointLegacy(router: Router, context: IRequiredContext, opts: ICredentialStatusListEndpointOpts) {
|
|
179
|
+
if (opts?.enabled === false) {
|
|
180
|
+
console.log(`Get statusList credential index status endpoint is disabled`)
|
|
181
|
+
return
|
|
182
|
+
}
|
|
72
183
|
const path = opts?.path ?? '/status-lists/:index/status/index/:statusListIndex'
|
|
73
184
|
router.get(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {
|
|
74
185
|
try {
|
|
@@ -83,10 +194,10 @@ export function getStatusListCredentialIndexStatusEndpoint(router: Router, conte
|
|
|
83
194
|
if (!statusListIndex || statusListIndex < 0) {
|
|
84
195
|
return sendErrorResponse(response, 400, `Please provide a proper statusListIndex`)
|
|
85
196
|
}
|
|
86
|
-
const correlationId = request.query.correlationId?.toString() ?? request.params.index?.toString() ?? request.originalUrl
|
|
197
|
+
//const correlationId = request.query.correlationId?.toString() ?? request.params.index?.toString() ?? request.originalUrl TODO I so not get these
|
|
198
|
+
const statusListCorrelationId = request.query.correlationId?.toString()
|
|
87
199
|
const driver = await getDriver({
|
|
88
|
-
|
|
89
|
-
correlationId,
|
|
200
|
+
...(statusListCorrelationId ? { correlationId: statusListCorrelationId } : { id: buildStatusListId(request) }),
|
|
90
201
|
dbName: opts.dbName,
|
|
91
202
|
})
|
|
92
203
|
const details = await driver.getStatusList()
|
|
@@ -94,29 +205,37 @@ export function getStatusListCredentialIndexStatusEndpoint(router: Router, conte
|
|
|
94
205
|
return sendErrorResponse(response, 400, `Please provide a proper statusListIndex`)
|
|
95
206
|
}
|
|
96
207
|
|
|
208
|
+
const entityCorrelationId = request.query.entityCorrelationId?.toString()
|
|
97
209
|
let entry = await driver.getStatusListEntryByIndex({
|
|
98
|
-
statusListIndex,
|
|
99
210
|
statusListId: details.id,
|
|
100
|
-
correlationId:
|
|
211
|
+
...(entityCorrelationId ? { correlationId: entityCorrelationId } : { statusListIndex: statusListIndex }),
|
|
101
212
|
errorOnNotFound: false,
|
|
102
213
|
})
|
|
103
|
-
const
|
|
214
|
+
const type = details.type === StatusListType.StatusList2021 ? 'StatusList2021Entry' : details.type
|
|
215
|
+
const status = await checkStatusIndexFromStatusListCredential({
|
|
216
|
+
statusListCredential: details.statusListCredential,
|
|
217
|
+
...(details.type === StatusListType.StatusList2021 ? { statusPurpose: details.statusList2021?.statusPurpose } : {}),
|
|
218
|
+
type,
|
|
219
|
+
id: details.id,
|
|
220
|
+
statusListIndex,
|
|
221
|
+
})
|
|
104
222
|
if (!entry) {
|
|
105
223
|
// The fact we have nothing on it means the status is okay
|
|
106
224
|
entry = {
|
|
107
|
-
|
|
225
|
+
statusListId: details.id,
|
|
108
226
|
value: '0',
|
|
109
227
|
statusListIndex,
|
|
110
228
|
}
|
|
111
229
|
}
|
|
112
230
|
response.statusCode = 200
|
|
113
|
-
return response.
|
|
231
|
+
return response.json({ ...entry, status })
|
|
114
232
|
} catch (e) {
|
|
115
|
-
return sendErrorResponse(response, 500, e
|
|
233
|
+
return sendErrorResponse(response, 500, (e as Error).message, e)
|
|
116
234
|
}
|
|
117
235
|
})
|
|
118
236
|
}
|
|
119
|
-
|
|
237
|
+
|
|
238
|
+
export function updateStatusEndpoint(router: Router, context: IRequiredContext, opts: IW3CredentialStatusEndpointOpts) {
|
|
120
239
|
if (opts?.enabled === false) {
|
|
121
240
|
console.log(`Update credential status endpoint is disabled`)
|
|
122
241
|
return
|
|
@@ -124,65 +243,92 @@ export function updateW3CStatusEndpoint(router: Router, context: IRequiredContex
|
|
|
124
243
|
router.post(opts?.path ?? '/credentials/status', checkAuth(opts?.endpoint), async (request: Request, response: Response) => {
|
|
125
244
|
try {
|
|
126
245
|
debug(JSON.stringify(request.body, null, 2))
|
|
127
|
-
const updateRequest = request.body as
|
|
128
|
-
const statusListId = updateRequest.statusListId ?? request.query.statusListId?.toString() ?? opts.statusListId
|
|
129
|
-
const statusListCorrelationId = updateRequest.statusListCorrelationId ?? request.query.
|
|
246
|
+
const updateRequest = request.body as UpdateW3cCredentialStatusRequest | UpdateIndexedCredentialStatusRequest
|
|
247
|
+
const statusListId = updateRequest.statusListId ?? request.query.statusListId?.toString() ?? opts.statusListId // TODO why query params when we have a JSON body ??
|
|
248
|
+
const statusListCorrelationId = updateRequest.statusListCorrelationId ?? request.query.statusListrelationId?.toString() ?? opts.correlationId
|
|
130
249
|
const entryCorrelationId = updateRequest.entryCorrelationId ?? request.query.entryCorrelationId?.toString()
|
|
131
|
-
const credentialId = updateRequest.credentialId
|
|
132
250
|
|
|
133
251
|
// TODO: Move mostly to driver
|
|
134
|
-
if (!
|
|
135
|
-
return sendErrorResponse(response, 400, 'No statusList
|
|
252
|
+
if (!statusListId && !statusListCorrelationId) {
|
|
253
|
+
return sendErrorResponse(response, 400, 'No statusList id or correlation Id provided or deduced for the API or in the request')
|
|
136
254
|
} else if (!updateRequest.credentialStatus || updateRequest.credentialStatus.length === 0) {
|
|
137
255
|
return sendErrorResponse(response, 400, 'No statusList updates supplied')
|
|
138
|
-
} else if (!statusListId && !statusListCorrelationId) {
|
|
139
|
-
return sendErrorResponse(response, 400, 'No statusList id or correlation Id provided or deduced for the API or in the request')
|
|
140
256
|
}
|
|
141
|
-
const driver = await getDriver({
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
statusListId,
|
|
145
|
-
statusListCorrelationId,
|
|
146
|
-
entryCorrelationId,
|
|
147
|
-
credentialId,
|
|
148
|
-
errorOnNotFound: true,
|
|
257
|
+
const driver = await getDriver({
|
|
258
|
+
...(statusListCorrelationId ? { correlationId: statusListCorrelationId } : { id: buildStatusListId(request) }),
|
|
259
|
+
dbName: opts.dbName,
|
|
149
260
|
})
|
|
261
|
+
let statusListResult: StatusListResult = await driver.getStatusList()
|
|
262
|
+
|
|
263
|
+
// Get status list entry based on request type
|
|
264
|
+
let statusListEntry: IStatusListEntryEntity | undefined
|
|
265
|
+
if ('credentialId' in updateRequest) {
|
|
266
|
+
if (!updateRequest.credentialId) {
|
|
267
|
+
return sendErrorResponse(response, 400, 'No credentialId supplied')
|
|
268
|
+
}
|
|
269
|
+
// unfortunately the W3C API works by credentialId. Which means you will have to map listIndices during issuance
|
|
270
|
+
statusListEntry = await driver.getStatusListEntryByCredentialId({
|
|
271
|
+
statusListId,
|
|
272
|
+
statusListCorrelationId,
|
|
273
|
+
entryCorrelationId,
|
|
274
|
+
credentialId: updateRequest.credentialId,
|
|
275
|
+
errorOnNotFound: true,
|
|
276
|
+
})
|
|
277
|
+
} else {
|
|
278
|
+
statusListEntry = await driver.getStatusListEntryByIndex({
|
|
279
|
+
...(statusListResult.id && { statusListId: statusListResult.id }),
|
|
280
|
+
...(statusListResult.correlationId && { statusListCorrelationId: statusListResult.correlationId }),
|
|
281
|
+
...(entryCorrelationId ? { entryCorrelationId } : { statusListIndex: updateRequest.statusListIndex }),
|
|
282
|
+
errorOnNotFound: true,
|
|
283
|
+
})
|
|
284
|
+
}
|
|
285
|
+
|
|
150
286
|
if (!statusListEntry) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
404,
|
|
154
|
-
`status list index for credential id ${credentialId} was never recorded for ${statusListId}. This means the status will be 0`,
|
|
155
|
-
)
|
|
287
|
+
const identifier = 'credentialId' in updateRequest ? updateRequest.credentialId : `index ${updateRequest.statusListIndex}`
|
|
288
|
+
return sendErrorResponse(response, 404, `Status list entry for ${identifier} not found for ${statusListId}`)
|
|
156
289
|
}
|
|
157
|
-
const statusListIndex = statusListEntry.statusListIndex
|
|
158
|
-
let details = await driver.getStatusList()
|
|
159
|
-
let statusListCredential = details.statusListCredential
|
|
160
290
|
|
|
291
|
+
let statusListCredential = statusListResult.statusListCredential
|
|
161
292
|
for (const updateItem of updateRequest.credentialStatus) {
|
|
162
|
-
if (updateItem.
|
|
163
|
-
return sendErrorResponse(response, 400, `
|
|
293
|
+
if (!updateItem.status) {
|
|
294
|
+
return sendErrorResponse(response, 400, `Required 'status' value was missing in the credentialStatus array`)
|
|
164
295
|
}
|
|
165
296
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
297
|
+
let value: string = '1'
|
|
298
|
+
if (updateItem.status === '0' || updateItem.status.toLowerCase() === 'false') {
|
|
299
|
+
value = '0'
|
|
300
|
+
} else if (updateItem.status !== '1' && updateItem.status.toLowerCase() !== 'true') {
|
|
301
|
+
if (updateItem.type === StatusListType.StatusList2021) {
|
|
302
|
+
// 2021 only allows 0 and 1
|
|
303
|
+
return sendErrorResponse(response, 400, `Invalid 'status' value in the credentialStatus array: ${updateItem.status}`)
|
|
304
|
+
} else if (parseInt(updateItem.status) < 0 || parseInt(updateItem.status) > 255) {
|
|
305
|
+
return sendErrorResponse(response, 400, `Invalid 'status' value in the credentialStatus array: ${updateItem.status}`)
|
|
306
|
+
}
|
|
307
|
+
value = `${parseInt(updateItem.status)}`
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const updStatusListId = statusListId ?? statusListEntry.statusList?.id // When input was statusListCorrelationId the statusList id should come from statusListEntry
|
|
311
|
+
if (!updStatusListId) {
|
|
312
|
+
return sendErrorResponse(response, 400, 'statuslist id could not be determined')
|
|
172
313
|
}
|
|
173
|
-
|
|
174
|
-
const statusList = statusListId ?? statusListEntry.statusList
|
|
175
|
-
await driver.updateStatusListEntry({ ...statusListEntry, statusListIndex, statusList, credentialId, value: value ? '1' : '0' })
|
|
314
|
+
await driver.updateStatusListEntry({ ...statusListEntry, statusListId: updStatusListId, value })
|
|
176
315
|
|
|
177
316
|
// todo: optimize. We are now creating a new VC for every item passed in. Probably wise to look at DB as well
|
|
178
|
-
|
|
179
|
-
|
|
317
|
+
statusListResult = await updateStatusIndexFromStatusListCredential(
|
|
318
|
+
{
|
|
319
|
+
statusListCredential: statusListCredential,
|
|
320
|
+
statusListIndex: statusListEntry.statusListIndex,
|
|
321
|
+
value: parseInt(value),
|
|
322
|
+
keyRef: opts.keyRef,
|
|
323
|
+
},
|
|
324
|
+
context,
|
|
325
|
+
)
|
|
326
|
+
statusListResult = await driver.updateStatusList({ statusListCredential: statusListResult.statusListCredential })
|
|
180
327
|
}
|
|
181
328
|
|
|
182
|
-
|
|
183
|
-
return response.send(details.statusListCredential)
|
|
329
|
+
return sendStatuslistResponse(statusListResult, statusListResult.statusListCredential, response)
|
|
184
330
|
} catch (e) {
|
|
185
|
-
return sendErrorResponse(response, 500, e
|
|
331
|
+
return sendErrorResponse(response, 500, (e as Error).message, e)
|
|
186
332
|
}
|
|
187
333
|
})
|
|
188
334
|
}
|
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
createNewStatusListEndpoint,
|
|
9
9
|
getStatusListCredentialEndpoint,
|
|
10
10
|
getStatusListCredentialIndexStatusEndpoint,
|
|
11
|
-
|
|
11
|
+
getStatusListCredentialIndexStatusEndpointLegacy,
|
|
12
|
+
updateStatusEndpoint,
|
|
12
13
|
} from './api-functions'
|
|
13
14
|
import { IStatusListOpts } from './types'
|
|
14
15
|
import { IRequiredPlugins } from '@sphereon/ssi-sdk.vc-status-list-issuer-drivers'
|
|
@@ -48,9 +49,10 @@ export class StatuslistManagementApiServer {
|
|
|
48
49
|
if (features.includes('status-list-hosting')) {
|
|
49
50
|
getStatusListCredentialEndpoint(this.router, context, opts.endpointOpts.getStatusList)
|
|
50
51
|
getStatusListCredentialIndexStatusEndpoint(this.router, context, opts.endpointOpts.getStatusList)
|
|
52
|
+
getStatusListCredentialIndexStatusEndpointLegacy(this.router, context, opts.endpointOpts.getStatusList)
|
|
51
53
|
}
|
|
52
54
|
if (features.includes('w3c-vc-api-credential-status')) {
|
|
53
|
-
|
|
55
|
+
updateStatusEndpoint(this.router, context, opts.endpointOpts.vcApiCredentialStatus)
|
|
54
56
|
}
|
|
55
57
|
this._express.use(opts?.endpointOpts?.basePath ?? '', this.router)
|
|
56
58
|
}
|
package/src/types.ts
CHANGED
|
@@ -31,8 +31,15 @@ export interface IW3CredentialStatusEndpointOpts extends ICredentialStatusListEn
|
|
|
31
31
|
keyRef?: string
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export interface UpdateCredentialStatusRequest {
|
|
34
|
+
export interface UpdateW3cCredentialStatusRequest extends UpdateCredentialStatusRequest {
|
|
35
35
|
credentialId: string
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface UpdateIndexedCredentialStatusRequest extends UpdateCredentialStatusRequest {
|
|
39
|
+
statusListIndex?: number
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface UpdateCredentialStatusRequest {
|
|
36
43
|
credentialStatus: UpdateCredentialStatusItem[]
|
|
37
44
|
statusListId?: string // Non spec compliant. Allows us to manage multiple status lists. The VC API endpoint also has this config option, allowing for a default
|
|
38
45
|
statusListCorrelationId?: string // Non spec compliant. Allows us to manage multiple status lists. The VC API endpoint also has this config option, allowing for a default
|
|
@@ -43,3 +50,13 @@ export interface UpdateCredentialStatusItem {
|
|
|
43
50
|
type?: StatusListType // makes very little sense, but listed in the spec. Would expect a purpose
|
|
44
51
|
status: string
|
|
45
52
|
}
|
|
53
|
+
|
|
54
|
+
export enum StatusListIdType {
|
|
55
|
+
StatusListId = 'StatusListId',
|
|
56
|
+
StatusListCorrelationId = 'StatusListCorrelationId',
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export enum EntryIdType {
|
|
60
|
+
StatusListIndex = 'StatusListIndex',
|
|
61
|
+
EntryCorrelationId = 'StatusListCorrelationId',
|
|
62
|
+
}
|