@grandlinex/kernel 0.20.0 → 0.22.1-alpha.0

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 (46) hide show
  1. package/CHANGELOG.md +71 -71
  2. package/LICENSE +29 -29
  3. package/README.md +30 -30
  4. package/dist/Kernel.d.ts +22 -21
  5. package/dist/Kernel.js +68 -60
  6. package/dist/KernelModule.d.ts +8 -10
  7. package/dist/KernelModule.js +89 -105
  8. package/dist/actions/ApiAuthTestAction.d.ts +27 -27
  9. package/dist/actions/ApiAuthTestAction.js +93 -92
  10. package/dist/actions/ApiVersionAction.d.ts +30 -30
  11. package/dist/actions/ApiVersionAction.js +96 -96
  12. package/dist/actions/GetTokenAction.d.ts +43 -43
  13. package/dist/actions/GetTokenAction.js +135 -133
  14. package/dist/actions/index.d.ts +4 -4
  15. package/dist/actions/index.js +12 -12
  16. package/dist/api/KernelEndpoint.d.ts +3 -3
  17. package/dist/api/KernelEndpoint.js +29 -29
  18. package/dist/api/index.d.ts +2 -2
  19. package/dist/api/index.js +8 -8
  20. package/dist/classes/BaseAction.d.ts +13 -13
  21. package/dist/classes/BaseAction.js +103 -103
  22. package/dist/classes/BaseApiAction.d.ts +8 -8
  23. package/dist/classes/BaseApiAction.js +67 -61
  24. package/dist/classes/BaseAuthProvider.d.ts +23 -16
  25. package/dist/classes/BaseAuthProvider.js +8 -8
  26. package/dist/classes/BaseEndpoint.d.ts +12 -12
  27. package/dist/classes/BaseEndpoint.js +61 -61
  28. package/dist/classes/BaseKernelModule.d.ts +5 -5
  29. package/dist/classes/BaseKernelModule.js +26 -26
  30. package/dist/classes/index.d.ts +8 -7
  31. package/dist/classes/index.js +34 -23
  32. package/dist/database/KernelDB.d.ts +14 -14
  33. package/dist/database/KernelDB.js +115 -115
  34. package/dist/database/entity/GKey.d.ts +8 -8
  35. package/dist/database/entity/GKey.js +61 -61
  36. package/dist/index.d.ts +14 -21
  37. package/dist/index.js +31 -54
  38. package/dist/lib/index.d.ts +31 -38
  39. package/dist/lib/index.js +2 -2
  40. package/dist/modules/crypto/CryptoClient.d.ts +19 -19
  41. package/dist/modules/crypto/CryptoClient.js +152 -170
  42. package/dist/modules/crypto/index.d.ts +3 -3
  43. package/dist/modules/crypto/index.js +19 -19
  44. package/dist/modules/crypto/utils/cors.d.ts +3 -3
  45. package/dist/modules/crypto/utils/cors.js +10 -10
  46. package/package.json +69 -72
