@grandlinex/kernel 0.25.3 → 0.27.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.
package/dist/Kernel.d.ts CHANGED
@@ -16,6 +16,7 @@ export default class Kernel extends CoreKernel<ICClient> implements IKernel {
16
16
  pathOverride?: string;
17
17
  portOverride?: number;
18
18
  envFilePath?: string;
19
+ loadFromLocalEnv?: boolean;
19
20
  logger?: (k: CoreKernel<any>) => CoreLogger;
20
21
  });
21
22
  getAppServerPort(): number;
package/dist/Kernel.js CHANGED
@@ -1,74 +1,45 @@
1
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 __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
29
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
4
  };
31
5
  Object.defineProperty(exports, "__esModule", { value: true });
32
- var core_1 = __importDefault(require("@grandlinex/core"));
33
- var CryptoClient_1 = __importDefault(require("./modules/crypto/CryptoClient"));
34
- var KernelModule_1 = __importDefault(require("./KernelModule"));
6
+ const core_1 = __importDefault(require("@grandlinex/core"));
7
+ const CryptoClient_1 = __importDefault(require("./modules/crypto/CryptoClient"));
8
+ const KernelModule_1 = __importDefault(require("./KernelModule"));
35
9
  /**
36
10
  * @class Kernel
37
11
  */
38
- var Kernel = /** @class */ (function (_super) {
39
- __extends(Kernel, _super);
12
+ class Kernel extends core_1.default {
40
13
  /**
41
14
  * Default Constructor
42
15
  * @param options App Name
43
16
  */
44
- function Kernel(options) {
45
- var _this = _super.call(this, __assign({}, options)) || this;
46
- _this.setBaseModule(new KernelModule_1.default(_this));
17
+ constructor(options) {
18
+ super(Object.assign({}, options));
19
+ this.setBaseModule(new KernelModule_1.default(this));
47
20
  if (options.portOverride) {
48
- _this.debug("use custiom api port @ ".concat(options.portOverride));
49
- _this.expressPort = options.portOverride;
21
+ this.debug(`use custiom api port @ ${options.portOverride}`);
22
+ this.expressPort = options.portOverride;
50
23
  }
51
24
  else {
52
- _this.expressPort = 9257;
25
+ this.expressPort = 9257;
53
26
  }
54
- var store = _this.getConfigStore();
27
+ const store = this.getConfigStore();
55
28
  if (store.has('SERVER_PASSWORD')) {
56
- _this.setCryptoClient(new CryptoClient_1.default(CryptoClient_1.default.fromPW(store.get('SERVER_PASSWORD')), _this));
29
+ this.setCryptoClient(new CryptoClient_1.default(CryptoClient_1.default.fromPW(store.get('SERVER_PASSWORD')), this));
57
30
  }
58
- return _this;
59
31
  }
60
- Kernel.prototype.getAppServerPort = function () {
32
+ getAppServerPort() {
61
33
  return this.expressPort;
62
- };
63
- Kernel.prototype.setAppServerPort = function (port) {
34
+ }
35
+ setAppServerPort(port) {
64
36
  this.expressPort = port;
65
- };
66
- Kernel.prototype.responseCodeFunction = function (data) {
67
- var code = data.code;
37
+ }
38
+ responseCodeFunction(data) {
39
+ const { code } = data;
68
40
  if (code < 200 || code >= 300) {
69
41
  this.debug(data.req.path, data.req.ip, data.code);
70
42
  }
71
- };
72
- return Kernel;
73
- }(core_1.default));
43
+ }
44
+ }
74
45
  exports.default = Kernel;
@@ -1,19 +1,4 @@
1
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
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -23,67 +8,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
23
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
24
9
  });
25
10
  };
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
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
54
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
55
13
  };
56
14
  Object.defineProperty(exports, "__esModule", { value: true });
