@sphereon/ssi-sdk.siopv2-oid4vp-rp-rest-api 0.32.1-feature.oid4vp.rest.api.improv.bootcamp.187 → 0.32.1-fix.143
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/siopv2-rp-api-server.d.ts.map +1 -1
- package/dist/siopv2-rp-api-server.js +4 -5
- package/dist/siopv2-rp-api-server.js.map +1 -1
- package/dist/types.d.ts +1 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/webapp-api-functions.d.ts +0 -1
- package/dist/webapp-api-functions.d.ts.map +1 -1
- package/dist/webapp-api-functions.js +14 -38
- package/dist/webapp-api-functions.js.map +1 -1
- package/package.json +14 -14
- package/src/siopv2-rp-api-server.ts +1 -2
- package/src/types.ts +1 -2
- package/src/webapp-api-functions.ts +12 -37
|
@@ -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,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAElD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAGhE,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;gBAEjC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAAC,cAAc,EAAE,cAAc,CAAC;QAAC,IAAI,CAAC,EAAE,oBAAoB,CAAA;KAAE;
|
|
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,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAElD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAGhE,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;gBAEjC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAAC,cAAc,EAAE,cAAc,CAAC;QAAC,IAAI,CAAC,EAAE,oBAAoB,CAAA;KAAE;IA+BlH,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"}
|
|
@@ -11,7 +11,7 @@ const siop_api_functions_1 = require("./siop-api-functions");
|
|
|
11
11
|
const webapp_api_functions_1 = require("./webapp-api-functions");
|
|
12
12
|
class SIOPv2RPApiServer {
|
|
13
13
|
constructor(args) {
|
|
14
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k
|
|
14
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
15
15
|
const { agent, opts } = args;
|
|
16
16
|
this._agent = agent;
|
|
17
17
|
(0, ssi_express_support_1.copyGlobalAuthToEndpoints)({ opts, keys: ['webappCreateAuthRequest', 'webappAuthStatus', 'webappDeleteAuthRequest'] });
|
|
@@ -29,14 +29,13 @@ class SIOPv2RPApiServer {
|
|
|
29
29
|
(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
30
|
(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
31
|
(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);
|
|
32
|
-
(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);
|
|
33
32
|
}
|
|
34
33
|
// SIOPv2 endpoints
|
|
35
34
|
if (features.includes('siop')) {
|
|
36
|
-
(0, siop_api_functions_1.getAuthRequestSIOPv2Endpoint)(this._router, context, (
|
|
37
|
-
(0, siop_api_functions_1.verifyAuthResponseSIOPv2Endpoint)(this._router, context, (
|
|
35
|
+
(0, siop_api_functions_1.getAuthRequestSIOPv2Endpoint)(this._router, context, (_g = opts === null || opts === void 0 ? void 0 : opts.endpointOpts) === null || _g === void 0 ? void 0 : _g.siopGetAuthRequest);
|
|
36
|
+
(0, siop_api_functions_1.verifyAuthResponseSIOPv2Endpoint)(this._router, context, (_h = opts === null || opts === void 0 ? void 0 : opts.endpointOpts) === null || _h === void 0 ? void 0 : _h.siopVerifyAuthResponse);
|
|
38
37
|
}
|
|
39
|
-
this._express.use((
|
|
38
|
+
this._express.use((_k = (_j = opts === null || opts === void 0 ? void 0 : opts.endpointOpts) === null || _j === void 0 ? void 0 : _j.basePath) !== null && _k !== void 0 ? _k : '', this.router);
|
|
40
39
|
}
|
|
41
40
|
get express() {
|
|
42
41
|
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,sDAAkD;AAClD,6DAAqG;AAErG,
|
|
1
|
+
{"version":3,"file":"siopv2-rp-api-server.js","sourceRoot":"","sources":["../src/siopv2-rp-api-server.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAqD;AACrD,uEAAyF;AAIzF,sDAAkD;AAClD,6DAAqG;AAErG,iEAAwI;AAExI,MAAa,iBAAiB;IAM5B,YAAY,IAAsG;;QAChH,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,mBAAmB,EAAE,CAAC;YACxD,IAAA,+CAAyB,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,oBAAoB,EAAE,wBAAwB,CAAC,EAAE,CAAC,CAAA;QAC7F,CAAC;QAED,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,C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CAAA;QACrG,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY,0CAAE,QAAQ,mCAAI,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IACpE,CAAC;IAED,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;AApDD,8CAoDC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -13,7 +13,6 @@ export interface ISIOPv2RPRestAPIOpts {
|
|
|
13
13
|
};
|
|
14
14
|
webappCreateAuthRequest?: ICreateAuthRequestWebappEndpointOpts;
|
|
15
15
|
webappDeleteAuthRequest?: ISingleEndpointOpts;
|
|
16
|
-
webappGetDefinitions?: ISingleEndpointOpts;
|
|
17
16
|
webappAuthStatus?: ISingleEndpointOpts;
|
|
18
17
|
siopVerifyAuthResponse?: ISingleEndpointOpts;
|
|
19
18
|
siopGetAuthRequest?: ISingleEndpointOpts;
|
|
@@ -23,7 +22,7 @@ export interface ICreateAuthRequestWebappEndpointOpts extends ISingleEndpointOpt
|
|
|
23
22
|
siopBaseURI?: string;
|
|
24
23
|
webappAuthStatusPath?: string;
|
|
25
24
|
webappBaseURI?: string;
|
|
26
|
-
|
|
25
|
+
nonce?: string;
|
|
27
26
|
}
|
|
28
27
|
export type IRequiredPlugins = ICredentialVerifier & ISIOPv2RP & IPresentationExchange & IPDManager;
|
|
29
28
|
export type IRequiredContext = IAgentContext<IRequiredPlugins>;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":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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,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,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,gBAAgB,GAAG,mBAAmB,GAAG,SAAS,GAAG,qBAAqB,GAAG,UAAU,CAAA;AACnG,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC,gBAAgB,CAAC,CAAA"}
|
|
@@ -4,5 +4,4 @@ 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;
|
|
8
7
|
//# 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;
|
|
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,QAyCrI;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"}
|
|
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.createAuthRequestWebappEndpoint = createAuthRequestWebappEndpoint;
|
|
16
16
|
exports.authStatusWebappEndpoint = authStatusWebappEndpoint;
|
|
17
17
|
exports.removeAuthRequestStateWebappEndpoint = removeAuthRequestStateWebappEndpoint;
|
|
18
|
-
exports.getDefinitionsEndpoint = getDefinitionsEndpoint;
|
|
19
18
|
const did_auth_siop_1 = require("@sphereon/did-auth-siop");
|
|
20
19
|
const ssi_express_support_1 = require("@sphereon/ssi-express-support");
|
|
21
20
|
const ssi_sdk_siopv2_oid4vp_common_1 = require("@sphereon/ssi-sdk.siopv2-oid4vp-common");
|
|
@@ -30,33 +29,28 @@ function createAuthRequestWebappEndpoint(router, context, opts) {
|
|
|
30
29
|
}
|
|
31
30
|
const path = (_a = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _a !== void 0 ? _a : '/webapp/definitions/:definitionId/auth-requests';
|
|
32
31
|
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* () {
|
|
33
|
-
var _a
|
|
32
|
+
var _a;
|
|
34
33
|
try {
|
|
35
34
|
// if (!request.agent) throw Error('No agent configured')
|
|
36
35
|
const definitionId = request.params.definitionId;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
const state = (_a = request.body.state) !== null && _a !== void 0 ? _a : short_uuid_1.default.uuid();
|
|
41
|
-
const correlationId = (_b = request.body.correlationId) !== null && _b !== void 0 ? _b : state;
|
|
42
|
-
const requestByReferenceURI = (0, ssi_sdk_siopv2_oid4vp_common_1.uriWithBase)(`/siop/definitions/${definitionId}/auth-requests/${state}`, {
|
|
36
|
+
const state = short_uuid_1.default.uuid();
|
|
37
|
+
const correlationId = state;
|
|
38
|
+
const requestByReferenceURI = (0, ssi_sdk_siopv2_oid4vp_common_1.uriWithBase)(`/siop/definitions/${definitionId}/auth-requests/${correlationId}`, {
|
|
43
39
|
baseURI: opts === null || opts === void 0 ? void 0 : opts.siopBaseURI,
|
|
44
40
|
});
|
|
45
|
-
const responseURI = (0, ssi_sdk_siopv2_oid4vp_common_1.uriWithBase)(`/siop/definitions/${definitionId}/auth-responses/${
|
|
46
|
-
|
|
47
|
-
const responseRedirectURI = (_c = ('response_redirect_uri' in request.body && request.body.response_redirect_uri)) !== null && _c !== void 0 ? _c : ('responseRedirectURI' in request.body && request.body.responseRedirectURI);
|
|
41
|
+
const responseURI = (0, ssi_sdk_siopv2_oid4vp_common_1.uriWithBase)(`/siop/definitions/${definitionId}/auth-responses/${correlationId}`, { baseURI: opts === null || opts === void 0 ? void 0 : opts.siopBaseURI });
|
|
42
|
+
const responseRedirectURI = 'response_redirect_uri' in request.body && request.body.response_redirect_uri;
|
|
48
43
|
const authRequestURI = yield context.agent.siopCreateAuthRequestURI(Object.assign({ definitionId,
|
|
49
44
|
correlationId,
|
|
50
|
-
state, nonce:
|
|
45
|
+
state, nonce: opts === null || opts === void 0 ? void 0 : opts.nonce, requestByReferenceURI, responseURIType: 'response_uri', responseURI }, (responseRedirectURI && { responseRedirectURI })));
|
|
51
46
|
const authRequestBody = {
|
|
52
47
|
correlationId,
|
|
53
|
-
state,
|
|
54
48
|
definitionId,
|
|
55
49
|
authRequestURI,
|
|
56
|
-
authStatusURI: `${(0, ssi_sdk_siopv2_oid4vp_common_1.uriWithBase)((
|
|
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 })}`,
|
|
57
51
|
};
|
|
58
52
|
console.log(`Auth Request URI data to send back: ${JSON.stringify(authRequestBody)}`);
|
|
59
|
-
return response.
|
|
53
|
+
return response.send(authRequestBody);
|
|
60
54
|
}
|
|
61
55
|
catch (error) {
|
|
62
56
|
return (0, ssi_express_support_1.sendErrorResponse)(response, 500, 'Could not create an authorization request URI', error);
|
|
@@ -93,7 +87,7 @@ function authStatusWebappEndpoint(router, context, opts) {
|
|
|
93
87
|
definitionId,
|
|
94
88
|
lastUpdated: requestState ? requestState.lastUpdated : Date.now(),
|
|
95
89
|
};
|
|
96
|
-
return response.
|
|
90
|
+
return response.send(statusBody);
|
|
97
91
|
}
|
|
98
92
|
let includeVerifiedData = ssi_sdk_siopv2_oid4vp_rp_auth_1.VerifiedDataMode.NONE;
|
|
99
93
|
if ('includeVerifiedData' in request.body) {
|
|
@@ -116,13 +110,13 @@ function authStatusWebappEndpoint(router, context, opts) {
|
|
|
116
110
|
verifiedData: responseState.verifiedData,
|
|
117
111
|
}
|
|
118
112
|
: {}));
|
|
119
|
-
console.
|
|
113
|
+
console.log(`Will send auth status: ${JSON.stringify(statusBody)}`);
|
|
120
114
|
if (overallState.status === 'error') {
|
|
121
115
|
response.statusCode = 500;
|
|
122
|
-
return response.
|
|
116
|
+
return response.send(statusBody);
|
|
123
117
|
}
|
|
124
118
|
response.statusCode = 200;
|
|
125
|
-
return response.
|
|
119
|
+
return response.send(statusBody);
|
|
126
120
|
}
|
|
127
121
|
catch (error) {
|
|
128
122
|
return (0, ssi_express_support_1.sendErrorResponse)(response, 500, error.message, error);
|
|
@@ -145,25 +139,7 @@ function removeAuthRequestStateWebappEndpoint(router, context, opts) {
|
|
|
145
139
|
return (0, ssi_express_support_1.sendErrorResponse)(response, 404, 'No authorization request could be found');
|
|
146
140
|
}
|
|
147
141
|
response.statusCode = 200;
|
|
148
|
-
return response.
|
|
149
|
-
}
|
|
150
|
-
catch (error) {
|
|
151
|
-
return (0, ssi_express_support_1.sendErrorResponse)(response, 500, error.message, error);
|
|
152
|
-
}
|
|
153
|
-
}));
|
|
154
|
-
}
|
|
155
|
-
function getDefinitionsEndpoint(router, context, opts) {
|
|
156
|
-
var _a;
|
|
157
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
158
|
-
console.log(`getDefinitions Webapp endpoint is disabled`);
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
const path = (_a = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _a !== void 0 ? _a : '/webapp/definitions';
|
|
162
|
-
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* () {
|
|
163
|
-
try {
|
|
164
|
-
const definitions = yield context.agent.pdmGetDefinitions();
|
|
165
|
-
response.statusCode = 200;
|
|
166
|
-
return response.json(definitions);
|
|
142
|
+
return response.send(context.agent.siopDeleteAuthState({ definitionId, correlationId }));
|
|
167
143
|
}
|
|
168
144
|
catch (error) {
|
|
169
145
|
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,0EAyCC;AAED,4DA2EC;AAED,oFAoBC;AArJD,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,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,CAAA;YAChD,MAAM,KAAK,GAAW,oBAAI,CAAC,IAAI,EAAE,CAAA;YACjC,MAAM,aAAa,GAAG,KAAK,CAAA;YAE3B,MAAM,qBAAqB,GAAG,IAAA,0CAAW,EAAC,qBAAqB,YAAY,kBAAkB,aAAa,EAAE,EAAE;gBAC5G,OAAO,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW;aAC3B,CAAC,CAAA;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;gBACxI,OAAO,IAAA,uCAAiB,EAAC,QAAQ,EAAE,GAAG,EAAE,yCAAyC,CAAC,CAAA;YACpF,CAAC;YACD,QAAQ,CAAC,UAAU,GAAG,GAAG,CAAA;YACzB,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,mBAAmB,CAAC,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC,CAAC,CAAA;QAC1F,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,IAAA,uCAAiB,EAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QAC/D,CAAC;IACH,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC"}
|
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-
|
|
3
|
+
"version": "0.32.1-fix.143+06a949d0",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,16 +11,16 @@
|
|
|
11
11
|
"start:dev": "ts-node __tests__/RestAPI.ts"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@sphereon/did-auth-siop": "0.16.1-
|
|
15
|
-
"@sphereon/ssi-express-support": "0.32.1-
|
|
16
|
-
"@sphereon/ssi-sdk.core": "0.32.1-
|
|
17
|
-
"@sphereon/ssi-sdk.credential-validation": "0.32.1-
|
|
18
|
-
"@sphereon/ssi-sdk.kv-store-temp": "0.32.1-
|
|
19
|
-
"@sphereon/ssi-sdk.pd-manager": "0.32.1-
|
|
20
|
-
"@sphereon/ssi-sdk.presentation-exchange": "0.32.1-
|
|
21
|
-
"@sphereon/ssi-sdk.siopv2-oid4vp-common": "0.32.1-
|
|
22
|
-
"@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth": "0.32.1-
|
|
23
|
-
"@sphereon/ssi-types": "0.32.1-
|
|
14
|
+
"@sphereon/did-auth-siop": "0.16.1-next.339",
|
|
15
|
+
"@sphereon/ssi-express-support": "0.32.1-fix.143+06a949d0",
|
|
16
|
+
"@sphereon/ssi-sdk.core": "0.32.1-fix.143+06a949d0",
|
|
17
|
+
"@sphereon/ssi-sdk.credential-validation": "0.32.1-fix.143+06a949d0",
|
|
18
|
+
"@sphereon/ssi-sdk.kv-store-temp": "0.32.1-fix.143+06a949d0",
|
|
19
|
+
"@sphereon/ssi-sdk.pd-manager": "0.32.1-fix.143+06a949d0",
|
|
20
|
+
"@sphereon/ssi-sdk.presentation-exchange": "0.32.1-fix.143+06a949d0",
|
|
21
|
+
"@sphereon/ssi-sdk.siopv2-oid4vp-common": "0.32.1-fix.143+06a949d0",
|
|
22
|
+
"@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth": "0.32.1-fix.143+06a949d0",
|
|
23
|
+
"@sphereon/ssi-types": "0.32.1-fix.143+06a949d0",
|
|
24
24
|
"@veramo/core": "4.2.0",
|
|
25
25
|
"@veramo/credential-w3c": "4.2.0",
|
|
26
26
|
"body-parser": "^1.20.2",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"@sphereon/pex": "5.0.0-unstable.28",
|
|
39
39
|
"@sphereon/pex-models": "^2.3.2",
|
|
40
40
|
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.27.0",
|
|
41
|
-
"@sphereon/ssi-sdk.data-store": "0.32.1-
|
|
42
|
-
"@sphereon/ssi-sdk.vc-handler-ld-local": "0.32.1-
|
|
41
|
+
"@sphereon/ssi-sdk.data-store": "0.32.1-fix.143+06a949d0",
|
|
42
|
+
"@sphereon/ssi-sdk.vc-handler-ld-local": "0.32.1-fix.143+06a949d0",
|
|
43
43
|
"@types/body-parser": "^1.19.5",
|
|
44
44
|
"@types/cookie-parser": "^1.4.7",
|
|
45
45
|
"@types/cors": "^2.8.17",
|
|
@@ -98,5 +98,5 @@
|
|
|
98
98
|
"Authenticator"
|
|
99
99
|
],
|
|
100
100
|
"nx": {},
|
|
101
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "06a949d0869605b81a747839e200d24186b55cca"
|
|
102
102
|
}
|
|
@@ -6,7 +6,7 @@ import { TAgent } from '@veramo/core'
|
|
|
6
6
|
import express, { Express, Router } from 'express'
|
|
7
7
|
import { getAuthRequestSIOPv2Endpoint, verifyAuthResponseSIOPv2Endpoint } from './siop-api-functions'
|
|
8
8
|
import { IRequiredPlugins, ISIOPv2RPRestAPIOpts } from './types'
|
|
9
|
-
import {authStatusWebappEndpoint, createAuthRequestWebappEndpoint,
|
|
9
|
+
import { authStatusWebappEndpoint, createAuthRequestWebappEndpoint, removeAuthRequestStateWebappEndpoint } from './webapp-api-functions'
|
|
10
10
|
|
|
11
11
|
export class SIOPv2RPApiServer {
|
|
12
12
|
private readonly _express: Express
|
|
@@ -35,7 +35,6 @@ export class SIOPv2RPApiServer {
|
|
|
35
35
|
createAuthRequestWebappEndpoint(this._router, context, opts?.endpointOpts?.webappCreateAuthRequest)
|
|
36
36
|
authStatusWebappEndpoint(this._router, context, opts?.endpointOpts?.webappAuthStatus)
|
|
37
37
|
removeAuthRequestStateWebappEndpoint(this._router, context, opts?.endpointOpts?.webappDeleteAuthRequest)
|
|
38
|
-
getDefinitionsEndpoint(this._router, context, opts?.endpointOpts?.webappGetDefinitions)
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
// SIOPv2 endpoints
|
package/src/types.ts
CHANGED
|
@@ -12,7 +12,6 @@ export interface ISIOPv2RPRestAPIOpts {
|
|
|
12
12
|
globalAuth?: GenericAuthArgs & { secureSiopEndpoints?: boolean }
|
|
13
13
|
webappCreateAuthRequest?: ICreateAuthRequestWebappEndpointOpts // Override the create Auth Request path. Needs to contain correlationId and definitionId path params!
|
|
14
14
|
webappDeleteAuthRequest?: ISingleEndpointOpts // Override the delete Auth Request path. Needs to contain correlationId and definitionId path params!
|
|
15
|
-
webappGetDefinitions?: ISingleEndpointOpts // Override the delete Auth Request path. Needs to contain correlationId and definitionId path params!
|
|
16
15
|
webappAuthStatus?: ISingleEndpointOpts // Override the Auth status path. CorrelationId and definitionId need to come from the body!
|
|
17
16
|
siopVerifyAuthResponse?: ISingleEndpointOpts // Override the siop Verify Response path. Needs to contain correlationId and definitionId path params!
|
|
18
17
|
siopGetAuthRequest?: ISingleEndpointOpts // Override the siop get Auth Request path. Needs to contain correlationId and definitionId path params!
|
|
@@ -22,7 +21,7 @@ export interface ICreateAuthRequestWebappEndpointOpts extends ISingleEndpointOpt
|
|
|
22
21
|
siopBaseURI?: string
|
|
23
22
|
webappAuthStatusPath?: string
|
|
24
23
|
webappBaseURI?: string
|
|
25
|
-
|
|
24
|
+
nonce?: string
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
export type IRequiredPlugins = ICredentialVerifier & ISIOPv2RP & IPresentationExchange & IPDManager
|
|
@@ -7,8 +7,6 @@ import uuid from 'short-uuid'
|
|
|
7
7
|
import { ICreateAuthRequestWebappEndpointOpts, IRequiredContext } from './types'
|
|
8
8
|
import { shaHasher as defaultHasher } from '@sphereon/ssi-sdk.core'
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
10
|
export function createAuthRequestWebappEndpoint(router: Router, context: IRequiredContext, opts?: ICreateAuthRequestWebappEndpointOpts) {
|
|
13
11
|
if (opts?.enabled === false) {
|
|
14
12
|
console.log(`createAuthRequest Webapp endpoint is disabled`)
|
|
@@ -19,24 +17,20 @@ export function createAuthRequestWebappEndpoint(router: Router, context: IRequir
|
|
|
19
17
|
try {
|
|
20
18
|
// if (!request.agent) throw Error('No agent configured')
|
|
21
19
|
const definitionId = request.params.definitionId
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
const state: string = request.body.state ?? uuid.uuid()
|
|
26
|
-
const correlationId = request.body.correlationId ?? state
|
|
20
|
+
const state: string = uuid.uuid()
|
|
21
|
+
const correlationId = state
|
|
27
22
|
|
|
28
|
-
const requestByReferenceURI = uriWithBase(`/siop/definitions/${definitionId}/auth-requests/${
|
|
23
|
+
const requestByReferenceURI = uriWithBase(`/siop/definitions/${definitionId}/auth-requests/${correlationId}`, {
|
|
29
24
|
baseURI: opts?.siopBaseURI,
|
|
30
25
|
})
|
|
31
|
-
const responseURI = uriWithBase(`/siop/definitions/${definitionId}/auth-responses/${
|
|
32
|
-
|
|
33
|
-
const responseRedirectURI = ('response_redirect_uri' in request.body && (request.body.response_redirect_uri as string | undefined)) ?? ('responseRedirectURI' in request.body && (request.body.responseRedirectURI as string | undefined))
|
|
26
|
+
const responseURI = uriWithBase(`/siop/definitions/${definitionId}/auth-responses/${correlationId}`, { baseURI: opts?.siopBaseURI })
|
|
27
|
+
const responseRedirectURI = 'response_redirect_uri' in request.body && (request.body.response_redirect_uri as string | undefined)
|
|
34
28
|
|
|
35
29
|
const authRequestURI = await context.agent.siopCreateAuthRequestURI({
|
|
36
30
|
definitionId,
|
|
37
31
|
correlationId,
|
|
38
32
|
state,
|
|
39
|
-
nonce:
|
|
33
|
+
nonce: opts?.nonce,
|
|
40
34
|
requestByReferenceURI,
|
|
41
35
|
responseURIType: 'response_uri',
|
|
42
36
|
responseURI,
|
|
@@ -44,13 +38,12 @@ export function createAuthRequestWebappEndpoint(router: Router, context: IRequir
|
|
|
44
38
|
})
|
|
45
39
|
const authRequestBody: GenerateAuthRequestURIResponse = {
|
|
46
40
|
correlationId,
|
|
47
|
-
state,
|
|
48
41
|
definitionId,
|
|
49
42
|
authRequestURI,
|
|
50
43
|
authStatusURI: `${uriWithBase(opts?.webappAuthStatusPath ?? '/webapp/auth-status', { baseURI: opts?.webappBaseURI })}`,
|
|
51
44
|
}
|
|
52
45
|
console.log(`Auth Request URI data to send back: ${JSON.stringify(authRequestBody)}`)
|
|
53
|
-
return response.
|
|
46
|
+
return response.send(authRequestBody)
|
|
54
47
|
} catch (error) {
|
|
55
48
|
return sendErrorResponse(response, 500, 'Could not create an authorization request URI', error)
|
|
56
49
|
}
|
|
@@ -89,7 +82,7 @@ export function authStatusWebappEndpoint(router: Router, context: IRequiredConte
|
|
|
89
82
|
definitionId,
|
|
90
83
|
lastUpdated: requestState ? requestState.lastUpdated : Date.now(),
|
|
91
84
|
}
|
|
92
|
-
return response.
|
|
85
|
+
return response.send(statusBody)
|
|
93
86
|
}
|
|
94
87
|
|
|
95
88
|
let includeVerifiedData: VerifiedDataMode = VerifiedDataMode.NONE
|
|
@@ -121,13 +114,13 @@ export function authStatusWebappEndpoint(router: Router, context: IRequiredConte
|
|
|
121
114
|
}
|
|
122
115
|
: {}),
|
|
123
116
|
}
|
|
124
|
-
console.
|
|
117
|
+
console.log(`Will send auth status: ${JSON.stringify(statusBody)}`)
|
|
125
118
|
if (overallState.status === 'error') {
|
|
126
119
|
response.statusCode = 500
|
|
127
|
-
return response.
|
|
120
|
+
return response.send(statusBody)
|
|
128
121
|
}
|
|
129
122
|
response.statusCode = 200
|
|
130
|
-
return response.
|
|
123
|
+
return response.send(statusBody)
|
|
131
124
|
} catch (error) {
|
|
132
125
|
return sendErrorResponse(response, 500, error.message, error)
|
|
133
126
|
}
|
|
@@ -149,25 +142,7 @@ export function removeAuthRequestStateWebappEndpoint(router: Router, context: IR
|
|
|
149
142
|
return sendErrorResponse(response, 404, 'No authorization request could be found')
|
|
150
143
|
}
|
|
151
144
|
response.statusCode = 200
|
|
152
|
-
return response.
|
|
153
|
-
} catch (error) {
|
|
154
|
-
return sendErrorResponse(response, 500, error.message, error)
|
|
155
|
-
}
|
|
156
|
-
})
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
export function getDefinitionsEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {
|
|
161
|
-
if (opts?.enabled === false) {
|
|
162
|
-
console.log(`getDefinitions Webapp endpoint is disabled`)
|
|
163
|
-
return
|
|
164
|
-
}
|
|
165
|
-
const path = opts?.path ?? '/webapp/definitions'
|
|
166
|
-
router.get(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {
|
|
167
|
-
try {
|
|
168
|
-
const definitions = await context.agent.pdmGetDefinitions()
|
|
169
|
-
response.statusCode = 200
|
|
170
|
-
return response.json(definitions)
|
|
145
|
+
return response.send(context.agent.siopDeleteAuthState({ definitionId, correlationId }))
|
|
171
146
|
} catch (error) {
|
|
172
147
|
return sendErrorResponse(response, 500, error.message, error)
|
|
173
148
|
}
|