@sphereon/ssi-sdk.siopv2-oid4vp-rp-rest-api 0.34.1-feature.SSISDK.46.41 → 0.34.1-feature.SSISDK.50.98
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 +120 -208
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -80
- package/dist/index.d.ts +7 -80
- package/dist/index.js +116 -204
- package/dist/index.js.map +1 -1
- package/package.json +19 -22
- package/src/index.ts +1 -1
- package/src/siop-api-functions.ts +10 -20
- package/src/siopv2-rp-api-server.ts +7 -7
- package/src/types/types.ts +1 -42
- package/src/webapp-api-functions.ts +183 -0
- package/src/middleware/validationMiddleware.ts +0 -20
- package/src/schemas/index.ts +0 -50
- package/src/universal-oid4vp-api-functions.ts +0 -172
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,7 +34,7 @@ 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, definitionId, tenantId, version } = request.params;
|
|
37
|
+
const { correlationId, definitionId, tenantId, version, credentialQueryId } = request.params;
|
|
39
38
|
if (!correlationId || !definitionId) {
|
|
40
39
|
console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, definitionId: ${definitionId}`);
|
|
41
40
|
return sendErrorResponse(response, 404, "No authorization request could be found");
|
|
@@ -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
|
+
definitionId,
|
|
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
|
+
definitionId,
|
|
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
|
-
|
|
119
|
+
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
|
-
|
|
148
|
-
state: "
|
|
140
|
+
definitionId,
|
|
141
|
+
state: "sent",
|
|
149
142
|
error
|
|
150
143
|
});
|
|
151
144
|
}
|
|
@@ -156,128 +149,45 @@ function getAuthRequestSIOPv2Endpoint(router, context, opts) {
|
|
|
156
149
|
}
|
|
157
150
|
__name(getAuthRequestSIOPv2Endpoint, "getAuthRequestSIOPv2Endpoint");
|
|
158
151
|
|
|
159
|
-
// src/
|
|
152
|
+
// src/webapp-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";
|
|
156
|
+
import { VerifiedDataMode } from "@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth";
|
|
163
157
|
import uuid from "short-uuid";
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
import { ZodError } from "zod";
|
|
167
|
-
var validateData = /* @__PURE__ */ __name((schema) => {
|
|
168
|
-
return (req, res, next) => {
|
|
169
|
-
try {
|
|
170
|
-
schema.parse(req.body);
|
|
171
|
-
next();
|
|
172
|
-
} catch (error) {
|
|
173
|
-
if (error instanceof ZodError) {
|
|
174
|
-
const errorMessages = error.issues.map((issue) => ({
|
|
175
|
-
message: `${issue.path.join(".")} is ${issue.message}`
|
|
176
|
-
}));
|
|
177
|
-
res.status(400).json({
|
|
178
|
-
status: 400,
|
|
179
|
-
message: "Invalid data",
|
|
180
|
-
error_details: errorMessages[0].message
|
|
181
|
-
});
|
|
182
|
-
} else {
|
|
183
|
-
res.status(500).json({
|
|
184
|
-
status: 500,
|
|
185
|
-
message: "Internal Server Error"
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
}, "validateData");
|
|
191
|
-
|
|
192
|
-
// src/schemas/index.ts
|
|
193
|
-
import { z } from "zod";
|
|
194
|
-
import { authorizationRequestStatuses, authorizationResponseStatuses } from "@sphereon/ssi-sdk.siopv2-oid4vp-common";
|
|
195
|
-
import { ResponseMode, ResponseType, RequestUriMethod } from "@sphereon/did-auth-siop";
|
|
196
|
-
var ResponseTypeSchema = z.enum([
|
|
197
|
-
ResponseType.VP_TOKEN
|
|
198
|
-
]);
|
|
199
|
-
var ResponseModeSchema = z.enum([
|
|
200
|
-
ResponseMode.DIRECT_POST,
|
|
201
|
-
ResponseMode.DIRECT_POST_JWT
|
|
202
|
-
]);
|
|
203
|
-
var RequestUriMethodSchema = z.enum([
|
|
204
|
-
RequestUriMethod.GET,
|
|
205
|
-
RequestUriMethod.POST
|
|
206
|
-
]);
|
|
207
|
-
var AuthorizationStatusSchema = z.enum([
|
|
208
|
-
...authorizationRequestStatuses,
|
|
209
|
-
...authorizationResponseStatuses
|
|
210
|
-
]);
|
|
211
|
-
var CallbackOptsSchema = z.object({
|
|
212
|
-
url: z.string(),
|
|
213
|
-
status: z.array(AuthorizationStatusSchema).optional()
|
|
214
|
-
});
|
|
215
|
-
var QRCodeOptsSchema = z.object({
|
|
216
|
-
size: z.number().optional(),
|
|
217
|
-
color_dark: z.string().optional(),
|
|
218
|
-
color_light: z.string().optional()
|
|
219
|
-
});
|
|
220
|
-
var CreateAuthorizationRequestBodySchema = z.object({
|
|
221
|
-
query_id: z.string(),
|
|
222
|
-
client_id: z.string().optional(),
|
|
223
|
-
request_uri_base: z.string().optional(),
|
|
224
|
-
correlation_id: z.string().optional(),
|
|
225
|
-
request_uri_method: RequestUriMethodSchema.optional(),
|
|
226
|
-
response_type: ResponseTypeSchema.optional(),
|
|
227
|
-
response_mode: ResponseModeSchema.optional(),
|
|
228
|
-
transaction_data: z.array(z.string()).optional(),
|
|
229
|
-
qr_code: QRCodeOptsSchema.optional(),
|
|
230
|
-
direct_post_response_redirect_uri: z.string().optional(),
|
|
231
|
-
callback: CallbackOptsSchema.optional()
|
|
232
|
-
});
|
|
233
|
-
var CreateAuthorizationResponseSchema = z.object({
|
|
234
|
-
correlation_id: z.string(),
|
|
235
|
-
query_id: z.string(),
|
|
236
|
-
request_uri: z.string(),
|
|
237
|
-
status_uri: z.string(),
|
|
238
|
-
qr_uri: z.string().optional()
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
// src/universal-oid4vp-api-functions.ts
|
|
242
|
-
function createAuthRequestUniversalOID4VPEndpoint(router, context, opts) {
|
|
158
|
+
import { shaHasher as defaultHasher } from "@sphereon/ssi-sdk.core";
|
|
159
|
+
function createAuthRequestWebappEndpoint(router, context, opts) {
|
|
243
160
|
if (opts?.enabled === false) {
|
|
244
|
-
console.log(`createAuthRequest
|
|
161
|
+
console.log(`createAuthRequest Webapp endpoint is disabled`);
|
|
245
162
|
return;
|
|
246
163
|
}
|
|
247
|
-
const path = opts?.path ?? "/
|
|
248
|
-
router.post(path, checkAuth2(opts?.endpoint),
|
|
164
|
+
const path = opts?.path ?? "/webapp/definitions/:definitionId/auth-requests";
|
|
165
|
+
router.post(path, checkAuth2(opts?.endpoint), async (request, response) => {
|
|
249
166
|
try {
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
const directPostResponseRedirectUri = request.body.direct_post_response_redirect_uri;
|
|
254
|
-
const requestUriBase = request.body.request_uri_base;
|
|
255
|
-
try {
|
|
256
|
-
await context.agent.pdmGetDefinition({
|
|
257
|
-
itemId: queryId
|
|
258
|
-
});
|
|
259
|
-
} catch (e) {
|
|
260
|
-
console.log(`No query could be found for the given id. Query id: ${queryId}`);
|
|
261
|
-
return sendErrorResponse2(response, 404, {
|
|
262
|
-
status: 404,
|
|
263
|
-
message: "No query could be found"
|
|
264
|
-
});
|
|
167
|
+
const definitionId = request.params.definitionId;
|
|
168
|
+
if (!definitionId) {
|
|
169
|
+
return sendErrorResponse2(response, 400, "No definitionId query parameter provided");
|
|
265
170
|
}
|
|
266
|
-
const
|
|
267
|
-
|
|
171
|
+
const state = request.body.state ?? uuid.uuid();
|
|
172
|
+
const correlationId = request.body.correlationId ?? state;
|
|
173
|
+
const qrCodeOpts = request.body.qrCodeOpts ?? opts?.qrCodeOpts;
|
|
174
|
+
const requestByReferenceURI = uriWithBase(`/siop/definitions/${definitionId}/auth-requests/${state}`, {
|
|
175
|
+
baseURI: opts?.siopBaseURI
|
|
268
176
|
});
|
|
269
|
-
const responseURI = uriWithBase(`/siop/definitions/${
|
|
177
|
+
const responseURI = uriWithBase(`/siop/definitions/${definitionId}/auth-responses/${state}`, {
|
|
270
178
|
baseURI: opts?.siopBaseURI
|
|
271
179
|
});
|
|
180
|
+
const responseRedirectURI = ("response_redirect_uri" in request.body && request.body.response_redirect_uri) ?? ("responseRedirectURI" in request.body && request.body.responseRedirectURI);
|
|
272
181
|
const authRequestURI = await context.agent.siopCreateAuthRequestURI({
|
|
273
|
-
|
|
182
|
+
definitionId,
|
|
274
183
|
correlationId,
|
|
184
|
+
state,
|
|
275
185
|
nonce: uuid.uuid(),
|
|
276
186
|
requestByReferenceURI,
|
|
277
187
|
responseURIType: "response_uri",
|
|
278
188
|
responseURI,
|
|
279
|
-
...
|
|
280
|
-
responseRedirectURI
|
|
189
|
+
...responseRedirectURI && {
|
|
190
|
+
responseRedirectURI
|
|
281
191
|
}
|
|
282
192
|
});
|
|
283
193
|
let qrCodeDataUri;
|
|
@@ -290,131 +200,133 @@ function createAuthRequestUniversalOID4VPEndpoint(router, context, opts) {
|
|
|
290
200
|
qrCodeDataUri = `data:image/png;base64,${(await qrCode.draw()).toString("base64")}`;
|
|
291
201
|
}
|
|
292
202
|
const authRequestBody = {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
203
|
+
correlationId,
|
|
204
|
+
state,
|
|
205
|
+
definitionId,
|
|
206
|
+
authRequestURI,
|
|
207
|
+
authStatusURI: `${uriWithBase(opts?.webappAuthStatusPath ?? "/webapp/auth-status", {
|
|
297
208
|
baseURI: opts?.webappBaseURI
|
|
298
209
|
})}`,
|
|
299
210
|
...qrCodeDataUri && {
|
|
300
|
-
|
|
211
|
+
qrCodeDataUri
|
|
301
212
|
}
|
|
302
213
|
};
|
|
303
214
|
console.log(`Auth Request URI data to send back: ${JSON.stringify(authRequestBody)}`);
|
|
304
|
-
return response.
|
|
305
|
-
} catch (error) {
|
|
306
|
-
return sendErrorResponse2(response, 500, {
|
|
307
|
-
status: 500,
|
|
308
|
-
message: "Could not create an authorization request URI"
|
|
309
|
-
}, error);
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
__name(createAuthRequestUniversalOID4VPEndpoint, "createAuthRequestUniversalOID4VPEndpoint");
|
|
314
|
-
function removeAuthRequestStateUniversalOID4VPEndpoint(router, context, opts) {
|
|
315
|
-
if (opts?.enabled === false) {
|
|
316
|
-
console.log(`removeAuthStatus universal OID4VP endpoint is disabled`);
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
const path = opts?.path ?? "/backend/auth/requests/:correlationId";
|
|
320
|
-
router.delete(path, checkAuth2(opts?.endpoint), async (request, response) => {
|
|
321
|
-
try {
|
|
322
|
-
const correlationId = request.params.correlationId;
|
|
323
|
-
const authRequestState = await context.agent.siopGetAuthRequestState({
|
|
324
|
-
correlationId,
|
|
325
|
-
errorOnNotFound: false
|
|
326
|
-
});
|
|
327
|
-
if (!authRequestState) {
|
|
328
|
-
console.log(`No authorization request could be found for the given correlationId. correlationId: ${correlationId}`);
|
|
329
|
-
return sendErrorResponse2(response, 404, {
|
|
330
|
-
status: 404,
|
|
331
|
-
message: "No authorization request could be found"
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
await context.agent.siopDeleteAuthState({
|
|
335
|
-
correlationId
|
|
336
|
-
});
|
|
337
|
-
return response.status(204).json();
|
|
215
|
+
return response.json(authRequestBody);
|
|
338
216
|
} catch (error) {
|
|
339
|
-
return sendErrorResponse2(response, 500,
|
|
340
|
-
status: 500,
|
|
341
|
-
message: error.message
|
|
342
|
-
}, error);
|
|
217
|
+
return sendErrorResponse2(response, 500, "Could not create an authorization request URI", error);
|
|
343
218
|
}
|
|
344
219
|
});
|
|
345
220
|
}
|
|
346
|
-
__name(
|
|
347
|
-
function
|
|
221
|
+
__name(createAuthRequestWebappEndpoint, "createAuthRequestWebappEndpoint");
|
|
222
|
+
function authStatusWebappEndpoint(router, context, opts) {
|
|
348
223
|
if (opts?.enabled === false) {
|
|
349
|
-
console.log(`authStatus
|
|
224
|
+
console.log(`authStatus Webapp endpoint is disabled`);
|
|
350
225
|
return;
|
|
351
226
|
}
|
|
352
|
-
const path = opts?.path ?? "/
|
|
353
|
-
router.
|
|
227
|
+
const path = opts?.path ?? "/webapp/auth-status";
|
|
228
|
+
router.post(path, checkAuth2(opts?.endpoint), async (request, response) => {
|
|
354
229
|
try {
|
|
355
230
|
console.log("Received auth-status request...");
|
|
356
|
-
const correlationId = request.
|
|
357
|
-
const
|
|
231
|
+
const correlationId = request.body.correlationId;
|
|
232
|
+
const definitionId = request.body.definitionId;
|
|
233
|
+
const requestState = correlationId && definitionId ? await context.agent.siopGetAuthRequestState({
|
|
358
234
|
correlationId,
|
|
235
|
+
definitionId,
|
|
359
236
|
errorOnNotFound: false
|
|
360
|
-
});
|
|
361
|
-
if (!requestState) {
|
|
362
|
-
console.log(`No
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
237
|
+
}) : void 0;
|
|
238
|
+
if (!requestState || !definitionId || !correlationId) {
|
|
239
|
+
console.log(`No authentication request mapping could be found for the given URL. correlation: ${correlationId}, definitionId: ${definitionId}`);
|
|
240
|
+
response.statusCode = 404;
|
|
241
|
+
const statusBody2 = {
|
|
242
|
+
status: requestState ? requestState.status : "error",
|
|
243
|
+
error: "No authentication request mapping could be found for the given URL.",
|
|
244
|
+
correlationId,
|
|
245
|
+
definitionId,
|
|
246
|
+
lastUpdated: requestState ? requestState.lastUpdated : Date.now()
|
|
247
|
+
};
|
|
248
|
+
return response.json(statusBody2);
|
|
249
|
+
}
|
|
250
|
+
let includeVerifiedData = VerifiedDataMode.NONE;
|
|
251
|
+
if ("includeVerifiedData" in request.body) {
|
|
252
|
+
includeVerifiedData = request.body.includeVerifiedData;
|
|
367
253
|
}
|
|
368
254
|
let responseState;
|
|
369
|
-
if (requestState.status === "
|
|
255
|
+
if (requestState.status === "sent") {
|
|
370
256
|
responseState = await context.agent.siopGetAuthResponseState({
|
|
371
257
|
correlationId,
|
|
258
|
+
definitionId,
|
|
259
|
+
includeVerifiedData,
|
|
372
260
|
errorOnNotFound: false
|
|
373
261
|
});
|
|
374
262
|
}
|
|
375
263
|
const overallState = responseState ?? requestState;
|
|
376
264
|
const statusBody = {
|
|
377
265
|
status: overallState.status,
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
266
|
+
...overallState.error ? {
|
|
267
|
+
error: overallState.error?.message
|
|
268
|
+
} : {},
|
|
269
|
+
correlationId,
|
|
270
|
+
definitionId,
|
|
271
|
+
lastUpdated: overallState.lastUpdated,
|
|
272
|
+
...responseState && responseState.status === AuthorizationResponseStateStatus.VERIFIED ? {
|
|
273
|
+
payload: await responseState.response.mergedPayloads({
|
|
274
|
+
hasher: defaultHasher
|
|
275
|
+
}),
|
|
382
276
|
verifiedData: responseState.verifiedData
|
|
383
|
-
}
|
|
384
|
-
...overallState.error && {
|
|
385
|
-
message: overallState.error.message
|
|
386
|
-
}
|
|
277
|
+
} : {}
|
|
387
278
|
};
|
|
388
279
|
console.debug(`Will send auth status: ${JSON.stringify(statusBody)}`);
|
|
389
280
|
if (overallState.status === "error") {
|
|
390
|
-
|
|
281
|
+
response.statusCode = 500;
|
|
282
|
+
return response.json(statusBody);
|
|
391
283
|
}
|
|
392
|
-
|
|
284
|
+
response.statusCode = 200;
|
|
285
|
+
return response.json(statusBody);
|
|
286
|
+
} catch (error) {
|
|
287
|
+
return sendErrorResponse2(response, 500, error.message, error);
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
__name(authStatusWebappEndpoint, "authStatusWebappEndpoint");
|
|
292
|
+
function removeAuthRequestStateWebappEndpoint(router, context, opts) {
|
|
293
|
+
if (opts?.enabled === false) {
|
|
294
|
+
console.log(`removeAuthStatus Webapp endpoint is disabled`);
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
const path = opts?.path ?? "/webapp/definitions/:definitionId/auth-requests/:correlationId";
|
|
298
|
+
router.delete(path, checkAuth2(opts?.endpoint), async (request, response) => {
|
|
299
|
+
try {
|
|
300
|
+
const correlationId = request.params.correlationId;
|
|
301
|
+
const definitionId = request.params.definitionId;
|
|
302
|
+
if (!correlationId || !definitionId) {
|
|
303
|
+
console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, definitionId: ${definitionId}`);
|
|
304
|
+
return sendErrorResponse2(response, 404, "No authorization request could be found");
|
|
305
|
+
}
|
|
306
|
+
response.statusCode = 200;
|
|
307
|
+
return response.json(await context.agent.siopDeleteAuthState({
|
|
308
|
+
definitionId,
|
|
309
|
+
correlationId
|
|
310
|
+
}));
|
|
393
311
|
} catch (error) {
|
|
394
|
-
return sendErrorResponse2(response, 500,
|
|
395
|
-
status: 500,
|
|
396
|
-
message: error.message
|
|
397
|
-
}, error);
|
|
312
|
+
return sendErrorResponse2(response, 500, error.message, error);
|
|
398
313
|
}
|
|
399
314
|
});
|
|
400
315
|
}
|
|
401
|
-
__name(
|
|
316
|
+
__name(removeAuthRequestStateWebappEndpoint, "removeAuthRequestStateWebappEndpoint");
|
|
402
317
|
function getDefinitionsEndpoint(router, context, opts) {
|
|
403
318
|
if (opts?.enabled === false) {
|
|
404
|
-
console.log(`getDefinitions
|
|
319
|
+
console.log(`getDefinitions Webapp endpoint is disabled`);
|
|
405
320
|
return;
|
|
406
321
|
}
|
|
407
|
-
const path = opts?.path ?? "/
|
|
322
|
+
const path = opts?.path ?? "/webapp/definitions";
|
|
408
323
|
router.get(path, checkAuth2(opts?.endpoint), async (request, response) => {
|
|
409
324
|
try {
|
|
410
325
|
const definitions = await context.agent.pdmGetDefinitions();
|
|
411
326
|
response.statusCode = 200;
|
|
412
327
|
return response.json(definitions);
|
|
413
328
|
} catch (error) {
|
|
414
|
-
return sendErrorResponse2(response, 500,
|
|
415
|
-
status: 500,
|
|
416
|
-
message: error.message
|
|
417
|
-
}, error);
|
|
329
|
+
return sendErrorResponse2(response, 500, error.message, error);
|
|
418
330
|
}
|
|
419
331
|
});
|
|
420
332
|
}
|
|
@@ -465,9 +377,9 @@ var SIOPv2RPApiServer = class {
|
|
|
465
377
|
];
|
|
466
378
|
console.log(`SIOPv2 API enabled, with features: ${JSON.stringify(features)}}`);
|
|
467
379
|
if (features.includes("rp-status")) {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
380
|
+
createAuthRequestWebappEndpoint(this._router, context, opts?.endpointOpts?.webappCreateAuthRequest);
|
|
381
|
+
authStatusWebappEndpoint(this._router, context, opts?.endpointOpts?.webappAuthStatus);
|
|
382
|
+
removeAuthRequestStateWebappEndpoint(this._router, context, opts?.endpointOpts?.webappDeleteAuthRequest);
|
|
471
383
|
getDefinitionsEndpoint(this._router, context, opts?.endpointOpts?.webappGetDefinitions);
|
|
472
384
|
}
|
|
473
385
|
if (features.includes("siop")) {
|
|
@@ -514,11 +426,11 @@ var SIOPv2RPApiServer = class {
|
|
|
514
426
|
};
|
|
515
427
|
export {
|
|
516
428
|
SIOPv2RPApiServer,
|
|
517
|
-
|
|
518
|
-
|
|
429
|
+
authStatusWebappEndpoint,
|
|
430
|
+
createAuthRequestWebappEndpoint,
|
|
519
431
|
getAuthRequestSIOPv2Endpoint,
|
|
520
432
|
getDefinitionsEndpoint,
|
|
521
|
-
|
|
433
|
+
removeAuthRequestStateWebappEndpoint,
|
|
522
434
|
verifyAuthResponseSIOPv2Endpoint
|
|
523
435
|
};
|
|
524
436
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/siop-api-functions.ts","../src/universal-oid4vp-api-functions.ts","../src/middleware/validationMiddleware.ts","../src/schemas/index.ts","../src/siopv2-rp-api-server.ts"],"sourcesContent":["import { AuthorizationResponsePayload, PresentationDefinitionLocation } from '@sphereon/did-auth-siop'\nimport { checkAuth, ISingleEndpointOpts, sendErrorResponse } from '@sphereon/ssi-express-support'\nimport { CredentialMapper } from '@sphereon/ssi-types'\nimport { AuthorizationChallengeValidationResponse } from '@sphereon/ssi-sdk.siopv2-oid4vp-common'\nimport { Request, Response, Router } from 'express'\nimport { IRequiredContext } from './types'\n\nconst parseAuthorizationResponse = (request: Request): AuthorizationResponsePayload => {\n const contentType = request.header('content-type')\n\n if (contentType === 'application/json') {\n const payload = typeof request.body === 'string' ? JSON.parse(request.body) : request.body\n return payload as AuthorizationResponsePayload\n }\n\n if (contentType === 'application/x-www-form-urlencoded') {\n const payload = request.body as AuthorizationResponsePayload\n\n // Parse presentation_submission if it's a string\n if (typeof payload.presentation_submission === 'string') {\n console.log(`Supplied presentation_submission was a string instead of JSON. Correcting, but external party should fix their implementation!`)\n payload.presentation_submission = JSON.parse(payload.presentation_submission)\n }\n\n // when using FORM_URL_ENCODED, vp_token comes back as string not matter whether the input was string, object or array. Handled below.\n if (typeof payload.vp_token === 'string') {\n const { vp_token } = payload\n\n // The only use case where vp_object is an object is JsonLdAsString atm. For arrays, any objects will be parsed along with the array\n // (Leaving the vp_token JsonLdAsString causes problems because the original credential will remain string and will be interpreted as JWT in some parts of the code)\n if ((vp_token.startsWith('[') && vp_token.endsWith(']')) || CredentialMapper.isJsonLdAsString(vp_token)) {\n payload.vp_token = JSON.parse(vp_token)\n }\n }\n\n return payload\n }\n\n throw new Error(\n `Unsupported content type: ${contentType}. Currently only application/x-www-form-urlencoded and application/json (for direct_post) are supported`,\n )\n}\n\nexport function verifyAuthResponseSIOPv2Endpoint(\n router: Router,\n context: IRequiredContext,\n opts?: ISingleEndpointOpts & { presentationDefinitionLocation?: PresentationDefinitionLocation },\n) {\n if (opts?.enabled === false) {\n console.log(`verifyAuthResponse SIOP endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/siop/definitions/:definitionId/auth-responses/:correlationId'\n router.post(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const { correlationId, definitionId, tenantId, version } = request.params\n if (!correlationId || !definitionId) {\n console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, definitionId: ${definitionId}`)\n return sendErrorResponse(response, 404, 'No authorization request could be found')\n }\n console.log('Authorization Response (siop-sessions')\n console.log(JSON.stringify(request.body, null, 2))\n const definitionItems = await context.agent.pdmGetDefinitions({ filter: [{ definitionId, tenantId, version }] })\n if (definitionItems.length === 0) {\n console.log(`Could not get definition ${definitionId} from agent. Will return 404`)\n response.statusCode = 404\n response.statusMessage = `No definition ${definitionId}`\n return response.send()\n }\n\n const authorizationResponse = parseAuthorizationResponse(request)\n console.log(`URI: ${JSON.stringify(authorizationResponse)}`)\n\n const definitionItem = definitionItems[0]\n const verifiedResponse = await context.agent.siopVerifyAuthResponse({\n authorizationResponse,\n correlationId,\n queryId: definitionId,\n presentationDefinitions: [\n {\n location: opts?.presentationDefinitionLocation ?? PresentationDefinitionLocation.TOPLEVEL_PRESENTATION_DEF,\n definition: definitionItem.definitionPayload,\n },\n ],\n dcqlQuery: definitionItem.dcqlPayload,\n })\n\n const wrappedPresentation = verifiedResponse?.oid4vpSubmission?.presentations[0]\n if (wrappedPresentation) {\n // const credentialSubject = wrappedPresentation.presentation.verifiableCredential[0]?.credential?.credentialSubject\n // console.log(JSON.stringify(credentialSubject, null, 2))\n console.log('PRESENTATION:' + JSON.stringify(wrappedPresentation.presentation, null, 2))\n response.statusCode = 200\n\n const authorizationChallengeValidationResponse: AuthorizationChallengeValidationResponse = {\n presentation_during_issuance_session: verifiedResponse.correlationId,\n }\n if (authorizationResponse.is_first_party) {\n response.setHeader('Content-Type', 'application/json')\n return response.send(JSON.stringify(authorizationChallengeValidationResponse))\n }\n\n const responseRedirectURI = await context.agent.siopGetRedirectURI({ correlationId, queryId: definitionId, state: verifiedResponse.state })\n if (responseRedirectURI) {\n response.setHeader('Content-Type', 'application/json')\n return response.send(JSON.stringify({ redirect_uri: responseRedirectURI }))\n }\n // todo: delete session\n } else {\n console.log('Missing Presentation (Verifiable Credentials)')\n response.statusCode = 500\n response.statusMessage = 'Missing Presentation (Verifiable Credentials)'\n }\n return response.send()\n } catch (error) {\n console.error(error)\n return sendErrorResponse(response, 500, 'Could not verify auth status', error)\n }\n })\n}\n\nexport function getAuthRequestSIOPv2Endpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`getAuthRequest SIOP endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/siop/definitions/:definitionId/auth-requests/:correlationId'\n router.get(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const correlationId = request.params.correlationId\n const definitionId = request.params.definitionId\n if (!correlationId || !definitionId) {\n console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, definitionId: ${definitionId}`)\n return sendErrorResponse(response, 404, 'No authorization request could be found')\n }\n const requestState = await context.agent.siopGetAuthRequestState({\n correlationId,\n queryId: definitionId,\n errorOnNotFound: false,\n })\n if (!requestState) {\n console.log(\n `No authorization request could be found for the given url in the state manager. correlationId: ${correlationId}, definitionId: ${definitionId}`,\n )\n return sendErrorResponse(response, 404, `No authorization request could be found`)\n }\n const requestObject = await requestState.request?.requestObject?.toJwt()\n console.log('JWT Request object:')\n console.log(requestObject)\n\n let error: string | undefined\n try {\n response.statusCode = 200\n response.setHeader('Content-Type', 'application/jwt')\n return response.send(requestObject)\n } catch (e) {\n error = typeof e === 'string' ? e : e instanceof Error ? e.message : undefined\n return sendErrorResponse(response, 500, 'Could not get authorization request', e)\n } finally {\n await context.agent.siopUpdateAuthRequestState({\n correlationId,\n queryId: definitionId,\n state: 'authorization_request_created',\n error,\n })\n }\n } catch (error) {\n return sendErrorResponse(response, 500, 'Could not get authorization request', error)\n }\n })\n}\n","import { AuthorizationResponseStateStatus } from '@sphereon/did-auth-siop'\nimport { checkAuth, ISingleEndpointOpts, sendErrorResponse } from '@sphereon/ssi-express-support'\nimport { uriWithBase } from '@sphereon/ssi-sdk.siopv2-oid4vp-common'\nimport { Request, Response, Router } from 'express'\nimport uuid from 'short-uuid'\nimport { validateData } from './middleware/validationMiddleware'\nimport { CreateAuthorizationRequestBodySchema } from './schemas'\nimport {\n CreateAuthorizationRequest,\n CreateAuthorizationRequestResponse,\n CreateAuthorizationResponse,\n DeleteAuthorizationRequest,\n GetAuthorizationRequestStatus,\n GetAuthStatusResponse,\n ICreateAuthRequestWebappEndpointOpts,\n IRequiredContext\n} from './types'\n\nexport function createAuthRequestUniversalOID4VPEndpoint(router: Router, context: IRequiredContext, opts?: ICreateAuthRequestWebappEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`createAuthRequest universal OID4VP endpoint is disabled`)\n return\n }\n\n const path = opts?.path ?? '/backend/auth/requests'\n router.post(path, checkAuth(opts?.endpoint), validateData(CreateAuthorizationRequestBodySchema), async (request: CreateAuthorizationRequest, response: CreateAuthorizationResponse) => {\n try {\n const correlationId = request.body.correlation_id ?? uuid.uuid()\n const qrCodeOpts = request.body.qr_code ?? opts?.qrCodeOpts\n const queryId = request.body.query_id\n const directPostResponseRedirectUri = request.body.direct_post_response_redirect_uri // TODO Uri not URI\n const requestUriBase = request.body.request_uri_base\n\n try {\n await context.agent.pdmGetDefinition({ itemId: queryId })\n } catch(e) {\n console.log(`No query could be found for the given id. Query id: ${queryId}`)\n return sendErrorResponse(response, 404, { status: 404, message: 'No query could be found' })\n }\n\n const requestByReferenceURI = uriWithBase(`/siop/definitions/${queryId}/auth-requests/${correlationId}`, {\n baseURI: requestUriBase ?? opts?.siopBaseURI,\n })\n const responseURI = uriWithBase(`/siop/definitions/${queryId}/auth-responses/${correlationId}`, { baseURI: opts?.siopBaseURI })\n\n const authRequestURI = await context.agent.siopCreateAuthRequestURI({\n queryId,\n correlationId,\n nonce: uuid.uuid(),\n requestByReferenceURI,\n responseURIType: 'response_uri',\n responseURI,\n ...(directPostResponseRedirectUri && { responseRedirectURI: directPostResponseRedirectUri }),\n })\n\n let qrCodeDataUri: string | undefined\n if (qrCodeOpts) {\n const { AwesomeQR } = await import('awesome-qr')\n const qrCode = new AwesomeQR({ ...qrCodeOpts, text: authRequestURI })\n qrCodeDataUri = `data:image/png;base64,${(await qrCode.draw())!.toString('base64')}`\n }\n\n const authRequestBody = {\n query_id: queryId,\n correlation_id: correlationId,\n request_uri: authRequestURI,\n status_uri: `${uriWithBase(opts?.webappAuthStatusPath ?? `/backend/auth/status/${correlationId}`, { baseURI: opts?.webappBaseURI })}`,\n ...(qrCodeDataUri && { qr_uri: qrCodeDataUri }),\n } satisfies CreateAuthorizationRequestResponse\n console.log(`Auth Request URI data to send back: ${JSON.stringify(authRequestBody)}`)\n\n return response.status(201).json(authRequestBody)\n } catch (error) {\n return sendErrorResponse(response, 500, { status: 500, message: 'Could not create an authorization request URI' }, error)\n }\n })\n}\n\nexport function removeAuthRequestStateUniversalOID4VPEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`removeAuthStatus universal OID4VP endpoint is disabled`)\n return\n }\n\n const path = opts?.path ?? '/backend/auth/requests/:correlationId'\n router.delete(path, checkAuth(opts?.endpoint), async (request: DeleteAuthorizationRequest, response: Response) => {\n try {\n const correlationId: string = request.params.correlationId\n\n const authRequestState = await context.agent.siopGetAuthRequestState({\n correlationId,\n errorOnNotFound: false\n })\n if (!authRequestState) {\n console.log(`No authorization request could be found for the given correlationId. correlationId: ${correlationId}`)\n return sendErrorResponse(response, 404, { status: 404, message: 'No authorization request could be found' })\n }\n\n await context.agent.siopDeleteAuthState({ correlationId })\n\n return response.status(204).json()\n } catch (error) {\n return sendErrorResponse(response, 500, { status: 500, message: error.message }, error)\n }\n })\n}\n\nexport function authStatusUniversalOID4VPEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`authStatus universal OID4VP endpoint is disabled`)\n return\n }\n\n const path = opts?.path ?? '/backend/auth/status/:correlationId'\n router.get(path, checkAuth(opts?.endpoint), async (request: GetAuthorizationRequestStatus, response: Response) => {\n try {\n console.log('Received auth-status request...')\n const correlationId: string = request.params.correlationId\n\n const requestState = await context.agent.siopGetAuthRequestState({\n correlationId,\n errorOnNotFound: false\n })\n\n if (!requestState) {\n console.log(`No authorization request could be found for the given correlationId. correlationId: ${correlationId}`)\n return sendErrorResponse(response, 404, { status: 404, message: 'No authorization request could be found' })\n }\n\n let responseState\n if (requestState.status === 'authorization_request_created') {\n responseState = (await context.agent.siopGetAuthResponseState({ correlationId, errorOnNotFound: false }))\n }\n const overallState = responseState ?? requestState\n\n const statusBody = {\n status: overallState.status,\n correlation_id: overallState.correlationId,\n query_id: overallState.queryId,\n last_updated: overallState.lastUpdated,\n ...((responseState?.status === AuthorizationResponseStateStatus.VERIFIED && responseState.verifiedData !== undefined) && { verifiedData: responseState.verifiedData }),\n ...(overallState.error && { message: overallState.error.message })\n } satisfies GetAuthStatusResponse\n console.debug(`Will send auth status: ${JSON.stringify(statusBody)}`)\n\n if (overallState.status === 'error') {\n return response.status(500).json(statusBody)\n }\n return response.status(200).json(statusBody)\n } catch (error) {\n return sendErrorResponse(response, 500, { status: 500, message: error.message }, error)\n }\n })\n}\n\nexport function getDefinitionsEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`getDefinitions universal OID4VP endpoint is disabled`)\n return\n }\n\n const path = opts?.path ?? '/backend/definitions'\n router.get(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const definitions = await context.agent.pdmGetDefinitions()\n response.statusCode = 200\n return response.json(definitions)\n } catch (error) {\n return sendErrorResponse(response, 500, { status: 500, message: error.message }, error)\n }\n })\n}\n","import { Request, Response, NextFunction } from 'express';\nimport { z, ZodError } from 'zod';\n\nexport const validateData = (schema: z.ZodObject<any, any>) => {\n return (req: Request, res: Response, next: NextFunction) => {\n try {\n schema.parse(req.body);\n next();\n } catch (error) {\n if (error instanceof ZodError) {\n const errorMessages = error.issues.map((issue: any) => ({\n message: `${issue.path.join('.')} is ${issue.message}`,\n }))\n res.status(400).json({ status: 400, message: 'Invalid data', error_details: errorMessages[0].message });\n } else {\n res.status(500).json({ status: 500, message: 'Internal Server Error' });\n }\n }\n };\n}\n","import { z } from 'zod';\nimport {\n authorizationRequestStatuses,\n authorizationResponseStatuses\n} from '@sphereon/ssi-sdk.siopv2-oid4vp-common'\nimport { ResponseMode, ResponseType, RequestUriMethod } from '@sphereon/did-auth-siop'\n\nexport const ResponseTypeSchema = z.enum([ResponseType.VP_TOKEN]);\n\nexport const ResponseModeSchema = z.enum([ResponseMode.DIRECT_POST, ResponseMode.DIRECT_POST_JWT]);\n\nexport const RequestUriMethodSchema = z.enum([RequestUriMethod.GET, RequestUriMethod.POST]);\n\nexport const AuthorizationStatusSchema = z.enum([\n ...authorizationRequestStatuses,\n ...authorizationResponseStatuses\n]);\n\nexport const CallbackOptsSchema = z.object({\n url: z.string(),\n status: z.array(AuthorizationStatusSchema).optional(),\n});\n\nexport const QRCodeOptsSchema = z.object({\n size: z.number().optional(),\n color_dark: z.string().optional(),\n color_light: z.string().optional(),\n});\n\nexport const CreateAuthorizationRequestBodySchema = z.object({\n query_id: z.string(),\n client_id: z.string().optional(),\n request_uri_base: z.string().optional(),\n correlation_id: z.string().optional(),\n request_uri_method: RequestUriMethodSchema.optional(),\n response_type: ResponseTypeSchema.optional(),\n response_mode: ResponseModeSchema.optional(),\n transaction_data: z.array(z.string()).optional(),\n qr_code: QRCodeOptsSchema.optional(),\n direct_post_response_redirect_uri: z.string().optional(),\n callback: CallbackOptsSchema.optional(),\n});\n\nexport const CreateAuthorizationResponseSchema = z.object({\n correlation_id: z.string(),\n query_id: z.string(),\n request_uri: z.string(),\n status_uri: z.string(),\n qr_uri: z.string().optional(),\n});\n","import { agentContext } from '@sphereon/ssi-sdk.core'\nimport { copyGlobalAuthToEndpoints, ExpressSupport } from '@sphereon/ssi-express-support'\nimport { IPresentationExchange } from '@sphereon/ssi-sdk.presentation-exchange'\nimport { ISIOPv2RP } from '@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth'\nimport { TAgent } from '@veramo/core'\nimport express, { Express, Request, Response, Router } from 'express'\nimport { getAuthRequestSIOPv2Endpoint, verifyAuthResponseSIOPv2Endpoint } from './siop-api-functions'\nimport { IRequiredPlugins, ISIOPv2RPRestAPIOpts } from './types'\nimport {\n authStatusUniversalOID4VPEndpoint,\n createAuthRequestUniversalOID4VPEndpoint,\n getDefinitionsEndpoint,\n removeAuthRequestStateUniversalOID4VPEndpoint,\n} from './universal-oid4vp-api-functions'\nimport swaggerUi from 'swagger-ui-express'\n\nexport class SIOPv2RPApiServer {\n private readonly _express: Express\n private readonly _router: Router\n private readonly _agent: TAgent<IPresentationExchange & ISIOPv2RP>\n private readonly _opts?: ISIOPv2RPRestAPIOpts\n private readonly _basePath: string\n\n private readonly OID4VP_SWAGGER_URL = 'https://api.swaggerhub.com/apis/SphereonInt/OID4VP/0.1.0'\n constructor(args: { agent: TAgent<IRequiredPlugins>; expressSupport: ExpressSupport; opts?: ISIOPv2RPRestAPIOpts }) {\n const { agent, opts } = args\n this._agent = agent\n copyGlobalAuthToEndpoints({ opts, keys: ['webappCreateAuthRequest', 'webappAuthStatus', 'webappDeleteAuthRequest'] })\n if (opts?.endpointOpts?.globalAuth?.secureSiopEndpoints) {\n copyGlobalAuthToEndpoints({ opts, keys: ['siopGetAuthRequest', 'siopVerifyAuthResponse'] })\n }\n\n this._opts = opts\n this._express = args.expressSupport.express\n this._router = express.Router()\n const context = agentContext(agent)\n\n const features = opts?.enableFeatures ?? ['rp-status', 'siop']\n console.log(`SIOPv2 API enabled, with features: ${JSON.stringify(features)}}`)\n\n // Webapp endpoints\n if (features.includes('rp-status')) {\n createAuthRequestUniversalOID4VPEndpoint(this._router, context, opts?.endpointOpts?.webappCreateAuthRequest)\n authStatusUniversalOID4VPEndpoint(this._router, context, opts?.endpointOpts?.webappAuthStatus)\n removeAuthRequestStateUniversalOID4VPEndpoint(this._router, context, opts?.endpointOpts?.webappDeleteAuthRequest)\n getDefinitionsEndpoint(this._router, context, opts?.endpointOpts?.webappGetDefinitions)\n }\n\n // SIOPv2 endpoints\n if (features.includes('siop')) {\n getAuthRequestSIOPv2Endpoint(this._router, context, opts?.endpointOpts?.siopGetAuthRequest)\n verifyAuthResponseSIOPv2Endpoint(this._router, context, opts?.endpointOpts?.siopVerifyAuthResponse)\n }\n this._basePath = opts?.endpointOpts?.basePath ?? ''\n this._express.use(this._basePath, this.router)\n this._express.set('trust proxy', opts?.endpointOpts?.trustProxy ?? true)\n this.setupSwaggerUi()\n }\n\n private setupSwaggerUi() {\n fetch(this.OID4VP_SWAGGER_URL)\n .then((res) => res.json())\n .then((swagger: any) => {\n const apiDocs = `${this._basePath}/api-docs`\n console.log(`[OID4P] API docs available at ${apiDocs}`)\n\n this._router.use(\n '/api-docs',\n (req: Request, res: Response, next: any) => {\n const regex = `${apiDocs.replace(/\\//, '\\/')}`.replace('/oid4vp', '').replace(/\\/api-docs.*/, '')\n swagger.servers = [{ url: `${req.protocol}://${req.get('host')}${regex}`, description: 'This server' }]\n // @ts-ignore\n req.swaggerDoc = swagger\n next()\n },\n swaggerUi.serveFiles(swagger, options),\n swaggerUi.setup(),\n )\n })\n .catch((err) => {\n console.log(`[OID4VP] Unable to fetch swagger document: ${err}. Will not host api-docs on this instance`)\n })\n const options = {\n // customCss: '.swagger-ui .topbar { display: none }',\n }\n }\n get express(): Express {\n return this._express\n }\n\n get router(): Router {\n return this._router\n }\n\n get agent(): TAgent<IPresentationExchange & ISIOPv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BC,UAAM,KAAKvC,kBAAkB,EAC1BwC,KAAK,CAACC,QAAQA,IAAIC,KAAI,CAAA,EACtBF,KAAK,CAACG,YAAAA;AACL,YAAMC,UAAU,GAAG,KAAK7C,SAAS;AACjCiB,cAAQC,IAAI,iCAAiC2B,OAAAA,EAAS;AAEtD,WAAKhD,QAAQsC,IACX,aACA,CAACW,KAAcJ,KAAeK,SAAAA;AAC5B,cAAMC,QAAQ,GAAGH,QAAQI,QAAQ,MAAM,GAAA,CAAA,GAAQA,QAAQ,WAAW,EAAA,EAAIA,QAAQ,gBAAgB,EAAA;AAC9FL,gBAAQM,UAAU;UAAC;YAAEC,KAAK,GAAGL,IAAIM,QAAQ,MAAMN,IAAIO,IAAI,MAAA,CAAA,GAAUL,KAAAA;YAASM,aAAa;UAAc;;AAErGR,YAAIS,aAAaX;AACjBG,aAAAA;MACF,GACAS,UAAUC,WAAWb,SAASc,OAAAA,GAC9BF,UAAUG,MAAK,CAAA;IAEnB,CAAA,EACCC,MAAM,CAACC,QAAAA;AACN5C,cAAQC,IAAI,8CAA8C2C,GAAAA,2CAA8C;IAC1G,CAAA;AACF,UAAMH,UAAU,CAEhB;EACF;EACA,IAAI/C,UAAmB;AACrB,WAAO,KAAKf;EACd;EAEA,IAAIwC,SAAiB;AACnB,WAAO,KAAKvC;EACd;EAEA,IAAIM,QAAmD;AACrD,WAAO,KAAKL;EACd;EAEA,IAAIM,OAAyC;AAC3C,WAAO,KAAKL;EACd;AACF;","names":["PresentationDefinitionLocation","checkAuth","sendErrorResponse","CredentialMapper","parseAuthorizationResponse","request","contentType","header","payload","body","JSON","parse","presentation_submission","console","log","vp_token","startsWith","endsWith","CredentialMapper","isJsonLdAsString","Error","verifyAuthResponseSIOPv2Endpoint","router","context","opts","enabled","path","post","checkAuth","endpoint","response","correlationId","definitionId","tenantId","version","params","sendErrorResponse","stringify","definitionItems","agent","pdmGetDefinitions","filter","length","statusCode","statusMessage","send","authorizationResponse","definitionItem","verifiedResponse","siopVerifyAuthResponse","queryId","presentationDefinitions","location","presentationDefinitionLocation","PresentationDefinitionLocation","TOPLEVEL_PRESENTATION_DEF","definition","definitionPayload","dcqlQuery","dcqlPayload","wrappedPresentation","oid4vpSubmission","presentations","presentation","authorizationChallengeValidationResponse","presentation_during_issuance_session","is_first_party","setHeader","responseRedirectURI","siopGetRedirectURI","state","redirect_uri","error","getAuthRequestSIOPv2Endpoint","get","requestState","siopGetAuthRequestState","errorOnNotFound","requestObject","toJwt","e","message","undefined","siopUpdateAuthRequestState","AuthorizationResponseStateStatus","checkAuth","sendErrorResponse","uriWithBase","uuid","ZodError","validateData","schema","req","res","next","parse","body","error","ZodError","errorMessages","issues","map","issue","message","path","join","status","json","error_details","z","authorizationRequestStatuses","authorizationResponseStatuses","ResponseMode","ResponseType","RequestUriMethod","ResponseTypeSchema","enum","VP_TOKEN","ResponseModeSchema","DIRECT_POST","DIRECT_POST_JWT","RequestUriMethodSchema","GET","POST","AuthorizationStatusSchema","CallbackOptsSchema","object","url","string","status","array","optional","QRCodeOptsSchema","size","number","color_dark","color_light","CreateAuthorizationRequestBodySchema","query_id","client_id","request_uri_base","correlation_id","request_uri_method","response_type","response_mode","transaction_data","qr_code","direct_post_response_redirect_uri","callback","CreateAuthorizationResponseSchema","request_uri","status_uri","qr_uri","createAuthRequestUniversalOID4VPEndpoint","router","context","opts","enabled","console","log","path","post","checkAuth","endpoint","validateData","CreateAuthorizationRequestBodySchema","request","response","correlationId","body","correlation_id","uuid","qrCodeOpts","qr_code","queryId","query_id","directPostResponseRedirectUri","direct_post_response_redirect_uri","requestUriBase","request_uri_base","agent","pdmGetDefinition","itemId","e","sendErrorResponse","status","message","requestByReferenceURI","uriWithBase","baseURI","siopBaseURI","responseURI","authRequestURI","siopCreateAuthRequestURI","nonce","responseURIType","responseRedirectURI","qrCodeDataUri","AwesomeQR","qrCode","text","draw","toString","authRequestBody","request_uri","status_uri","webappAuthStatusPath","webappBaseURI","qr_uri","JSON","stringify","json","error","removeAuthRequestStateUniversalOID4VPEndpoint","delete","params","authRequestState","siopGetAuthRequestState","errorOnNotFound","siopDeleteAuthState","authStatusUniversalOID4VPEndpoint","get","requestState","responseState","siopGetAuthResponseState","overallState","statusBody","last_updated","lastUpdated","AuthorizationResponseStateStatus","VERIFIED","verifiedData","undefined","debug","getDefinitionsEndpoint","definitions","pdmGetDefinitions","statusCode","agentContext","copyGlobalAuthToEndpoints","express","swaggerUi","SIOPv2RPApiServer","_express","_router","_agent","_opts","_basePath","OID4VP_SWAGGER_URL","args","agent","opts","copyGlobalAuthToEndpoints","keys","endpointOpts","globalAuth","secureSiopEndpoints","expressSupport","express","Router","context","agentContext","features","enableFeatures","console","log","JSON","stringify","includes","createAuthRequestUniversalOID4VPEndpoint","webappCreateAuthRequest","authStatusUniversalOID4VPEndpoint","webappAuthStatus","removeAuthRequestStateUniversalOID4VPEndpoint","webappDeleteAuthRequest","getDefinitionsEndpoint","webappGetDefinitions","getAuthRequestSIOPv2Endpoint","siopGetAuthRequest","verifyAuthResponseSIOPv2Endpoint","siopVerifyAuthResponse","basePath","use","router","set","trustProxy","setupSwaggerUi","fetch","then","res","json","swagger","apiDocs","req","next","regex","replace","servers","url","protocol","get","description","swaggerDoc","swaggerUi","serveFiles","options","setup","catch","err"]}
|
|
1
|
+
{"version":3,"sources":["../src/siop-api-functions.ts","../src/webapp-api-functions.ts","../src/siopv2-rp-api-server.ts"],"sourcesContent":["import { AuthorizationResponsePayload } from '@sphereon/did-auth-siop'\nimport { checkAuth, ISingleEndpointOpts, sendErrorResponse } from '@sphereon/ssi-express-support'\nimport { CredentialMapper } from '@sphereon/ssi-types'\nimport { AuthorizationChallengeValidationResponse } from '@sphereon/ssi-sdk.siopv2-oid4vp-common'\nimport { Request, Response, Router } from 'express'\nimport { IRequiredContext } from './types'\n\nconst parseAuthorizationResponse = (request: Request): AuthorizationResponsePayload => {\n const contentType = request.header('content-type')\n\n if (contentType === 'application/json') {\n const payload = typeof request.body === 'string' ? JSON.parse(request.body) : request.body\n return payload as AuthorizationResponsePayload\n }\n\n if (contentType === 'application/x-www-form-urlencoded') {\n const payload = request.body as AuthorizationResponsePayload\n\n // Parse presentation_submission if it's a string\n if (typeof payload.presentation_submission === 'string') {\n console.log(`Supplied presentation_submission was a string instead of JSON. Correcting, but external party should fix their implementation!`)\n payload.presentation_submission = JSON.parse(payload.presentation_submission)\n }\n\n // when using FORM_URL_ENCODED, vp_token comes back as string not matter whether the input was string, object or array. Handled below.\n if (typeof payload.vp_token === 'string') {\n const { vp_token } = payload\n\n // The only use case where vp_object is an object is JsonLdAsString atm. For arrays, any objects will be parsed along with the array\n // (Leaving the vp_token JsonLdAsString causes problems because the original credential will remain string and will be interpreted as JWT in some parts of the code)\n if ((vp_token.startsWith('[') && vp_token.endsWith(']')) || CredentialMapper.isJsonLdAsString(vp_token)) {\n payload.vp_token = JSON.parse(vp_token)\n }\n }\n\n return payload\n }\n\n throw new Error(\n `Unsupported content type: ${contentType}. Currently only application/x-www-form-urlencoded and application/json (for direct_post) are supported`,\n )\n}\n\nexport function verifyAuthResponseSIOPv2Endpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`verifyAuthResponse SIOP endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/siop/definitions/:definitionId/auth-responses/:correlationId'\n router.post(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const { correlationId, definitionId, tenantId, version, credentialQueryId } = request.params // TODO Can credentialQueryId be a request param\n if (!correlationId || !definitionId) {\n console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, definitionId: ${definitionId}`)\n return sendErrorResponse(response, 404, 'No authorization request could be found')\n }\n console.log('Authorization Response (siop-sessions')\n console.log(JSON.stringify(request.body, null, 2))\n const definitionItems = await context.agent.pdmGetDefinitions({ filter: [{ definitionId, tenantId, version }] })\n if (definitionItems.length === 0) {\n console.log(`Could not get definition ${definitionId} from agent. Will return 404`)\n response.statusCode = 404\n response.statusMessage = `No definition ${definitionId}`\n return response.send()\n }\n\n const authorizationResponse = parseAuthorizationResponse(request)\n console.log(`URI: ${JSON.stringify(authorizationResponse)}`)\n\n const definitionItem = definitionItems[0]\n const verifiedResponse = await context.agent.siopVerifyAuthResponse({\n authorizationResponse,\n correlationId,\n definitionId,\n dcqlQueryPayload: definitionItem.dcqlPayload,\n })\n\n const wrappedPresentation = verifiedResponse?.oid4vpSubmission?.presentation[credentialQueryId]\n if (wrappedPresentation) {\n // const credentialSubject = wrappedPresentation.presentation.verifiableCredential[0]?.credential?.credentialSubject\n // console.log(JSON.stringify(credentialSubject, null, 2))\n console.log('PRESENTATION:' + JSON.stringify(wrappedPresentation.presentation, null, 2))\n response.statusCode = 200\n\n const authorizationChallengeValidationResponse: AuthorizationChallengeValidationResponse = {\n presentation_during_issuance_session: verifiedResponse.correlationId,\n }\n if (authorizationResponse.is_first_party) {\n response.setHeader('Content-Type', 'application/json')\n return response.send(JSON.stringify(authorizationChallengeValidationResponse))\n }\n\n const responseRedirectURI = await context.agent.siopGetRedirectURI({ correlationId, definitionId, state: verifiedResponse.state })\n if (responseRedirectURI) {\n response.setHeader('Content-Type', 'application/json')\n return response.send(JSON.stringify({ redirect_uri: responseRedirectURI }))\n }\n // todo: delete session\n } else {\n console.log('Missing Presentation (Verifiable Credentials)')\n response.statusCode = 500\n response.statusMessage = 'Missing Presentation (Verifiable Credentials)'\n }\n return response.send()\n } catch (error) {\n console.error(error)\n return sendErrorResponse(response, 500, 'Could not verify auth status', error)\n }\n })\n}\n\nexport function getAuthRequestSIOPv2Endpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`getAuthRequest SIOP endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/siop/definitions/:definitionId/auth-requests/:correlationId'\n router.get(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const correlationId = request.params.correlationId\n const definitionId = request.params.definitionId\n if (!correlationId || !definitionId) {\n console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, definitionId: ${definitionId}`)\n return sendErrorResponse(response, 404, 'No authorization request could be found')\n }\n const requestState = await context.agent.siopGetAuthRequestState({\n correlationId,\n definitionId,\n errorOnNotFound: false,\n })\n if (!requestState) {\n console.log(\n `No authorization request could be found for the given url in the state manager. correlationId: ${correlationId}, definitionId: ${definitionId}`,\n )\n return sendErrorResponse(response, 404, `No authorization request could be found`)\n }\n const requestObject = await requestState.request?.requestObject?.toJwt()\n console.log('JWT Request object:')\n console.log(requestObject)\n\n let error: string | undefined\n try {\n response.statusCode = 200\n response.setHeader('Content-Type', 'application/jwt')\n return response.send(requestObject)\n } catch (e) {\n error = typeof e === 'string' ? e : e instanceof Error ? e.message : undefined\n return sendErrorResponse(response, 500, 'Could not get authorization request', e)\n } finally {\n await context.agent.siopUpdateAuthRequestState({\n correlationId,\n definitionId,\n state: 'sent',\n error,\n })\n }\n } catch (error) {\n return sendErrorResponse(response, 500, 'Could not get authorization request', error)\n }\n })\n}\n","import { AuthorizationRequestState, AuthorizationResponseStateStatus } from '@sphereon/did-auth-siop'\nimport { checkAuth, ISingleEndpointOpts, sendErrorResponse } from '@sphereon/ssi-express-support'\nimport { AuthStatusResponse, GenerateAuthRequestURIResponse, uriWithBase } from '@sphereon/ssi-sdk.siopv2-oid4vp-common'\nimport { AuthorizationResponseStateWithVerifiedData, VerifiedDataMode } from '@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth'\nimport { Request, Response, Router } from 'express'\nimport uuid from 'short-uuid'\nimport { ICreateAuthRequestWebappEndpointOpts, IRequiredContext } from './types'\nimport { shaHasher as defaultHasher } from '@sphereon/ssi-sdk.core'\n\nexport function createAuthRequestWebappEndpoint(router: Router, context: IRequiredContext, opts?: ICreateAuthRequestWebappEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`createAuthRequest Webapp endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/webapp/definitions/:definitionId/auth-requests'\n router.post(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n // if (!request.agent) throw Error('No agent configured')\n const definitionId = request.params.definitionId\n if (!definitionId) {\n return sendErrorResponse(response, 400, 'No definitionId query parameter provided')\n }\n const state: string = request.body.state ?? uuid.uuid()\n const correlationId = request.body.correlationId ?? state\n const qrCodeOpts = request.body.qrCodeOpts ?? opts?.qrCodeOpts\n\n const requestByReferenceURI = uriWithBase(`/siop/definitions/${definitionId}/auth-requests/${state}`, {\n baseURI: opts?.siopBaseURI,\n })\n const responseURI = uriWithBase(`/siop/definitions/${definitionId}/auth-responses/${state}`, { baseURI: opts?.siopBaseURI })\n // first version is for backwards compat\n const responseRedirectURI =\n ('response_redirect_uri' in request.body && (request.body.response_redirect_uri as string | undefined)) ??\n ('responseRedirectURI' in request.body && (request.body.responseRedirectURI as string | undefined))\n\n const authRequestURI = await context.agent.siopCreateAuthRequestURI({\n definitionId,\n correlationId,\n state,\n nonce: uuid.uuid(),\n requestByReferenceURI,\n responseURIType: 'response_uri',\n responseURI,\n ...(responseRedirectURI && { responseRedirectURI }),\n })\n\n let qrCodeDataUri: string | undefined\n if (qrCodeOpts) {\n const { AwesomeQR } = await import('awesome-qr')\n const qrCode = new AwesomeQR({ ...qrCodeOpts, text: authRequestURI })\n qrCodeDataUri = `data:image/png;base64,${(await qrCode.draw())!.toString('base64')}`\n }\n const authRequestBody: GenerateAuthRequestURIResponse = {\n correlationId,\n state,\n definitionId,\n authRequestURI,\n authStatusURI: `${uriWithBase(opts?.webappAuthStatusPath ?? '/webapp/auth-status', { baseURI: opts?.webappBaseURI })}`,\n ...(qrCodeDataUri && { qrCodeDataUri }),\n }\n console.log(`Auth Request URI data to send back: ${JSON.stringify(authRequestBody)}`)\n return response.json(authRequestBody)\n } catch (error) {\n return sendErrorResponse(response, 500, 'Could not create an authorization request URI', error)\n }\n })\n}\n\nexport function authStatusWebappEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`authStatus Webapp endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/webapp/auth-status'\n router.post(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n console.log('Received auth-status request...')\n const correlationId: string = request.body.correlationId as string\n const definitionId: string = request.body.definitionId as string\n\n const requestState =\n correlationId && definitionId\n ? await context.agent.siopGetAuthRequestState({\n correlationId,\n definitionId,\n errorOnNotFound: false,\n })\n : undefined\n if (!requestState || !definitionId || !correlationId) {\n console.log(\n `No authentication request mapping could be found for the given URL. correlation: ${correlationId}, definitionId: ${definitionId}`,\n )\n response.statusCode = 404\n const statusBody: AuthStatusResponse = {\n status: requestState ? requestState.status : 'error',\n error: 'No authentication request mapping could be found for the given URL.',\n correlationId,\n definitionId,\n lastUpdated: requestState ? requestState.lastUpdated : Date.now(),\n }\n return response.json(statusBody)\n }\n\n let includeVerifiedData: VerifiedDataMode = VerifiedDataMode.NONE\n if ('includeVerifiedData' in request.body) {\n includeVerifiedData = request.body.includeVerifiedData as VerifiedDataMode\n }\n\n let responseState\n if (requestState.status === 'sent') {\n responseState = (await context.agent.siopGetAuthResponseState({\n correlationId,\n definitionId,\n includeVerifiedData: includeVerifiedData,\n errorOnNotFound: false,\n })) as AuthorizationResponseStateWithVerifiedData\n }\n const overallState: AuthorizationRequestState | AuthorizationResponseStateWithVerifiedData = responseState ?? requestState\n\n const statusBody: AuthStatusResponse = {\n status: overallState.status,\n ...(overallState.error ? { error: overallState.error?.message } : {}),\n correlationId,\n definitionId,\n lastUpdated: overallState.lastUpdated,\n ...(responseState && responseState.status === AuthorizationResponseStateStatus.VERIFIED\n ? {\n payload: await responseState.response.mergedPayloads({ hasher: defaultHasher }),\n verifiedData: responseState.verifiedData,\n }\n : {}),\n }\n console.debug(`Will send auth status: ${JSON.stringify(statusBody)}`)\n if (overallState.status === 'error') {\n response.statusCode = 500\n return response.json(statusBody)\n }\n response.statusCode = 200\n return response.json(statusBody)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n\nexport function removeAuthRequestStateWebappEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`removeAuthStatus Webapp endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/webapp/definitions/:definitionId/auth-requests/:correlationId'\n router.delete(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const correlationId: string = request.params.correlationId\n const definitionId: string = request.params.definitionId\n if (!correlationId || !definitionId) {\n console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, definitionId: ${definitionId}`)\n return sendErrorResponse(response, 404, 'No authorization request could be found')\n }\n response.statusCode = 200\n return response.json(await context.agent.siopDeleteAuthState({ definitionId, correlationId }))\n } catch (error) {\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n\nexport function getDefinitionsEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`getDefinitions Webapp endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/webapp/definitions'\n router.get(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const definitions = await context.agent.pdmGetDefinitions()\n response.statusCode = 200\n return response.json(definitions)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n","import { agentContext } from '@sphereon/ssi-sdk.core'\nimport { copyGlobalAuthToEndpoints, ExpressSupport } from '@sphereon/ssi-express-support'\nimport { IPresentationExchange } from '@sphereon/ssi-sdk.presentation-exchange'\nimport { ISIOPv2RP } from '@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth'\nimport { TAgent } from '@veramo/core'\nimport express, { Express, Request, Response, Router } from 'express'\nimport { getAuthRequestSIOPv2Endpoint, verifyAuthResponseSIOPv2Endpoint } from './siop-api-functions'\nimport { IRequiredPlugins, ISIOPv2RPRestAPIOpts } from './types'\nimport {\n authStatusWebappEndpoint,\n createAuthRequestWebappEndpoint,\n getDefinitionsEndpoint,\n removeAuthRequestStateWebappEndpoint,\n} from './webapp-api-functions'\nimport swaggerUi from 'swagger-ui-express'\n\nexport class SIOPv2RPApiServer {\n private readonly _express: Express\n private readonly _router: Router\n private readonly _agent: TAgent<IPresentationExchange & ISIOPv2RP>\n private readonly _opts?: ISIOPv2RPRestAPIOpts\n private readonly _basePath: string\n\n private readonly OID4VP_SWAGGER_URL = 'https://api.swaggerhub.com/apis/SphereonInt/OID4VP/0.1.0'\n constructor(args: { agent: TAgent<IRequiredPlugins>; expressSupport: ExpressSupport; opts?: ISIOPv2RPRestAPIOpts }) {\n const { agent, opts } = args\n this._agent = agent\n copyGlobalAuthToEndpoints({ opts, keys: ['webappCreateAuthRequest', 'webappAuthStatus', 'webappDeleteAuthRequest'] })\n if (opts?.endpointOpts?.globalAuth?.secureSiopEndpoints) {\n copyGlobalAuthToEndpoints({ opts, keys: ['siopGetAuthRequest', 'siopVerifyAuthResponse'] })\n }\n\n this._opts = opts\n this._express = args.expressSupport.express\n this._router = express.Router()\n const context = agentContext(agent)\n\n const features = opts?.enableFeatures ?? ['rp-status', 'siop']\n console.log(`SIOPv2 API enabled, with features: ${JSON.stringify(features)}}`)\n\n // Webapp endpoints\n if (features.includes('rp-status')) {\n createAuthRequestWebappEndpoint(this._router, context, opts?.endpointOpts?.webappCreateAuthRequest)\n authStatusWebappEndpoint(this._router, context, opts?.endpointOpts?.webappAuthStatus)\n removeAuthRequestStateWebappEndpoint(this._router, context, opts?.endpointOpts?.webappDeleteAuthRequest)\n getDefinitionsEndpoint(this._router, context, opts?.endpointOpts?.webappGetDefinitions)\n }\n\n // SIOPv2 endpoints\n if (features.includes('siop')) {\n getAuthRequestSIOPv2Endpoint(this._router, context, opts?.endpointOpts?.siopGetAuthRequest)\n verifyAuthResponseSIOPv2Endpoint(this._router, context, opts?.endpointOpts?.siopVerifyAuthResponse)\n }\n this._basePath = opts?.endpointOpts?.basePath ?? ''\n this._express.use(this._basePath, this.router)\n this._express.set('trust proxy', opts?.endpointOpts?.trustProxy ?? true)\n this.setupSwaggerUi()\n }\n\n private setupSwaggerUi() {\n fetch(this.OID4VP_SWAGGER_URL)\n .then((res) => res.json())\n .then((swagger: any) => {\n const apiDocs = `${this._basePath}/api-docs`\n console.log(`[OID4P] API docs available at ${apiDocs}`)\n\n this._router.use(\n '/api-docs',\n (req: Request, res: Response, next: any) => {\n const regex = `${apiDocs.replace(/\\//, '\\/')}`.replace('/oid4vp', '').replace(/\\/api-docs.*/, '')\n swagger.servers = [{ url: `${req.protocol}://${req.get('host')}${regex}`, description: 'This server' }]\n // @ts-ignore\n req.swaggerDoc = swagger\n next()\n },\n swaggerUi.serveFiles(swagger, options),\n swaggerUi.setup(),\n )\n })\n .catch((err) => {\n console.log(`[OID4VP] Unable to fetch swagger document: ${err}. Will not host api-docs on this instance`)\n })\n const options = {\n // customCss: '.swagger-ui .topbar { display: none }',\n }\n }\n get express(): Express {\n return this._express\n }\n\n get router(): Router {\n return this._router\n }\n\n get agent(): TAgent<IPresentationExchange & ISIOPv2RP> {\n return this._agent\n }\n\n get opts(): ISIOPv2RPRestAPIOpts | undefined {\n return this._opts\n }\n}\n"],"mappings":";;;;AACA,SAASA,WAAgCC,yBAAyB;AAClE,SAASC,wBAAwB;AAKjC,IAAMC,6BAA6B,wBAACC,YAAAA;AAClC,QAAMC,cAAcD,QAAQE,OAAO,cAAA;AAEnC,MAAID,gBAAgB,oBAAoB;AACtC,UAAME,UAAU,OAAOH,QAAQI,SAAS,WAAWC,KAAKC,MAAMN,QAAQI,IAAI,IAAIJ,QAAQI;AACtF,WAAOD;EACT;AAEA,MAAIF,gBAAgB,qCAAqC;AACvD,UAAME,UAAUH,QAAQI;AAGxB,QAAI,OAAOD,QAAQI,4BAA4B,UAAU;AACvDC,cAAQC,IAAI,gIAAgI;AAC5IN,cAAQI,0BAA0BF,KAAKC,MAAMH,QAAQI,uBAAuB;IAC9E;AAGA,QAAI,OAAOJ,QAAQO,aAAa,UAAU;AACxC,YAAM,EAAEA,SAAQ,IAAKP;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KAAeK,SAAAA;AAC5B,cAAMC,QAAQ,GAAGH,QAAQI,QAAQ,MAAM,GAAA,CAAA,GAAQA,QAAQ,WAAW,EAAA,EAAIA,QAAQ,gBAAgB,EAAA;AAC9FL,gBAAQM,UAAU;UAAC;YAAEC,KAAK,GAAGL,IAAIM,QAAQ,MAAMN,IAAIO,IAAI,MAAA,CAAA,GAAUL,KAAAA;YAASM,aAAa;UAAc;;AAErGR,YAAIS,aAAaX;AACjBG,aAAAA;MACF,GACAS,UAAUC,WAAWb,SAASc,OAAAA,GAC9BF,UAAUG,MAAK,CAAA;IAEnB,CAAA,EACCC,MAAM,CAACC,QAAAA;AACN5C,cAAQC,IAAI,8CAA8C2C,GAAAA,2CAA8C;IAC1G,CAAA;AACF,UAAMH,UAAU,CAEhB;EACF;EACA,IAAI/C,UAAmB;AACrB,WAAO,KAAKhB;EACd;EAEA,IAAIyC,SAAiB;AACnB,WAAO,KAAKxC;EACd;EAEA,IAAIO,QAAmD;AACrD,WAAO,KAAKN;EACd;EAEA,IAAIO,OAAyC;AAC3C,WAAO,KAAKN;EACd;AACF;","names":["checkAuth","sendErrorResponse","CredentialMapper","parseAuthorizationResponse","request","contentType","header","payload","body","JSON","parse","presentation_submission","console","log","vp_token","startsWith","endsWith","CredentialMapper","isJsonLdAsString","Error","verifyAuthResponseSIOPv2Endpoint","router","context","opts","enabled","path","post","checkAuth","endpoint","response","correlationId","definitionId","tenantId","version","credentialQueryId","params","sendErrorResponse","stringify","definitionItems","agent","pdmGetDefinitions","filter","length","statusCode","statusMessage","send","authorizationResponse","definitionItem","verifiedResponse","siopVerifyAuthResponse","dcqlQueryPayload","dcqlPayload","wrappedPresentation","oid4vpSubmission","presentation","authorizationChallengeValidationResponse","presentation_during_issuance_session","is_first_party","setHeader","responseRedirectURI","siopGetRedirectURI","state","redirect_uri","error","getAuthRequestSIOPv2Endpoint","get","requestState","siopGetAuthRequestState","errorOnNotFound","requestObject","toJwt","e","message","undefined","siopUpdateAuthRequestState","AuthorizationResponseStateStatus","checkAuth","sendErrorResponse","uriWithBase","VerifiedDataMode","uuid","shaHasher","defaultHasher","createAuthRequestWebappEndpoint","router","context","opts","enabled","console","log","path","post","checkAuth","endpoint","request","response","definitionId","params","sendErrorResponse","state","body","uuid","correlationId","qrCodeOpts","requestByReferenceURI","uriWithBase","baseURI","siopBaseURI","responseURI","responseRedirectURI","response_redirect_uri","authRequestURI","agent","siopCreateAuthRequestURI","nonce","responseURIType","qrCodeDataUri","AwesomeQR","qrCode","text","draw","toString","authRequestBody","authStatusURI","webappAuthStatusPath","webappBaseURI","JSON","stringify","json","error","authStatusWebappEndpoint","requestState","siopGetAuthRequestState","errorOnNotFound","undefined","statusCode","statusBody","status","lastUpdated","Date","now","includeVerifiedData","VerifiedDataMode","NONE","responseState","siopGetAuthResponseState","overallState","message","AuthorizationResponseStateStatus","VERIFIED","payload","mergedPayloads","hasher","defaultHasher","verifiedData","debug","removeAuthRequestStateWebappEndpoint","delete","siopDeleteAuthState","getDefinitionsEndpoint","get","definitions","pdmGetDefinitions","agentContext","copyGlobalAuthToEndpoints","express","swaggerUi","SIOPv2RPApiServer","_express","_router","_agent","_opts","_basePath","OID4VP_SWAGGER_URL","constructor","args","agent","opts","copyGlobalAuthToEndpoints","keys","endpointOpts","globalAuth","secureSiopEndpoints","expressSupport","express","Router","context","agentContext","features","enableFeatures","console","log","JSON","stringify","includes","createAuthRequestWebappEndpoint","webappCreateAuthRequest","authStatusWebappEndpoint","webappAuthStatus","removeAuthRequestStateWebappEndpoint","webappDeleteAuthRequest","getDefinitionsEndpoint","webappGetDefinitions","getAuthRequestSIOPv2Endpoint","siopGetAuthRequest","verifyAuthResponseSIOPv2Endpoint","siopVerifyAuthResponse","basePath","use","router","set","trustProxy","setupSwaggerUi","fetch","then","res","json","swagger","apiDocs","req","next","regex","replace","servers","url","protocol","get","description","swaggerDoc","swaggerUi","serveFiles","options","setup","catch","err"]}
|