@sphereon/ssi-sdk.siopv2-oid4vp-rp-rest-api 0.32.1-feature.MWALL.715.state.persist.227 → 0.32.1-feature.MWALL.715.state.persist.229
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.
|
@@ -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,
|
|
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,EAAC,OAAO,EAAqB,MAAM,EAAC,MAAM,SAAS,CAAA;AAEnE,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;IAkClH,OAAO,CAAC,cAAc;IA4BtB,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
15
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
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'] });
|
|
@@ -36,7 +38,30 @@ class SIOPv2RPApiServer {
|
|
|
36
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);
|
|
37
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);
|
|
38
40
|
}
|
|
39
|
-
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.setupSwaggerUi();
|
|
44
|
+
}
|
|
45
|
+
setupSwaggerUi() {
|
|
46
|
+
fetch(this.OID4VP_SWAGGER_URL)
|
|
47
|
+
.then((res) => res.json())
|
|
48
|
+
.then((swagger) => {
|
|
49
|
+
const apiDocs = `${this._basePath}/api-docs`;
|
|
50
|
+
console.log(`[OID4P] API docs available at ${apiDocs}`);
|
|
51
|
+
this._router.use('/api-docs', (req, res, next) => {
|
|
52
|
+
const regex = `${apiDocs.replace(/\//, '\/')}`.replace('/oid4vp', '').replace(/\/api-docs.*/, '');
|
|
53
|
+
swagger.servers = [{ url: `${req.protocol}://${req.get('host')}${regex}`, description: 'This server' }];
|
|
54
|
+
// @ts-ignore
|
|
55
|
+
req.swaggerDoc = swagger;
|
|
56
|
+
next();
|
|
57
|
+
}, swagger_ui_express_1.default.serveFiles(swagger, options), swagger_ui_express_1.default.setup());
|
|
58
|
+
})
|
|
59
|
+
.catch((err) => {
|
|
60
|
+
console.log(`[OID4VP] Unable to fetch swagger document: ${err}. Will not host api-docs on this instance`);
|
|
61
|
+
});
|
|
62
|
+
const options = {
|
|
63
|
+
// customCss: '.swagger-ui .topbar { display: none }',
|
|
64
|
+
};
|
|
40
65
|
}
|
|
41
66
|
get express() {
|
|
42
67
|
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,sDAAmE;AACnE,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,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,CAAC,OAAO,CAAA;QAC3C,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,EAAE,CAAA;YACR,CAAC,EACD,4BAAS,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,EACtC,4BAAS,CAAC,KAAK,EAAE,CACpB,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;QACN,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"}
|
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-feature.MWALL.715.state.persist.
|
|
3
|
+
"version": "0.32.1-feature.MWALL.715.state.persist.229+a6c9fb4a",
|
|
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-feature.MWALL.715.
|
|
15
|
-
"@sphereon/ssi-express-support": "0.32.1-feature.MWALL.715.state.persist.
|
|
16
|
-
"@sphereon/ssi-sdk.core": "0.32.1-feature.MWALL.715.state.persist.
|
|
17
|
-
"@sphereon/ssi-sdk.credential-validation": "0.32.1-feature.MWALL.715.state.persist.
|
|
18
|
-
"@sphereon/ssi-sdk.kv-store-temp": "0.32.1-feature.MWALL.715.state.persist.
|
|
19
|
-
"@sphereon/ssi-sdk.pd-manager": "0.32.1-feature.MWALL.715.state.persist.
|
|
20
|
-
"@sphereon/ssi-sdk.presentation-exchange": "0.32.1-feature.MWALL.715.state.persist.
|
|
21
|
-
"@sphereon/ssi-sdk.siopv2-oid4vp-common": "0.32.1-feature.MWALL.715.state.persist.
|
|
22
|
-
"@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth": "0.32.1-feature.MWALL.715.state.persist.
|
|
23
|
-
"@sphereon/ssi-types": "0.32.1-feature.MWALL.715.state.persist.
|
|
14
|
+
"@sphereon/did-auth-siop": "0.16.1-feature.MWALL.715.391",
|
|
15
|
+
"@sphereon/ssi-express-support": "0.32.1-feature.MWALL.715.state.persist.229+a6c9fb4a",
|
|
16
|
+
"@sphereon/ssi-sdk.core": "0.32.1-feature.MWALL.715.state.persist.229+a6c9fb4a",
|
|
17
|
+
"@sphereon/ssi-sdk.credential-validation": "0.32.1-feature.MWALL.715.state.persist.229+a6c9fb4a",
|
|
18
|
+
"@sphereon/ssi-sdk.kv-store-temp": "0.32.1-feature.MWALL.715.state.persist.229+a6c9fb4a",
|
|
19
|
+
"@sphereon/ssi-sdk.pd-manager": "0.32.1-feature.MWALL.715.state.persist.229+a6c9fb4a",
|
|
20
|
+
"@sphereon/ssi-sdk.presentation-exchange": "0.32.1-feature.MWALL.715.state.persist.229+a6c9fb4a",
|
|
21
|
+
"@sphereon/ssi-sdk.siopv2-oid4vp-common": "0.32.1-feature.MWALL.715.state.persist.229+a6c9fb4a",
|
|
22
|
+
"@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth": "0.32.1-feature.MWALL.715.state.persist.229+a6c9fb4a",
|
|
23
|
+
"@sphereon/ssi-types": "0.32.1-feature.MWALL.715.state.persist.229+a6c9fb4a",
|
|
24
24
|
"@veramo/core": "4.2.0",
|
|
25
25
|
"@veramo/credential-w3c": "4.2.0",
|
|
26
26
|
"body-parser": "^1.20.2",
|
|
@@ -30,16 +30,18 @@
|
|
|
30
30
|
"dotenv-flow": "^3.3.0",
|
|
31
31
|
"express": "^4.19.2",
|
|
32
32
|
"short-uuid": "^4.2.2",
|
|
33
|
+
"swagger-ui-express": "^5.0.1",
|
|
33
34
|
"uuid": "^9.0.1"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"@decentralized-identity/ion-sdk": "^0.6.0",
|
|
38
|
+
"@sphereon/did-auth-siop-adapter": "0.16.1-feature.MWALL.715.391",
|
|
37
39
|
"@sphereon/did-uni-client": "^0.6.3",
|
|
38
40
|
"@sphereon/pex": "5.0.0-unstable.28",
|
|
39
41
|
"@sphereon/pex-models": "^2.3.2",
|
|
40
42
|
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.27.1-next.14",
|
|
41
|
-
"@sphereon/ssi-sdk.data-store": "0.32.1-feature.MWALL.715.state.persist.
|
|
42
|
-
"@sphereon/ssi-sdk.vc-handler-ld-local": "0.32.1-feature.MWALL.715.state.persist.
|
|
43
|
+
"@sphereon/ssi-sdk.data-store": "0.32.1-feature.MWALL.715.state.persist.229+a6c9fb4a",
|
|
44
|
+
"@sphereon/ssi-sdk.vc-handler-ld-local": "0.32.1-feature.MWALL.715.state.persist.229+a6c9fb4a",
|
|
43
45
|
"@types/body-parser": "^1.19.5",
|
|
44
46
|
"@types/cookie-parser": "^1.4.7",
|
|
45
47
|
"@types/cors": "^2.8.17",
|
|
@@ -51,6 +53,7 @@
|
|
|
51
53
|
"@types/node": "^20.17.1",
|
|
52
54
|
"@types/passport": "^1.0.16",
|
|
53
55
|
"@types/passport-http-bearer": "^1.0.41",
|
|
56
|
+
"@types/swagger-ui-express": "^4.1.7",
|
|
54
57
|
"@types/uuid": "^9.0.8",
|
|
55
58
|
"@veramo/data-store": "4.2.0",
|
|
56
59
|
"@veramo/did-manager": "4.2.0",
|
|
@@ -62,6 +65,7 @@
|
|
|
62
65
|
"@veramo/key-manager": "4.2.0",
|
|
63
66
|
"@veramo/kms-local": "4.2.0",
|
|
64
67
|
"@veramo/utils": "4.2.0",
|
|
68
|
+
"debug": "^4.4.0",
|
|
65
69
|
"did-resolver": "^4.1.0",
|
|
66
70
|
"morgan": "^1.10.0",
|
|
67
71
|
"nock": "^13.5.4",
|
|
@@ -98,5 +102,5 @@
|
|
|
98
102
|
"Authenticator"
|
|
99
103
|
],
|
|
100
104
|
"nx": {},
|
|
101
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "a6c9fb4ac98f74ee4fbc41ca3d2363faec383c44"
|
|
102
106
|
}
|
|
@@ -3,7 +3,7 @@ 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, {
|
|
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
9
|
import {
|
|
@@ -12,13 +12,16 @@ import {
|
|
|
12
12
|
getDefinitionsEndpoint,
|
|
13
13
|
removeAuthRequestStateWebappEndpoint,
|
|
14
14
|
} from './webapp-api-functions'
|
|
15
|
+
import swaggerUi from 'swagger-ui-express'
|
|
15
16
|
|
|
16
17
|
export class SIOPv2RPApiServer {
|
|
17
18
|
private readonly _express: Express
|
|
18
19
|
private readonly _router: Router
|
|
19
20
|
private readonly _agent: TAgent<IPresentationExchange & ISIOPv2RP>
|
|
20
21
|
private readonly _opts?: ISIOPv2RPRestAPIOpts
|
|
22
|
+
private readonly _basePath: string
|
|
21
23
|
|
|
24
|
+
private readonly OID4VP_SWAGGER_URL = 'https://api.swaggerhub.com/apis/SphereonInt/OID4VP/0.1.0'
|
|
22
25
|
constructor(args: { agent: TAgent<IRequiredPlugins>; expressSupport: ExpressSupport; opts?: ISIOPv2RPRestAPIOpts }) {
|
|
23
26
|
const { agent, opts } = args
|
|
24
27
|
this._agent = agent
|
|
@@ -48,9 +51,39 @@ export class SIOPv2RPApiServer {
|
|
|
48
51
|
getAuthRequestSIOPv2Endpoint(this._router, context, opts?.endpointOpts?.siopGetAuthRequest)
|
|
49
52
|
verifyAuthResponseSIOPv2Endpoint(this._router, context, opts?.endpointOpts?.siopVerifyAuthResponse)
|
|
50
53
|
}
|
|
51
|
-
this.
|
|
54
|
+
this._basePath = opts?.endpointOpts?.basePath ?? ''
|
|
55
|
+
this._express.use(this._basePath, this.router)
|
|
56
|
+
this.setupSwaggerUi()
|
|
52
57
|
}
|
|
53
58
|
|
|
59
|
+
private setupSwaggerUi() {
|
|
60
|
+
|
|
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
|
+
}
|
|
54
87
|
get express(): Express {
|
|
55
88
|
return this._express
|
|
56
89
|
}
|