elemento-alpha-tools 1.1.6 → 1.1.8

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.
Files changed (48) hide show
  1. package/dist/ap/303/255/ExpressLogableConfig.d.ts +5 -5
  2. package/dist/ap/303/255/ExpressLogableConfig.js +15 -15
  3. package/dist/ap/303/255/checkers/RoleServicePermissionsCheckers.d.ts +13 -13
  4. package/dist/ap/303/255/checkers/RoleServicePermissionsCheckers.js +68 -68
  5. package/dist/ap/303/255/checkers/ServiceSessionChecker.d.ts +28 -28
  6. package/dist/ap/303/255/checkers/ServiceSessionChecker.js +105 -105
  7. package/dist/crud/AvailablePlataformManager.d.ts +35 -35
  8. package/dist/crud/AvailablePlataformManager.js +79 -79
  9. package/dist/crud/BusinessManager.d.ts +32 -32
  10. package/dist/crud/BusinessManager.js +67 -67
  11. package/dist/crud/ComponentManager.d.ts +51 -51
  12. package/dist/crud/ComponentManager.js +70 -70
  13. package/dist/crud/Intermediaries.d.ts +36 -36
  14. package/dist/crud/Intermediaries.js +73 -73
  15. package/dist/crud/IntermediaryDataManager.d.ts +43 -0
  16. package/dist/crud/IntermediaryDataManager.js +84 -0
  17. package/dist/crud/IntermediaryDataManager.js.map +1 -0
  18. package/dist/crud/PlatformManager.d.ts +39 -39
  19. package/dist/crud/PlatformManager.js +67 -67
  20. package/dist/crud/RoleManager.d.ts +50 -50
  21. package/dist/crud/RoleManager.js +67 -67
  22. package/dist/crud/SourcesManager.d.ts +33 -0
  23. package/dist/crud/SourcesManager.js +80 -0
  24. package/dist/crud/SourcesManager.js.map +1 -0
  25. package/dist/crud/StatusManager.d.ts +32 -32
  26. package/dist/crud/StatusManager.js +69 -69
  27. package/dist/crud/TypeManager.d.ts +29 -29
  28. package/dist/crud/TypeManager.js +63 -63
  29. package/dist/crud/UserCredentialsManager.d.ts +37 -37
  30. package/dist/crud/UserCredentialsManager.js +79 -79
  31. package/dist/crud/UserManager.d.ts +35 -35
  32. package/dist/crud/UserManager.js +77 -77
  33. package/dist/crud/test/ComponentMocks.d.ts +2 -2
  34. package/dist/crud/test/ComponentMocks.js +62 -62
  35. package/dist/crud/test/LoginServiceMocks.d.ts +2 -2
  36. package/dist/crud/test/LoginServiceMocks.js +51 -51
  37. package/dist/crud/test/PlatformMocks.d.ts +2 -2
  38. package/dist/crud/test/PlatformMocks.js +76 -76
  39. package/dist/crud/test/RoleMocks.d.ts +2 -2
  40. package/dist/crud/test/RoleMocks.js +57 -57
  41. package/dist/crud/test/StatusMocks.d.ts +2 -2
  42. package/dist/crud/test/StatusMocks.js +44 -44
  43. package/dist/crud/test/TypeMocks.d.ts +2 -2
  44. package/dist/crud/test/TypeMocks.js +44 -44
  45. package/dist/index.d.ts +20 -18
  46. package/dist/index.js +43 -39
  47. package/dist/index.js.map +1 -1
  48. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- import { ExpressStandardConfiguration } from "itrm-tools";
