@sphereon/ssi-sdk.siopv2-oid4vp-rp-rest-api 0.34.1-feature.SSISDK.58.host.nonce.endpoint.145 → 0.34.1-feature.SSISDK.62.218
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 +186 -133
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -9
- package/dist/index.d.ts +49 -9
- package/dist/index.js +185 -132
- 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/siop-api-functions.ts +31 -20
- package/src/siopv2-rp-api-server.ts +9 -10
- package/src/types/types.ts +60 -3
- package/src/universal-oid4vp-api-functions.ts +195 -0
- package/src/webapp-api-functions.ts +26 -28
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);
|
|
@@ -71,29 +71,36 @@ function verifyAuthResponseSIOPv2Endpoint(router, context, opts) {
|
|
|
71
71
|
console.log(`verifyAuthResponse SIOP endpoint is disabled`);
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
const path = opts?.path ?? "/siop/
|
|
74
|
+
const path = opts?.path ?? "/siop/queries/:queryId/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,
|
|
78
|
-
if (!correlationId
|
|
79
|
-
console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}
|
|
77
|
+
const { correlationId, queryId, tenantId, version } = request.params;
|
|
78
|
+
if (!correlationId) {
|
|
79
|
+
console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}`);
|
|
80
80
|
return (0, import_ssi_express_support.sendErrorResponse)(response, 404, "No authorization request could be found");
|
|
81
81
|
}
|
|
82
|
-
console.
|
|
83
|
-
console.
|
|
82
|
+
console.debug("Authorization Response (siop-sessions");
|
|
83
|
+
console.debug(JSON.stringify(request.body, null, 2));
|
|
84
84
|
const definitionItems = await context.agent.pdmGetDefinitions({
|
|
85
85
|
filter: [
|
|
86
86
|
{
|
|
87
|
-
|
|
88
|
-
tenantId
|
|
89
|
-
|
|
87
|
+
queryId,
|
|
88
|
+
...tenantId && {
|
|
89
|
+
tenantId
|
|
90
|
+
},
|
|
91
|
+
...version && {
|
|
92
|
+
version
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: queryId
|
|
90
97
|
}
|
|
91
98
|
]
|
|
92
99
|
});
|
|
93
100
|
if (definitionItems.length === 0) {
|
|
94
|
-
console.log(`Could not get
|
|
101
|
+
console.log(`Could not get dcql query with id ${queryId} from agent. Will return 404`);
|
|
95
102
|
response.statusCode = 404;
|
|
96
|
-
response.statusMessage = `No definition ${
|
|
103
|
+
response.statusMessage = `No definition ${queryId}`;
|
|
97
104
|
return response.send();
|
|
98
105
|
}
|
|
99
106
|
const authorizationResponse = parseAuthorizationResponse(request);
|
|
@@ -102,8 +109,8 @@ function verifyAuthResponseSIOPv2Endpoint(router, context, opts) {
|
|
|
102
109
|
const verifiedResponse = await context.agent.siopVerifyAuthResponse({
|
|
103
110
|
authorizationResponse,
|
|
104
111
|
correlationId,
|
|
105
|
-
|
|
106
|
-
|
|
112
|
+
queryId,
|
|
113
|
+
dcqlQuery: definitionItem.query
|
|
107
114
|
});
|
|
108
115
|
const presentation = verifiedResponse?.oid4vpSubmission?.presentation;
|
|
109
116
|
if (presentation && Object.keys(presentation).length > 0) {
|
|
@@ -118,7 +125,7 @@ function verifyAuthResponseSIOPv2Endpoint(router, context, opts) {
|
|
|
118
125
|
}
|
|
119
126
|
const responseRedirectURI = await context.agent.siopGetRedirectURI({
|
|
120
127
|
correlationId,
|
|
121
|
-
|
|
128
|
+
queryId,
|
|
122
129
|
state: verifiedResponse.state
|
|
123
130
|
});
|
|
124
131
|
if (responseRedirectURI) {
|
|
@@ -145,22 +152,22 @@ function getAuthRequestSIOPv2Endpoint(router, context, opts) {
|
|
|
145
152
|
console.log(`getAuthRequest SIOP endpoint is disabled`);
|
|
146
153
|
return;
|
|
147
154
|
}
|
|
148
|
-
const path = opts?.path ?? "/siop/
|
|
155
|
+
const path = opts?.path ?? "/siop/queries/:queryId/auth-requests/:correlationId";
|
|
149
156
|
router.get(path, (0, import_ssi_express_support.checkAuth)(opts?.endpoint), async (request, response) => {
|
|
150
157
|
try {
|
|
151
158
|
const correlationId = request.params.correlationId;
|
|
152
|
-
const
|
|
153
|
-
if (!correlationId || !
|
|
154
|
-
console.log(`No authorization request could be found for the given url. correlationId: ${correlationId},
|
|
159
|
+
const queryId = request.params.queryId;
|
|
160
|
+
if (!correlationId || !queryId) {
|
|
161
|
+
console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, queryId: ${queryId}`);
|
|
155
162
|
return (0, import_ssi_express_support.sendErrorResponse)(response, 404, "No authorization request could be found");
|
|
156
163
|
}
|
|
157
164
|
const requestState = await context.agent.siopGetAuthRequestState({
|
|
158
165
|
correlationId,
|
|
159
|
-
|
|
166
|
+
queryId,
|
|
160
167
|
errorOnNotFound: false
|
|
161
168
|
});
|
|
162
169
|
if (!requestState) {
|
|
163
|
-
console.log(`No authorization request could be found for the given url in the state manager. correlationId: ${correlationId}, definitionId: ${
|
|
170
|
+
console.log(`No authorization request could be found for the given url in the state manager. correlationId: ${correlationId}, definitionId: ${queryId}`);
|
|
164
171
|
return (0, import_ssi_express_support.sendErrorResponse)(response, 404, `No authorization request could be found`);
|
|
165
172
|
}
|
|
166
173
|
const requestObject = await requestState.request?.requestObject?.toJwt();
|
|
@@ -177,8 +184,8 @@ function getAuthRequestSIOPv2Endpoint(router, context, opts) {
|
|
|
177
184
|
} finally {
|
|
178
185
|
await context.agent.siopUpdateAuthRequestState({
|
|
179
186
|
correlationId,
|
|
180
|
-
|
|
181
|
-
state: "
|
|
187
|
+
queryId,
|
|
188
|
+
state: "authorization_request_created",
|
|
182
189
|
error
|
|
183
190
|
});
|
|
184
191
|
}
|
|
@@ -189,45 +196,90 @@ function getAuthRequestSIOPv2Endpoint(router, context, opts) {
|
|
|
189
196
|
}
|
|
190
197
|
__name(getAuthRequestSIOPv2Endpoint, "getAuthRequestSIOPv2Endpoint");
|
|
191
198
|
|
|
192
|
-
// src/
|
|
199
|
+
// src/universal-oid4vp-api-functions.ts
|
|
193
200
|
var import_did_auth_siop = require("@sphereon/did-auth-siop");
|
|
194
201
|
var import_ssi_express_support2 = require("@sphereon/ssi-express-support");
|
|
195
202
|
var import_ssi_sdk = require("@sphereon/ssi-sdk.siopv2-oid4vp-common");
|
|
196
203
|
var import_ssi_sdk2 = require("@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth");
|
|
197
204
|
var import_short_uuid = __toESM(require("short-uuid"), 1);
|
|
198
|
-
|
|
199
|
-
|
|
205
|
+
|
|
206
|
+
// src/middleware/validationMiddleware.ts
|
|
207
|
+
var import_zod = require("zod");
|
|
208
|
+
var validateData = /* @__PURE__ */ __name((schema) => {
|
|
209
|
+
return (req, res, next) => {
|
|
210
|
+
try {
|
|
211
|
+
schema.parse(req.body);
|
|
212
|
+
next();
|
|
213
|
+
} catch (error) {
|
|
214
|
+
if (error instanceof import_zod.ZodError) {
|
|
215
|
+
const errorMessages = error.issues.map((issue) => ({
|
|
216
|
+
message: `${issue.path.join(".")} is ${issue.message}`
|
|
217
|
+
}));
|
|
218
|
+
res.status(400).json({
|
|
219
|
+
status: 400,
|
|
220
|
+
message: "Invalid data",
|
|
221
|
+
error_details: errorMessages[0].message
|
|
222
|
+
});
|
|
223
|
+
} else {
|
|
224
|
+
res.status(500).json({
|
|
225
|
+
status: 500,
|
|
226
|
+
message: "Internal Server Error"
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
}, "validateData");
|
|
232
|
+
|
|
233
|
+
// src/universal-oid4vp-api-functions.ts
|
|
234
|
+
function createAuthRequestUniversalOID4VPEndpoint(router, context, opts) {
|
|
200
235
|
if (opts?.enabled === false) {
|
|
201
|
-
console.log(`createAuthRequest
|
|
236
|
+
console.log(`createAuthRequest universal OID4VP endpoint is disabled`);
|
|
202
237
|
return;
|
|
203
238
|
}
|
|
204
|
-
const path = opts?.path ?? "/
|
|
205
|
-
router.post(path, (0, import_ssi_express_support2.checkAuth)(opts?.endpoint), async (request, response) => {
|
|
239
|
+
const path = opts?.path ?? "/backend/auth/requests";
|
|
240
|
+
router.post(path, (0, import_ssi_express_support2.checkAuth)(opts?.endpoint), validateData(import_did_auth_siop.CreateAuthorizationRequestPayloadSchema), async (request, response) => {
|
|
206
241
|
try {
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
242
|
+
const authRequest = (0, import_did_auth_siop.createAuthorizationRequestFromPayload)(request.body);
|
|
243
|
+
const correlationId = authRequest.correlationId ?? import_short_uuid.default.uuid();
|
|
244
|
+
const qrCodeOpts = authRequest.qrCode ? {
|
|
245
|
+
...authRequest.qrCode
|
|
246
|
+
} : opts?.qrCodeOpts;
|
|
247
|
+
const queryId = authRequest.queryId;
|
|
248
|
+
const definitionItems = await context.agent.pdmGetDefinitions({
|
|
249
|
+
filter: [
|
|
250
|
+
{
|
|
251
|
+
id: queryId
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
queryId
|
|
255
|
+
}
|
|
256
|
+
]
|
|
257
|
+
});
|
|
258
|
+
if (definitionItems.length === 0) {
|
|
259
|
+
console.log(`No query could be found for the given id. Query id: ${queryId}`);
|
|
260
|
+
return (0, import_ssi_express_support2.sendErrorResponse)(response, 404, {
|
|
261
|
+
status: 404,
|
|
262
|
+
message: "No query could be found"
|
|
263
|
+
});
|
|
210
264
|
}
|
|
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
|
|
265
|
+
const requestByReferenceURI = (0, import_ssi_sdk.uriWithBase)(`/siop/queries/${queryId}/auth-requests/${correlationId}`, {
|
|
266
|
+
baseURI: authRequest.requestUriBase ?? opts?.siopBaseURI
|
|
216
267
|
});
|
|
217
|
-
const responseURI = (0, import_ssi_sdk.uriWithBase)(`/siop/
|
|
268
|
+
const responseURI = (0, import_ssi_sdk.uriWithBase)(`/siop/queries/${queryId}/auth-responses/${correlationId}`, {
|
|
218
269
|
baseURI: opts?.siopBaseURI
|
|
219
270
|
});
|
|
220
|
-
const responseRedirectURI = ("response_redirect_uri" in request.body && request.body.response_redirect_uri) ?? ("responseRedirectURI" in request.body && request.body.responseRedirectURI);
|
|
221
271
|
const authRequestURI = await context.agent.siopCreateAuthRequestURI({
|
|
222
|
-
|
|
272
|
+
queryId,
|
|
223
273
|
correlationId,
|
|
224
|
-
state,
|
|
225
274
|
nonce: import_short_uuid.default.uuid(),
|
|
226
275
|
requestByReferenceURI,
|
|
227
276
|
responseURIType: "response_uri",
|
|
228
277
|
responseURI,
|
|
229
|
-
...
|
|
230
|
-
responseRedirectURI
|
|
278
|
+
...authRequest.directPostResponseRedirectUri && {
|
|
279
|
+
responseRedirectURI: authRequest.directPostResponseRedirectUri
|
|
280
|
+
},
|
|
281
|
+
...authRequest.callback && {
|
|
282
|
+
callback: authRequest.callback
|
|
231
283
|
}
|
|
232
284
|
});
|
|
233
285
|
let qrCodeDataUri;
|
|
@@ -238,142 +290,143 @@ function createAuthRequestWebappEndpoint(router, context, opts) {
|
|
|
238
290
|
text: authRequestURI
|
|
239
291
|
});
|
|
240
292
|
qrCodeDataUri = `data:image/png;base64,${(await qrCode.draw()).toString("base64")}`;
|
|
293
|
+
} else {
|
|
294
|
+
qrCodeDataUri = authRequestURI;
|
|
241
295
|
}
|
|
242
296
|
const authRequestBody = {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
authStatusURI: `${(0, import_ssi_sdk.uriWithBase)(opts?.webappAuthStatusPath ?? "/webapp/auth-status", {
|
|
297
|
+
query_id: queryId,
|
|
298
|
+
correlation_id: correlationId,
|
|
299
|
+
request_uri: authRequestURI,
|
|
300
|
+
status_uri: `${(0, import_ssi_sdk.uriWithBase)(opts?.webappAuthStatusPath ?? `/backend/auth/status/${correlationId}`, {
|
|
248
301
|
baseURI: opts?.webappBaseURI
|
|
249
302
|
})}`,
|
|
250
303
|
...qrCodeDataUri && {
|
|
251
|
-
qrCodeDataUri
|
|
304
|
+
qr_uri: qrCodeDataUri
|
|
252
305
|
}
|
|
253
306
|
};
|
|
254
307
|
console.log(`Auth Request URI data to send back: ${JSON.stringify(authRequestBody)}`);
|
|
255
|
-
return response.json(authRequestBody);
|
|
308
|
+
return response.status(201).json(authRequestBody);
|
|
256
309
|
} catch (error) {
|
|
257
|
-
return (0, import_ssi_express_support2.sendErrorResponse)(response, 500,
|
|
310
|
+
return (0, import_ssi_express_support2.sendErrorResponse)(response, 500, {
|
|
311
|
+
status: 500,
|
|
312
|
+
message: "Could not create an authorization request URI"
|
|
313
|
+
}, error);
|
|
258
314
|
}
|
|
259
315
|
});
|
|
260
316
|
}
|
|
261
|
-
__name(
|
|
262
|
-
function
|
|
317
|
+
__name(createAuthRequestUniversalOID4VPEndpoint, "createAuthRequestUniversalOID4VPEndpoint");
|
|
318
|
+
function removeAuthRequestStateUniversalOID4VPEndpoint(router, context, opts) {
|
|
263
319
|
if (opts?.enabled === false) {
|
|
264
|
-
console.log(`
|
|
320
|
+
console.log(`removeAuthStatus universal OID4VP endpoint is disabled`);
|
|
265
321
|
return;
|
|
266
322
|
}
|
|
267
|
-
const path = opts?.path ?? "/
|
|
268
|
-
router.
|
|
323
|
+
const path = opts?.path ?? "/backend/auth/requests/:correlationId";
|
|
324
|
+
router.delete(path, (0, import_ssi_express_support2.checkAuth)(opts?.endpoint), async (request, response) => {
|
|
269
325
|
try {
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
const definitionId = request.body.definitionId;
|
|
273
|
-
const requestState = correlationId && definitionId ? await context.agent.siopGetAuthRequestState({
|
|
326
|
+
const correlationId = request.params.correlationId;
|
|
327
|
+
const authRequestState = await context.agent.siopGetAuthRequestState({
|
|
274
328
|
correlationId,
|
|
275
|
-
definitionId,
|
|
276
329
|
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);
|
|
330
|
+
});
|
|
331
|
+
if (!authRequestState) {
|
|
332
|
+
console.log(`No authorization request could be found for the given correlationId. correlationId: ${correlationId}`);
|
|
333
|
+
return (0, import_ssi_express_support2.sendErrorResponse)(response, 404, {
|
|
334
|
+
status: 404,
|
|
335
|
+
message: "No authorization request could be found"
|
|
336
|
+
});
|
|
289
337
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
338
|
+
await context.agent.siopDeleteAuthState({
|
|
339
|
+
correlationId
|
|
340
|
+
});
|
|
341
|
+
return response.status(204).json();
|
|
342
|
+
} catch (error) {
|
|
343
|
+
return (0, import_ssi_express_support2.sendErrorResponse)(response, 500, {
|
|
344
|
+
status: 500,
|
|
345
|
+
message: error.message
|
|
346
|
+
}, error);
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
__name(removeAuthRequestStateUniversalOID4VPEndpoint, "removeAuthRequestStateUniversalOID4VPEndpoint");
|
|
351
|
+
function authStatusUniversalOID4VPEndpoint(router, context, opts) {
|
|
352
|
+
if (opts?.enabled === false) {
|
|
353
|
+
console.log(`authStatus universal OID4VP endpoint is disabled`);
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
const path = opts?.path ?? "/backend/auth/status/:correlationId";
|
|
357
|
+
router.get(path, (0, import_ssi_express_support2.checkAuth)(opts?.endpoint), async (request, response) => {
|
|
358
|
+
try {
|
|
359
|
+
console.log("Received auth-status request...");
|
|
360
|
+
const correlationId = request.params.correlationId;
|
|
361
|
+
const requestState = await context.agent.siopGetAuthRequestState({
|
|
362
|
+
correlationId,
|
|
363
|
+
errorOnNotFound: false
|
|
364
|
+
});
|
|
365
|
+
if (!requestState) {
|
|
366
|
+
console.log(`No authorization request could be found for the given correlationId. correlationId: ${correlationId}`);
|
|
367
|
+
return (0, import_ssi_express_support2.sendErrorResponse)(response, 404, {
|
|
368
|
+
status: 404,
|
|
369
|
+
message: "No authorization request could be found"
|
|
370
|
+
});
|
|
293
371
|
}
|
|
294
372
|
let responseState;
|
|
295
|
-
if (requestState.status ===
|
|
373
|
+
if (requestState.status === import_did_auth_siop.AuthorizationRequestStateStatus.RETRIEVED) {
|
|
296
374
|
responseState = await context.agent.siopGetAuthResponseState({
|
|
297
375
|
correlationId,
|
|
298
|
-
|
|
299
|
-
includeVerifiedData
|
|
300
|
-
errorOnNotFound: false
|
|
376
|
+
errorOnNotFound: false,
|
|
377
|
+
includeVerifiedData: import_ssi_sdk2.VerifiedDataMode.VERIFIED_PRESENTATION
|
|
301
378
|
});
|
|
302
379
|
}
|
|
303
380
|
const overallState = responseState ?? requestState;
|
|
304
381
|
const statusBody = {
|
|
305
382
|
status: overallState.status,
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
...
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}),
|
|
316
|
-
verifiedData: responseState.verifiedData
|
|
317
|
-
} : {}
|
|
383
|
+
correlation_id: overallState.correlationId,
|
|
384
|
+
query_id: overallState.queryId,
|
|
385
|
+
last_updated: overallState.lastUpdated,
|
|
386
|
+
...responseState?.status === import_did_auth_siop.AuthorizationResponseStateStatus.VERIFIED && responseState.verifiedData !== void 0 && {
|
|
387
|
+
verified_data: responseState.verifiedData
|
|
388
|
+
},
|
|
389
|
+
...overallState.error && {
|
|
390
|
+
message: overallState.error.message
|
|
391
|
+
}
|
|
318
392
|
};
|
|
319
393
|
console.debug(`Will send auth status: ${JSON.stringify(statusBody)}`);
|
|
320
394
|
if (overallState.status === "error") {
|
|
321
|
-
response.
|
|
322
|
-
return response.json(statusBody);
|
|
395
|
+
return response.status(500).json(statusBody);
|
|
323
396
|
}
|
|
324
|
-
response.
|
|
325
|
-
return response.json(statusBody);
|
|
397
|
+
return response.status(200).json(statusBody);
|
|
326
398
|
} catch (error) {
|
|
327
|
-
return (0, import_ssi_express_support2.sendErrorResponse)(response, 500,
|
|
399
|
+
return (0, import_ssi_express_support2.sendErrorResponse)(response, 500, {
|
|
400
|
+
status: 500,
|
|
401
|
+
message: error.message
|
|
402
|
+
}, error);
|
|
328
403
|
}
|
|
329
404
|
});
|
|
330
405
|
}
|
|
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");
|
|
406
|
+
__name(authStatusUniversalOID4VPEndpoint, "authStatusUniversalOID4VPEndpoint");
|
|
357
407
|
function getDefinitionsEndpoint(router, context, opts) {
|
|
358
408
|
if (opts?.enabled === false) {
|
|
359
|
-
console.log(`getDefinitions
|
|
409
|
+
console.log(`getDefinitions universal OID4VP endpoint is disabled`);
|
|
360
410
|
return;
|
|
361
411
|
}
|
|
362
|
-
const path = opts?.path ?? "/
|
|
412
|
+
const path = opts?.path ?? "/backend/definitions";
|
|
363
413
|
router.get(path, (0, import_ssi_express_support2.checkAuth)(opts?.endpoint), async (request, response) => {
|
|
364
414
|
try {
|
|
365
415
|
const definitions = await context.agent.pdmGetDefinitions();
|
|
366
416
|
response.statusCode = 200;
|
|
367
417
|
return response.json(definitions);
|
|
368
418
|
} catch (error) {
|
|
369
|
-
return (0, import_ssi_express_support2.sendErrorResponse)(response, 500,
|
|
419
|
+
return (0, import_ssi_express_support2.sendErrorResponse)(response, 500, {
|
|
420
|
+
status: 500,
|
|
421
|
+
message: error.message
|
|
422
|
+
}, error);
|
|
370
423
|
}
|
|
371
424
|
});
|
|
372
425
|
}
|
|
373
426
|
__name(getDefinitionsEndpoint, "getDefinitionsEndpoint");
|
|
374
427
|
|
|
375
428
|
// src/siopv2-rp-api-server.ts
|
|
376
|
-
var
|
|
429
|
+
var import_ssi_sdk3 = require("@sphereon/ssi-sdk.core");
|
|
377
430
|
var import_ssi_express_support3 = require("@sphereon/ssi-express-support");
|
|
378
431
|
var import_express = __toESM(require("express"), 1);
|
|
379
432
|
var import_swagger_ui_express = __toESM(require("swagger-ui-express"), 1);
|
|
@@ -410,16 +463,16 @@ var SIOPv2RPApiServer = class {
|
|
|
410
463
|
this._opts = opts;
|
|
411
464
|
this._express = args.expressSupport.express;
|
|
412
465
|
this._router = import_express.default.Router();
|
|
413
|
-
const context = (0,
|
|
466
|
+
const context = (0, import_ssi_sdk3.agentContext)(agent);
|
|
414
467
|
const features = opts?.enableFeatures ?? [
|
|
415
468
|
"rp-status",
|
|
416
469
|
"siop"
|
|
417
470
|
];
|
|
418
471
|
console.log(`SIOPv2 API enabled, with features: ${JSON.stringify(features)}}`);
|
|
419
472
|
if (features.includes("rp-status")) {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
473
|
+
createAuthRequestUniversalOID4VPEndpoint(this._router, context, opts?.endpointOpts?.webappCreateAuthRequest);
|
|
474
|
+
authStatusUniversalOID4VPEndpoint(this._router, context, opts?.endpointOpts?.webappAuthStatus);
|
|
475
|
+
removeAuthRequestStateUniversalOID4VPEndpoint(this._router, context, opts?.endpointOpts?.webappDeleteAuthRequest);
|
|
423
476
|
getDefinitionsEndpoint(this._router, context, opts?.endpointOpts?.webappGetDefinitions);
|
|
424
477
|
}
|
|
425
478
|
if (features.includes("siop")) {
|