@sphereon/ssi-sdk.siopv2-oid4vp-rp-rest-api 0.34.1-feature.SSISDK.26.RP.58 → 0.34.1-feature.SSISDK.45.189
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 +205 -134
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +102 -13
- package/dist/index.d.ts +102 -13
- package/dist/index.js +203 -132
- package/dist/index.js.map +1 -1
- package/package.json +21 -20
- package/src/index.ts +1 -1
- package/src/middleware/validationMiddleware.ts +20 -0
- package/src/schemas/index.ts +36 -0
- package/src/siop-api-functions.ts +19 -30
- package/src/siopv2-rp-api-server.ts +9 -10
- package/src/types/types.ts +69 -3
- package/src/universal-oid4vp-api-functions.ts +179 -0
- package/src/webapp-api-functions.ts +1 -1
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, queryId, tenantId, version } = request.params;
|
|
38
|
+
if (!correlationId || !queryId) {
|
|
39
|
+
console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, queryId: ${queryId}`);
|
|
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
|
-
|
|
47
|
+
queryId,
|
|
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 ${queryId} from agent. Will return 404`);
|
|
56
55
|
response.statusCode = 404;
|
|
57
|
-
response.statusMessage = `No definition ${
|
|
56
|
+
response.statusMessage = `No definition ${queryId}`;
|
|
58
57
|
return response.send();
|
|
59
58
|
}
|
|
60
59
|
const authorizationResponse = parseAuthorizationResponse(request);
|
|
@@ -63,18 +62,12 @@ 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,
|
|
66
|
+
dcqlQuery: definitionItem.query
|
|
74
67
|
});
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
77
|
-
console.log("
|
|
68
|
+
const presentation = verifiedResponse?.oid4vpSubmission?.presentation;
|
|
69
|
+
if (presentation && Object.keys(presentation).length > 0) {
|
|
70
|
+
console.log("PRESENTATIONS:" + JSON.stringify(verifiedResponse?.oid4vpSubmission?.presentation, null, 2));
|
|
78
71
|
response.statusCode = 200;
|
|
79
72
|
const authorizationChallengeValidationResponse = {
|
|
80
73
|
presentation_during_issuance_session: verifiedResponse.correlationId
|
|
@@ -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,
|
|
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,126 @@ 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 { CallbackOptsSchema, ResponseMode, ResponseType } from "@sphereon/did-auth-siop";
|
|
187
|
+
import { z } from "zod";
|
|
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 requestUriMethods = [
|
|
196
|
+
"get",
|
|
197
|
+
"post"
|
|
198
|
+
];
|
|
199
|
+
var RequestUriMethodSchema = z.enum(requestUriMethods);
|
|
200
|
+
var QRCodeOptsSchema = z.object({
|
|
201
|
+
size: z.number().optional(),
|
|
202
|
+
color_dark: z.string().optional(),
|
|
203
|
+
color_light: z.string().optional()
|
|
204
|
+
});
|
|
205
|
+
var CreateAuthorizationRequestBodySchema = z.object({
|
|
206
|
+
query_id: z.string(),
|
|
207
|
+
client_id: z.string().optional(),
|
|
208
|
+
request_uri_base: z.string().optional(),
|
|
209
|
+
correlation_id: z.string().optional(),
|
|
210
|
+
request_uri_method: RequestUriMethodSchema.optional(),
|
|
211
|
+
response_type: ResponseTypeSchema.optional(),
|
|
212
|
+
response_mode: ResponseModeSchema.optional(),
|
|
213
|
+
transaction_data: z.array(z.string()).optional(),
|
|
214
|
+
qr_code: QRCodeOptsSchema.optional(),
|
|
215
|
+
direct_post_response_redirect_uri: z.string().optional(),
|
|
216
|
+
callback: CallbackOptsSchema.optional()
|
|
217
|
+
});
|
|
218
|
+
var CreateAuthorizationResponseSchema = z.object({
|
|
219
|
+
correlation_id: z.string(),
|
|
220
|
+
query_id: z.string(),
|
|
221
|
+
request_uri: z.string(),
|
|
222
|
+
status_uri: z.string(),
|
|
223
|
+
qr_uri: z.string().optional()
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
// src/universal-oid4vp-api-functions.ts
|
|
227
|
+
function createAuthRequestUniversalOID4VPEndpoint(router, context, opts) {
|
|
167
228
|
if (opts?.enabled === false) {
|
|
168
|
-
console.log(`createAuthRequest
|
|
229
|
+
console.log(`createAuthRequest universal OID4VP endpoint is disabled`);
|
|
169
230
|
return;
|
|
170
231
|
}
|
|
171
|
-
const path = opts?.path ?? "/
|
|
172
|
-
router.post(path, checkAuth2(opts?.endpoint), async (request, response) => {
|
|
232
|
+
const path = opts?.path ?? "/backend/auth/requests";
|
|
233
|
+
router.post(path, checkAuth2(opts?.endpoint), validateData(CreateAuthorizationRequestBodySchema), async (request, response) => {
|
|
173
234
|
try {
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
235
|
+
const correlationId = request.body.correlation_id ?? uuid.uuid();
|
|
236
|
+
const qrCodeOpts = request.body.qr_code ?? opts?.qrCodeOpts;
|
|
237
|
+
const queryId = request.body.query_id;
|
|
238
|
+
const directPostResponseRedirectUri = request.body.direct_post_response_redirect_uri;
|
|
239
|
+
const requestUriBase = request.body.request_uri_base;
|
|
240
|
+
const callback = request.body.callback;
|
|
241
|
+
const definitionItems = await context.agent.pdmGetDefinitions({
|
|
242
|
+
filter: [
|
|
243
|
+
{
|
|
244
|
+
queryId
|
|
245
|
+
}
|
|
246
|
+
]
|
|
247
|
+
});
|
|
248
|
+
if (definitionItems.length === 0) {
|
|
249
|
+
console.log(`No query could be found for the given id. Query id: ${queryId}`);
|
|
250
|
+
return sendErrorResponse2(response, 404, {
|
|
251
|
+
status: 404,
|
|
252
|
+
message: "No query could be found"
|
|
253
|
+
});
|
|
177
254
|
}
|
|
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
|
|
255
|
+
const requestByReferenceURI = uriWithBase(`/siop/definitions/${queryId}/auth-requests/${correlationId}`, {
|
|
256
|
+
baseURI: requestUriBase ?? opts?.siopBaseURI
|
|
183
257
|
});
|
|
184
|
-
const responseURI = uriWithBase(`/siop/definitions/${
|
|
258
|
+
const responseURI = uriWithBase(`/siop/definitions/${queryId}/auth-responses/${correlationId}`, {
|
|
185
259
|
baseURI: opts?.siopBaseURI
|
|
186
260
|
});
|
|
187
|
-
const responseRedirectURI = ("response_redirect_uri" in request.body && request.body.response_redirect_uri) ?? ("responseRedirectURI" in request.body && request.body.responseRedirectURI);
|
|
188
261
|
const authRequestURI = await context.agent.siopCreateAuthRequestURI({
|
|
189
|
-
|
|
262
|
+
queryId,
|
|
190
263
|
correlationId,
|
|
191
|
-
state,
|
|
192
264
|
nonce: uuid.uuid(),
|
|
193
265
|
requestByReferenceURI,
|
|
194
266
|
responseURIType: "response_uri",
|
|
195
267
|
responseURI,
|
|
196
|
-
...
|
|
197
|
-
responseRedirectURI
|
|
198
|
-
}
|
|
268
|
+
...directPostResponseRedirectUri && {
|
|
269
|
+
responseRedirectURI: directPostResponseRedirectUri
|
|
270
|
+
},
|
|
271
|
+
callback
|
|
199
272
|
});
|
|
200
273
|
let qrCodeDataUri;
|
|
201
274
|
if (qrCodeOpts) {
|
|
@@ -207,133 +280,131 @@ function createAuthRequestWebappEndpoint(router, context, opts) {
|
|
|
207
280
|
qrCodeDataUri = `data:image/png;base64,${(await qrCode.draw()).toString("base64")}`;
|
|
208
281
|
}
|
|
209
282
|
const authRequestBody = {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
authStatusURI: `${uriWithBase(opts?.webappAuthStatusPath ?? "/webapp/auth-status", {
|
|
283
|
+
query_id: queryId,
|
|
284
|
+
correlation_id: correlationId,
|
|
285
|
+
request_uri: authRequestURI,
|
|
286
|
+
status_uri: `${uriWithBase(opts?.webappAuthStatusPath ?? `/backend/auth/status/${correlationId}`, {
|
|
215
287
|
baseURI: opts?.webappBaseURI
|
|
216
288
|
})}`,
|
|
217
289
|
...qrCodeDataUri && {
|
|
218
|
-
qrCodeDataUri
|
|
290
|
+
qr_uri: qrCodeDataUri
|
|
219
291
|
}
|
|
220
292
|
};
|
|
221
293
|
console.log(`Auth Request URI data to send back: ${JSON.stringify(authRequestBody)}`);
|
|
222
|
-
return response.json(authRequestBody);
|
|
294
|
+
return response.status(201).json(authRequestBody);
|
|
223
295
|
} catch (error) {
|
|
224
|
-
return sendErrorResponse2(response, 500,
|
|
296
|
+
return sendErrorResponse2(response, 500, {
|
|
297
|
+
status: 500,
|
|
298
|
+
message: "Could not create an authorization request URI"
|
|
299
|
+
}, error);
|
|
225
300
|
}
|
|
226
301
|
});
|
|
227
302
|
}
|
|
228
|
-
__name(
|
|
229
|
-
function
|
|
303
|
+
__name(createAuthRequestUniversalOID4VPEndpoint, "createAuthRequestUniversalOID4VPEndpoint");
|
|
304
|
+
function removeAuthRequestStateUniversalOID4VPEndpoint(router, context, opts) {
|
|
230
305
|
if (opts?.enabled === false) {
|
|
231
|
-
console.log(`
|
|
306
|
+
console.log(`removeAuthStatus universal OID4VP endpoint is disabled`);
|
|
232
307
|
return;
|
|
233
308
|
}
|
|
234
|
-
const path = opts?.path ?? "/
|
|
235
|
-
router.
|
|
309
|
+
const path = opts?.path ?? "/backend/auth/requests/:correlationId";
|
|
310
|
+
router.delete(path, checkAuth2(opts?.endpoint), async (request, response) => {
|
|
236
311
|
try {
|
|
237
|
-
|
|
238
|
-
const
|
|
239
|
-
const definitionId = request.body.definitionId;
|
|
240
|
-
const requestState = correlationId && definitionId ? await context.agent.siopGetAuthRequestState({
|
|
312
|
+
const correlationId = request.params.correlationId;
|
|
313
|
+
const authRequestState = await context.agent.siopGetAuthRequestState({
|
|
241
314
|
correlationId,
|
|
242
|
-
definitionId,
|
|
243
315
|
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);
|
|
316
|
+
});
|
|
317
|
+
if (!authRequestState) {
|
|
318
|
+
console.log(`No authorization request could be found for the given correlationId. correlationId: ${correlationId}`);
|
|
319
|
+
return sendErrorResponse2(response, 404, {
|
|
320
|
+
status: 404,
|
|
321
|
+
message: "No authorization request could be found"
|
|
322
|
+
});
|
|
256
323
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
324
|
+
await context.agent.siopDeleteAuthState({
|
|
325
|
+
correlationId
|
|
326
|
+
});
|
|
327
|
+
return response.status(204).json();
|
|
328
|
+
} catch (error) {
|
|
329
|
+
return sendErrorResponse2(response, 500, {
|
|
330
|
+
status: 500,
|
|
331
|
+
message: error.message
|
|
332
|
+
}, error);
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
__name(removeAuthRequestStateUniversalOID4VPEndpoint, "removeAuthRequestStateUniversalOID4VPEndpoint");
|
|
337
|
+
function authStatusUniversalOID4VPEndpoint(router, context, opts) {
|
|
338
|
+
if (opts?.enabled === false) {
|
|
339
|
+
console.log(`authStatus universal OID4VP endpoint is disabled`);
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
const path = opts?.path ?? "/backend/auth/status/:correlationId";
|
|
343
|
+
router.get(path, checkAuth2(opts?.endpoint), async (request, response) => {
|
|
344
|
+
try {
|
|
345
|
+
console.log("Received auth-status request...");
|
|
346
|
+
const correlationId = request.params.correlationId;
|
|
347
|
+
const requestState = await context.agent.siopGetAuthRequestState({
|
|
348
|
+
correlationId,
|
|
349
|
+
errorOnNotFound: false
|
|
350
|
+
});
|
|
351
|
+
if (!requestState) {
|
|
352
|
+
console.log(`No authorization request could be found for the given correlationId. correlationId: ${correlationId}`);
|
|
353
|
+
return sendErrorResponse2(response, 404, {
|
|
354
|
+
status: 404,
|
|
355
|
+
message: "No authorization request could be found"
|
|
356
|
+
});
|
|
260
357
|
}
|
|
261
358
|
let responseState;
|
|
262
|
-
if (requestState.status === "
|
|
359
|
+
if (requestState.status === "authorization_request_created") {
|
|
263
360
|
responseState = await context.agent.siopGetAuthResponseState({
|
|
264
361
|
correlationId,
|
|
265
|
-
definitionId,
|
|
266
|
-
includeVerifiedData,
|
|
267
362
|
errorOnNotFound: false
|
|
268
363
|
});
|
|
269
364
|
}
|
|
270
365
|
const overallState = responseState ?? requestState;
|
|
271
366
|
const statusBody = {
|
|
272
367
|
status: overallState.status,
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
...
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}),
|
|
283
|
-
verifiedData: responseState.verifiedData
|
|
284
|
-
} : {}
|
|
368
|
+
correlation_id: overallState.correlationId,
|
|
369
|
+
query_id: overallState.queryId,
|
|
370
|
+
last_updated: overallState.lastUpdated,
|
|
371
|
+
...responseState?.status === AuthorizationResponseStateStatus.VERIFIED && responseState.verifiedData !== void 0 && {
|
|
372
|
+
verified_data: responseState.verifiedData
|
|
373
|
+
},
|
|
374
|
+
...overallState.error && {
|
|
375
|
+
message: overallState.error.message
|
|
376
|
+
}
|
|
285
377
|
};
|
|
286
378
|
console.debug(`Will send auth status: ${JSON.stringify(statusBody)}`);
|
|
287
379
|
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");
|
|
380
|
+
return response.status(500).json(statusBody);
|
|
312
381
|
}
|
|
313
|
-
response.
|
|
314
|
-
return response.json(await context.agent.siopDeleteAuthState({
|
|
315
|
-
definitionId,
|
|
316
|
-
correlationId
|
|
317
|
-
}));
|
|
382
|
+
return response.status(200).json(statusBody);
|
|
318
383
|
} catch (error) {
|
|
319
|
-
return sendErrorResponse2(response, 500,
|
|
384
|
+
return sendErrorResponse2(response, 500, {
|
|
385
|
+
status: 500,
|
|
386
|
+
message: error.message
|
|
387
|
+
}, error);
|
|
320
388
|
}
|
|
321
389
|
});
|
|
322
390
|
}
|
|
323
|
-
__name(
|
|
391
|
+
__name(authStatusUniversalOID4VPEndpoint, "authStatusUniversalOID4VPEndpoint");
|
|
324
392
|
function getDefinitionsEndpoint(router, context, opts) {
|
|
325
393
|
if (opts?.enabled === false) {
|
|
326
|
-
console.log(`getDefinitions
|
|
394
|
+
console.log(`getDefinitions universal OID4VP endpoint is disabled`);
|
|
327
395
|
return;
|
|
328
396
|
}
|
|
329
|
-
const path = opts?.path ?? "/
|
|
397
|
+
const path = opts?.path ?? "/backend/definitions";
|
|
330
398
|
router.get(path, checkAuth2(opts?.endpoint), async (request, response) => {
|
|
331
399
|
try {
|
|
332
400
|
const definitions = await context.agent.pdmGetDefinitions();
|
|
333
401
|
response.statusCode = 200;
|
|
334
402
|
return response.json(definitions);
|
|
335
403
|
} catch (error) {
|
|
336
|
-
return sendErrorResponse2(response, 500,
|
|
404
|
+
return sendErrorResponse2(response, 500, {
|
|
405
|
+
status: 500,
|
|
406
|
+
message: error.message
|
|
407
|
+
}, error);
|
|
337
408
|
}
|
|
338
409
|
});
|
|
339
410
|
}
|
|
@@ -384,9 +455,9 @@ var SIOPv2RPApiServer = class {
|
|
|
384
455
|
];
|
|
385
456
|
console.log(`SIOPv2 API enabled, with features: ${JSON.stringify(features)}}`);
|
|
386
457
|
if (features.includes("rp-status")) {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
458
|
+
createAuthRequestUniversalOID4VPEndpoint(this._router, context, opts?.endpointOpts?.webappCreateAuthRequest);
|
|
459
|
+
authStatusUniversalOID4VPEndpoint(this._router, context, opts?.endpointOpts?.webappAuthStatus);
|
|
460
|
+
removeAuthRequestStateUniversalOID4VPEndpoint(this._router, context, opts?.endpointOpts?.webappDeleteAuthRequest);
|
|
390
461
|
getDefinitionsEndpoint(this._router, context, opts?.endpointOpts?.webappGetDefinitions);
|
|
391
462
|
}
|
|
392
463
|
if (features.includes("siop")) {
|
|
@@ -433,11 +504,11 @@ var SIOPv2RPApiServer = class {
|
|
|
433
504
|
};
|
|
434
505
|
export {
|
|
435
506
|
SIOPv2RPApiServer,
|
|
436
|
-
|
|
437
|
-
|
|
507
|
+
authStatusUniversalOID4VPEndpoint,
|
|
508
|
+
createAuthRequestUniversalOID4VPEndpoint,
|
|
438
509
|
getAuthRequestSIOPv2Endpoint,
|
|
439
510
|
getDefinitionsEndpoint,
|
|
440
|
-
|
|
511
|
+
removeAuthRequestStateUniversalOID4VPEndpoint,
|
|
441
512
|
verifyAuthResponseSIOPv2Endpoint
|
|
442
513
|
};
|
|
443
514
|
//# sourceMappingURL=index.js.map
|