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