2
- import { Express } from "express";
3
- export declare class ExpressLogableConfig extends ExpressStandardConfiguration {
4
- apply(app: Express): void;
5
- }
1
+ import { ExpressStandardConfiguration } from "itrm-tools";
2
+ import { Express } from "express";
3
+ export declare class ExpressLogableConfig extends ExpressStandardConfiguration {
4
+ apply(app: Express): void;
5
+ }
@@ -1,16 +1,16 @@
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.ExpressLogableConfig = void 0;
7
- const itrm_tools_1 = require("itrm-tools");
8
- const morgan_1 = __importDefault(require("morgan"));
9
- class ExpressLogableConfig extends itrm_tools_1.ExpressStandardConfiguration {
10
- apply(app) {
11
- super.apply(app);
12
- app.use((0, morgan_1.default)(':remote-addr - :remote-user [:date[web]] ":method :url HTTP/:http-version" :status :res[content-length]'));
13
- }
14
- }
15
- exports.ExpressLogableConfig = ExpressLogableConfig;
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.ExpressLogableConfig = void 0;
7
+ const itrm_tools_1 = require("itrm-tools");
8
+ const morgan_1 = __importDefault(require("morgan"));
9
+ class ExpressLogableConfig extends itrm_tools_1.ExpressStandardConfiguration {
10
+ apply(app) {
11
+ super.apply(app);
12
+ app.use((0, morgan_1.default)(':remote-addr - :remote-user [:date[web]] ":method :url HTTP/:http-version" :status :res[content-length]'));
13
+ }
14
+ }
15
+ exports.ExpressLogableConfig = ExpressLogableConfig;
16
16
  //# sourceMappingURL=ExpressLogableConfig.js.map
