@sphereon/ssi-sdk.contact-manager-rest-api 0.33.1-next.3 → 0.33.1-next.73
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 +277 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +48 -0
- package/dist/index.d.ts +48 -4
- package/dist/index.js +244 -18
- package/dist/index.js.map +1 -1
- package/package.json +30 -19
- package/dist/api-functions.d.ts +0 -12
- package/dist/api-functions.d.ts.map +0 -1
- package/dist/api-functions.js +0 -173
- package/dist/api-functions.js.map +0 -1
- package/dist/contact-manager-api-server.d.ts +0 -20
- package/dist/contact-manager-api-server.d.ts.map +0 -1
- package/dist/contact-manager-api-server.js +0 -59
- package/dist/contact-manager-api-server.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/types.d.ts +0 -20
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
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
|
+
ContactManagerApiServer: () => ContactManagerApiServer,
|
|
35
|
+
identitiesReadEndpoint: () => identitiesReadEndpoint,
|
|
36
|
+
identityReadEndpoints: () => identityReadEndpoints,
|
|
37
|
+
partiesReadEndpoint: () => partiesReadEndpoint,
|
|
38
|
+
partiesTypeReadEndpoint: () => partiesTypeReadEndpoint,
|
|
39
|
+
partyDeleteEndpoint: () => partyDeleteEndpoint,
|
|
40
|
+
partyReadEndpoint: () => partyReadEndpoint,
|
|
41
|
+
partyTypeReadEndpoint: () => partyTypeReadEndpoint,
|
|
42
|
+
partyWriteEndpoint: () => partyWriteEndpoint
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(index_exports);
|
|
45
|
+
|
|
46
|
+
// src/contact-manager-api-server.ts
|
|
47
|
+
var import_ssi_sdk = require("@sphereon/ssi-sdk.core");
|
|
48
|
+
var import_express = __toESM(require("express"), 1);
|
|
49
|
+
|
|
50
|
+
// src/api-functions.ts
|
|
51
|
+
var import_ssi_express_support = require("@sphereon/ssi-express-support");
|
|
52
|
+
function partiesReadEndpoint(router, context, opts) {
|
|
53
|
+
if (opts?.enabled === false) {
|
|
54
|
+
console.log(`"partiesReadEndpoint" Endpoint is disabled`);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const path = opts?.path ?? "/parties";
|
|
58
|
+
router.get(path, (0, import_ssi_express_support.checkAuth)(opts?.endpoint), async (request, response) => {
|
|
59
|
+
try {
|
|
60
|
+
const parties = await context.agent.cmGetContacts();
|
|
61
|
+
response.statusCode = 200;
|
|
62
|
+
return response.send(parties);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
return (0, import_ssi_express_support.sendErrorResponse)(response, 500, error.message, error);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
__name(partiesReadEndpoint, "partiesReadEndpoint");
|
|
69
|
+
function partyReadEndpoint(router, context, opts) {
|
|
70
|
+
if (opts?.enabled === false) {
|
|
71
|
+
console.log(`"partyReadEndpoint" Endpoint is disabled`);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const path = opts?.path ?? "/parties";
|
|
75
|
+
router.get(`${path}/:partyId`, (0, import_ssi_express_support.checkAuth)(opts?.endpoint), async (request, response) => {
|
|
76
|
+
try {
|
|
77
|
+
const partyId = request.params.partyId;
|
|
78
|
+
const party = await context.agent.cmGetContact({
|
|
79
|
+
contactId: partyId
|
|
80
|
+
});
|
|
81
|
+
response.statusCode = 200;
|
|
82
|
+
return response.send(party);
|
|
83
|
+
} catch (error) {
|
|
84
|
+
return (0, import_ssi_express_support.sendErrorResponse)(response, 500, error.message, error);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
__name(partyReadEndpoint, "partyReadEndpoint");
|
|
89
|
+
function partyWriteEndpoint(router, context, opts) {
|
|
90
|
+
if (opts?.enabled === false) {
|
|
91
|
+
console.log(`"partyWriteEndpoint" Endpoint is disabled`);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const path = opts?.path ?? "/parties";
|
|
95
|
+
router.post(path, async (request, response) => {
|
|
96
|
+
try {
|
|
97
|
+
const addParty = request.body;
|
|
98
|
+
const party = await context.agent.cmAddContact(addParty);
|
|
99
|
+
response.statusCode = 201;
|
|
100
|
+
return response.send(party);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
return (0, import_ssi_express_support.sendErrorResponse)(response, 500, error.message, error);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
__name(partyWriteEndpoint, "partyWriteEndpoint");
|
|
107
|
+
function partyDeleteEndpoint(router, context, opts) {
|
|
108
|
+
if (opts?.enabled === false) {
|
|
109
|
+
console.log(`"partyDeleteEndpoint" Endpoint is disabled`);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const path = opts?.path ?? "/parties";
|
|
113
|
+
router.delete(`${path}/:partyId`, async (request, response) => {
|
|
114
|
+
try {
|
|
115
|
+
const partyId = request.params.partyId;
|
|
116
|
+
const result = await context.agent.cmRemoveContact({
|
|
117
|
+
contactId: partyId
|
|
118
|
+
});
|
|
119
|
+
response.statusCode = 200;
|
|
120
|
+
return response.send(result);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
return (0, import_ssi_express_support.sendErrorResponse)(response, 500, error.message, error);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
__name(partyDeleteEndpoint, "partyDeleteEndpoint");
|
|
127
|
+
function partiesTypeReadEndpoint(router, context, opts) {
|
|
128
|
+
if (opts?.enabled === false) {
|
|
129
|
+
console.log(`"partiesTypeReadEndpoint" Endpoint is disabled`);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const path = opts?.path ?? "/party-types";
|
|
133
|
+
router.get(path, (0, import_ssi_express_support.checkAuth)(opts?.endpoint), async (request, response) => {
|
|
134
|
+
try {
|
|
135
|
+
const partyTypes = await context.agent.cmGetContactTypes();
|
|
136
|
+
response.statusCode = 200;
|
|
137
|
+
return response.send(partyTypes);
|
|
138
|
+
} catch (error) {
|
|
139
|
+
return (0, import_ssi_express_support.sendErrorResponse)(response, 500, error.message, error);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
__name(partiesTypeReadEndpoint, "partiesTypeReadEndpoint");
|
|
144
|
+
function partyTypeReadEndpoint(router, context, opts) {
|
|
145
|
+
if (opts?.enabled === false) {
|
|
146
|
+
console.log(`"partyTypeReadEndpoint" Endpoint is disabled`);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const path = opts?.path ?? "/party-types";
|
|
150
|
+
router.get(`${path}/:partyTypeId`, (0, import_ssi_express_support.checkAuth)(opts?.endpoint), async (request, response) => {
|
|
151
|
+
try {
|
|
152
|
+
const partyTypeId = request.params.partyTypeId;
|
|
153
|
+
const partyType = await context.agent.cmGetContactType({
|
|
154
|
+
contactTypeId: partyTypeId
|
|
155
|
+
});
|
|
156
|
+
response.statusCode = 200;
|
|
157
|
+
return response.send(partyType);
|
|
158
|
+
} catch (error) {
|
|
159
|
+
return (0, import_ssi_express_support.sendErrorResponse)(response, 500, error.message, error);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
__name(partyTypeReadEndpoint, "partyTypeReadEndpoint");
|
|
164
|
+
function identitiesReadEndpoint(router, context, opts) {
|
|
165
|
+
if (opts?.enabled === false) {
|
|
166
|
+
console.log(`"identitiesReadEndpoint" Endpoint is disabled`);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const path = opts?.path ?? "/identities";
|
|
170
|
+
router.get(path, (0, import_ssi_express_support.checkAuth)(opts?.endpoint), async (request, response) => {
|
|
171
|
+
try {
|
|
172
|
+
const identities = await context.agent.cmGetIdentities();
|
|
173
|
+
response.statusCode = 200;
|
|
174
|
+
return response.send(identities);
|
|
175
|
+
} catch (error) {
|
|
176
|
+
return (0, import_ssi_express_support.sendErrorResponse)(response, 500, error.message, error);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
__name(identitiesReadEndpoint, "identitiesReadEndpoint");
|
|
181
|
+
function identityReadEndpoints(router, context, opts) {
|
|
182
|
+
if (opts?.enabled === false) {
|
|
183
|
+
console.log(`"identityReadEndpoints" Endpoint is disabled`);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const path = opts?.path ?? "/identities";
|
|
187
|
+
router.get(`${path}/:identityId`, (0, import_ssi_express_support.checkAuth)(opts?.endpoint), async (request, response) => {
|
|
188
|
+
try {
|
|
189
|
+
const identityId = request.params.identityId;
|
|
190
|
+
const identity = await context.agent.cmGetIdentity({
|
|
191
|
+
identityId
|
|
192
|
+
});
|
|
193
|
+
response.statusCode = 200;
|
|
194
|
+
return response.send(identity);
|
|
195
|
+
} catch (error) {
|
|
196
|
+
return (0, import_ssi_express_support.sendErrorResponse)(response, 500, error.message, error);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
__name(identityReadEndpoints, "identityReadEndpoints");
|
|
201
|
+
|
|
202
|
+
// src/contact-manager-api-server.ts
|
|
203
|
+
var import_ssi_express_support2 = require("@sphereon/ssi-express-support");
|
|
204
|
+
var ContactManagerApiServer = class {
|
|
205
|
+
static {
|
|
206
|
+
__name(this, "ContactManagerApiServer");
|
|
207
|
+
}
|
|
208
|
+
_express;
|
|
209
|
+
_agent;
|
|
210
|
+
_opts;
|
|
211
|
+
_router;
|
|
212
|
+
constructor(args) {
|
|
213
|
+
const { agent, opts } = args;
|
|
214
|
+
this._agent = agent;
|
|
215
|
+
(0, import_ssi_express_support2.copyGlobalAuthToEndpoints)({
|
|
216
|
+
opts,
|
|
217
|
+
keys: [
|
|
218
|
+
"partyRead",
|
|
219
|
+
"partyWrite",
|
|
220
|
+
"partyTypeRead",
|
|
221
|
+
"identityRead"
|
|
222
|
+
]
|
|
223
|
+
});
|
|
224
|
+
if (opts?.endpointOpts?.globalAuth?.secureContactManagerEndpoints) {
|
|
225
|
+
(0, import_ssi_express_support2.copyGlobalAuthToEndpoints)({
|
|
226
|
+
opts,
|
|
227
|
+
keys: [
|
|
228
|
+
"partyRead",
|
|
229
|
+
"partyWrite",
|
|
230
|
+
"partyTypeRead",
|
|
231
|
+
"identityRead"
|
|
232
|
+
]
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
this._opts = opts;
|
|
236
|
+
this._express = args.expressSupport.express;
|
|
237
|
+
this._router = import_express.default.Router();
|
|
238
|
+
const context = (0, import_ssi_sdk.agentContext)(agent);
|
|
239
|
+
const features = opts?.enableFeatures ?? [
|
|
240
|
+
"party_read",
|
|
241
|
+
"party_write",
|
|
242
|
+
"party_type_read",
|
|
243
|
+
"identity_read"
|
|
244
|
+
];
|
|
245
|
+
console.log(`Contact Manager API enabled, with features: ${JSON.stringify(features)}}`);
|
|
246
|
+
if (features.includes("party_read")) {
|
|
247
|
+
partiesReadEndpoint(this.router, context, this._opts?.endpointOpts?.partyRead);
|
|
248
|
+
partyReadEndpoint(this.router, context, this._opts?.endpointOpts?.partyRead);
|
|
249
|
+
}
|
|
250
|
+
if (features.includes("party_write")) {
|
|
251
|
+
partyWriteEndpoint(this.router, context, this._opts?.endpointOpts?.partyWrite);
|
|
252
|
+
partyDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.partyWrite);
|
|
253
|
+
}
|
|
254
|
+
if (features.includes("party_type_read")) {
|
|
255
|
+
partiesTypeReadEndpoint(this.router, context, this._opts?.endpointOpts?.partyTypeRead);
|
|
256
|
+
partyTypeReadEndpoint(this.router, context, this._opts?.endpointOpts?.partyTypeRead);
|
|
257
|
+
}
|
|
258
|
+
if (features.includes("identity_read")) {
|
|
259
|
+
identitiesReadEndpoint(this.router, context, this._opts?.endpointOpts?.identityRead);
|
|
260
|
+
identityReadEndpoints(this.router, context, this._opts?.endpointOpts?.identityRead);
|
|
261
|
+
}
|
|
262
|
+
this._express.use(opts?.endpointOpts?.basePath ?? "", this.router);
|
|
263
|
+
}
|
|
264
|
+
get express() {
|
|
265
|
+
return this._express;
|
|
266
|
+
}
|
|
267
|
+
get router() {
|
|
268
|
+
return this._router;
|
|
269
|
+
}
|
|
270
|
+
get agent() {
|
|
271
|
+
return this._agent;
|
|
272
|
+
}
|
|
273
|
+
get opts() {
|
|
274
|
+
return this._opts;
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/contact-manager-api-server.ts","../src/api-functions.ts"],"sourcesContent":["export * from './types'\nexport * from './contact-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 { IContactManagerAPIEndpointOpts, IRequiredPlugins } from './types'\nimport {\n identityReadEndpoints,\n partiesReadEndpoint,\n partyDeleteEndpoint,\n partyReadEndpoint,\n partiesTypeReadEndpoint,\n partyWriteEndpoint,\n partyTypeReadEndpoint,\n identitiesReadEndpoint,\n} from './api-functions'\nimport { copyGlobalAuthToEndpoints, ExpressSupport } from '@sphereon/ssi-express-support'\n\nexport class ContactManagerApiServer {\n private readonly _express: Express\n private readonly _agent: TAgent<IRequiredPlugins>\n private readonly _opts?: IContactManagerAPIEndpointOpts\n private readonly _router: Router\n\n constructor(args: { agent: TAgent<IRequiredPlugins>; expressSupport: ExpressSupport; opts?: IContactManagerAPIEndpointOpts }) {\n const { agent, opts } = args\n this._agent = agent\n copyGlobalAuthToEndpoints({ opts, keys: ['partyRead', 'partyWrite', 'partyTypeRead', 'identityRead'] })\n if (opts?.endpointOpts?.globalAuth?.secureContactManagerEndpoints) {\n copyGlobalAuthToEndpoints({ opts, keys: ['partyRead', 'partyWrite', 'partyTypeRead', 'identityRead'] })\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 ?? ['party_read', 'party_write', 'party_type_read', 'identity_read']\n console.log(`Contact Manager API enabled, with features: ${JSON.stringify(features)}}`)\n\n // endpoints\n if (features.includes('party_read')) {\n partiesReadEndpoint(this.router, context, this._opts?.endpointOpts?.partyRead)\n partyReadEndpoint(this.router, context, this._opts?.endpointOpts?.partyRead)\n }\n if (features.includes('party_write')) {\n partyWriteEndpoint(this.router, context, this._opts?.endpointOpts?.partyWrite)\n partyDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.partyWrite)\n }\n if (features.includes('party_type_read')) {\n partiesTypeReadEndpoint(this.router, context, this._opts?.endpointOpts?.partyTypeRead)\n partyTypeReadEndpoint(this.router, context, this._opts?.endpointOpts?.partyTypeRead)\n }\n if (features.includes('identity_read')) {\n identitiesReadEndpoint(this.router, context, this._opts?.endpointOpts?.identityRead)\n identityReadEndpoints(this.router, context, this._opts?.endpointOpts?.identityRead)\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 get opts(): IContactManagerAPIEndpointOpts | undefined {\n return this._opts\n }\n}\n","import { checkAuth, sendErrorResponse, ISingleEndpointOpts } from '@sphereon/ssi-express-support'\nimport { Request, Response, Router } from 'express'\nimport { IRequiredContext } from './types'\nimport { AddContactArgs } from '@sphereon/ssi-sdk.contact-manager'\n\nexport function partiesReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"partiesReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/parties'\n router.get(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n // later we will add filter to this\n const parties = await context.agent.cmGetContacts()\n response.statusCode = 200\n return response.send(parties)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function partyReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"partyReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/parties'\n router.get(`${path}/:partyId`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const partyId = request.params.partyId\n const party = await context.agent.cmGetContact({ contactId: partyId })\n response.statusCode = 200\n return response.send(party)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function partyWriteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"partyWriteEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/parties'\n router.post(path, async (request: Request, response: Response) => {\n try {\n const addParty = request.body\n const party = await context.agent.cmAddContact(addParty as AddContactArgs)\n response.statusCode = 201\n return response.send(party)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n\nexport function partyDeleteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"partyDeleteEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/parties'\n router.delete(`${path}/:partyId`, async (request, response) => {\n try {\n const partyId = request.params.partyId\n const result = await context.agent.cmRemoveContact({ contactId: partyId })\n response.statusCode = 200\n return response.send(result)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n\nexport function partiesTypeReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"partiesTypeReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/party-types'\n router.get(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n // later we will add filter to this\n const partyTypes = await context.agent.cmGetContactTypes()\n response.statusCode = 200\n return response.send(partyTypes)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function partyTypeReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"partyTypeReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/party-types'\n router.get(`${path}/:partyTypeId`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const partyTypeId = request.params.partyTypeId\n const partyType = await context.agent.cmGetContactType({ contactTypeId: partyTypeId })\n response.statusCode = 200\n return response.send(partyType)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function identitiesReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"identitiesReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/identities'\n router.get(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n // later we will add filter to this\n const identities = await context.agent.cmGetIdentities()\n response.statusCode = 200\n return response.send(identities)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function identityReadEndpoints(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"identityReadEndpoints\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/identities'\n router.get(`${path}/:identityId`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const identityId = request.params.identityId\n const identity = await context.agent.cmGetIdentity({ identityId })\n response.statusCode = 200\n return response.send(identity)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;ACAA,qBAA6B;AAG7B,qBAAyC;;;ACHzC,iCAAkE;AAK3D,SAASA,oBAAoBC,QAAgBC,SAA2BC,MAA0B;AACvG,MAAIA,MAAMC,YAAY,OAAO;AAC3BC,YAAQC,IAAI,4CAA4C;AACxD;EACF;AACA,QAAMC,OA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N,QAAQV,SAAS,KAAKd,OAAOQ,cAAcuB,aAAAA;AACxEC,4BAAsB,KAAKR,QAAQV,SAAS,KAAKd,OAAOQ,cAAcuB,aAAAA;IACxE;AACA,QAAIf,SAASM,SAAS,eAAA,GAAkB;AACtCW,6BAAuB,KAAKT,QAAQV,SAAS,KAAKd,OAAOQ,cAAc0B,YAAAA;AACvEC,4BAAsB,KAAKX,QAAQV,SAAS,KAAKd,OAAOQ,cAAc0B,YAAAA;IACxE;AACA,SAAKpC,SAASsC,IAAI/B,MAAMG,cAAc6B,YAAY,IAAI,KAAKb,MAAM;EACnE;EAEA,IAAIZ,UAAmB;AACrB,WAAO,KAAKd;EACd;EAEA,IAAI0B,SAAiB;AACnB,WAAO,KAAKvB;EACd;EAEA,IAAIG,QAAkC;AACpC,WAAO,KAAKL;EACd;EACA,IAAIM,OAAmD;AACrD,WAAO,KAAKL;EACd;AACF;","names":["partiesReadEndpoint","router","context","opts","enabled","console","log","path","get","checkAuth","endpoint","request","response","parties","agent","cmGetContacts","statusCode","send","error","sendErrorResponse","message","partyReadEndpoint","partyId","params","party","cmGetContact","contactId","partyWriteEndpoint","post","addParty","body","cmAddContact","partyDeleteEndpoint","delete","result","cmRemoveContact","partiesTypeReadEndpoint","partyTypes","cmGetContactTypes","partyTypeReadEndpoint","partyTypeId","partyType","cmGetContactType","contactTypeId","identitiesReadEndpoint","identities","cmGetIdentities","identityReadEndpoints","identityId","identity","cmGetIdentity","import_ssi_express_support","ContactManagerApiServer","_express","_agent","_opts","_router","constructor","args","agent","opts","copyGlobalAuthToEndpoints","keys","endpointOpts","globalAuth","secureContactManagerEndpoints","expressSupport","express","Router","context","agentContext","features","enableFeatures","console","log","JSON","stringify","includes","partiesReadEndpoint","router","partyRead","partyReadEndpoint","partyWriteEndpoint","partyWrite","partyDeleteEndpoint","partiesTypeReadEndpoint","partyTypeRead","partyTypeReadEndpoint","identitiesReadEndpoint","identityRead","identityReadEndpoints","use","basePath"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { GenericAuthArgs, ISingleEndpointOpts, ExpressSupport } from '@sphereon/ssi-express-support';
|
|
2
|
+
import { IContactManager } from '@sphereon/ssi-sdk.contact-manager';
|
|
3
|
+
import { IKeyManager, IDIDManager, IAgentContext, TAgent } from '@veramo/core';
|
|
4
|
+
import { Express, Router } from 'express';
|
|
5
|
+
|
|
6
|
+
type ContactManagerMRestApiFeatures = 'party_read' | 'party_write' | 'party_type_read' | 'identity_read';
|
|
7
|
+
interface IContactManagerAPIEndpointOpts {
|
|
8
|
+
endpointOpts?: {
|
|
9
|
+
basePath?: string;
|
|
10
|
+
globalAuth?: GenericAuthArgs & {
|
|
11
|
+
secureContactManagerEndpoints?: boolean;
|
|
12
|
+
};
|
|
13
|
+
partyRead?: ISingleEndpointOpts;
|
|
14
|
+
partyWrite?: ISingleEndpointOpts;
|
|
15
|
+
partyTypeRead?: ISingleEndpointOpts;
|
|
16
|
+
identityRead?: ISingleEndpointOpts;
|
|
17
|
+
};
|
|
18
|
+
enableFeatures?: ContactManagerMRestApiFeatures[];
|
|
19
|
+
}
|
|
20
|
+
type IRequiredPlugins = IContactManager & IKeyManager & IDIDManager;
|
|
21
|
+
type IRequiredContext = IAgentContext<IRequiredPlugins>;
|
|
22
|
+
|
|
23
|
+
declare class ContactManagerApiServer {
|
|
24
|
+
private readonly _express;
|
|
25
|
+
private readonly _agent;
|
|
26
|
+
private readonly _opts?;
|
|
27
|
+
private readonly _router;
|
|
28
|
+
constructor(args: {
|
|
29
|
+
agent: TAgent<IRequiredPlugins>;
|
|
30
|
+
expressSupport: ExpressSupport;
|
|
31
|
+
opts?: IContactManagerAPIEndpointOpts;
|
|
32
|
+
});
|
|
33
|
+
get express(): Express;
|
|
34
|
+
get router(): Router;
|
|
35
|
+
get agent(): TAgent<IRequiredPlugins>;
|
|
36
|
+
get opts(): IContactManagerAPIEndpointOpts | undefined;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare function partiesReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
40
|
+
declare function partyReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
41
|
+
declare function partyWriteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
42
|
+
declare function partyDeleteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
43
|
+
declare function partiesTypeReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
44
|
+
declare function partyTypeReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
45
|
+
declare function identitiesReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
46
|
+
declare function identityReadEndpoints(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
47
|
+
|
|
48
|
+
export { ContactManagerApiServer, type ContactManagerMRestApiFeatures, type IContactManagerAPIEndpointOpts, type IRequiredContext, type IRequiredPlugins, identitiesReadEndpoint, identityReadEndpoints, partiesReadEndpoint, partiesTypeReadEndpoint, partyDeleteEndpoint, partyReadEndpoint, partyTypeReadEndpoint, partyWriteEndpoint };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { GenericAuthArgs, ISingleEndpointOpts, ExpressSupport } from '@sphereon/ssi-express-support';
|
|
2
|
+
import { IContactManager } from '@sphereon/ssi-sdk.contact-manager';
|
|
3
|
+
import { IKeyManager, IDIDManager, IAgentContext, TAgent } from '@veramo/core';
|
|
4
|
+
import { Express, Router } from 'express';
|
|
5
|
+
|
|
6
|
+
type ContactManagerMRestApiFeatures = 'party_read' | 'party_write' | 'party_type_read' | 'identity_read';
|
|
7
|
+
interface IContactManagerAPIEndpointOpts {
|
|
8
|
+
endpointOpts?: {
|
|
9
|
+
basePath?: string;
|
|
10
|
+
globalAuth?: GenericAuthArgs & {
|
|
11
|
+
secureContactManagerEndpoints?: boolean;
|
|
12
|
+
};
|
|
13
|
+
partyRead?: ISingleEndpointOpts;
|
|
14
|
+
partyWrite?: ISingleEndpointOpts;
|
|
15
|
+
partyTypeRead?: ISingleEndpointOpts;
|
|
16
|
+
identityRead?: ISingleEndpointOpts;
|
|
17
|
+
};
|
|
18
|
+
enableFeatures?: ContactManagerMRestApiFeatures[];
|
|
19
|
+
}
|
|
20
|
+
type IRequiredPlugins = IContactManager & IKeyManager & IDIDManager;
|
|
21
|
+
type IRequiredContext = IAgentContext<IRequiredPlugins>;
|
|
22
|
+
|
|
23
|
+
declare class ContactManagerApiServer {
|
|
24
|
+
private readonly _express;
|
|
25
|
+
private readonly _agent;
|
|
26
|
+
private readonly _opts?;
|
|
27
|
+
private readonly _router;
|
|
28
|
+
constructor(args: {
|
|
29
|
+
agent: TAgent<IRequiredPlugins>;
|
|
30
|
+
expressSupport: ExpressSupport;
|
|
31
|
+
opts?: IContactManagerAPIEndpointOpts;
|
|
32
|
+
});
|
|
33
|
+
get express(): Express;
|
|
34
|
+
get router(): Router;
|
|
35
|
+
get agent(): TAgent<IRequiredPlugins>;
|
|
36
|
+
get opts(): IContactManagerAPIEndpointOpts | undefined;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare function partiesReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
40
|
+
declare function partyReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
41
|
+
declare function partyWriteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
42
|
+
declare function partyDeleteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
43
|
+
declare function partiesTypeReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
44
|
+
declare function partyTypeReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
45
|
+
declare function identitiesReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
46
|
+
declare function identityReadEndpoints(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
47
|
+
|
|
48
|
+
export { ContactManagerApiServer, type ContactManagerMRestApiFeatures, type IContactManagerAPIEndpointOpts, type IRequiredContext, type IRequiredPlugins, identitiesReadEndpoint, identityReadEndpoints, partiesReadEndpoint, partiesTypeReadEndpoint, partyDeleteEndpoint, partyReadEndpoint, partyTypeReadEndpoint, partyWriteEndpoint };
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,246 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/contact-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
|
+
function partiesReadEndpoint(router, context, opts) {
|
|
11
|
+
if (opts?.enabled === false) {
|
|
12
|
+
console.log(`"partiesReadEndpoint" Endpoint is disabled`);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const path = opts?.path ?? "/parties";
|
|
16
|
+
router.get(path, checkAuth(opts?.endpoint), async (request, response) => {
|
|
17
|
+
try {
|
|
18
|
+
const parties = await context.agent.cmGetContacts();
|
|
19
|
+
response.statusCode = 200;
|
|
20
|
+
return response.send(parties);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
return sendErrorResponse(response, 500, error.message, error);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
__name(partiesReadEndpoint, "partiesReadEndpoint");
|
|
27
|
+
function partyReadEndpoint(router, context, opts) {
|
|
28
|
+
if (opts?.enabled === false) {
|
|
29
|
+
console.log(`"partyReadEndpoint" Endpoint is disabled`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const path = opts?.path ?? "/parties";
|
|
33
|
+
router.get(`${path}/:partyId`, checkAuth(opts?.endpoint), async (request, response) => {
|
|
34
|
+
try {
|
|
35
|
+
const partyId = request.params.partyId;
|
|
36
|
+
const party = await context.agent.cmGetContact({
|
|
37
|
+
contactId: partyId
|
|
38
|
+
});
|
|
39
|
+
response.statusCode = 200;
|
|
40
|
+
return response.send(party);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
return sendErrorResponse(response, 500, error.message, error);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
__name(partyReadEndpoint, "partyReadEndpoint");
|
|
47
|
+
function partyWriteEndpoint(router, context, opts) {
|
|
48
|
+
if (opts?.enabled === false) {
|
|
49
|
+
console.log(`"partyWriteEndpoint" Endpoint is disabled`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const path = opts?.path ?? "/parties";
|
|
53
|
+
router.post(path, async (request, response) => {
|
|
54
|
+
try {
|
|
55
|
+
const addParty = request.body;
|
|
56
|
+
const party = await context.agent.cmAddContact(addParty);
|
|
57
|
+
response.statusCode = 201;
|
|
58
|
+
return response.send(party);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
return sendErrorResponse(response, 500, error.message, error);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
__name(partyWriteEndpoint, "partyWriteEndpoint");
|
|
65
|
+
function partyDeleteEndpoint(router, context, opts) {
|
|
66
|
+
if (opts?.enabled === false) {
|
|
67
|
+
console.log(`"partyDeleteEndpoint" Endpoint is disabled`);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const path = opts?.path ?? "/parties";
|
|
71
|
+
router.delete(`${path}/:partyId`, async (request, response) => {
|
|
72
|
+
try {
|
|
73
|
+
const partyId = request.params.partyId;
|
|
74
|
+
const result = await context.agent.cmRemoveContact({
|
|
75
|
+
contactId: partyId
|
|
76
|
+
});
|
|
77
|
+
response.statusCode = 200;
|
|
78
|
+
return response.send(result);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
return sendErrorResponse(response, 500, error.message, error);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
__name(partyDeleteEndpoint, "partyDeleteEndpoint");
|
|
85
|
+
function partiesTypeReadEndpoint(router, context, opts) {
|
|
86
|
+
if (opts?.enabled === false) {
|
|
87
|
+
console.log(`"partiesTypeReadEndpoint" Endpoint is disabled`);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const path = opts?.path ?? "/party-types";
|
|
91
|
+
router.get(path, checkAuth(opts?.endpoint), async (request, response) => {
|
|
92
|
+
try {
|
|
93
|
+
const partyTypes = await context.agent.cmGetContactTypes();
|
|
94
|
+
response.statusCode = 200;
|
|
95
|
+
return response.send(partyTypes);
|
|
96
|
+
} catch (error) {
|
|
97
|
+
return sendErrorResponse(response, 500, error.message, error);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
__name(partiesTypeReadEndpoint, "partiesTypeReadEndpoint");
|
|
102
|
+
function partyTypeReadEndpoint(router, context, opts) {
|
|
103
|
+
if (opts?.enabled === false) {
|
|
104
|
+
console.log(`"partyTypeReadEndpoint" Endpoint is disabled`);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const path = opts?.path ?? "/party-types";
|
|
108
|
+
router.get(`${path}/:partyTypeId`, checkAuth(opts?.endpoint), async (request, response) => {
|
|
109
|
+
try {
|
|
110
|
+
const partyTypeId = request.params.partyTypeId;
|
|
111
|
+
const partyType = await context.agent.cmGetContactType({
|
|
112
|
+
contactTypeId: partyTypeId
|
|
113
|
+
});
|
|
114
|
+
response.statusCode = 200;
|
|
115
|
+
return response.send(partyType);
|
|
116
|
+
} catch (error) {
|
|
117
|
+
return sendErrorResponse(response, 500, error.message, error);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
__name(partyTypeReadEndpoint, "partyTypeReadEndpoint");
|
|
122
|
+
function identitiesReadEndpoint(router, context, opts) {
|
|
123
|
+
if (opts?.enabled === false) {
|
|
124
|
+
console.log(`"identitiesReadEndpoint" Endpoint is disabled`);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const path = opts?.path ?? "/identities";
|
|
128
|
+
router.get(path, checkAuth(opts?.endpoint), async (request, response) => {
|
|
129
|
+
try {
|
|
130
|
+
const identities = await context.agent.cmGetIdentities();
|
|
131
|
+
response.statusCode = 200;
|
|
132
|
+
return response.send(identities);
|
|
133
|
+
} catch (error) {
|
|
134
|
+
return sendErrorResponse(response, 500, error.message, error);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
__name(identitiesReadEndpoint, "identitiesReadEndpoint");
|
|
139
|
+
function identityReadEndpoints(router, context, opts) {
|
|
140
|
+
if (opts?.enabled === false) {
|
|
141
|
+
console.log(`"identityReadEndpoints" Endpoint is disabled`);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const path = opts?.path ?? "/identities";
|
|
145
|
+
router.get(`${path}/:identityId`, checkAuth(opts?.endpoint), async (request, response) => {
|
|
146
|
+
try {
|
|
147
|
+
const identityId = request.params.identityId;
|
|
148
|
+
const identity = await context.agent.cmGetIdentity({
|
|
149
|
+
identityId
|
|
150
|
+
});
|
|
151
|
+
response.statusCode = 200;
|
|
152
|
+
return response.send(identity);
|
|
153
|
+
} catch (error) {
|
|
154
|
+
return sendErrorResponse(response, 500, error.message, error);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
__name(identityReadEndpoints, "identityReadEndpoints");
|
|
159
|
+
|
|
160
|
+
// src/contact-manager-api-server.ts
|
|
161
|
+
import { copyGlobalAuthToEndpoints } from "@sphereon/ssi-express-support";
|
|
162
|
+
var ContactManagerApiServer = class {
|
|
163
|
+
static {
|
|
164
|
+
__name(this, "ContactManagerApiServer");
|
|
165
|
+
}
|
|
166
|
+
_express;
|
|
167
|
+
_agent;
|
|
168
|
+
_opts;
|
|
169
|
+
_router;
|
|
170
|
+
constructor(args) {
|
|
171
|
+
const { agent, opts } = args;
|
|
172
|
+
this._agent = agent;
|
|
173
|
+
copyGlobalAuthToEndpoints({
|
|
174
|
+
opts,
|
|
175
|
+
keys: [
|
|
176
|
+
"partyRead",
|
|
177
|
+
"partyWrite",
|
|
178
|
+
"partyTypeRead",
|
|
179
|
+
"identityRead"
|
|
180
|
+
]
|
|
181
|
+
});
|
|
182
|
+
if (opts?.endpointOpts?.globalAuth?.secureContactManagerEndpoints) {
|
|
183
|
+
copyGlobalAuthToEndpoints({
|
|
184
|
+
opts,
|
|
185
|
+
keys: [
|
|
186
|
+
"partyRead",
|
|
187
|
+
"partyWrite",
|
|
188
|
+
"partyTypeRead",
|
|
189
|
+
"identityRead"
|
|
190
|
+
]
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
this._opts = opts;
|
|
194
|
+
this._express = args.expressSupport.express;
|
|
195
|
+
this._router = express.Router();
|
|
196
|
+
const context = agentContext(agent);
|
|
197
|
+
const features = opts?.enableFeatures ?? [
|
|
198
|
+
"party_read",
|
|
199
|
+
"party_write",
|
|
200
|
+
"party_type_read",
|
|
201
|
+
"identity_read"
|
|
202
|
+
];
|
|
203
|
+
console.log(`Contact Manager API enabled, with features: ${JSON.stringify(features)}}`);
|
|
204
|
+
if (features.includes("party_read")) {
|
|
205
|
+
partiesReadEndpoint(this.router, context, this._opts?.endpointOpts?.partyRead);
|
|
206
|
+
partyReadEndpoint(this.router, context, this._opts?.endpointOpts?.partyRead);
|
|
207
|
+
}
|
|
208
|
+
if (features.includes("party_write")) {
|
|
209
|
+
partyWriteEndpoint(this.router, context, this._opts?.endpointOpts?.partyWrite);
|
|
210
|
+
partyDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.partyWrite);
|
|
211
|
+
}
|
|
212
|
+
if (features.includes("party_type_read")) {
|
|
213
|
+
partiesTypeReadEndpoint(this.router, context, this._opts?.endpointOpts?.partyTypeRead);
|
|
214
|
+
partyTypeReadEndpoint(this.router, context, this._opts?.endpointOpts?.partyTypeRead);
|
|
215
|
+
}
|
|
216
|
+
if (features.includes("identity_read")) {
|
|
217
|
+
identitiesReadEndpoint(this.router, context, this._opts?.endpointOpts?.identityRead);
|
|
218
|
+
identityReadEndpoints(this.router, context, this._opts?.endpointOpts?.identityRead);
|
|
219
|
+
}
|
|
220
|
+
this._express.use(opts?.endpointOpts?.basePath ?? "", this.router);
|
|
221
|
+
}
|
|
222
|
+
get express() {
|
|
223
|
+
return this._express;
|
|
224
|
+
}
|
|
225
|
+
get router() {
|
|
226
|
+
return this._router;
|
|
227
|
+
}
|
|
228
|
+
get agent() {
|
|
229
|
+
return this._agent;
|
|
230
|
+
}
|
|
231
|
+
get opts() {
|
|
232
|
+
return this._opts;
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
export {
|
|
236
|
+
ContactManagerApiServer,
|
|
237
|
+
identitiesReadEndpoint,
|
|
238
|
+
identityReadEndpoints,
|
|
239
|
+
partiesReadEndpoint,
|
|
240
|
+
partiesTypeReadEndpoint,
|
|
241
|
+
partyDeleteEndpoint,
|
|
242
|
+
partyReadEndpoint,
|
|
243
|
+
partyTypeReadEndpoint,
|
|
244
|
+
partyWriteEndpoint
|
|
15
245
|
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./types"), exports);
|
|
18
|
-
__exportStar(require("./contact-manager-api-server"), exports);
|
|
19
|
-
__exportStar(require("./api-functions"), exports);
|
|
20
246
|
//# 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,0CAAuB;AACvB,+DAA4C;AAC5C,kDAA+B"}
|
|
1
|
+
{"version":3,"sources":["../src/contact-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 { IContactManagerAPIEndpointOpts, IRequiredPlugins } from './types'\nimport {\n identityReadEndpoints,\n partiesReadEndpoint,\n partyDeleteEndpoint,\n partyReadEndpoint,\n partiesTypeReadEndpoint,\n partyWriteEndpoint,\n partyTypeReadEndpoint,\n identitiesReadEndpoint,\n} from './api-functions'\nimport { copyGlobalAuthToEndpoints, ExpressSupport } from '@sphereon/ssi-express-support'\n\nexport class ContactManagerApiServer {\n private readonly _express: Express\n private readonly _agent: TAgent<IRequiredPlugins>\n private readonly _opts?: IContactManagerAPIEndpointOpts\n private readonly _router: Router\n\n constructor(args: { agent: TAgent<IRequiredPlugins>; expressSupport: ExpressSupport; opts?: IContactManagerAPIEndpointOpts }) {\n const { agent, opts } = args\n this._agent = agent\n copyGlobalAuthToEndpoints({ opts, keys: ['partyRead', 'partyWrite', 'partyTypeRead', 'identityRead'] })\n if (opts?.endpointOpts?.globalAuth?.secureContactManagerEndpoints) {\n copyGlobalAuthToEndpoints({ opts, keys: ['partyRead', 'partyWrite', 'partyTypeRead', 'identityRead'] })\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 ?? ['party_read', 'party_write', 'party_type_read', 'identity_read']\n console.log(`Contact Manager API enabled, with features: ${JSON.stringify(features)}}`)\n\n // endpoints\n if (features.includes('party_read')) {\n partiesReadEndpoint(this.router, context, this._opts?.endpointOpts?.partyRead)\n partyReadEndpoint(this.router, context, this._opts?.endpointOpts?.partyRead)\n }\n if (features.includes('party_write')) {\n partyWriteEndpoint(this.router, context, this._opts?.endpointOpts?.partyWrite)\n partyDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.partyWrite)\n }\n if (features.includes('party_type_read')) {\n partiesTypeReadEndpoint(this.router, context, this._opts?.endpointOpts?.partyTypeRead)\n partyTypeReadEndpoint(this.router, context, this._opts?.endpointOpts?.partyTypeRead)\n }\n if (features.includes('identity_read')) {\n identitiesReadEndpoint(this.router, context, this._opts?.endpointOpts?.identityRead)\n identityReadEndpoints(this.router, context, this._opts?.endpointOpts?.identityRead)\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 get opts(): IContactManagerAPIEndpointOpts | undefined {\n return this._opts\n }\n}\n","import { checkAuth, sendErrorResponse, ISingleEndpointOpts } from '@sphereon/ssi-express-support'\nimport { Request, Response, Router } from 'express'\nimport { IRequiredContext } from './types'\nimport { AddContactArgs } from '@sphereon/ssi-sdk.contact-manager'\n\nexport function partiesReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"partiesReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/parties'\n router.get(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n // later we will add filter to this\n const parties = await context.agent.cmGetContacts()\n response.statusCode = 200\n return response.send(parties)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function partyReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"partyReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/parties'\n router.get(`${path}/:partyId`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const partyId = request.params.partyId\n const party = await context.agent.cmGetContact({ contactId: partyId })\n response.statusCode = 200\n return response.send(party)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function partyWriteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"partyWriteEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/parties'\n router.post(path, async (request: Request, response: Response) => {\n try {\n const addParty = request.body\n const party = await context.agent.cmAddContact(addParty as AddContactArgs)\n response.statusCode = 201\n return response.send(party)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n\nexport function partyDeleteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"partyDeleteEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/parties'\n router.delete(`${path}/:partyId`, async (request, response) => {\n try {\n const partyId = request.params.partyId\n const result = await context.agent.cmRemoveContact({ contactId: partyId })\n response.statusCode = 200\n return response.send(result)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message, error)\n }\n })\n}\n\nexport function partiesTypeReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"partiesTypeReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/party-types'\n router.get(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n // later we will add filter to this\n const partyTypes = await context.agent.cmGetContactTypes()\n response.statusCode = 200\n return response.send(partyTypes)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function partyTypeReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"partyTypeReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/party-types'\n router.get(`${path}/:partyTypeId`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const partyTypeId = request.params.partyTypeId\n const partyType = await context.agent.cmGetContactType({ contactTypeId: partyTypeId })\n response.statusCode = 200\n return response.send(partyType)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function identitiesReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"identitiesReadEndpoint\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/identities'\n router.get(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n // later we will add filter to this\n const identities = await context.agent.cmGetIdentities()\n response.statusCode = 200\n return response.send(identities)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n\nexport function identityReadEndpoints(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`\"identityReadEndpoints\" Endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/identities'\n router.get(`${path}/:identityId`, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const identityId = request.params.identityId\n const identity = await context.agent.cmGetIdentity({ identityId })\n response.statusCode = 200\n return response.send(identity)\n } catch (error) {\n return sendErrorResponse(response, 500, error.message as string, error)\n }\n })\n}\n"],"mappings":";;;;AAAA,SAASA,oBAAoB;AAG7B,OAAOC,aAAkC;;;ACHzC,SAASC,WAAWC,yBAA8C;AAK3D,SAASC,oBAAoBC,QAAgBC,SAA2BC,MAA0B;AACvG,MAAIA,MAAMC,YAAY,OAAO;AAC3BC,YAAQC,IAAI,4CAA4C;AACxD;EACF;AACA,QAAMC,OAAOJ,MAAMI,QAAQ;AAC3BN,SAAOO,IAAID,MAAME,UAAUN,MAAMO,QAAAA,GAAW,OAAOC,SAAkBC,aAAAA;AACnE,QAAI;AAEF,YAAMC,UAAU,MAAMX,QAAQY,MAAMC,cAAa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QV,SAAS,KAAKd,OAAOQ,cAAc0B,YAAAA;AACvEC,4BAAsB,KAAKX,QAAQV,SAAS,KAAKd,OAAOQ,cAAc0B,YAAAA;IACxE;AACA,SAAKpC,SAASsC,IAAI/B,MAAMG,cAAc6B,YAAY,IAAI,KAAKb,MAAM;EACnE;EAEA,IAAIZ,UAAmB;AACrB,WAAO,KAAKd;EACd;EAEA,IAAI0B,SAAiB;AACnB,WAAO,KAAKvB;EACd;EAEA,IAAIG,QAAkC;AACpC,WAAO,KAAKL;EACd;EACA,IAAIM,OAAmD;AACrD,WAAO,KAAKL;EACd;AACF;","names":["agentContext","express","checkAuth","sendErrorResponse","partiesReadEndpoint","router","context","opts","enabled","console","log","path","get","checkAuth","endpoint","request","response","parties","agent","cmGetContacts","statusCode","send","error","sendErrorResponse","message","partyReadEndpoint","partyId","params","party","cmGetContact","contactId","partyWriteEndpoint","post","addParty","body","cmAddContact","partyDeleteEndpoint","delete","result","cmRemoveContact","partiesTypeReadEndpoint","partyTypes","cmGetContactTypes","partyTypeReadEndpoint","partyTypeId","partyType","cmGetContactType","contactTypeId","identitiesReadEndpoint","identities","cmGetIdentities","identityReadEndpoints","identityId","identity","cmGetIdentity","copyGlobalAuthToEndpoints","ContactManagerApiServer","_express","_agent","_opts","_router","constructor","args","agent","opts","copyGlobalAuthToEndpoints","keys","endpointOpts","globalAuth","secureContactManagerEndpoints","expressSupport","express","Router","context","agentContext","features","enableFeatures","console","log","JSON","stringify","includes","partiesReadEndpoint","router","partyRead","partyReadEndpoint","partyWriteEndpoint","partyWrite","partyDeleteEndpoint","partiesTypeReadEndpoint","partyTypeRead","partyTypeReadEndpoint","identitiesReadEndpoint","identityRead","identityReadEndpoints","use","basePath"]}
|
package/package.json
CHANGED
|
@@ -1,24 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.contact-manager-rest-api",
|
|
3
|
-
"version": "0.33.1-next.
|
|
3
|
+
"version": "0.33.1-next.73+be17b2cb",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
"react-native": "./dist/index.js",
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/index.d.cts",
|
|
17
|
+
"require": "./dist/index.cjs"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
7
20
|
"scripts": {
|
|
8
|
-
"build": "
|
|
9
|
-
"build:clean": "tsc --build --clean && tsc --build",
|
|
21
|
+
"build": "tsup --config ../../tsup.config.ts --tsconfig ../../tsconfig.tsup.json",
|
|
10
22
|
"start:prod": "node build/index.js",
|
|
11
23
|
"start:dev": "ts-node __tests__/RestAPI.ts"
|
|
12
24
|
},
|
|
13
25
|
"dependencies": {
|
|
14
|
-
"@sphereon/ssi-express-support": "0.33.1-next.
|
|
15
|
-
"@sphereon/ssi-sdk-ext.key-manager": "0.28.
|
|
16
|
-
"@sphereon/ssi-sdk-ext.key-utils": "0.28.
|
|
17
|
-
"@sphereon/ssi-sdk.contact-manager": "0.33.1-next.
|
|
18
|
-
"@sphereon/ssi-sdk.core": "0.33.1-next.
|
|
19
|
-
"@sphereon/ssi-sdk.data-store": "0.33.1-next.
|
|
20
|
-
"@sphereon/ssi-sdk.kv-store-temp": "0.33.1-next.
|
|
21
|
-
"@sphereon/ssi-types": "0.33.1-next.
|
|
26
|
+
"@sphereon/ssi-express-support": "0.33.1-next.73+be17b2cb",
|
|
27
|
+
"@sphereon/ssi-sdk-ext.key-manager": "0.28.1-next.53",
|
|
28
|
+
"@sphereon/ssi-sdk-ext.key-utils": "0.28.1-next.53",
|
|
29
|
+
"@sphereon/ssi-sdk.contact-manager": "0.33.1-next.73+be17b2cb",
|
|
30
|
+
"@sphereon/ssi-sdk.core": "0.33.1-next.73+be17b2cb",
|
|
31
|
+
"@sphereon/ssi-sdk.data-store": "0.33.1-next.73+be17b2cb",
|
|
32
|
+
"@sphereon/ssi-sdk.kv-store-temp": "0.33.1-next.73+be17b2cb",
|
|
33
|
+
"@sphereon/ssi-types": "0.33.1-next.73+be17b2cb",
|
|
22
34
|
"@veramo/core": "4.2.0",
|
|
23
35
|
"body-parser": "^1.20.2",
|
|
24
36
|
"casbin": "^5.30.0",
|
|
@@ -33,7 +45,7 @@
|
|
|
33
45
|
},
|
|
34
46
|
"devDependencies": {
|
|
35
47
|
"@decentralized-identity/ion-sdk": "^0.6.0",
|
|
36
|
-
"@sphereon/ssi-sdk.agent-config": "0.33.1-next.
|
|
48
|
+
"@sphereon/ssi-sdk.agent-config": "0.33.1-next.73+be17b2cb",
|
|
37
49
|
"@types/body-parser": "^1.19.5",
|
|
38
50
|
"@types/cookie-parser": "^1.4.7",
|
|
39
51
|
"@types/cors": "^2.8.17",
|
|
@@ -57,11 +69,11 @@
|
|
|
57
69
|
"passport": "^0.6.0",
|
|
58
70
|
"passport-http-bearer": "^1.0.1",
|
|
59
71
|
"ts-node": "^10.9.2",
|
|
60
|
-
"typeorm": "
|
|
72
|
+
"typeorm": "0.3.20"
|
|
61
73
|
},
|
|
62
74
|
"files": [
|
|
63
|
-
"dist
|
|
64
|
-
"src
|
|
75
|
+
"dist",
|
|
76
|
+
"src",
|
|
65
77
|
"README.md",
|
|
66
78
|
"LICENSE"
|
|
67
79
|
],
|
|
@@ -80,6 +92,5 @@
|
|
|
80
92
|
"REST",
|
|
81
93
|
"API"
|
|
82
94
|
],
|
|
83
|
-
"
|
|
84
|
-
"gitHead": "fd1a6fba306a83a73ff7c531db87fa207dbf436d"
|
|
95
|
+
"gitHead": "be17b2cb752a6e5368119259e89a1f2a99f56848"
|
|
85
96
|
}
|
package/dist/api-functions.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ISingleEndpointOpts } from '@sphereon/ssi-express-support';
|
|
2
|
-
import { Router } from 'express';
|
|
3
|
-
import { IRequiredContext } from './types';
|
|
4
|
-
export declare function partiesReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
5
|
-
export declare function partyReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
6
|
-
export declare function partyWriteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
7
|
-
export declare function partyDeleteEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
8
|
-
export declare function partiesTypeReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
9
|
-
export declare function partyTypeReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
10
|
-
export declare function identitiesReadEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
11
|
-
export declare function identityReadEndpoints(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
12
|
-
//# 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,EAAgC,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AACjG,OAAO,EAAqB,MAAM,EAAE,MAAM,SAAS,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAG1C,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,mBAAmB,QAgBxG;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,mBAAmB,QAgBtG;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,mBAAmB,QAgBvG;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,mBAAmB,QAgBxG;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,mBAAmB,QAgB5G;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,mBAAmB,QAgB1G;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,mBAAmB,QAgB3G;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,mBAAmB,QAgB1G"}
|
package/dist/api-functions.js
DELETED
|
@@ -1,173 +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.partiesReadEndpoint = partiesReadEndpoint;
|
|
13
|
-
exports.partyReadEndpoint = partyReadEndpoint;
|
|
14
|
-
exports.partyWriteEndpoint = partyWriteEndpoint;
|
|
15
|
-
exports.partyDeleteEndpoint = partyDeleteEndpoint;
|
|
16
|
-
exports.partiesTypeReadEndpoint = partiesTypeReadEndpoint;
|
|
17
|
-
exports.partyTypeReadEndpoint = partyTypeReadEndpoint;
|
|
18
|
-
exports.identitiesReadEndpoint = identitiesReadEndpoint;
|
|
19
|
-
exports.identityReadEndpoints = identityReadEndpoints;
|
|
20
|
-
const ssi_express_support_1 = require("@sphereon/ssi-express-support");
|
|
21
|
-
function partiesReadEndpoint(router, context, opts) {
|
|
22
|
-
var _a;
|
|
23
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
24
|
-
console.log(`"partiesReadEndpoint" Endpoint is disabled`);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const path = (_a = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _a !== void 0 ? _a : '/parties';
|
|
28
|
-
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* () {
|
|
29
|
-
try {
|
|
30
|
-
// later we will add filter to this
|
|
31
|
-
const parties = yield context.agent.cmGetContacts();
|
|
32
|
-
response.statusCode = 200;
|
|
33
|
-
return response.send(parties);
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
return (0, ssi_express_support_1.sendErrorResponse)(response, 500, error.message, error);
|
|
37
|
-
}
|
|
38
|
-
}));
|
|
39
|
-
}
|
|
40
|
-
function partyReadEndpoint(router, context, opts) {
|
|
41
|
-
var _a;
|
|
42
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
43
|
-
console.log(`"partyReadEndpoint" Endpoint is disabled`);
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const path = (_a = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _a !== void 0 ? _a : '/parties';
|
|
47
|
-
router.get(`${path}/:partyId`, (0, ssi_express_support_1.checkAuth)(opts === null || opts === void 0 ? void 0 : opts.endpoint), (request, response) => __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
try {
|
|
49
|
-
const partyId = request.params.partyId;
|
|
50
|
-
const party = yield context.agent.cmGetContact({ contactId: partyId });
|
|
51
|
-
response.statusCode = 200;
|
|
52
|
-
return response.send(party);
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
return (0, ssi_express_support_1.sendErrorResponse)(response, 500, error.message, error);
|
|
56
|
-
}
|
|
57
|
-
}));
|
|
58
|
-
}
|
|
59
|
-
function partyWriteEndpoint(router, context, opts) {
|
|
60
|
-
var _a;
|
|
61
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
62
|
-
console.log(`"partyWriteEndpoint" Endpoint is disabled`);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const path = (_a = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _a !== void 0 ? _a : '/parties';
|
|
66
|
-
router.post(path, (request, response) => __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
try {
|
|
68
|
-
const addParty = request.body;
|
|
69
|
-
const party = yield context.agent.cmAddContact(addParty);
|
|
70
|
-
response.statusCode = 201;
|
|
71
|
-
return response.send(party);
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
return (0, ssi_express_support_1.sendErrorResponse)(response, 500, error.message, error);
|
|
75
|
-
}
|
|
76
|
-
}));
|
|
77
|
-
}
|
|
78
|
-
function partyDeleteEndpoint(router, context, opts) {
|
|
79
|
-
var _a;
|
|
80
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
81
|
-
console.log(`"partyDeleteEndpoint" Endpoint is disabled`);
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
const path = (_a = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _a !== void 0 ? _a : '/parties';
|
|
85
|
-
router.delete(`${path}/:partyId`, (request, response) => __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
try {
|
|
87
|
-
const partyId = request.params.partyId;
|
|
88
|
-
const result = yield context.agent.cmRemoveContact({ contactId: partyId });
|
|
89
|
-
response.statusCode = 200;
|
|
90
|
-
return response.send(result);
|
|
91
|
-
}
|
|
92
|
-
catch (error) {
|
|
93
|
-
return (0, ssi_express_support_1.sendErrorResponse)(response, 500, error.message, error);
|
|
94
|
-
}
|
|
95
|
-
}));
|
|
96
|
-
}
|
|
97
|
-
function partiesTypeReadEndpoint(router, context, opts) {
|
|
98
|
-
var _a;
|
|
99
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
100
|
-
console.log(`"partiesTypeReadEndpoint" Endpoint is disabled`);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
const path = (_a = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _a !== void 0 ? _a : '/party-types';
|
|
104
|
-
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* () {
|
|
105
|
-
try {
|
|
106
|
-
// later we will add filter to this
|
|
107
|
-
const partyTypes = yield context.agent.cmGetContactTypes();
|
|
108
|
-
response.statusCode = 200;
|
|
109
|
-
return response.send(partyTypes);
|
|
110
|
-
}
|
|
111
|
-
catch (error) {
|
|
112
|
-
return (0, ssi_express_support_1.sendErrorResponse)(response, 500, error.message, error);
|
|
113
|
-
}
|
|
114
|
-
}));
|
|
115
|
-
}
|
|
116
|
-
function partyTypeReadEndpoint(router, context, opts) {
|
|
117
|
-
var _a;
|
|
118
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
119
|
-
console.log(`"partyTypeReadEndpoint" Endpoint is disabled`);
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
const path = (_a = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _a !== void 0 ? _a : '/party-types';
|
|
123
|
-
router.get(`${path}/:partyTypeId`, (0, ssi_express_support_1.checkAuth)(opts === null || opts === void 0 ? void 0 : opts.endpoint), (request, response) => __awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
try {
|
|
125
|
-
const partyTypeId = request.params.partyTypeId;
|
|
126
|
-
const partyType = yield context.agent.cmGetContactType({ contactTypeId: partyTypeId });
|
|
127
|
-
response.statusCode = 200;
|
|
128
|
-
return response.send(partyType);
|
|
129
|
-
}
|
|
130
|
-
catch (error) {
|
|
131
|
-
return (0, ssi_express_support_1.sendErrorResponse)(response, 500, error.message, error);
|
|
132
|
-
}
|
|
133
|
-
}));
|
|
134
|
-
}
|
|
135
|
-
function identitiesReadEndpoint(router, context, opts) {
|
|
136
|
-
var _a;
|
|
137
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
138
|
-
console.log(`"identitiesReadEndpoint" Endpoint is disabled`);
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
const path = (_a = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _a !== void 0 ? _a : '/identities';
|
|
142
|
-
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* () {
|
|
143
|
-
try {
|
|
144
|
-
// later we will add filter to this
|
|
145
|
-
const identities = yield context.agent.cmGetIdentities();
|
|
146
|
-
response.statusCode = 200;
|
|
147
|
-
return response.send(identities);
|
|
148
|
-
}
|
|
149
|
-
catch (error) {
|
|
150
|
-
return (0, ssi_express_support_1.sendErrorResponse)(response, 500, error.message, error);
|
|
151
|
-
}
|
|
152
|
-
}));
|
|
153
|
-
}
|
|
154
|
-
function identityReadEndpoints(router, context, opts) {
|
|
155
|
-
var _a;
|
|
156
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.enabled) === false) {
|
|
157
|
-
console.log(`"identityReadEndpoints" Endpoint is disabled`);
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
const path = (_a = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _a !== void 0 ? _a : '/identities';
|
|
161
|
-
router.get(`${path}/:identityId`, (0, ssi_express_support_1.checkAuth)(opts === null || opts === void 0 ? void 0 : opts.endpoint), (request, response) => __awaiter(this, void 0, void 0, function* () {
|
|
162
|
-
try {
|
|
163
|
-
const identityId = request.params.identityId;
|
|
164
|
-
const identity = yield context.agent.cmGetIdentity({ identityId });
|
|
165
|
-
response.statusCode = 200;
|
|
166
|
-
return response.send(identity);
|
|
167
|
-
}
|
|
168
|
-
catch (error) {
|
|
169
|
-
return (0, ssi_express_support_1.sendErrorResponse)(response, 500, error.message, error);
|
|
170
|
-
}
|
|
171
|
-
}));
|
|
172
|
-
}
|
|
173
|
-
//# sourceMappingURL=api-functions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-functions.js","sourceRoot":"","sources":["../src/api-functions.ts"],"names":[],"mappings":";;;;;;;;;;;AAKA,kDAgBC;AAED,8CAgBC;AAED,gDAgBC;AAED,kDAgBC;AAED,0DAgBC;AAED,sDAgBC;AAED,wDAgBC;AAED,sDAgBC;AAnJD,uEAAiG;AAKjG,SAAgB,mBAAmB,CAAC,MAAc,EAAE,OAAyB,EAAE,IAA0B;;IACvG,IAAI,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,MAAK,KAAK,EAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAA;QACzD,OAAM;IACR,CAAC;IACD,MAAM,IAAI,GAAG,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,mCAAI,UAAU,CAAA;IACrC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,IAAA,+BAAS,EAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,CAAC,EAAE,CAAO,OAAgB,EAAE,QAAkB,EAAE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AAM,CAAC,GAAG,CAAC,GAAG,IAAI,cAAc,EAAE,IAAA,+BAAS,EAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,CAAC,EAAE,CAAO,OAAgB,EAAE,QAAkB,EAAE,EAAE;QAC1G,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,CAAA;YAC5C,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,UAAU,EAAE,CAAC,CAAA;YAClE,QAAQ,CAAC,UAAU,GAAG,GAAG,CAAA;YACzB,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAChC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,IAAA,uCAAiB,EAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,CAAC,OAAiB,EAAE,KAAK,CAAC,CAAA;QACzE,CAAC;IACH,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { TAgent } from '@veramo/core';
|
|
2
|
-
import { Express, Router } from 'express';
|
|
3
|
-
import { IContactManagerAPIEndpointOpts, IRequiredPlugins } from './types';
|
|
4
|
-
import { ExpressSupport } from '@sphereon/ssi-express-support';
|
|
5
|
-
export declare class ContactManagerApiServer {
|
|
6
|
-
private readonly _express;
|
|
7
|
-
private readonly _agent;
|
|
8
|
-
private readonly _opts?;
|
|
9
|
-
private readonly _router;
|
|
10
|
-
constructor(args: {
|
|
11
|
-
agent: TAgent<IRequiredPlugins>;
|
|
12
|
-
expressSupport: ExpressSupport;
|
|
13
|
-
opts?: IContactManagerAPIEndpointOpts;
|
|
14
|
-
});
|
|
15
|
-
get express(): Express;
|
|
16
|
-
get router(): Router;
|
|
17
|
-
get agent(): TAgent<IRequiredPlugins>;
|
|
18
|
-
get opts(): IContactManagerAPIEndpointOpts | undefined;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=contact-manager-api-server.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contact-manager-api-server.d.ts","sourceRoot":"","sources":["../src/contact-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,8BAA8B,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAW1E,OAAO,EAA6B,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAEzF,qBAAa,uBAAuB;IAClC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;IACjD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAgC;IACvD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;gBAEpB,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAAC,cAAc,EAAE,cAAc,CAAC;QAAC,IAAI,CAAC,EAAE,8BAA8B,CAAA;KAAE;IAkC5H,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,KAAK,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAEpC;IACD,IAAI,IAAI,IAAI,8BAA8B,GAAG,SAAS,CAErD;CACF"}
|
|
@@ -1,59 +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.ContactManagerApiServer = void 0;
|
|
7
|
-
const ssi_sdk_core_1 = require("@sphereon/ssi-sdk.core");
|
|
8
|
-
const express_1 = __importDefault(require("express"));
|
|
9
|
-
const api_functions_1 = require("./api-functions");
|
|
10
|
-
const ssi_express_support_1 = require("@sphereon/ssi-express-support");
|
|
11
|
-
class ContactManagerApiServer {
|
|
12
|
-
constructor(args) {
|
|
13
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
14
|
-
const { agent, opts } = args;
|
|
15
|
-
this._agent = agent;
|
|
16
|
-
(0, ssi_express_support_1.copyGlobalAuthToEndpoints)({ opts, keys: ['partyRead', 'partyWrite', 'partyTypeRead', 'identityRead'] });
|
|
17
|
-
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.secureContactManagerEndpoints) {
|
|
18
|
-
(0, ssi_express_support_1.copyGlobalAuthToEndpoints)({ opts, keys: ['partyRead', 'partyWrite', 'partyTypeRead', 'identityRead'] });
|
|
19
|
-
}
|
|
20
|
-
this._opts = opts;
|
|
21
|
-
this._express = args.expressSupport.express;
|
|
22
|
-
this._router = express_1.default.Router();
|
|
23
|
-
const context = (0, ssi_sdk_core_1.agentContext)(agent);
|
|
24
|
-
const features = (_c = opts === null || opts === void 0 ? void 0 : opts.enableFeatures) !== null && _c !== void 0 ? _c : ['party_read', 'party_write', 'party_type_read', 'identity_read'];
|
|
25
|
-
console.log(`Contact Manager API enabled, with features: ${JSON.stringify(features)}}`);
|
|
26
|
-
// endpoints
|
|
27
|
-
if (features.includes('party_read')) {
|
|
28
|
-
(0, api_functions_1.partiesReadEndpoint)(this.router, context, (_e = (_d = this._opts) === null || _d === void 0 ? void 0 : _d.endpointOpts) === null || _e === void 0 ? void 0 : _e.partyRead);
|
|
29
|
-
(0, api_functions_1.partyReadEndpoint)(this.router, context, (_g = (_f = this._opts) === null || _f === void 0 ? void 0 : _f.endpointOpts) === null || _g === void 0 ? void 0 : _g.partyRead);
|
|
30
|
-
}
|
|
31
|
-
if (features.includes('party_write')) {
|
|
32
|
-
(0, api_functions_1.partyWriteEndpoint)(this.router, context, (_j = (_h = this._opts) === null || _h === void 0 ? void 0 : _h.endpointOpts) === null || _j === void 0 ? void 0 : _j.partyWrite);
|
|
33
|
-
(0, api_functions_1.partyDeleteEndpoint)(this.router, context, (_l = (_k = this._opts) === null || _k === void 0 ? void 0 : _k.endpointOpts) === null || _l === void 0 ? void 0 : _l.partyWrite);
|
|
34
|
-
}
|
|
35
|
-
if (features.includes('party_type_read')) {
|
|
36
|
-
(0, api_functions_1.partiesTypeReadEndpoint)(this.router, context, (_o = (_m = this._opts) === null || _m === void 0 ? void 0 : _m.endpointOpts) === null || _o === void 0 ? void 0 : _o.partyTypeRead);
|
|
37
|
-
(0, api_functions_1.partyTypeReadEndpoint)(this.router, context, (_q = (_p = this._opts) === null || _p === void 0 ? void 0 : _p.endpointOpts) === null || _q === void 0 ? void 0 : _q.partyTypeRead);
|
|
38
|
-
}
|
|
39
|
-
if (features.includes('identity_read')) {
|
|
40
|
-
(0, api_functions_1.identitiesReadEndpoint)(this.router, context, (_s = (_r = this._opts) === null || _r === void 0 ? void 0 : _r.endpointOpts) === null || _s === void 0 ? void 0 : _s.identityRead);
|
|
41
|
-
(0, api_functions_1.identityReadEndpoints)(this.router, context, (_u = (_t = this._opts) === null || _t === void 0 ? void 0 : _t.endpointOpts) === null || _u === void 0 ? void 0 : _u.identityRead);
|
|
42
|
-
}
|
|
43
|
-
this._express.use((_w = (_v = opts === null || opts === void 0 ? void 0 : opts.endpointOpts) === null || _v === void 0 ? void 0 : _v.basePath) !== null && _w !== void 0 ? _w : '', this.router);
|
|
44
|
-
}
|
|
45
|
-
get express() {
|
|
46
|
-
return this._express;
|
|
47
|
-
}
|
|
48
|
-
get router() {
|
|
49
|
-
return this._router;
|
|
50
|
-
}
|
|
51
|
-
get agent() {
|
|
52
|
-
return this._agent;
|
|
53
|
-
}
|
|
54
|
-
get opts() {
|
|
55
|
-
return this._opts;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.ContactManagerApiServer = ContactManagerApiServer;
|
|
59
|
-
//# sourceMappingURL=contact-manager-api-server.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contact-manager-api-server.js","sourceRoot":"","sources":["../src/contact-manager-api-server.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAqD;AAGrD,sDAAkD;AAElD,mDASwB;AACxB,uEAAyF;AAEzF,MAAa,uBAAuB;IAMlC,YAAY,IAAgH;;QAC1H,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,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,CAAC,EAAE,CAAC,CAAA;QACvG,IAAI,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY,0CAAE,UAAU,0CAAE,6BAA6B,EAAE,CAAC;YAClE,IAAA,+CAAyB,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,CAAC,EAAE,CAAC,CAAA;QACzG,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAA;QAC3C,IAAI,CAAC,OAAO,GAAG,iBAAO,CAAC,MAAM,EAAE,CAAA;QAC/B,MAAM,OAAO,GAAG,IAAA,2BAAY,EAAC,KAAK,CAAC,CAAA;QACnC,MAAM,QAAQ,GAAG,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,cAAc,mCAAI,CAAC,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,eAAe,CAAC,CAAA;QAC1G,OAAO,CAAC,GAAG,CAAC,+CAA+C,IAAI,CA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AE,YAAY,0CAAE,YAAY,CAAC,CAAA;YACpF,IAAA,qCAAqB,EAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,MAAA,MAAA,IAAI,CAAC,KAAK,0CAAE,YAAY,0CAAE,YAAY,CAAC,CAAA;QACrF,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;IACD,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;CACF;AAtDD,0DAsDC"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,8BAA8B,CAAA;AAC5C,cAAc,iBAAiB,CAAA"}
|
package/dist/types.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { GenericAuthArgs, ISingleEndpointOpts } from '@sphereon/ssi-express-support';
|
|
2
|
-
import { IContactManager } from '@sphereon/ssi-sdk.contact-manager';
|
|
3
|
-
import { IAgentContext, IDIDManager, IKeyManager } from '@veramo/core';
|
|
4
|
-
export type ContactManagerMRestApiFeatures = 'party_read' | 'party_write' | 'party_type_read' | 'identity_read';
|
|
5
|
-
export interface IContactManagerAPIEndpointOpts {
|
|
6
|
-
endpointOpts?: {
|
|
7
|
-
basePath?: string;
|
|
8
|
-
globalAuth?: GenericAuthArgs & {
|
|
9
|
-
secureContactManagerEndpoints?: boolean;
|
|
10
|
-
};
|
|
11
|
-
partyRead?: ISingleEndpointOpts;
|
|
12
|
-
partyWrite?: ISingleEndpointOpts;
|
|
13
|
-
partyTypeRead?: ISingleEndpointOpts;
|
|
14
|
-
identityRead?: ISingleEndpointOpts;
|
|
15
|
-
};
|
|
16
|
-
enableFeatures?: ContactManagerMRestApiFeatures[];
|
|
17
|
-
}
|
|
18
|
-
export type IRequiredPlugins = IContactManager & IKeyManager & IDIDManager;
|
|
19
|
-
export type IRequiredContext = IAgentContext<IRequiredPlugins>;
|
|
20
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -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,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAEtE,MAAM,MAAM,8BAA8B,GAAG,YAAY,GAAG,aAAa,GAAG,iBAAiB,GAAG,eAAe,CAAA;AAE/G,MAAM,WAAW,8BAA8B;IAC7C,YAAY,CAAC,EAAE;QACb,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,UAAU,CAAC,EAAE,eAAe,GAAG;YAAE,6BAA6B,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;QAC1E,SAAS,CAAC,EAAE,mBAAmB,CAAA;QAC/B,UAAU,CAAC,EAAE,mBAAmB,CAAA;QAChC,aAAa,CAAC,EAAE,mBAAmB,CAAA;QACnC,YAAY,CAAC,EAAE,mBAAmB,CAAA;KACnC,CAAA;IACD,cAAc,CAAC,EAAE,8BAA8B,EAAE,CAAA;CAClD;AAED,MAAM,MAAM,gBAAgB,GAAG,eAAe,GAAG,WAAW,GAAG,WAAW,CAAA;AAC1E,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC,gBAAgB,CAAC,CAAA"}
|
package/dist/types.js
DELETED
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|