57
- var core_1 = require("@grandlinex/core");
58
- var BaseKernelModule_1 = __importDefault(require("./classes/BaseKernelModule"));
59
- var KernelEndpoint_1 = __importDefault(require("./api/KernelEndpoint"));
60
- var ApiVersionAction_1 = __importDefault(require("./actions/ApiVersionAction"));
61
- var GetTokenAction_1 = __importDefault(require("./actions/GetTokenAction"));
62
- var ApiAuthTestAction_1 = __importDefault(require("./actions/ApiAuthTestAction"));
63
- var KernelModule = /** @class */ (function (_super) {
64
- __extends(KernelModule, _super);
65
- function KernelModule(kernel) {
66
- var _this = _super.call(this, 'base-mod', kernel) || this;
67
- _this.addAction(new ApiVersionAction_1.default(_this), new ApiAuthTestAction_1.default(_this), new GetTokenAction_1.default(_this));
68
- _this.addService(new core_1.OfflineService(_this));
69
- return _this;
15
+ const core_1 = require("@grandlinex/core");
16
+ const BaseKernelModule_1 = __importDefault(require("./classes/BaseKernelModule"));
17
+ const KernelEndpoint_1 = __importDefault(require("./api/KernelEndpoint"));
18
+ const ApiVersionAction_1 = __importDefault(require("./actions/ApiVersionAction"));
19
+ const GetTokenAction_1 = __importDefault(require("./actions/GetTokenAction"));
20
+ const ApiAuthTestAction_1 = __importDefault(require("./actions/ApiAuthTestAction"));
21
+ class KernelModule extends BaseKernelModule_1.default {
22
+ constructor(kernel) {
23
+ super('base-mod', kernel);
24
+ this.addAction(new ApiVersionAction_1.default(this), new ApiAuthTestAction_1.default(this), new GetTokenAction_1.default(this));
25
+ this.addService(new core_1.OfflineService(this));
70
26
  }
71
- KernelModule.prototype.initModule = function () {
72
- return __awaiter(this, void 0, void 0, function () {
73
- var endpoint;
74
- return __generator(this, function (_a) {
75
- switch (_a.label) {
76
- case 0:
77
- endpoint = new KernelEndpoint_1.default('api', this, this.getKernel().getAppServerPort());
78
- this.setPresenter(endpoint);
79
- return [4 /*yield*/, this.getKernel().triggerFunction('load')];
80
- case 1:
81
- _a.sent();
82
- return [2 /*return*/];
83
- }
84
- });
27
+ initModule() {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const endpoint = new KernelEndpoint_1.default('api', this, this.getKernel().getAppServerPort());
30
+ this.setPresenter(endpoint);
31
+ yield this.getKernel().triggerFunction('load');
85
32
  });
86
- };
87
- return KernelModule;
88
- }(BaseKernelModule_1.default));
33
+ }
34
+ }
89
35
  exports.default = KernelModule;
@@ -1,19 +1,4 @@
1
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
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -23,35 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
23
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
24
9
  });
25
10
  };
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
11
  Object.defineProperty(exports, "__esModule", { value: true });
54
- var classes_1 = require("../classes");
12
+ const classes_1 = require("../classes");
55
13
  /**
56
14
  * @name ApiAuthTestAction
57
15
  *
@@ -72,22 +30,16 @@ var classes_1 = require("../classes");
72
30
  * description: invalid token / not authorized
73
31
  *
74
32
  */
75
- var ApiAuthTestAction = /** @class */ (function (_super) {
76
- __extends(ApiAuthTestAction, _super);
77
- function ApiAuthTestAction(module) {
78
- var _this = _super.call(this, 'GET', '/test/auth', module) || this;
79
- _this.handler = _this.handler.bind(_this);
80
- return _this;
33
+ class ApiAuthTestAction extends classes_1.BaseApiAction {
34
+ constructor(module) {
35
+ super('GET', '/test/auth', module);
36
+ this.handler = this.handler.bind(this);
81
37
  }
82
- ApiAuthTestAction.prototype.handler = function (req, res, next, data) {
83
- return __awaiter(this, void 0, void 0, function () {
84
- return __generator(this, function (_a) {
85
- this.debug(data.userid);
86
- res.status(200).send("It work's");
87
- return [2 /*return*/];
88
- });
38
+ handler(req, res, next, data) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ this.debug(data.userid);
41
+ res.status(200).send("It work's");
89
42
  });
90
- };
91
- return ApiAuthTestAction;
92
- }(classes_1.BaseApiAction));
43
+ }
44
+ }
93
45
  exports.default = ApiAuthTestAction;
