@sphereon/ssi-sdk.siopv2-oid4vp-rp-rest-api 0.32.1-next.20 → 0.32.1-next.291
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/siop-api-functions.d.ts.map +1 -1
- package/dist/siop-api-functions.js +11 -3
- 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 +31 -4
- 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 +3 -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 +19 -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.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 +69 -18
- package/dist/webapp-api-functions.js.map +1 -1
- package/package.json +21 -16
- package/src/siop-api-functions.ts +14 -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.map +0 -1
- /package/dist/{types.js → types/types.js} +0 -0
|
@@ -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;
|
|
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"}
|
|
@@ -66,7 +66,7 @@ function verifyAuthResponseSIOPv2Endpoint(router, context, opts) {
|
|
|
66
66
|
}
|
|
67
67
|
const authorizationResponse = parseAuthorizationResponse(request);
|
|
68
68
|
console.log(`URI: ${JSON.stringify(authorizationResponse)}`);
|
|
69
|
-
const
|
|
69
|
+
const definitionItem = definitionItems[0];
|
|
70
70
|
const verifiedResponse = yield context.agent.siopVerifyAuthResponse({
|
|
71
71
|
authorizationResponse,
|
|
72
72
|
correlationId,
|
|
@@ -74,17 +74,25 @@ function verifyAuthResponseSIOPv2Endpoint(router, context, opts) {
|
|
|
74
74
|
presentationDefinitions: [
|
|
75
75
|
{
|
|
76
76
|
location: (_a = opts === null || opts === void 0 ? void 0 : opts.presentationDefinitionLocation) !== null && _a !== void 0 ? _a : did_auth_siop_1.PresentationDefinitionLocation.TOPLEVEL_PRESENTATION_DEF,
|
|
77
|
-
definition,
|
|
77
|
+
definition: definitionItem.definitionPayload,
|
|
78
78
|
},
|
|
79
79
|
],
|
|
80
|
+
dcqlQuery: definitionItem.dcqlPayload,
|
|
80
81
|
});
|
|
81
82
|
const wrappedPresentation = (_b = verifiedResponse === null || verifiedResponse === void 0 ? void 0 : verifiedResponse.oid4vpSubmission) === null || _b === void 0 ? void 0 : _b.presentations[0];
|
|
82
83
|
if (wrappedPresentation) {
|
|
83
84
|
// const credentialSubject = wrappedPresentation.presentation.verifiableCredential[0]?.credential?.credentialSubject
|
|
84
85
|
// console.log(JSON.stringify(credentialSubject, null, 2))
|
|
85
86
|
console.log('PRESENTATION:' + JSON.stringify(wrappedPresentation.presentation, null, 2));
|
|
86
|
-
const responseRedirectURI = yield context.agent.siopGetRedirectURI({ correlationId, definitionId, state: verifiedResponse.state });
|
|
87
87
|
response.statusCode = 200;
|
|
88
|
+
const authorizationChallengeValidationResponse = {
|
|
89
|
+
presentation_during_issuance_session: verifiedResponse.correlationId,
|
|
90
|
+
};
|
|
91
|
+
if (authorizationResponse.is_first_party) {
|
|
92
|
+
response.setHeader('Content-Type', 'application/json');
|
|
93
|
+
return response.send(JSON.stringify(authorizationChallengeValidationResponse));
|
|
94
|
+
}
|
|
95
|
+
const responseRedirectURI = yield context.agent.siopGetRedirectURI({ correlationId, definitionId, state: verifiedResponse.state });
|
|
88
96
|
if (responseRedirectURI) {
|
|
89
97
|
response.setHeader('Content-Type', 'application/json');
|
|
90
98
|
return response.send(JSON.stringify({ redirect_uri: responseRedirectURI }));
|
|
@@ -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":";;;;;;;;;;;AA2CA,4EA4EC;AAED,oEAiDC;AA1KD,2DAAsG;AACtG,uEAAiG;AACjG,mDAAsD;AAKtD,MAAM,0BAA0B,GAAG,CAAC,OAAgB,EAAgC,EAAE;IACpF,MAAM,WAAW,GAAG,OAAO,CA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EAAE,iBAAiB,CAAC,CAAA;gBACrD,OAAO,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;YACrC,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,KAAK,GAAG,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAA;gBAC9E,OAAO,IAAA,uCAAiB,EAAC,QAAQ,EAAE,GAAG,EAAE,qCAAqC,EAAE,CAAC,CAAC,CAAA;YACnF,CAAC;oBAAS,CAAC;gBACT,MAAM,OAAO,CAAC,KAAK,CAAC,0BAA0B,CAAC;oBAC7C,aAAa;oBACb,YAAY;oBACZ,KAAK,EAAE,MAAM;oBACb,KAAK;iBACN,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,IAAA,uCAAiB,EAAC,QAAQ,EAAE,GAAG,EAAE,qCAAqC,EAAE,KAAK,CAAC,CAAA;QACvF,CAAC;IACH,CAAC,CAAA,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"}
|
|
@@ -9,9 +9,11 @@ const ssi_express_support_1 = require("@sphereon/ssi-express-support");
|
|
|
9
9
|
const express_1 = __importDefault(require("express"));
|
|
10
10
|
const siop_api_functions_1 = require("./siop-api-functions");
|
|
11
11
|
const webapp_api_functions_1 = require("./webapp-api-functions");
|
|
12
|
+
const swagger_ui_express_1 = __importDefault(require("swagger-ui-express"));
|
|
12
13
|
class SIOPv2RPApiServer {
|
|
13
14
|
constructor(args) {
|
|
14
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
15
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
16
|
+
this.OID4VP_SWAGGER_URL = 'https://api.swaggerhub.com/apis/SphereonInt/OID4VP/0.1.0';
|
|
15
17
|
const { agent, opts } = args;
|
|
16
18
|
this._agent = agent;
|
|
17
19
|
(0, ssi_express_support_1.copyGlobalAuthToEndpoints)({ opts, keys: ['webappCreateAuthRequest', 'webappAuthStatus', 'webappDeleteAuthRequest'] });
|
|
@@ -29,13 +31,38 @@ class SIOPv2RPApiServer {
|
|
|
29
31
|
(0, webapp_api_functions_1.createAuthRequestWebappEndpoint)(this._router, context, (_d = opts === null || opts === void 0 ? void 0 : opts.endpointOpts) === null || _d === void 0 ? void 0 : _d.webappCreateAuthRequest);
|
|
30
32
|
(0, webapp_api_functions_1.authStatusWebappEndpoint)(this._router, context, (_e = opts === null || opts === void 0 ? void 0 : opts.endpointOpts) === null || _e === void 0 ? void 0 : _e.webappAuthStatus);
|
|
31
33
|
(0, webapp_api_functions_1.removeAuthRequestStateWebappEndpoint)(this._router, context, (_f = opts === null || opts === void 0 ? void 0 : opts.endpointOpts) === null || _f === void 0 ? void 0 : _f.webappDeleteAuthRequest);
|
|
34
|
+
(0, webapp_api_functions_1.getDefinitionsEndpoint)(this._router, context, (_g = opts === null || opts === void 0 ? void 0 : opts.endpointOpts) === null || _g === void 0 ? void 0 : _g.webappGetDefinitions);
|
|
32
35
|
}
|
|
33
36
|
// SIOPv2 endpoints
|
|
34
37
|
if (features.includes('siop')) {
|
|
35
|
-
(0, siop_api_functions_1.getAuthRequestSIOPv2Endpoint)(this._router, context, (
|
|
36
|
-
(0, siop_api_functions_1.verifyAuthResponseSIOPv2Endpoint)(this._router, context, (
|
|
38
|
+
(0, siop_api_functions_1.getAuthRequestSIOPv2Endpoint)(this._router, context, (_h = opts === null || opts === void 0 ? void 0 : opts.endpointOpts) === null || _h === void 0 ? void 0 : _h.siopGetAuthRequest);
|
|
39
|
+
(0, siop_api_functions_1.verifyAuthResponseSIOPv2Endpoint)(this._router, context, (_j = opts === null || opts === void 0 ? void 0 : opts.endpointOpts) === null || _j === void 0 ? void 0 : _j.siopVerifyAuthResponse);
|
|
37
40
|
}
|
|
38
|
-
this.
|
|
41
|
+
this._basePath = (_l = (_k = opts === null || opts === void 0 ? void 0 : opts.endpointOpts) === null || _k === void 0 ? void 0 : _k.basePath) !== null && _l !== void 0 ? _l : '';
|
|
42
|
+
this._express.use(this._basePath, this.router);
|
|
43
|
+
this._express.set('trust proxy', (_o = (_m = opts === null || opts === void 0 ? void 0 : opts.endpointOpts) === null || _m === void 0 ? void 0 : _m.trustProxy) !== null && _o !== void 0 ? _o : true);
|
|
44
|
+
this.setupSwaggerUi();
|
|
45
|
+
}
|
|
46
|
+
setupSwaggerUi() {
|
|
47
|
+
fetch(this.OID4VP_SWAGGER_URL)
|
|
48
|
+
.then((res) => res.json())
|
|
49
|
+
.then((swagger) => {
|
|
50
|
+
const apiDocs = `${this._basePath}/api-docs`;
|
|
51
|
+
console.log(`[OID4P] API docs available at ${apiDocs}`);
|
|
52
|
+
this._router.use('/api-docs', (req, res, next) => {
|
|
53
|
+
const regex = `${apiDocs.replace(/\//, '\/')}`.replace('/oid4vp', '').replace(/\/api-docs.*/, '');
|
|
54
|
+
swagger.servers = [{ url: `${req.protocol}://${req.get('host')}${regex}`, description: 'This server' }];
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
req.swaggerDoc = swagger;
|
|
57
|
+
next();
|
|
58
|
+
}, swagger_ui_express_1.default.serveFiles(swagger, options), swagger_ui_express_1.default.setup());
|
|
59
|
+
})
|
|
60
|
+
.catch((err) => {
|
|
61
|
+
console.log(`[OID4VP] Unable to fetch swagger document: ${err}. Will not host api-docs on this instance`);
|
|
62
|
+
});
|
|
63
|
+
const options = {
|
|
64
|
+
// customCss: '.swagger-ui .topbar { display: none }',
|
|
65
|
+
};
|
|
39
66
|
}
|
|
40
67
|
get express() {
|
|
41
68
|
return this._express;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"siopv2-rp-api-server.js","sourceRoot":"","sources":["../src/siopv2-rp-api-server.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAqD;AACrD,uEAAyF;AAIzF,
|
|
1
|
+
{"version":3,"file":"siopv2-rp-api-server.js","sourceRoot":"","sources":["../src/siopv2-rp-api-server.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAqD;AACrD,uEAAyF;AAIzF,sDAAqE;AACrE,6DAAqG;AAErG,iEAK+B;AAC/B,4EAA0C;AAE1C,MAAa,iBAAiB;IAQ5B,YAAY,IAAsG;;QADjG,uBAAkB,GAAG,0DAA0D,CAAA;QAE9F,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;QAC5B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;QACnB,IAAA,+CAAyB,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,yBAAyB,EAAE,kBAAkB,EAAE,yBAAyB,CAAC,EAAE,CAAC,CAAA;QACrH,IAAI,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY,0CAAE,UAAU,0CAAE,m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,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAA;gBACjG,OAAO,CAAC,OAAO,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,QAAQ,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,KAAK,EAAE,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC,CAAA;gBACvG,aAAa;gBACb,GAAG,CAAC,UAAU,GAAG,OAAO,CAAA;gBACxB,IAAI,EAAE,CAAA;YACR,CAAC,EACD,4BAAS,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,EACtC,4BAAS,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;AArFD,8CAqFC"}
|
|
@@ -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,IA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AC,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,19 @@
|
|
|
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
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./QRCode.types"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,iDAA8B"}
|
|
@@ -3,16 +3,19 @@ import { IPresentationExchange } from '@sphereon/ssi-sdk.presentation-exchange';
|
|
|
3
3
|
import { ISIOPv2RP } from '@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth';
|
|
4
4
|
import { IAgentContext, ICredentialVerifier } from '@veramo/core';
|
|
5
5
|
import { IPDManager } from '@sphereon/ssi-sdk.pd-manager';
|
|
6
|
+
import { QRCodeOpts } from './QRCode.types';
|
|
6
7
|
export type SiopFeatures = 'rp-status' | 'siop';
|
|
7
8
|
export interface ISIOPv2RPRestAPIOpts {
|
|
8
9
|
enableFeatures?: SiopFeatures[];
|
|
9
10
|
endpointOpts?: {
|
|
10
11
|
basePath?: string;
|
|
12
|
+
trustProxy?: boolean | Array<string>;
|
|
11
13
|
globalAuth?: GenericAuthArgs & {
|
|
12
14
|
secureSiopEndpoints?: boolean;
|
|
13
15
|
};
|
|
14
16
|
webappCreateAuthRequest?: ICreateAuthRequestWebappEndpointOpts;
|
|
15
17
|
webappDeleteAuthRequest?: ISingleEndpointOpts;
|
|
18
|
+
webappGetDefinitions?: ISingleEndpointOpts;
|
|
16
19
|
webappAuthStatus?: ISingleEndpointOpts;
|
|
17
20
|
siopVerifyAuthResponse?: ISingleEndpointOpts;
|
|
18
21
|
siopGetAuthRequest?: ISingleEndpointOpts;
|
|
@@ -20,9 +23,10 @@ export interface ISIOPv2RPRestAPIOpts {
|
|
|
20
23
|
}
|
|
21
24
|
export interface ICreateAuthRequestWebappEndpointOpts extends ISingleEndpointOpts {
|
|
22
25
|
siopBaseURI?: string;
|
|
26
|
+
qrCodeOpts?: QRCodeOpts;
|
|
23
27
|
webappAuthStatusPath?: string;
|
|
24
28
|
webappBaseURI?: string;
|
|
25
|
-
|
|
29
|
+
responseRedirectURI?: string;
|
|
26
30
|
}
|
|
27
31
|
export type IRequiredPlugins = ICredentialVerifier & ISIOPv2RP & IPresentationExchange & IPDManager;
|
|
28
32
|
export type IRequiredContext = IAgentContext<IRequiredPlugins>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAA;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,MAAM,CAAA;AAC/C,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,EAAE,YAAY,EAAE,CAAA;IAC/B,YAAY,CAAC,EAAE;QACb,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,UAAU,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAA;QACpC,UAAU,CAAC,EAAE,eAAe,GAAG;YAAE,mBAAmB,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;QAChE,uBAAuB,CAAC,EAAE,oCAAoC,CAAA;QAC9D,uBAAuB,CAAC,EAAE,mBAAmB,CAAA;QAC7C,oBAAoB,CAAC,EAAE,mBAAmB,CAAA;QAC1C,gBAAgB,CAAC,EAAE,mBAAmB,CAAA;QACtC,sBAAsB,CAAC,EAAE,mBAAmB,CAAA;QAC5C,kBAAkB,CAAC,EAAE,mBAAmB,CAAA;KACzC,CAAA;CACF;AACD,MAAM,WAAW,oCAAqC,SAAQ,mBAAmB;IAC/E,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAC7B;AAED,MAAM,MAAM,gBAAgB,GAAG,mBAAmB,GAAG,SAAS,GAAG,qBAAqB,GAAG,UAAU,CAAA;AACnG,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC,gBAAgB,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":""}
|
|
@@ -4,4 +4,5 @@ import { ICreateAuthRequestWebappEndpointOpts, IRequiredContext } from './types'
|
|
|
4
4
|
export declare function createAuthRequestWebappEndpoint(router: Router, context: IRequiredContext, opts?: ICreateAuthRequestWebappEndpointOpts): void;
|
|
5
5
|
export declare function authStatusWebappEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
6
6
|
export declare function removeAuthRequestStateWebappEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
7
|
+
export declare function getDefinitionsEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
7
8
|
//# sourceMappingURL=webapp-api-functions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webapp-api-functions.d.ts","sourceRoot":"","sources":["../src/webapp-api-functions.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,mBAAmB,EAAqB,MAAM,+BAA+B,CAAA;AAGjG,OAAO,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAA;AAEnD,OAAO,EAAE,oCAAoC,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAGhF,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,oCAAoC,
|
|
1
|
+
{"version":3,"file":"webapp-api-functions.d.ts","sourceRoot":"","sources":["../src/webapp-api-functions.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,mBAAmB,EAAqB,MAAM,+BAA+B,CAAA;AAGjG,OAAO,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAA;AAEnD,OAAO,EAAE,oCAAoC,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAGhF,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,oCAAoC,QAyDrI;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,mBAAmB,QA2E7G;AAED,wBAAgB,oCAAoC,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,mBAAmB,QAoBzH;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,mBAAmB,QAe3G"}
|
|
@@ -1,4 +1,27 @@
|
|
|
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -15,6 +38,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
38
|
exports.createAuthRequestWebappEndpoint = createAuthRequestWebappEndpoint;
|
|
16
39
|
exports.authStatusWebappEndpoint = authStatusWebappEndpoint;
|
|
17
40
|
exports.removeAuthRequestStateWebappEndpoint = removeAuthRequestStateWebappEndpoint;
|
|
41
|
+
exports.getDefinitionsEndpoint = getDefinitionsEndpoint;
|
|
18
42
|
const did_auth_siop_1 = require("@sphereon/did-auth-siop");
|
|
19
43
|
const ssi_express_support_1 = require("@sphereon/ssi-express-support");
|
|
20
44
|
const ssi_sdk_siopv2_oid4vp_common_1 = require("@sphereon/ssi-sdk.siopv2-oid4vp-common");
|
|
@@ -29,28 +53,37 @@ function createAuthRequestWebappEndpoint(router, context, opts) {
|
|
|
29
53
|
}
|
|
30
54
|
const path = (_a = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _a !== void 0 ? _a : '/webapp/definitions/:definitionId/auth-requests';
|
|
31
55
|
router.post(path, (0, ssi_express_support_1.checkAuth)(opts === null || opts === void 0 ? void 0 : opts.endpoint), (request, response) => __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
var _a;
|
|
56
|
+
var _a, _b, _c, _d, _e;
|
|
33
57
|
try {
|
|
34
58
|
// if (!request.agent) throw Error('No agent configured')
|
|
35
59
|
const definitionId = request.params.definitionId;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
60
|
+
if (!definitionId) {
|
|
61
|
+
return (0, ssi_express_support_1.sendErrorResponse)(response, 400, 'No definitionId query parameter provided');
|
|
62
|
+
}
|
|
63
|
+
const state = (_a = request.body.state) !== null && _a !== void 0 ? _a : short_uuid_1.default.uuid();
|
|
64
|
+
const correlationId = (_b = request.body.correlationId) !== null && _b !== void 0 ? _b : state;
|
|
65
|
+
const qrCodeOpts = (_c = request.body.qrCodeOpts) !== null && _c !== void 0 ? _c : opts === null || opts === void 0 ? void 0 : opts.qrCodeOpts;
|
|
66
|
+
const requestByReferenceURI = (0, ssi_sdk_siopv2_oid4vp_common_1.uriWithBase)(`/siop/definitions/${definitionId}/auth-requests/${state}`, {
|
|
39
67
|
baseURI: opts === null || opts === void 0 ? void 0 : opts.siopBaseURI,
|
|
40
68
|
});
|
|
41
|
-
const responseURI = (0, ssi_sdk_siopv2_oid4vp_common_1.uriWithBase)(`/siop/definitions/${definitionId}/auth-responses/${
|
|
42
|
-
|
|
69
|
+
const responseURI = (0, ssi_sdk_siopv2_oid4vp_common_1.uriWithBase)(`/siop/definitions/${definitionId}/auth-responses/${state}`, { baseURI: opts === null || opts === void 0 ? void 0 : opts.siopBaseURI });
|
|
70
|
+
// first version is for backwards compat
|
|
71
|
+
const responseRedirectURI = (_d = ('response_redirect_uri' in request.body && request.body.response_redirect_uri)) !== null && _d !== void 0 ? _d : ('responseRedirectURI' in request.body && request.body.responseRedirectURI);
|
|
43
72
|
const authRequestURI = yield context.agent.siopCreateAuthRequestURI(Object.assign({ definitionId,
|
|
44
73
|
correlationId,
|
|
45
|
-
state, nonce:
|
|
46
|
-
|
|
47
|
-
|
|
74
|
+
state, nonce: short_uuid_1.default.uuid(), requestByReferenceURI, responseURIType: 'response_uri', responseURI }, (responseRedirectURI && { responseRedirectURI })));
|
|
75
|
+
let qrCodeDataUri;
|
|
76
|
+
if (qrCodeOpts) {
|
|
77
|
+
const { AwesomeQR } = yield Promise.resolve().then(() => __importStar(require('awesome-qr')));
|
|
78
|
+
const qrCode = new AwesomeQR(Object.assign(Object.assign({}, qrCodeOpts), { text: authRequestURI }));
|
|
79
|
+
qrCodeDataUri = `data:image/png;base64,${(yield qrCode.draw()).toString('base64')}`;
|
|
80
|
+
}
|
|
81
|
+
const authRequestBody = Object.assign({ correlationId,
|
|
82
|
+
state,
|
|
48
83
|
definitionId,
|
|
49
|
-
authRequestURI,
|
|
50
|
-
authStatusURI: `${(0, ssi_sdk_siopv2_oid4vp_common_1.uriWithBase)((_a = opts === null || opts === void 0 ? void 0 : opts.webappAuthStatusPath) !== null && _a !== void 0 ? _a : '/webapp/auth-status', { baseURI: opts === null || opts === void 0 ? void 0 : opts.webappBaseURI })}`,
|
|
51
|
-
};
|
|
84
|
+
authRequestURI, authStatusURI: `${(0, ssi_sdk_siopv2_oid4vp_common_1.uriWithBase)((_e = opts === null || opts === void 0 ? void 0 : opts.webappAuthStatusPath) !== null && _e !== void 0 ? _e : '/webapp/auth-status', { baseURI: opts === null || opts === void 0 ? void 0 : opts.webappBaseURI })}` }, (qrCodeDataUri && { qrCodeDataUri }));
|
|
52
85
|
console.log(`Auth Request URI data to send back: ${JSON.stringify(authRequestBody)}`);
|
|
53
|
-
return response.
|
|
86
|
+
return response.json(authRequestBody);
|
|
54
87
|
}
|
|
55
88
|
catch (error) {
|
|
56
89
|
return (0, ssi_express_support_1.sendErrorResponse)(response, 500, 'Could not create an authorization request URI', error);
|
|
@@ -87,7 +120,7 @@ function authStatusWebappEndpoint(router, context, opts) {
|
|
|
87
120
|
definitionId,
|
|
88
121
|
lastUpdated: requestState ? requestState.lastUpdated : Date.now(),
|
|
89
122
|
};
|
|
90
|
-
return response.
|
|
123
|
+
return response.json(statusBody);
|
|
91
124
|
}
|
|
92
125
|
let includeVerifiedData = ssi_sdk_siopv2_oid4vp_rp_auth_1.VerifiedDataMode.NONE;
|
|
93
126
|
if ('includeVerifiedData' in request.body) {
|
|
@@ -110,13 +143,13 @@ function authStatusWebappEndpoint(router, context, opts) {
|
|
|
110
143
|
verifiedData: responseState.verifiedData,
|
|
111
144
|
}
|
|
112
145
|
: {}));
|
|
113
|
-
console.
|
|
146
|
+
console.debug(`Will send auth status: ${JSON.stringify(statusBody)}`);
|
|
114
147
|
if (overallState.status === 'error') {
|
|
115
148
|
response.statusCode = 500;
|
|
116
|
-
return response.
|
|
149
|
+
return response.json(statusBody);
|
|
117
150
|
}
|
|
118
151
|
response.statusCode = 200;
|
|
119
|
-
return response.
|
|
152
|
+
return response.json(statusBody);
|
|
120
153
|
}
|
|
121
154
|
catch (error) {
|
|
122
155
|
return (0, ssi_express_support_1.sendErrorResponse)(response, 500, error.message, error);
|
|
@@ -139,7 +172,25 @@ function removeAuthRequestStateWebappEndpoint(router, context, opts) {
|
|
|
139
172
|
return (0, ssi_express_support_1.sendErrorResponse)(response, 404, 'No authorization request could be found');
|
|
140
173
|
}
|
|
141
174
|
response.statusCode = 200;
|
|
142
|
-
return response.
|
|
175
|
+
return response.json(yield context.agent.siopDeleteAuthState({ definitionId, correlationId }));
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
return (0, ssi_express_support_1.sendErrorResponse)(response, 500, error.message, error);
|
|
179
|
+
}
|
|
180
|
+
}));
|
|
181
|
+
}
|
|
182
|
+
function getDefinitionsEndpoint(router, context, opts) {
|
|
183
|
+
var _a;
|
|
184
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
185
|
+
console.log(`getDefinitions Webapp endpoint is disabled`);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const path = (_a = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _a !== void 0 ? _a : '/webapp/definitions';
|
|
189
|
+
router.get(path, (0, ssi_express_support_1.checkAuth)(opts === null || opts === void 0 ? void 0 : opts.endpoint), (request, response) => __awaiter(this, void 0, void 0, function* () {
|
|
190
|
+
try {
|
|
191
|
+
const definitions = yield context.agent.pdmGetDefinitions();
|
|
192
|
+
response.statusCode = 200;
|
|
193
|
+
return response.json(definitions);
|
|
143
194
|
}
|
|
144
195
|
catch (error) {
|
|
145
196
|
return (0, ssi_express_support_1.sendErrorResponse)(response, 500, error.message, error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webapp-api-functions.js","sourceRoot":"","sources":["../src/webapp-api-functions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webapp-api-functions.js","sourceRoot":"","sources":["../src/webapp-api-functions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,0EAyDC;AAED,4DA2EC;AAED,oFAoBC;AAED,wDAeC;AAtLD,2DAAqG;AACrG,uEAAiG;AACjG,yFAAwH;AACxH,2FAAsH;AAEtH,4DAA6B;AAE7B,yDAAmE;AAEnE,SAAgB,+BAA+B,CAAC,MAAc,EAAE,OAAyB,EAAE,IAA2C;;IACpI,IAAI,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,MAAK,KAAK,EAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAA;QAC5D,OAAM;IACR,CAAC;IACD,MAAM,IAAI,GAAG,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,mCAAI,iDAAiD,CAAA;IAC5E,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAA,+BAAS,EAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,CAAC,EAAE,CAAO,OAAgB,EAAE,QAAkB,EAAE,EAAE;;QAC1F,IAAI,CAAC;YACH,yDAAyD;YACzD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package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.siopv2-oid4vp-rp-rest-api",
|
|
3
|
-
"version": "0.32.1-next.
|
|
3
|
+
"version": "0.32.1-next.291+bef8bb12",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,18 +11,19 @@
|
|
|
11
11
|
"start:dev": "ts-node __tests__/RestAPI.ts"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@sphereon/did-auth-siop": "0.
|
|
15
|
-
"@sphereon/ssi-express-support": "0.32.1-next.
|
|
16
|
-
"@sphereon/ssi-sdk.core": "0.32.1-next.
|
|
17
|
-
"@sphereon/ssi-sdk.credential-validation": "0.32.1-next.
|
|
18
|
-
"@sphereon/ssi-sdk.kv-store-temp": "0.32.1-next.
|
|
19
|
-
"@sphereon/ssi-sdk.pd-manager": "0.32.1-next.
|
|
20
|
-
"@sphereon/ssi-sdk.presentation-exchange": "0.32.1-next.
|
|
21
|
-
"@sphereon/ssi-sdk.siopv2-oid4vp-common": "0.32.1-next.
|
|
22
|
-
"@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth": "0.32.1-next.
|
|
23
|
-
"@sphereon/ssi-types": "0.32.1-next.
|
|
14
|
+
"@sphereon/did-auth-siop": "0.17.0",
|
|
15
|
+
"@sphereon/ssi-express-support": "0.32.1-next.291+bef8bb12",
|
|
16
|
+
"@sphereon/ssi-sdk.core": "0.32.1-next.291+bef8bb12",
|
|
17
|
+
"@sphereon/ssi-sdk.credential-validation": "0.32.1-next.291+bef8bb12",
|
|
18
|
+
"@sphereon/ssi-sdk.kv-store-temp": "0.32.1-next.291+bef8bb12",
|
|
19
|
+
"@sphereon/ssi-sdk.pd-manager": "0.32.1-next.291+bef8bb12",
|
|
20
|
+
"@sphereon/ssi-sdk.presentation-exchange": "0.32.1-next.291+bef8bb12",
|
|
21
|
+
"@sphereon/ssi-sdk.siopv2-oid4vp-common": "0.32.1-next.291+bef8bb12",
|
|
22
|
+
"@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth": "0.32.1-next.291+bef8bb12",
|
|
23
|
+
"@sphereon/ssi-types": "0.32.1-next.291+bef8bb12",
|
|
24
24
|
"@veramo/core": "4.2.0",
|
|
25
25
|
"@veramo/credential-w3c": "4.2.0",
|
|
26
|
+
"awesome-qr": "^2.1.5-rc.0",
|
|
26
27
|
"body-parser": "^1.20.2",
|
|
27
28
|
"cookie-parser": "^1.4.6",
|
|
28
29
|
"cors": "^2.8.5",
|
|
@@ -30,16 +31,18 @@
|
|
|
30
31
|
"dotenv-flow": "^3.3.0",
|
|
31
32
|
"express": "^4.19.2",
|
|
32
33
|
"short-uuid": "^4.2.2",
|
|
34
|
+
"swagger-ui-express": "^5.0.1",
|
|
33
35
|
"uuid": "^9.0.1"
|
|
34
36
|
},
|
|
35
37
|
"devDependencies": {
|
|
36
38
|
"@decentralized-identity/ion-sdk": "^0.6.0",
|
|
39
|
+
"@sphereon/did-auth-siop-adapter": "0.17.0",
|
|
37
40
|
"@sphereon/did-uni-client": "^0.6.3",
|
|
38
41
|
"@sphereon/pex": "5.0.0-unstable.28",
|
|
39
42
|
"@sphereon/pex-models": "^2.3.2",
|
|
40
|
-
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.
|
|
41
|
-
"@sphereon/ssi-sdk.data-store": "0.32.1-next.
|
|
42
|
-
"@sphereon/ssi-sdk.vc-handler-ld-local": "0.32.1-next.
|
|
43
|
+
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.28.0",
|
|
44
|
+
"@sphereon/ssi-sdk.data-store": "0.32.1-next.291+bef8bb12",
|
|
45
|
+
"@sphereon/ssi-sdk.vc-handler-ld-local": "0.32.1-next.291+bef8bb12",
|
|
43
46
|
"@types/body-parser": "^1.19.5",
|
|
44
47
|
"@types/cookie-parser": "^1.4.7",
|
|
45
48
|
"@types/cors": "^2.8.17",
|
|
@@ -51,6 +54,7 @@
|
|
|
51
54
|
"@types/node": "^20.17.1",
|
|
52
55
|
"@types/passport": "^1.0.16",
|
|
53
56
|
"@types/passport-http-bearer": "^1.0.41",
|
|
57
|
+
"@types/swagger-ui-express": "^4.1.7",
|
|
54
58
|
"@types/uuid": "^9.0.8",
|
|
55
59
|
"@veramo/data-store": "4.2.0",
|
|
56
60
|
"@veramo/did-manager": "4.2.0",
|
|
@@ -62,13 +66,14 @@
|
|
|
62
66
|
"@veramo/key-manager": "4.2.0",
|
|
63
67
|
"@veramo/kms-local": "4.2.0",
|
|
64
68
|
"@veramo/utils": "4.2.0",
|
|
69
|
+
"debug": "^4.4.0",
|
|
65
70
|
"did-resolver": "^4.1.0",
|
|
66
71
|
"morgan": "^1.10.0",
|
|
67
72
|
"nock": "^13.5.4",
|
|
68
73
|
"passport": "^0.6.0",
|
|
69
74
|
"passport-http-bearer": "^1.0.1",
|
|
70
75
|
"ts-node": "^10.9.2",
|
|
71
|
-
"typeorm": "^0.3.
|
|
76
|
+
"typeorm": "^0.3.21"
|
|
72
77
|
},
|
|
73
78
|
"files": [
|
|
74
79
|
".yalc/**/*",
|
|
@@ -98,5 +103,5 @@
|
|
|
98
103
|
"Authenticator"
|
|
99
104
|
],
|
|
100
105
|
"nx": {},
|
|
101
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "bef8bb123f197ecb66da7edff9d2cb55492af7ef"
|
|
102
107
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AuthorizationResponsePayload, PresentationDefinitionLocation } from '@sphereon/did-auth-siop'
|
|
2
2
|
import { checkAuth, ISingleEndpointOpts, sendErrorResponse } from '@sphereon/ssi-express-support'
|
|
3
3
|
import { CredentialMapper } from '@sphereon/ssi-types'
|
|
4
|
+
import { AuthorizationChallengeValidationResponse } from '@sphereon/ssi-sdk.siopv2-oid4vp-common'
|
|
4
5
|
import { Request, Response, Router } from 'express'
|
|
5
6
|
import { IRequiredContext } from './types'
|
|
6
7
|
|
|
@@ -70,7 +71,7 @@ export function verifyAuthResponseSIOPv2Endpoint(
|
|
|
70
71
|
const authorizationResponse = parseAuthorizationResponse(request)
|
|
71
72
|
console.log(`URI: ${JSON.stringify(authorizationResponse)}`)
|
|
72
73
|
|
|
73
|
-
const
|
|
74
|
+
const definitionItem = definitionItems[0]
|
|
74
75
|
const verifiedResponse = await context.agent.siopVerifyAuthResponse({
|
|
75
76
|
authorizationResponse,
|
|
76
77
|
correlationId,
|
|
@@ -78,9 +79,10 @@ export function verifyAuthResponseSIOPv2Endpoint(
|
|
|
78
79
|
presentationDefinitions: [
|
|
79
80
|
{
|
|
80
81
|
location: opts?.presentationDefinitionLocation ?? PresentationDefinitionLocation.TOPLEVEL_PRESENTATION_DEF,
|
|
81
|
-
definition,
|
|
82
|
+
definition: definitionItem.definitionPayload,
|
|
82
83
|
},
|
|
83
84
|
],
|
|
85
|
+
dcqlQuery: definitionItem.dcqlPayload,
|
|
84
86
|
})
|
|
85
87
|
|
|
86
88
|
const wrappedPresentation = verifiedResponse?.oid4vpSubmission?.presentations[0]
|
|
@@ -88,8 +90,17 @@ export function verifyAuthResponseSIOPv2Endpoint(
|
|
|
88
90
|
// const credentialSubject = wrappedPresentation.presentation.verifiableCredential[0]?.credential?.credentialSubject
|
|
89
91
|
// console.log(JSON.stringify(credentialSubject, null, 2))
|
|
90
92
|
console.log('PRESENTATION:' + JSON.stringify(wrappedPresentation.presentation, null, 2))
|
|
91
|
-
const responseRedirectURI = await context.agent.siopGetRedirectURI({ correlationId, definitionId, state: verifiedResponse.state })
|
|
92
93
|
response.statusCode = 200
|
|
94
|
+
|
|
95
|
+
const authorizationChallengeValidationResponse: AuthorizationChallengeValidationResponse = {
|
|
96
|
+
presentation_during_issuance_session: verifiedResponse.correlationId,
|
|
97
|
+
}
|
|
98
|
+
if (authorizationResponse.is_first_party) {
|
|
99
|
+
response.setHeader('Content-Type', 'application/json')
|
|
100
|
+
return response.send(JSON.stringify(authorizationChallengeValidationResponse))
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const responseRedirectURI = await context.agent.siopGetRedirectURI({ correlationId, definitionId, state: verifiedResponse.state })
|
|
93
104
|
if (responseRedirectURI) {
|
|
94
105
|
response.setHeader('Content-Type', 'application/json')
|
|
95
106
|
return response.send(JSON.stringify({ redirect_uri: responseRedirectURI }))
|
|
@@ -3,17 +3,25 @@ import { copyGlobalAuthToEndpoints, ExpressSupport } from '@sphereon/ssi-express
|
|
|
3
3
|
import { IPresentationExchange } from '@sphereon/ssi-sdk.presentation-exchange'
|
|
4
4
|
import { ISIOPv2RP } from '@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth'
|
|
5
5
|
import { TAgent } from '@veramo/core'
|
|
6
|
-
import express, { Express, Router } from 'express'
|
|
6
|
+
import express, { Express, Request, Response, Router } from 'express'
|
|
7
7
|
import { getAuthRequestSIOPv2Endpoint, verifyAuthResponseSIOPv2Endpoint } from './siop-api-functions'
|
|
8
8
|
import { IRequiredPlugins, ISIOPv2RPRestAPIOpts } from './types'
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
authStatusWebappEndpoint,
|
|
11
|
+
createAuthRequestWebappEndpoint,
|
|
12
|
+
getDefinitionsEndpoint,
|
|
13
|
+
removeAuthRequestStateWebappEndpoint,
|
|
14
|
+
} from './webapp-api-functions'
|
|
15
|
+
import swaggerUi from 'swagger-ui-express'
|
|
10
16
|
|
|
11
17
|
export class SIOPv2RPApiServer {
|
|
12
18
|
private readonly _express: Express
|
|
13
19
|
private readonly _router: Router
|
|
14
20
|
private readonly _agent: TAgent<IPresentationExchange & ISIOPv2RP>
|
|
15
21
|
private readonly _opts?: ISIOPv2RPRestAPIOpts
|
|
22
|
+
private readonly _basePath: string
|
|
16
23
|
|
|
24
|
+
private readonly OID4VP_SWAGGER_URL = 'https://api.swaggerhub.com/apis/SphereonInt/OID4VP/0.1.0'
|
|
17
25
|
constructor(args: { agent: TAgent<IRequiredPlugins>; expressSupport: ExpressSupport; opts?: ISIOPv2RPRestAPIOpts }) {
|
|
18
26
|
const { agent, opts } = args
|
|
19
27
|
this._agent = agent
|
|
@@ -35,6 +43,7 @@ export class SIOPv2RPApiServer {
|
|
|
35
43
|
createAuthRequestWebappEndpoint(this._router, context, opts?.endpointOpts?.webappCreateAuthRequest)
|
|
36
44
|
authStatusWebappEndpoint(this._router, context, opts?.endpointOpts?.webappAuthStatus)
|
|
37
45
|
removeAuthRequestStateWebappEndpoint(this._router, context, opts?.endpointOpts?.webappDeleteAuthRequest)
|
|
46
|
+
getDefinitionsEndpoint(this._router, context, opts?.endpointOpts?.webappGetDefinitions)
|
|
38
47
|
}
|
|
39
48
|
|
|
40
49
|
// SIOPv2 endpoints
|
|
@@ -42,9 +51,39 @@ export class SIOPv2RPApiServer {
|
|
|
42
51
|
getAuthRequestSIOPv2Endpoint(this._router, context, opts?.endpointOpts?.siopGetAuthRequest)
|
|
43
52
|
verifyAuthResponseSIOPv2Endpoint(this._router, context, opts?.endpointOpts?.siopVerifyAuthResponse)
|
|
44
53
|
}
|
|
45
|
-
this.
|
|
54
|
+
this._basePath = opts?.endpointOpts?.basePath ?? ''
|
|
55
|
+
this._express.use(this._basePath, this.router)
|
|
56
|
+
this._express.set('trust proxy', opts?.endpointOpts?.trustProxy ?? true)
|
|
57
|
+
this.setupSwaggerUi()
|
|
46
58
|
}
|
|
47
59
|
|
|
60
|
+
private setupSwaggerUi() {
|
|
61
|
+
fetch(this.OID4VP_SWAGGER_URL)
|
|
62
|
+
.then((res) => res.json())
|
|
63
|
+
.then((swagger) => {
|
|
64
|
+
const apiDocs = `${this._basePath}/api-docs`
|
|
65
|
+
console.log(`[OID4P] API docs available at ${apiDocs}`)
|
|
66
|
+
|
|
67
|
+
this._router.use(
|
|
68
|
+
'/api-docs',
|
|
69
|
+
(req: Request, res: Response, next: any) => {
|
|
70
|
+
const regex = `${apiDocs.replace(/\//, '\/')}`.replace('/oid4vp', '').replace(/\/api-docs.*/, '')
|
|
71
|
+
swagger.servers = [{ url: `${req.protocol}://${req.get('host')}${regex}`, description: 'This server' }]
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
req.swaggerDoc = swagger
|
|
74
|
+
next()
|
|
75
|
+
},
|
|
76
|
+
swaggerUi.serveFiles(swagger, options),
|
|
77
|
+
swaggerUi.setup(),
|
|
78
|
+
)
|
|
79
|
+
})
|
|
80
|
+
.catch((err) => {
|
|
81
|
+
console.log(`[OID4VP] Unable to fetch swagger document: ${err}. Will not host api-docs on this instance`)
|
|
82
|
+
})
|
|
83
|
+
const options = {
|
|
84
|
+
// customCss: '.swagger-ui .topbar { display: none }',
|
|
85
|
+
}
|
|
86
|
+
}
|
|
48
87
|
get express(): Express {
|
|
49
88
|
return this._express
|
|
50
89
|
}
|
|
@@ -0,0 +1,227 @@
|
|
|
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
|
+
/**
|
|
14
|
+
* Component options for timing patterns.
|
|
15
|
+
*/
|
|
16
|
+
timing?: {
|
|
17
|
+
/**
|
|
18
|
+
* Scale factor for timing patterns.
|
|
19
|
+
* @default 1
|
|
20
|
+
*/
|
|
21
|
+
scale?: number
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Protector for timing patterns.
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
protectors?: boolean
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Component options for alignment patterns.
|
|
32
|
+
*/
|
|
33
|
+
alignment?: {
|
|
34
|
+
/**
|
|
35
|
+
* Scale factor for alignment patterns.
|
|
36
|
+
* @default 1
|
|
37
|
+
*/
|
|
38
|
+
scale?: number
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Protector for alignment patterns.
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
protectors?: boolean
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Component options for alignment pattern on the bottom-right corner.
|
|
49
|
+
*/
|
|
50
|
+
cornerAlignment?: {
|
|
51
|
+
/**
|
|
52
|
+
* Scale factor for alignment pattern on the bottom-right corner.
|
|
53
|
+
* @default 1
|
|
54
|
+
*/
|
|
55
|
+
scale?: number
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Protector for alignment pattern on the bottom-right corner.
|
|
59
|
+
* @default true
|
|
60
|
+
*/
|
|
61
|
+
protectors?: boolean
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface QRCodeOpts {
|
|
66
|
+
/**
|
|
67
|
+
* Size of the QR code in pixel.
|
|
68
|
+
*
|
|
69
|
+
* @defaultValue 400
|
|
70
|
+
*/
|
|
71
|
+
size?: number
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Size of margins around the QR code body in pixel.
|
|
75
|
+
*
|
|
76
|
+
* @defaultValue 20
|
|
77
|
+
*/
|
|
78
|
+
margin?: number
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Error correction level of the QR code.
|
|
82
|
+
*
|
|
83
|
+
* Accepts a value provided by _QRErrorCorrectLevel_.
|
|
84
|
+
*
|
|
85
|
+
* For more information, please refer to [https://www.qrcode.com/en/about/error_correction.html](https://www.qrcode.com/en/about/error_correction.html).
|
|
86
|
+
*
|
|
87
|
+
* @defaultValue 0
|
|
88
|
+
*/
|
|
89
|
+
correctLevel?: number
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* **This is an advanced option.**
|
|
93
|
+
*
|
|
94
|
+
* Specify the mask pattern to be used in QR code encoding.
|
|
95
|
+
*
|
|
96
|
+
* Accepts a value provided by _QRMaskPattern_.
|
|
97
|
+
*
|
|
98
|
+
* 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)
|
|
99
|
+
*
|
|
100
|
+
* 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).
|
|
101
|
+
*/
|
|
102
|
+
maskPattern?: number
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* **This is an advanced option.**
|
|
106
|
+
*
|
|
107
|
+
* Specify the version to be used in QR code encoding.
|
|
108
|
+
*
|
|
109
|
+
* Accepts an integer in range [1, 40].
|
|
110
|
+
*
|
|
111
|
+
* For more information, please refer to [https://www.qrcode.com/en/about/version.html](https://www.qrcode.com/en/about/version.html).
|
|
112
|
+
*/
|
|
113
|
+
version?: number
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Options to control components in the QR code.
|
|
117
|
+
*
|
|
118
|
+
* @deafultValue undefined
|
|
119
|
+
*/
|
|
120
|
+
components?: ComponentOptions
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Color of the blocks on the QR code.
|
|
124
|
+
*
|
|
125
|
+
* Accepts a CSS <color>.
|
|
126
|
+
*
|
|
127
|
+
* 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).
|
|
128
|
+
*
|
|
129
|
+
* @defaultValue "#000000"
|
|
130
|
+
*/
|
|
131
|
+
colorDark?: string
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Color of the empty areas on the QR code.
|
|
135
|
+
*
|
|
136
|
+
* Accepts a CSS <color>.
|
|
137
|
+
*
|
|
138
|
+
* 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).
|
|
139
|
+
*
|
|
140
|
+
* @defaultValue "#ffffff"
|
|
141
|
+
*/
|
|
142
|
+
colorLight?: string
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Automatically calculate the _colorLight_ value from the QR code's background.
|
|
146
|
+
*
|
|
147
|
+
* @defaultValue true
|
|
148
|
+
*/
|
|
149
|
+
autoColor?: boolean
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Background image to be used in the QR code.
|
|
153
|
+
*
|
|
154
|
+
* Accepts a `data:` string in web browsers or a Buffer in Node.js.
|
|
155
|
+
*
|
|
156
|
+
* @defaultValue undefined
|
|
157
|
+
*/
|
|
158
|
+
backgroundImage?: string | Buffer
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Color of the dimming mask above the background image.
|
|
162
|
+
*
|
|
163
|
+
* Accepts a CSS <color>.
|
|
164
|
+
*
|
|
165
|
+
* 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).
|
|
166
|
+
*
|
|
167
|
+
* @defaultValue "rgba(0, 0, 0, 0)"
|
|
168
|
+
*/
|
|
169
|
+
backgroundDimming?: string
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* GIF background image to be used in the QR code.
|
|
173
|
+
*
|
|
174
|
+
* @defaultValue undefined
|
|
175
|
+
*/
|
|
176
|
+
gifBackground?: ArrayBuffer
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Use a white margin instead of a transparent one which reveals the background of the QR code on margins.
|
|
180
|
+
*
|
|
181
|
+
* @defaultValue true
|
|
182
|
+
*/
|
|
183
|
+
whiteMargin?: boolean
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Logo image to be displayed at the center of the QR code.
|
|
187
|
+
*
|
|
188
|
+
* Accepts a `data:` string in web browsers or a Buffer in Node.js.
|
|
189
|
+
*
|
|
190
|
+
* When set to `undefined` or `null`, the logo is disabled.
|
|
191
|
+
*
|
|
192
|
+
* @defaultValue undefined
|
|
193
|
+
*/
|
|
194
|
+
logoImage?: string | Buffer
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Ratio of the logo size to the QR code size.
|
|
198
|
+
*
|
|
199
|
+
* @defaultValue 0.2
|
|
200
|
+
*/
|
|
201
|
+
logoScale?: number
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Size of margins around the logo image in pixels.
|
|
205
|
+
*
|
|
206
|
+
* @defaultValue 6
|
|
207
|
+
*/
|
|
208
|
+
logoMargin?: number
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Corner radius of the logo image in pixels.
|
|
212
|
+
*
|
|
213
|
+
* @defaultValue 8
|
|
214
|
+
*/
|
|
215
|
+
logoCornerRadius?: number
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* @deprecated
|
|
219
|
+
*
|
|
220
|
+
* Ratio of the real size to the full size of the blocks.
|
|
221
|
+
*
|
|
222
|
+
* This can be helpful when you want to make more parts of the background visible.
|
|
223
|
+
*
|
|
224
|
+
* @deafultValue 0.4
|
|
225
|
+
*/
|
|
226
|
+
dotScale?: number
|
|
227
|
+
}
|
|
@@ -3,15 +3,18 @@ import { IPresentationExchange } from '@sphereon/ssi-sdk.presentation-exchange'
|
|
|
3
3
|
import { ISIOPv2RP } from '@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth'
|
|
4
4
|
import { IAgentContext, ICredentialVerifier } from '@veramo/core'
|
|
5
5
|
import { IPDManager } from '@sphereon/ssi-sdk.pd-manager'
|
|
6
|
+
import { QRCodeOpts } from './QRCode.types'
|
|
6
7
|
|
|
7
8
|
export type SiopFeatures = 'rp-status' | 'siop'
|
|
8
9
|
export interface ISIOPv2RPRestAPIOpts {
|
|
9
10
|
enableFeatures?: SiopFeatures[]
|
|
10
11
|
endpointOpts?: {
|
|
11
12
|
basePath?: string
|
|
13
|
+
trustProxy?: boolean | Array<string>
|
|
12
14
|
globalAuth?: GenericAuthArgs & { secureSiopEndpoints?: boolean }
|
|
13
15
|
webappCreateAuthRequest?: ICreateAuthRequestWebappEndpointOpts // Override the create Auth Request path. Needs to contain correlationId and definitionId path params!
|
|
14
16
|
webappDeleteAuthRequest?: ISingleEndpointOpts // Override the delete Auth Request path. Needs to contain correlationId and definitionId path params!
|
|
17
|
+
webappGetDefinitions?: ISingleEndpointOpts // Override the delete Auth Request path. Needs to contain correlationId and definitionId path params!
|
|
15
18
|
webappAuthStatus?: ISingleEndpointOpts // Override the Auth status path. CorrelationId and definitionId need to come from the body!
|
|
16
19
|
siopVerifyAuthResponse?: ISingleEndpointOpts // Override the siop Verify Response path. Needs to contain correlationId and definitionId path params!
|
|
17
20
|
siopGetAuthRequest?: ISingleEndpointOpts // Override the siop get Auth Request path. Needs to contain correlationId and definitionId path params!
|
|
@@ -19,9 +22,10 @@ export interface ISIOPv2RPRestAPIOpts {
|
|
|
19
22
|
}
|
|
20
23
|
export interface ICreateAuthRequestWebappEndpointOpts extends ISingleEndpointOpts {
|
|
21
24
|
siopBaseURI?: string
|
|
25
|
+
qrCodeOpts?: QRCodeOpts
|
|
22
26
|
webappAuthStatusPath?: string
|
|
23
27
|
webappBaseURI?: string
|
|
24
|
-
|
|
28
|
+
responseRedirectURI?: string
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
export type IRequiredPlugins = ICredentialVerifier & ISIOPv2RP & IPresentationExchange & IPDManager
|
|
@@ -17,33 +17,49 @@ export function createAuthRequestWebappEndpoint(router: Router, context: IRequir
|
|
|
17
17
|
try {
|
|
18
18
|
// if (!request.agent) throw Error('No agent configured')
|
|
19
19
|
const definitionId = request.params.definitionId
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
if (!definitionId) {
|
|
21
|
+
return sendErrorResponse(response, 400, 'No definitionId query parameter provided')
|
|
22
|
+
}
|
|
23
|
+
const state: string = request.body.state ?? uuid.uuid()
|
|
24
|
+
const correlationId = request.body.correlationId ?? state
|
|
25
|
+
const qrCodeOpts = request.body.qrCodeOpts ?? opts?.qrCodeOpts
|
|
22
26
|
|
|
23
|
-
const requestByReferenceURI = uriWithBase(`/siop/definitions/${definitionId}/auth-requests/${
|
|
27
|
+
const requestByReferenceURI = uriWithBase(`/siop/definitions/${definitionId}/auth-requests/${state}`, {
|
|
24
28
|
baseURI: opts?.siopBaseURI,
|
|
25
29
|
})
|
|
26
|
-
const responseURI = uriWithBase(`/siop/definitions/${definitionId}/auth-responses/${
|
|
27
|
-
|
|
30
|
+
const responseURI = uriWithBase(`/siop/definitions/${definitionId}/auth-responses/${state}`, { baseURI: opts?.siopBaseURI })
|
|
31
|
+
// first version is for backwards compat
|
|
32
|
+
const responseRedirectURI =
|
|
33
|
+
('response_redirect_uri' in request.body && (request.body.response_redirect_uri as string | undefined)) ??
|
|
34
|
+
('responseRedirectURI' in request.body && (request.body.responseRedirectURI as string | undefined))
|
|
28
35
|
|
|
29
36
|
const authRequestURI = await context.agent.siopCreateAuthRequestURI({
|
|
30
37
|
definitionId,
|
|
31
38
|
correlationId,
|
|
32
39
|
state,
|
|
33
|
-
nonce:
|
|
40
|
+
nonce: uuid.uuid(),
|
|
34
41
|
requestByReferenceURI,
|
|
35
42
|
responseURIType: 'response_uri',
|
|
36
43
|
responseURI,
|
|
37
44
|
...(responseRedirectURI && { responseRedirectURI }),
|
|
38
45
|
})
|
|
46
|
+
|
|
47
|
+
let qrCodeDataUri: string | undefined
|
|
48
|
+
if (qrCodeOpts) {
|
|
49
|
+
const { AwesomeQR } = await import('awesome-qr')
|
|
50
|
+
const qrCode = new AwesomeQR({ ...qrCodeOpts, text: authRequestURI })
|
|
51
|
+
qrCodeDataUri = `data:image/png;base64,${(await qrCode.draw())!.toString('base64')}`
|
|
52
|
+
}
|
|
39
53
|
const authRequestBody: GenerateAuthRequestURIResponse = {
|
|
40
54
|
correlationId,
|
|
55
|
+
state,
|
|
41
56
|
definitionId,
|
|
42
57
|
authRequestURI,
|
|
43
58
|
authStatusURI: `${uriWithBase(opts?.webappAuthStatusPath ?? '/webapp/auth-status', { baseURI: opts?.webappBaseURI })}`,
|
|
59
|
+
...(qrCodeDataUri && { qrCodeDataUri }),
|
|
44
60
|
}
|
|
45
61
|
console.log(`Auth Request URI data to send back: ${JSON.stringify(authRequestBody)}`)
|
|
46
|
-
return response.
|
|
62
|
+
return response.json(authRequestBody)
|
|
47
63
|
} catch (error) {
|
|
48
64
|
return sendErrorResponse(response, 500, 'Could not create an authorization request URI', error)
|
|
49
65
|
}
|
|
@@ -82,7 +98,7 @@ export function authStatusWebappEndpoint(router: Router, context: IRequiredConte
|
|
|
82
98
|
definitionId,
|
|
83
99
|
lastUpdated: requestState ? requestState.lastUpdated : Date.now(),
|
|
84
100
|
}
|
|
85
|
-
return response.
|
|
101
|
+
return response.json(statusBody)
|
|
86
102
|
}
|
|
87
103
|
|
|
88
104
|
let includeVerifiedData: VerifiedDataMode = VerifiedDataMode.NONE
|
|
@@ -114,13 +130,13 @@ export function authStatusWebappEndpoint(router: Router, context: IRequiredConte
|
|
|
114
130
|
}
|
|
115
131
|
: {}),
|
|
116
132
|
}
|
|
117
|
-
console.
|
|
133
|
+
console.debug(`Will send auth status: ${JSON.stringify(statusBody)}`)
|
|
118
134
|
if (overallState.status === 'error') {
|
|
119
135
|
response.statusCode = 500
|
|
120
|
-
return response.
|
|
136
|
+
return response.json(statusBody)
|
|
121
137
|
}
|
|
122
138
|
response.statusCode = 200
|
|
123
|
-
return response.
|
|
139
|
+
return response.json(statusBody)
|
|
124
140
|
} catch (error) {
|
|
125
141
|
return sendErrorResponse(response, 500, error.message, error)
|
|
126
142
|
}
|
|
@@ -142,7 +158,24 @@ export function removeAuthRequestStateWebappEndpoint(router: Router, context: IR
|
|
|
142
158
|
return sendErrorResponse(response, 404, 'No authorization request could be found')
|
|
143
159
|
}
|
|
144
160
|
response.statusCode = 200
|
|
145
|
-
return response.
|
|
161
|
+
return response.json(await context.agent.siopDeleteAuthState({ definitionId, correlationId }))
|
|
162
|
+
} catch (error) {
|
|
163
|
+
return sendErrorResponse(response, 500, error.message, error)
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export function getDefinitionsEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {
|
|
169
|
+
if (opts?.enabled === false) {
|
|
170
|
+
console.log(`getDefinitions Webapp endpoint is disabled`)
|
|
171
|
+
return
|
|
172
|
+
}
|
|
173
|
+
const path = opts?.path ?? '/webapp/definitions'
|
|
174
|
+
router.get(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {
|
|
175
|
+
try {
|
|
176
|
+
const definitions = await context.agent.pdmGetDefinitions()
|
|
177
|
+
response.statusCode = 200
|
|
178
|
+
return response.json(definitions)
|
|
146
179
|
} catch (error) {
|
|
147
180
|
return sendErrorResponse(response, 500, error.message, error)
|
|
148
181
|
}
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAA;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AAEzD,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,MAAM,CAAA;AAC/C,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,EAAE,YAAY,EAAE,CAAA;IAC/B,YAAY,CAAC,EAAE;QACb,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,UAAU,CAAC,EAAE,eAAe,GAAG;YAAE,mBAAmB,CAAC,EAAE,OAAO,CA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