@grandlinex/kernel 0.22.1-alpha.0 → 0.24.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/CHANGELOG.md +71 -71
- package/LICENSE +29 -29
- package/README.md +30 -30
- package/dist/Kernel.d.ts +27 -22
- package/dist/Kernel.js +74 -68
- package/dist/KernelModule.d.ts +8 -8
- package/dist/KernelModule.js +89 -89
- package/dist/actions/ApiAuthTestAction.d.ts +27 -27
- package/dist/actions/ApiAuthTestAction.js +93 -93
- package/dist/actions/ApiVersionAction.d.ts +30 -30
- package/dist/actions/ApiVersionAction.js +96 -96
- package/dist/actions/GetTokenAction.d.ts +43 -43
- package/dist/actions/GetTokenAction.js +135 -135
- package/dist/actions/index.d.ts +4 -4
- package/dist/actions/index.js +12 -12
- package/dist/api/KernelEndpoint.d.ts +3 -3
- package/dist/api/KernelEndpoint.js +29 -29
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.js +8 -8
- package/dist/classes/BaseAction.d.ts +13 -13
- package/dist/classes/BaseAction.js +110 -103
- package/dist/classes/BaseApiAction.d.ts +9 -8
- package/dist/classes/BaseApiAction.js +67 -67
- package/dist/classes/BaseAuthProvider.d.ts +23 -23
- package/dist/classes/BaseAuthProvider.js +8 -8
- package/dist/classes/BaseEndpoint.d.ts +12 -12
- package/dist/classes/BaseEndpoint.js +61 -61
- package/dist/classes/BaseKernelModule.d.ts +4 -5
- package/dist/classes/BaseKernelModule.js +26 -26
- package/dist/classes/index.d.ts +8 -8
- package/dist/classes/index.js +38 -34
- package/dist/index.d.ts +14 -14
- package/dist/index.js +35 -31
- package/dist/lib/index.d.ts +35 -31
- package/dist/lib/index.js +2 -2
- package/dist/modules/crypto/CryptoClient.d.ts +19 -19
- package/dist/modules/crypto/CryptoClient.js +152 -152
- package/dist/modules/crypto/index.d.ts +3 -3
- package/dist/modules/crypto/index.js +23 -19
- package/dist/modules/crypto/utils/cors.d.ts +3 -3
- package/dist/modules/crypto/utils/cors.js +10 -10
- package/package.json +69 -69
- package/dist/database/KernelDB.d.ts +0 -14
- package/dist/database/KernelDB.js +0 -115
- package/dist/database/entity/GKey.d.ts +0 -8
- package/dist/database/entity/GKey.js +0 -61
|
@@ -1,96 +1,96 @@
|
|
|
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 classes_1 = require("../classes");
|
|
55
|
-
/**
|
|
56
|
-
* @name ApiVersionAction
|
|
57
|
-
*
|
|
58
|
-
* @openapi
|
|
59
|
-
* /version:
|
|
60
|
-
* get:
|
|
61
|
-
* summary: get api schema version
|
|
62
|
-
* tags:
|
|
63
|
-
* - Kernel
|
|
64
|
-
* responses:
|
|
65
|
-
* 200:
|
|
66
|
-
* description: OK
|
|
67
|
-
* content:
|
|
68
|
-
* application/json:
|
|
69
|
-
* schema:
|
|
70
|
-
* type: object
|
|
71
|
-
* properties:
|
|
72
|
-
* api:
|
|
73
|
-
* type: number
|
|
74
|
-
* 401:
|
|
75
|
-
* description: invalid token / not authorized
|
|
76
|
-
*
|
|
77
|
-
*/
|
|
78
|
-
var ApiVersionAction = /** @class */ (function (_super) {
|
|
79
|
-
__extends(ApiVersionAction, _super);
|
|
80
|
-
function ApiVersionAction(module) {
|
|
81
|
-
var _this = _super.call(this, 'GET', '/version', module) || this;
|
|
82
|
-
_this.handler = _this.handler.bind(_this);
|
|
83
|
-
_this.setDmz(true);
|
|
84
|
-
return _this;
|
|
85
|
-
}
|
|
86
|
-
ApiVersionAction.prototype.handler = function (req, res, next) {
|
|
87
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
88
|
-
return __generator(this, function (_a) {
|
|
89
|
-
res.status(200).send({ api: 1 });
|
|
90
|
-
return [2 /*return*/];
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
|
-
return ApiVersionAction;
|
|
95
|
-
}(classes_1.BaseApiAction));
|
|
96
|
-
exports.default = ApiVersionAction;
|
|
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 classes_1 = require("../classes");
|
|
55
|
+
/**
|
|
56
|
+
* @name ApiVersionAction
|
|
57
|
+
*
|
|
58
|
+
* @openapi
|
|
59
|
+
* /version:
|
|
60
|
+
* get:
|
|
61
|
+
* summary: get api schema version
|
|
62
|
+
* tags:
|
|
63
|
+
* - Kernel
|
|
64
|
+
* responses:
|
|
65
|
+
* 200:
|
|
66
|
+
* description: OK
|
|
67
|
+
* content:
|
|
68
|
+
* application/json:
|
|
69
|
+
* schema:
|
|
70
|
+
* type: object
|
|
71
|
+
* properties:
|
|
72
|
+
* api:
|
|
73
|
+
* type: number
|
|
74
|
+
* 401:
|
|
75
|
+
* description: invalid token / not authorized
|
|
76
|
+
*
|
|
77
|
+
*/
|
|
78
|
+
var ApiVersionAction = /** @class */ (function (_super) {
|
|
79
|
+
__extends(ApiVersionAction, _super);
|
|
80
|
+
function ApiVersionAction(module) {
|
|
81
|
+
var _this = _super.call(this, 'GET', '/version', module) || this;
|
|
82
|
+
_this.handler = _this.handler.bind(_this);
|
|
83
|
+
_this.setDmz(true);
|
|
84
|
+
return _this;
|
|
85
|
+
}
|
|
86
|
+
ApiVersionAction.prototype.handler = function (req, res, next) {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
88
|
+
return __generator(this, function (_a) {
|
|
89
|
+
res.status(200).send({ api: 1 });
|
|
90
|
+
return [2 /*return*/];
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
return ApiVersionAction;
|
|
95
|
+
}(classes_1.BaseApiAction));
|
|
96
|
+
exports.default = ApiVersionAction;
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { Request, Response } from 'express';
|
|
2
|
-
import { IBaseKernelModule } from '../lib';
|
|
3
|
-
import { BaseApiAction } from '../classes';
|
|
4
|
-
/**
|
|
5
|
-
* @openapi
|
|
6
|
-
* /token:
|
|
7
|
-
* post:
|
|
8
|
-
* summary: Get Bearer for user.
|
|
9
|
-
* tags:
|
|
10
|
-
* - Kernel
|
|
11
|
-
* description: Returns JWT.
|
|
12
|
-
* responses:
|
|
13
|
-
* '200':
|
|
14
|
-
* description: OK
|
|
15
|
-
* content:
|
|
16
|
-
* application/json:
|
|
17
|
-
* schema:
|
|
18
|
-
* type: object
|
|
19
|
-
* properties:
|
|
20
|
-
* token:
|
|
21
|
-
* type: string
|
|
22
|
-
* '403':
|
|
23
|
-
* description: Not Authorized
|
|
24
|
-
* requestBody:
|
|
25
|
-
* required: true
|
|
26
|
-
* content:
|
|
27
|
-
* application/json:
|
|
28
|
-
* schema:
|
|
29
|
-
* type: object
|
|
30
|
-
* properties:
|
|
31
|
-
* username:
|
|
32
|
-
* type: string
|
|
33
|
-
* token:
|
|
34
|
-
* type: string
|
|
35
|
-
*/
|
|
36
|
-
export default class GetTokenAction extends BaseApiAction {
|
|
37
|
-
/**
|
|
38
|
-
*
|
|
39
|
-
* @param module Parent Module
|
|
40
|
-
*/
|
|
41
|
-
constructor(module: IBaseKernelModule<any, any, any, any>);
|
|
42
|
-
handler(req: Request, res: Response, next: () => void): Promise<void>;
|
|
43
|
-
}
|
|
1
|
+
import { Request, Response } from 'express';
|
|
2
|
+
import { IBaseKernelModule } from '../lib';
|
|
3
|
+
import { BaseApiAction } from '../classes';
|
|
4
|
+
/**
|
|
5
|
+
* @openapi
|
|
6
|
+
* /token:
|
|
7
|
+
* post:
|
|
8
|
+
* summary: Get Bearer for user.
|
|
9
|
+
* tags:
|
|
10
|
+
* - Kernel
|
|
11
|
+
* description: Returns JWT.
|
|
12
|
+
* responses:
|
|
13
|
+
* '200':
|
|
14
|
+
* description: OK
|
|
15
|
+
* content:
|
|
16
|
+
* application/json:
|
|
17
|
+
* schema:
|
|
18
|
+
* type: object
|
|
19
|
+
* properties:
|
|
20
|
+
* token:
|
|
21
|
+
* type: string
|
|
22
|
+
* '403':
|
|
23
|
+
* description: Not Authorized
|
|
24
|
+
* requestBody:
|
|
25
|
+
* required: true
|
|
26
|
+
* content:
|
|
27
|
+
* application/json:
|
|
28
|
+
* schema:
|
|
29
|
+
* type: object
|
|
30
|
+
* properties:
|
|
31
|
+
* username:
|
|
32
|
+
* type: string
|
|
33
|
+
* token:
|
|
34
|
+
* type: string
|
|
35
|
+
*/
|
|
36
|
+
export default class GetTokenAction extends BaseApiAction {
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @param module Parent Module
|
|
40
|
+
*/
|
|
41
|
+
constructor(module: IBaseKernelModule<any, any, any, any>);
|
|
42
|
+
handler(req: Request, res: Response, next: () => void): Promise<void>;
|
|
43
|
+
}
|
|
@@ -1,135 +1,135 @@
|
|
|
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 classes_1 = require("../classes");
|
|
55
|
-
/**
|
|
56
|
-
* @openapi
|
|
57
|
-
* /token:
|
|
58
|
-
* post:
|
|
59
|
-
* summary: Get Bearer for user.
|
|
60
|
-
* tags:
|
|
61
|
-
* - Kernel
|
|
62
|
-
* description: Returns JWT.
|
|
63
|
-
* responses:
|
|
64
|
-
* '200':
|
|
65
|
-
* description: OK
|
|
66
|
-
* content:
|
|
67
|
-
* application/json:
|
|
68
|
-
* schema:
|
|
69
|
-
* type: object
|
|
70
|
-
* properties:
|
|
71
|
-
* token:
|
|
72
|
-
* type: string
|
|
73
|
-
* '403':
|
|
74
|
-
* description: Not Authorized
|
|
75
|
-
* requestBody:
|
|
76
|
-
* required: true
|
|
77
|
-
* content:
|
|
78
|
-
* application/json:
|
|
79
|
-
* schema:
|
|
80
|
-
* type: object
|
|
81
|
-
* properties:
|
|
82
|
-
* username:
|
|
83
|
-
* type: string
|
|
84
|
-
* token:
|
|
85
|
-
* type: string
|
|
86
|
-
*/
|
|
87
|
-
var GetTokenAction = /** @class */ (function (_super) {
|
|
88
|
-
__extends(GetTokenAction, _super);
|
|
89
|
-
/**
|
|
90
|
-
*
|
|
91
|
-
* @param module Parent Module
|
|
92
|
-
*/
|
|
93
|
-
function GetTokenAction(module) {
|
|
94
|
-
var _this = _super.call(this, 'POST', '/token', module) || this;
|
|
95
|
-
_this.handler = _this.handler.bind(_this);
|
|
96
|
-
_this.setDmz(true);
|
|
97
|
-
return _this;
|
|
98
|
-
}
|
|
99
|
-
GetTokenAction.prototype.handler = function (req, res, next) {
|
|
100
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
-
var cc, _a, username, token, valid, jwt;
|
|
102
|
-
return __generator(this, function (_b) {
|
|
103
|
-
switch (_b.label) {
|
|
104
|
-
case 0:
|
|
105
|
-
cc = this.getKernel().getCryptoClient();
|
|
106
|
-
if (!req.body.token) {
|
|
107
|
-
res.status(400).send('no token');
|
|
108
|
-
return [2 /*return*/];
|
|
109
|
-
}
|
|
110
|
-
if (!req.body.username) {
|
|
111
|
-
res.status(401).send('no username');
|
|
112
|
-
return [2 /*return*/];
|
|
113
|
-
}
|
|
114
|
-
_a = req.body, username = _a.username, token = _a.token;
|
|
115
|
-
return [4 /*yield*/, cc.apiTokenValidation(username, token, 'api')];
|
|
116
|
-
case 1:
|
|
117
|
-
valid = _b.sent();
|
|
118
|
-
if (valid.valid && valid.userId) {
|
|
119
|
-
jwt = cc.jwtGenerateAccessToken({
|
|
120
|
-
userid: valid.userId,
|
|
121
|
-
username: username,
|
|
122
|
-
});
|
|
123
|
-
res.status(200).send({ token: jwt });
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
res.status(403).send('no no no ...');
|
|
127
|
-
}
|
|
128
|
-
return [2 /*return*/];
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
return GetTokenAction;
|
|
134
|
-
}(classes_1.BaseApiAction));
|
|
135
|
-
exports.default = GetTokenAction;
|
|
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 classes_1 = require("../classes");
|
|
55
|
+
/**
|
|
56
|
+
* @openapi
|
|
57
|
+
* /token:
|
|
58
|
+
* post:
|
|
59
|
+
* summary: Get Bearer for user.
|
|
60
|
+
* tags:
|
|
61
|
+
* - Kernel
|
|
62
|
+
* description: Returns JWT.
|
|
63
|
+
* responses:
|
|
64
|
+
* '200':
|
|
65
|
+
* description: OK
|
|
66
|
+
* content:
|
|
67
|
+
* application/json:
|
|
68
|
+
* schema:
|
|
69
|
+
* type: object
|
|
70
|
+
* properties:
|
|
71
|
+
* token:
|
|
72
|
+
* type: string
|
|
73
|
+
* '403':
|
|
74
|
+
* description: Not Authorized
|
|
75
|
+
* requestBody:
|
|
76
|
+
* required: true
|
|
77
|
+
* content:
|
|
78
|
+
* application/json:
|
|
79
|
+
* schema:
|
|
80
|
+
* type: object
|
|
81
|
+
* properties:
|
|
82
|
+
* username:
|
|
83
|
+
* type: string
|
|
84
|
+
* token:
|
|
85
|
+
* type: string
|
|
86
|
+
*/
|
|
87
|
+
var GetTokenAction = /** @class */ (function (_super) {
|
|
88
|
+
__extends(GetTokenAction, _super);
|
|
89
|
+
/**
|
|
90
|
+
*
|
|
91
|
+
* @param module Parent Module
|
|
92
|
+
*/
|
|
93
|
+
function GetTokenAction(module) {
|
|
94
|
+
var _this = _super.call(this, 'POST', '/token', module) || this;
|
|
95
|
+
_this.handler = _this.handler.bind(_this);
|
|
96
|
+
_this.setDmz(true);
|
|
97
|
+
return _this;
|
|
98
|
+
}
|
|
99
|
+
GetTokenAction.prototype.handler = function (req, res, next) {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
+
var cc, _a, username, token, valid, jwt;
|
|
102
|
+
return __generator(this, function (_b) {
|
|
103
|
+
switch (_b.label) {
|
|
104
|
+
case 0:
|
|
105
|
+
cc = this.getKernel().getCryptoClient();
|
|
106
|
+
if (!req.body.token) {
|
|
107
|
+
res.status(400).send('no token');
|
|
108
|
+
return [2 /*return*/];
|
|
109
|
+
}
|
|
110
|
+
if (!req.body.username) {
|
|
111
|
+
res.status(401).send('no username');
|
|
112
|
+
return [2 /*return*/];
|
|
113
|
+
}
|
|
114
|
+
_a = req.body, username = _a.username, token = _a.token;
|
|
115
|
+
return [4 /*yield*/, cc.apiTokenValidation(username, token, 'api')];
|
|
116
|
+
case 1:
|
|
117
|
+
valid = _b.sent();
|
|
118
|
+
if (valid.valid && valid.userId) {
|
|
119
|
+
jwt = cc.jwtGenerateAccessToken({
|
|
120
|
+
userid: valid.userId,
|
|
121
|
+
username: username,
|
|
122
|
+
});
|
|
123
|
+
res.status(200).send({ token: jwt });
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
res.status(403).send('no no no ...');
|
|
127
|
+
}
|
|
128
|
+
return [2 /*return*/];
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
return GetTokenAction;
|
|
134
|
+
}(classes_1.BaseApiAction));
|
|
135
|
+
exports.default = GetTokenAction;
|
package/dist/actions/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ApiAuthTestAction from './ApiAuthTestAction';
|
|
2
|
-
import ApiVersionAction from './ApiVersionAction';
|
|
3
|
-
import GetTokenAction from './GetTokenAction';
|
|
4
|
-
export { ApiVersionAction, ApiAuthTestAction, GetTokenAction };
|
|
1
|
+
import ApiAuthTestAction from './ApiAuthTestAction';
|
|
2
|
+
import ApiVersionAction from './ApiVersionAction';
|
|
3
|
+
import GetTokenAction from './GetTokenAction';
|
|
4
|
+
export { ApiVersionAction, ApiAuthTestAction, GetTokenAction };
|
package/dist/actions/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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.GetTokenAction = exports.ApiAuthTestAction = exports.ApiVersionAction = void 0;
|
|
7
|
-
var ApiAuthTestAction_1 = __importDefault(require("./ApiAuthTestAction"));
|
|
8
|
-
exports.ApiAuthTestAction = ApiAuthTestAction_1.default;
|
|
9
|
-
var ApiVersionAction_1 = __importDefault(require("./ApiVersionAction"));
|
|
10
|
-
exports.ApiVersionAction = ApiVersionAction_1.default;
|
|
11
|
-
var GetTokenAction_1 = __importDefault(require("./GetTokenAction"));
|
|
12
|
-
exports.GetTokenAction = GetTokenAction_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.GetTokenAction = exports.ApiAuthTestAction = exports.ApiVersionAction = void 0;
|
|
7
|
+
var ApiAuthTestAction_1 = __importDefault(require("./ApiAuthTestAction"));
|
|
8
|
+
exports.ApiAuthTestAction = ApiAuthTestAction_1.default;
|
|
9
|
+
var ApiVersionAction_1 = __importDefault(require("./ApiVersionAction"));
|
|
10
|
+
exports.ApiVersionAction = ApiVersionAction_1.default;
|
|
11
|
+
var GetTokenAction_1 = __importDefault(require("./GetTokenAction"));
|
|
12
|
+
exports.GetTokenAction = GetTokenAction_1.default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import BaseEndpoint from '../classes/BaseEndpoint';
|
|
2
|
-
export default class KernelEndpoint extends BaseEndpoint {
|
|
3
|
-
}
|
|
1
|
+
import BaseEndpoint from '../classes/BaseEndpoint';
|
|
2
|
+
export default class KernelEndpoint extends BaseEndpoint {
|
|
3
|
+
}
|