@@ -1,29 +1,29 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- var BaseEndpoint_1 = __importDefault(require("../classes/BaseEndpoint"));
22
- var KernelEndpoint = /** @class */ (function (_super) {
23
- __extends(KernelEndpoint, _super);
24
- function KernelEndpoint() {
25
- return _super !== null && _super.apply(this, arguments) || this;
26
- }
27
- return KernelEndpoint;
28
- }(BaseEndpoint_1.default));
29
- exports.default = KernelEndpoint;
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ var BaseEndpoint_1 = __importDefault(require("../classes/BaseEndpoint"));
22
+ var KernelEndpoint = /** @class */ (function (_super) {
23
+ __extends(KernelEndpoint, _super);
24
+ function KernelEndpoint() {
25
+ return _super !== null && _super.apply(this, arguments) || this;
26
+ }
27
+ return KernelEndpoint;
28
+ }(BaseEndpoint_1.default));
29
+ exports.default = KernelEndpoint;
@@ -1,2 +1,2 @@
1
- import KernelEndpoint from './KernelEndpoint';
2
- export { KernelEndpoint };
1
+ import KernelEndpoint from './KernelEndpoint';
2
+ export { KernelEndpoint };
package/dist/api/index.js CHANGED
@@ -1,8 +1,8 @@
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.KernelEndpoint = void 0;
7
- var KernelEndpoint_1 = __importDefault(require("./KernelEndpoint"));
8
- exports.KernelEndpoint = KernelEndpoint_1.default;
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.KernelEndpoint = void 0;
7
+ var KernelEndpoint_1 = __importDefault(require("./KernelEndpoint"));
8
+ exports.KernelEndpoint = KernelEndpoint_1.default;
@@ -1,13 +1,13 @@
1
- import { Request, Response } from 'express';
2
- import { CoreAction } from '@grandlinex/core';
3
- import { IBaseAction, IBaseKernelModule } from '../lib';
4
- import { JwtToken } from './BaseAuthProvider';
5
- export default abstract class BaseAction extends CoreAction implements IBaseAction {
6
- dmz: boolean;
7
- constructor(chanel: string, module: IBaseKernelModule<any, any, any, any>);
8
- abstract handler(req: Request, res: Response, next: () => void, data: JwtToken | null): Promise<void>;
9
- secureHandler(req: Request, res: Response, next: () => void): Promise<void>;
10
- abstract register(): void;
11
- setDmz(val: boolean): void;
12
- getDmz(): boolean;
13
- }
1
+ import { Request, Response } from 'express';
2
+ import { CoreAction } from '@grandlinex/core';
3
+ import { IBaseAction, IBaseKernelModule } from '../lib';
4
+ import { JwtToken } from './BaseAuthProvider';
5
+ export default abstract class BaseAction extends CoreAction implements IBaseAction {
6
+ dmz: boolean;
7
+ constructor(chanel: string, module: IBaseKernelModule<any, any, any, any>);
8
+ abstract handler(req: Request, res: Response, next: () => void, data: JwtToken | null): Promise<void>;
9
+ secureHandler(req: Request, res: Response, next: () => void): Promise<void>;
10
+ abstract register(): void;
11
+ setDmz(val: boolean): void;
12
+ getDmz(): boolean;
13
+ }
@@ -1,103 +1,103 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
- return new (P || (P = Promise))(function (resolve, reject) {
20
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
- step((generator = generator.apply(thisArg, _arguments || [])).next());
24
- });
25
- };
26
- var __generator = (this && this.__generator) || function (thisArg, body) {
27
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
- function verb(n) { return function (v) { return step([n, v]); }; }
30
- function step(op) {
31
- if (f) throw new TypeError("Generator is already executing.");
32
- while (_) try {
33
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
- if (y = 0, t) op = [op[0] & 2, t.value];
35
- switch (op[0]) {
36
- case 0: case 1: t = op; break;
37
- case 4: _.label++; return { value: op[1], done: false };
38
- case 5: _.label++; y = op[1]; op = [0]; continue;
39
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
- default:
41
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
- if (t[2]) _.ops.pop();
46
- _.trys.pop(); continue;
47
- }
48
- op = body.call(thisArg, _);
49
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
- }
52
- };
53
- Object.defineProperty(exports, "__esModule", { value: true });
54
- var core_1 = require("@grandlinex/core");
55
- var BaseAction = /** @class */ (function (_super) {
56
- __extends(BaseAction, _super);
57
- function BaseAction(chanel, module) {
58
- var _this = _super.call(this, chanel, module) || this;
59
- _this.dmz = false;
60
- _this.secureHandler = _this.secureHandler.bind(_this);
61
- return _this;
62
- }
63
- BaseAction.prototype.secureHandler = function (req, res, next) {
64
- return __awaiter(this, void 0, void 0, function () {
65
- var cc, dat;
66
- return __generator(this, function (_a) {
67
- switch (_a.label) {
68
- case 0:
69
- cc = this.getKernel().getCryptoClient();
70
- if (!cc) {
71
- res.status(504).send('internal server error');
72
- return [2 /*return*/];
73
- }
74
- if (!this.dmz) return [3 /*break*/, 2];
75
- return [4 /*yield*/, this.handler(req, res, next, null)];
76
- case 1:
77
- _a.sent();
78
- return [2 /*return*/];
79
- case 2: return [4 /*yield*/, cc.bearerTokenValidation(req)];
80
- case 3:
81
- dat = _a.sent();
82
- if (!dat) return [3 /*break*/, 5];
83
- return [4 /*yield*/, this.handler(req, res, next, dat)];
84
- case 4:
85
- _a.sent();
86
- return [3 /*break*/, 6];
87
- case 5:
88
- res.status(401).send('no no no ...');
89
- _a.label = 6;
90
- case 6: return [2 /*return*/];
91
- }
92
- });
93
- });
94
- };
95
- BaseAction.prototype.setDmz = function (val) {
96
- this.dmz = val;
97
- };
98
- BaseAction.prototype.getDmz = function () {
99
- return this.dmz;
100
- };
101
- return BaseAction;
102
- }(core_1.CoreAction));
103
- exports.default = BaseAction;
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ var core_1 = require("@grandlinex/core");
55
+ var BaseAction = /** @class */ (function (_super) {
56
+ __extends(BaseAction, _super);
57
+ function BaseAction(chanel, module) {
58
+ var _this = _super.call(this, chanel, module) || this;
59
+ _this.dmz = false;
60
+ _this.secureHandler = _this.secureHandler.bind(_this);
61
+ return _this;
62
+ }
63
+ BaseAction.prototype.secureHandler = function (req, res, next) {
64
+ return __awaiter(this, void 0, void 0, function () {
65
+ var cc, dat;
66
+ return __generator(this, function (_a) {
67
+ switch (_a.label) {
68
+ case 0:
69
+ cc = this.getKernel().getCryptoClient();
70
+ if (!cc) {
71
+ res.status(504).send('internal server error');
72
+ return [2 /*return*/];
73
+ }
74
+ if (!this.dmz) return [3 /*break*/, 2];
75
+ return [4 /*yield*/, this.handler(req, res, next, null)];
76
+ case 1:
77
+ _a.sent();
78
+ return [2 /*return*/];
79
+ case 2: return [4 /*yield*/, cc.bearerTokenValidation(req)];
80
+ case 3:
81
+ dat = _a.sent();
82
+ if (!dat) return [3 /*break*/, 5];
83
+ return [4 /*yield*/, this.handler(req, res, next, dat)];
84
+ case 4:
85
+ _a.sent();
86
+ return [3 /*break*/, 6];
87
+ case 5:
88
+ res.status(401).send('no no no ...');
89
+ _a.label = 6;
90
+ case 6: return [2 /*return*/];
91
+ }
92
+ });
93
+ });
94
+ };
95
+ BaseAction.prototype.setDmz = function (val) {
96
+ this.dmz = val;
97
+ };
98
+ BaseAction.prototype.getDmz = function () {
99
+ return this.dmz;
100
+ };
101
+ return BaseAction;
102
+ }(core_1.CoreAction));
103
+ exports.default = BaseAction;
@@ -1,8 +1,8 @@
1
- import { ActionTypes, IBaseAction, IBaseKernelModule } from '../lib';
2
- import BaseAction from './BaseAction';
3
- export default abstract class BaseApiAction extends BaseAction implements IBaseAction {
4
- exmod: undefined | IBaseKernelModule<any, any, any, any>;
5
- type: ActionTypes;
6
- constructor(type: ActionTypes, chanel: string, module: IBaseKernelModule<any, any, any, any>, extMod?: IBaseKernelModule<any, any, any, any>);
7
- register(): void;
8
- }
1
+ import { ActionTypes, IBaseAction, IBaseKernelModule } from '../lib';
2
+ import BaseAction from './BaseAction';
3
+ export default abstract class BaseApiAction extends BaseAction implements IBaseAction {
4
+ exmod: undefined | IBaseKernelModule<any, any, any, any>;
5
+ type: ActionTypes;
6
+ constructor(type: ActionTypes, chanel: string, module: IBaseKernelModule<any, any, any, any>, extMod?: IBaseKernelModule<any, any, any, any>);
7
+ register(): void;
8
+ }
@@ -1,61 +1,67 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- var BaseAction_1 = __importDefault(require("./BaseAction"));
22
- var BaseApiAction = /** @class */ (function (_super) {
23
- __extends(BaseApiAction, _super);
24
- function BaseApiAction(type, chanel, module, extMod) {
25
- var _this = _super.call(this, chanel, module) || this;
26
- _this.exmod = extMod;
27
- _this.type = type;
28
- return _this;
29
- }
30
- BaseApiAction.prototype.register = function () {
31
- var endpoint;
32
- if (this.exmod) {
33
- endpoint = this.exmod.getPresenter();
34
- }
35
- else {
36
- endpoint = this.getModule().getPresenter();
37
- }
38
- if (endpoint) {
39
- this.log("register ".concat(this.getName()));
40
- var app = endpoint.getApp();
41
- switch (this.type) {
42
- case 'POST':
43
- app.post(this.getName(), this.secureHandler);
44
- break;
45
- case 'USE':
46
- app.use(this.getName(), this.secureHandler);
47
- break;
48
- case 'GET':
49
- default:
50
- app.get(this.getName(), this.secureHandler);
51
- break;
52
- }
53
- }
54
- else {
55
- this.error("on register -> ".concat(this.getName()));
56
- this.error("No Endpoint found");
57
- }
58
- };
59
- return BaseApiAction;
60
- }(BaseAction_1.default));
61
- exports.default = BaseApiAction;
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ var BaseAction_1 = __importDefault(require("./BaseAction"));
22
+ var BaseApiAction = /** @class */ (function (_super) {
23
+ __extends(BaseApiAction, _super);
24
+ function BaseApiAction(type, chanel, module, extMod) {
25
+ var _this = _super.call(this, chanel, module) || this;
26
+ _this.exmod = extMod;
27
+ _this.type = type;
28
+ return _this;
29
+ }
30
+ BaseApiAction.prototype.register = function () {
31
+ var endpoint;
32
+ if (this.exmod) {
33
+ endpoint = this.exmod.getPresenter();
34
+ }
35
+ else {
36
+ endpoint = this.getModule().getPresenter();
37
+ }
38
+ if (endpoint) {
39
+ this.log("register ".concat(this.type, " ").concat(this.getName()));
40
+ var app = endpoint.getApp();
41
+ switch (this.type) {
42
+ case 'POST':
43
+ app.post(this.getName(), this.secureHandler);
44
+ break;
45
+ case 'USE':
46
+ app.use(this.getName(), this.secureHandler);
47
+ break;
48
+ case 'PATCH':
49
+ app.patch(this.getName(), this.secureHandler);
50
+ break;
51
+ case 'DELETE':
52
+ app.delete(this.getName(), this.secureHandler);
53
+ break;
54
+ case 'GET':
55
+ default:
56
+ app.get(this.getName(), this.secureHandler);
57
+ break;
58
+ }
59
+ }
60
+ else {
61
+ this.error("on register -> ".concat(this.getName()));
62
+ this.error("No Endpoint found");
63
+ }
64
+ };
65
+ return BaseApiAction;
66
+ }(BaseAction_1.default));
67
+ exports.default = BaseApiAction;
@@ -1,16 +1,23 @@
1
- import { Request } from 'express';
2
- export interface JwtToken {
3
- exp: number;
4
- iat: number;
5
- username: string;
6
- }
7
- export interface IAuthProvider {
8
- authorizeToken(username: string, token: any, requestType: string): Promise<boolean>;
9
- validateAcces(token: JwtToken, requestType: string): Promise<boolean>;
10
- bearerTokenValidation(req: Request): Promise<JwtToken | null>;
11
- }
12
- export default abstract class BaseAuthProvider implements IAuthProvider {
13
- abstract authorizeToken(username: string, token: any, requestType: string): Promise<boolean>;
14
- abstract validateAcces(token: JwtToken, requestType: string): Promise<boolean>;
15
- abstract bearerTokenValidation(req: Request): Promise<JwtToken | null>;
16
- }
1
+ import { Request } from 'express';
2
+ export interface JwtTokenData {
3
+ username: string;
4
+ userid: string;
5
+ }
6
+ export interface JwtToken extends JwtTokenData {
7
+ exp: number;
8
+ iat: number;
9
+ }
10
+ export declare type AuthResult = {
11
+ valid: boolean;
12
+ userId: string | null;
13
+ };
14
+ export interface IAuthProvider {
15
+ authorizeToken(userid: string, token: string, requestType: string): Promise<AuthResult>;
16
+ validateAccess(token: JwtToken, requestType: string): Promise<boolean>;
17
+ bearerTokenValidation(req: Request): Promise<JwtToken | null>;
18
+ }
19
+ export default abstract class BaseAuthProvider implements IAuthProvider {
20
+ abstract authorizeToken(username: string, token: string, requestType: string): Promise<AuthResult>;
21
+ abstract validateAccess(token: JwtToken, requestType: string): Promise<boolean>;
22
+ abstract bearerTokenValidation(req: Request): Promise<JwtToken | null>;
23
+ }
@@ -1,8 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var BaseAuthProvider = /** @class */ (function () {
4
- function BaseAuthProvider() {
5
- }
6
- return BaseAuthProvider;
7
- }());
8
- exports.default = BaseAuthProvider;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var BaseAuthProvider = /** @class */ (function () {
4
+ function BaseAuthProvider() {
5
+ }
6
+ return BaseAuthProvider;
7
+ }());
8
+ exports.default = BaseAuthProvider;
@@ -1,12 +1,12 @@
1
- import express from 'express';
2
- import { CorePresenter } from '@grandlinex/core';
3
- import { IBaseKernelModule, IBasePresenter } from '../lib';
4
- export default abstract class BaseEndpoint extends CorePresenter<express.Express> implements IBasePresenter {
5
- private appServer;
6
- private httpServer;
7
- private port;
8
- constructor(chanel: string, module: IBaseKernelModule<any, any, any, any>, port: number);
9
- start(): Promise<boolean>;
10
- stop(): Promise<boolean>;
11
- getApp(): express.Express;
12
- }
1
+ import express from 'express';
2
+ import { CorePresenter } from '@grandlinex/core';
3
+ import { IBaseKernelModule, IBasePresenter } from '../lib';
4
+ export default abstract class BaseEndpoint extends CorePresenter<express.Express> implements IBasePresenter {
5
+ private appServer;
6
+ private httpServer;
7
+ private port;
8
+ constructor(chanel: string, module: IBaseKernelModule<any, any, any, any>, port: number);
9
+ start(): Promise<boolean>;
10
+ stop(): Promise<boolean>;
11
+ getApp(): express.Express;
12
+ }