@grandlinex/kernel 0.26.0 → 0.27.1
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/CHANGELOG.md +5 -0
- package/dist/Kernel.d.ts +2 -2
- package/dist/Kernel.js +20 -49
- package/dist/KernelModule.js +18 -72
- package/dist/actions/ApiAuthTestAction.d.ts +2 -2
- package/dist/actions/ApiAuthTestAction.js +11 -59
- package/dist/actions/ApiVersionAction.d.ts +2 -2
- package/dist/actions/ApiVersionAction.js +13 -61
- package/dist/actions/GetTokenAction.d.ts +2 -2
- package/dist/actions/GetTokenAction.js +33 -89
- package/dist/actions/index.js +3 -3
- package/dist/api/KernelEndpoint.js +3 -23
- package/dist/api/index.js +1 -1
- package/dist/classes/BaseAction.d.ts +3 -3
- package/dist/classes/BaseAction.js +45 -106
- package/dist/classes/BaseApiAction.js +14 -32
- package/dist/classes/BaseAuthProvider.d.ts +3 -3
- package/dist/classes/BaseAuthProvider.js +2 -5
- package/dist/classes/BaseEndpoint.d.ts +6 -3
- package/dist/classes/BaseEndpoint.js +41 -49
- package/dist/classes/BaseKernelModule.js +3 -23
- package/dist/classes/index.d.ts +2 -2
- package/dist/classes/index.js +20 -7
- package/dist/classes/timing/ExpressServerTiming.d.ts +3 -3
- package/dist/classes/timing/ExpressServerTiming.js +29 -61
- package/dist/classes/timing/ServerTiming.js +16 -52
- package/dist/classes/timing/ServerTimingElement.js +7 -8
- package/dist/classes/timing/index.js +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -2
- package/dist/lib/express.d.ts +6 -0
- package/dist/lib/express.js +2 -0
- package/dist/lib/index.d.ts +5 -4
- package/dist/modules/crypto/CryptoClient.d.ts +2 -2
- package/dist/modules/crypto/CryptoClient.js +60 -119
- package/dist/modules/crypto/index.js +1 -1
- package/dist/modules/crypto/utils/cors.d.ts +2 -2
- package/dist/modules/crypto/utils/cors.js +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
|
|
4
|
+
## [v0.27.1] - 2023-01-26
|
|
5
|
+
### Added
|
|
6
|
+
- Add raw body field for express calls
|
|
7
|
+
- change BaseEndpoint variables from private to protected
|
|
8
|
+
|
|
4
9
|
## [v0.25.2] - 2022-08-07
|
|
5
10
|
### Added
|
|
6
11
|
- Add express timing api in dev mode
|
package/dist/Kernel.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import CoreKernel, { CoreLogger } from '@grandlinex/core';
|
|
2
|
-
import { Request } from 'express';
|
|
3
2
|
import { ICClient, IKernel } from './lib';
|
|
3
|
+
import { XRequest } from './lib/express';
|
|
4
4
|
/**
|
|
5
5
|
* @class Kernel
|
|
6
6
|
*/
|
|
@@ -23,6 +23,6 @@ export default class Kernel extends CoreKernel<ICClient> implements IKernel {
|
|
|
23
23
|
setAppServerPort(port: number): void;
|
|
24
24
|
responseCodeFunction(data: {
|
|
25
25
|
code: number;
|
|
26
|
-
req:
|
|
26
|
+
req: XRequest;
|
|
27
27
|
}): void;
|
|
28
28
|
}
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
17
|
+
constructor(options) {
|
|
18
|
+
super(Object.assign({}, options));
|
|
19
|
+
this.setBaseModule(new KernelModule_1.default(this));
|
|
47
20
|
if (options.portOverride) {
|
|
48
|
-
|
|
49
|
-
|
|
21
|
+
this.debug(`use custiom api port @ ${options.portOverride}`);
|
|
22
|
+
this.expressPort = options.portOverride;
|
|
50
23
|
}
|
|
51
24
|
else {
|
|
52
|
-
|
|
25
|
+
this.expressPort = 9257;
|
|
53
26
|
}
|
|
54
|
-
|
|
27
|
+
const store = this.getConfigStore();
|
|
55
28
|
if (store.has('SERVER_PASSWORD')) {
|
|
56
|
-
|
|
29
|
+
this.setCryptoClient(new CryptoClient_1.default(CryptoClient_1.default.fromPW(store.get('SERVER_PASSWORD')), this));
|
|
57
30
|
}
|
|
58
|
-
return _this;
|
|
59
31
|
}
|
|
60
|
-
|
|
32
|
+
getAppServerPort() {
|
|
61
33
|
return this.expressPort;
|
|
62
|
-
}
|
|
63
|
-
|
|
34
|
+
}
|
|
35
|
+
setAppServerPort(port) {
|
|
64
36
|
this.expressPort = port;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
73
|
-
}(core_1.default));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
74
45
|
exports.default = Kernel;
|
package/dist/KernelModule.js
CHANGED
|
@@ -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 (g && (g = 0, op[0] && (_ = 0)), _) 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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
72
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
88
|
-
}(BaseKernelModule_1.default));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
89
35
|
exports.default = KernelModule;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import e from 'express';
|
|
2
1
|
import { IBaseKernelModule } from '../lib';
|
|
3
2
|
import { BaseApiAction, JwtToken } from '../classes';
|
|
3
|
+
import { XRequest, XResponse } from '../lib/express';
|
|
4
4
|
/**
|
|
5
5
|
* @name ApiAuthTestAction
|
|
6
6
|
*
|
|
@@ -23,5 +23,5 @@ import { BaseApiAction, JwtToken } from '../classes';
|
|
|
23
23
|
*/
|
|
24
24
|
export default class ApiAuthTestAction extends BaseApiAction {
|
|
25
25
|
constructor(module: IBaseKernelModule<any, any, any, any>);
|
|
26
|
-
handler(req:
|
|
26
|
+
handler(req: XRequest, res: XResponse, next: () => void, data: JwtToken): Promise<void>;
|
|
27
27
|
}
|
|
@@ -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 (g && (g = 0, op[0] && (_ = 0)), _) 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
|
-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
83
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
92
|
-
}(classes_1.BaseApiAction));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
93
45
|
exports.default = ApiAuthTestAction;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import e from 'express';
|
|
2
1
|
import { IBaseKernelModule } from '../lib';
|
|
3
2
|
import { BaseApiAction } from '../classes';
|
|
4
3
|
import { IExtensionInterface } from '../classes/timing/ExpressServerTiming';
|
|
4
|
+
import { XRequest, XResponse } from '../lib/express';
|
|
5
5
|
/**
|
|
6
6
|
* @name ApiVersionAction
|
|
7
7
|
*
|
|
@@ -27,5 +27,5 @@ import { IExtensionInterface } from '../classes/timing/ExpressServerTiming';
|
|
|
27
27
|
*/
|
|
28
28
|
export default class ApiVersionAction extends BaseApiAction {
|
|
29
29
|
constructor(module: IBaseKernelModule);
|
|
30
|
-
handler(req:
|
|
30
|
+
handler(req: XRequest, res: XResponse, next: () => void, data: any, ex: IExtensionInterface): Promise<void>;
|
|
31
31
|
}
|
|
@@ -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 (g && (g = 0, op[0] && (_ = 0)), _) 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
|
-
|
|
55
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
88
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
97
|
-
}(classes_1.BaseApiAction));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
98
50
|
exports.default = ApiVersionAction;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Request, Response } from 'express';
|
|
2
1
|
import { IBaseKernelModule } from '../lib';
|
|
3
2
|
import { BaseApiAction } from '../classes';
|
|
4
3
|
import { IExtensionInterface } from '../classes/timing/ExpressServerTiming';
|
|
4
|
+
import { XRequest, XResponse } from '../lib/express';
|
|
5
5
|
/**
|
|
6
6
|
* @openapi
|
|
7
7
|
* /token:
|
|
@@ -40,5 +40,5 @@ export default class GetTokenAction extends BaseApiAction {
|
|
|
40
40
|
* @param module Parent Module
|
|
41
41
|
*/
|
|
42
42
|
constructor(module: IBaseKernelModule<any, any, any, any>);
|
|
43
|
-
handler(req:
|
|
43
|
+
handler(req: XRequest, res: XResponse, next: () => void, data: any, ex: IExtensionInterface): Promise<void>;
|
|
44
44
|
}
|
|
@@ -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 (g && (g = 0, op[0] && (_ = 0)), _) 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
|
-
|
|
55
|
-
|
|
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
|
-
|
|
89
|
-
__extends(GetTokenAction, _super);
|
|
46
|
+
class GetTokenAction extends classes_1.BaseApiAction {
|
|
90
47
|
/**
|
|
91
48
|
*
|
|
92
49
|
* @param module Parent Module
|
|
93
50
|
*/
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
101
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
138
|
-
}(classes_1.BaseApiAction));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
139
83
|
exports.default = GetTokenAction;
|
package/dist/actions/index.js
CHANGED
|
@@ -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
|
-
|
|
7
|
+
const ApiAuthTestAction_1 = __importDefault(require("./ApiAuthTestAction"));
|
|
8
8
|
exports.ApiAuthTestAction = ApiAuthTestAction_1.default;
|
|
9
|
-
|
|
9
|
+
const ApiVersionAction_1 = __importDefault(require("./ApiVersionAction"));
|
|
10
10
|
exports.ApiVersionAction = ApiVersionAction_1.default;
|
|
11
|
-
|
|
11
|
+
const GetTokenAction_1 = __importDefault(require("./GetTokenAction"));
|
|
12
12
|
exports.GetTokenAction = GetTokenAction_1.default;
|