@sphereon/ssi-sdk.siopv2-oid4vp-rp-rest-api 0.32.1-next.54 → 0.33.1-feature.jose.vcdm.55

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.
@@ -1,164 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.verifyAuthResponseSIOPv2Endpoint = verifyAuthResponseSIOPv2Endpoint;
13
- exports.getAuthRequestSIOPv2Endpoint = getAuthRequestSIOPv2Endpoint;
14
- const did_auth_siop_1 = require("@sphereon/did-auth-siop");
15
- const ssi_express_support_1 = require("@sphereon/ssi-express-support");
16
- const ssi_types_1 = require("@sphereon/ssi-types");
17
- const parseAuthorizationResponse = (request) => {
18
- const contentType = request.header('content-type');
19
- if (contentType === 'application/json') {
20
- const payload = typeof request.body === 'string' ? JSON.parse(request.body) : request.body;
21
- return payload;
22
- }
23
- if (contentType === 'application/x-www-form-urlencoded') {
24
- const payload = request.body;
25
- // Parse presentation_submission if it's a string
26
- if (typeof payload.presentation_submission === 'string') {
27
- console.log(`Supplied presentation_submission was a string instead of JSON. Correcting, but external party should fix their implementation!`);
28
- payload.presentation_submission = JSON.parse(payload.presentation_submission);
29
- }
30
- // when using FORM_URL_ENCODED, vp_token comes back as string not matter whether the input was string, object or array. Handled below.
31
- if (typeof payload.vp_token === 'string') {
32
- const { vp_token } = payload;
33
- // The only use case where vp_object is an object is JsonLdAsString atm. For arrays, any objects will be parsed along with the array
34
- // (Leaving the vp_token JsonLdAsString causes problems because the original credential will remain string and will be interpreted as JWT in some parts of the code)
35
- if ((vp_token.startsWith('[') && vp_token.endsWith(']')) || ssi_types_1.CredentialMapper.isJsonLdAsString(vp_token)) {
36
- payload.vp_token = JSON.parse(vp_token);
37
- }
38
- }
39
- return payload;
40
- }
41
- throw new Error(`Unsupported content type: ${contentType}. Currently only application/x-www-form-urlencoded and application/json (for direct_post) are supported`);
42
- };
43
- function verifyAuthResponseSIOPv2Endpoint(router, context, opts) {
44
- var _a;
45
- if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
46
- console.log(`verifyAuthResponse SIOP endpoint is disabled`);
47
- return;
48
- }
49
- const path = (_a = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _a !== void 0 ? _a : '/siop/definitions/:definitionId/auth-responses/:correlationId';
50
- 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* () {
51
- var _a, _b;
52
- try {
53
- const { correlationId, definitionId, tenantId, version } = request.params;
54
- if (!correlationId || !definitionId) {
55
- console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, definitionId: ${definitionId}`);
56
- return (0, ssi_express_support_1.sendErrorResponse)(response, 404, 'No authorization request could be found');
57
- }
58
- console.log('Authorization Response (siop-sessions');
59
- console.log(JSON.stringify(request.body, null, 2));
60
- const definitionItems = yield context.agent.pdmGetDefinitions({ filter: [{ definitionId, tenantId, version }] });
61
- if (definitionItems.length === 0) {
62
- console.log(`Could not get definition ${definitionId} from agent. Will return 404`);
63
- response.statusCode = 404;
64
- response.statusMessage = `No definition ${definitionId}`;
65
- return response.send();
66
- }
67
- const authorizationResponse = parseAuthorizationResponse(request);
68
- console.log(`URI: ${JSON.stringify(authorizationResponse)}`);
69
- const definition = definitionItems[0].definitionPayload;
70
- const verifiedResponse = yield context.agent.siopVerifyAuthResponse({
71
- authorizationResponse,
72
- correlationId,
73
- definitionId,
74
- presentationDefinitions: [
75
- {
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,
78
- },
79
- ],
80
- });
81
- const wrappedPresentation = (_b = verifiedResponse === null || verifiedResponse === void 0 ? void 0 : verifiedResponse.oid4vpSubmission) === null || _b === void 0 ? void 0 : _b.presentations[0];
82
- if (wrappedPresentation) {
83
- // const credentialSubject = wrappedPresentation.presentation.verifiableCredential[0]?.credential?.credentialSubject
84
- // console.log(JSON.stringify(credentialSubject, null, 2))
85
- console.log('PRESENTATION:' + JSON.stringify(wrappedPresentation.presentation, null, 2));
86
- response.statusCode = 200;
87
- const authorizationChallengeValidationResponse = { presentation_during_issuance_session: verifiedResponse.correlationId };
88
- if (authorizationResponse.is_first_party) {
89
- response.setHeader('Content-Type', 'application/json');
90
- return response.send(JSON.stringify(authorizationChallengeValidationResponse));
91
- }
92
- const responseRedirectURI = yield context.agent.siopGetRedirectURI({ correlationId, definitionId, state: verifiedResponse.state });
93
- if (responseRedirectURI) {
94
- response.setHeader('Content-Type', 'application/json');
95
- return response.send(JSON.stringify({ redirect_uri: responseRedirectURI }));
96
- }
97
- // todo: delete session
98
- }
99
- else {
100
- console.log('Missing Presentation (Verifiable Credentials)');
101
- response.statusCode = 500;
102
- response.statusMessage = 'Missing Presentation (Verifiable Credentials)';
103
- }
104
- return response.send();
105
- }
106
- catch (error) {
107
- console.error(error);
108
- return (0, ssi_express_support_1.sendErrorResponse)(response, 500, 'Could not verify auth status', error);
109
- }
110
- }));
111
- }
112
- function getAuthRequestSIOPv2Endpoint(router, context, opts) {
113
- var _a;
114
- if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
115
- console.log(`getAuthRequest SIOP endpoint is disabled`);
116
- return;
117
- }
118
- const path = (_a = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _a !== void 0 ? _a : '/siop/definitions/:definitionId/auth-requests/:correlationId';
119
- 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* () {
120
- var _a, _b;
121
- try {
122
- const correlationId = request.params.correlationId;
123
- const definitionId = request.params.definitionId;
124
- if (!correlationId || !definitionId) {
125
- console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, definitionId: ${definitionId}`);
126
- return (0, ssi_express_support_1.sendErrorResponse)(response, 404, 'No authorization request could be found');
127
- }
128
- const requestState = yield context.agent.siopGetAuthRequestState({
129
- correlationId,
130
- definitionId,
131
- errorOnNotFound: false,
132
- });
133
- if (!requestState) {
134
- console.log(`No authorization request could be found for the given url in the state manager. correlationId: ${correlationId}, definitionId: ${definitionId}`);
135
- return (0, ssi_express_support_1.sendErrorResponse)(response, 404, `No authorization request could be found`);
136
- }
137
- const requestObject = yield ((_b = (_a = requestState.request) === null || _a === void 0 ? void 0 : _a.requestObject) === null || _b === void 0 ? void 0 : _b.toJwt());
138
- console.log('JWT Request object:');
139
- console.log(requestObject);
140
- let error;
141
- try {
142
- response.statusCode = 200;
143
- response.setHeader('Content-Type', 'application/jwt');
144
- return response.send(requestObject);
145
- }
146
- catch (e) {
147
- error = typeof e === 'string' ? e : e instanceof Error ? e.message : undefined;
148
- return (0, ssi_express_support_1.sendErrorResponse)(response, 500, 'Could not get authorization request', e);
149
- }
150
- finally {
151
- yield context.agent.siopUpdateAuthRequestState({
152
- correlationId,
153
- definitionId,
154
- state: 'sent',
155
- error,
156
- });
157
- }
158
- }
159
- catch (error) {
160
- return (0, ssi_express_support_1.sendErrorResponse)(response, 500, 'Could not get authorization request', error);
161
- }
162
- }));
163
- }
164
- //# sourceMappingURL=siop-api-functions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"siop-api-functions.js","sourceRoot":"","sources":["../src/siop-api-functions.ts"],"names":[],"mappings":";;;;;;;;;;;AA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AA;YAC7B,IAAI,CAAC;gBACH,QAAQ,CAAC,UAAU,GAAG,GAAG,CAAA;gBACzB,QAAQ,CAAC,SAAS,CAAC,cAAc,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"}
@@ -1,22 +0,0 @@
1
- import { ExpressSupport } from '@sphereon/ssi-express-support';
2
- import { IPresentationExchange } from '@sphereon/ssi-sdk.presentation-exchange';
3
- import { ISIOPv2RP } from '@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth';
4
- import { TAgent } from '@veramo/core';
5
- import { Express, Router } from 'express';
6
- import { IRequiredPlugins, ISIOPv2RPRestAPIOpts } from './types';
7
- export declare class SIOPv2RPApiServer {
8
- private readonly _express;
9
- private readonly _router;
10
- private readonly _agent;
11
- private readonly _opts?;
12
- constructor(args: {
13
- agent: TAgent<IRequiredPlugins>;
14
- expressSupport: ExpressSupport;
15
- opts?: ISIOPv2RPRestAPIOpts;
16
- });
17
- get express(): Express;
18
- get router(): Router;
19
- get agent(): TAgent<IPresentationExchange & ISIOPv2RP>;
20
- get opts(): ISIOPv2RPRestAPIOpts | undefined;
21
- }
22
- //# sourceMappingURL=siopv2-rp-api-server.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,54 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SIOPv2RPApiServer = void 0;
7
- const ssi_sdk_core_1 = require("@sphereon/ssi-sdk.core");
8
- const ssi_express_support_1 = require("@sphereon/ssi-express-support");
9
- const express_1 = __importDefault(require("express"));
10
- const siop_api_functions_1 = require("./siop-api-functions");
11
- const webapp_api_functions_1 = require("./webapp-api-functions");
12
- class SIOPv2RPApiServer {
13
- constructor(args) {
14
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
15
- const { agent, opts } = args;
16
- this._agent = agent;
17
- (0, ssi_express_support_1.copyGlobalAuthToEndpoints)({ opts, keys: ['webappCreateAuthRequest', 'webappAuthStatus', 'webappDeleteAuthRequest'] });
18
- if ((_b = (_a = opts === null || opts === void 0 ? void 0 : opts.endpointOpts) === null || _a === void 0 ? void 0 : _a.globalAuth) === null || _b === void 0 ? void 0 : _b.secureSiopEndpoints) {
19
- (0, ssi_express_support_1.copyGlobalAuthToEndpoints)({ opts, keys: ['siopGetAuthRequest', 'siopVerifyAuthResponse'] });
20
- }
21
- this._opts = opts;
22
- this._express = args.expressSupport.express;
23
- this._router = express_1.default.Router();
24
- const context = (0, ssi_sdk_core_1.agentContext)(agent);
25
- const features = (_c = opts === null || opts === void 0 ? void 0 : opts.enableFeatures) !== null && _c !== void 0 ? _c : ['rp-status', 'siop'];
26
- console.log(`SIOPv2 API enabled, with features: ${JSON.stringify(features)}}`);
27
- // Webapp endpoints
28
- if (features.includes('rp-status')) {
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
- (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
- (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
- }
33
- // SIOPv2 endpoints
34
- if (features.includes('siop')) {
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);
37
- }
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);
39
- }
40
- get express() {
41
- return this._express;
42
- }
43
- get router() {
44
- return this._router;
45
- }
46
- get agent() {
47
- return this._agent;
48
- }
49
- get opts() {
50
- return this._opts;
51
- }
52
- }
53
- exports.SIOPv2RPApiServer = SIOPv2RPApiServer;
54
- //# sourceMappingURL=siopv2-rp-api-server.js.map
@@ -1 +0,0 @@
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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AC,EAAE,CAAC;YAC9B,IAAA,iDAA4B,EAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY,0CAAE,kBAAkB,CAAC,CAAA;YAC3F,IAAA,qDAAgC,EAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY,0CAAE,sBAAsB,CAAC,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 DELETED
@@ -1,29 +0,0 @@
1
- import { GenericAuthArgs, ISingleEndpointOpts } from '@sphereon/ssi-express-support';
2
- import { IPresentationExchange } from '@sphereon/ssi-sdk.presentation-exchange';
3
- import { ISIOPv2RP } from '@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth';
4
- import { IAgentContext, ICredentialVerifier } from '@veramo/core';
5
- import { IPDManager } from '@sphereon/ssi-sdk.pd-manager';
6
- export type SiopFeatures = 'rp-status' | 'siop';
7
- export interface ISIOPv2RPRestAPIOpts {
8
- enableFeatures?: SiopFeatures[];
9
- endpointOpts?: {
10
- basePath?: string;
11
- globalAuth?: GenericAuthArgs & {
12
- secureSiopEndpoints?: boolean;
13
- };
14
- webappCreateAuthRequest?: ICreateAuthRequestWebappEndpointOpts;
15
- webappDeleteAuthRequest?: ISingleEndpointOpts;
16
- webappAuthStatus?: ISingleEndpointOpts;
17
- siopVerifyAuthResponse?: ISingleEndpointOpts;
18
- siopGetAuthRequest?: ISingleEndpointOpts;
19
- };
20
- }
21
- export interface ICreateAuthRequestWebappEndpointOpts extends ISingleEndpointOpts {
22
- siopBaseURI?: string;
23
- webappAuthStatusPath?: string;
24
- webappBaseURI?: string;
25
- nonce?: string;
26
- }
27
- export type IRequiredPlugins = ICredentialVerifier & ISIOPv2RP & IPresentationExchange & IPDManager;
28
- export type IRequiredContext = IAgentContext<IRequiredPlugins>;
29
- //# sourceMappingURL=types.d.ts.map
@@ -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,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"}
package/dist/types.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -1,7 +0,0 @@
1
- import { ISingleEndpointOpts } from '@sphereon/ssi-express-support';
2
- import { Router } from 'express';
3
- import { ICreateAuthRequestWebappEndpointOpts, IRequiredContext } from './types';
4
- export declare function createAuthRequestWebappEndpoint(router: Router, context: IRequiredContext, opts?: ICreateAuthRequestWebappEndpointOpts): void;
5
- export declare function authStatusWebappEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
6
- export declare function removeAuthRequestStateWebappEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
7
- //# sourceMappingURL=webapp-api-functions.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,149 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.createAuthRequestWebappEndpoint = createAuthRequestWebappEndpoint;
16
- exports.authStatusWebappEndpoint = authStatusWebappEndpoint;
17
- exports.removeAuthRequestStateWebappEndpoint = removeAuthRequestStateWebappEndpoint;
18
- const did_auth_siop_1 = require("@sphereon/did-auth-siop");
19
- const ssi_express_support_1 = require("@sphereon/ssi-express-support");
20
- const ssi_sdk_siopv2_oid4vp_common_1 = require("@sphereon/ssi-sdk.siopv2-oid4vp-common");
21
- const ssi_sdk_siopv2_oid4vp_rp_auth_1 = require("@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth");
22
- const short_uuid_1 = __importDefault(require("short-uuid"));
23
- const ssi_sdk_core_1 = require("@sphereon/ssi-sdk.core");
24
- function createAuthRequestWebappEndpoint(router, context, opts) {
25
- var _a;
26
- if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
27
- console.log(`createAuthRequest Webapp endpoint is disabled`);
28
- return;
29
- }
30
- const path = (_a = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _a !== void 0 ? _a : '/webapp/definitions/:definitionId/auth-requests';
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* () {
32
- var _a;
33
- try {
34
- // if (!request.agent) throw Error('No agent configured')
35
- const definitionId = request.params.definitionId;
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}`, {
39
- baseURI: opts === null || opts === void 0 ? void 0 : opts.siopBaseURI,
40
- });
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;
43
- const authRequestURI = yield context.agent.siopCreateAuthRequestURI(Object.assign({ definitionId,
44
- correlationId,
45
- state, nonce: opts === null || opts === void 0 ? void 0 : opts.nonce, requestByReferenceURI, responseURIType: 'response_uri', responseURI }, (responseRedirectURI && { responseRedirectURI })));
46
- const authRequestBody = {
47
- correlationId,
48
- 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
- };
52
- console.log(`Auth Request URI data to send back: ${JSON.stringify(authRequestBody)}`);
53
- return response.send(authRequestBody);
54
- }
55
- catch (error) {
56
- return (0, ssi_express_support_1.sendErrorResponse)(response, 500, 'Could not create an authorization request URI', error);
57
- }
58
- }));
59
- }
60
- function authStatusWebappEndpoint(router, context, opts) {
61
- var _a;
62
- if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
63
- console.log(`authStatus Webapp endpoint is disabled`);
64
- return;
65
- }
66
- const path = (_a = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _a !== void 0 ? _a : '/webapp/auth-status';
67
- 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* () {
68
- var _a;
69
- try {
70
- console.log('Received auth-status request...');
71
- const correlationId = request.body.correlationId;
72
- const definitionId = request.body.definitionId;
73
- const requestState = correlationId && definitionId
74
- ? yield context.agent.siopGetAuthRequestState({
75
- correlationId,
76
- definitionId,
77
- errorOnNotFound: false,
78
- })
79
- : undefined;
80
- if (!requestState || !definitionId || !correlationId) {
81
- console.log(`No authentication request mapping could be found for the given URL. correlation: ${correlationId}, definitionId: ${definitionId}`);
82
- response.statusCode = 404;
83
- const statusBody = {
84
- status: requestState ? requestState.status : 'error',
85
- error: 'No authentication request mapping could be found for the given URL.',
86
- correlationId,
87
- definitionId,
88
- lastUpdated: requestState ? requestState.lastUpdated : Date.now(),
89
- };
90
- return response.send(statusBody);
91
- }
92
- let includeVerifiedData = ssi_sdk_siopv2_oid4vp_rp_auth_1.VerifiedDataMode.NONE;
93
- if ('includeVerifiedData' in request.body) {
94
- includeVerifiedData = request.body.includeVerifiedData;
95
- }
96
- let responseState;
97
- if (requestState.status === 'sent') {
98
- responseState = (yield context.agent.siopGetAuthResponseState({
99
- correlationId,
100
- definitionId,
101
- includeVerifiedData: includeVerifiedData,
102
- errorOnNotFound: false,
103
- }));
104
- }
105
- const overallState = responseState !== null && responseState !== void 0 ? responseState : requestState;
106
- const statusBody = Object.assign(Object.assign(Object.assign({ status: overallState.status }, (overallState.error ? { error: (_a = overallState.error) === null || _a === void 0 ? void 0 : _a.message } : {})), { correlationId,
107
- definitionId, lastUpdated: overallState.lastUpdated }), (responseState && responseState.status === did_auth_siop_1.AuthorizationResponseStateStatus.VERIFIED
108
- ? {
109
- payload: yield responseState.response.mergedPayloads({ hasher: ssi_sdk_core_1.shaHasher }),
110
- verifiedData: responseState.verifiedData,
111
- }
112
- : {}));
113
- console.log(`Will send auth status: ${JSON.stringify(statusBody)}`);
114
- if (overallState.status === 'error') {
115
- response.statusCode = 500;
116
- return response.send(statusBody);
117
- }
118
- response.statusCode = 200;
119
- return response.send(statusBody);
120
- }
121
- catch (error) {
122
- return (0, ssi_express_support_1.sendErrorResponse)(response, 500, error.message, error);
123
- }
124
- }));
125
- }
126
- function removeAuthRequestStateWebappEndpoint(router, context, opts) {
127
- var _a;
128
- if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
129
- console.log(`removeAuthStatus Webapp endpoint is disabled`);
130
- return;
131
- }
132
- const path = (_a = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _a !== void 0 ? _a : '/webapp/definitions/:definitionId/auth-requests/:correlationId';
133
- router.delete(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* () {
134
- try {
135
- const correlationId = request.params.correlationId;
136
- const definitionId = request.params.definitionId;
137
- if (!correlationId || !definitionId) {
138
- console.log(`No authorization request could be found for the given url. correlationId: ${correlationId}, definitionId: ${definitionId}`);
139
- return (0, ssi_express_support_1.sendErrorResponse)(response, 404, 'No authorization request could be found');
140
- }
141
- response.statusCode = 200;
142
- return response.send(context.agent.siopDeleteAuthState({ definitionId, correlationId }));
143
- }
144
- catch (error) {
145
- return (0, ssi_express_support_1.sendErrorResponse)(response, 500, error.message, error);
146
- }
147
- }));
148
- }
149
- //# sourceMappingURL=webapp-api-functions.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