@sphereon/ssi-sdk.siopv2-oid4vp-rp-rest-api 0.34.1-feature.SSISDK.45.93 → 0.34.1-feature.SSISDK.46.151
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +207 -123
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +92 -6
- package/dist/index.d.ts +92 -6
- package/dist/index.js +203 -119
- package/dist/index.js.map +1 -1
- package/package.json +21 -18
- package/src/index.ts +1 -1
- package/src/middleware/validationMiddleware.ts +20 -0
- package/src/schemas/index.ts +51 -0
- package/src/siop-api-functions.ts +11 -13
- package/src/siopv2-rp-api-server.ts +7 -7
- package/src/types/types.ts +68 -1
- package/src/universal-oid4vp-api-functions.ts +171 -0
- package/src/webapp-api-functions.ts +0 -183
package/dist/index.cjs
CHANGED
|
@@ -32,11 +32,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
32
32
|
var index_exports = {};
|
|
33
33
|
__export(index_exports, {
|
|
34
34
|
SIOPv2RPApiServer: () => SIOPv2RPApiServer,
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
authStatusUniversalOID4VPEndpoint: () => authStatusUniversalOID4VPEndpoint,
|
|
36
|
+
createAuthRequestUniversalOID4VPEndpoint: () => createAuthRequestUniversalOID4VPEndpoint,
|
|
37
37
|
getAuthRequestSIOPv2Endpoint: () => getAuthRequestSIOPv2Endpoint,
|
|
38
38
|
getDefinitionsEndpoint: () => getDefinitionsEndpoint,
|
|
39
|
-
|
|
39
|
+
removeAuthRequestStateUniversalOID4VPEndpoint: () => removeAuthRequestStateUniversalOID4VPEndpoint,
|
|
40
40
|
verifyAuthResponseSIOPv2Endpoint: () => verifyAuthResponseSIOPv2Endpoint
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -74,7 +74,7 @@ function verifyAuthResponseSIOPv2Endpoint(router, context, opts) {
|
|
|
74
74
|
const path = opts?.path ?? "/siop/definitions/:definitionId/auth-responses/:correlationId";
|
|
75
75
|
router.post(path, (0, import_ssi_express_support.checkAuth)(opts?.endpoint), async (request, response) => {
|
|
76
76
|
try {
|
|
77
|
-
const { correlationId, definitionId, tenantId, version
|
|
77
|
+
const { correlationId, definitionId, tenantId, version } = request.params;
|
|
78
78
|
if (!correlationId || !definitionId) {
|
|
79
79
|
console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, definitionId: ${definitionId}`);
|
|
80
80
|
return (0, import_ssi_express_support.sendErrorResponse)(response, 404, "No authorization request could be found");
|
|
@@ -102,12 +102,11 @@ function verifyAuthResponseSIOPv2Endpoint(router, context, opts) {
|
|
|
102
102
|
const verifiedResponse = await context.agent.siopVerifyAuthResponse({
|
|
103
103
|
authorizationResponse,
|
|
104
104
|
correlationId,
|
|
105
|
-
|
|
106
|
-
dcqlQuery: definitionItem.dcqlPayload
|
|
105
|
+
dcqlQueryPayload: definitionItem.dcqlPayload
|
|
107
106
|
});
|
|
108
|
-
const
|
|
109
|
-
if (
|
|
110
|
-
console.log("
|
|
107
|
+
const presentation = verifiedResponse?.oid4vpSubmission?.presentation;
|
|
108
|
+
if (presentation && Object.keys(presentation).length > 0) {
|
|
109
|
+
console.log("PRESENTATIONS:" + JSON.stringify(verifiedResponse?.oid4vpSubmission?.presentation, null, 2));
|
|
111
110
|
response.statusCode = 200;
|
|
112
111
|
const authorizationChallengeValidationResponse = {
|
|
113
112
|
presentation_during_issuance_session: verifiedResponse.correlationId
|
|
@@ -118,7 +117,7 @@ function verifyAuthResponseSIOPv2Endpoint(router, context, opts) {
|
|
|
118
117
|
}
|
|
119
118
|
const responseRedirectURI = await context.agent.siopGetRedirectURI({
|
|
120
119
|
correlationId,
|
|
121
|
-
definitionId,
|
|
120
|
+
queryId: definitionId,
|
|
122
121
|
state: verifiedResponse.state
|
|
123
122
|
});
|
|
124
123
|
if (responseRedirectURI) {
|
|
@@ -156,7 +155,7 @@ function getAuthRequestSIOPv2Endpoint(router, context, opts) {
|
|
|
156
155
|
}
|
|
157
156
|
const requestState = await context.agent.siopGetAuthRequestState({
|
|
158
157
|
correlationId,
|
|
159
|
-
definitionId,
|
|
158
|
+
queryId: definitionId,
|
|
160
159
|
errorOnNotFound: false
|
|
161
160
|
});
|
|
162
161
|
if (!requestState) {
|
|
@@ -177,8 +176,8 @@ function getAuthRequestSIOPv2Endpoint(router, context, opts) {
|
|
|
177
176
|
} finally {
|
|
178
177
|
await context.agent.siopUpdateAuthRequestState({
|
|
179
178
|
correlationId,
|
|
180
|
-
definitionId,
|
|
181
|
-
state: "
|
|
179
|
+
queryId: definitionId,
|
|
180
|
+
state: "authorization_request_created",
|
|
182
181
|
error
|
|
183
182
|
});
|
|
184
183
|
}
|
|
@@ -189,45 +188,132 @@ function getAuthRequestSIOPv2Endpoint(router, context, opts) {
|
|
|
189
188
|
}
|
|
190
189
|
__name(getAuthRequestSIOPv2Endpoint, "getAuthRequestSIOPv2Endpoint");
|
|
191
190
|
|
|
192
|
-
// src/
|
|
193
|
-
var
|
|
191
|
+
// src/universal-oid4vp-api-functions.ts
|
|
192
|
+
var import_did_auth_siop2 = require("@sphereon/did-auth-siop");
|
|
194
193
|
var import_ssi_express_support2 = require("@sphereon/ssi-express-support");
|
|
195
|
-
var
|
|
196
|
-
var import_ssi_sdk2 = require("@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth");
|
|
194
|
+
var import_ssi_sdk2 = require("@sphereon/ssi-sdk.siopv2-oid4vp-common");
|
|
197
195
|
var import_short_uuid = __toESM(require("short-uuid"), 1);
|
|
198
|
-
|
|
199
|
-
|
|
196
|
+
|
|
197
|
+
// src/middleware/validationMiddleware.ts
|
|
198
|
+
var import_zod = require("zod");
|
|
199
|
+
var validateData = /* @__PURE__ */ __name((schema) => {
|
|
200
|
+
return (req, res, next) => {
|
|
201
|
+
try {
|
|
202
|
+
schema.parse(req.body);
|
|
203
|
+
next();
|
|
204
|
+
} catch (error) {
|
|
205
|
+
if (error instanceof import_zod.ZodError) {
|
|
206
|
+
const errorMessages = error.issues.map((issue) => ({
|
|
207
|
+
message: `${issue.path.join(".")} is ${issue.message}`
|
|
208
|
+
}));
|
|
209
|
+
res.status(400).json({
|
|
210
|
+
status: 400,
|
|
211
|
+
message: "Invalid data",
|
|
212
|
+
error_details: errorMessages[0].message
|
|
213
|
+
});
|
|
214
|
+
} else {
|
|
215
|
+
res.status(500).json({
|
|
216
|
+
status: 500,
|
|
217
|
+
message: "Internal Server Error"
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
}, "validateData");
|
|
223
|
+
|
|
224
|
+
// src/schemas/index.ts
|
|
225
|
+
var import_zod2 = require("zod");
|
|
226
|
+
var import_ssi_sdk = require("@sphereon/ssi-sdk.siopv2-oid4vp-common");
|
|
227
|
+
var import_did_auth_siop = require("@sphereon/did-auth-siop");
|
|
228
|
+
var ResponseTypeSchema = import_zod2.z.enum([
|
|
229
|
+
import_did_auth_siop.ResponseType.VP_TOKEN
|
|
230
|
+
]);
|
|
231
|
+
var ResponseModeSchema = import_zod2.z.enum([
|
|
232
|
+
import_did_auth_siop.ResponseMode.DIRECT_POST,
|
|
233
|
+
import_did_auth_siop.ResponseMode.DIRECT_POST_JWT
|
|
234
|
+
]);
|
|
235
|
+
var requestUriMethods = [
|
|
236
|
+
"get",
|
|
237
|
+
"post"
|
|
238
|
+
];
|
|
239
|
+
var RequestUriMethodSchema = import_zod2.z.enum(requestUriMethods);
|
|
240
|
+
var AuthorizationStatusSchema = import_zod2.z.enum([
|
|
241
|
+
...import_ssi_sdk.authorizationRequestStatuses,
|
|
242
|
+
...import_ssi_sdk.authorizationResponseStatuses
|
|
243
|
+
]);
|
|
244
|
+
var CallbackOptsSchema = import_zod2.z.object({
|
|
245
|
+
url: import_zod2.z.string(),
|
|
246
|
+
status: import_zod2.z.array(AuthorizationStatusSchema).optional()
|
|
247
|
+
});
|
|
248
|
+
var QRCodeOptsSchema = import_zod2.z.object({
|
|
249
|
+
size: import_zod2.z.number().optional(),
|
|
250
|
+
color_dark: import_zod2.z.string().optional(),
|
|
251
|
+
color_light: import_zod2.z.string().optional()
|
|
252
|
+
});
|
|
253
|
+
var CreateAuthorizationRequestBodySchema = import_zod2.z.object({
|
|
254
|
+
query_id: import_zod2.z.string(),
|
|
255
|
+
client_id: import_zod2.z.string().optional(),
|
|
256
|
+
request_uri_base: import_zod2.z.string().optional(),
|
|
257
|
+
correlation_id: import_zod2.z.string().optional(),
|
|
258
|
+
request_uri_method: RequestUriMethodSchema.optional(),
|
|
259
|
+
response_type: ResponseTypeSchema.optional(),
|
|
260
|
+
response_mode: ResponseModeSchema.optional(),
|
|
261
|
+
transaction_data: import_zod2.z.array(import_zod2.z.string()).optional(),
|
|
262
|
+
qr_code: QRCodeOptsSchema.optional(),
|
|
263
|
+
direct_post_response_redirect_uri: import_zod2.z.string().optional(),
|
|
264
|
+
callback: CallbackOptsSchema.optional()
|
|
265
|
+
});
|
|
266
|
+
var CreateAuthorizationResponseSchema = import_zod2.z.object({
|
|
267
|
+
correlation_id: import_zod2.z.string(),
|
|
268
|
+
query_id: import_zod2.z.string(),
|
|
269
|
+
request_uri: import_zod2.z.string(),
|
|
270
|
+
status_uri: import_zod2.z.string(),
|
|
271
|
+
qr_uri: import_zod2.z.string().optional()
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
// src/universal-oid4vp-api-functions.ts
|
|
275
|
+
function createAuthRequestUniversalOID4VPEndpoint(router, context, opts) {
|
|
200
276
|
if (opts?.enabled === false) {
|
|
201
|
-
console.log(`createAuthRequest
|
|
277
|
+
console.log(`createAuthRequest universal OID4VP endpoint is disabled`);
|
|
202
278
|
return;
|
|
203
279
|
}
|
|
204
|
-
const path = opts?.path ?? "/
|
|
205
|
-
router.post(path, (0, import_ssi_express_support2.checkAuth)(opts?.endpoint), async (request, response) => {
|
|
280
|
+
const path = opts?.path ?? "/backend/auth/requests";
|
|
281
|
+
router.post(path, (0, import_ssi_express_support2.checkAuth)(opts?.endpoint), validateData(CreateAuthorizationRequestBodySchema), async (request, response) => {
|
|
206
282
|
try {
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
283
|
+
const correlationId = request.body.correlation_id ?? import_short_uuid.default.uuid();
|
|
284
|
+
const qrCodeOpts = request.body.qr_code ?? opts?.qrCodeOpts;
|
|
285
|
+
const queryId = request.body.query_id;
|
|
286
|
+
const directPostResponseRedirectUri = request.body.direct_post_response_redirect_uri;
|
|
287
|
+
const requestUriBase = request.body.request_uri_base;
|
|
288
|
+
const definitionItems = await context.agent.pdmGetDefinitions({
|
|
289
|
+
filter: [
|
|
290
|
+
{
|
|
291
|
+
definitionId: queryId
|
|
292
|
+
}
|
|
293
|
+
]
|
|
294
|
+
});
|
|
295
|
+
if (definitionItems.length === 0) {
|
|
296
|
+
console.log(`No query could be found for the given id. Query id: ${queryId}`);
|
|
297
|
+
return (0, import_ssi_express_support2.sendErrorResponse)(response, 404, {
|
|
298
|
+
status: 404,
|
|
299
|
+
message: "No query could be found"
|
|
300
|
+
});
|
|
210
301
|
}
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
const qrCodeOpts = request.body.qrCodeOpts ?? opts?.qrCodeOpts;
|
|
214
|
-
const requestByReferenceURI = (0, import_ssi_sdk.uriWithBase)(`/siop/definitions/${definitionId}/auth-requests/${state}`, {
|
|
215
|
-
baseURI: opts?.siopBaseURI
|
|
302
|
+
const requestByReferenceURI = (0, import_ssi_sdk2.uriWithBase)(`/siop/definitions/${queryId}/auth-requests/${correlationId}`, {
|
|
303
|
+
baseURI: requestUriBase ?? opts?.siopBaseURI
|
|
216
304
|
});
|
|
217
|
-
const responseURI = (0,
|
|
305
|
+
const responseURI = (0, import_ssi_sdk2.uriWithBase)(`/siop/definitions/${queryId}/auth-responses/${correlationId}`, {
|
|
218
306
|
baseURI: opts?.siopBaseURI
|
|
219
307
|
});
|
|
220
|
-
const responseRedirectURI = ("response_redirect_uri" in request.body && request.body.response_redirect_uri) ?? ("responseRedirectURI" in request.body && request.body.responseRedirectURI);
|
|
221
308
|
const authRequestURI = await context.agent.siopCreateAuthRequestURI({
|
|
222
|
-
|
|
309
|
+
queryId,
|
|
223
310
|
correlationId,
|
|
224
|
-
state,
|
|
225
311
|
nonce: import_short_uuid.default.uuid(),
|
|
226
312
|
requestByReferenceURI,
|
|
227
313
|
responseURIType: "response_uri",
|
|
228
314
|
responseURI,
|
|
229
|
-
...
|
|
230
|
-
responseRedirectURI
|
|
315
|
+
...directPostResponseRedirectUri && {
|
|
316
|
+
responseRedirectURI: directPostResponseRedirectUri
|
|
231
317
|
}
|
|
232
318
|
});
|
|
233
319
|
let qrCodeDataUri;
|
|
@@ -240,140 +326,138 @@ function createAuthRequestWebappEndpoint(router, context, opts) {
|
|
|
240
326
|
qrCodeDataUri = `data:image/png;base64,${(await qrCode.draw()).toString("base64")}`;
|
|
241
327
|
}
|
|
242
328
|
const authRequestBody = {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
authStatusURI: `${(0, import_ssi_sdk.uriWithBase)(opts?.webappAuthStatusPath ?? "/webapp/auth-status", {
|
|
329
|
+
query_id: queryId,
|
|
330
|
+
correlation_id: correlationId,
|
|
331
|
+
request_uri: authRequestURI,
|
|
332
|
+
status_uri: `${(0, import_ssi_sdk2.uriWithBase)(opts?.webappAuthStatusPath ?? `/backend/auth/status/${correlationId}`, {
|
|
248
333
|
baseURI: opts?.webappBaseURI
|
|
249
334
|
})}`,
|
|
250
335
|
...qrCodeDataUri && {
|
|
251
|
-
qrCodeDataUri
|
|
336
|
+
qr_uri: qrCodeDataUri
|
|
252
337
|
}
|
|
253
338
|
};
|
|
254
339
|
console.log(`Auth Request URI data to send back: ${JSON.stringify(authRequestBody)}`);
|
|
255
|
-
return response.json(authRequestBody);
|
|
340
|
+
return response.status(201).json(authRequestBody);
|
|
256
341
|
} catch (error) {
|
|
257
|
-
return (0, import_ssi_express_support2.sendErrorResponse)(response, 500,
|
|
342
|
+
return (0, import_ssi_express_support2.sendErrorResponse)(response, 500, {
|
|
343
|
+
status: 500,
|
|
344
|
+
message: "Could not create an authorization request URI"
|
|
345
|
+
}, error);
|
|
258
346
|
}
|
|
259
347
|
});
|
|
260
348
|
}
|
|
261
|
-
__name(
|
|
262
|
-
function
|
|
349
|
+
__name(createAuthRequestUniversalOID4VPEndpoint, "createAuthRequestUniversalOID4VPEndpoint");
|
|
350
|
+
function removeAuthRequestStateUniversalOID4VPEndpoint(router, context, opts) {
|
|
263
351
|
if (opts?.enabled === false) {
|
|
264
|
-
console.log(`
|
|
352
|
+
console.log(`removeAuthStatus universal OID4VP endpoint is disabled`);
|
|
265
353
|
return;
|
|
266
354
|
}
|
|
267
|
-
const path = opts?.path ?? "/
|
|
268
|
-
router.
|
|
355
|
+
const path = opts?.path ?? "/backend/auth/requests/:correlationId";
|
|
356
|
+
router.delete(path, (0, import_ssi_express_support2.checkAuth)(opts?.endpoint), async (request, response) => {
|
|
269
357
|
try {
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
const definitionId = request.body.definitionId;
|
|
273
|
-
const requestState = correlationId && definitionId ? await context.agent.siopGetAuthRequestState({
|
|
358
|
+
const correlationId = request.params.correlationId;
|
|
359
|
+
const authRequestState = await context.agent.siopGetAuthRequestState({
|
|
274
360
|
correlationId,
|
|
275
|
-
definitionId,
|
|
276
361
|
errorOnNotFound: false
|
|
277
|
-
})
|
|
278
|
-
if (!
|
|
279
|
-
console.log(`No
|
|
280
|
-
response
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
correlationId,
|
|
285
|
-
definitionId,
|
|
286
|
-
lastUpdated: requestState ? requestState.lastUpdated : Date.now()
|
|
287
|
-
};
|
|
288
|
-
return response.json(statusBody2);
|
|
362
|
+
});
|
|
363
|
+
if (!authRequestState) {
|
|
364
|
+
console.log(`No authorization request could be found for the given correlationId. correlationId: ${correlationId}`);
|
|
365
|
+
return (0, import_ssi_express_support2.sendErrorResponse)(response, 404, {
|
|
366
|
+
status: 404,
|
|
367
|
+
message: "No authorization request could be found"
|
|
368
|
+
});
|
|
289
369
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
370
|
+
await context.agent.siopDeleteAuthState({
|
|
371
|
+
correlationId
|
|
372
|
+
});
|
|
373
|
+
return response.status(204).json();
|
|
374
|
+
} catch (error) {
|
|
375
|
+
return (0, import_ssi_express_support2.sendErrorResponse)(response, 500, {
|
|
376
|
+
status: 500,
|
|
377
|
+
message: error.message
|
|
378
|
+
}, error);
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
__name(removeAuthRequestStateUniversalOID4VPEndpoint, "removeAuthRequestStateUniversalOID4VPEndpoint");
|
|
383
|
+
function authStatusUniversalOID4VPEndpoint(router, context, opts) {
|
|
384
|
+
if (opts?.enabled === false) {
|
|
385
|
+
console.log(`authStatus universal OID4VP endpoint is disabled`);
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
const path = opts?.path ?? "/backend/auth/status/:correlationId";
|
|
389
|
+
router.get(path, (0, import_ssi_express_support2.checkAuth)(opts?.endpoint), async (request, response) => {
|
|
390
|
+
try {
|
|
391
|
+
console.log("Received auth-status request...");
|
|
392
|
+
const correlationId = request.params.correlationId;
|
|
393
|
+
const requestState = await context.agent.siopGetAuthRequestState({
|
|
394
|
+
correlationId,
|
|
395
|
+
errorOnNotFound: false
|
|
396
|
+
});
|
|
397
|
+
if (!requestState) {
|
|
398
|
+
console.log(`No authorization request could be found for the given correlationId. correlationId: ${correlationId}`);
|
|
399
|
+
return (0, import_ssi_express_support2.sendErrorResponse)(response, 404, {
|
|
400
|
+
status: 404,
|
|
401
|
+
message: "No authorization request could be found"
|
|
402
|
+
});
|
|
293
403
|
}
|
|
294
404
|
let responseState;
|
|
295
|
-
if (requestState.status === "
|
|
405
|
+
if (requestState.status === "authorization_request_created") {
|
|
296
406
|
responseState = await context.agent.siopGetAuthResponseState({
|
|
297
407
|
correlationId,
|
|
298
|
-
definitionId,
|
|
299
|
-
includeVerifiedData,
|
|
300
408
|
errorOnNotFound: false
|
|
301
409
|
});
|
|
302
410
|
}
|
|
303
411
|
const overallState = responseState ?? requestState;
|
|
304
412
|
const statusBody = {
|
|
305
413
|
status: overallState.status,
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
...
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}),
|
|
316
|
-
verifiedData: responseState.verifiedData
|
|
317
|
-
} : {}
|
|
414
|
+
correlation_id: overallState.correlationId,
|
|
415
|
+
query_id: overallState.queryId,
|
|
416
|
+
last_updated: overallState.lastUpdated,
|
|
417
|
+
...responseState?.status === import_did_auth_siop2.AuthorizationResponseStateStatus.VERIFIED && responseState.verifiedData !== void 0 && {
|
|
418
|
+
verified_data: responseState.verifiedData
|
|
419
|
+
},
|
|
420
|
+
...overallState.error && {
|
|
421
|
+
message: overallState.error.message
|
|
422
|
+
}
|
|
318
423
|
};
|
|
319
424
|
console.debug(`Will send auth status: ${JSON.stringify(statusBody)}`);
|
|
320
425
|
if (overallState.status === "error") {
|
|
321
|
-
response.
|
|
322
|
-
return response.json(statusBody);
|
|
426
|
+
return response.status(500).json(statusBody);
|
|
323
427
|
}
|
|
324
|
-
response.
|
|
325
|
-
return response.json(statusBody);
|
|
428
|
+
return response.status(200).json(statusBody);
|
|
326
429
|
} catch (error) {
|
|
327
|
-
return (0, import_ssi_express_support2.sendErrorResponse)(response, 500,
|
|
430
|
+
return (0, import_ssi_express_support2.sendErrorResponse)(response, 500, {
|
|
431
|
+
status: 500,
|
|
432
|
+
message: error.message
|
|
433
|
+
}, error);
|
|
328
434
|
}
|
|
329
435
|
});
|
|
330
436
|
}
|
|
331
|
-
__name(
|
|
332
|
-
function removeAuthRequestStateWebappEndpoint(router, context, opts) {
|
|
333
|
-
if (opts?.enabled === false) {
|
|
334
|
-
console.log(`removeAuthStatus Webapp endpoint is disabled`);
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
const path = opts?.path ?? "/webapp/definitions/:definitionId/auth-requests/:correlationId";
|
|
338
|
-
router.delete(path, (0, import_ssi_express_support2.checkAuth)(opts?.endpoint), async (request, response) => {
|
|
339
|
-
try {
|
|
340
|
-
const correlationId = request.params.correlationId;
|
|
341
|
-
const definitionId = request.params.definitionId;
|
|
342
|
-
if (!correlationId || !definitionId) {
|
|
343
|
-
console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, definitionId: ${definitionId}`);
|
|
344
|
-
return (0, import_ssi_express_support2.sendErrorResponse)(response, 404, "No authorization request could be found");
|
|
345
|
-
}
|
|
346
|
-
response.statusCode = 200;
|
|
347
|
-
return response.json(await context.agent.siopDeleteAuthState({
|
|
348
|
-
definitionId,
|
|
349
|
-
correlationId
|
|
350
|
-
}));
|
|
351
|
-
} catch (error) {
|
|
352
|
-
return (0, import_ssi_express_support2.sendErrorResponse)(response, 500, error.message, error);
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
__name(removeAuthRequestStateWebappEndpoint, "removeAuthRequestStateWebappEndpoint");
|
|
437
|
+
__name(authStatusUniversalOID4VPEndpoint, "authStatusUniversalOID4VPEndpoint");
|
|
357
438
|
function getDefinitionsEndpoint(router, context, opts) {
|
|
358
439
|
if (opts?.enabled === false) {
|
|
359
|
-
console.log(`getDefinitions
|
|
440
|
+
console.log(`getDefinitions universal OID4VP endpoint is disabled`);
|
|
360
441
|
return;
|
|
361
442
|
}
|
|
362
|
-
const path = opts?.path ?? "/
|
|
443
|
+
const path = opts?.path ?? "/backend/definitions";
|
|
363
444
|
router.get(path, (0, import_ssi_express_support2.checkAuth)(opts?.endpoint), async (request, response) => {
|
|
364
445
|
try {
|
|
365
446
|
const definitions = await context.agent.pdmGetDefinitions();
|
|
366
447
|
response.statusCode = 200;
|
|
367
448
|
return response.json(definitions);
|
|
368
449
|
} catch (error) {
|
|
369
|
-
return (0, import_ssi_express_support2.sendErrorResponse)(response, 500,
|
|
450
|
+
return (0, import_ssi_express_support2.sendErrorResponse)(response, 500, {
|
|
451
|
+
status: 500,
|
|
452
|
+
message: error.message
|
|
453
|
+
}, error);
|
|
370
454
|
}
|
|
371
455
|
});
|
|
372
456
|
}
|
|
373
457
|
__name(getDefinitionsEndpoint, "getDefinitionsEndpoint");
|
|
374
458
|
|
|
375
459
|
// src/siopv2-rp-api-server.ts
|
|
376
|
-
var
|
|
460
|
+
var import_ssi_sdk3 = require("@sphereon/ssi-sdk.core");
|
|
377
461
|
var import_ssi_express_support3 = require("@sphereon/ssi-express-support");
|
|
378
462
|
var import_express = __toESM(require("express"), 1);
|
|
379
463
|
var import_swagger_ui_express = __toESM(require("swagger-ui-express"), 1);
|
|
@@ -410,16 +494,16 @@ var SIOPv2RPApiServer = class {
|
|
|
410
494
|
this._opts = opts;
|
|
411
495
|
this._express = args.expressSupport.express;
|
|
412
496
|
this._router = import_express.default.Router();
|
|
413
|
-
const context = (0,
|
|
497
|
+
const context = (0, import_ssi_sdk3.agentContext)(agent);
|
|
414
498
|
const features = opts?.enableFeatures ?? [
|
|
415
499
|
"rp-status",
|
|
416
500
|
"siop"
|
|
417
501
|
];
|
|
418
502
|
console.log(`SIOPv2 API enabled, with features: ${JSON.stringify(features)}}`);
|
|
419
503
|
if (features.includes("rp-status")) {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
504
|
+
createAuthRequestUniversalOID4VPEndpoint(this._router, context, opts?.endpointOpts?.webappCreateAuthRequest);
|
|
505
|
+
authStatusUniversalOID4VPEndpoint(this._router, context, opts?.endpointOpts?.webappAuthStatus);
|
|
506
|
+
removeAuthRequestStateUniversalOID4VPEndpoint(this._router, context, opts?.endpointOpts?.webappDeleteAuthRequest);
|
|
423
507
|
getDefinitionsEndpoint(this._router, context, opts?.endpointOpts?.webappGetDefinitions);
|
|
424
508
|
}
|
|
425
509
|
if (features.includes("siop")) {
|