UNPKG

@sphereon/ssi-sdk.contact-manager-rest-api

Version:

59 lines 4.17 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ContactManagerApiServer = void 0; const ssi_sdk_core_1 = require("@sphereon/ssi-sdk.core"); const express_1 = __importDefault(require("express")); const api_functions_1 = require("./api-functions"); const ssi_express_support_1 = require("@sphereon/ssi-express-support"); class ContactManagerApiServer { constructor(args) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w; const { agent, opts } = args; this._agent = agent; (0, ssi_express_support_1.copyGlobalAuthToEndpoints)({ opts, keys: ['partyRead', 'partyWrite', 'partyTypeRead', 'identityRead'] }); 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) { (0, ssi_express_support_1.copyGlobalAuthToEndpoints)({ opts, keys: ['partyRead', 'partyWrite', 'partyTypeRead', 'identityRead'] }); } this._opts = opts; this._express = args.expressSupport.express; this._router = express_1.default.Router(); const context = (0, ssi_sdk_core_1.agentContext)(agent); 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']; console.log(`Contact Manager API enabled, with features: ${JSON.stringify(features)}}`); // endpoints if (features.includes('party_read')) { (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); (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); } if (features.includes('party_write')) { (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); (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); } if (features.includes('party_type_read')) { (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); (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); } if (features.includes('identity_read')) { (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); (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); } 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); } get express() { return this._express; } get router() { return this._router; } get agent() { return this._agent; } get opts() { return this._opts; } } exports.ContactManagerApiServer = ContactManagerApiServer; //# sourceMappingURL=contact-manager-api-server.js.map