@sphereon/ssi-sdk.siopv2-oid4vp-rp-rest-api 0.34.1-feat.SSISDK.35.64 → 0.34.1-feat.SSISDK.55.243
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 +203 -144
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -13
- package/dist/index.d.ts +34 -13
- package/dist/index.js +201 -142
- package/dist/index.js.map +1 -1
- package/package.json +23 -18
- package/src/index.ts +1 -1
- package/src/middleware/validationMiddleware.ts +20 -0
- package/src/siop-api-functions.ts +49 -38
- package/src/siopv2-rp-api-server.ts +9 -10
- package/src/types/types.ts +38 -3
- package/src/universal-oid4vp-api-functions.ts +191 -0
- package/src/webapp-api-functions.ts +0 -183
package/dist/index.js
CHANGED
|
@@ -2,7 +2,6 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
// src/siop-api-functions.ts
|
|
5
|
-
import { PresentationDefinitionLocation } from "@sphereon/did-auth-siop";
|
|
6
5
|
import { checkAuth, sendErrorResponse } from "@sphereon/ssi-express-support";
|
|
7
6
|
import { CredentialMapper } from "@sphereon/ssi-types";
|
|
8
7
|
var parseAuthorizationResponse = /* @__PURE__ */ __name((request) => {
|
|
@@ -27,34 +26,44 @@ var parseAuthorizationResponse = /* @__PURE__ */ __name((request) => {
|
|
|
27
26
|
}
|
|
28
27
|
throw new Error(`Unsupported content type: ${contentType}. Currently only application/x-www-form-urlencoded and application/json (for direct_post) are supported`);
|
|
29
28
|
}, "parseAuthorizationResponse");
|
|
29
|
+
var validatePresentationSubmission = /* @__PURE__ */ __name((query, submission) => {
|
|
30
|
+
return query.credentials.every((credential) => credential.id in submission);
|
|
31
|
+
}, "validatePresentationSubmission");
|
|
30
32
|
function verifyAuthResponseSIOPv2Endpoint(router, context, opts) {
|
|
31
33
|
if (opts?.enabled === false) {
|
|
32
34
|
console.log(`verifyAuthResponse SIOP endpoint is disabled`);
|
|
33
35
|
return;
|
|
34
36
|
}
|
|
35
|
-
const path = opts?.path ?? "/siop/
|
|
37
|
+
const path = opts?.path ?? "/siop/queries/:queryId/auth-responses/:correlationId";
|
|
36
38
|
router.post(path, checkAuth(opts?.endpoint), async (request, response) => {
|
|
37
39
|
try {
|
|
38
|
-
const { correlationId,
|
|
39
|
-
if (!correlationId
|
|
40
|
-
console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}
|
|
40
|
+
const { correlationId, queryId, tenantId, version } = request.params;
|
|
41
|
+
if (!correlationId) {
|
|
42
|
+
console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}`);
|
|
41
43
|
return sendErrorResponse(response, 404, "No authorization request could be found");
|
|
42
44
|
}
|
|
43
|
-
console.
|
|
44
|
-
console.
|
|
45
|
+
console.debug("Authorization Response (siop-sessions");
|
|
46
|
+
console.debug(JSON.stringify(request.body, null, 2));
|
|
45
47
|
const definitionItems = await context.agent.pdmGetDefinitions({
|
|
46
48
|
filter: [
|
|
47
49
|
{
|
|
48
|
-
|
|
49
|
-
tenantId
|
|
50
|
-
|
|
50
|
+
queryId,
|
|
51
|
+
...tenantId && {
|
|
52
|
+
tenantId
|
|
53
|
+
},
|
|
54
|
+
...version && {
|
|
55
|
+
version
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: queryId
|
|
51
60
|
}
|
|
52
61
|
]
|
|
53
62
|
});
|
|
54
63
|
if (definitionItems.length === 0) {
|
|
55
|
-
console.log(`Could not get
|
|
64
|
+
console.log(`Could not get dcql query with id ${queryId} from agent. Will return 404`);
|
|
56
65
|
response.statusCode = 404;
|
|
57
|
-
response.statusMessage = `No definition ${
|
|
66
|
+
response.statusMessage = `No definition ${queryId}`;
|
|
58
67
|
return response.send();
|
|
59
68
|
}
|
|
60
69
|
const authorizationResponse = parseAuthorizationResponse(request);
|
|
@@ -63,18 +72,11 @@ function verifyAuthResponseSIOPv2Endpoint(router, context, opts) {
|
|
|
63
72
|
const verifiedResponse = await context.agent.siopVerifyAuthResponse({
|
|
64
73
|
authorizationResponse,
|
|
65
74
|
correlationId,
|
|
66
|
-
|
|
67
|
-
presentationDefinitions: [
|
|
68
|
-
{
|
|
69
|
-
location: opts?.presentationDefinitionLocation ?? PresentationDefinitionLocation.TOPLEVEL_PRESENTATION_DEF,
|
|
70
|
-
definition: definitionItem.definitionPayload
|
|
71
|
-
}
|
|
72
|
-
],
|
|
73
|
-
dcqlQuery: definitionItem.dcqlPayload
|
|
75
|
+
dcqlQuery: definitionItem.query
|
|
74
76
|
});
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
77
|
-
console.log("
|
|
77
|
+
const presentation = verifiedResponse?.oid4vpSubmission?.presentation;
|
|
78
|
+
if (presentation && validatePresentationSubmission(definitionItem.query, presentation)) {
|
|
79
|
+
console.log("PRESENTATIONS:" + JSON.stringify(presentation, null, 2));
|
|
78
80
|
response.statusCode = 200;
|
|
79
81
|
const authorizationChallengeValidationResponse = {
|
|
80
82
|
presentation_during_issuance_session: verifiedResponse.correlationId
|
|
@@ -85,7 +87,7 @@ function verifyAuthResponseSIOPv2Endpoint(router, context, opts) {
|
|
|
85
87
|
}
|
|
86
88
|
const responseRedirectURI = await context.agent.siopGetRedirectURI({
|
|
87
89
|
correlationId,
|
|
88
|
-
|
|
90
|
+
queryId,
|
|
89
91
|
state: verifiedResponse.state
|
|
90
92
|
});
|
|
91
93
|
if (responseRedirectURI) {
|
|
@@ -112,24 +114,38 @@ function getAuthRequestSIOPv2Endpoint(router, context, opts) {
|
|
|
112
114
|
console.log(`getAuthRequest SIOP endpoint is disabled`);
|
|
113
115
|
return;
|
|
114
116
|
}
|
|
115
|
-
const path = opts?.path ?? "/siop/
|
|
117
|
+
const path = opts?.path ?? "/siop/queries/:queryId/auth-requests/:correlationId";
|
|
116
118
|
router.get(path, checkAuth(opts?.endpoint), async (request, response) => {
|
|
117
119
|
try {
|
|
118
120
|
const correlationId = request.params.correlationId;
|
|
119
|
-
const
|
|
120
|
-
if (!correlationId || !
|
|
121
|
-
console.log(`No authorization request could be found for the given url. correlationId: ${correlationId},
|
|
121
|
+
const queryId = request.params.queryId;
|
|
122
|
+
if (!correlationId || !queryId) {
|
|
123
|
+
console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, queryId: ${queryId}`);
|
|
122
124
|
return sendErrorResponse(response, 404, "No authorization request could be found");
|
|
123
125
|
}
|
|
124
126
|
const requestState = await context.agent.siopGetAuthRequestState({
|
|
125
127
|
correlationId,
|
|
126
|
-
definitionId,
|
|
127
128
|
errorOnNotFound: false
|
|
128
129
|
});
|
|
129
130
|
if (!requestState) {
|
|
130
|
-
console.log(`No authorization request could be found for the given url in the state manager. correlationId: ${correlationId}, definitionId: ${
|
|
131
|
+
console.log(`No authorization request could be found for the given url in the state manager. correlationId: ${correlationId}, definitionId: ${queryId}`);
|
|
131
132
|
return sendErrorResponse(response, 404, `No authorization request could be found`);
|
|
132
133
|
}
|
|
134
|
+
const definitionItems = await context.agent.pdmGetDefinitions({
|
|
135
|
+
filter: [
|
|
136
|
+
{
|
|
137
|
+
queryId
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
});
|
|
141
|
+
if (definitionItems.length === 0) {
|
|
142
|
+
console.log(`Could not get dcql query with id ${queryId} from agent. Will return 404`);
|
|
143
|
+
response.statusCode = 404;
|
|
144
|
+
response.statusMessage = `No definition ${queryId}`;
|
|
145
|
+
return response.send();
|
|
146
|
+
}
|
|
147
|
+
const payload = requestState.request?.requestObject?.getPayload();
|
|
148
|
+
payload.dcql_query = definitionItems[0].query;
|
|
133
149
|
const requestObject = await requestState.request?.requestObject?.toJwt();
|
|
134
150
|
console.log("JWT Request object:");
|
|
135
151
|
console.log(requestObject);
|
|
@@ -144,8 +160,7 @@ function getAuthRequestSIOPv2Endpoint(router, context, opts) {
|
|
|
144
160
|
} finally {
|
|
145
161
|
await context.agent.siopUpdateAuthRequestState({
|
|
146
162
|
correlationId,
|
|
147
|
-
|
|
148
|
-
state: "sent",
|
|
163
|
+
state: "authorization_request_created",
|
|
149
164
|
error
|
|
150
165
|
});
|
|
151
166
|
}
|
|
@@ -156,45 +171,89 @@ function getAuthRequestSIOPv2Endpoint(router, context, opts) {
|
|
|
156
171
|
}
|
|
157
172
|
__name(getAuthRequestSIOPv2Endpoint, "getAuthRequestSIOPv2Endpoint");
|
|
158
173
|
|
|
159
|
-
// src/
|
|
160
|
-
import {
|
|
174
|
+
// src/universal-oid4vp-api-functions.ts
|
|
175
|
+
import { AuthorizationRequestStateStatus, createAuthorizationRequestFromPayload, CreateAuthorizationRequestPayloadSchema } from "@sphereon/did-auth-siop";
|
|
161
176
|
import { checkAuth as checkAuth2, sendErrorResponse as sendErrorResponse2 } from "@sphereon/ssi-express-support";
|
|
162
177
|
import { uriWithBase } from "@sphereon/ssi-sdk.siopv2-oid4vp-common";
|
|
163
|
-
import { VerifiedDataMode } from "@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth";
|
|
164
178
|
import uuid from "short-uuid";
|
|
165
|
-
|
|
166
|
-
|
|
179
|
+
|
|
180
|
+
// src/middleware/validationMiddleware.ts
|
|
181
|
+
import { ZodError } from "zod";
|
|
182
|
+
var validateData = /* @__PURE__ */ __name((schema) => {
|
|
183
|
+
return (req, res, next) => {
|
|
184
|
+
try {
|
|
185
|
+
schema.parse(req.body);
|
|
186
|
+
next();
|
|
187
|
+
} catch (error) {
|
|
188
|
+
if (error instanceof ZodError) {
|
|
189
|
+
const errorMessages = error.issues.map((issue) => ({
|
|
190
|
+
message: `${issue.path.join(".")} is ${issue.message}`
|
|
191
|
+
}));
|
|
192
|
+
res.status(400).json({
|
|
193
|
+
status: 400,
|
|
194
|
+
message: "Invalid data",
|
|
195
|
+
error_details: errorMessages[0].message
|
|
196
|
+
});
|
|
197
|
+
} else {
|
|
198
|
+
res.status(500).json({
|
|
199
|
+
status: 500,
|
|
200
|
+
message: "Internal Server Error"
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
}, "validateData");
|
|
206
|
+
|
|
207
|
+
// src/universal-oid4vp-api-functions.ts
|
|
208
|
+
function createAuthRequestUniversalOID4VPEndpoint(router, context, opts) {
|
|
167
209
|
if (opts?.enabled === false) {
|
|
168
|
-
console.log(`createAuthRequest
|
|
210
|
+
console.log(`createAuthRequest universal OID4VP endpoint is disabled`);
|
|
169
211
|
return;
|
|
170
212
|
}
|
|
171
|
-
const path = opts?.path ?? "/
|
|
172
|
-
router.post(path, checkAuth2(opts?.endpoint), async (request, response) => {
|
|
213
|
+
const path = opts?.path ?? "/backend/auth/requests";
|
|
214
|
+
router.post(path, checkAuth2(opts?.endpoint), validateData(CreateAuthorizationRequestPayloadSchema), async (request, response) => {
|
|
173
215
|
try {
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
216
|
+
const authRequest = createAuthorizationRequestFromPayload(request.body);
|
|
217
|
+
const correlationId = authRequest.correlationId ?? uuid.uuid();
|
|
218
|
+
const qrCodeOpts = authRequest.qrCode ? {
|
|
219
|
+
...authRequest.qrCode
|
|
220
|
+
} : opts?.qrCodeOpts;
|
|
221
|
+
const queryId = authRequest.queryId;
|
|
222
|
+
const definitionItems = await context.agent.pdmGetDefinitions({
|
|
223
|
+
filter: [
|
|
224
|
+
{
|
|
225
|
+
id: queryId
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
queryId
|
|
229
|
+
}
|
|
230
|
+
]
|
|
231
|
+
});
|
|
232
|
+
if (definitionItems.length === 0) {
|
|
233
|
+
console.log(`No query could be found for the given id. Query id: ${queryId}`);
|
|
234
|
+
return sendErrorResponse2(response, 404, {
|
|
235
|
+
status: 404,
|
|
236
|
+
message: "No query could be found"
|
|
237
|
+
});
|
|
177
238
|
}
|
|
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
|
|
239
|
+
const requestByReferenceURI = uriWithBase(`/siop/queries/${queryId}/auth-requests/${correlationId}`, {
|
|
240
|
+
baseURI: authRequest.requestUriBase ?? opts?.siopBaseURI
|
|
183
241
|
});
|
|
184
|
-
const responseURI = uriWithBase(`/siop/
|
|
242
|
+
const responseURI = uriWithBase(`/siop/queries/${queryId}/auth-responses/${correlationId}`, {
|
|
185
243
|
baseURI: opts?.siopBaseURI
|
|
186
244
|
});
|
|
187
|
-
const responseRedirectURI = ("response_redirect_uri" in request.body && request.body.response_redirect_uri) ?? ("responseRedirectURI" in request.body && request.body.responseRedirectURI);
|
|
188
245
|
const authRequestURI = await context.agent.siopCreateAuthRequestURI({
|
|
189
|
-
|
|
246
|
+
queryId,
|
|
190
247
|
correlationId,
|
|
191
|
-
state,
|
|
192
248
|
nonce: uuid.uuid(),
|
|
193
249
|
requestByReferenceURI,
|
|
194
250
|
responseURIType: "response_uri",
|
|
195
251
|
responseURI,
|
|
196
|
-
...
|
|
197
|
-
responseRedirectURI
|
|
252
|
+
...authRequest.directPostResponseRedirectUri && {
|
|
253
|
+
responseRedirectURI: authRequest.directPostResponseRedirectUri
|
|
254
|
+
},
|
|
255
|
+
...authRequest.callback && {
|
|
256
|
+
callback: authRequest.callback
|
|
198
257
|
}
|
|
199
258
|
});
|
|
200
259
|
let qrCodeDataUri;
|
|
@@ -205,135 +264,135 @@ function createAuthRequestWebappEndpoint(router, context, opts) {
|
|
|
205
264
|
text: authRequestURI
|
|
206
265
|
});
|
|
207
266
|
qrCodeDataUri = `data:image/png;base64,${(await qrCode.draw()).toString("base64")}`;
|
|
267
|
+
} else {
|
|
268
|
+
qrCodeDataUri = authRequestURI;
|
|
208
269
|
}
|
|
209
270
|
const authRequestBody = {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
authStatusURI: `${uriWithBase(opts?.webappAuthStatusPath ?? "/webapp/auth-status", {
|
|
271
|
+
query_id: queryId,
|
|
272
|
+
correlation_id: correlationId,
|
|
273
|
+
request_uri: authRequestURI,
|
|
274
|
+
status_uri: `${uriWithBase(opts?.webappAuthStatusPath ?? `/backend/auth/status/${correlationId}`, {
|
|
215
275
|
baseURI: opts?.webappBaseURI
|
|
216
276
|
})}`,
|
|
217
277
|
...qrCodeDataUri && {
|
|
218
|
-
qrCodeDataUri
|
|
278
|
+
qr_uri: qrCodeDataUri
|
|
219
279
|
}
|
|
220
280
|
};
|
|
221
281
|
console.log(`Auth Request URI data to send back: ${JSON.stringify(authRequestBody)}`);
|
|
222
|
-
return response.json(authRequestBody);
|
|
282
|
+
return response.status(201).json(authRequestBody);
|
|
223
283
|
} catch (error) {
|
|
224
|
-
return sendErrorResponse2(response, 500,
|
|
284
|
+
return sendErrorResponse2(response, 500, {
|
|
285
|
+
status: 500,
|
|
286
|
+
message: "Could not create an authorization request URI"
|
|
287
|
+
}, error);
|
|
225
288
|
}
|
|
226
289
|
});
|
|
227
290
|
}
|
|
228
|
-
__name(
|
|
229
|
-
function
|
|
291
|
+
__name(createAuthRequestUniversalOID4VPEndpoint, "createAuthRequestUniversalOID4VPEndpoint");
|
|
292
|
+
function removeAuthRequestStateUniversalOID4VPEndpoint(router, context, opts) {
|
|
230
293
|
if (opts?.enabled === false) {
|
|
231
|
-
console.log(`
|
|
294
|
+
console.log(`removeAuthStatus universal OID4VP endpoint is disabled`);
|
|
232
295
|
return;
|
|
233
296
|
}
|
|
234
|
-
const path = opts?.path ?? "/
|
|
235
|
-
router.
|
|
297
|
+
const path = opts?.path ?? "/backend/auth/requests/:correlationId";
|
|
298
|
+
router.delete(path, checkAuth2(opts?.endpoint), async (request, response) => {
|
|
236
299
|
try {
|
|
237
|
-
|
|
238
|
-
const
|
|
239
|
-
const definitionId = request.body.definitionId;
|
|
240
|
-
const requestState = correlationId && definitionId ? await context.agent.siopGetAuthRequestState({
|
|
300
|
+
const correlationId = request.params.correlationId;
|
|
301
|
+
const authRequestState = await context.agent.siopGetAuthRequestState({
|
|
241
302
|
correlationId,
|
|
242
|
-
definitionId,
|
|
243
303
|
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);
|
|
304
|
+
});
|
|
305
|
+
if (!authRequestState) {
|
|
306
|
+
console.log(`No authorization request could be found for the given correlationId. correlationId: ${correlationId}`);
|
|
307
|
+
return sendErrorResponse2(response, 404, {
|
|
308
|
+
status: 404,
|
|
309
|
+
message: "No authorization request could be found"
|
|
310
|
+
});
|
|
256
311
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
312
|
+
await context.agent.siopDeleteAuthState({
|
|
313
|
+
correlationId
|
|
314
|
+
});
|
|
315
|
+
return response.status(204).json();
|
|
316
|
+
} catch (error) {
|
|
317
|
+
return sendErrorResponse2(response, 500, {
|
|
318
|
+
status: 500,
|
|
319
|
+
message: error.message
|
|
320
|
+
}, error);
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
__name(removeAuthRequestStateUniversalOID4VPEndpoint, "removeAuthRequestStateUniversalOID4VPEndpoint");
|
|
325
|
+
function authStatusUniversalOID4VPEndpoint(router, context, opts) {
|
|
326
|
+
if (opts?.enabled === false) {
|
|
327
|
+
console.log(`authStatus universal OID4VP endpoint is disabled`);
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
const path = opts?.path ?? "/backend/auth/status/:correlationId";
|
|
331
|
+
router.get(path, checkAuth2(opts?.endpoint), async (request, response) => {
|
|
332
|
+
try {
|
|
333
|
+
console.log("Received auth-status request...");
|
|
334
|
+
const correlationId = request.params.correlationId;
|
|
335
|
+
const requestState = await context.agent.siopGetAuthRequestState({
|
|
336
|
+
correlationId,
|
|
337
|
+
errorOnNotFound: false
|
|
338
|
+
});
|
|
339
|
+
if (!requestState) {
|
|
340
|
+
console.log(`No authorization request could be found for the given correlationId. correlationId: ${correlationId}`);
|
|
341
|
+
return sendErrorResponse2(response, 404, {
|
|
342
|
+
status: 404,
|
|
343
|
+
message: "No authorization request could be found"
|
|
344
|
+
});
|
|
260
345
|
}
|
|
261
346
|
let responseState;
|
|
262
|
-
if (requestState.status ===
|
|
347
|
+
if (requestState.status === AuthorizationRequestStateStatus.RETRIEVED) {
|
|
263
348
|
responseState = await context.agent.siopGetAuthResponseState({
|
|
264
349
|
correlationId,
|
|
265
|
-
definitionId,
|
|
266
|
-
includeVerifiedData,
|
|
267
350
|
errorOnNotFound: false
|
|
268
351
|
});
|
|
269
352
|
}
|
|
270
353
|
const overallState = responseState ?? requestState;
|
|
271
354
|
const statusBody = {
|
|
272
355
|
status: overallState.status,
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
...
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}),
|
|
283
|
-
verifiedData: responseState.verifiedData
|
|
284
|
-
} : {}
|
|
356
|
+
correlation_id: overallState.correlationId,
|
|
357
|
+
query_id: overallState.queryId,
|
|
358
|
+
last_updated: overallState.lastUpdated,
|
|
359
|
+
..."verifiedData" in overallState && {
|
|
360
|
+
verified_data: overallState.verifiedData
|
|
361
|
+
},
|
|
362
|
+
...overallState.error && {
|
|
363
|
+
message: overallState.error.message
|
|
364
|
+
}
|
|
285
365
|
};
|
|
286
366
|
console.debug(`Will send auth status: ${JSON.stringify(statusBody)}`);
|
|
287
367
|
if (overallState.status === "error") {
|
|
288
|
-
response.
|
|
289
|
-
return response.json(statusBody);
|
|
368
|
+
return response.status(500).json(statusBody);
|
|
290
369
|
}
|
|
291
|
-
response.
|
|
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");
|
|
312
|
-
}
|
|
313
|
-
response.statusCode = 200;
|
|
314
|
-
return response.json(await context.agent.siopDeleteAuthState({
|
|
315
|
-
definitionId,
|
|
316
|
-
correlationId
|
|
317
|
-
}));
|
|
370
|
+
return response.status(200).json(statusBody);
|
|
318
371
|
} catch (error) {
|
|
319
|
-
return sendErrorResponse2(response, 500,
|
|
372
|
+
return sendErrorResponse2(response, 500, {
|
|
373
|
+
status: 500,
|
|
374
|
+
message: error.message
|
|
375
|
+
}, error);
|
|
320
376
|
}
|
|
321
377
|
});
|
|
322
378
|
}
|
|
323
|
-
__name(
|
|
379
|
+
__name(authStatusUniversalOID4VPEndpoint, "authStatusUniversalOID4VPEndpoint");
|
|
324
380
|
function getDefinitionsEndpoint(router, context, opts) {
|
|
325
381
|
if (opts?.enabled === false) {
|
|
326
|
-
console.log(`getDefinitions
|
|
382
|
+
console.log(`getDefinitions universal OID4VP endpoint is disabled`);
|
|
327
383
|
return;
|
|
328
384
|
}
|
|
329
|
-
const path = opts?.path ?? "/
|
|
385
|
+
const path = opts?.path ?? "/backend/definitions";
|
|
330
386
|
router.get(path, checkAuth2(opts?.endpoint), async (request, response) => {
|
|
331
387
|
try {
|
|
332
388
|
const definitions = await context.agent.pdmGetDefinitions();
|
|
333
389
|
response.statusCode = 200;
|
|
334
390
|
return response.json(definitions);
|
|
335
391
|
} catch (error) {
|
|
336
|
-
return sendErrorResponse2(response, 500,
|
|
392
|
+
return sendErrorResponse2(response, 500, {
|
|
393
|
+
status: 500,
|
|
394
|
+
message: error.message
|
|
395
|
+
}, error);
|
|
337
396
|
}
|
|
338
397
|
});
|
|
339
398
|
}
|
|
@@ -384,9 +443,9 @@ var SIOPv2RPApiServer = class {
|
|
|
384
443
|
];
|
|
385
444
|
console.log(`SIOPv2 API enabled, with features: ${JSON.stringify(features)}}`);
|
|
386
445
|
if (features.includes("rp-status")) {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
446
|
+
createAuthRequestUniversalOID4VPEndpoint(this._router, context, opts?.endpointOpts?.webappCreateAuthRequest);
|
|
447
|
+
authStatusUniversalOID4VPEndpoint(this._router, context, opts?.endpointOpts?.webappAuthStatus);
|
|
448
|
+
removeAuthRequestStateUniversalOID4VPEndpoint(this._router, context, opts?.endpointOpts?.webappDeleteAuthRequest);
|
|
390
449
|
getDefinitionsEndpoint(this._router, context, opts?.endpointOpts?.webappGetDefinitions);
|
|
391
450
|
}
|
|
392
451
|
if (features.includes("siop")) {
|
|
@@ -433,11 +492,11 @@ var SIOPv2RPApiServer = class {
|
|
|
433
492
|
};
|
|
434
493
|
export {
|
|
435
494
|
SIOPv2RPApiServer,
|
|
436
|
-
|
|
437
|
-
|
|
495
|
+
authStatusUniversalOID4VPEndpoint,
|
|
496
|
+
createAuthRequestUniversalOID4VPEndpoint,
|
|
438
497
|
getAuthRequestSIOPv2Endpoint,
|
|
439
498
|
getDefinitionsEndpoint,
|
|
440
|
-
|
|
499
|
+
removeAuthRequestStateUniversalOID4VPEndpoint,
|
|
441
500
|
verifyAuthResponseSIOPv2Endpoint
|
|
442
501
|
};
|
|
443
502
|
//# sourceMappingURL=index.js.map
|