@sphereon/ssi-sdk.siopv2-oid4vp-rp-rest-api 0.34.1-feature.SSISDK.26.RP.57 → 0.34.1-feature.SSISDK.45.135
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 +198 -131
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +100 -10
- package/dist/index.d.ts +100 -10
- package/dist/index.js +196 -129
- 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 +41 -0
- package/src/siop-api-functions.ts +22 -26
- package/src/siopv2-rp-api-server.ts +7 -7
- package/src/types/types.ts +68 -1
- package/src/universal-oid4vp-api-functions.ts +173 -0
- package/src/webapp-api-functions.ts +0 -183
package/dist/index.js
CHANGED
|
@@ -2,7 +2,6 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
// src/siop-api-functions.ts
|
|
5
|
-
import { PresentationDefinitionLocation } from "@sphereon/did-auth-siop";
|
|
6
5
|
import { checkAuth, sendErrorResponse } from "@sphereon/ssi-express-support";
|
|
7
6
|
import { CredentialMapper } from "@sphereon/ssi-types";
|
|
8
7
|
var parseAuthorizationResponse = /* @__PURE__ */ __name((request) => {
|
|
@@ -35,9 +34,9 @@ function verifyAuthResponseSIOPv2Endpoint(router, context, opts) {
|
|
|
35
34
|
const path = opts?.path ?? "/siop/definitions/:definitionId/auth-responses/:correlationId";
|
|
36
35
|
router.post(path, checkAuth(opts?.endpoint), async (request, response) => {
|
|
37
36
|
try {
|
|
38
|
-
const { correlationId,
|
|
39
|
-
if (!correlationId || !
|
|
40
|
-
console.log(`No authorization request could be found for the given url. correlationId: ${correlationId},
|
|
37
|
+
const { correlationId, tenantId, version, credentialQueryId } = request.params;
|
|
38
|
+
if (!correlationId || !credentialQueryId) {
|
|
39
|
+
console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, credentialQueryId: ${credentialQueryId}`);
|
|
41
40
|
return sendErrorResponse(response, 404, "No authorization request could be found");
|
|
42
41
|
}
|
|
43
42
|
console.log("Authorization Response (siop-sessions");
|
|
@@ -45,16 +44,16 @@ function verifyAuthResponseSIOPv2Endpoint(router, context, opts) {
|
|
|
45
44
|
const definitionItems = await context.agent.pdmGetDefinitions({
|
|
46
45
|
filter: [
|
|
47
46
|
{
|
|
48
|
-
definitionId,
|
|
47
|
+
definitionId: credentialQueryId,
|
|
49
48
|
tenantId,
|
|
50
49
|
version
|
|
51
50
|
}
|
|
52
51
|
]
|
|
53
52
|
});
|
|
54
53
|
if (definitionItems.length === 0) {
|
|
55
|
-
console.log(`Could not get definition ${
|
|
54
|
+
console.log(`Could not get definition ${credentialQueryId} from agent. Will return 404`);
|
|
56
55
|
response.statusCode = 404;
|
|
57
|
-
response.statusMessage = `No definition ${
|
|
56
|
+
response.statusMessage = `No definition ${credentialQueryId}`;
|
|
58
57
|
return response.send();
|
|
59
58
|
}
|
|
60
59
|
const authorizationResponse = parseAuthorizationResponse(request);
|
|
@@ -63,16 +62,10 @@ function verifyAuthResponseSIOPv2Endpoint(router, context, opts) {
|
|
|
63
62
|
const verifiedResponse = await context.agent.siopVerifyAuthResponse({
|
|
64
63
|
authorizationResponse,
|
|
65
64
|
correlationId,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
{
|
|
69
|
-
location: opts?.presentationDefinitionLocation ?? PresentationDefinitionLocation.TOPLEVEL_PRESENTATION_DEF,
|
|
70
|
-
definition: definitionItem.definitionPayload
|
|
71
|
-
}
|
|
72
|
-
],
|
|
73
|
-
dcqlQuery: definitionItem.dcqlPayload
|
|
65
|
+
queryId: credentialQueryId,
|
|
66
|
+
dcqlQueryPayload: definitionItem.dcqlPayload
|
|
74
67
|
});
|
|
75
|
-
const wrappedPresentation = verifiedResponse?.oid4vpSubmission?.
|
|
68
|
+
const wrappedPresentation = verifiedResponse?.oid4vpSubmission?.presentation[credentialQueryId];
|
|
76
69
|
if (wrappedPresentation) {
|
|
77
70
|
console.log("PRESENTATION:" + JSON.stringify(wrappedPresentation.presentation, null, 2));
|
|
78
71
|
response.statusCode = 200;
|
|
@@ -85,7 +78,7 @@ function verifyAuthResponseSIOPv2Endpoint(router, context, opts) {
|
|
|
85
78
|
}
|
|
86
79
|
const responseRedirectURI = await context.agent.siopGetRedirectURI({
|
|
87
80
|
correlationId,
|
|
88
|
-
|
|
81
|
+
queryId: credentialQueryId,
|
|
89
82
|
state: verifiedResponse.state
|
|
90
83
|
});
|
|
91
84
|
if (responseRedirectURI) {
|
|
@@ -123,7 +116,7 @@ function getAuthRequestSIOPv2Endpoint(router, context, opts) {
|
|
|
123
116
|
}
|
|
124
117
|
const requestState = await context.agent.siopGetAuthRequestState({
|
|
125
118
|
correlationId,
|
|
126
|
-
definitionId,
|
|
119
|
+
queryId: definitionId,
|
|
127
120
|
errorOnNotFound: false
|
|
128
121
|
});
|
|
129
122
|
if (!requestState) {
|
|
@@ -144,8 +137,8 @@ function getAuthRequestSIOPv2Endpoint(router, context, opts) {
|
|
|
144
137
|
} finally {
|
|
145
138
|
await context.agent.siopUpdateAuthRequestState({
|
|
146
139
|
correlationId,
|
|
147
|
-
definitionId,
|
|
148
|
-
state: "
|
|
140
|
+
queryId: definitionId,
|
|
141
|
+
state: "authorization_request_created",
|
|
149
142
|
error
|
|
150
143
|
});
|
|
151
144
|
}
|
|
@@ -156,46 +149,122 @@ function getAuthRequestSIOPv2Endpoint(router, context, opts) {
|
|
|
156
149
|
}
|
|
157
150
|
__name(getAuthRequestSIOPv2Endpoint, "getAuthRequestSIOPv2Endpoint");
|
|
158
151
|
|
|
159
|
-
// src/
|
|
152
|
+
// src/universal-oid4vp-api-functions.ts
|
|
160
153
|
import { AuthorizationResponseStateStatus } from "@sphereon/did-auth-siop";
|
|
161
154
|
import { checkAuth as checkAuth2, sendErrorResponse as sendErrorResponse2 } from "@sphereon/ssi-express-support";
|
|
162
155
|
import { uriWithBase } from "@sphereon/ssi-sdk.siopv2-oid4vp-common";
|
|
163
|
-
import { VerifiedDataMode } from "@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth";
|
|
164
156
|
import uuid from "short-uuid";
|
|
165
|
-
|
|
166
|
-
|
|
157
|
+
|
|
158
|
+
// src/middleware/validationMiddleware.ts
|
|
159
|
+
import { ZodError } from "zod";
|
|
160
|
+
var validateData = /* @__PURE__ */ __name((schema) => {
|
|
161
|
+
return (req, res, next) => {
|
|
162
|
+
try {
|
|
163
|
+
schema.parse(req.body);
|
|
164
|
+
next();
|
|
165
|
+
} catch (error) {
|
|
166
|
+
if (error instanceof ZodError) {
|
|
167
|
+
const errorMessages = error.issues.map((issue) => ({
|
|
168
|
+
message: `${issue.path.join(".")} is ${issue.message}`
|
|
169
|
+
}));
|
|
170
|
+
res.status(400).json({
|
|
171
|
+
status: 400,
|
|
172
|
+
message: "Invalid data",
|
|
173
|
+
error_details: errorMessages[0].message
|
|
174
|
+
});
|
|
175
|
+
} else {
|
|
176
|
+
res.status(500).json({
|
|
177
|
+
status: 500,
|
|
178
|
+
message: "Internal Server Error"
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
}, "validateData");
|
|
184
|
+
|
|
185
|
+
// src/schemas/index.ts
|
|
186
|
+
import { z } from "zod";
|
|
187
|
+
import { ResponseMode, ResponseType, RequestUriMethod, CallbackOptsSchema } from "@sphereon/did-auth-siop";
|
|
188
|
+
var ResponseTypeSchema = z.enum([
|
|
189
|
+
ResponseType.VP_TOKEN
|
|
190
|
+
]);
|
|
191
|
+
var ResponseModeSchema = z.enum([
|
|
192
|
+
ResponseMode.DIRECT_POST,
|
|
193
|
+
ResponseMode.DIRECT_POST_JWT
|
|
194
|
+
]);
|
|
195
|
+
var RequestUriMethodSchema = z.enum(Object.values(RequestUriMethod));
|
|
196
|
+
var QRCodeOptsSchema = z.object({
|
|
197
|
+
size: z.number().optional(),
|
|
198
|
+
color_dark: z.string().optional(),
|
|
199
|
+
color_light: z.string().optional()
|
|
200
|
+
});
|
|
201
|
+
var CreateAuthorizationRequestBodySchema = z.object({
|
|
202
|
+
query_id: z.string(),
|
|
203
|
+
client_id: z.string().optional(),
|
|
204
|
+
request_uri_base: z.string().optional(),
|
|
205
|
+
correlation_id: z.string().optional(),
|
|
206
|
+
request_uri_method: RequestUriMethodSchema.optional(),
|
|
207
|
+
response_type: ResponseTypeSchema.optional(),
|
|
208
|
+
response_mode: ResponseModeSchema.optional(),
|
|
209
|
+
transaction_data: z.array(z.string()).optional(),
|
|
210
|
+
qr_code: QRCodeOptsSchema.optional(),
|
|
211
|
+
direct_post_response_redirect_uri: z.string().optional(),
|
|
212
|
+
callback: CallbackOptsSchema.optional()
|
|
213
|
+
});
|
|
214
|
+
var CreateAuthorizationResponseSchema = z.object({
|
|
215
|
+
correlation_id: z.string(),
|
|
216
|
+
query_id: z.string(),
|
|
217
|
+
request_uri: z.string(),
|
|
218
|
+
status_uri: z.string(),
|
|
219
|
+
qr_uri: z.string().optional()
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
// src/universal-oid4vp-api-functions.ts
|
|
223
|
+
function createAuthRequestUniversalOID4VPEndpoint(router, context, opts) {
|
|
167
224
|
if (opts?.enabled === false) {
|
|
168
|
-
console.log(`createAuthRequest
|
|
225
|
+
console.log(`createAuthRequest universal OID4VP endpoint is disabled`);
|
|
169
226
|
return;
|
|
170
227
|
}
|
|
171
|
-
const path = opts?.path ?? "/
|
|
172
|
-
router.post(path, checkAuth2(opts?.endpoint), async (request, response) => {
|
|
228
|
+
const path = opts?.path ?? "/backend/auth/requests";
|
|
229
|
+
router.post(path, checkAuth2(opts?.endpoint), validateData(CreateAuthorizationRequestBodySchema), async (request, response) => {
|
|
173
230
|
try {
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
231
|
+
const correlationId = request.body.correlation_id ?? uuid.uuid();
|
|
232
|
+
const qrCodeOpts = request.body.qr_code ?? opts?.qrCodeOpts;
|
|
233
|
+
const queryId = request.body.query_id;
|
|
234
|
+
const directPostResponseRedirectUri = request.body.direct_post_response_redirect_uri;
|
|
235
|
+
const requestUriBase = request.body.request_uri_base;
|
|
236
|
+
const callback = request.body.callback;
|
|
237
|
+
const definitionItems = await context.agent.pdmGetDefinitions({
|
|
238
|
+
filter: [
|
|
239
|
+
{
|
|
240
|
+
definitionId: queryId
|
|
241
|
+
}
|
|
242
|
+
]
|
|
243
|
+
});
|
|
244
|
+
if (definitionItems.length === 0) {
|
|
245
|
+
console.log(`No query could be found for the given id. Query id: ${queryId}`);
|
|
246
|
+
return sendErrorResponse2(response, 404, {
|
|
247
|
+
status: 404,
|
|
248
|
+
message: "No query could be found"
|
|
249
|
+
});
|
|
177
250
|
}
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
const qrCodeOpts = request.body.qrCodeOpts ?? opts?.qrCodeOpts;
|
|
181
|
-
const requestByReferenceURI = uriWithBase(`/siop/definitions/${definitionId}/auth-requests/${state}`, {
|
|
182
|
-
baseURI: opts?.siopBaseURI
|
|
251
|
+
const requestByReferenceURI = uriWithBase(`/siop/definitions/${queryId}/auth-requests/${correlationId}`, {
|
|
252
|
+
baseURI: requestUriBase ?? opts?.siopBaseURI
|
|
183
253
|
});
|
|
184
|
-
const responseURI = uriWithBase(`/siop/definitions/${
|
|
254
|
+
const responseURI = uriWithBase(`/siop/definitions/${queryId}/auth-responses/${correlationId}`, {
|
|
185
255
|
baseURI: opts?.siopBaseURI
|
|
186
256
|
});
|
|
187
|
-
const responseRedirectURI = ("response_redirect_uri" in request.body && request.body.response_redirect_uri) ?? ("responseRedirectURI" in request.body && request.body.responseRedirectURI);
|
|
188
257
|
const authRequestURI = await context.agent.siopCreateAuthRequestURI({
|
|
189
|
-
|
|
258
|
+
queryId,
|
|
190
259
|
correlationId,
|
|
191
|
-
state,
|
|
192
260
|
nonce: uuid.uuid(),
|
|
193
261
|
requestByReferenceURI,
|
|
194
262
|
responseURIType: "response_uri",
|
|
195
263
|
responseURI,
|
|
196
|
-
...
|
|
197
|
-
responseRedirectURI
|
|
198
|
-
}
|
|
264
|
+
...directPostResponseRedirectUri && {
|
|
265
|
+
responseRedirectURI: directPostResponseRedirectUri
|
|
266
|
+
},
|
|
267
|
+
callback
|
|
199
268
|
});
|
|
200
269
|
let qrCodeDataUri;
|
|
201
270
|
if (qrCodeOpts) {
|
|
@@ -207,133 +276,131 @@ function createAuthRequestWebappEndpoint(router, context, opts) {
|
|
|
207
276
|
qrCodeDataUri = `data:image/png;base64,${(await qrCode.draw()).toString("base64")}`;
|
|
208
277
|
}
|
|
209
278
|
const authRequestBody = {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
authStatusURI: `${uriWithBase(opts?.webappAuthStatusPath ?? "/webapp/auth-status", {
|
|
279
|
+
query_id: queryId,
|
|
280
|
+
correlation_id: correlationId,
|
|
281
|
+
request_uri: authRequestURI,
|
|
282
|
+
status_uri: `${uriWithBase(opts?.webappAuthStatusPath ?? `/backend/auth/status/${correlationId}`, {
|
|
215
283
|
baseURI: opts?.webappBaseURI
|
|
216
284
|
})}`,
|
|
217
285
|
...qrCodeDataUri && {
|
|
218
|
-
qrCodeDataUri
|
|
286
|
+
qr_uri: qrCodeDataUri
|
|
219
287
|
}
|
|
220
288
|
};
|
|
221
289
|
console.log(`Auth Request URI data to send back: ${JSON.stringify(authRequestBody)}`);
|
|
222
|
-
return response.json(authRequestBody);
|
|
290
|
+
return response.status(201).json(authRequestBody);
|
|
223
291
|
} catch (error) {
|
|
224
|
-
return sendErrorResponse2(response, 500,
|
|
292
|
+
return sendErrorResponse2(response, 500, {
|
|
293
|
+
status: 500,
|
|
294
|
+
message: "Could not create an authorization request URI"
|
|
295
|
+
}, error);
|
|
225
296
|
}
|
|
226
297
|
});
|
|
227
298
|
}
|
|
228
|
-
__name(
|
|
229
|
-
function
|
|
299
|
+
__name(createAuthRequestUniversalOID4VPEndpoint, "createAuthRequestUniversalOID4VPEndpoint");
|
|
300
|
+
function removeAuthRequestStateUniversalOID4VPEndpoint(router, context, opts) {
|
|
230
301
|
if (opts?.enabled === false) {
|
|
231
|
-
console.log(`
|
|
302
|
+
console.log(`removeAuthStatus universal OID4VP endpoint is disabled`);
|
|
232
303
|
return;
|
|
233
304
|
}
|
|
234
|
-
const path = opts?.path ?? "/
|
|
235
|
-
router.
|
|
305
|
+
const path = opts?.path ?? "/backend/auth/requests/:correlationId";
|
|
306
|
+
router.delete(path, checkAuth2(opts?.endpoint), async (request, response) => {
|
|
236
307
|
try {
|
|
237
|
-
|
|
238
|
-
const
|
|
239
|
-
const definitionId = request.body.definitionId;
|
|
240
|
-
const requestState = correlationId && definitionId ? await context.agent.siopGetAuthRequestState({
|
|
308
|
+
const correlationId = request.params.correlationId;
|
|
309
|
+
const authRequestState = await context.agent.siopGetAuthRequestState({
|
|
241
310
|
correlationId,
|
|
242
|
-
definitionId,
|
|
243
311
|
errorOnNotFound: false
|
|
244
|
-
})
|
|
245
|
-
if (!
|
|
246
|
-
console.log(`No
|
|
247
|
-
response
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
correlationId,
|
|
252
|
-
definitionId,
|
|
253
|
-
lastUpdated: requestState ? requestState.lastUpdated : Date.now()
|
|
254
|
-
};
|
|
255
|
-
return response.json(statusBody2);
|
|
312
|
+
});
|
|
313
|
+
if (!authRequestState) {
|
|
314
|
+
console.log(`No authorization request could be found for the given correlationId. correlationId: ${correlationId}`);
|
|
315
|
+
return sendErrorResponse2(response, 404, {
|
|
316
|
+
status: 404,
|
|
317
|
+
message: "No authorization request could be found"
|
|
318
|
+
});
|
|
256
319
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
320
|
+
await context.agent.siopDeleteAuthState({
|
|
321
|
+
correlationId
|
|
322
|
+
});
|
|
323
|
+
return response.status(204).json();
|
|
324
|
+
} catch (error) {
|
|
325
|
+
return sendErrorResponse2(response, 500, {
|
|
326
|
+
status: 500,
|
|
327
|
+
message: error.message
|
|
328
|
+
}, error);
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
__name(removeAuthRequestStateUniversalOID4VPEndpoint, "removeAuthRequestStateUniversalOID4VPEndpoint");
|
|
333
|
+
function authStatusUniversalOID4VPEndpoint(router, context, opts) {
|
|
334
|
+
if (opts?.enabled === false) {
|
|
335
|
+
console.log(`authStatus universal OID4VP endpoint is disabled`);
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
const path = opts?.path ?? "/backend/auth/status/:correlationId";
|
|
339
|
+
router.get(path, checkAuth2(opts?.endpoint), async (request, response) => {
|
|
340
|
+
try {
|
|
341
|
+
console.log("Received auth-status request...");
|
|
342
|
+
const correlationId = request.params.correlationId;
|
|
343
|
+
const requestState = await context.agent.siopGetAuthRequestState({
|
|
344
|
+
correlationId,
|
|
345
|
+
errorOnNotFound: false
|
|
346
|
+
});
|
|
347
|
+
if (!requestState) {
|
|
348
|
+
console.log(`No authorization request could be found for the given correlationId. correlationId: ${correlationId}`);
|
|
349
|
+
return sendErrorResponse2(response, 404, {
|
|
350
|
+
status: 404,
|
|
351
|
+
message: "No authorization request could be found"
|
|
352
|
+
});
|
|
260
353
|
}
|
|
261
354
|
let responseState;
|
|
262
|
-
if (requestState.status === "
|
|
355
|
+
if (requestState.status === "authorization_request_created") {
|
|
263
356
|
responseState = await context.agent.siopGetAuthResponseState({
|
|
264
357
|
correlationId,
|
|
265
|
-
definitionId,
|
|
266
|
-
includeVerifiedData,
|
|
267
358
|
errorOnNotFound: false
|
|
268
359
|
});
|
|
269
360
|
}
|
|
270
361
|
const overallState = responseState ?? requestState;
|
|
271
362
|
const statusBody = {
|
|
272
363
|
status: overallState.status,
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
definitionId,
|
|
278
|
-
lastUpdated: overallState.lastUpdated,
|
|
279
|
-
...responseState && responseState.status === AuthorizationResponseStateStatus.VERIFIED ? {
|
|
280
|
-
payload: await responseState.response.mergedPayloads({
|
|
281
|
-
hasher: defaultHasher
|
|
282
|
-
}),
|
|
364
|
+
correlation_id: overallState.correlationId,
|
|
365
|
+
query_id: overallState.queryId,
|
|
366
|
+
last_updated: overallState.lastUpdated,
|
|
367
|
+
...responseState?.status === AuthorizationResponseStateStatus.VERIFIED && responseState.verifiedData !== void 0 && {
|
|
283
368
|
verifiedData: responseState.verifiedData
|
|
284
|
-
}
|
|
369
|
+
},
|
|
370
|
+
...overallState.error && {
|
|
371
|
+
message: overallState.error.message
|
|
372
|
+
}
|
|
285
373
|
};
|
|
286
374
|
console.debug(`Will send auth status: ${JSON.stringify(statusBody)}`);
|
|
287
375
|
if (overallState.status === "error") {
|
|
288
|
-
response.
|
|
289
|
-
return response.json(statusBody);
|
|
290
|
-
}
|
|
291
|
-
response.statusCode = 200;
|
|
292
|
-
return response.json(statusBody);
|
|
293
|
-
} catch (error) {
|
|
294
|
-
return sendErrorResponse2(response, 500, error.message, error);
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
__name(authStatusWebappEndpoint, "authStatusWebappEndpoint");
|
|
299
|
-
function removeAuthRequestStateWebappEndpoint(router, context, opts) {
|
|
300
|
-
if (opts?.enabled === false) {
|
|
301
|
-
console.log(`removeAuthStatus Webapp endpoint is disabled`);
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
const path = opts?.path ?? "/webapp/definitions/:definitionId/auth-requests/:correlationId";
|
|
305
|
-
router.delete(path, checkAuth2(opts?.endpoint), async (request, response) => {
|
|
306
|
-
try {
|
|
307
|
-
const correlationId = request.params.correlationId;
|
|
308
|
-
const definitionId = request.params.definitionId;
|
|
309
|
-
if (!correlationId || !definitionId) {
|
|
310
|
-
console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, definitionId: ${definitionId}`);
|
|
311
|
-
return sendErrorResponse2(response, 404, "No authorization request could be found");
|
|
376
|
+
return response.status(500).json(statusBody);
|
|
312
377
|
}
|
|
313
|
-
response.
|
|
314
|
-
return response.json(await context.agent.siopDeleteAuthState({
|
|
315
|
-
definitionId,
|
|
316
|
-
correlationId
|
|
317
|
-
}));
|
|
378
|
+
return response.status(200).json(statusBody);
|
|
318
379
|
} catch (error) {
|
|
319
|
-
return sendErrorResponse2(response, 500,
|
|
380
|
+
return sendErrorResponse2(response, 500, {
|
|
381
|
+
status: 500,
|
|
382
|
+
message: error.message
|
|
383
|
+
}, error);
|
|
320
384
|
}
|
|
321
385
|
});
|
|
322
386
|
}
|
|
323
|
-
__name(
|
|
387
|
+
__name(authStatusUniversalOID4VPEndpoint, "authStatusUniversalOID4VPEndpoint");
|
|
324
388
|
function getDefinitionsEndpoint(router, context, opts) {
|
|
325
389
|
if (opts?.enabled === false) {
|
|
326
|
-
console.log(`getDefinitions
|
|
390
|
+
console.log(`getDefinitions universal OID4VP endpoint is disabled`);
|
|
327
391
|
return;
|
|
328
392
|
}
|
|
329
|
-
const path = opts?.path ?? "/
|
|
393
|
+
const path = opts?.path ?? "/backend/definitions";
|
|
330
394
|
router.get(path, checkAuth2(opts?.endpoint), async (request, response) => {
|
|
331
395
|
try {
|
|
332
396
|
const definitions = await context.agent.pdmGetDefinitions();
|
|
333
397
|
response.statusCode = 200;
|
|
334
398
|
return response.json(definitions);
|
|
335
399
|
} catch (error) {
|
|
336
|
-
return sendErrorResponse2(response, 500,
|
|
400
|
+
return sendErrorResponse2(response, 500, {
|
|
401
|
+
status: 500,
|
|
402
|
+
message: error.message
|
|
403
|
+
}, error);
|
|
337
404
|
}
|
|
338
405
|
});
|
|
339
406
|
}
|
|
@@ -384,9 +451,9 @@ var SIOPv2RPApiServer = class {
|
|
|
384
451
|
];
|
|
385
452
|
console.log(`SIOPv2 API enabled, with features: ${JSON.stringify(features)}}`);
|
|
386
453
|
if (features.includes("rp-status")) {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
454
|
+
createAuthRequestUniversalOID4VPEndpoint(this._router, context, opts?.endpointOpts?.webappCreateAuthRequest);
|
|
455
|
+
authStatusUniversalOID4VPEndpoint(this._router, context, opts?.endpointOpts?.webappAuthStatus);
|
|
456
|
+
removeAuthRequestStateUniversalOID4VPEndpoint(this._router, context, opts?.endpointOpts?.webappDeleteAuthRequest);
|
|
390
457
|
getDefinitionsEndpoint(this._router, context, opts?.endpointOpts?.webappGetDefinitions);
|
|
391
458
|
}
|
|
392
459
|
if (features.includes("siop")) {
|
|
@@ -433,11 +500,11 @@ var SIOPv2RPApiServer = class {
|
|
|
433
500
|
};
|
|
434
501
|
export {
|
|
435
502
|
SIOPv2RPApiServer,
|
|
436
|
-
|
|
437
|
-
|
|
503
|
+
authStatusUniversalOID4VPEndpoint,
|
|
504
|
+
createAuthRequestUniversalOID4VPEndpoint,
|
|
438
505
|
getAuthRequestSIOPv2Endpoint,
|
|
439
506
|
getDefinitionsEndpoint,
|
|
440
|
-
|
|
507
|
+
removeAuthRequestStateUniversalOID4VPEndpoint,
|
|
441
508
|
verifyAuthResponseSIOPv2Endpoint
|
|
442
509
|
};
|
|
443
510
|
//# sourceMappingURL=index.js.map
|