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