@@ -1,13 +1,13 @@
1
- import { APICheck, APICheckConfig, APICheckResult } from "itrm-tools";
2
- import { Request } from "express";
3
- export declare class RoleServicePermissionsChecker implements APICheck {
4
- private service;
5
- private sessionServiceUrl;
6
- private roleManager;
7
- constructor(service: string, sessionServiceUrl: string, sessionServiceCrud: string);
8
- getConfig(): APICheckConfig;
9
- apply(config: APICheckConfig, req: Request): Promise<APICheckResult>;
10
- private checkServicePermissions;
11
- private isMethodAndPathAllowed;
12
- private unexpectedErrorRejection;
13
- }
1
+ import { APICheck, APICheckConfig, APICheckResult } from "itrm-tools";
2
+ import { Request } from "express";
3
+ export declare class RoleServicePermissionsChecker implements APICheck {
4
+ private service;
5
+ private sessionServiceUrl;
6
+ private roleManager;
7
+ constructor(service: string, sessionServiceUrl: string, sessionServiceCrud: string);
8
+ getConfig(): APICheckConfig;
9
+ apply(config: APICheckConfig, req: Request): Promise<APICheckResult>;
10
+ private checkServicePermissions;
11
+ private isMethodAndPathAllowed;
12
+ private unexpectedErrorRejection;
13
+ }
@@ -1,69 +1,69 @@
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.RoleServicePermissionsChecker = void 0;
13
- const itrm_tools_1 = require("itrm-tools");
14
- const RoleManager_1 = require("../../crud/RoleManager");
15
- class RoleServicePermissionsChecker {
16
- constructor(service, sessionServiceUrl, sessionServiceCrud) {
17
- this.service = service;
18
- this.sessionServiceUrl = sessionServiceUrl;
19
- this.roleManager = new RoleManager_1.RoleManager(`${sessionServiceCrud}/v1`);
20
- }
21
- getConfig() {
22
- return {
23
- check: "rolePermissionService",
24
- };
25
- }
26
- apply(config, req) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- var _a, _b;
29
- try {
30
- const { platform } = req.headers;
31
- let headers = {
32
- headers: {
33
- "Authorization": req.headers.authorization,
34
- "platform": platform
35
- }
36
- };
37
- let verification = yield itrm_tools_1.RequestAxiosCall.post(`${this.sessionServiceUrl}/v1/verify`, { jwt: ((_a = req.headers.authorization) !== null && _a !== void 0 ? _a : 'NoToken').replace("Bearer ", ""), platform: platform }, headers);
38
- let role = yield this.roleManager.find({ name: verification.role, permissions: {}, config: headers });
39
- return this.checkServicePermissions((_b = role === null || role === void 0 ? void 0 : role.permissions.services) !== null && _b !== void 0 ? _b : {}, req, verification);
40
- }
41
- catch (error) {
42
- return this.unexpectedErrorRejection(error);
43
- }
44
- });
45
- }
46
- checkServicePermissions(permissions, req, verification) {
47
- if (permissions[this.service]) {
48
- if (this.isMethodAndPathAllowed(permissions[this.service], req))
49
- return { approved: true, payload: verification };
50
- return { approved: false, rejection: { code: 401, payload: { status: "Error", message: `Method or Path are not allowed: ${req.method} ${req.baseUrl + req.path.replace(/\/\d+$/, "")}` } } };
51
- }
52
- return { approved: false, rejection: { code: 401, payload: { status: "Error", message: "Service is not allowed" } } };
53
- }
54
- isMethodAndPathAllowed(permissions, req) {
55
- return permissions[req.method] && permissions[req.method][req.baseUrl + req.path.replace(/\/\d+$/, "")];
56
- }
57
- unexpectedErrorRejection(error) {
58
- var _a, _b, _c, _d;
59
- return {
60
- approved: false,
61
- rejection: {
62
- code: (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : 500,
63
- payload: { status: "Error", message: (_d = (_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.data) !== null && _d !== void 0 ? _d : error, }
64
- },
65
- };
66
- }
67
- }
68
- exports.RoleServicePermissionsChecker = RoleServicePermissionsChecker;
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.RoleServicePermissionsChecker = void 0;
13
+ const itrm_tools_1 = require("itrm-tools");
14
+ const RoleManager_1 = require("../../crud/RoleManager");
15
+ class RoleServicePermissionsChecker {
16
+ constructor(service, sessionServiceUrl, sessionServiceCrud) {
17
+ this.service = service;
18
+ this.sessionServiceUrl = sessionServiceUrl;
19
+ this.roleManager = new RoleManager_1.RoleManager(`${sessionServiceCrud}/v1`);
20
+ }
21
+ getConfig() {
22
+ return {
23
+ check: "rolePermissionService",
24
+ };
25
+ }
26
+ apply(config, req) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ var _a, _b;
29
+ try {
30
+ const { platform } = req.headers;
31
+ let headers = {
32
+ headers: {
33
+ "Authorization": req.headers.authorization,
34
+ "platform": platform
35
+ }
36
+ };
37
+ let verification = yield itrm_tools_1.RequestAxiosCall.post(`${this.sessionServiceUrl}/v1/verify`, { jwt: ((_a = req.headers.authorization) !== null && _a !== void 0 ? _a : 'NoToken').replace("Bearer ", ""), platform: platform }, headers);
38
+ let role = yield this.roleManager.find({ name: verification.role, permissions: {}, config: headers });
39
+ return this.checkServicePermissions((_b = role === null || role === void 0 ? void 0 : role.permissions.services) !== null && _b !== void 0 ? _b : {}, req, verification);
40
+ }
41
+ catch (error) {
42
+ return this.unexpectedErrorRejection(error);
43
+ }
44
+ });
45
+ }
46
+ checkServicePermissions(permissions, req, verification) {
47
+ if (permissions[this.service]) {
48
+ if (this.isMethodAndPathAllowed(permissions[this.service], req))
49
+ return { approved: true, payload: verification };
50
+ return { approved: false, rejection: { code: 401, payload: { status: "Error", message: `Method or Path are not allowed: ${req.method} ${req.baseUrl + req.path.replace(/\/\d+$/, "")}` } } };
51
+ }
52
+ return { approved: false, rejection: { code: 401, payload: { status: "Error", message: "Service is not allowed" } } };
53
+ }
54
+ isMethodAndPathAllowed(permissions, req) {
55
+ return permissions[req.method] && permissions[req.method][req.baseUrl + req.path.replace(/\/\d+$/, "")];
56
+ }
57
+ unexpectedErrorRejection(error) {
58
+ var _a, _b, _c, _d;
59
+ return {
60
+ approved: false,
61
+ rejection: {
62
+ code: (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : 500,
63
+ payload: { status: "Error", message: (_d = (_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.data) !== null && _d !== void 0 ? _d : error, }
64
+ },
65
+ };
66
+ }
67
+ }
68
+ exports.RoleServicePermissionsChecker = RoleServicePermissionsChecker;
69
69
  //# sourceMappingURL=RoleServicePermissionsCheckers.js.map
@@ -1,28 +1,28 @@
1
- import { Request } from "express";
2
- import { APICheck, APICheckConfig, APICheckResult } from "itrm-tools";
3
- export interface IServiceSessionConfig {
4
- name: string;
5
- url: string;
6
- }
7
- export interface IServiceCredentials {
8
- apiKey: string;
9
- apiSecret: string;
10
- }
11
- export declare class ServiceSessionChecker implements APICheck {
12
- private token;
13
- private sessionServiceUrl;
14
- private config;
15
- constructor(sessionServiceUrl: string, config: IServiceSessionConfig);
16
- getConfig(): APICheckConfig;
17
- apply(config: APICheckConfig, req: Request): Promise<APICheckResult>;
18
- private createToken;
19
- sign(params: {
20
- method: string;
21
- path: string;
22
- }): Promise<{
23
- headers: {
24
- Authorization: string;
25
- };
26
- } | undefined>;
27
- private getServiceCredentials;
28
- }
1
+ import { Request } from "express";
2
+ import { APICheck, APICheckConfig, APICheckResult } from "itrm-tools";
3
+ export interface IServiceSessionConfig {
4
+ name: string;
5
+ url: string;
6
+ }
7
+ export interface IServiceCredentials {
8
+ apiKey: string;
9
+ apiSecret: string;
10
+ }
11
+ export declare class ServiceSessionChecker implements APICheck {
12
+ private token;
13
+ private sessionServiceUrl;
14
+ private config;
15
+ constructor(sessionServiceUrl: string, config: IServiceSessionConfig);
16
+ getConfig(): APICheckConfig;
17
+ apply(config: APICheckConfig, req: Request): Promise<APICheckResult>;
18
+ private createToken;
19
+ sign(params: {
20
+ method: string;
21
+ path: string;
22
+ }): Promise<{
23
+ headers: {
24
+ Authorization: string;
25
+ };
26
+ } | undefined>;
27
+ private getServiceCredentials;
28
+ }
@@ -1,106 +1,106 @@
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.ServiceSessionChecker = void 0;
13
- const crypto_js_1 = require("crypto-js");
14
- const itrm_tools_1 = require("itrm-tools");
15
- class ServiceSessionChecker {
16
- constructor(sessionServiceUrl, config) {
17
- this.token = "";
18
- this.sessionServiceUrl = sessionServiceUrl;
19
- this.config = config;
20
- }
21
- getConfig() {
22
- return {
23
- check: "serviceSession"
24
- };
25
- }
26
- apply(config, req) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- var _a;
29
- try {
30
- let verification = yield itrm_tools_1.RequestAxiosCall.post(`${this.sessionServiceUrl}/v1/verify`, { jwt: ((_a = req.headers.authorization) !== null && _a !== void 0 ? _a : 'NoToken').replace("Bearer ", ""),
31
- platform: req.headers.platform }, { headers: { "Authorization": this.token } });
32
- console.log("> verification:", verification);
33
- return {
34
- approved: true,
35
- payload: { headers: { "Authorization": this.token } }
36
- };
37
- }
38
- catch (err) {
39
- return yield this.createToken();
40
- }
41
- });
42
- }
43
- createToken() {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- var _a, _b, _c, _d, _e;
46
- try {
47
- const headers = yield this.sign({ method: "POST", path: "/login" });
48
- if (headers) {
49
- const session = yield itrm_tools_1.RequestAxiosCall.post(`${this.sessionServiceUrl}/service/login`, { service: this.config.name }, headers);
50
- this.token = (_c = (_b = (_a = session === null || session === void 0 ? void 0 : session.token) === null || _a === void 0 ? void 0 : _a.payload) === null || _b === void 0 ? void 0 : _b.jwt) !== null && _c !== void 0 ? _c : "";
51
- return {
52
- approved: true,
53
- payload: { headers: { "Authorization": this.token } }
54
- };
55
- }
56
- return {
57
- approved: false,
58
- rejection: {
59
- code: 500,
60
- payload: { status: 'Error', message: 'Public API is not available' }
61
- }
62
- };
63
- }
64
- catch (err) {
65
- return {
66
- approved: false,
67
- rejection: {
68
- code: 401,
69
- payload: (_e = (_d = err === null || err === void 0 ? void 0 : err.response) === null || _d === void 0 ? void 0 : _d.data) !== null && _e !== void 0 ? _e : err
70
- }
71
- };
72
- }
73
- });
74
- }
75
- sign(params) {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- const { method, path } = params;
78
- let nonce = Date.now();
79
- let message = `${nonce}${method}${path}${this.config.name ? JSON.stringify(this.config.name) : ""}`;
80
- const credentials = yield this.getServiceCredentials();
81
- if (credentials) {
82
- const hash = (0, crypto_js_1.HmacSHA256)(message, credentials.apiSecret);
83
- let signature = crypto_js_1.enc.Hex.stringify(hash);
84
- return {
85
- headers: {
86
- Authorization: `${credentials.apiKey}:${nonce}:${signature}`,
87
- },
88
- };
89
- }
90
- return undefined;
91
- });
92
- }
93
- getServiceCredentials() {
94
- return __awaiter(this, void 0, void 0, function* () {
95
- try {
96
- const credentials = yield itrm_tools_1.RequestAxiosCall.get(`${this.sessionServiceUrl}/service/credentials?service=${this.config.name}`, { headers: { referer: this.config.url } });
97
- return credentials.payload;
98
- }
99
- catch (error) {
100
- return undefined;
101
- }
102
- });
103
- }
104
- }
105
- exports.ServiceSessionChecker = ServiceSessionChecker;
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.ServiceSessionChecker = void 0;
13
+ const crypto_js_1 = require("crypto-js");
14
+ const itrm_tools_1 = require("itrm-tools");
15
+ class ServiceSessionChecker {
16
+ constructor(sessionServiceUrl, config) {
17
+ this.token = "";
18
+ this.sessionServiceUrl = sessionServiceUrl;
19
+ this.config = config;
20
+ }
21
+ getConfig() {
22
+ return {
23
+ check: "serviceSession"
24
+ };
25
+ }
26
+ apply(config, req) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ var _a;
29
+ try {
30
+ let verification = yield itrm_tools_1.RequestAxiosCall.post(`${this.sessionServiceUrl}/v1/verify`, { jwt: ((_a = req.headers.authorization) !== null && _a !== void 0 ? _a : 'NoToken').replace("Bearer ", ""),
31
+ platform: req.headers.platform }, { headers: { "Authorization": this.token } });
32
+ console.log("> verification:", verification);
33
+ return {
34
+ approved: true,
35
+ payload: { headers: { "Authorization": this.token } }
36
+ };
37
+ }
38
+ catch (err) {
39
+ return yield this.createToken();
40
+ }
41
+ });
42
+ }
43
+ createToken() {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ var _a, _b, _c, _d, _e;
46
+ try {
47
+ const headers = yield this.sign({ method: "POST", path: "/login" });
48
+ if (headers) {
49
+ const session = yield itrm_tools_1.RequestAxiosCall.post(`${this.sessionServiceUrl}/service/login`, { service: this.config.name }, headers);
50
+ this.token = (_c = (_b = (_a = session === null || session === void 0 ? void 0 : session.token) === null || _a === void 0 ? void 0 : _a.payload) === null || _b === void 0 ? void 0 : _b.jwt) !== null && _c !== void 0 ? _c : "";
51
+ return {
52
+ approved: true,
53
+ payload: { headers: { "Authorization": this.token } }
54
+ };
55
+ }
56
+ return {
57
+ approved: false,
58
+ rejection: {
59
+ code: 500,
60
+ payload: { status: 'Error', message: 'Public API is not available' }
61
+ }
62
+ };
63
+ }
64
+ catch (err) {
65
+ return {
66
+ approved: false,
67
+ rejection: {
68
+ code: 401,
69
+ payload: (_e = (_d = err === null || err === void 0 ? void 0 : err.response) === null || _d === void 0 ? void 0 : _d.data) !== null && _e !== void 0 ? _e : err
70
+ }
71
+ };
72
+ }
73
+ });
74
+ }
75
+ sign(params) {
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ const { method, path } = params;
78
+ let nonce = Date.now();
79
+ let message = `${nonce}${method}${path}${this.config.name ? JSON.stringify(this.config.name) : ""}`;
80
+ const credentials = yield this.getServiceCredentials();
81
+ if (credentials) {
82
+ const hash = (0, crypto_js_1.HmacSHA256)(message, credentials.apiSecret);
83
+ let signature = crypto_js_1.enc.Hex.stringify(hash);
84
+ return {
85
+ headers: {
86
+ Authorization: `${credentials.apiKey}:${nonce}:${signature}`,
87
+ },
88
+ };
89
+ }
90
+ return undefined;
91
+ });
92
+ }
93
+ getServiceCredentials() {
94
+ return __awaiter(this, void 0, void 0, function* () {
95
+ try {
96
+ const credentials = yield itrm_tools_1.RequestAxiosCall.get(`${this.sessionServiceUrl}/service/credentials?service=${this.config.name}`, { headers: { referer: this.config.url } });
97
+ return credentials.payload;
98
+ }
99
+ catch (error) {
100
+ return undefined;
101
+ }
102
+ });
103
+ }
104
+ }
105
+ exports.ServiceSessionChecker = ServiceSessionChecker;
106
106
  //# sourceMappingURL=ServiceSessionChecker.js.map
