@sphereon/ssi-sdk.vc-status-list-issuer-rest-api 0.33.1-feature.vcdm2.tsup.33 → 0.33.1-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,52 @@
1
+ import { GenericAuthArgs, ISingleEndpointOpts } from '@sphereon/ssi-express-support';
2
+ import { IStatusListPlugin } from '@sphereon/ssi-sdk.vc-status-list';
3
+ import { IRequiredPlugins } from '@sphereon/ssi-sdk.vc-status-list-issuer-drivers';
4
+ import { StatusListType } from '@sphereon/ssi-types';
5
+ import { IAgentContext } from '@veramo/core';
6
+ export type IRequiredContext = IAgentContext<IRequiredPlugins & IStatusListPlugin>;
7
+ export interface IStatusListOpts {
8
+ endpointOpts: IStatusListEndpointOpts;
9
+ enableFeatures?: statusListFeatures[];
10
+ }
11
+ export interface IStatusListEndpointOpts {
12
+ basePath?: string;
13
+ globalAuth?: GenericAuthArgs;
14
+ vcApiCredentialStatus: IW3CredentialStatusEndpointOpts;
15
+ createStatusList: ICredentialStatusListEndpointOpts;
16
+ getStatusList: ICredentialStatusListEndpointOpts;
17
+ }
18
+ export type statusListFeatures = 'w3c-vc-api-credential-status' | 'status-list-management' | 'status-list-hosting';
19
+ export interface ICredentialStatusListEndpointOpts extends ISingleEndpointOpts {
20
+ dbName: string;
21
+ }
22
+ export interface IW3CredentialStatusEndpointOpts extends ICredentialStatusListEndpointOpts {
23
+ statusListId?: string;
24
+ correlationId?: string;
25
+ keyRef?: string;
26
+ }
27
+ export interface UpdateW3cCredentialStatusRequest extends UpdateCredentialStatusRequest {
28
+ credentialId: string;
29
+ }
30
+ export interface UpdateIndexedCredentialStatusRequest extends UpdateCredentialStatusRequest {
31
+ statusListIndex?: number;
32
+ }
33
+ interface UpdateCredentialStatusRequest {
34
+ credentialStatus: UpdateCredentialStatusItem[];
35
+ statusListId?: string;
36
+ statusListCorrelationId?: string;
37
+ entryCorrelationId?: string;
38
+ }
39
+ export interface UpdateCredentialStatusItem {
40
+ type?: StatusListType;
41
+ status: string;
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 {};
52
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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,kBAAkB,EAAE,CAAA;CACtC;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,eAAe,CAAA;IAC5B,qBAAqB,EAAE,+BAA+B,CAAA;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 ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EntryIdType = exports.StatusListIdType = void 0;
4
+ var StatusListIdType;
5
+ (function (StatusListIdType) {
6
+ StatusListIdType["StatusListId"] = "StatusListId";
7
+ StatusListIdType["StatusListCorrelationId"] = "StatusListCorrelationId";
8
+ })(StatusListIdType || (exports.StatusListIdType = StatusListIdType = {}));
9
+ var EntryIdType;
10
+ (function (EntryIdType) {
11
+ EntryIdType["StatusListIndex"] = "StatusListIndex";
12
+ EntryIdType["EntryCorrelationId"] = "StatusListCorrelationId";
13
+ })(EntryIdType || (exports.EntryIdType = EntryIdType = {}));
14
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAqDA,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,iDAA6B,CAAA;IAC7B,uEAAmD,CAAA;AACrD,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B;AAED,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,kDAAmC,CAAA;IACnC,6DAA8C,CAAA;AAChD,CAAC,EAHW,WAAW,2BAAX,WAAW,QAGtB"}
package/package.json CHANGED
@@ -1,54 +1,42 @@
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.33.1-feature.vcdm2.tsup.33+7765edb3",
4
+ "version": "0.33.1-next.3+fd1a6fba",
5
5
  "source": "src/index.ts",
6
- "type": "module",
7
- "main": "./dist/index.cjs",
8
- "module": "./dist/index.js",
9
- "types": "./dist/index.d.ts",
10
- "exports": {
11
- "react-native": "./dist/index.js",
12
- "import": {
13
- "types": "./dist/index.d.ts",
14
- "import": "./dist/index.js"
15
- },
16
- "require": {
17
- "types": "./dist/index.d.cts",
18
- "require": "./dist/index.cjs"
19
- }
20
- },
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
21
8
  "scripts": {
22
- "build": "tsup --config ../../tsup.config.ts --tsconfig ../../tsconfig.tsup.json",
9
+ "build": "tsc --build",
10
+ "build:clean": "tsc --build --clean && tsc --build",
23
11
  "start:dev": "node --experimental-specifier-resolution=node --loader ts-node/esm __tests__/agent.ts",
24
12
  "start:dev2": "node --experimental-specifier-resolution=node --loader ts-node/esm __tests__/agent.ts"
25
13
  },
26
14
  "dependencies": {
27
- "@sphereon/ssi-express-support": "^0.33.1-feature.vcdm2.tsup.33+7765edb3",
28
- "@sphereon/ssi-sdk-ext.did-utils": "0.28.1-feature.esm.cjs.17",
29
- "@sphereon/ssi-sdk-ext.identifier-resolution": "0.28.1-feature.esm.cjs.17",
30
- "@sphereon/ssi-sdk-ext.jwt-service": "0.28.1-feature.esm.cjs.17",
31
- "@sphereon/ssi-sdk.core": "^0.33.1-feature.vcdm2.tsup.33+7765edb3",
32
- "@sphereon/ssi-sdk.data-store": "^0.33.1-feature.vcdm2.tsup.33+7765edb3",
33
- "@sphereon/ssi-sdk.vc-status-list": "^0.33.1-feature.vcdm2.tsup.33+7765edb3",
34
- "@sphereon/ssi-sdk.vc-status-list-issuer-drivers": "^0.33.1-feature.vcdm2.tsup.33+7765edb3",
35
- "@sphereon/ssi-types": "^0.33.1-feature.vcdm2.tsup.33+7765edb3",
15
+ "@sphereon/ssi-express-support": "0.33.1-next.3+fd1a6fba",
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-next.3+fd1a6fba",
20
+ "@sphereon/ssi-sdk.data-store": "0.33.1-next.3+fd1a6fba",
21
+ "@sphereon/ssi-sdk.vc-status-list": "0.33.1-next.3+fd1a6fba",
22
+ "@sphereon/ssi-sdk.vc-status-list-issuer-drivers": "0.33.1-next.3+fd1a6fba",
23
+ "@sphereon/ssi-types": "0.33.1-next.3+fd1a6fba",
36
24
  "@sphereon/vc-status-list": "7.0.0-next.0",
37
25
  "@veramo/core": "4.2.0",
38
26
  "debug": "^4.3.5",
39
27
  "express": "^4.19.2",
40
- "reflect-metadata": "^0.2.2",
41
- "typeorm": "0.3.20",
28
+ "reflect-metadata": "0.2.2",
29
+ "typeorm": "^0.3.21",
42
30
  "uint8arrays": "^3.1.1",
43
31
  "uuid": "^9.0.1"
44
32
  },
45
33
  "devDependencies": {
46
34
  "@sphereon/did-uni-client": "^0.6.3",
47
- "@sphereon/ssi-sdk-ext.did-provider-jwk": "0.28.1-feature.esm.cjs.17",
48
- "@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.28.1-feature.esm.cjs.17",
49
- "@sphereon/ssi-sdk.agent-config": "^0.33.1-feature.vcdm2.tsup.33+7765edb3",
50
- "@sphereon/ssi-sdk.data-store": "workspace:^",
51
- "@sphereon/ssi-sdk.vc-handler-ld-local": "^0.33.1-feature.vcdm2.tsup.33+7765edb3",
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-next.3+fd1a6fba",
38
+ "@sphereon/ssi-sdk.data-store": "workspace:*",
39
+ "@sphereon/ssi-sdk.vc-handler-ld-local": "0.33.1-next.3+fd1a6fba",
52
40
  "@types/body-parser": "^1.19.5",
53
41
  "@types/cookie-parser": "^1.4.7",
54
42
  "@types/cors": "^2.8.17",
@@ -71,11 +59,11 @@
71
59
  "@veramo/utils": "4.2.0",
72
60
  "did-resolver": "^4.1.0",
73
61
  "morgan": "^1.10.0",
74
- "typescript": "5.8.3"
62
+ "typescript": "5.4.2"
75
63
  },
76
64
  "files": [
77
- "dist",
78
- "src",
65
+ "dist/**/*",
66
+ "src/**/*",
79
67
  "README.md",
80
68
  "LICENSE"
81
69
  ],
@@ -91,5 +79,6 @@
91
79
  "SSI",
92
80
  "StatusList2021"
93
81
  ],
