@grandlinex/kernel 0.13.1 → 0.15.3
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 +50 -0
- package/README.md +3 -0
- package/dist/Kernel.js +1 -1
- package/dist/classes/BaseApiAction.js +2 -2
- package/dist/classes/BaseEndpoint.js +2 -2
- package/dist/database/DBFunctions.d.ts +10 -0
- package/dist/database/DBFunctions.js +118 -0
- package/dist/database/KernelDB.d.ts +4 -4
- package/dist/database/KernelDB.js +31 -117
- package/dist/database/KernelDBLight.d.ts +6 -5
- package/dist/database/KernelDBLight.js +35 -85
- package/dist/database/entity/GKey.d.ts +8 -0
- package/dist/database/entity/GKey.js +61 -0
- package/dist/database/index.d.ts +2 -2
- package/dist/database/index.js +3 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +20 -4
- package/dist/lib/index.d.ts +2 -7
- package/dist/modules/crypto/CryptoClient.js +3 -0
- package/package.json +22 -21
- package/dist/database/newInit.d.ts +0 -3
- package/dist/database/newInit.js +0 -11
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this project will be documented in this file.
|
|
3
|
+
|
|
4
|
+
## [0.15.3] - 2021-12-06
|
|
5
|
+
### Changed
|
|
6
|
+
- Update to core 0.15.1
|
|
7
|
+
|
|
8
|
+
## [0.15.2] - 2021-12-04
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- Update to fixed database bundles
|
|
12
|
+
- Export DB Classes in root file
|
|
13
|
+
|
|
14
|
+
## [0.15.1] - 2021-12-03
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- Linting error
|
|
18
|
+
- DB Duplication
|
|
19
|
+
|
|
20
|
+
## [0.15.0] - 2021-12-02
|
|
21
|
+
### Added
|
|
22
|
+
- Add Changelog
|
|
23
|
+
- Add ORM System
|
|
24
|
+
- Add reflection Typescript feature (for ORM)
|
|
25
|
+
````json
|
|
26
|
+
{
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"reflect-metadata": "^0.1.13"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
````
|
|
32
|
+
- `GKey` Store
|
|
33
|
+
- `GKey` - ORM Entity
|
|
34
|
+
### Changed
|
|
35
|
+
- Update to core version `0.15.0`
|
|
36
|
+
- Change tsconfig.json enable decorator feature
|
|
37
|
+
````json
|
|
38
|
+
{
|
|
39
|
+
"experimentalDecorators": true,
|
|
40
|
+
"emitDecoratorMetadata": true
|
|
41
|
+
}
|
|
42
|
+
````
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
### Removed
|
|
46
|
+
- legacy keystore
|
|
47
|
+
|
|
48
|
+
### Fixed
|
|
49
|
+
> bundle export nameSpace
|
|
50
|
+
|
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
GrandLineX is an out-of-the-box server framework on top of ExpressJs.
|
|
6
6
|
|
|
7
|
+
<img alt="img" height="24" src="https://img.shields.io/static/v1?label=&message=KERNEL&color=black&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAAAAACPAi4CAAABJWlDQ1BJQ0MgcHJvZmlsZQAAKJGdkL9KxEAQxr/EQ0XORsVCLLawPbAxlY1/MFgcnLkIRqvcbg4PszFk9zh8A9/Ee5grBME38AUUrP02Wli4jQvD/Bhmvm9mgVCUUpvOPqAr28TJUXaVXYuVN3TRwQYOEObS1P3hWQrv+3xF4PJLz2n5+/58y6owknnBqGTdWCA4JEczWztmYOsuTU7Ij2ShdKXIc/Ke0sqxm010OZU/mm6bblFdDl2dsYsY5+hjAIERppighEWPuWLlFBHvFOxpkOMBBpK5RMHajD0WtyRDpRjHpJTEbTx+O63fgC4jakyo5Rzuoanp/OD+93vs46KdDLYXdd7kbWmJEY7HwPsTsJ4Bm8/A2o3Ha/X3bZ6eqO35541f9HxQa/wig0AAAAAJcEhZcwAAC7gAAAu4AT6yGBcAAAAHdElNRQflDAQSNSxPhIOMAAAEMElEQVRYw+2Wa0wUVxTH/3dmH+wgr4WdBWst4gIVwUAoxqJUwYatthCMtpVoE0usqY1pg/ShMTFpm6YiiWlMStLWEm0biqQE05qoLUIEIqlaHoW2yoLQxQWB3YVleezszuztB8XFFdoh/dKkO5/mnjnzmznnnnP+l/D4dxeDACAACAD+GwDF3z2LDNUvVYh3hxx2cfEAEp2bHa/jCECnh00/1Y0u5LfAQNG+smOFgsyuqKe78uzkvI5s8LzYp8pe4lniW7P8+sR2h2wAMR5PYf1jNaRdG5MLyD72xL2vU68oUhACACTG0DAjLwfLK5IJAHhMbR09U8Gr0zNiGAAQyz/2ygEoSwsZANRyqmaUAgBrOLhVBQCWnd1yQsh4hwMAU/G5qft7YGt8bBUBsMR1RUYlsrsjAMD6QQt9YJsouw0ATGaYjELiU90AvLWX5xoHKjcQAHbFfDlQ6DnvmN33BwlKALTf+cASF9tjWSrYALCrJvqpPyC25OkI0Vx1ZuFyP1b42fcVN/dPAcaTlsJhvxD4T9YOd3KJh8UzCwJYBaOOsbIA7IMWwT8HuzJ+L+7RvLXj2Zoc/aUX7tbG5+vM5yxxxq7HUwaqrdAVrOzzFeXN72yu7Uta84MuN3qZdCPXfsGJK+IRPjp1be4zsU1TPwuVL/YJ0+7W9AOuP5yC+/yK1Ga32zUontwi3DDwPJ810Z52Y7zX5Rl9Vf/eiDAzU2tgtFIbEqqrv/hUz3LLzrfkh361qy0ln7C60kOOrOV715kOnfB1JWFYwoT2F13UFsS8pvyo6NaWPIVAojDZFZQZqoJ0qpx2kKQ1OqKzouu0cmeaPoVWfMPEb3soas/nDernomKXTW9DGJvGmJg8zZ39P6gB0B6qOviy0uwiBHCLkgeMl6hB/Daf2jEDQuD4taO5+qri25zng9p1W1UuABTBsaR+INPne33D3pCIjQQAt13CnSEfxmyOtpv3hFQqrh0/YDTS26YoKoleOJrji8VurUQlCfBK9HRKdomnj/NSyfA+0PyhJFFJovCKkrX87Tfgru4kPFmeHTNUZwi/lKGvt0GzOXmkNdk0mdbbQrL0dWNhOQk9vyV3WYwaAgx3Z9ia1kdemNJuHm5CQk7I9avCo+0c92UIAPfRuoesmWVqAGgsof/YTLaZJAD09V/mDjBu30oCADoZ7ey4KAIg60q4OV57NpGF6vzRgfLnJh4Au1rfNduQwUVvht67662VAZj0ZKkAKJI3Ro0zrCqEz3238P778wDmU6aaNbuVANikxH0jTqqJ1CoJILHypU0oDc9TAAAbHj5rk+qyVfLVeezw1346JjWcmF6MvI8dPdLpmVP9zrPFVuei1NldVV9gTIhgCKGQxjuqfhS0ZjWAcdnqDIDTJz0ZqRLttzoHXQDhNQAm7IsABE5pAUAA8D8D/AUp6ovNs1/7jgAAAABJRU5ErkJggg==" />
|
|
8
|
+
|
|
7
9
|
|
|
8
10
|
[](https://github.com/GrandlineX/kernel)
|
|
9
11
|
[](https://www.npmjs.com/package/@grandlinex/kernel)
|
|
@@ -25,3 +27,4 @@ GrandLineX is an out-of-the-box server framework on top of ExpressJs.
|
|
|
25
27
|
## Documentation
|
|
26
28
|
- [Documentation](https://grandlinex.github.io/kernel/)
|
|
27
29
|
- [GrandLineX Docs](https://grandlinex.github.io/docs/)
|
|
30
|
+
- [GrandLineX Project](https://grandlinex.github.io/)
|
package/dist/Kernel.js
CHANGED
|
@@ -37,7 +37,7 @@ var Kernel = /** @class */ (function (_super) {
|
|
|
37
37
|
_this.setLogger(_this.globalLogger);
|
|
38
38
|
_this.setBaseModule(new KernelModule_1.default(_this));
|
|
39
39
|
if (options.portOverride) {
|
|
40
|
-
_this.debug("use custiom api port @ "
|
|
40
|
+
_this.debug("use custiom api port @ ".concat(options.portOverride));
|
|
41
41
|
_this.expressPort = options.portOverride;
|
|
42
42
|
}
|
|
43
43
|
else {
|
|
@@ -36,7 +36,7 @@ var BaseApiAction = /** @class */ (function (_super) {
|
|
|
36
36
|
endpoint = this.getModule().getEndpoint();
|
|
37
37
|
}
|
|
38
38
|
if (endpoint) {
|
|
39
|
-
this.log("register "
|
|
39
|
+
this.log("register ".concat(this.chanel));
|
|
40
40
|
var app = endpoint.getApp();
|
|
41
41
|
switch (this.type) {
|
|
42
42
|
case 'POST':
|
|
@@ -52,7 +52,7 @@ var BaseApiAction = /** @class */ (function (_super) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
55
|
-
this.error("on register -> "
|
|
55
|
+
this.error("on register -> ".concat(this.chanel));
|
|
56
56
|
this.error("No Endpoint found");
|
|
57
57
|
}
|
|
58
58
|
};
|
|
@@ -24,7 +24,7 @@ var core_1 = require("@grandlinex/core");
|
|
|
24
24
|
var BaseEndpoint = /** @class */ (function (_super) {
|
|
25
25
|
__extends(BaseEndpoint, _super);
|
|
26
26
|
function BaseEndpoint(chanel, module, port) {
|
|
27
|
-
var _this = _super.call(this, "endpoint-"
|
|
27
|
+
var _this = _super.call(this, "endpoint-".concat(chanel), module) || this;
|
|
28
28
|
_this.port = port;
|
|
29
29
|
_this.appServer = (0, express_1.default)();
|
|
30
30
|
_this.appServer.use((0, body_parser_1.json)());
|
|
@@ -36,7 +36,7 @@ var BaseEndpoint = /** @class */ (function (_super) {
|
|
|
36
36
|
return new Promise(function (resolve) {
|
|
37
37
|
_this.httpServer = _this.appServer
|
|
38
38
|
.listen(_this.port, function () {
|
|
39
|
-
_this.debug("Endpoint listen on "
|
|
39
|
+
_this.debug("Endpoint listen on ".concat(_this.port));
|
|
40
40
|
resolve(true);
|
|
41
41
|
})
|
|
42
42
|
.on('error', function (err) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { CoreDBCon } from '@grandlinex/core';
|
|
3
|
+
import GKey from './entity/GKey';
|
|
4
|
+
declare type DBC = CoreDBCon<any, any>;
|
|
5
|
+
export declare function initNewDB(db: DBC): Promise<void>;
|
|
6
|
+
export declare function setKey(db: DBC, secret: string, iv: Buffer, auth: Buffer): Promise<number>;
|
|
7
|
+
export declare function getKey(db: DBC, id: number): Promise<GKey | null>;
|
|
8
|
+
export declare function deleteKey(db: DBC, id: number): Promise<void>;
|
|
9
|
+
export declare const KERNEL_DB_VERSION = "1";
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.KERNEL_DB_VERSION = exports.deleteKey = exports.getKey = exports.setKey = exports.initNewDB = void 0;
|
|
43
|
+
var core_1 = require("@grandlinex/core");
|
|
44
|
+
var crypto_1 = require("crypto");
|
|
45
|
+
var GKey_1 = __importDefault(require("./entity/GKey"));
|
|
46
|
+
function initNewDB(db) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
+
var seed;
|
|
49
|
+
return __generator(this, function (_a) {
|
|
50
|
+
switch (_a.label) {
|
|
51
|
+
case 0:
|
|
52
|
+
seed = (0, core_1.generateSeed)();
|
|
53
|
+
return [4 /*yield*/, db.setConfig('seed', seed)];
|
|
54
|
+
case 1:
|
|
55
|
+
_a.sent();
|
|
56
|
+
return [4 /*yield*/, db.setConfig('uid', (0, crypto_1.randomUUID)())];
|
|
57
|
+
case 2:
|
|
58
|
+
_a.sent();
|
|
59
|
+
return [2 /*return*/];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
exports.initNewDB = initNewDB;
|
|
65
|
+
function setKey(db, secret, iv, auth) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
+
var keyStore, res;
|
|
68
|
+
return __generator(this, function (_a) {
|
|
69
|
+
switch (_a.label) {
|
|
70
|
+
case 0:
|
|
71
|
+
keyStore = db.getEntityWrapper('GKey');
|
|
72
|
+
if (!keyStore) return [3 /*break*/, 2];
|
|
73
|
+
return [4 /*yield*/, keyStore.createObject(new GKey_1.default({
|
|
74
|
+
secret: secret,
|
|
75
|
+
iv: iv,
|
|
76
|
+
auth: auth,
|
|
77
|
+
}))];
|
|
78
|
+
case 1:
|
|
79
|
+
res = _a.sent();
|
|
80
|
+
return [2 /*return*/, (res === null || res === void 0 ? void 0 : res.e_id) || -1];
|
|
81
|
+
case 2: throw new Error('No keystore');
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
exports.setKey = setKey;
|
|
87
|
+
function getKey(db, id) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
89
|
+
var keyStore;
|
|
90
|
+
return __generator(this, function (_a) {
|
|
91
|
+
keyStore = db.getEntityWrapper('GKey');
|
|
92
|
+
if (keyStore) {
|
|
93
|
+
return [2 /*return*/, keyStore.getObjById(id)];
|
|
94
|
+
}
|
|
95
|
+
throw new Error('No keystore');
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
exports.getKey = getKey;
|
|
100
|
+
function deleteKey(db, id) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
+
var keyStore;
|
|
103
|
+
return __generator(this, function (_a) {
|
|
104
|
+
switch (_a.label) {
|
|
105
|
+
case 0:
|
|
106
|
+
keyStore = db.getEntityWrapper('GKey');
|
|
107
|
+
if (!keyStore) return [3 /*break*/, 2];
|
|
108
|
+
return [4 /*yield*/, keyStore.delete(id)];
|
|
109
|
+
case 1:
|
|
110
|
+
_a.sent();
|
|
111
|
+
_a.label = 2;
|
|
112
|
+
case 2: throw new Error('No keystore');
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
exports.deleteKey = deleteKey;
|
|
118
|
+
exports.KERNEL_DB_VERSION = '1';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { PGCon } from '@grandlinex/bundle-postgresql';
|
|
3
|
-
import { IBaseKernelModule, IKernelDb
|
|
4
|
-
|
|
3
|
+
import { IBaseKernelModule, IKernelDb } from '../lib';
|
|
4
|
+
import GKey from './entity/GKey';
|
|
5
5
|
export default class KernelDB extends PGCon implements IKernelDb {
|
|
6
6
|
constructor(module: IBaseKernelModule<any, any, any, any>);
|
|
7
|
+
deleteKey(id: number): Promise<void>;
|
|
8
|
+
getKey(id: number): Promise<GKey | null>;
|
|
7
9
|
initNewDB(): Promise<void>;
|
|
8
10
|
setKey(secret: string, iv: Buffer, auth: Buffer): Promise<number>;
|
|
9
|
-
getKey(id: number): Promise<KeyType>;
|
|
10
|
-
deleteKey(id: number): Promise<void>;
|
|
11
11
|
}
|
|
@@ -14,136 +14,50 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
}
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
52
35
|
};
|
|
53
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
38
|
};
|
|
56
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
-
exports.KERNEL_DB_VERSION = void 0;
|
|
58
|
-
var crypto_1 = require("crypto");
|
|
59
|
-
var core_1 = require("@grandlinex/core");
|
|
60
40
|
var bundle_postgresql_1 = require("@grandlinex/bundle-postgresql");
|
|
61
|
-
var
|
|
62
|
-
|
|
41
|
+
var GKey_1 = __importDefault(require("./entity/GKey"));
|
|
42
|
+
var DBF = __importStar(require("./DBFunctions"));
|
|
63
43
|
var KernelDB = /** @class */ (function (_super) {
|
|
64
44
|
__extends(KernelDB, _super);
|
|
65
45
|
function KernelDB(module) {
|
|
66
|
-
|
|
46
|
+
var _this = _super.call(this, module, DBF.KERNEL_DB_VERSION) || this;
|
|
47
|
+
_this.registerEntity(new GKey_1.default());
|
|
48
|
+
return _this;
|
|
67
49
|
}
|
|
68
|
-
KernelDB.prototype.
|
|
69
|
-
return
|
|
70
|
-
var seed;
|
|
71
|
-
return __generator(this, function (_a) {
|
|
72
|
-
switch (_a.label) {
|
|
73
|
-
case 0: return [4 /*yield*/, this.execScripts((0, newInit_1.default)(this.schemaName))];
|
|
74
|
-
case 1:
|
|
75
|
-
_a.sent();
|
|
76
|
-
seed = (0, core_1.generateSeed)();
|
|
77
|
-
return [4 /*yield*/, this.setConfig('seed', seed)];
|
|
78
|
-
case 2:
|
|
79
|
-
_a.sent();
|
|
80
|
-
return [4 /*yield*/, this.setConfig('uid', (0, crypto_1.randomUUID)())];
|
|
81
|
-
case 3:
|
|
82
|
-
_a.sent();
|
|
83
|
-
return [2 /*return*/];
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
KernelDB.prototype.setKey = function (secret, iv, auth) {
|
|
89
|
-
var _a;
|
|
90
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
91
|
-
var query, row, e_1;
|
|
92
|
-
return __generator(this, function (_b) {
|
|
93
|
-
switch (_b.label) {
|
|
94
|
-
case 0:
|
|
95
|
-
_b.trys.push([0, 2, , 3]);
|
|
96
|
-
return [4 /*yield*/, ((_a = this.db) === null || _a === void 0 ? void 0 : _a.query("INSERT INTO " + this.schemaName + ".keys (secret, iv, auth) VALUES ($1,$2,$3) RETURNING id;", [secret, iv, auth]))];
|
|
97
|
-
case 1:
|
|
98
|
-
query = _b.sent();
|
|
99
|
-
if (!query) {
|
|
100
|
-
return [2 /*return*/, -1];
|
|
101
|
-
}
|
|
102
|
-
row = query.rows[0];
|
|
103
|
-
return [2 /*return*/, row.id];
|
|
104
|
-
case 2:
|
|
105
|
-
e_1 = _b.sent();
|
|
106
|
-
this.error(e_1);
|
|
107
|
-
throw e_1;
|
|
108
|
-
case 3: return [2 /*return*/];
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
});
|
|
50
|
+
KernelDB.prototype.deleteKey = function (id) {
|
|
51
|
+
return DBF.deleteKey(this, id);
|
|
112
52
|
};
|
|
113
53
|
KernelDB.prototype.getKey = function (id) {
|
|
114
|
-
|
|
115
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
116
|
-
var query, res, auth, buffer;
|
|
117
|
-
return __generator(this, function (_b) {
|
|
118
|
-
switch (_b.label) {
|
|
119
|
-
case 0: return [4 /*yield*/, ((_a = this.db) === null || _a === void 0 ? void 0 : _a.query("SELECT *\n FROM " + this.schemaName + ".keys\n WHERE id = " + id))];
|
|
120
|
-
case 1:
|
|
121
|
-
query = _b.sent();
|
|
122
|
-
res = query === null || query === void 0 ? void 0 : query.rows[0];
|
|
123
|
-
auth = res.auth;
|
|
124
|
-
buffer = Buffer.from(auth);
|
|
125
|
-
return [2 /*return*/, {
|
|
126
|
-
id: res.id,
|
|
127
|
-
secret: res.secret,
|
|
128
|
-
iv: res.iv,
|
|
129
|
-
auth: buffer,
|
|
130
|
-
}];
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
});
|
|
54
|
+
return DBF.getKey(this, id);
|
|
134
55
|
};
|
|
135
|
-
KernelDB.prototype.
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
case 0: return [4 /*yield*/, ((_a = this.db) === null || _a === void 0 ? void 0 : _a.query("DELETE\n FROM " + this.schemaName + ".keys\n WHERE id = " + id))];
|
|
141
|
-
case 1:
|
|
142
|
-
_b.sent();
|
|
143
|
-
return [2 /*return*/];
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
});
|
|
56
|
+
KernelDB.prototype.initNewDB = function () {
|
|
57
|
+
return DBF.initNewDB(this);
|
|
58
|
+
};
|
|
59
|
+
KernelDB.prototype.setKey = function (secret, iv, auth) {
|
|
60
|
+
return DBF.setKey(this, secret, iv, auth);
|
|
147
61
|
};
|
|
148
62
|
return KernelDB;
|
|
149
63
|
}(bundle_postgresql_1.PGCon));
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import
|
|
3
|
-
import { IBaseKernelModule, IKernelDb
|
|
2
|
+
import SQLCon from '@grandlinex/bundle-sqlight';
|
|
3
|
+
import { IBaseKernelModule, IKernelDb } from '../lib';
|
|
4
|
+
import GKey from './entity/GKey';
|
|
4
5
|
export default class KernelDBLight extends SQLCon implements IKernelDb {
|
|
5
6
|
constructor(module: IBaseKernelModule<any, any, any, any>);
|
|
6
|
-
initNewDB(): Promise<any>;
|
|
7
|
-
setKey(secret: string, iv: Buffer, auth: Buffer): Promise<number>;
|
|
8
|
-
getKey(id: number): Promise<KeyType>;
|
|
9
7
|
deleteKey(id: number): Promise<void>;
|
|
8
|
+
getKey(id: number): Promise<GKey | null>;
|
|
9
|
+
initNewDB(): Promise<void>;
|
|
10
|
+
setKey(secret: string, iv: Buffer, auth: Buffer): Promise<number>;
|
|
10
11
|
}
|
|
@@ -14,101 +14,51 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
25
35
|
};
|
|
26
|
-
var
|
|
27
|
-
|
|
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
|
-
}
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
52
38
|
};
|
|
53
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
var bundle_sqlight_1 = require("@grandlinex/bundle-sqlight");
|
|
40
|
+
var bundle_sqlight_1 = __importDefault(require("@grandlinex/bundle-sqlight"));
|
|
41
|
+
var GKey_1 = __importDefault(require("./entity/GKey"));
|
|
42
|
+
var DBF = __importStar(require("./DBFunctions"));
|
|
55
43
|
var KernelDBLight = /** @class */ (function (_super) {
|
|
56
44
|
__extends(KernelDBLight, _super);
|
|
57
45
|
function KernelDBLight(module) {
|
|
58
|
-
|
|
46
|
+
var _this = _super.call(this, module, DBF.KERNEL_DB_VERSION) || this;
|
|
47
|
+
_this.registerEntity(new GKey_1.default());
|
|
48
|
+
return _this;
|
|
59
49
|
}
|
|
60
|
-
KernelDBLight.prototype.
|
|
61
|
-
return
|
|
62
|
-
return __generator(this, function (_a) {
|
|
63
|
-
switch (_a.label) {
|
|
64
|
-
case 0: return [4 /*yield*/, this.execScripts([
|
|
65
|
-
{
|
|
66
|
-
exec: 'CREATE TABLE main.keys(id INTEGER PRIMARY KEY ,secret TEXT, iv BLOB, auth BLOB);',
|
|
67
|
-
param: [],
|
|
68
|
-
},
|
|
69
|
-
])];
|
|
70
|
-
case 1:
|
|
71
|
-
_a.sent();
|
|
72
|
-
return [2 /*return*/];
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
KernelDBLight.prototype.setKey = function (secret, iv, auth) {
|
|
78
|
-
var _a;
|
|
79
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
-
var query, row;
|
|
81
|
-
return __generator(this, function (_b) {
|
|
82
|
-
query = (_a = this.db) === null || _a === void 0 ? void 0 : _a.prepare("INSERT INTO main.keys (secret,iv ,auth) VALUES (?,?,?);");
|
|
83
|
-
if (query === undefined) {
|
|
84
|
-
return [2 /*return*/, -1];
|
|
85
|
-
}
|
|
86
|
-
row = "" + query.run([secret, iv, auth]).lastInsertRowid;
|
|
87
|
-
return [2 /*return*/, Number.parseInt(row, 10)];
|
|
88
|
-
});
|
|
89
|
-
});
|
|
50
|
+
KernelDBLight.prototype.deleteKey = function (id) {
|
|
51
|
+
return DBF.deleteKey(this, id);
|
|
90
52
|
};
|
|
91
53
|
KernelDBLight.prototype.getKey = function (id) {
|
|
92
|
-
|
|
93
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
94
|
-
var query;
|
|
95
|
-
return __generator(this, function (_b) {
|
|
96
|
-
query = (_a = this.db) === null || _a === void 0 ? void 0 : _a.prepare("SELECT * FROM main.keys WHERE id=" + id);
|
|
97
|
-
return [2 /*return*/, query === null || query === void 0 ? void 0 : query.get()];
|
|
98
|
-
});
|
|
99
|
-
});
|
|
54
|
+
return DBF.getKey(this, id);
|
|
100
55
|
};
|
|
101
|
-
KernelDBLight.prototype.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
query = (_a = this.db) === null || _a === void 0 ? void 0 : _a.prepare("DELETE FROM main.keys WHERE id=" + id);
|
|
107
|
-
query === null || query === void 0 ? void 0 : query.run();
|
|
108
|
-
return [2 /*return*/];
|
|
109
|
-
});
|
|
110
|
-
});
|
|
56
|
+
KernelDBLight.prototype.initNewDB = function () {
|
|
57
|
+
return DBF.initNewDB(this);
|
|
58
|
+
};
|
|
59
|
+
KernelDBLight.prototype.setKey = function (secret, iv, auth) {
|
|
60
|
+
return DBF.setKey(this, secret, iv, auth);
|
|
111
61
|
};
|
|
112
62
|
return KernelDBLight;
|
|
113
|
-
}(bundle_sqlight_1.
|
|
63
|
+
}(bundle_sqlight_1.default));
|
|
114
64
|
exports.default = KernelDBLight;
|
|
@@ -0,0 +1,61 @@
|
|
|
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 __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
var core_1 = require("@grandlinex/core");
|
|
28
|
+
var GKey = /** @class */ (function (_super) {
|
|
29
|
+
__extends(GKey, _super);
|
|
30
|
+
function GKey(props) {
|
|
31
|
+
var _this = _super.call(this) || this;
|
|
32
|
+
_this.secret = (props === null || props === void 0 ? void 0 : props.secret) || '';
|
|
33
|
+
_this.iv = (props === null || props === void 0 ? void 0 : props.iv) || Buffer.from('');
|
|
34
|
+
_this.auth = (props === null || props === void 0 ? void 0 : props.auth) || Buffer.from('');
|
|
35
|
+
return _this;
|
|
36
|
+
}
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, core_1.Column)({
|
|
39
|
+
dataType: 'text',
|
|
40
|
+
}),
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], GKey.prototype, "secret", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, core_1.Column)({
|
|
45
|
+
dataType: 'blob',
|
|
46
|
+
}),
|
|
47
|
+
__metadata("design:type", Buffer)
|
|
48
|
+
], GKey.prototype, "iv", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, core_1.Column)({
|
|
51
|
+
dataType: 'blob',
|
|
52
|
+
}),
|
|
53
|
+
__metadata("design:type", Buffer)
|
|
54
|
+
], GKey.prototype, "auth", void 0);
|
|
55
|
+
GKey = __decorate([
|
|
56
|
+
(0, core_1.Entity)('GKey', 0),
|
|
57
|
+
__metadata("design:paramtypes", [Object])
|
|
58
|
+
], GKey);
|
|
59
|
+
return GKey;
|
|
60
|
+
}(core_1.CoreEntity));
|
|
61
|
+
exports.default = GKey;
|
package/dist/database/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import KernelDB from './KernelDB';
|
|
2
|
-
import
|
|
3
|
-
export { KernelDB,
|
|
2
|
+
import KernelDBLight from './KernelDBLight';
|
|
3
|
+
export { KernelDB, KernelDBLight };
|
package/dist/database/index.js
CHANGED
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.KernelDBLight = exports.KernelDB = void 0;
|
|
7
7
|
var KernelDB_1 = __importDefault(require("./KernelDB"));
|
|
8
8
|
exports.KernelDB = KernelDB_1.default;
|
|
9
|
-
var
|
|
10
|
-
exports.
|
|
9
|
+
var KernelDBLight_1 = __importDefault(require("./KernelDBLight"));
|
|
10
|
+
exports.KernelDBLight = KernelDBLight_1.default;
|
package/dist/index.d.ts
CHANGED
|
@@ -11,8 +11,10 @@ export * from './modules/crypto';
|
|
|
11
11
|
export * from './database';
|
|
12
12
|
export * from './lib';
|
|
13
13
|
export * from '@grandlinex/core';
|
|
14
|
-
export * from '@grandlinex/bundle-postgresql';
|
|
15
|
-
export * from '@grandlinex/bundle-sqlight';
|
|
16
|
-
export * from '@grandlinex/bundle-elogger';
|
|
14
|
+
export * as bundlePostgreSQL from '@grandlinex/bundle-postgresql';
|
|
15
|
+
export * as bundleSQLight from '@grandlinex/bundle-sqlight';
|
|
16
|
+
export * as bundleELogger from '@grandlinex/bundle-elogger';
|
|
17
|
+
export { SQLCon } from '@grandlinex/bundle-sqlight';
|
|
18
|
+
export { PGCon } from '@grandlinex/bundle-postgresql';
|
|
17
19
|
export { KernelModule, Kernel };
|
|
18
20
|
export default Kernel;
|
package/dist/index.js
CHANGED
|
@@ -6,14 +6,26 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
6
6
|
if (k2 === undefined) k2 = k;
|
|
7
7
|
o[k2] = m[k];
|
|
8
8
|
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
9
14
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
15
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
16
|
};
|
|
17
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
18
|
+
if (mod && mod.__esModule) return mod;
|
|
19
|
+
var result = {};
|
|
20
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
__setModuleDefault(result, mod);
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
12
24
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
26
|
};
|
|
15
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.Kernel = exports.KernelModule = void 0;
|
|
28
|
+
exports.Kernel = exports.KernelModule = exports.PGCon = exports.SQLCon = exports.bundleELogger = exports.bundleSQLight = exports.bundlePostgreSQL = void 0;
|
|
17
29
|
/**
|
|
18
30
|
* @name Kernel Main Module
|
|
19
31
|
* @author David Nagy
|
|
@@ -29,7 +41,11 @@ __exportStar(require("./modules/crypto"), exports);
|
|
|
29
41
|
__exportStar(require("./database"), exports);
|
|
30
42
|
__exportStar(require("./lib"), exports);
|
|
31
43
|
__exportStar(require("@grandlinex/core"), exports);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
44
|
+
exports.bundlePostgreSQL = __importStar(require("@grandlinex/bundle-postgresql"));
|
|
45
|
+
exports.bundleSQLight = __importStar(require("@grandlinex/bundle-sqlight"));
|
|
46
|
+
exports.bundleELogger = __importStar(require("@grandlinex/bundle-elogger"));
|
|
47
|
+
var bundle_sqlight_1 = require("@grandlinex/bundle-sqlight");
|
|
48
|
+
Object.defineProperty(exports, "SQLCon", { enumerable: true, get: function () { return bundle_sqlight_1.SQLCon; } });
|
|
49
|
+
var bundle_postgresql_1 = require("@grandlinex/bundle-postgresql");
|
|
50
|
+
Object.defineProperty(exports, "PGCon", { enumerable: true, get: function () { return bundle_postgresql_1.PGCon; } });
|
|
35
51
|
exports.default = Kernel_1.default;
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import express, { Request, Response } from 'express';
|
|
|
3
3
|
import { ICoreAction, ICoreBridge, ICoreCache, ICoreCClient, ICoreElement, ICoreKernel, ICoreKernelModule, ICorePresenter, ICoreService, IDataBase } from '@grandlinex/core';
|
|
4
4
|
import { BaseClient } from 'classes';
|
|
5
5
|
import { IAuthProvider, JwtToken } from '../classes/BaseAuthProvider';
|
|
6
|
+
import GKey from '../database/entity/GKey';
|
|
6
7
|
export declare type ActionTypes = 'POST' | 'GET' | 'USE';
|
|
7
8
|
export interface ICClient extends ICoreCClient {
|
|
8
9
|
setAuthProvider(provider: IAuthProvider): boolean;
|
|
@@ -23,7 +24,7 @@ export interface IKernel extends ICoreKernel<ICClient> {
|
|
|
23
24
|
export interface IKernelDb {
|
|
24
25
|
initNewDB(): Promise<void>;
|
|
25
26
|
setKey(secret: string, iv: Buffer, auth: Buffer): Promise<number>;
|
|
26
|
-
getKey(id: number): Promise<
|
|
27
|
+
getKey(id: number): Promise<GKey | null>;
|
|
27
28
|
deleteKey(id: number): Promise<void>;
|
|
28
29
|
}
|
|
29
30
|
export declare type IBaseKernelModule<T extends IDataBase<any, any> | null, P extends BaseClient | null, C extends IBaseCache | null, E extends IBasePresenter | null> = ICoreKernelModule<IKernel, T, P, C, E>;
|
|
@@ -31,12 +32,6 @@ export declare type IBasePresenter = ICorePresenter<express.Express>;
|
|
|
31
32
|
export interface IBaseAction extends ICoreAction {
|
|
32
33
|
handler(req: Request, res: Response, next: () => void, data: JwtToken | null): Promise<void>;
|
|
33
34
|
}
|
|
34
|
-
export interface KeyType {
|
|
35
|
-
id: number;
|
|
36
|
-
iv: Buffer;
|
|
37
|
-
secret: string;
|
|
38
|
-
auth: Buffer;
|
|
39
|
-
}
|
|
40
35
|
export declare type IBaseService = ICoreService;
|
|
41
36
|
export declare type IBaseBrige = ICoreBridge;
|
|
42
37
|
export declare type IBaseCache = ICoreCache;
|
|
@@ -157,6 +157,9 @@ var CryptoClient = /** @class */ (function (_super) {
|
|
|
157
157
|
return [4 /*yield*/, db.getKey(id)];
|
|
158
158
|
case 1:
|
|
159
159
|
key = _a.sent();
|
|
160
|
+
if (!key) {
|
|
161
|
+
return [2 /*return*/, null];
|
|
162
|
+
}
|
|
160
163
|
return [2 /*return*/, this.decrypt(key.secret, key.iv, key.auth)];
|
|
161
164
|
}
|
|
162
165
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grandlinex/kernel",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "0.15.3",
|
|
4
|
+
"description": "GrandLineX is an out-of-the-box server framework on top of ExpressJs.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"typescript",
|
|
19
19
|
"framework",
|
|
20
20
|
"express",
|
|
21
|
+
"orm",
|
|
21
22
|
"server",
|
|
22
23
|
"backend"
|
|
23
24
|
],
|
|
@@ -26,10 +27,10 @@
|
|
|
26
27
|
},
|
|
27
28
|
"license": "BSD-3-Clause",
|
|
28
29
|
"dependencies": {
|
|
29
|
-
"@grandlinex/bundle-elogger": "^0.
|
|
30
|
-
"@grandlinex/bundle-postgresql": "^0.
|
|
31
|
-
"@grandlinex/bundle-sqlight": "^0.
|
|
32
|
-
"@grandlinex/core": "^0.
|
|
30
|
+
"@grandlinex/bundle-elogger": "^0.15.1",
|
|
31
|
+
"@grandlinex/bundle-postgresql": "^0.15.2",
|
|
32
|
+
"@grandlinex/bundle-sqlight": "^0.15.2",
|
|
33
|
+
"@grandlinex/core": "^0.15.1",
|
|
33
34
|
"axios": "^0.24.0",
|
|
34
35
|
"body-parser": "^1.19.0",
|
|
35
36
|
"express": "^4.17.1",
|
|
@@ -38,31 +39,31 @@
|
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@grandlinex/docs-to-openapi": "^0.6.0",
|
|
40
41
|
"@types/express": "^4.17.13",
|
|
41
|
-
"@types/jest": "^27.0.
|
|
42
|
-
"@types/jsonwebtoken": "^8.5.
|
|
43
|
-
"@types/node": "^16.11.
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
45
|
-
"@typescript-eslint/parser": "^
|
|
42
|
+
"@types/jest": "^27.0.3",
|
|
43
|
+
"@types/jsonwebtoken": "^8.5.6",
|
|
44
|
+
"@types/node": "^16.11.11",
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^5.5.0",
|
|
46
|
+
"@typescript-eslint/parser": "^5.5.0",
|
|
46
47
|
"cross-env": "^7.0.3",
|
|
47
|
-
"eslint": "^
|
|
48
|
-
"eslint-config-airbnb": "^19.0.
|
|
49
|
-
"eslint-config-airbnb-typescript": "^
|
|
48
|
+
"eslint": "^8.3.0",
|
|
49
|
+
"eslint-config-airbnb": "^19.0.2",
|
|
50
|
+
"eslint-config-airbnb-typescript": "^16.1.0",
|
|
50
51
|
"eslint-config-prettier": "^8.3.0",
|
|
51
52
|
"eslint-plugin-import": "^2.25.3",
|
|
52
|
-
"eslint-plugin-jest": "^25.
|
|
53
|
+
"eslint-plugin-jest": "^25.3.0",
|
|
53
54
|
"eslint-plugin-jsx-a11y": "^6.5.1",
|
|
54
55
|
"eslint-plugin-prettier": "^4.0.0",
|
|
55
|
-
"eslint-plugin-react": "^7.27.
|
|
56
|
+
"eslint-plugin-react": "^7.27.1",
|
|
56
57
|
"eslint-plugin-react-hooks": "^4.3.0",
|
|
57
58
|
"html-webpack-plugin": "^5.5.0",
|
|
58
|
-
"jest": "^27.3
|
|
59
|
+
"jest": "^27.4.3",
|
|
59
60
|
"jest-junit": "^13.0.0",
|
|
60
|
-
"prettier": "^2.
|
|
61
|
-
"ts-jest": "^27.0
|
|
61
|
+
"prettier": "^2.5.1",
|
|
62
|
+
"ts-jest": "^27.1.0",
|
|
62
63
|
"ts-loader": "^9.2.6",
|
|
63
64
|
"ts-node": "^10.4.0",
|
|
64
|
-
"typedoc": "^0.22.
|
|
65
|
-
"typescript": "^4.
|
|
65
|
+
"typedoc": "^0.22.10",
|
|
66
|
+
"typescript": "^4.5.2"
|
|
66
67
|
},
|
|
67
68
|
"repository": {
|
|
68
69
|
"type": "git",
|
package/dist/database/newInit.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function newInit(schema) {
|
|
4
|
-
return [
|
|
5
|
-
{
|
|
6
|
-
exec: "CREATE TABLE " + schema + ".keys\n (\n id SERIAL PRIMARY KEY,\n secret TEXT,\n iv BYTEA,\n auth BYTEA\n );",
|
|
7
|
-
param: [],
|
|
8
|
-
},
|
|
9
|
-
];
|
|
10
|
-
}
|
|
11
|
-
exports.default = newInit;
|