@@ -1,19 +1,4 @@
1
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
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -23,36 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
23
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
24
9
  });
25
10
  };
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
11
  Object.defineProperty(exports, "__esModule", { value: true });
54
- var classes_1 = require("../classes");
55
- var BaseAction_1 = require("../classes/BaseAction");
12
+ const classes_1 = require("../classes");
13
+ const BaseAction_1 = require("../classes/BaseAction");
56
14
  /**
57
15
  * @name ApiVersionAction
58
16
  *
@@ -76,23 +34,17 @@ var BaseAction_1 = require("../classes/BaseAction");
76
34
  * description: invalid token / not authorized
77
35
  *
78
36
  */
79
- var ApiVersionAction = /** @class */ (function (_super) {
80
- __extends(ApiVersionAction, _super);
81
- function ApiVersionAction(module) {
82
- var _this = _super.call(this, 'GET', '/version', module) || this;
83
- _this.handler = _this.handler.bind(_this);
84
- _this.setMode(BaseAction_1.ActionMode.DMZ);
85
- return _this;
37
+ class ApiVersionAction extends classes_1.BaseApiAction {
38
+ constructor(module) {
39
+ super('GET', '/version', module);
40
+ this.handler = this.handler.bind(this);
41
+ this.setMode(BaseAction_1.ActionMode.DMZ);
86
42
  }
87
- ApiVersionAction.prototype.handler = function (req, res, next, data, ex) {
88
- return __awaiter(this, void 0, void 0, function () {
89
- return __generator(this, function (_a) {
90
- ex.done();
91
- res.status(200).send({ api: 1 });
92
- return [2 /*return*/];
93
- });
43
+ handler(req, res, next, data, ex) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ ex.done();
46
+ res.status(200).send({ api: 1 });
94
47
  });
95
- };
96
- return ApiVersionAction;
97
- }(classes_1.BaseApiAction));
48
+ }
49
+ }
98
50
  exports.default = ApiVersionAction;
@@ -1,19 +1,4 @@
1
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
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -23,36 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
23
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
24
9
  });
25
10
  };
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
11
  Object.defineProperty(exports, "__esModule", { value: true });
54
- var classes_1 = require("../classes");
55
- var BaseAction_1 = require("../classes/BaseAction");
12
+ const classes_1 = require("../classes");
13
+ const BaseAction_1 = require("../classes/BaseAction");
56
14
  /**
57
15
  * @openapi
58
16
  * /token:
@@ -85,55 +43,41 @@ var BaseAction_1 = require("../classes/BaseAction");
85
43
  * token:
86
44
  * type: string
87
45
  */
