@sphereon/ssi-sdk.pd-manager-rest-api 0.32.1-next.54 → 0.33.1-feature.vcdm2.4
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/api-functions.js +48 -71
- package/dist/api-functions.js.map +1 -1
- package/dist/index.js +3 -19
- package/dist/index.js.map +1 -1
- package/dist/pd-manager-api-server.js +23 -27
- package/dist/pd-manager-api-server.js.map +1 -1
- package/dist/types.js +1 -2
- package/package.json +9 -9
- package/src/api-functions.ts +5 -5
- package/src/pd-manager-api-server.ts +1 -1
package/dist/api-functions.js
CHANGED
|
@@ -1,134 +1,111 @@
|
|
|
1
|
-
|
|
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.pdReadEndpoint = pdReadEndpoint;
|
|
13
|
-
exports.pdHasEndpoint = pdHasEndpoint;
|
|
14
|
-
exports.pdsReadEndpoint = pdsReadEndpoint;
|
|
15
|
-
exports.pdPersistEndpoint = pdPersistEndpoint;
|
|
16
|
-
exports.pdDeleteEndpoint = pdDeleteEndpoint;
|
|
17
|
-
exports.pdsDeleteEndpoint = pdsDeleteEndpoint;
|
|
18
|
-
const ssi_express_support_1 = require("@sphereon/ssi-express-support");
|
|
1
|
+
import { checkAuth, sendErrorResponse } from '@sphereon/ssi-express-support';
|
|
19
2
|
const operation = '/presentation-definitions';
|
|
20
|
-
function pdReadEndpoint(router, context, opts) {
|
|
21
|
-
|
|
22
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
3
|
+
export function pdReadEndpoint(router, context, opts) {
|
|
4
|
+
if (opts?.enabled === false) {
|
|
23
5
|
console.log(`"pdReadEndpoint" Endpoint is disabled`);
|
|
24
6
|
return;
|
|
25
7
|
}
|
|
26
|
-
const path =
|
|
27
|
-
router.get(`${path}/:itemId`,
|
|
8
|
+
const path = opts?.path ?? operation;
|
|
9
|
+
router.get(`${path}/:itemId`, checkAuth(opts?.endpoint), async (request, response) => {
|
|
28
10
|
try {
|
|
29
11
|
const itemId = request.params.itemId;
|
|
30
|
-
const pd =
|
|
12
|
+
const pd = await context.agent.pdmGetDefinition({ itemId: itemId });
|
|
31
13
|
response.statusCode = 200;
|
|
32
|
-
return response.
|
|
14
|
+
return response.json(pd);
|
|
33
15
|
}
|
|
34
16
|
catch (error) {
|
|
35
|
-
return
|
|
17
|
+
return sendErrorResponse(response, 500, error.message, error);
|
|
36
18
|
}
|
|
37
|
-
})
|
|
19
|
+
});
|
|
38
20
|
}
|
|
39
|
-
function pdHasEndpoint(router, context, opts) {
|
|
40
|
-
|
|
41
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
21
|
+
export function pdHasEndpoint(router, context, opts) {
|
|
22
|
+
if (opts?.enabled === false) {
|
|
42
23
|
console.log(`"pdReadEndpoint" Endpoint is disabled`);
|
|
43
24
|
return;
|
|
44
25
|
}
|
|
45
|
-
const path =
|
|
46
|
-
router.get(`${path}/:itemId`,
|
|
26
|
+
const path = opts?.path ?? operation;
|
|
27
|
+
router.get(`${path}/:itemId`, checkAuth(opts?.endpoint), async (request, response) => {
|
|
47
28
|
try {
|
|
48
29
|
const itemId = request.params.itemId;
|
|
49
|
-
const result =
|
|
30
|
+
const result = await context.agent.pdmHasDefinition({ itemId: itemId });
|
|
50
31
|
response.statusCode = 200;
|
|
51
|
-
return response.
|
|
32
|
+
return response.json(result);
|
|
52
33
|
}
|
|
53
34
|
catch (error) {
|
|
54
|
-
return
|
|
35
|
+
return sendErrorResponse(response, 500, error.message, error);
|
|
55
36
|
}
|
|
56
|
-
})
|
|
37
|
+
});
|
|
57
38
|
}
|
|
58
|
-
function pdsReadEndpoint(router, context, opts) {
|
|
59
|
-
|
|
60
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
39
|
+
export function pdsReadEndpoint(router, context, opts) {
|
|
40
|
+
if (opts?.enabled === false) {
|
|
61
41
|
console.log(`"pdsReadEndpoint" Endpoint is disabled`);
|
|
62
42
|
return;
|
|
63
43
|
}
|
|
64
|
-
const path =
|
|
65
|
-
router.get(`${path}`,
|
|
44
|
+
const path = opts?.path ?? operation;
|
|
45
|
+
router.get(`${path}`, checkAuth(opts?.endpoint), async (request, response) => {
|
|
66
46
|
try {
|
|
67
47
|
// TODO Get all of them for now
|
|
68
|
-
const pd =
|
|
48
|
+
const pd = await context.agent.pdmGetDefinitions();
|
|
69
49
|
response.statusCode = 200;
|
|
70
|
-
return response.
|
|
50
|
+
return response.json(pd);
|
|
71
51
|
}
|
|
72
52
|
catch (error) {
|
|
73
|
-
return
|
|
53
|
+
return sendErrorResponse(response, 500, error.message, error);
|
|
74
54
|
}
|
|
75
|
-
})
|
|
55
|
+
});
|
|
76
56
|
}
|
|
77
|
-
function pdPersistEndpoint(router, context, opts) {
|
|
78
|
-
|
|
79
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
57
|
+
export function pdPersistEndpoint(router, context, opts) {
|
|
58
|
+
if (opts?.enabled === false) {
|
|
80
59
|
console.log(`"pdPersistEndpoint" Endpoint is disabled`);
|
|
81
60
|
return;
|
|
82
61
|
}
|
|
83
|
-
const path =
|
|
84
|
-
router.post(path, (request, response) =>
|
|
62
|
+
const path = opts?.path ?? operation;
|
|
63
|
+
router.post(path, async (request, response) => {
|
|
85
64
|
try {
|
|
86
65
|
const addPd = request.body;
|
|
87
|
-
const pd =
|
|
66
|
+
const pd = await context.agent.pdmPersistDefinitionItem(addPd);
|
|
88
67
|
response.statusCode = 200; // TODO find out if pdmPersistDefinitionItem added or updated
|
|
89
|
-
return response.
|
|
68
|
+
return response.json(pd);
|
|
90
69
|
}
|
|
91
70
|
catch (error) {
|
|
92
|
-
return
|
|
71
|
+
return sendErrorResponse(response, 500, error.message, error);
|
|
93
72
|
}
|
|
94
|
-
})
|
|
73
|
+
});
|
|
95
74
|
}
|
|
96
|
-
function pdDeleteEndpoint(router, context, opts) {
|
|
97
|
-
|
|
98
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
75
|
+
export function pdDeleteEndpoint(router, context, opts) {
|
|
76
|
+
if (opts?.enabled === false) {
|
|
99
77
|
console.log(`"pdDeleteEndpoint" Endpoint is disabled`);
|
|
100
78
|
return;
|
|
101
79
|
}
|
|
102
|
-
const path =
|
|
103
|
-
router.delete(`${path}/:itemId`, (request, response) =>
|
|
80
|
+
const path = opts?.path ?? operation;
|
|
81
|
+
router.delete(`${path}/:itemId`, async (request, response) => {
|
|
104
82
|
try {
|
|
105
83
|
const itemId = request.params.itemId;
|
|
106
|
-
const result =
|
|
84
|
+
const result = await context.agent.pdmDeleteDefinition({ itemId: itemId });
|
|
107
85
|
response.statusCode = 200;
|
|
108
|
-
return response.
|
|
86
|
+
return response.json(result);
|
|
109
87
|
}
|
|
110
88
|
catch (error) {
|
|
111
|
-
return
|
|
89
|
+
return sendErrorResponse(response, 500, error.message, error);
|
|
112
90
|
}
|
|
113
|
-
})
|
|
91
|
+
});
|
|
114
92
|
}
|
|
115
|
-
function pdsDeleteEndpoint(router, context, opts) {
|
|
116
|
-
|
|
117
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
93
|
+
export function pdsDeleteEndpoint(router, context, opts) {
|
|
94
|
+
if (opts?.enabled === false) {
|
|
118
95
|
console.log(`"pdsDeleteEndpoint" Endpoint is disabled`);
|
|
119
96
|
return;
|
|
120
97
|
}
|
|
121
|
-
const path =
|
|
122
|
-
router.delete(`${path}/filter`, (request, response) =>
|
|
98
|
+
const path = opts?.path ?? operation;
|
|
99
|
+
router.delete(`${path}/filter`, async (request, response) => {
|
|
123
100
|
try {
|
|
124
101
|
// TODO we are not going to delete all PDs without filter like we did with pdsGet... Finish when filter is implemented
|
|
125
102
|
response.statusCode = 500;
|
|
126
103
|
response.statusMessage = 'Not yet implemented';
|
|
127
|
-
return
|
|
104
|
+
return sendErrorResponse(response, 500, 'Not yet implemented');
|
|
128
105
|
}
|
|
129
106
|
catch (error) {
|
|
130
|
-
return
|
|
107
|
+
return sendErrorResponse(response, 500, error.message, error);
|
|
131
108
|
}
|
|
132
|
-
})
|
|
109
|
+
});
|
|
133
110
|
}
|
|
134
111
|
//# sourceMappingURL=api-functions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-functions.js","sourceRoot":"","sources":["../src/api-functions.ts"],"names":[],"mappings":"
|
|
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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D,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAc,EAAE,OAAyB,EAAE,IAA0B;IACrG,IAAI,IAAI,EAAE,OAAO,KAAK,KAAK,EAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAA;QACvD,OAAM;IACR,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,EAAE,IAAI,IAAI,SAAS,CAAA;IACpC,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;QAC1D,IAAI,CAAC;YACH,sHAAsH;YACtH,QAAQ,CAAC,UAAU,GAAG,GAAG,CAAA;YACzB,QAAQ,CAAC,aAAa,GAAG,qBAAqB,CAAA;YAC9C,OAAO,iBAAiB,CAAC,QAAQ,EAAE,GAAG,EAAE,qBAAqB,CAAC,CAAA;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"}
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./types"), exports);
|
|
18
|
-
__exportStar(require("./pd-manager-api-server"), exports);
|
|
19
|
-
__exportStar(require("./api-functions"), exports);
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './pd-manager-api-server';
|
|
3
|
+
export * from './api-functions';
|
|
20
4
|
//# 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":"
|
|
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,42 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const ssi_express_support_1 = require("@sphereon/ssi-express-support");
|
|
11
|
-
class PdManagerApiServer {
|
|
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;
|
|
12
10
|
constructor(args) {
|
|
13
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
14
11
|
const { agent, opts } = args;
|
|
15
12
|
this._agent = agent;
|
|
16
|
-
|
|
17
|
-
if (
|
|
18
|
-
|
|
13
|
+
copyGlobalAuthToEndpoints({ opts, keys: ['pdRead', 'pdWrite', 'pdUpdate', 'pdDelete'] });
|
|
14
|
+
if (opts?.endpointOpts?.globalAuth?.securePDManagerEndpoints) {
|
|
15
|
+
copyGlobalAuthToEndpoints({ opts, keys: ['pdRead', 'pdWrite', 'pdUpdate', 'pdDelete'] });
|
|
19
16
|
}
|
|
20
17
|
this._opts = opts;
|
|
21
18
|
this._express = args.expressSupport.express;
|
|
22
|
-
this._router =
|
|
23
|
-
const context =
|
|
24
|
-
const features =
|
|
25
|
-
console.log(`
|
|
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)}}`);
|
|
26
23
|
// endpoints
|
|
27
24
|
if (features.includes('pd_read')) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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);
|
|
31
28
|
}
|
|
32
29
|
if (features.includes('pd_write')) {
|
|
33
|
-
|
|
30
|
+
pdPersistEndpoint(this.router, context, this._opts?.endpointOpts?.pdWrite);
|
|
34
31
|
}
|
|
35
32
|
if (features.includes('pd_delete')) {
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
pdDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.pdDelete);
|
|
34
|
+
pdsDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.pdDelete);
|
|
38
35
|
}
|
|
39
|
-
this._express.use(
|
|
36
|
+
this._express.use(opts?.endpointOpts?.basePath ?? '', this.router);
|
|
40
37
|
}
|
|
41
38
|
get express() {
|
|
42
39
|
return this._express;
|
|
@@ -51,5 +48,4 @@ class PdManagerApiServer {
|
|
|
51
48
|
return this._opts;
|
|
52
49
|
}
|
|
53
50
|
}
|
|
54
|
-
exports.PdManagerApiServer = PdManagerApiServer;
|
|
55
51
|
//# sourceMappingURL=pd-manager-api-server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pd-manager-api-server.js","sourceRoot":"","sources":["../src/pd-manager-api-server.ts"],"names":[],"mappings":"
|
|
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,UAAU,EAAE,UAAU,CAAC,EAAE,CAAC,CAAA;QACxF,IAAI,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,wBAAwB,EAAE,CAAC;YAC7D,yBAAyB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC,EAAE,CAAC,CAAA;QAC1F,CAA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AAE,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.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.pd-manager-rest-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
"start:dev": "ts-node __tests__/RestAPI.ts"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@sphereon/ssi-express-support": "0.
|
|
15
|
-
"@sphereon/ssi-sdk.core": "0.
|
|
16
|
-
"@sphereon/ssi-sdk.data-store": "0.
|
|
17
|
-
"@sphereon/ssi-sdk.pd-manager": "0.
|
|
18
|
-
"@sphereon/ssi-types": "0.
|
|
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",
|
|
19
19
|
"@veramo/core": "4.2.0",
|
|
20
20
|
"body-parser": "^1.20.2",
|
|
21
21
|
"casbin": "^5.30.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@decentralized-identity/ion-sdk": "^0.6.0",
|
|
33
|
-
"@sphereon/ssi-sdk.agent-config": "^0.
|
|
33
|
+
"@sphereon/ssi-sdk.agent-config": "^0.33.1-feature.vcdm2.4+9f634bdb",
|
|
34
34
|
"@types/body-parser": "^1.19.5",
|
|
35
35
|
"@types/cookie-parser": "^1.4.7",
|
|
36
36
|
"@types/cors": "^2.8.17",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"passport": "^0.6.0",
|
|
55
55
|
"passport-http-bearer": "^1.0.1",
|
|
56
56
|
"ts-node": "^10.9.2",
|
|
57
|
-
"typeorm": "^0.3.
|
|
57
|
+
"typeorm": "^0.3.21"
|
|
58
58
|
},
|
|
59
59
|
"files": [
|
|
60
60
|
"dist/**/*",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"presentation-definition-management"
|
|
80
80
|
],
|
|
81
81
|
"nx": {},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "9f634bdb714061141e277508c124b08d626f6036"
|
|
83
83
|
}
|
package/src/api-functions.ts
CHANGED
|
@@ -17,7 +17,7 @@ export function pdReadEndpoint(router: Router, context: IRequiredContext, opts?:
|
|
|
17
17
|
const itemId = request.params.itemId
|
|
18
18
|
const pd = await context.agent.pdmGetDefinition({ itemId: itemId })
|
|
19
19
|
response.statusCode = 200
|
|
20
|
-
return response.
|
|
20
|
+
return response.json(pd)
|
|
21
21
|
} catch (error) {
|
|
22
22
|
return sendErrorResponse(response, 500, error.message as string, error)
|
|
23
23
|
}
|
|
@@ -35,7 +35,7 @@ export function pdHasEndpoint(router: Router, context: IRequiredContext, opts?:
|
|
|
35
35
|
const itemId = request.params.itemId
|
|
36
36
|
const result = await context.agent.pdmHasDefinition({ itemId: itemId })
|
|
37
37
|
response.statusCode = 200
|
|
38
|
-
return response.
|
|
38
|
+
return response.json(result)
|
|
39
39
|
} catch (error) {
|
|
40
40
|
return sendErrorResponse(response, 500, error.message as string, error)
|
|
41
41
|
}
|
|
@@ -53,7 +53,7 @@ export function pdsReadEndpoint(router: Router, context: IRequiredContext, opts?
|
|
|
53
53
|
// TODO Get all of them for now
|
|
54
54
|
const pd = await context.agent.pdmGetDefinitions()
|
|
55
55
|
response.statusCode = 200
|
|
56
|
-
return response.
|
|
56
|
+
return response.json(pd)
|
|
57
57
|
} catch (error) {
|
|
58
58
|
return sendErrorResponse(response, 500, error.message as string, error)
|
|
59
59
|
}
|
|
@@ -71,7 +71,7 @@ export function pdPersistEndpoint(router: Router, context: IRequiredContext, opt
|
|
|
71
71
|
const addPd = request.body
|
|
72
72
|
const pd = await context.agent.pdmPersistDefinitionItem(addPd as PersistDefinitionArgs)
|
|
73
73
|
response.statusCode = 200 // TODO find out if pdmPersistDefinitionItem added or updated
|
|
74
|
-
return response.
|
|
74
|
+
return response.json(pd)
|
|
75
75
|
} catch (error) {
|
|
76
76
|
return sendErrorResponse(response, 500, error.message, error)
|
|
77
77
|
}
|
|
@@ -89,7 +89,7 @@ export function pdDeleteEndpoint(router: Router, context: IRequiredContext, opts
|
|
|
89
89
|
const itemId = request.params.itemId
|
|
90
90
|
const result = await context.agent.pdmDeleteDefinition({ itemId: itemId } as DeleteDefinitionArgs)
|
|
91
91
|
response.statusCode = 200
|
|
92
|
-
return response.
|
|
92
|
+
return response.json(result)
|
|
93
93
|
} catch (error) {
|
|
94
94
|
return sendErrorResponse(response, 500, error.message, error)
|
|
95
95
|
}
|
|
@@ -30,7 +30,7 @@ export class PdManagerApiServer {
|
|
|
30
30
|
this._router = express.Router()
|
|
31
31
|
const context = agentContext(agent)
|
|
32
32
|
const features = opts?.enableFeatures ?? ['pd_read', 'pd_write', 'pd_delete']
|
|
33
|
-
console.log(`
|
|
33
|
+
console.log(`Presentation Definition API enabled, with features: ${JSON.stringify(features)}}`)
|
|
34
34
|
|
|
35
35
|
// endpoints
|
|
36
36
|
if (features.includes('pd_read')) {
|