94
- "gitHead": "7765edb3fd7f69b4fbd36f02a725821cb38e4e30"
82
+ "nx": {},
83
+ "gitHead": "fd1a6fba306a83a73ff7c531db87fa207dbf436d"
95
84
  }
package/dist/index.cjs DELETED
@@ -1,455 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
-
31
- // src/index.ts
32
- var index_exports = {};
33
- __export(index_exports, {
34
- EntryIdType: () => EntryIdType,
35
- StatusListIdType: () => StatusListIdType,
36
- StatuslistManagementApiServer: () => StatuslistManagementApiServer,
37
- createNewStatusListEndpoint: () => createNewStatusListEndpoint,
38
- getStatusListCredentialEndpoint: () => getStatusListCredentialEndpoint,
39
- getStatusListCredentialIndexStatusEndpoint: () => getStatusListCredentialIndexStatusEndpoint,
40
- getStatusListCredentialIndexStatusEndpointLegacy: () => getStatusListCredentialIndexStatusEndpointLegacy,
41
- updateStatusEndpoint: () => updateStatusEndpoint
42
- });
43
- module.exports = __toCommonJS(index_exports);
44
-
45
- // src/statuslist-management-api-server.ts
46
- var import_ssi_express_support2 = require("@sphereon/ssi-express-support");
47
- var import_ssi_sdk3 = require("@sphereon/ssi-sdk.core");
48
- var import_express = __toESM(require("express"), 1);
49
-
50
- // src/api-functions.ts
51
- var import_ssi_express_support = require("@sphereon/ssi-express-support");
52
- var import_ssi_sdk = require("@sphereon/ssi-sdk.vc-status-list");
53
- var import_ssi_sdk2 = require("@sphereon/ssi-sdk.vc-status-list-issuer-drivers");
54
- var import_debug = __toESM(require("debug"), 1);
55
-
56
- // src/types.ts
57
- var StatusListIdType = /* @__PURE__ */ function(StatusListIdType2) {
58
- StatusListIdType2["StatusListId"] = "StatusListId";
59
- StatusListIdType2["StatusListCorrelationId"] = "StatusListCorrelationId";
60
- return StatusListIdType2;
61
- }({});
62
- var EntryIdType = /* @__PURE__ */ function(EntryIdType2) {
63
- EntryIdType2["StatusListIndex"] = "StatusListIndex";
64
- EntryIdType2["EntryCorrelationId"] = "StatusListCorrelationId";
65
- return EntryIdType2;
66
- }({});
67
-
68
- // src/api-functions.ts
69
- var import_ssi_types = require("@sphereon/ssi-types");
70
- var debug = (0, import_debug.default)("sphereon:ssi-sdk:status-list");
71
- function sendStatuslistResponse(details, statuslistPayload, response) {
72
- let payload;
73
- switch (details.proofFormat) {
74
- case "jwt":
75
- case "cbor":
76
- payload = Buffer.from(statuslistPayload, "ascii");
77
- break;
78
- default:
79
- payload = statuslistPayload;
80
- }
81
- return response.status(200).setHeader("Content-Type", details.statuslistContentType).send(payload);
82
- }
83
- __name(sendStatuslistResponse, "sendStatuslistResponse");
84
- function buildStatusListId(request) {
85
- const protocol = request.headers["x-forwarded-proto"]?.toString() ?? request.protocol;
86
- let host = request.headers["x-forwarded-host"]?.toString() ?? request.get("host");
87
- const forwardedPort = request.headers["x-forwarded-port"]?.toString();
88
- if (forwardedPort && !(protocol === "https" && forwardedPort === "443") && !(protocol === "http" && forwardedPort === "80")) {
89
- host += `:${forwardedPort}`;
90
- }
91
- const forwardedPrefix = request.headers["x-forwarded-prefix"]?.toString() ?? "";
92
- return `${protocol}://${host}${forwardedPrefix}${request.originalUrl.split("?")[0].replace(/\/status\/index\/.*/, "")}`;
93
- }
94
- __name(buildStatusListId, "buildStatusListId");
95
- function createNewStatusListEndpoint(router, context, opts) {
96
- if (opts?.enabled === false) {
97
- console.log(`Create new status list endpoint is disabled`);
98
- return;
99
- }
100
- const path = opts?.path ?? "/status-lists";
101
- router.post(path, (0, import_ssi_express_support.checkAuth)(opts?.endpoint), async (request, response) => {
102
- try {
103
- const statusListArgs = request.body.statusList;
104
- if (!statusListArgs) {
105
- return (0, import_ssi_express_support.sendErrorResponse)(response, 400, "No statusList details supplied");
106
- }
107
- const details = await context.agent.slCreateStatusList(statusListArgs);
108
- const statuslistPayload = details.statusListCredential;
109
- return sendStatuslistResponse(details, statuslistPayload, response);
110
- } catch (e) {
111
- return (0, import_ssi_express_support.sendErrorResponse)(response, 500, e.message, e);
112
- }
113
- });
114
- }
115
- __name(createNewStatusListEndpoint, "createNewStatusListEndpoint");
116
- function getStatusListCredentialEndpoint(router, context, opts) {
117
- if (opts?.enabled === false) {
118
- console.log(`Get statusList credential endpoint is disabled`);
119
- return;
120
- }
121
- const path = opts?.path ?? "/status-lists/:index";
122
- router.get(path, (0, import_ssi_express_support.checkAuth)(opts?.endpoint), async (request, response) => {
123
- try {
124
- const correlationId = request.query.correlationId?.toString();
125
- const driver = await (0, import_ssi_sdk2.getDriver)({
126
- ...correlationId ? {
127
- correlationId
128
- } : {
129
- id: buildStatusListId(request)
130
- },
131
- dbName: opts.dbName
132
- });
133
- const details = await driver.getStatusList();
134
- const statuslistPayload = details.statusListCredential;
135
- return sendStatuslistResponse(details, statuslistPayload, response);
136
- } catch (e) {
137
- return (0, import_ssi_express_support.sendErrorResponse)(response, 500, e.message, e);
138
- }
139
- });
140
- }
141
- __name(getStatusListCredentialEndpoint, "getStatusListCredentialEndpoint");
142
- function getStatusListCredentialIndexStatusEndpoint(router, context, opts) {
143
- if (opts?.enabled === false) {
144
- console.log(`Get statusList credential index status endpoint is disabled`);
145
- return;
146
- }
147
- const path = opts?.path ?? "/status-lists/:statusListId/status/entry-by-id/:entryId";
148
- router.get(path, (0, import_ssi_express_support.checkAuth)(opts?.endpoint), async (request, response) => {
149
- try {
150
- const statusListIdType = request.query.statusListIdType ?? StatusListIdType.StatusListId;
151
- const entryIdType = request.query.entryIdType ?? EntryIdType.StatusListIndex;
152
- let statusListIndex;
153
- let entityCorrelationId;
154
- let statusListId;
155
- let statusListCorrelationId;
156
- if (entryIdType === EntryIdType.StatusListIndex) {
157
- try {
158
- statusListIndex = Number.parseInt(request.params.entryId);
159
- if (!statusListIndex || statusListIndex < 0) {
160
- return (0, import_ssi_express_support.sendErrorResponse)(response, 400, `Please provide a proper statusListIndex`);
161
- }
162
- } catch (error) {
163
- return (0, import_ssi_express_support.sendErrorResponse)(response, 400, `Please provide a proper statusListIndex`);
164
- }
165
- } else {
166
- entityCorrelationId = request.params.entryId;
167
- }
168
- if (statusListIdType === StatusListIdType.StatusListId) {
169
- statusListId = request.params.statusListId;
170
- } else {
171
- statusListCorrelationId = request.params.statusListId;
172
- }
173
- const driver = await (0, import_ssi_sdk2.getDriver)({
174
- ...statusListCorrelationId ? {
175
- correlationId: statusListCorrelationId
176
- } : {
177
- id: statusListId
178
- },
179
- dbName: opts.dbName
180
- });
181
- const details = await driver.getStatusList();
182
- if (statusListIndex && statusListIndex > details.length) {
183
- return (0, import_ssi_express_support.sendErrorResponse)(response, 400, `Please provide a proper statusListIndex`);
184
- }
185
- let entry = await driver.getStatusListEntryByIndex({
186
- statusListId: details.id,
187
- ...entityCorrelationId ? {
188
- correlationId: entityCorrelationId
189
- } : {
190
- statusListIndex
191
- },
192
- errorOnNotFound: false
193
- });
194
- const type = details.type === import_ssi_types.StatusListType.StatusList2021 ? "StatusList2021Entry" : details.type;
195
- const resultStatusIndex = entry?.statusListIndex ?? statusListIndex ?? 0;
196
- const status = await (0, import_ssi_sdk.checkStatusIndexFromStatusListCredential)({
197
- statusListCredential: details.statusListCredential,
198
- ...details.type === import_ssi_types.StatusListType.StatusList2021 ? {
199
- statusPurpose: details.statusList2021?.statusPurpose
200
- } : {},
201
- type,
202
- id: details.id,
203
- statusListIndex: resultStatusIndex
204
- });
205
- if (!entry) {
206
- entry = {
207
- statusListId: details.id,
208
- value: "0",
209
- statusListIndex: resultStatusIndex
210
- };
211
- }
212
- response.statusCode = 200;
213
- return response.json({
214
- ...entry,
215
- status
216
- });
217
- } catch (e) {
218
- return (0, import_ssi_express_support.sendErrorResponse)(response, 500, e.message, e);
219
- }
220
- });
221
- }
222
- __name(getStatusListCredentialIndexStatusEndpoint, "getStatusListCredentialIndexStatusEndpoint");
223
- function getStatusListCredentialIndexStatusEndpointLegacy(router, context, opts) {
224
- if (opts?.enabled === false) {
225
- console.log(`Get statusList credential index status endpoint is disabled`);
226
- return;
227
- }
228
- const path = opts?.path ?? "/status-lists/:index/status/index/:statusListIndex";
229
- router.get(path, (0, import_ssi_express_support.checkAuth)(opts?.endpoint), async (request, response) => {
230
- try {
231
- const statusListIndexStr = request.params.statusListIndex;
232
- let statusListIndex;
233
- try {
234
- statusListIndex = Number.parseInt(statusListIndexStr);
235
- } catch (error) {
236
- return (0, import_ssi_express_support.sendErrorResponse)(response, 400, `Please provide a proper statusListIndex`);
237
- }
238
- if (!statusListIndex || statusListIndex < 0) {
239
- return (0, import_ssi_express_support.sendErrorResponse)(response, 400, `Please provide a proper statusListIndex`);
240
- }
241
- const statusListCorrelationId = request.query.correlationId?.toString();
242
- const driver = await (0, import_ssi_sdk2.getDriver)({
243
- ...statusListCorrelationId ? {
244
- correlationId: statusListCorrelationId
245
- } : {
246
- id: buildStatusListId(request)
247
- },
248
- dbName: opts.dbName
249
- });
250
- const details = await driver.getStatusList();
251
- if (statusListIndex > details.length) {
252
- return (0, import_ssi_express_support.sendErrorResponse)(response, 400, `Please provide a proper statusListIndex`);
253
- }
254
- const entityCorrelationId = request.query.entityCorrelationId?.toString();
255
- let entry = await driver.getStatusListEntryByIndex({
256
- statusListId: details.id,
257
- ...entityCorrelationId ? {
258
- correlationId: entityCorrelationId
259
- } : {
260
- statusListIndex
261
- },
262
- errorOnNotFound: false
263
- });
264
- const type = details.type === import_ssi_types.StatusListType.StatusList2021 ? "StatusList2021Entry" : details.type;
265
- const status = await (0, import_ssi_sdk.checkStatusIndexFromStatusListCredential)({
266
- statusListCredential: details.statusListCredential,
267
- ...details.type === import_ssi_types.StatusListType.StatusList2021 ? {
268
- statusPurpose: details.statusList2021?.statusPurpose
269
- } : {},
270
- type,
271
- id: details.id,
272
- statusListIndex
273
- });
274
- if (!entry) {
275
- entry = {
276
- statusListId: details.id,
277
- value: "0",
278
- statusListIndex
279
- };
280
- }
281
- response.statusCode = 200;
282
- return response.json({
283
- ...entry,
284
- status
285
- });
286
- } catch (e) {
287
- return (0, import_ssi_express_support.sendErrorResponse)(response, 500, e.message, e);
288
- }
289
- });
290
- }
291
- __name(getStatusListCredentialIndexStatusEndpointLegacy, "getStatusListCredentialIndexStatusEndpointLegacy");
292
- function updateStatusEndpoint(router, context, opts) {
293
- if (opts?.enabled === false) {
294
- console.log(`Update credential status endpoint is disabled`);
295
- return;
296
- }
297
- router.post(opts?.path ?? "/credentials/status", (0, import_ssi_express_support.checkAuth)(opts?.endpoint), async (request, response) => {
298
- try {
299
- debug(JSON.stringify(request.body, null, 2));
300
- const updateRequest = request.body;
301
- const statusListId = updateRequest.statusListId ?? request.query.statusListId?.toString() ?? opts.statusListId;
302
- const statusListCorrelationId = updateRequest.statusListCorrelationId ?? request.query.statusListrelationId?.toString() ?? opts.correlationId;
303
- const entryCorrelationId = updateRequest.entryCorrelationId ?? request.query.entryCorrelationId?.toString();
304
- if (!statusListId && !statusListCorrelationId) {
305
- return (0, import_ssi_express_support.sendErrorResponse)(response, 400, "No statusList id or correlation Id provided or deduced for the API or in the request");
306
- } else if (!updateRequest.credentialStatus || updateRequest.credentialStatus.length === 0) {
307
- return (0, import_ssi_express_support.sendErrorResponse)(response, 400, "No statusList updates supplied");
308
- }
309
- const driver = await (0, import_ssi_sdk2.getDriver)({
310
- ...statusListCorrelationId ? {
311
- correlationId: statusListCorrelationId
312
- } : {
313
- id: buildStatusListId(request)
314
- },
315
- dbName: opts.dbName
316
- });
317
- let statusListResult = await driver.getStatusList();
318
- let statusListEntry;
319
- if ("credentialId" in updateRequest) {
320
- if (!updateRequest.credentialId) {
321
- return (0, import_ssi_express_support.sendErrorResponse)(response, 400, "No credentialId supplied");
322
- }
323
- statusListEntry = await driver.getStatusListEntryByCredentialId({
324
- statusListId,
325
- statusListCorrelationId,
326
- entryCorrelationId,
327
- credentialId: updateRequest.credentialId,
328
- errorOnNotFound: true
329
- });
330
- } else {
331
- statusListEntry = await driver.getStatusListEntryByIndex({
332
- ...statusListResult.id && {
333
- statusListId: statusListResult.id
334
- },
335
- ...statusListResult.correlationId && {
336
- statusListCorrelationId: statusListResult.correlationId
337
- },
338
- ...entryCorrelationId ? {
339
- entryCorrelationId
340
- } : {
341
- statusListIndex: updateRequest.statusListIndex
342
- },
343
- errorOnNotFound: true
344
- });
345
- }
346
- if (!statusListEntry) {
347
- const identifier = "credentialId" in updateRequest ? updateRequest.credentialId : `index ${updateRequest.statusListIndex}`;
348
- return (0, import_ssi_express_support.sendErrorResponse)(response, 404, `Status list entry for ${identifier} not found for ${statusListId}`);
349
- }
350
- let statusListCredential = statusListResult.statusListCredential;
351
- for (const updateItem of updateRequest.credentialStatus) {
352
- if (!updateItem.status) {
353
- return (0, import_ssi_express_support.sendErrorResponse)(response, 400, `Required 'status' value was missing in the credentialStatus array`);
354
- }
355
- let value = "1";
356
- if (updateItem.status === "0" || updateItem.status.toLowerCase() === "false") {
357
- value = "0";
358
- } else if (updateItem.status !== "1" && updateItem.status.toLowerCase() !== "true") {
359
- if (updateItem.type === import_ssi_types.StatusListType.StatusList2021) {
360
- return (0, import_ssi_express_support.sendErrorResponse)(response, 400, `Invalid 'status' value in the credentialStatus array: ${updateItem.status}`);
361
- } else if (parseInt(updateItem.status) < 0 || parseInt(updateItem.status) > 255) {
362
- return (0, import_ssi_express_support.sendErrorResponse)(response, 400, `Invalid 'status' value in the credentialStatus array: ${updateItem.status}`);
363
- }
364
- value = `${parseInt(updateItem.status)}`;
365
- }
366
- const updStatusListId = statusListId ?? statusListEntry.statusList?.id;
367
- if (!updStatusListId) {
368
- return (0, import_ssi_express_support.sendErrorResponse)(response, 400, "statuslist id could not be determined");
369
- }
370
- await driver.updateStatusListEntry({
371
- ...statusListEntry,
372
- statusListId: updStatusListId,
373
- value
374
- });
375
- statusListResult = await (0, import_ssi_sdk.updateStatusIndexFromStatusListCredential)({
376
- statusListCredential,
377
- statusListIndex: statusListEntry.statusListIndex,
378
- value: parseInt(value),
379
- keyRef: opts.keyRef
380
- }, context);
381
- statusListResult = await driver.updateStatusList({
382
- statusListCredential: statusListResult.statusListCredential
383
- });
384
- }
385
- return sendStatuslistResponse(statusListResult, statusListResult.statusListCredential, response);
386
- } catch (e) {
387
- return (0, import_ssi_express_support.sendErrorResponse)(response, 500, e.message, e);
388
- }
389
- });
390
- }
391
- __name(updateStatusEndpoint, "updateStatusEndpoint");
392
-
393
- // src/statuslist-management-api-server.ts
394
- var StatuslistManagementApiServer = class {
395
- static {
396
- __name(this, "StatuslistManagementApiServer");
397
- }
398
- get router() {
399
- return this._router;
400
- }
401
- _express;
402
- _agent;
403
- _opts;
404
- _router;
405
- constructor(args) {
406
- const { agent, opts } = args;
407
- this._agent = agent;
408
- if (opts?.endpointOpts?.globalAuth) {
409
- (0, import_ssi_express_support2.copyGlobalAuthToEndpoint)({
410
- opts,
411
- key: "vcApiCredentialStatus"
412
- });
413
- (0, import_ssi_express_support2.copyGlobalAuthToEndpoint)({
414
- opts,
415
- key: "createStatusList"
416
- });
417
- (0, import_ssi_express_support2.copyGlobalAuthToEndpoint)({
418
- opts,
419
- key: "getStatusList"
420
- });
421
- }
422
- this._opts = opts;
423
- this._express = args.expressSupport.express;
424
- this._router = import_express.default.Router();
425
- const context = (0, import_ssi_sdk3.agentContext)(agent);
426
- const features = opts?.enableFeatures ?? [
427
- "status-list-management",
428
- "status-list-hosting",
429
- "w3c-vc-api-credential-status"
430
- ];
431
- console.log(`Status List API enabled, with features: ${JSON.stringify(features)}`);
432
- if (features.includes("status-list-management")) {
433
- createNewStatusListEndpoint(this.router, context, opts.endpointOpts.createStatusList);
434
- }
435
- if (features.includes("status-list-hosting")) {
436
- getStatusListCredentialEndpoint(this.router, context, opts.endpointOpts.getStatusList);
437
- getStatusListCredentialIndexStatusEndpoint(this.router, context, opts.endpointOpts.getStatusList);
438
- getStatusListCredentialIndexStatusEndpointLegacy(this.router, context, opts.endpointOpts.getStatusList);
439
- }
440
- if (features.includes("w3c-vc-api-credential-status")) {
441
- updateStatusEndpoint(this.router, context, opts.endpointOpts.vcApiCredentialStatus);
442
- }
443
- this._express.use(opts?.endpointOpts?.basePath ?? "", this.router);
444
- }
445
- get agent() {
446
- return this._agent;
447
- }
448
- get opts() {
449
- return this._opts;
450
- }
451
- get express() {
452
- return this._express;
453
- }
454
- };
455
- //# sourceMappingURL=index.cjs.map