@sphereon/ssi-sdk.pd-manager-rest-api 0.33.1-feature.vcdm2.4 → 0.33.1-feature.vcdm2.tsup.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,244 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/index.ts
32
+ var index_exports = {};
33
+ __export(index_exports, {
34
+ PdManagerApiServer: () => PdManagerApiServer,
35
+ pdDeleteEndpoint: () => pdDeleteEndpoint,
36
+ pdHasEndpoint: () => pdHasEndpoint,
37
+ pdPersistEndpoint: () => pdPersistEndpoint,
38
+ pdReadEndpoint: () => pdReadEndpoint,
39
+ pdsDeleteEndpoint: () => pdsDeleteEndpoint,
40
+ pdsReadEndpoint: () => pdsReadEndpoint
41
+ });
42
+ module.exports = __toCommonJS(index_exports);
43
+
44
+ // src/pd-manager-api-server.ts
45
+ var import_ssi_sdk = require("@sphereon/ssi-sdk.core");
46
+ var import_express = __toESM(require("express"), 1);
47
+
48
+ // src/api-functions.ts
49
+ var import_ssi_express_support = require("@sphereon/ssi-express-support");
50
+ var operation = "/presentation-definitions";
51
+ function pdReadEndpoint(router, context, opts) {
52
+ if (opts?.enabled === false) {
53
+ console.log(`"pdReadEndpoint" Endpoint is disabled`);
54
+ return;
55
+ }
56
+ const path = opts?.path ?? operation;
57
+ router.get(`${path}/:itemId`, (0, import_ssi_express_support.checkAuth)(opts?.endpoint), async (request, response) => {
58
+ try {
59
+ const itemId = request.params.itemId;
60
+ const pd = await context.agent.pdmGetDefinition({
61
+ itemId
62
+ });
63
+ response.statusCode = 200;
64
+ return response.json(pd);
65
+ } catch (error) {
66
+ return (0, import_ssi_express_support.sendErrorResponse)(response, 500, error.message, error);
67
+ }
68
+ });
69
+ }
70
+ __name(pdReadEndpoint, "pdReadEndpoint");
71
+ function pdHasEndpoint(router, context, opts) {
72
+ if (opts?.enabled === false) {
73
+ console.log(`"pdReadEndpoint" Endpoint is disabled`);
74
+ return;
75
+ }
76
+ const path = opts?.path ?? operation;
77
+ router.get(`${path}/:itemId`, (0, import_ssi_express_support.checkAuth)(opts?.endpoint), async (request, response) => {
78
+ try {
79
+ const itemId = request.params.itemId;
80
+ const result = await context.agent.pdmHasDefinition({
81
+ itemId
82
+ });
83
+ response.statusCode = 200;
84
+ return response.json(result);
85
+ } catch (error) {
86
+ return (0, import_ssi_express_support.sendErrorResponse)(response, 500, error.message, error);
87
+ }
88
+ });
89
+ }
90
+ __name(pdHasEndpoint, "pdHasEndpoint");
91
+ function pdsReadEndpoint(router, context, opts) {
92
+ if (opts?.enabled === false) {
93
+ console.log(`"pdsReadEndpoint" Endpoint is disabled`);
94
+ return;
95
+ }
96
+ const path = opts?.path ?? operation;
97
+ router.get(`${path}`, (0, import_ssi_express_support.checkAuth)(opts?.endpoint), async (request, response) => {
98
+ try {
99
+ const pd = await context.agent.pdmGetDefinitions();
100
+ response.statusCode = 200;
101
+ return response.json(pd);
102
+ } catch (error) {
103
+ return (0, import_ssi_express_support.sendErrorResponse)(response, 500, error.message, error);
104
+ }
105
+ });
106
+ }
107
+ __name(pdsReadEndpoint, "pdsReadEndpoint");
108
+ function pdPersistEndpoint(router, context, opts) {
109
+ if (opts?.enabled === false) {
110
+ console.log(`"pdPersistEndpoint" Endpoint is disabled`);
111
+ return;
112
+ }
113
+ const path = opts?.path ?? operation;
114
+ router.post(path, async (request, response) => {
115
+ try {
116
+ const addPd = request.body;
117
+ const pd = await context.agent.pdmPersistDefinitionItem(addPd);
118
+ response.statusCode = 200;
119
+ return response.json(pd);
120
+ } catch (error) {
121
+ return (0, import_ssi_express_support.sendErrorResponse)(response, 500, error.message, error);
122
+ }
123
+ });
124
+ }
125
+ __name(pdPersistEndpoint, "pdPersistEndpoint");
126
+ function pdDeleteEndpoint(router, context, opts) {
127
+ if (opts?.enabled === false) {
128
+ console.log(`"pdDeleteEndpoint" Endpoint is disabled`);
129
+ return;
130
+ }
131
+ const path = opts?.path ?? operation;
132
+ router.delete(`${path}/:itemId`, async (request, response) => {
133
+ try {
134
+ const itemId = request.params.itemId;
135
+ const result = await context.agent.pdmDeleteDefinition({
136
+ itemId
137
+ });
138
+ response.statusCode = 200;
139
+ return response.json(result);
140
+ } catch (error) {
141
+ return (0, import_ssi_express_support.sendErrorResponse)(response, 500, error.message, error);
142
+ }
143
+ });
144
+ }
145
+ __name(pdDeleteEndpoint, "pdDeleteEndpoint");
146
+ function pdsDeleteEndpoint(router, context, opts) {
147
+ if (opts?.enabled === false) {
148
+ console.log(`"pdsDeleteEndpoint" Endpoint is disabled`);
149
+ return;
150
+ }
151
+ const path = opts?.path ?? operation;
152
+ router.delete(`${path}/filter`, async (request, response) => {
153
+ try {
154
+ response.statusCode = 500;
155
+ response.statusMessage = "Not yet implemented";
156
+ return (0, import_ssi_express_support.sendErrorResponse)(response, 500, "Not yet implemented");
157
+ } catch (error) {
158
+ return (0, import_ssi_express_support.sendErrorResponse)(response, 500, error.message, error);
159
+ }
160
+ });
161
+ }
162
+ __name(pdsDeleteEndpoint, "pdsDeleteEndpoint");
163
+
164
+ // src/pd-manager-api-server.ts
165
+ var import_ssi_express_support2 = require("@sphereon/ssi-express-support");
166
+ var PdManagerApiServer = class {
167
+ static {
168
+ __name(this, "PdManagerApiServer");
169
+ }
170
+ _express;
171
+ _agent;
172
+ _opts;
173
+ _router;
174
+ constructor(args) {
175
+ const { agent, opts } = args;
176
+ this._agent = agent;
177
+ (0, import_ssi_express_support2.copyGlobalAuthToEndpoints)({
178
+ opts,
179
+ keys: [
180
+ "pdRead",
181
+ "pdWrite",
182
+ "pdUpdate",
183
+ "pdDelete"
184
+ ]
185
+ });
186
+ if (opts?.endpointOpts?.globalAuth?.securePDManagerEndpoints) {
187
+ (0, import_ssi_express_support2.copyGlobalAuthToEndpoints)({
188
+ opts,
189
+ keys: [
190
+ "pdRead",
191
+ "pdWrite",
192
+ "pdUpdate",
193
+ "pdDelete"
194
+ ]
195
+ });
196
+ }
197
+ this._opts = opts;
198
+ this._express = args.expressSupport.express;
199
+ this._router = import_express.default.Router();
200
+ const context = (0, import_ssi_sdk.agentContext)(agent);
201
+ const features = opts?.enableFeatures ?? [
202
+ "pd_read",
203
+ "pd_write",
204
+ "pd_delete"
205
+ ];
206
+ console.log(`Presentation Definition API enabled, with features: ${JSON.stringify(features)}}`);
207
+ if (features.includes("pd_read")) {
208
+ pdReadEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead);
209
+ pdHasEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead);
210
+ pdsReadEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead);
211
+ }
212
+ if (features.includes("pd_write")) {
213
+ pdPersistEndpoint(this.router, context, this._opts?.endpointOpts?.pdWrite);
214
+ }
215
+ if (features.includes("pd_delete")) {
216
+ pdDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.pdDelete);
217
+ pdsDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.pdDelete);
218
+ }
219
+ this._express.use(opts?.endpointOpts?.basePath ?? "", this.router);
220
+ }
221
+ get express() {
222
+ return this._express;
223
+ }
224
+ get router() {
225
+ return this._router;
226
+ }
227
+ get agent() {
228
+ return this._agent;
229
+ }
230
+ get opts() {
231
+ return this._opts;
232
+ }
233
+ };
234
+ // Annotate the CommonJS export names for ESM import in node:
235
+ 0 && (module.exports = {
236
+ PdManagerApiServer,
237
+ pdDeleteEndpoint,
238
+ pdHasEndpoint,
239
+ pdPersistEndpoint,
240
+ pdReadEndpoint,
241
+ pdsDeleteEndpoint,
242
+ pdsReadEndpoint
243
+ });
244
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/pd-manager-api-server.ts","../src/api-functions.ts"],"sourcesContent":["export * from './types'\nexport * from './pd-manager-api-server'\nexport * from './api-functions'\n","import { agentContext } from '@sphereon/ssi-sdk.core'\nimport { TAgent } from '@veramo/core'\n\nimport express, { Express, Router } from 'express'\nimport { IPDManagerAPIEndpointOpts, IRequiredPlugins } from './types'\nimport { pdDeleteEndpoint, pdHasEndpoint, pdPersistEndpoint, pdReadEndpoint, pdsDeleteEndpoint, pdsReadEndpoint } from './api-functions'\nimport { copyGlobalAuthToEndpoints, ExpressSupport } from '@sphereon/ssi-express-support'\n\ntype PdManagerApiServerArgs = {\n agent: TAgent<IRequiredPlugins>\n expressSupport: ExpressSupport\n opts?: IPDManagerAPIEndpointOpts\n}\n\nexport class PdManagerApiServer {\n private readonly _express: Express\n private readonly _agent: TAgent<IRequiredPlugins>\n private readonly _opts?: IPDManagerAPIEndpointOpts\n private readonly _router: Router\n\n constructor(args: PdManagerApiServerArgs) {\n const { agent, opts } = args\n this._agent = agent\n copyGlobalAuthToEndpoints({ opts, keys: ['pdRead', 'pdWrite', 'pdUpdate', 'pdDelete'] })\n if (opts?.endpointOpts?.globalAuth?.securePDManagerEndpoints) {\n copyGlobalAuthToEndpoints({ opts, keys: ['pdRead', 'pdWrite', 'pdUpdate', 'pdDelete'] })\n }\n this._opts = opts\n this._express = args.expressSupport.express\n this._router = express.Router()\n const context = agentContext(agent)\n const features = opts?.enableFeatures ?? ['pd_read', 'pd_write', 'pd_delete']\n console.log(`Presentation Definition API enabled, with features: ${JSON.stringify(features)}}`)\n\n // endpoints\n if (features.includes('pd_read')) {\n pdReadEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead)\n pdHasEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead)\n pdsReadEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead)\n }\n if (features.includes('pd_write')) {\n pdPersistEndpoint(this.router, context, this._opts?.endpointOpts?.pdWrite)\n }\n if (features.includes('pd_delete')) {\n pdDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.pdDelete)\n pdsDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.pdDelete)\n }\n this._express.use(opts?.endpointOpts?.basePath ?? '', this.router)\n }\n\n get express(): Express {\n return this._express\n }\n\n get router(): Router {\n return this._router\n }\n\n get agent(): TAgent<IRequiredPlugins> {\n return this._agent\n }\n\n get opts(): IPDManagerAPIEndpointOpts | undefined {\n return this._opts\n }\n}\n","import { checkAuth, ISingleEndpointOpts, sendErrorResponse } from '@sphereon/ssi-express-support'\nimport { Request, Response, Router } from 'express'\nimport { IRequiredContext } from './types'\nimport { PersistDefinitionArgs } from '@sphereon/ssi-sdk.pd-manager'\nimport { DeleteDefinitionArgs } from '@sphereon/ssi-sdk.data-store'\n\nconst operation = '/presentation-definitions'\n\nexport function pdReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.get(`${path}/:itemId`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const itemId = request.params.itemId\n const pd = await context.agent.pdmGetDefinition({ itemId: itemId })\n response.statusCode = 200\n return response.json(pd)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function pdHasEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.get(`${path}/:itemId`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const itemId = request.params.itemId\n const result = await context.agent.pdmHasDefinition({ itemId: itemId })\n response.statusCode = 200\n return response.json(result)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function pdsReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdsReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.get(`${path}`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n // TODO Get all of them for now\n const pd = await context.agent.pdmGetDefinitions()\n response.statusCode = 200\n return response.json(pd)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function pdPersistEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdPersistEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.post(path, async (request: Request, response: Response) => {\n try {\n const addPd = request.body\n const pd = await context.agent.pdmPersistDefinitionItem(addPd as PersistDefinitionArgs)\n response.statusCode = 200 // TODO find out if pdmPersistDefinitionItem added or updated\n return response.json(pd)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n\nexport function pdDeleteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdDeleteEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.delete(`${path}/:itemId`, async (request, response) => {\n try {\n const itemId = request.params.itemId\n const result = await context.agent.pdmDeleteDefinition({ itemId: itemId } as DeleteDefinitionArgs)\n response.statusCode = 200\n return response.json(result)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n\nexport function pdsDeleteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdsDeleteEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.delete(`${path}/filter`, async (request, response) => {\n try {\n // TODO we are not going to delete all PDs without filter like we did with pdsGet... Finish when filter is implemented\n response.statusCode = 500\n response.statusMessage = 'Not yet implemented'\n return sendErrorResponse(response, 500, 'Not yet implemented')\n } catch (error) {\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;ACAA,qBAA6B;AAG7B,qBAAyC;;;ACHzC,iCAAkE;AAMlE,IAAMA,YAAY;AAEX,SAASC,eAAeC,QAAgBC,SAA2BC,MAA0B;AAClG,MAAIA,MAAMC,YAAY,OAAO;AAC3BC,YAAQC,IAAI,uCAAuC;AACnD;EACF;AACA,QAAMC,OAAOJ,MAAMI,QAAQR;AAC3BE,SAAOO,IAAI,GAAGD,IAAAA,gBAAgBE,sCAAUN,MAAMO,QAAAA,GAAW,OAAOC,SAAkBC,aAAAA;AAChF,QAAI;AACF,YAAMC,SAASF,QAAQG,OAAOD;AAC9B,YAAME,KAAK,MAAMb,QAAQc,MAAMC,iBAAiB;QAAEJ;MAAe,CAAA;AACjED,eAASM,aAAa;AACtB,aAAON,SAASO,KAAKJ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mC,IAAI5B,MAAMG,cAAc0B,YAAY,IAAI,KAAKV,MAAM;EACnE;EAEA,IAAIZ,UAAmB;AACrB,WAAO,KAAKd;EACd;EAEA,IAAI0B,SAAiB;AACnB,WAAO,KAAKvB;EACd;EAEA,IAAIG,QAAkC;AACpC,WAAO,KAAKL;EACd;EAEA,IAAIM,OAA8C;AAChD,WAAO,KAAKL;EACd;AACF;","names":["operation","pdReadEndpoint","router","context","opts","enabled","console","log","path","get","checkAuth","endpoint","request","response","itemId","params","pd","agent","pdmGetDefinition","statusCode","json","error","sendErrorResponse","message","pdHasEndpoint","result","pdmHasDefinition","pdsReadEndpoint","pdmGetDefinitions","pdPersistEndpoint","post","addPd","body","pdmPersistDefinitionItem","pdDeleteEndpoint","delete","pdmDeleteDefinition","pdsDeleteEndpoint","statusMessage","import_ssi_express_support","PdManagerApiServer","_express","_agent","_opts","_router","constructor","args","agent","opts","copyGlobalAuthToEndpoints","keys","endpointOpts","globalAuth","securePDManagerEndpoints","expressSupport","express","Router","context","agentContext","features","enableFeatures","console","log","JSON","stringify","includes","pdReadEndpoint","router","pdRead","pdHasEndpoint","pdsReadEndpoint","pdPersistEndpoint","pdWrite","pdDeleteEndpoint","pdDelete","pdsDeleteEndpoint","use","basePath"]}
@@ -0,0 +1,46 @@
1
+ import { GenericAuthArgs, ISingleEndpointOpts, ExpressSupport } from '@sphereon/ssi-express-support';
2
+ import { IPDManager } from '@sphereon/ssi-sdk.pd-manager';
3
+ import { IAgentContext, TAgent } from '@veramo/core';
4
+ import { Express, Router } from 'express';
5
+
6
+ type PDManagerMRestApiFeatures = 'pd_read' | 'pd_write' | 'pd_delete';
7
+ interface IPDManagerAPIEndpointOpts {
8
+ endpointOpts?: {
9
+ basePath?: string;
10
+ globalAuth?: GenericAuthArgs & {
11
+ securePDManagerEndpoints?: boolean;
12
+ };
13
+ pdRead?: ISingleEndpointOpts;
14
+ pdWrite?: ISingleEndpointOpts;
15
+ pdDelete?: ISingleEndpointOpts;
16
+ };
17
+ enableFeatures?: PDManagerMRestApiFeatures[];
18
+ }
19
+ type IRequiredPlugins = IPDManager;
20
+ type IRequiredContext = IAgentContext<IRequiredPlugins>;
21
+
22
+ type PdManagerApiServerArgs = {
23
+ agent: TAgent<IRequiredPlugins>;
24
+ expressSupport: ExpressSupport;
25
+ opts?: IPDManagerAPIEndpointOpts;
26
+ };
27
+ declare class PdManagerApiServer {
28
+ private readonly _express;
29
+ private readonly _agent;
30
+ private readonly _opts?;
31
+ private readonly _router;
32
+ constructor(args: PdManagerApiServerArgs);
33
+ get express(): Express;
34
+ get router(): Router;
35
+ get agent(): TAgent<IRequiredPlugins>;
36
+ get opts(): IPDManagerAPIEndpointOpts | undefined;
37
+ }
38
+
39
+ declare function pdReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
40
+ declare function pdHasEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
41
+ declare function pdsReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
42
+ declare function pdPersistEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
43
+ declare function pdDeleteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
44
+ declare function pdsDeleteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
45
+
46
+ export { type IPDManagerAPIEndpointOpts, type IRequiredContext, type IRequiredPlugins, type PDManagerMRestApiFeatures, PdManagerApiServer, pdDeleteEndpoint, pdHasEndpoint, pdPersistEndpoint, pdReadEndpoint, pdsDeleteEndpoint, pdsReadEndpoint };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,46 @@
1
- export * from './types';
2
- export * from './pd-manager-api-server';
3
- export * from './api-functions';
4
- //# sourceMappingURL=index.d.ts.map
1
+ import { GenericAuthArgs, ISingleEndpointOpts, ExpressSupport } from '@sphereon/ssi-express-support';
2
+ import { IPDManager } from '@sphereon/ssi-sdk.pd-manager';
3
+ import { IAgentContext, TAgent } from '@veramo/core';
4
+ import { Express, Router } from 'express';
5
+
6
+ type PDManagerMRestApiFeatures = 'pd_read' | 'pd_write' | 'pd_delete';
7
+ interface IPDManagerAPIEndpointOpts {
8
+ endpointOpts?: {
9
+ basePath?: string;
10
+ globalAuth?: GenericAuthArgs & {
11
+ securePDManagerEndpoints?: boolean;
12
+ };
13
+ pdRead?: ISingleEndpointOpts;
14
+ pdWrite?: ISingleEndpointOpts;
15
+ pdDelete?: ISingleEndpointOpts;
16
+ };
17
+ enableFeatures?: PDManagerMRestApiFeatures[];
18
+ }
19
+ type IRequiredPlugins = IPDManager;
20
+ type IRequiredContext = IAgentContext<IRequiredPlugins>;
21
+
22
+ type PdManagerApiServerArgs = {
23
+ agent: TAgent<IRequiredPlugins>;
24
+ expressSupport: ExpressSupport;
25
+ opts?: IPDManagerAPIEndpointOpts;
26
+ };
27
+ declare class PdManagerApiServer {
28
+ private readonly _express;
29
+ private readonly _agent;
30
+ private readonly _opts?;
31
+ private readonly _router;
32
+ constructor(args: PdManagerApiServerArgs);
33
+ get express(): Express;
34
+ get router(): Router;
35
+ get agent(): TAgent<IRequiredPlugins>;
36
+ get opts(): IPDManagerAPIEndpointOpts | undefined;
37
+ }
38
+
39
+ declare function pdReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
40
+ declare function pdHasEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
41
+ declare function pdsReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
42
+ declare function pdPersistEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
43
+ declare function pdDeleteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
44
+ declare function pdsDeleteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
45
+
46
+ export { type IPDManagerAPIEndpointOpts, type IRequiredContext, type IRequiredPlugins, type PDManagerMRestApiFeatures, PdManagerApiServer, pdDeleteEndpoint, pdHasEndpoint, pdPersistEndpoint, pdReadEndpoint, pdsDeleteEndpoint, pdsReadEndpoint };
package/dist/index.js CHANGED
@@ -1,4 +1,203 @@
1
- export * from './types';
2
- export * from './pd-manager-api-server';
3
- export * from './api-functions';
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/pd-manager-api-server.ts
5
+ import { agentContext } from "@sphereon/ssi-sdk.core";
6
+ import express from "express";
7
+
8
+ // src/api-functions.ts
9
+ import { checkAuth, sendErrorResponse } from "@sphereon/ssi-express-support";
10
+ var operation = "/presentation-definitions";
11
+ function pdReadEndpoint(router, context, opts) {
12
+ if (opts?.enabled === false) {
13
+ console.log(`"pdReadEndpoint" Endpoint is disabled`);
14
+ return;
15
+ }
16
+ const path = opts?.path ?? operation;
17
+ router.get(`${path}/:itemId`, checkAuth(opts?.endpoint), async (request, response) => {
18
+ try {
19
+ const itemId = request.params.itemId;
20
+ const pd = await context.agent.pdmGetDefinition({
21
+ itemId
22
+ });
23
+ response.statusCode = 200;
24
+ return response.json(pd);
25
+ } catch (error) {
26
+ return sendErrorResponse(response, 500, error.message, error);
27
+ }
28
+ });
29
+ }
30
+ __name(pdReadEndpoint, "pdReadEndpoint");
31
+ function pdHasEndpoint(router, context, opts) {
32
+ if (opts?.enabled === false) {
33
+ console.log(`"pdReadEndpoint" Endpoint is disabled`);
34
+ return;
35
+ }
36
+ const path = opts?.path ?? operation;
37
+ router.get(`${path}/:itemId`, checkAuth(opts?.endpoint), async (request, response) => {
38
+ try {
39
+ const itemId = request.params.itemId;
40
+ const result = await context.agent.pdmHasDefinition({
41
+ itemId
42
+ });
43
+ response.statusCode = 200;
44
+ return response.json(result);
45
+ } catch (error) {
46
+ return sendErrorResponse(response, 500, error.message, error);
47
+ }
48
+ });
49
+ }
50
+ __name(pdHasEndpoint, "pdHasEndpoint");
51
+ function pdsReadEndpoint(router, context, opts) {
52
+ if (opts?.enabled === false) {
53
+ console.log(`"pdsReadEndpoint" Endpoint is disabled`);
54
+ return;
55
+ }
56
+ const path = opts?.path ?? operation;
57
+ router.get(`${path}`, checkAuth(opts?.endpoint), async (request, response) => {
58
+ try {
59
+ const pd = await context.agent.pdmGetDefinitions();
60
+ response.statusCode = 200;
61
+ return response.json(pd);
62
+ } catch (error) {
63
+ return sendErrorResponse(response, 500, error.message, error);
64
+ }
65
+ });
66
+ }
67
+ __name(pdsReadEndpoint, "pdsReadEndpoint");
68
+ function pdPersistEndpoint(router, context, opts) {
69
+ if (opts?.enabled === false) {
70
+ console.log(`"pdPersistEndpoint" Endpoint is disabled`);
71
+ return;
72
+ }
73
+ const path = opts?.path ?? operation;
74
+ router.post(path, async (request, response) => {
75
+ try {
76
+ const addPd = request.body;
77
+ const pd = await context.agent.pdmPersistDefinitionItem(addPd);
78
+ response.statusCode = 200;
79
+ return response.json(pd);
80
+ } catch (error) {
81
+ return sendErrorResponse(response, 500, error.message, error);
82
+ }
83
+ });
84
+ }
85
+ __name(pdPersistEndpoint, "pdPersistEndpoint");
86
+ function pdDeleteEndpoint(router, context, opts) {
87
+ if (opts?.enabled === false) {
88
+ console.log(`"pdDeleteEndpoint" Endpoint is disabled`);
89
+ return;
90
+ }
91
+ const path = opts?.path ?? operation;
92
+ router.delete(`${path}/:itemId`, async (request, response) => {
93
+ try {
94
+ const itemId = request.params.itemId;
95
+ const result = await context.agent.pdmDeleteDefinition({
96
+ itemId
97
+ });
98
+ response.statusCode = 200;
99
+ return response.json(result);
100
+ } catch (error) {
101
+ return sendErrorResponse(response, 500, error.message, error);
102
+ }
103
+ });
104
+ }
105
+ __name(pdDeleteEndpoint, "pdDeleteEndpoint");
106
+ function pdsDeleteEndpoint(router, context, opts) {
107
+ if (opts?.enabled === false) {
108
+ console.log(`"pdsDeleteEndpoint" Endpoint is disabled`);
109
+ return;
110
+ }
111
+ const path = opts?.path ?? operation;
112
+ router.delete(`${path}/filter`, async (request, response) => {
113
+ try {
114
+ response.statusCode = 500;
115
+ response.statusMessage = "Not yet implemented";
116
+ return sendErrorResponse(response, 500, "Not yet implemented");
117
+ } catch (error) {
118
+ return sendErrorResponse(response, 500, error.message, error);
119
+ }
120
+ });
121
+ }
122
+ __name(pdsDeleteEndpoint, "pdsDeleteEndpoint");
123
+
124
+ // src/pd-manager-api-server.ts
125
+ import { copyGlobalAuthToEndpoints } from "@sphereon/ssi-express-support";
126
+ var PdManagerApiServer = class {
127
+ static {
128
+ __name(this, "PdManagerApiServer");
129
+ }
130
+ _express;
131
+ _agent;
132
+ _opts;
133
+ _router;
134
+ constructor(args) {
135
+ const { agent, opts } = args;
136
+ this._agent = agent;
137
+ copyGlobalAuthToEndpoints({
138
+ opts,
139
+ keys: [
140
+ "pdRead",
141
+ "pdWrite",
142
+ "pdUpdate",
143
+ "pdDelete"
144
+ ]
145
+ });
146
+ if (opts?.endpointOpts?.globalAuth?.securePDManagerEndpoints) {
147
+ copyGlobalAuthToEndpoints({
148
+ opts,
149
+ keys: [
150
+ "pdRead",
151
+ "pdWrite",
152
+ "pdUpdate",
153
+ "pdDelete"
154
+ ]
155
+ });
156
+ }
157
+ this._opts = opts;
158
+ this._express = args.expressSupport.express;
159
+ this._router = express.Router();
160
+ const context = agentContext(agent);
161
+ const features = opts?.enableFeatures ?? [
162
+ "pd_read",
163
+ "pd_write",
164
+ "pd_delete"
165
+ ];
166
+ console.log(`Presentation Definition API enabled, with features: ${JSON.stringify(features)}}`);
167
+ if (features.includes("pd_read")) {
168
+ pdReadEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead);
169
+ pdHasEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead);
170
+ pdsReadEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead);
171
+ }
172
+ if (features.includes("pd_write")) {
173
+ pdPersistEndpoint(this.router, context, this._opts?.endpointOpts?.pdWrite);
174
+ }
175
+ if (features.includes("pd_delete")) {
176
+ pdDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.pdDelete);
177
+ pdsDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.pdDelete);
178
+ }
179
+ this._express.use(opts?.endpointOpts?.basePath ?? "", this.router);
180
+ }
181
+ get express() {
182
+ return this._express;
183
+ }
184
+ get router() {
185
+ return this._router;
186
+ }
187
+ get agent() {
188
+ return this._agent;
189
+ }
190
+ get opts() {
191
+ return this._opts;
192
+ }
193
+ };
194
+ export {
195
+ PdManagerApiServer,
196
+ pdDeleteEndpoint,
197
+ pdHasEndpoint,
198
+ pdPersistEndpoint,
199
+ pdReadEndpoint,
200
+ pdsDeleteEndpoint,
201
+ pdsReadEndpoint
202
+ };
4
203
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,yBAAyB,CAAA;AACvC,cAAc,iBAAiB,CAAA"}
1
+ {"version":3,"sources":["../src/pd-manager-api-server.ts","../src/api-functions.ts"],"sourcesContent":["import { agentContext } from '@sphereon/ssi-sdk.core'\nimport { TAgent } from '@veramo/core'\n\nimport express, { Express, Router } from 'express'\nimport { IPDManagerAPIEndpointOpts, IRequiredPlugins } from './types'\nimport { pdDeleteEndpoint, pdHasEndpoint, pdPersistEndpoint, pdReadEndpoint, pdsDeleteEndpoint, pdsReadEndpoint } from './api-functions'\nimport { copyGlobalAuthToEndpoints, ExpressSupport } from '@sphereon/ssi-express-support'\n\ntype PdManagerApiServerArgs = {\n agent: TAgent<IRequiredPlugins>\n expressSupport: ExpressSupport\n opts?: IPDManagerAPIEndpointOpts\n}\n\nexport class PdManagerApiServer {\n private readonly _express: Express\n private readonly _agent: TAgent<IRequiredPlugins>\n private readonly _opts?: IPDManagerAPIEndpointOpts\n private readonly _router: Router\n\n constructor(args: PdManagerApiServerArgs) {\n const { agent, opts } = args\n this._agent = agent\n copyGlobalAuthToEndpoints({ opts, keys: ['pdRead', 'pdWrite', 'pdUpdate', 'pdDelete'] })\n if (opts?.endpointOpts?.globalAuth?.securePDManagerEndpoints) {\n copyGlobalAuthToEndpoints({ opts, keys: ['pdRead', 'pdWrite', 'pdUpdate', 'pdDelete'] })\n }\n this._opts = opts\n this._express = args.expressSupport.express\n this._router = express.Router()\n const context = agentContext(agent)\n const features = opts?.enableFeatures ?? ['pd_read', 'pd_write', 'pd_delete']\n console.log(`Presentation Definition API enabled, with features: ${JSON.stringify(features)}}`)\n\n // endpoints\n if (features.includes('pd_read')) {\n pdReadEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead)\n pdHasEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead)\n pdsReadEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead)\n }\n if (features.includes('pd_write')) {\n pdPersistEndpoint(this.router, context, this._opts?.endpointOpts?.pdWrite)\n }\n if (features.includes('pd_delete')) {\n pdDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.pdDelete)\n pdsDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.pdDelete)\n }\n this._express.use(opts?.endpointOpts?.basePath ?? '', this.router)\n }\n\n get express(): Express {\n return this._express\n }\n\n get router(): Router {\n return this._router\n }\n\n get agent(): TAgent<IRequiredPlugins> {\n return this._agent\n }\n\n get opts(): IPDManagerAPIEndpointOpts | undefined {\n return this._opts\n }\n}\n","import { checkAuth, ISingleEndpointOpts, sendErrorResponse } from '@sphereon/ssi-express-support'\nimport { Request, Response, Router } from 'express'\nimport { IRequiredContext } from './types'\nimport { PersistDefinitionArgs } from '@sphereon/ssi-sdk.pd-manager'\nimport { DeleteDefinitionArgs } from '@sphereon/ssi-sdk.data-store'\n\nconst operation = '/presentation-definitions'\n\nexport function pdReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.get(`${path}/:itemId`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const itemId = request.params.itemId\n const pd = await context.agent.pdmGetDefinition({ itemId: itemId })\n response.statusCode = 200\n return response.json(pd)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function pdHasEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.get(`${path}/:itemId`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const itemId = request.params.itemId\n const result = await context.agent.pdmHasDefinition({ itemId: itemId })\n response.statusCode = 200\n return response.json(result)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function pdsReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdsReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.get(`${path}`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n // TODO Get all of them for now\n const pd = await context.agent.pdmGetDefinitions()\n response.statusCode = 200\n return response.json(pd)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function pdPersistEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdPersistEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.post(path, async (request: Request, response: Response) => {\n try {\n const addPd = request.body\n const pd = await context.agent.pdmPersistDefinitionItem(addPd as PersistDefinitionArgs)\n response.statusCode = 200 // TODO find out if pdmPersistDefinitionItem added or updated\n return response.json(pd)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n\nexport function pdDeleteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdDeleteEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.delete(`${path}/:itemId`, async (request, response) => {\n try {\n const itemId = request.params.itemId\n const result = await context.agent.pdmDeleteDefinition({ itemId: itemId } as DeleteDefinitionArgs)\n response.statusCode = 200\n return response.json(result)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n\nexport function pdsDeleteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"pdsDeleteEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? operation\n router.delete(`${path}/filter`, async (request, response) => {\n try {\n // TODO we are not going to delete all PDs without filter like we did with pdsGet... Finish when filter is implemented\n response.statusCode = 500\n response.statusMessage = 'Not yet implemented'\n return sendErrorResponse(response, 500, 'Not yet implemented')\n } catch (error) {\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n"],"mappings":";;;;AAAA,SAASA,oBAAoB;AAG7B,OAAOC,aAAkC;;;ACHzC,SAASC,WAAgCC,yBAAyB;AAMlE,IAAMC,YAAY;AAEX,SAASC,eAAeC,QAAgBC,SAA2BC,MAA0B;AAClG,MAAIA,MAAMC,YAAY,OAAO;AAC3BC,YAAQC,IAAI,uCAAuC;AACnD;EACF;AACA,QAAMC,OAAOJ,MAAMI,QAAQR;AAC3BE,SAAOO,IAAI,GAAGD,IAAAA,YAAgBE,UAAUN,MAAMO,QAAAA,GAAW,OAAOC,SAAkBC,aAAAA;AAChF,QAAI;AACF,YAAMC,SAASF,QAAQG,OAAOD;AAC9B,YAAME,KAAK,MAAMb,QAAQc,MAAMC,iBAAiB;QAAEJ;MAAe,CAAA;AACjED,eAASM,aAAa;AACtB,aAAON,SAASO,KAAKJ,EAAAA;IACvB,SAASK,OAAO;AACd,aAAOC,kBAAkBT,UAAU,KAAKQ,MAAME,SAAmBF,KAAAA;IACnE;EACF,CAAA;AACF;AAhBgBpB;AAkBT,SAASuB,cAActB,QAAgBC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AAkC;AACpC,WAAO,KAAKL;EACd;EAEA,IAAIM,OAA8C;AAChD,WAAO,KAAKL;EACd;AACF;","names":["agentContext","express","checkAuth","sendErrorResponse","operation","pdReadEndpoint","router","context","opts","enabled","console","log","path","get","checkAuth","endpoint","request","response","itemId","params","pd","agent","pdmGetDefinition","statusCode","json","error","sendErrorResponse","message","pdHasEndpoint","result","pdmHasDefinition","pdsReadEndpoint","pdmGetDefinitions","pdPersistEndpoint","post","addPd","body","pdmPersistDefinitionItem","pdDeleteEndpoint","delete","pdmDeleteDefinition","pdsDeleteEndpoint","statusMessage","copyGlobalAuthToEndpoints","PdManagerApiServer","_express","_agent","_opts","_router","constructor","args","agent","opts","copyGlobalAuthToEndpoints","keys","endpointOpts","globalAuth","securePDManagerEndpoints","expressSupport","express","Router","context","agentContext","features","enableFeatures","console","log","JSON","stringify","includes","pdReadEndpoint","router","pdRead","pdHasEndpoint","pdsReadEndpoint","pdPersistEndpoint","pdWrite","pdDeleteEndpoint","pdDelete","pdsDeleteEndpoint","use","basePath"]}
package/package.json CHANGED
@@ -1,21 +1,32 @@
1
1
  {
2
2
  "name": "@sphereon/ssi-sdk.pd-manager-rest-api",
3
- "version": "0.33.1-feature.vcdm2.4+9f634bdb",
3
+ "version": "0.33.1-feature.vcdm2.tsup.18+1fbb8be0",
4
4
  "source": "src/index.ts",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ "import": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "require": {
15
+ "types": "./dist/index.d.cts",
16
+ "require": "./dist/index.cjs"
17
+ }
18
+ },
7
19
  "scripts": {
8
- "build": "tsc --build",
9
- "build:clean": "tsc --build --clean && tsc --build",
20
+ "build": "tsup --config ../../tsup.config.ts --tsconfig ../../tsconfig.tsup.json",
10
21
  "start:prod": "node build/index.js",
11
22
  "start:dev": "ts-node __tests__/RestAPI.ts"
12
23
  },
13
24
  "dependencies": {
14
- "@sphereon/ssi-express-support": "0.33.1-feature.vcdm2.4+9f634bdb",
15
- "@sphereon/ssi-sdk.core": "0.33.1-feature.vcdm2.4+9f634bdb",
16
- "@sphereon/ssi-sdk.data-store": "0.33.1-feature.vcdm2.4+9f634bdb",
17
- "@sphereon/ssi-sdk.pd-manager": "0.33.1-feature.vcdm2.4+9f634bdb",
18
- "@sphereon/ssi-types": "0.33.1-feature.vcdm2.4+9f634bdb",
25
+ "@sphereon/ssi-express-support": "^0.33.1-feature.vcdm2.tsup.18+1fbb8be0",
26
+ "@sphereon/ssi-sdk.core": "^0.33.1-feature.vcdm2.tsup.18+1fbb8be0",
27
+ "@sphereon/ssi-sdk.data-store": "^0.33.1-feature.vcdm2.tsup.18+1fbb8be0",
28
+ "@sphereon/ssi-sdk.pd-manager": "^0.33.1-feature.vcdm2.tsup.18+1fbb8be0",
29
+ "@sphereon/ssi-types": "^0.33.1-feature.vcdm2.tsup.18+1fbb8be0",
19
30
  "@veramo/core": "4.2.0",
20
31
  "body-parser": "^1.20.2",
21
32
  "casbin": "^5.30.0",
@@ -30,7 +41,7 @@
30
41
  },
31
42
  "devDependencies": {
32
43
  "@decentralized-identity/ion-sdk": "^0.6.0",
33
- "@sphereon/ssi-sdk.agent-config": "^0.33.1-feature.vcdm2.4+9f634bdb",
44
+ "@sphereon/ssi-sdk.agent-config": "^0.33.1-feature.vcdm2.tsup.18+1fbb8be0",
34
45
  "@types/body-parser": "^1.19.5",
35
46
  "@types/cookie-parser": "^1.4.7",
36
47
  "@types/cors": "^2.8.17",
@@ -54,11 +65,11 @@
54
65
  "passport": "^0.6.0",
55
66
  "passport-http-bearer": "^1.0.1",
56
67
  "ts-node": "^10.9.2",
57
- "typeorm": "^0.3.21"
68
+ "typeorm": "^0.3.22"
58
69
  },
59
70
  "files": [
60
- "dist/**/*",
61
- "src/**/*",
71
+ "dist",
72
+ "src",
62
73
  "README.md",
63
74
  "LICENSE"
64
75
  ],
@@ -78,6 +89,5 @@
78
89
  "pd-management",
79
90
  "presentation-definition-management"
80
91
  ],
81
- "nx": {},
82
- "gitHead": "9f634bdb714061141e277508c124b08d626f6036"
92
+ "gitHead": "1fbb8be0256ec8dbc1b52d860b7bfd09d12f0d00"
83
93
  }
@@ -1,10 +0,0 @@
1
- import { ISingleEndpointOpts } from '@sphereon/ssi-express-support';
2
- import { Router } from 'express';
3
- import { IRequiredContext } from './types';
4
- export declare function pdReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
5
- export declare function pdHasEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
6
- export declare function pdsReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
7
- export declare function pdPersistEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
8
- export declare function pdDeleteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
9
- export declare function pdsDeleteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
10
- //# sourceMappingURL=api-functions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api-functions.d.ts","sourceRoot":"","sources":["../src/api-functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,mBAAmB,EAAqB,MAAM,+BAA+B,CAAA;AACjG,OAAO,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAM1C,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,mBAAmB,QAgBnG;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,mBAAmB,QAgBlG;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,mBAAmB,QAgBpG;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,mBAAmB,QAgBtG;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,mBAAmB,QAgBrG;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,mBAAmB,QAgBtG"}
@@ -1,111 +0,0 @@
1
- import { checkAuth, sendErrorResponse } from '@sphereon/ssi-express-support';
2
- const operation = '/presentation-definitions';
3
- export function pdReadEndpoint(router, context, opts) {
4
- if (opts?.enabled === false) {
5
- console.log(`"pdReadEndpoint" Endpoint is disabled`);
6
- return;
7
- }
8
- const path = opts?.path ?? operation;
9
- router.get(`${path}/:itemId`, checkAuth(opts?.endpoint), async (request, response) => {
10
- try {
11
- const itemId = request.params.itemId;
12
- const pd = await context.agent.pdmGetDefinition({ itemId: itemId });
13
- response.statusCode = 200;
14
- return response.json(pd);
15
- }
16
- catch (error) {
17
- return sendErrorResponse(response, 500, error.message, error);
18
- }
19
- });
20
- }
21
- export function pdHasEndpoint(router, context, opts) {
22
- if (opts?.enabled === false) {
23
- console.log(`"pdReadEndpoint" Endpoint is disabled`);
24
- return;
25
- }
26
- const path = opts?.path ?? operation;
27
- router.get(`${path}/:itemId`, checkAuth(opts?.endpoint), async (request, response) => {
28
- try {
29
- const itemId = request.params.itemId;
30
- const result = await context.agent.pdmHasDefinition({ itemId: itemId });
31
- response.statusCode = 200;
32
- return response.json(result);
33
- }
34
- catch (error) {
35
- return sendErrorResponse(response, 500, error.message, error);
36
- }
37
- });
38
- }
39
- export function pdsReadEndpoint(router, context, opts) {
40
- if (opts?.enabled === false) {
41
- console.log(`"pdsReadEndpoint" Endpoint is disabled`);
42
- return;
43
- }
44
- const path = opts?.path ?? operation;
45
- router.get(`${path}`, checkAuth(opts?.endpoint), async (request, response) => {
46
- try {
47
- // TODO Get all of them for now
48
- const pd = await context.agent.pdmGetDefinitions();
49
- response.statusCode = 200;
50
- return response.json(pd);
51
- }
52
- catch (error) {
53
- return sendErrorResponse(response, 500, error.message, error);
54
- }
55
- });
56
- }
57
- export function pdPersistEndpoint(router, context, opts) {
58
- if (opts?.enabled === false) {
59
- console.log(`"pdPersistEndpoint" Endpoint is disabled`);
60
- return;
61
- }
62
- const path = opts?.path ?? operation;
63
- router.post(path, async (request, response) => {
64
- try {
65
- const addPd = request.body;
66
- const pd = await context.agent.pdmPersistDefinitionItem(addPd);
67
- response.statusCode = 200; // TODO find out if pdmPersistDefinitionItem added or updated
68
- return response.json(pd);
69
- }
70
- catch (error) {
71
- return sendErrorResponse(response, 500, error.message, error);
72
- }
73
- });
74
- }
75
- export function pdDeleteEndpoint(router, context, opts) {
76
- if (opts?.enabled === false) {
77
- console.log(`"pdDeleteEndpoint" Endpoint is disabled`);
78
- return;
79
- }
80
- const path = opts?.path ?? operation;
81
- router.delete(`${path}/:itemId`, async (request, response) => {
82
- try {
83
- const itemId = request.params.itemId;
84
- const result = await context.agent.pdmDeleteDefinition({ itemId: itemId });
85
- response.statusCode = 200;
86
- return response.json(result);
87
- }
88
- catch (error) {
89
- return sendErrorResponse(response, 500, error.message, error);
90
- }
91
- });
92
- }
93
- export function pdsDeleteEndpoint(router, context, opts) {
94
- if (opts?.enabled === false) {
95
- console.log(`"pdsDeleteEndpoint" Endpoint is disabled`);
96
- return;
97
- }
98
- const path = opts?.path ?? operation;
99
- router.delete(`${path}/filter`, async (request, response) => {
100
- try {
101
- // TODO we are not going to delete all PDs without filter like we did with pdsGet... Finish when filter is implemented
102
- response.statusCode = 500;
103
- response.statusMessage = 'Not yet implemented';
104
- return sendErrorResponse(response, 500, 'Not yet implemented');
105
- }
106
- catch (error) {
107
- return sendErrorResponse(response, 500, error.message, error);
108
- }
109
- });
110
- }
111
- //# sourceMappingURL=api-functions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api-functions.js","sourceRoot":"","sources":["../src/api-functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAuB,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAMjG,MAAM,SAAS,GAAG,2BAA2B,CAAA;AAE7C,MAAM,UAAU,cAAc,CAAC,MAAc,EAAE,OAAyB,EAAE,IAA0B;IAClG,IAAI,IAAI,EAAE,OAAO,KAAK,KAAK,EAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAA;QACpD,OAAM;IACR,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,EAAE,IAAI,IAAI,SAAS,CAAA;IACpC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,UAAU,EAAE,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,KAAK,EAAE,OAAgB,EAAE,QAAkB,EAAE,EAAE;QACtG,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAA;YACpC,MAAM,EAAE,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;YACnE,QAAQ,CAAC,UAAU,GAAG,GAAG,CAAA;YACzB,OAAO,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAC1B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,iBAAiB,CAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,CAAC,OAAiB,EAAE,KAAK,CAAC,CAAA;QACzE,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAAc,EAAE,OAAyB,EAAE,IAA0B;IACjG,IAAI,IAAI,EAAE,OAAO,KAAK,KAAK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;QAChE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,iBAAiB,CAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QAC/D,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,yBAAyB,CAAA;AACvC,cAAc,iBAAiB,CAAA"}
@@ -1,22 +0,0 @@
1
- import { TAgent } from '@veramo/core';
2
- import { Express, Router } from 'express';
3
- import { IPDManagerAPIEndpointOpts, IRequiredPlugins } from './types';
4
- import { ExpressSupport } from '@sphereon/ssi-express-support';
5
- type PdManagerApiServerArgs = {
6
- agent: TAgent<IRequiredPlugins>;
7
- expressSupport: ExpressSupport;
8
- opts?: IPDManagerAPIEndpointOpts;
9
- };
10
- export declare class PdManagerApiServer {
11
- private readonly _express;
12
- private readonly _agent;
13
- private readonly _opts?;
14
- private readonly _router;
15
- constructor(args: PdManagerApiServerArgs);
16
- get express(): Express;
17
- get router(): Router;
18
- get agent(): TAgent<IRequiredPlugins>;
19
- get opts(): IPDManagerAPIEndpointOpts | undefined;
20
- }
21
- export {};
22
- //# sourceMappingURL=pd-manager-api-server.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pd-manager-api-server.d.ts","sourceRoot":"","sources":["../src/pd-manager-api-server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAgB,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAErE,OAAO,EAA6B,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAEzF,KAAK,sBAAsB,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAA;IAC/B,cAAc,EAAE,cAAc,CAAA;IAC9B,IAAI,CAAC,EAAE,yBAAyB,CAAA;CACjC,CAAA;AAED,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;IACjD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAA2B;IAClD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;gBAEpB,IAAI,EAAE,sBAAsB;IA8BxC,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,KAAK,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAEpC;IAED,IAAI,IAAI,IAAI,yBAAyB,GAAG,SAAS,CAEhD;CACF"}
@@ -1,51 +0,0 @@
1
- import { agentContext } from '@sphereon/ssi-sdk.core';
2
- import express from 'express';
3
- import { pdDeleteEndpoint, pdHasEndpoint, pdPersistEndpoint, pdReadEndpoint, pdsDeleteEndpoint, pdsReadEndpoint } from './api-functions';
4
- import { copyGlobalAuthToEndpoints } from '@sphereon/ssi-express-support';
5
- export class PdManagerApiServer {
6
- _express;
7
- _agent;
8
- _opts;
9
- _router;
10
- constructor(args) {
11
- const { agent, opts } = args;
12
- this._agent = agent;
13
- copyGlobalAuthToEndpoints({ opts, keys: ['pdRead', 'pdWrite', 'pdUpdate', 'pdDelete'] });
14
- if (opts?.endpointOpts?.globalAuth?.securePDManagerEndpoints) {
15
- copyGlobalAuthToEndpoints({ opts, keys: ['pdRead', 'pdWrite', 'pdUpdate', 'pdDelete'] });
16
- }
17
- this._opts = opts;
18
- this._express = args.expressSupport.express;
19
- this._router = express.Router();
20
- const context = agentContext(agent);
21
- const features = opts?.enableFeatures ?? ['pd_read', 'pd_write', 'pd_delete'];
22
- console.log(`Presentation Definition API enabled, with features: ${JSON.stringify(features)}}`);
23
- // endpoints
24
- if (features.includes('pd_read')) {
25
- pdReadEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead);
26
- pdHasEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead);
27
- pdsReadEndpoint(this.router, context, this._opts?.endpointOpts?.pdRead);
28
- }
29
- if (features.includes('pd_write')) {
30
- pdPersistEndpoint(this.router, context, this._opts?.endpointOpts?.pdWrite);
31
- }
32
- if (features.includes('pd_delete')) {
33
- pdDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.pdDelete);
34
- pdsDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.pdDelete);
35
- }
36
- this._express.use(opts?.endpointOpts?.basePath ?? '', this.router);
37
- }
38
- get express() {
39
- return this._express;
40
- }
41
- get router() {
42
- return this._router;
43
- }
44
- get agent() {
45
- return this._agent;
46
- }
47
- get opts() {
48
- return this._opts;
49
- }
50
- }
51
- //# sourceMappingURL=pd-manager-api-server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pd-manager-api-server.js","sourceRoot":"","sources":["../src/pd-manager-api-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAGrD,OAAO,OAA4B,MAAM,SAAS,CAAA;AAElD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,iBAAiB,EAAE,cAAc,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACxI,OAAO,EAAE,yBAAyB,EAAkB,MAAM,+BAA+B,CAAA;AAQzF,MAAM,OAAO,kBAAkB;IACZ,QAAQ,CAAS;IACjB,MAAM,CAA0B;IAChC,KAAK,CAA4B;IACjC,OAAO,CAAQ;IAEhC,YAAY,IAA4B;QACtC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;QAC5B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;QACnB,yBAAyB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,UAA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AO,CAAC,CAAA;QAC5E,CAAC;QACD,IAAI,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YACnC,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAA;YAC1E,iBAAiB,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAA;QAC7E,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,EAAE,QAAQ,IAAI,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"}
package/dist/types.d.ts DELETED
@@ -1,19 +0,0 @@
1
- import { GenericAuthArgs, ISingleEndpointOpts } from '@sphereon/ssi-express-support';
2
- import { IPDManager } from '@sphereon/ssi-sdk.pd-manager';
3
- import { IAgentContext } from '@veramo/core';
4
- export type PDManagerMRestApiFeatures = 'pd_read' | 'pd_write' | 'pd_delete';
5
- export interface IPDManagerAPIEndpointOpts {
6
- endpointOpts?: {
7
- basePath?: string;
8
- globalAuth?: GenericAuthArgs & {
9
- securePDManagerEndpoints?: boolean;
10
- };
11
- pdRead?: ISingleEndpointOpts;
12
- pdWrite?: ISingleEndpointOpts;
13
- pdDelete?: ISingleEndpointOpts;
14
- };
15
- enableFeatures?: PDManagerMRestApiFeatures[];
16
- }
17
- export type IRequiredPlugins = IPDManager;
18
- export type IRequiredContext = IAgentContext<IRequiredPlugins>;
19
- //# 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,UAAU,EAAE,MAAM,8BAA8B,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAE5C,MAAM,MAAM,yBAAyB,GAAG,SAAS,GAAG,UAAU,GAAG,WAAW,CAAA;AAE5E,MAAM,WAAW,yBAAyB;IACxC,YAAY,CAAC,EAAE;QACb,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,UAAU,CAAC,EAAE,eAAe,GAAG;YAAE,wBAAwB,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;QACrE,MAAM,CAAC,EAAE,mBAAmB,CAAA;QAC5B,OAAO,CAAC,EAAE,mBAAmB,CAAA;QAC7B,QAAQ,CAAC,EAAE,mBAAmB,CAAA;KAC/B,CAAA;IACD,cAAc,CAAC,EAAE,yBAAyB,EAAE,CAAA;CAC7C;AAED,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAA;AACzC,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC,gBAAgB,CAAC,CAAA"}
package/dist/types.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# 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":""}