@@ -1,35 +1,35 @@
1
- import { CrudServiceManager, StandardIdRequestDefinition } from "itrm-tools";
2
- import { AxiosRequestConfig } from "axios";
3
- export interface IAvailablePlatform {
4
- availablePlatformId?: number;
5
- userId: number;
6
- roleId: number;
7
- platformId: number;
8
- restrictions: any;
9
- updatedAt?: string;
10
- createdAt?: string;
11
- config?: AxiosRequestConfig;
12
- }
13
- export interface IAvailablePlatformSearchDetails {
14
- userId?: number;
15
- roleId?: number;
16
- platformId?: number;
17
- restrictions?: any;
18
- limit?: number;
19
- offset?: number;
20
- config?: AxiosRequestConfig;
21
- }
22
- export declare class AvailablePlatformManager extends CrudServiceManager<IAvailablePlatformSearchDetails, IAvailablePlatform> {
23
- private url;
24
- constructor(url: string);
25
- find(details: IAvailablePlatformSearchDetails): Promise<IAvailablePlatform | undefined>;
26
- findAll(details: IAvailablePlatformSearchDetails): Promise<IAvailablePlatform[] | undefined>;
27
- findById(id: StandardIdRequestDefinition): Promise<IAvailablePlatform | undefined>;
28
- create(details: IAvailablePlatformSearchDetails): Promise<IAvailablePlatform | undefined>;
29
- modify(availablePlatform: IAvailablePlatform): Promise<any>;
30
- destroy(availablePlatforms: IAvailablePlatform): Promise<any>;
31
- count(details: IAvailablePlatform): Promise<{
32
- result: number;
33
- }>;
34
- private buildRequestUrl;
35
- }
1
+ import { CrudServiceManager, StandardIdRequestDefinition } from "itrm-tools";
2
+ import { AxiosRequestConfig } from "axios";
3
+ export interface IAvailablePlatform {
4
+ availablePlatformId?: number;
5
+ userId: number;
6
+ roleId: number;
7
+ platformId: number;
8
+ restrictions: any;
9
+ updatedAt?: string;
10
+ createdAt?: string;
11
+ config?: AxiosRequestConfig;
12
+ }
13
+ export interface IAvailablePlatformSearchDetails {
14
+ userId?: number;
15
+ roleId?: number;
16
+ platformId?: number;
17
+ restrictions?: any;
18
+ limit?: number;
19
+ offset?: number;
20
+ config?: AxiosRequestConfig;
21
+ }
22
+ export declare class AvailablePlatformManager extends CrudServiceManager<IAvailablePlatformSearchDetails, IAvailablePlatform> {
23
+ private url;
24
+ constructor(url: string);
25
+ find(details: IAvailablePlatformSearchDetails): Promise<IAvailablePlatform | undefined>;
26
+ findAll(details: IAvailablePlatformSearchDetails): Promise<IAvailablePlatform[] | undefined>;
27
+ findById(id: StandardIdRequestDefinition): Promise<IAvailablePlatform | undefined>;
28
+ create(details: IAvailablePlatformSearchDetails): Promise<IAvailablePlatform | undefined>;
29
+ modify(availablePlatform: IAvailablePlatform): Promise<any>;
30
+ destroy(availablePlatforms: IAvailablePlatform): Promise<any>;
31
+ count(details: IAvailablePlatform): Promise<{
32
+ result: number;
33
+ }>;
34
+ private buildRequestUrl;
35
+ }