@sphereon/ssi-sdk.contact-manager-rest-api 0.33.1-feature.vcdm2.4 → 0.33.1-feature.vcdm2.tsup.19
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 +289 -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 +245 -3
- package/dist/index.js.map +1 -1
- package/package.json +29 -19
- package/dist/api-functions.d.ts +0 -12
- package/dist/api-functions.d.ts.map +0 -1
- package/dist/api-functions.js +0 -146
- 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 -55
- 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 -2
- package/dist/types.js.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
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
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
278
|
+
0 && (module.exports = {
|
|
279
|
+
ContactManagerApiServer,
|
|
280
|
+
identitiesReadEndpoint,
|
|
281
|
+
identityReadEndpoints,
|
|
282
|
+
partiesReadEndpoint,
|
|
283
|
+
partiesTypeReadEndpoint,
|
|
284
|
+
partyDeleteEndpoint,
|
|
285
|
+
partyReadEndpoint,
|
|
286
|
+
partyTypeReadEndpoint,
|
|
287
|
+
partyWriteEndpoint
|
|
288
|
+
});
|
|
289
|
+
//# 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,OAAOJ,MAAMI,QAAQ;AAC3BN,SAAOO,IAAID,UAAME,sCAAUN,MAAMO,QAAAA,GAAW,OAAOC,SAAkBC,aAAAA;AACnE,QAAI;AAEF,YAAMC,UAAU,MAAMX,QAAQY,MAAMC,cAAa;AACjDH,eAASI,aAAa;AACtB,aAAOJ,SAASK,KAAKJ,OAAAA;IACvB,SAASK,OAAO;AACd,iBAAOC,8CAAkBP,UAAU,KAAKM,MAAME,SAAmBF,KAAAA;IACnE;EACF,CAAA;AACF;AAhBgBlB;AAkBT,SAASqB,kBAAkBpB,QAAgBC,SAA2BC,MAA0B;AACrG,MAAIA,MAAMC,YAAY,OAAO;AAC3BC,YAAQC,IAAI,0CAA0C;AACtD;EACF;AACA,QAAMC,OAAOJ,MAAMI,QAAQ;AAC3BN,SAAOO,IAAI,GAAGD,IAAAA,iBAAiBE,sCAAUN,MAAMO,QAAAA,GAAW,OAAOC,SAAkBC,aAAAA;AACjF,QAAI;AACF,YAAMU,UAAUX,QAAQY,OAAOD;AAC/B,YAAME,QAAQ,MAAMtB,QAAQY,MAAMW,aAAa;QAAEC,WAAWJ;MAAQ,CAAA;AACpEV,eAASI,aAAa;AACtB,aAAOJ,SAASK,KAAKO,KAAAA;IACvB,SAASN,OAAO;AACd,iBAAOC,8CAAkBP,UAAU,KAAKM,MAAME,SAAmBF,KAAAA;IACnE;EACF,CAAA;AACF;AAhBgBG;AAkBT,SAASM,mBAAmB1B,QA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,KAAKd,OAAOQ,cAAciB,SAAAA;AACpEC,wBAAkB,KAAKF,QAAQV,SAAS,KAAKd,OAAOQ,cAAciB,SAAAA;IACpE;AACA,QAAIT,SAASM,SAAS,aAAA,GAAgB;AACpCK,yBAAmB,KAAKH,QAAQV,SAAS,KAAKd,OAAOQ,cAAcoB,UAAAA;AACnEC,0BAAoB,KAAKL,QAAQV,SAAS,KAAKd,OAAOQ,cAAcoB,UAAAA;IACtE;AACA,QAAIZ,SAASM,SAAS,iBAAA,GAAoB;AACxCQ,8BAAwB,KAAKN,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,4 +1,246 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
245
|
+
};
|
|
4
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,cAAc,SAAS,CAAA;AACvB,cAAc,8BAA8B,CAAA;AAC5C,cAAc,iBAAiB,CAAA"}
|
|
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,OAAO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AAAA;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":["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,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.contact-manager-rest-api",
|
|
3
|
-
"version": "0.33.1-feature.vcdm2.
|
|
3
|
+
"version": "0.33.1-feature.vcdm2.tsup.19+db508b44",
|
|
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
|
+
"import": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/index.d.cts",
|
|
16
|
+
"require": "./dist/index.cjs"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
7
19
|
"scripts": {
|
|
8
|
-
"build": "
|
|
9
|
-
"build:clean": "tsc --build --clean && tsc --build",
|
|
20
|
+
"build": "tsup --config ../../tsup.config.ts --tsconfig ../../tsconfig.tsup.json",
|
|
10
21
|
"start:prod": "node build/index.js",
|
|
11
22
|
"start:dev": "ts-node __tests__/RestAPI.ts"
|
|
12
23
|
},
|
|
13
24
|
"dependencies": {
|
|
14
|
-
"@sphereon/ssi-express-support": "0.33.1-feature.vcdm2.
|
|
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-feature.vcdm2.
|
|
18
|
-
"@sphereon/ssi-sdk.core": "0.33.1-feature.vcdm2.
|
|
19
|
-
"@sphereon/ssi-sdk.data-store": "0.33.1-feature.vcdm2.
|
|
20
|
-
"@sphereon/ssi-sdk.kv-store-temp": "0.33.1-feature.vcdm2.
|
|
21
|
-
"@sphereon/ssi-types": "0.33.1-feature.vcdm2.
|
|
25
|
+
"@sphereon/ssi-express-support": "^0.33.1-feature.vcdm2.tsup.19+db508b44",
|
|
26
|
+
"@sphereon/ssi-sdk-ext.key-manager": "0.28.1-feature.esm.cjs.11",
|
|
27
|
+
"@sphereon/ssi-sdk-ext.key-utils": "0.28.1-feature.esm.cjs.11",
|
|
28
|
+
"@sphereon/ssi-sdk.contact-manager": "^0.33.1-feature.vcdm2.tsup.19+db508b44",
|
|
29
|
+
"@sphereon/ssi-sdk.core": "^0.33.1-feature.vcdm2.tsup.19+db508b44",
|
|
30
|
+
"@sphereon/ssi-sdk.data-store": "^0.33.1-feature.vcdm2.tsup.19+db508b44",
|
|
31
|
+
"@sphereon/ssi-sdk.kv-store-temp": "^0.33.1-feature.vcdm2.tsup.19+db508b44",
|
|
32
|
+
"@sphereon/ssi-types": "^0.33.1-feature.vcdm2.tsup.19+db508b44",
|
|
22
33
|
"@veramo/core": "4.2.0",
|
|
23
34
|
"body-parser": "^1.20.2",
|
|
24
35
|
"casbin": "^5.30.0",
|
|
@@ -33,7 +44,7 @@
|
|
|
33
44
|
},
|
|
34
45
|
"devDependencies": {
|
|
35
46
|
"@decentralized-identity/ion-sdk": "^0.6.0",
|
|
36
|
-
"@sphereon/ssi-sdk.agent-config": "0.33.1-feature.vcdm2.
|
|
47
|
+
"@sphereon/ssi-sdk.agent-config": "^0.33.1-feature.vcdm2.tsup.19+db508b44",
|
|
37
48
|
"@types/body-parser": "^1.19.5",
|
|
38
49
|
"@types/cookie-parser": "^1.4.7",
|
|
39
50
|
"@types/cors": "^2.8.17",
|
|
@@ -57,11 +68,11 @@
|
|
|
57
68
|
"passport": "^0.6.0",
|
|
58
69
|
"passport-http-bearer": "^1.0.1",
|
|
59
70
|
"ts-node": "^10.9.2",
|
|
60
|
-
"typeorm": "^0.3.
|
|
71
|
+
"typeorm": "^0.3.22"
|
|
61
72
|
},
|
|
62
73
|
"files": [
|
|
63
|
-
"dist
|
|
64
|
-
"src
|
|
74
|
+
"dist",
|
|
75
|
+
"src",
|
|
65
76
|
"README.md",
|
|
66
77
|
"LICENSE"
|
|
67
78
|
],
|
|
@@ -80,6 +91,5 @@
|
|
|
80
91
|
"REST",
|
|
81
92
|
"API"
|
|
82
93
|
],
|
|
83
|
-
"
|
|
84
|
-
"gitHead": "9f634bdb714061141e277508c124b08d626f6036"
|
|
94
|
+
"gitHead": "db508b447fb1f769700f1d5e7cd8196653f4f794"
|
|
85
95
|
}
|
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,146 +0,0 @@
|
|
|
1
|
-
import { checkAuth, sendErrorResponse } from '@sphereon/ssi-express-support';
|
|
2
|
-
export function partiesReadEndpoint(router, context, opts) {
|
|
3
|
-
if (opts?.enabled === false) {
|
|
4
|
-
console.log(`"partiesReadEndpoint" Endpoint is disabled`);
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
7
|
-
const path = opts?.path ?? '/parties';
|
|
8
|
-
router.get(path, checkAuth(opts?.endpoint), async (request, response) => {
|
|
9
|
-
try {
|
|
10
|
-
// later we will add filter to this
|
|
11
|
-
const parties = await context.agent.cmGetContacts();
|
|
12
|
-
response.statusCode = 200;
|
|
13
|
-
return response.send(parties);
|
|
14
|
-
}
|
|
15
|
-
catch (error) {
|
|
16
|
-
return sendErrorResponse(response, 500, error.message, error);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
export function partyReadEndpoint(router, context, opts) {
|
|
21
|
-
if (opts?.enabled === false) {
|
|
22
|
-
console.log(`"partyReadEndpoint" Endpoint is disabled`);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const path = opts?.path ?? '/parties';
|
|
26
|
-
router.get(`${path}/:partyId`, checkAuth(opts?.endpoint), async (request, response) => {
|
|
27
|
-
try {
|
|
28
|
-
const partyId = request.params.partyId;
|
|
29
|
-
const party = await context.agent.cmGetContact({ contactId: partyId });
|
|
30
|
-
response.statusCode = 200;
|
|
31
|
-
return response.send(party);
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
return sendErrorResponse(response, 500, error.message, error);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
export function partyWriteEndpoint(router, context, opts) {
|
|
39
|
-
if (opts?.enabled === false) {
|
|
40
|
-
console.log(`"partyWriteEndpoint" Endpoint is disabled`);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const path = opts?.path ?? '/parties';
|
|
44
|
-
router.post(path, async (request, response) => {
|
|
45
|
-
try {
|
|
46
|
-
const addParty = request.body;
|
|
47
|
-
const party = await context.agent.cmAddContact(addParty);
|
|
48
|
-
response.statusCode = 201;
|
|
49
|
-
return response.send(party);
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
return sendErrorResponse(response, 500, error.message, error);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
export function partyDeleteEndpoint(router, context, opts) {
|
|
57
|
-
if (opts?.enabled === false) {
|
|
58
|
-
console.log(`"partyDeleteEndpoint" Endpoint is disabled`);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const path = opts?.path ?? '/parties';
|
|
62
|
-
router.delete(`${path}/:partyId`, async (request, response) => {
|
|
63
|
-
try {
|
|
64
|
-
const partyId = request.params.partyId;
|
|
65
|
-
const result = await context.agent.cmRemoveContact({ contactId: partyId });
|
|
66
|
-
response.statusCode = 200;
|
|
67
|
-
return response.send(result);
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
return sendErrorResponse(response, 500, error.message, error);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
export function partiesTypeReadEndpoint(router, context, opts) {
|
|
75
|
-
if (opts?.enabled === false) {
|
|
76
|
-
console.log(`"partiesTypeReadEndpoint" Endpoint is disabled`);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
const path = opts?.path ?? '/party-types';
|
|
80
|
-
router.get(path, checkAuth(opts?.endpoint), async (request, response) => {
|
|
81
|
-
try {
|
|
82
|
-
// later we will add filter to this
|
|
83
|
-
const partyTypes = await context.agent.cmGetContactTypes();
|
|
84
|
-
response.statusCode = 200;
|
|
85
|
-
return response.send(partyTypes);
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
return sendErrorResponse(response, 500, error.message, error);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
export function partyTypeReadEndpoint(router, context, opts) {
|
|
93
|
-
if (opts?.enabled === false) {
|
|
94
|
-
console.log(`"partyTypeReadEndpoint" Endpoint is disabled`);
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const path = opts?.path ?? '/party-types';
|
|
98
|
-
router.get(`${path}/:partyTypeId`, checkAuth(opts?.endpoint), async (request, response) => {
|
|
99
|
-
try {
|
|
100
|
-
const partyTypeId = request.params.partyTypeId;
|
|
101
|
-
const partyType = await context.agent.cmGetContactType({ contactTypeId: partyTypeId });
|
|
102
|
-
response.statusCode = 200;
|
|
103
|
-
return response.send(partyType);
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
return sendErrorResponse(response, 500, error.message, error);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
export function identitiesReadEndpoint(router, context, opts) {
|
|
111
|
-
if (opts?.enabled === false) {
|
|
112
|
-
console.log(`"identitiesReadEndpoint" Endpoint is disabled`);
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
const path = opts?.path ?? '/identities';
|
|
116
|
-
router.get(path, checkAuth(opts?.endpoint), async (request, response) => {
|
|
117
|
-
try {
|
|
118
|
-
// later we will add filter to this
|
|
119
|
-
const identities = await context.agent.cmGetIdentities();
|
|
120
|
-
response.statusCode = 200;
|
|
121
|
-
return response.send(identities);
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
return sendErrorResponse(response, 500, error.message, error);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
export function identityReadEndpoints(router, context, opts) {
|
|
129
|
-
if (opts?.enabled === false) {
|
|
130
|
-
console.log(`"identityReadEndpoints" Endpoint is disabled`);
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
const path = opts?.path ?? '/identities';
|
|
134
|
-
router.get(`${path}/:identityId`, checkAuth(opts?.endpoint), async (request, response) => {
|
|
135
|
-
try {
|
|
136
|
-
const identityId = request.params.identityId;
|
|
137
|
-
const identity = await context.agent.cmGetIdentity({ identityId });
|
|
138
|
-
response.statusCode = 200;
|
|
139
|
-
return response.send(identity);
|
|
140
|
-
}
|
|
141
|
-
catch (error) {
|
|
142
|
-
return sendErrorResponse(response, 500, error.message, error);
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
//# sourceMappingURL=api-functions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-functions.js","sourceRoot":"","sources":["../src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G,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,iBAAiB,CAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,CAAC,OAAiB,EAAE,KAAK,CAAC,CAAA;QACzE,CAAC;IACH,CAAC,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,55 +0,0 @@
|
|
|
1
|
-
import { agentContext } from '@sphereon/ssi-sdk.core';
|
|
2
|
-
import express from 'express';
|
|
3
|
-
import { identityReadEndpoints, partiesReadEndpoint, partyDeleteEndpoint, partyReadEndpoint, partiesTypeReadEndpoint, partyWriteEndpoint, partyTypeReadEndpoint, identitiesReadEndpoint, } from './api-functions';
|
|
4
|
-
import { copyGlobalAuthToEndpoints } from '@sphereon/ssi-express-support';
|
|
5
|
-
export class ContactManagerApiServer {
|
|
6
|
-
_express;
|
|
7
|
-
_agent;
|
|
8
|
-
_opts;
|
|
9
|
-
_router;
|
|
10
|
-
constructor(args) {
|
|
11
|
-
const { agent, opts } = args;
|
|
12
|
-
this._agent = agent;
|
|
13
|
-
copyGlobalAuthToEndpoints({ opts, keys: ['partyRead', 'partyWrite', 'partyTypeRead', 'identityRead'] });
|
|
14
|
-
if (opts?.endpointOpts?.globalAuth?.secureContactManagerEndpoints) {
|
|
15
|
-
copyGlobalAuthToEndpoints({ opts, keys: ['partyRead', 'partyWrite', 'partyTypeRead', 'identityRead'] });
|
|
16
|
-
}
|
|
17
|
-
this._opts = opts;
|
|
18
|
-
this._express = args.expressSupport.express;
|
|
19
|
-
this._router = express.Router();
|
|
20
|
-
const context = agentContext(agent);
|
|
21
|
-
const features = opts?.enableFeatures ?? ['party_read', 'party_write', 'party_type_read', 'identity_read'];
|
|
22
|
-
console.log(`Contact Manager API enabled, with features: ${JSON.stringify(features)}}`);
|
|
23
|
-
// endpoints
|
|
24
|
-
if (features.includes('party_read')) {
|
|
25
|
-
partiesReadEndpoint(this.router, context, this._opts?.endpointOpts?.partyRead);
|
|
26
|
-
partyReadEndpoint(this.router, context, this._opts?.endpointOpts?.partyRead);
|
|
27
|
-
}
|
|
28
|
-
if (features.includes('party_write')) {
|
|
29
|
-
partyWriteEndpoint(this.router, context, this._opts?.endpointOpts?.partyWrite);
|
|
30
|
-
partyDeleteEndpoint(this.router, context, this._opts?.endpointOpts?.partyWrite);
|
|
31
|
-
}
|
|
32
|
-
if (features.includes('party_type_read')) {
|
|
33
|
-
partiesTypeReadEndpoint(this.router, context, this._opts?.endpointOpts?.partyTypeRead);
|
|
34
|
-
partyTypeReadEndpoint(this.router, context, this._opts?.endpointOpts?.partyTypeRead);
|
|
35
|
-
}
|
|
36
|
-
if (features.includes('identity_read')) {
|
|
37
|
-
identitiesReadEndpoint(this.router, context, this._opts?.endpointOpts?.identityRead);
|
|
38
|
-
identityReadEndpoints(this.router, context, this._opts?.endpointOpts?.identityRead);
|
|
39
|
-
}
|
|
40
|
-
this._express.use(opts?.endpointOpts?.basePath ?? '', this.router);
|
|
41
|
-
}
|
|
42
|
-
get express() {
|
|
43
|
-
return this._express;
|
|
44
|
-
}
|
|
45
|
-
get router() {
|
|
46
|
-
return this._router;
|
|
47
|
-
}
|
|
48
|
-
get agent() {
|
|
49
|
-
return this._agent;
|
|
50
|
-
}
|
|
51
|
-
get opts() {
|
|
52
|
-
return this._opts;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
//# 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,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAGrD,OAAO,OAA4B,MAAM,SAAS,CAAA;AAElD,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,yBAAyB,EAAkB,MAAM,+BAA+B,CAAA;AAEzF,MAAM,OAAO,uBAAuB;IACjB,QAAQ,CAAS;IACjB,MAAM,CAA0B;IAChC,KAAK,CAAiC;IACtC,OAAO,CAAQ;IAEhC,YAAY,IAAgH;QAC1H,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,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,CAAC,EAAE,CAAC,CAAA;QACvG,IAAI,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,6BAA6B,EAAE,CAAC;YAClE,yBAAyB,CAAC,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,IAA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Q,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC;YACvC,sBAAsB,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,YAAY,EAAE,YAAY,CAAC,CAAA;YACpF,qBAAqB,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,YAAY,EAAE,YAAY,CAAC,CAAA;QACrF,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;IACD,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;CACF"}
|
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":""}
|