88
- var GetTokenAction = /** @class */ (function (_super) {
89
- __extends(GetTokenAction, _super);
46
+ class GetTokenAction extends classes_1.BaseApiAction {
90
47
  /**
91
48
  *
92
49
  * @param module Parent Module
93
50
  */
94
- function GetTokenAction(module) {
95
- var _this = _super.call(this, 'POST', '/token', module) || this;
96
- _this.handler = _this.handler.bind(_this);
97
- _this.setMode(BaseAction_1.ActionMode.DMZ);
98
- return _this;
51
+ constructor(module) {
52
+ super('POST', '/token', module);
53
+ this.handler = this.handler.bind(this);
54
+ this.setMode(BaseAction_1.ActionMode.DMZ);
99
55
  }
100
- GetTokenAction.prototype.handler = function (req, res, next, data, ex) {
101
- return __awaiter(this, void 0, void 0, function () {
102
- var cc, _a, username, token, valid, jwt;
103
- return __generator(this, function (_b) {
104
- switch (_b.label) {
105
- case 0:
106
- cc = this.getKernel().getCryptoClient();
107
- if (!req.body.token) {
108
- res.status(400).send('no token');
109
- return [2 /*return*/];
110
- }
111
- if (!req.body.username) {
112
- res.status(401).send('no username');
113
- return [2 /*return*/];
114
- }
115
- _a = req.body, username = _a.username, token = _a.token;
116
- return [4 /*yield*/, ex.timing.startFunc('validation', function () {
117
- return cc.apiTokenValidation(username, token, 'api');
118
- })];
119
- case 1:
120
- valid = _b.sent();
121
- if (valid.valid && valid.userId) {
122
- jwt = cc.jwtGenerateAccessToken({
123
- userid: valid.userId,
124
- username: username,
125
- });
126
- ex.done();
127
- res.status(200).send({ token: jwt });
128
- }
129
- else {
130
- res.status(403).send('no no no ...');
131
- }
132
- return [2 /*return*/];
133
- }
134
- });
56
+ handler(req, res, next, data, ex) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ const cc = this.getKernel().getCryptoClient();
59
+ if (!req.body.token) {
60
+ res.status(400).send('no token');
61
+ return;
62
+ }
63
+ if (!req.body.username) {
64
+ res.status(401).send('no username');
65
+ return;
66
+ }
67
+ const { username, token } = req.body;
68
+ const valid = yield ex.timing.startFunc('validation', () => cc.apiTokenValidation(username, token, 'api'));
69
+ if (valid.valid && valid.userId) {
70
+ const jwt = cc.jwtGenerateAccessToken({
71
+ userid: valid.userId,
72
+ username,
73
+ });
74
+ ex.done();
75
+ res.status(200).send({ token: jwt });
76
+ }
77
+ else {
78
+ res.status(403).send('no no no ...');
79
+ }
135
80
  });
136
- };
137
- return GetTokenAction;
138
- }(classes_1.BaseApiAction));
81
+ }
82
+ }
139
83
  exports.default = GetTokenAction;
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.GetTokenAction = exports.ApiAuthTestAction = exports.ApiVersionAction = void 0;
7
- var ApiAuthTestAction_1 = __importDefault(require("./ApiAuthTestAction"));
7
+ const ApiAuthTestAction_1 = __importDefault(require("./ApiAuthTestAction"));
8
8
  exports.ApiAuthTestAction = ApiAuthTestAction_1.default;
9
- var ApiVersionAction_1 = __importDefault(require("./ApiVersionAction"));
9
+ const ApiVersionAction_1 = __importDefault(require("./ApiVersionAction"));
10
10
  exports.ApiVersionAction = ApiVersionAction_1.default;
11
- var GetTokenAction_1 = __importDefault(require("./GetTokenAction"));
11
+ const GetTokenAction_1 = __importDefault(require("./GetTokenAction"));
12
12
  exports.GetTokenAction = GetTokenAction_1.default;
@@ -1,29 +1,9 @@
1
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
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
18
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
4
  };
20
5
  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));
6
+ const BaseEndpoint_1 = __importDefault(require("../classes/BaseEndpoint"));
7
+ class KernelEndpoint extends BaseEndpoint_1.default {
8
+ }
29
9
  exports.default = KernelEndpoint;
package/dist/api/index.js CHANGED
@@ -4,5 +4,5 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.KernelEndpoint = void 0;
7
- var KernelEndpoint_1 = __importDefault(require("./KernelEndpoint"));
7
+ const KernelEndpoint_1 = __importDefault(require("./KernelEndpoint"));
8
8
  exports.KernelEndpoint = KernelEndpoint_1.default;