@sphereon/ssi-sdk.siopv2-oid4vp-rp-rest-api 0.32.1-next.54 → 0.33.1-feature.vcdm2.4
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.js +4 -20
- package/dist/index.js.map +1 -1
- package/dist/siop-api-functions.d.ts.map +1 -1
- package/dist/siop-api-functions.js +34 -48
- package/dist/siop-api-functions.js.map +1 -1
- package/dist/siopv2-rp-api-server.d.ts +3 -0
- package/dist/siopv2-rp-api-server.d.ts.map +1 -1
- package/dist/siopv2-rp-api-server.js +50 -26
- package/dist/siopv2-rp-api-server.js.map +1 -1
- package/dist/types/QRCode.types.d.ts +204 -0
- package/dist/types/QRCode.types.d.ts.map +1 -0
- package/dist/types/QRCode.types.js +2 -0
- package/dist/types/QRCode.types.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/{types.d.ts → types/types.d.ts} +5 -1
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +2 -0
- package/dist/types/types.js.map +1 -0
- package/dist/webapp-api-functions.d.ts +1 -0
- package/dist/webapp-api-functions.d.ts.map +1 -1
- package/dist/webapp-api-functions.js +95 -73
- package/dist/webapp-api-functions.js.map +1 -1
- package/package.json +21 -16
- package/src/siop-api-functions.ts +6 -3
- package/src/siopv2-rp-api-server.ts +42 -3
- package/src/types/QRCode.types.ts +227 -0
- package/src/types/index.ts +2 -0
- package/src/{types.ts → types/types.ts} +5 -1
- package/src/webapp-api-functions.ts +45 -12
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
1
|
/**
|
|
18
2
|
* @public
|
|
19
3
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
4
|
+
export * from './siop-api-functions';
|
|
5
|
+
export * from './webapp-api-functions';
|
|
6
|
+
export * from './types';
|
|
7
|
+
export * from './siopv2-rp-api-server';
|
|
24
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,SAAS,CAAA;AACvB,cAAc,wBAAwB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"siop-api-functions.d.ts","sourceRoot":"","sources":["../src/siop-api-functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,8BAA8B,EAAE,MAAM,yBAAyB,CAAA;AACtG,OAAO,EAAa,mBAAmB,EAAqB,MAAM,+BAA+B,CAAA;AAGjG,OAAO,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAsC1C,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB,EACzB,IAAI,CAAC,EAAE,mBAAmB,GAAG;IAAE,8BAA8B,CAAC,EAAE,8BAA8B,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"siop-api-functions.d.ts","sourceRoot":"","sources":["../src/siop-api-functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,8BAA8B,EAAE,MAAM,yBAAyB,CAAA;AACtG,OAAO,EAAa,mBAAmB,EAAqB,MAAM,+BAA+B,CAAA;AAGjG,OAAO,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAsC1C,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB,EACzB,IAAI,CAAC,EAAE,mBAAmB,GAAG;IAAE,8BAA8B,CAAC,EAAE,8BAA8B,CAAA;CAAE,QAyEjG;AAED,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,mBAAmB,QAiDjH"}
|
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.verifyAuthResponseSIOPv2Endpoint = verifyAuthResponseSIOPv2Endpoint;
|
|
13
|
-
exports.getAuthRequestSIOPv2Endpoint = getAuthRequestSIOPv2Endpoint;
|
|
14
|
-
const did_auth_siop_1 = require("@sphereon/did-auth-siop");
|
|
15
|
-
const ssi_express_support_1 = require("@sphereon/ssi-express-support");
|
|
16
|
-
const ssi_types_1 = require("@sphereon/ssi-types");
|
|
1
|
+
import { PresentationDefinitionLocation } from '@sphereon/did-auth-siop';
|
|
2
|
+
import { checkAuth, sendErrorResponse } from '@sphereon/ssi-express-support';
|
|
3
|
+
import { CredentialMapper } from '@sphereon/ssi-types';
|
|
17
4
|
const parseAuthorizationResponse = (request) => {
|
|
18
5
|
const contentType = request.header('content-type');
|
|
19
6
|
if (contentType === 'application/json') {
|
|
@@ -32,7 +19,7 @@ const parseAuthorizationResponse = (request) => {
|
|
|
32
19
|
const { vp_token } = payload;
|
|
33
20
|
// The only use case where vp_object is an object is JsonLdAsString atm. For arrays, any objects will be parsed along with the array
|
|
34
21
|
// (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)
|
|
35
|
-
if ((vp_token.startsWith('[') && vp_token.endsWith(']')) ||
|
|
22
|
+
if ((vp_token.startsWith('[') && vp_token.endsWith(']')) || CredentialMapper.isJsonLdAsString(vp_token)) {
|
|
36
23
|
payload.vp_token = JSON.parse(vp_token);
|
|
37
24
|
}
|
|
38
25
|
}
|
|
@@ -40,24 +27,22 @@ const parseAuthorizationResponse = (request) => {
|
|
|
40
27
|
}
|
|
41
28
|
throw new Error(`Unsupported content type: ${contentType}. Currently only application/x-www-form-urlencoded and application/json (for direct_post) are supported`);
|
|
42
29
|
};
|
|
43
|
-
function verifyAuthResponseSIOPv2Endpoint(router, context, opts) {
|
|
44
|
-
|
|
45
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
30
|
+
export function verifyAuthResponseSIOPv2Endpoint(router, context, opts) {
|
|
31
|
+
if (opts?.enabled === false) {
|
|
46
32
|
console.log(`verifyAuthResponse SIOP endpoint is disabled`);
|
|
47
33
|
return;
|
|
48
34
|
}
|
|
49
|
-
const path =
|
|
50
|
-
router.post(path,
|
|
51
|
-
var _a, _b;
|
|
35
|
+
const path = opts?.path ?? '/siop/definitions/:definitionId/auth-responses/:correlationId';
|
|
36
|
+
router.post(path, checkAuth(opts?.endpoint), async (request, response) => {
|
|
52
37
|
try {
|
|
53
38
|
const { correlationId, definitionId, tenantId, version } = request.params;
|
|
54
39
|
if (!correlationId || !definitionId) {
|
|
55
40
|
console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, definitionId: ${definitionId}`);
|
|
56
|
-
return
|
|
41
|
+
return sendErrorResponse(response, 404, 'No authorization request could be found');
|
|
57
42
|
}
|
|
58
43
|
console.log('Authorization Response (siop-sessions');
|
|
59
44
|
console.log(JSON.stringify(request.body, null, 2));
|
|
60
|
-
const definitionItems =
|
|
45
|
+
const definitionItems = await context.agent.pdmGetDefinitions({ filter: [{ definitionId, tenantId, version }] });
|
|
61
46
|
if (definitionItems.length === 0) {
|
|
62
47
|
console.log(`Could not get definition ${definitionId} from agent. Will return 404`);
|
|
63
48
|
response.statusCode = 404;
|
|
@@ -66,30 +51,33 @@ function verifyAuthResponseSIOPv2Endpoint(router, context, opts) {
|
|
|
66
51
|
}
|
|
67
52
|
const authorizationResponse = parseAuthorizationResponse(request);
|
|
68
53
|
console.log(`URI: ${JSON.stringify(authorizationResponse)}`);
|
|
69
|
-
const
|
|
70
|
-
const verifiedResponse =
|
|
54
|
+
const definitionItem = definitionItems[0];
|
|
55
|
+
const verifiedResponse = await context.agent.siopVerifyAuthResponse({
|
|
71
56
|
authorizationResponse,
|
|
72
57
|
correlationId,
|
|
73
58
|
definitionId,
|
|
74
59
|
presentationDefinitions: [
|
|
75
60
|
{
|
|
76
|
-
location:
|
|
77
|
-
definition,
|
|
61
|
+
location: opts?.presentationDefinitionLocation ?? PresentationDefinitionLocation.TOPLEVEL_PRESENTATION_DEF,
|
|
62
|
+
definition: definitionItem.definitionPayload,
|
|
78
63
|
},
|
|
79
64
|
],
|
|
65
|
+
dcqlQuery: definitionItem.dcqlPayload,
|
|
80
66
|
});
|
|
81
|
-
const wrappedPresentation =
|
|
67
|
+
const wrappedPresentation = verifiedResponse?.oid4vpSubmission?.presentations[0];
|
|
82
68
|
if (wrappedPresentation) {
|
|
83
69
|
// const credentialSubject = wrappedPresentation.presentation.verifiableCredential[0]?.credential?.credentialSubject
|
|
84
70
|
// console.log(JSON.stringify(credentialSubject, null, 2))
|
|
85
71
|
console.log('PRESENTATION:' + JSON.stringify(wrappedPresentation.presentation, null, 2));
|
|
86
72
|
response.statusCode = 200;
|
|
87
|
-
const authorizationChallengeValidationResponse = {
|
|
73
|
+
const authorizationChallengeValidationResponse = {
|
|
74
|
+
presentation_during_issuance_session: verifiedResponse.correlationId,
|
|
75
|
+
};
|
|
88
76
|
if (authorizationResponse.is_first_party) {
|
|
89
77
|
response.setHeader('Content-Type', 'application/json');
|
|
90
78
|
return response.send(JSON.stringify(authorizationChallengeValidationResponse));
|
|
91
79
|
}
|
|
92
|
-
const responseRedirectURI =
|
|
80
|
+
const responseRedirectURI = await context.agent.siopGetRedirectURI({ correlationId, definitionId, state: verifiedResponse.state });
|
|
93
81
|
if (responseRedirectURI) {
|
|
94
82
|
response.setHeader('Content-Type', 'application/json');
|
|
95
83
|
return response.send(JSON.stringify({ redirect_uri: responseRedirectURI }));
|
|
@@ -105,36 +93,34 @@ function verifyAuthResponseSIOPv2Endpoint(router, context, opts) {
|
|
|
105
93
|
}
|
|
106
94
|
catch (error) {
|
|
107
95
|
console.error(error);
|
|
108
|
-
return
|
|
96
|
+
return sendErrorResponse(response, 500, 'Could not verify auth status', error);
|
|
109
97
|
}
|
|
110
|
-
})
|
|
98
|
+
});
|
|
111
99
|
}
|
|
112
|
-
function getAuthRequestSIOPv2Endpoint(router, context, opts) {
|
|
113
|
-
|
|
114
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
100
|
+
export function getAuthRequestSIOPv2Endpoint(router, context, opts) {
|
|
101
|
+
if (opts?.enabled === false) {
|
|
115
102
|
console.log(`getAuthRequest SIOP endpoint is disabled`);
|
|
116
103
|
return;
|
|
117
104
|
}
|
|
118
|
-
const path =
|
|
119
|
-
router.get(path,
|
|
120
|
-
var _a, _b;
|
|
105
|
+
const path = opts?.path ?? '/siop/definitions/:definitionId/auth-requests/:correlationId';
|
|
106
|
+
router.get(path, checkAuth(opts?.endpoint), async (request, response) => {
|
|
121
107
|
try {
|
|
122
108
|
const correlationId = request.params.correlationId;
|
|
123
109
|
const definitionId = request.params.definitionId;
|
|
124
110
|
if (!correlationId || !definitionId) {
|
|
125
111
|
console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, definitionId: ${definitionId}`);
|
|
126
|
-
return
|
|
112
|
+
return sendErrorResponse(response, 404, 'No authorization request could be found');
|
|
127
113
|
}
|
|
128
|
-
const requestState =
|
|
114
|
+
const requestState = await context.agent.siopGetAuthRequestState({
|
|
129
115
|
correlationId,
|
|
130
116
|
definitionId,
|
|
131
117
|
errorOnNotFound: false,
|
|
132
118
|
});
|
|
133
119
|
if (!requestState) {
|
|
134
120
|
console.log(`No authorization request could be found for the given url in the state manager. correlationId: ${correlationId}, definitionId: ${definitionId}`);
|
|
135
|
-
return
|
|
121
|
+
return sendErrorResponse(response, 404, `No authorization request could be found`);
|
|
136
122
|
}
|
|
137
|
-
const requestObject =
|
|
123
|
+
const requestObject = await requestState.request?.requestObject?.toJwt();
|
|
138
124
|
console.log('JWT Request object:');
|
|
139
125
|
console.log(requestObject);
|
|
140
126
|
let error;
|
|
@@ -145,10 +131,10 @@ function getAuthRequestSIOPv2Endpoint(router, context, opts) {
|
|
|
145
131
|
}
|
|
146
132
|
catch (e) {
|
|
147
133
|
error = typeof e === 'string' ? e : e instanceof Error ? e.message : undefined;
|
|
148
|
-
return
|
|
134
|
+
return sendErrorResponse(response, 500, 'Could not get authorization request', e);
|
|
149
135
|
}
|
|
150
136
|
finally {
|
|
151
|
-
|
|
137
|
+
await context.agent.siopUpdateAuthRequestState({
|
|
152
138
|
correlationId,
|
|
153
139
|
definitionId,
|
|
154
140
|
state: 'sent',
|
|
@@ -157,8 +143,8 @@ function getAuthRequestSIOPv2Endpoint(router, context, opts) {
|
|
|
157
143
|
}
|
|
158
144
|
}
|
|
159
145
|
catch (error) {
|
|
160
|
-
return
|
|
146
|
+
return sendErrorResponse(response, 500, 'Could not get authorization request', error);
|
|
161
147
|
}
|
|
162
|
-
})
|
|
148
|
+
});
|
|
163
149
|
}
|
|
164
150
|
//# sourceMappingURL=siop-api-functions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"siop-api-functions.js","sourceRoot":"","sources":["../src/siop-api-functions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"siop-api-functions.js","sourceRoot":"","sources":["../src/siop-api-functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,8BAA8B,EAAE,MAAM,yBAAyB,CAAA;AACtG,OAAO,EAAE,SAAS,EAAuB,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACjG,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAKtD,MAAM,0BAA0B,GAAG,CAAC,OAAgB,EAAgC,EAAE;IACpF,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;IAElD,IAAI,WAAW,KAAK,kBAAkB,EAAE,CAAC;QACvC,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAA;QAC1F,OAAO,OAAuC,CAAA;IAChD,CAAC;IAED,IAAI,WAAW,KAAK,mCAAmC,EAAE,CAAC;QACx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E,KAAK,CAAC,CAAA;QACvF,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -9,11 +9,14 @@ export declare class SIOPv2RPApiServer {
|
|
|
9
9
|
private readonly _router;
|
|
10
10
|
private readonly _agent;
|
|
11
11
|
private readonly _opts?;
|
|
12
|
+
private readonly _basePath;
|
|
13
|
+
private readonly OID4VP_SWAGGER_URL;
|
|
12
14
|
constructor(args: {
|
|
13
15
|
agent: TAgent<IRequiredPlugins>;
|
|
14
16
|
expressSupport: ExpressSupport;
|
|
15
17
|
opts?: ISIOPv2RPRestAPIOpts;
|
|
16
18
|
});
|
|
19
|
+
private setupSwaggerUi;
|
|
17
20
|
get express(): Express;
|
|
18
21
|
get router(): Router;
|
|
19
22
|
get agent(): TAgent<IPresentationExchange & ISIOPv2RP>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"siopv2-rp-api-server.d.ts","sourceRoot":"","sources":["../src/siopv2-rp-api-server.ts"],"names":[],"mappings":"AACA,OAAO,EAA6B,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAA;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAgB,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"siopv2-rp-api-server.d.ts","sourceRoot":"","sources":["../src/siopv2-rp-api-server.ts"],"names":[],"mappings":"AACA,OAAO,EAA6B,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAA;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAgB,EAAE,OAAO,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAA;AAErE,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAShE,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2C;IAClE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAsB;IAC7C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAQ;IAElC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA6D;gBACpF,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAAC,cAAc,EAAE,cAAc,CAAC;QAAC,IAAI,CAAC,EAAE,oBAAoB,CAAA;KAAE;IAmClH,OAAO,CAAC,cAAc;IA2BtB,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,KAAK,IAAI,MAAM,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAErD;IAED,IAAI,IAAI,IAAI,oBAAoB,GAAG,SAAS,CAE3C;CACF"}
|
|
@@ -1,41 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { agentContext } from '@sphereon/ssi-sdk.core';
|
|
2
|
+
import { copyGlobalAuthToEndpoints } from '@sphereon/ssi-express-support';
|
|
3
|
+
import express from 'express';
|
|
4
|
+
import { getAuthRequestSIOPv2Endpoint, verifyAuthResponseSIOPv2Endpoint } from './siop-api-functions';
|
|
5
|
+
import { authStatusWebappEndpoint, createAuthRequestWebappEndpoint, getDefinitionsEndpoint, removeAuthRequestStateWebappEndpoint, } from './webapp-api-functions';
|
|
6
|
+
import swaggerUi from 'swagger-ui-express';
|
|
7
|
+
export class SIOPv2RPApiServer {
|
|
8
|
+
_express;
|
|
9
|
+
_router;
|
|
10
|
+
_agent;
|
|
11
|
+
_opts;
|
|
12
|
+
_basePath;
|
|
13
|
+
OID4VP_SWAGGER_URL = 'https://api.swaggerhub.com/apis/SphereonInt/OID4VP/0.1.0';
|
|
13
14
|
constructor(args) {
|
|
14
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
15
15
|
const { agent, opts } = args;
|
|
16
16
|
this._agent = agent;
|
|
17
|
-
|
|
18
|
-
if (
|
|
19
|
-
|
|
17
|
+
copyGlobalAuthToEndpoints({ opts, keys: ['webappCreateAuthRequest', 'webappAuthStatus', 'webappDeleteAuthRequest'] });
|
|
18
|
+
if (opts?.endpointOpts?.globalAuth?.secureSiopEndpoints) {
|
|
19
|
+
copyGlobalAuthToEndpoints({ opts, keys: ['siopGetAuthRequest', 'siopVerifyAuthResponse'] });
|
|
20
20
|
}
|
|
21
21
|
this._opts = opts;
|
|
22
22
|
this._express = args.expressSupport.express;
|
|
23
|
-
this._router =
|
|
24
|
-
const context =
|
|
25
|
-
const features =
|
|
23
|
+
this._router = express.Router();
|
|
24
|
+
const context = agentContext(agent);
|
|
25
|
+
const features = opts?.enableFeatures ?? ['rp-status', 'siop'];
|
|
26
26
|
console.log(`SIOPv2 API enabled, with features: ${JSON.stringify(features)}}`);
|
|
27
27
|
// Webapp endpoints
|
|
28
28
|
if (features.includes('rp-status')) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
createAuthRequestWebappEndpoint(this._router, context, opts?.endpointOpts?.webappCreateAuthRequest);
|
|
30
|
+
authStatusWebappEndpoint(this._router, context, opts?.endpointOpts?.webappAuthStatus);
|
|
31
|
+
removeAuthRequestStateWebappEndpoint(this._router, context, opts?.endpointOpts?.webappDeleteAuthRequest);
|
|
32
|
+
getDefinitionsEndpoint(this._router, context, opts?.endpointOpts?.webappGetDefinitions);
|
|
32
33
|
}
|
|
33
34
|
// SIOPv2 endpoints
|
|
34
35
|
if (features.includes('siop')) {
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
getAuthRequestSIOPv2Endpoint(this._router, context, opts?.endpointOpts?.siopGetAuthRequest);
|
|
37
|
+
verifyAuthResponseSIOPv2Endpoint(this._router, context, opts?.endpointOpts?.siopVerifyAuthResponse);
|
|
37
38
|
}
|
|
38
|
-
this.
|
|
39
|
+
this._basePath = opts?.endpointOpts?.basePath ?? '';
|
|
40
|
+
this._express.use(this._basePath, this.router);
|
|
41
|
+
this._express.set('trust proxy', opts?.endpointOpts?.trustProxy ?? true);
|
|
42
|
+
this.setupSwaggerUi();
|
|
43
|
+
}
|
|
44
|
+
setupSwaggerUi() {
|
|
45
|
+
fetch(this.OID4VP_SWAGGER_URL)
|
|
46
|
+
.then((res) => res.json())
|
|
47
|
+
.then((swagger) => {
|
|
48
|
+
const apiDocs = `${this._basePath}/api-docs`;
|
|
49
|
+
console.log(`[OID4P] API docs available at ${apiDocs}`);
|
|
50
|
+
this._router.use('/api-docs', (req, res, next) => {
|
|
51
|
+
const regex = `${apiDocs.replace(/\//, '\/')}`.replace('/oid4vp', '').replace(/\/api-docs.*/, '');
|
|
52
|
+
swagger.servers = [{ url: `${req.protocol}://${req.get('host')}${regex}`, description: 'This server' }];
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
req.swaggerDoc = swagger;
|
|
55
|
+
next();
|
|
56
|
+
}, swaggerUi.serveFiles(swagger, options), swaggerUi.setup());
|
|
57
|
+
})
|
|
58
|
+
.catch((err) => {
|
|
59
|
+
console.log(`[OID4VP] Unable to fetch swagger document: ${err}. Will not host api-docs on this instance`);
|
|
60
|
+
});
|
|
61
|
+
const options = {
|
|
62
|
+
// customCss: '.swagger-ui .topbar { display: none }',
|
|
63
|
+
};
|
|
39
64
|
}
|
|
40
65
|
get express() {
|
|
41
66
|
return this._express;
|
|
@@ -50,5 +75,4 @@ class SIOPv2RPApiServer {
|
|
|
50
75
|
return this._opts;
|
|
51
76
|
}
|
|
52
77
|
}
|
|
53
|
-
exports.SIOPv2RPApiServer = SIOPv2RPApiServer;
|
|
54
78
|
//# sourceMappingURL=siopv2-rp-api-server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"siopv2-rp-api-server.js","sourceRoot":"","sources":["../src/siopv2-rp-api-server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"siopv2-rp-api-server.js","sourceRoot":"","sources":["../src/siopv2-rp-api-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,yBAAyB,EAAkB,MAAM,+BAA+B,CAAA;AAIzF,OAAO,OAA+C,MAAM,SAAS,CAAA;AACrE,OAAO,EAAE,4BAA4B,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAA;AAErG,OAAO,EACL,wBAAwB,EACxB,+BAA+B,EAC/B,sBAAsB,EACtB,oCAAoC,GACrC,MAAM,wBAAwB,CAAA;AAC/B,OAAO,SAAS,MAAM,oBAAoB,CAAA;AAE1C,MAAM,OAAO,iBAAiB;IACX,QAAQ,CAAS;IACjB,OAAO,CAAQ;IACf,MAAM,CAA2C;IACjD,KAAK,CAAuB;IAC5B,SAAS,CAAQ;IAEjB,kBAAkB,GAAG,0DAA0D,CAAA;IAChG,YAAY,IAAsG;QAChH,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;QAC5B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;QACnB,yBAAyB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,yBAAyB,EAAE,kBAAkB,EAAE,yBAAyB,CAAC,EAAE,CAAC,CAAA;QACrH,IAAI,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,CAAC;YACxD,yBAAyB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,oBAAoB,EAAE,wBAAwB,CAAC,EAAE,C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SAAS,CAAC,KAAK,EAAE,CAClB,CAAA;QACH,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACb,OAAO,CAAC,GAAG,CAAC,8CAA8C,GAAG,2CAA2C,CAAC,CAAA;QAC3G,CAAC,CAAC,CAAA;QACJ,MAAM,OAAO,GAAG;QACd,sDAAsD;SACvD,CAAA;IACH,CAAC;IACD,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
export interface ComponentOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Component options for data/ECC.
|
|
4
|
+
*/
|
|
5
|
+
data?: {
|
|
6
|
+
/**
|
|
7
|
+
* Scale factor for data/ECC dots.
|
|
8
|
+
* @default 1
|
|
9
|
+
*/
|
|
10
|
+
scale?: number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Component options for timing patterns.
|
|
14
|
+
*/
|
|
15
|
+
timing?: {
|
|
16
|
+
/**
|
|
17
|
+
* Scale factor for timing patterns.
|
|
18
|
+
* @default 1
|
|
19
|
+
*/
|
|
20
|
+
scale?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Protector for timing patterns.
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
protectors?: boolean;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Component options for alignment patterns.
|
|
29
|
+
*/
|
|
30
|
+
alignment?: {
|
|
31
|
+
/**
|
|
32
|
+
* Scale factor for alignment patterns.
|
|
33
|
+
* @default 1
|
|
34
|
+
*/
|
|
35
|
+
scale?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Protector for alignment patterns.
|
|
38
|
+
* @default false
|
|
39
|
+
*/
|
|
40
|
+
protectors?: boolean;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Component options for alignment pattern on the bottom-right corner.
|
|
44
|
+
*/
|
|
45
|
+
cornerAlignment?: {
|
|
46
|
+
/**
|
|
47
|
+
* Scale factor for alignment pattern on the bottom-right corner.
|
|
48
|
+
* @default 1
|
|
49
|
+
*/
|
|
50
|
+
scale?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Protector for alignment pattern on the bottom-right corner.
|
|
53
|
+
* @default true
|
|
54
|
+
*/
|
|
55
|
+
protectors?: boolean;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export interface QRCodeOpts {
|
|
59
|
+
/**
|
|
60
|
+
* Size of the QR code in pixel.
|
|
61
|
+
*
|
|
62
|
+
* @defaultValue 400
|
|
63
|
+
*/
|
|
64
|
+
size?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Size of margins around the QR code body in pixel.
|
|
67
|
+
*
|
|
68
|
+
* @defaultValue 20
|
|
69
|
+
*/
|
|
70
|
+
margin?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Error correction level of the QR code.
|
|
73
|
+
*
|
|
74
|
+
* Accepts a value provided by _QRErrorCorrectLevel_.
|
|
75
|
+
*
|
|
76
|
+
* For more information, please refer to [https://www.qrcode.com/en/about/error_correction.html](https://www.qrcode.com/en/about/error_correction.html).
|
|
77
|
+
*
|
|
78
|
+
* @defaultValue 0
|
|
79
|
+
*/
|
|
80
|
+
correctLevel?: number;
|
|
81
|
+
/**
|
|
82
|
+
* **This is an advanced option.**
|
|
83
|
+
*
|
|
84
|
+
* Specify the mask pattern to be used in QR code encoding.
|
|
85
|
+
*
|
|
86
|
+
* Accepts a value provided by _QRMaskPattern_.
|
|
87
|
+
*
|
|
88
|
+
* To find out all eight mask patterns, please refer to [https://en.wikipedia.org/wiki/File:QR_Code_Mask_Patterns.svg](https://en.wikipedia.org/wiki/File:QR_Code_Mask_Patterns.svg)
|
|
89
|
+
*
|
|
90
|
+
* For more information, please refer to [https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders#Masking](https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders#Masking).
|
|
91
|
+
*/
|
|
92
|
+
maskPattern?: number;
|
|
93
|
+
/**
|
|
94
|
+
* **This is an advanced option.**
|
|
95
|
+
*
|
|
96
|
+
* Specify the version to be used in QR code encoding.
|
|
97
|
+
*
|
|
98
|
+
* Accepts an integer in range [1, 40].
|
|
99
|
+
*
|
|
100
|
+
* For more information, please refer to [https://www.qrcode.com/en/about/version.html](https://www.qrcode.com/en/about/version.html).
|
|
101
|
+
*/
|
|
102
|
+
version?: number;
|
|
103
|
+
/**
|
|
104
|
+
* Options to control components in the QR code.
|
|
105
|
+
*
|
|
106
|
+
* @deafultValue undefined
|
|
107
|
+
*/
|
|
108
|
+
components?: ComponentOptions;
|
|
109
|
+
/**
|
|
110
|
+
* Color of the blocks on the QR code.
|
|
111
|
+
*
|
|
112
|
+
* Accepts a CSS <color>.
|
|
113
|
+
*
|
|
114
|
+
* For more information about CSS <color>, please refer to [https://developer.mozilla.org/en-US/docs/Web/CSS/color_value](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value).
|
|
115
|
+
*
|
|
116
|
+
* @defaultValue "#000000"
|
|
117
|
+
*/
|
|
118
|
+
colorDark?: string;
|
|
119
|
+
/**
|
|
120
|
+
* Color of the empty areas on the QR code.
|
|
121
|
+
*
|
|
122
|
+
* Accepts a CSS <color>.
|
|
123
|
+
*
|
|
124
|
+
* For more information about CSS <color>, please refer to [https://developer.mozilla.org/en-US/docs/Web/CSS/color_value](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value).
|
|
125
|
+
*
|
|
126
|
+
* @defaultValue "#ffffff"
|
|
127
|
+
*/
|
|
128
|
+
colorLight?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Automatically calculate the _colorLight_ value from the QR code's background.
|
|
131
|
+
*
|
|
132
|
+
* @defaultValue true
|
|
133
|
+
*/
|
|
134
|
+
autoColor?: boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Background image to be used in the QR code.
|
|
137
|
+
*
|
|
138
|
+
* Accepts a `data:` string in web browsers or a Buffer in Node.js.
|
|
139
|
+
*
|
|
140
|
+
* @defaultValue undefined
|
|
141
|
+
*/
|
|
142
|
+
backgroundImage?: string | Buffer;
|
|
143
|
+
/**
|
|
144
|
+
* Color of the dimming mask above the background image.
|
|
145
|
+
*
|
|
146
|
+
* Accepts a CSS <color>.
|
|
147
|
+
*
|
|
148
|
+
* For more information about CSS <color>, please refer to [https://developer.mozilla.org/en-US/docs/Web/CSS/color_value](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value).
|
|
149
|
+
*
|
|
150
|
+
* @defaultValue "rgba(0, 0, 0, 0)"
|
|
151
|
+
*/
|
|
152
|
+
backgroundDimming?: string;
|
|
153
|
+
/**
|
|
154
|
+
* GIF background image to be used in the QR code.
|
|
155
|
+
*
|
|
156
|
+
* @defaultValue undefined
|
|
157
|
+
*/
|
|
158
|
+
gifBackground?: ArrayBuffer;
|
|
159
|
+
/**
|
|
160
|
+
* Use a white margin instead of a transparent one which reveals the background of the QR code on margins.
|
|
161
|
+
*
|
|
162
|
+
* @defaultValue true
|
|
163
|
+
*/
|
|
164
|
+
whiteMargin?: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Logo image to be displayed at the center of the QR code.
|
|
167
|
+
*
|
|
168
|
+
* Accepts a `data:` string in web browsers or a Buffer in Node.js.
|
|
169
|
+
*
|
|
170
|
+
* When set to `undefined` or `null`, the logo is disabled.
|
|
171
|
+
*
|
|
172
|
+
* @defaultValue undefined
|
|
173
|
+
*/
|
|
174
|
+
logoImage?: string | Buffer;
|
|
175
|
+
/**
|
|
176
|
+
* Ratio of the logo size to the QR code size.
|
|
177
|
+
*
|
|
178
|
+
* @defaultValue 0.2
|
|
179
|
+
*/
|
|
180
|
+
logoScale?: number;
|
|
181
|
+
/**
|
|
182
|
+
* Size of margins around the logo image in pixels.
|
|
183
|
+
*
|
|
184
|
+
* @defaultValue 6
|
|
185
|
+
*/
|
|
186
|
+
logoMargin?: number;
|
|
187
|
+
/**
|
|
188
|
+
* Corner radius of the logo image in pixels.
|
|
189
|
+
*
|
|
190
|
+
* @defaultValue 8
|
|
191
|
+
*/
|
|
192
|
+
logoCornerRadius?: number;
|
|
193
|
+
/**
|
|
194
|
+
* @deprecated
|
|
195
|
+
*
|
|
196
|
+
* Ratio of the real size to the full size of the blocks.
|
|
197
|
+
*
|
|
198
|
+
* This can be helpful when you want to make more parts of the background visible.
|
|
199
|
+
*
|
|
200
|
+
* @deafultValue 0.4
|
|
201
|
+
*/
|
|
202
|
+
dotScale?: number;
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=QRCode.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QRCode.types.d.ts","sourceRoot":"","sources":["../../src/types/QRCode.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,IAAI,CAAC,EAAE;QACL;;;WAGG;QACH,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,CAAA;IAED;;OAEG;IACH,MAAM,CAAC,EAAE;QACP;;;WAGG;QACH,KAAK,CAAC,EAAE,MAAM,CAAA;QAEd;;;WAGG;QACH,UAAU,CAAC,EAAE,OAAO,CAAA;KACrB,CAAA;IAED;;OAEG;IACH,SAAS,CAAC,EAAE;QACV;;;WAGG;QACH,KAAK,CAAC,EAAE,MAAM,CAAA;QAEd;;;WAGG;QACH,UAAU,CAAC,EAAE,OAAO,CAAA;KACrB,CAAA;IAED;;OAEG;IACH,eAAe,CAAC,EAAE;QAChB;;;WAGG;QACH,KAAK,CAAC,EAAE,MAAM,CAAA;QAEd;;;WAGG;QACH,UAAU,CAAC,EAAE,OAAO,CAAA;KACrB,CAAA;CACF;AAED,MAAM,WAAW,UAAU;IACzB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;;;;;;;;OAUG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;;;OAIG;IACH,UAAU,CAAC,EAAE,gBAAgB,CAAA;IAE7B;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IAEnB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAEjC;;;;;;;;OAQG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAE1B;;;;OAIG;IACH,aAAa,CAAC,EAAE,WAAW,CAAA;IAE3B;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IAErB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAE3B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEzB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QRCode.types.js","sourceRoot":"","sources":["../../src/types/QRCode.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,gBAAgB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,gBAAgB,CAAA"}
|