@grandlinex/kernel 0.16.0 → 0.17.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 +17 -0
- package/dist/KernelModule.d.ts +1 -2
- package/dist/KernelModule.js +51 -16
- package/dist/database/KernelDB.d.ts +8 -5
- package/dist/database/KernelDB.js +81 -30
- package/dist/index.d.ts +3 -2
- package/dist/index.js +5 -2
- package/package.json +14 -14
- package/dist/database/DBFunctions.d.ts +0 -10
- package/dist/database/DBFunctions.js +0 -118
- package/dist/database/KernelDBLight.d.ts +0 -11
- package/dist/database/KernelDBLight.js +0 -64
- package/dist/database/index.d.ts +0 -3
- package/dist/database/index.js +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
|
|
4
|
+
|
|
5
|
+
## [v0.17.0] - 2022-01-03
|
|
6
|
+
### Changed
|
|
7
|
+
- Update to core 0.17.1
|
|
8
|
+
- Using db prefab for kernel db
|
|
9
|
+
|
|
10
|
+
## [v0.16.2] - 2021-12-17
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- Update Db Bundles with search bug
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## [v0.16.1] - 2021-12-07
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
- Update to core 0.16.2
|
|
20
|
+
|
|
4
21
|
## [0.15.3] - 2021-12-06
|
|
5
22
|
### Changed
|
|
6
23
|
- Update to core 0.15.1
|
package/dist/KernelModule.d.ts
CHANGED
|
@@ -3,8 +3,7 @@ import BaseKernelModule from './classes/BaseKernelModule';
|
|
|
3
3
|
import KernelDB from './database/KernelDB';
|
|
4
4
|
import { IKernel } from './lib';
|
|
5
5
|
import KernelEndpoint from './api/KernelEndpoint';
|
|
6
|
-
|
|
7
|
-
export default class KernelModule extends BaseKernelModule<KernelDB | KernelDBLight, null, InMemCache, KernelEndpoint> {
|
|
6
|
+
export default class KernelModule extends BaseKernelModule<KernelDB, null, InMemCache, KernelEndpoint> {
|
|
8
7
|
useLightDB: boolean;
|
|
9
8
|
constructor(kernel: IKernel);
|
|
10
9
|
initModule(): Promise<void>;
|
package/dist/KernelModule.js
CHANGED
|
@@ -14,6 +14,25 @@ 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 __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;
|
|
35
|
+
};
|
|
17
36
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
37
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
38
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -54,45 +73,61 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
54
73
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
74
|
};
|
|
56
75
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
76
|
+
// eslint-disable-next-line max-classes-per-file
|
|
57
77
|
var core_1 = require("@grandlinex/core");
|
|
78
|
+
var bundle_sqlight_1 = __importDefault(require("@grandlinex/bundle-sqlight"));
|
|
79
|
+
var bundle_postgresql_1 = __importDefault(require("@grandlinex/bundle-postgresql"));
|
|
58
80
|
var BaseKernelModule_1 = __importDefault(require("./classes/BaseKernelModule"));
|
|
59
|
-
var KernelDB_1 =
|
|
81
|
+
var KernelDB_1 = __importStar(require("./database/KernelDB"));
|
|
60
82
|
var KernelEndpoint_1 = __importDefault(require("./api/KernelEndpoint"));
|
|
61
83
|
var ApiVersionAction_1 = __importDefault(require("./actions/ApiVersionAction"));
|
|
62
84
|
var GetTokenAction_1 = __importDefault(require("./actions/GetTokenAction"));
|
|
63
85
|
var ApiAuthTestAction_1 = __importDefault(require("./actions/ApiAuthTestAction"));
|
|
64
|
-
var
|
|
86
|
+
var GKey_1 = __importDefault(require("./database/entity/GKey"));
|
|
65
87
|
var KernelModule = /** @class */ (function (_super) {
|
|
66
88
|
__extends(KernelModule, _super);
|
|
67
89
|
function KernelModule(kernel) {
|
|
68
90
|
var _this = _super.call(this, 'kernel', kernel) || this;
|
|
69
91
|
_this.useLightDB = false;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
new ApiAuthTestAction_1.default(_this),
|
|
73
|
-
new GetTokenAction_1.default(_this),
|
|
74
|
-
].forEach(function (action) {
|
|
75
|
-
_this.addAction(action);
|
|
76
|
-
});
|
|
77
|
-
[new core_1.OfflineService(_this)].forEach(function (service) {
|
|
78
|
-
_this.addService(service);
|
|
79
|
-
});
|
|
92
|
+
_this.addAction(new ApiVersionAction_1.default(_this), new ApiAuthTestAction_1.default(_this), new GetTokenAction_1.default(_this));
|
|
93
|
+
_this.addService(new core_1.OfflineService(_this));
|
|
80
94
|
return _this;
|
|
81
95
|
}
|
|
82
96
|
KernelModule.prototype.initModule = function () {
|
|
83
97
|
return __awaiter(this, void 0, void 0, function () {
|
|
84
|
-
var db, endpoint;
|
|
98
|
+
var db, Db, Db, endpoint;
|
|
85
99
|
return __generator(this, function (_a) {
|
|
86
100
|
switch (_a.label) {
|
|
87
101
|
case 0:
|
|
88
|
-
this.setCache(new core_1.InMemCache(this,
|
|
102
|
+
this.setCache(new core_1.InMemCache(this, 480000));
|
|
89
103
|
if (this.useLightDB) {
|
|
90
|
-
|
|
104
|
+
Db = /** @class */ (function (_super) {
|
|
105
|
+
__extends(Db, _super);
|
|
106
|
+
function Db(mod) {
|
|
107
|
+
return _super.call(this, mod, KernelDB_1.KERNEL_DB_VERSION) || this;
|
|
108
|
+
}
|
|
109
|
+
Db.prototype.initNewDB = function () {
|
|
110
|
+
return Promise.resolve(undefined);
|
|
111
|
+
};
|
|
112
|
+
return Db;
|
|
113
|
+
}(bundle_sqlight_1.default));
|
|
114
|
+
db = new KernelDB_1.default(new Db(this));
|
|
91
115
|
}
|
|
92
116
|
else {
|
|
93
|
-
|
|
117
|
+
Db = /** @class */ (function (_super) {
|
|
118
|
+
__extends(Db, _super);
|
|
119
|
+
function Db(mod) {
|
|
120
|
+
return _super.call(this, mod, KernelDB_1.KERNEL_DB_VERSION) || this;
|
|
121
|
+
}
|
|
122
|
+
Db.prototype.initNewDB = function () {
|
|
123
|
+
return Promise.resolve(undefined);
|
|
124
|
+
};
|
|
125
|
+
return Db;
|
|
126
|
+
}(bundle_postgresql_1.default));
|
|
127
|
+
db = new KernelDB_1.default(new Db(this));
|
|
94
128
|
}
|
|
95
129
|
db.setEntityCache(true);
|
|
130
|
+
db.registerEntity(new GKey_1.default());
|
|
96
131
|
this.setDb(db);
|
|
97
132
|
endpoint = new KernelEndpoint_1.default('api', this, this.getKernel().getAppServerPort());
|
|
98
133
|
this.setEndpoint(endpoint);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { CoreDBCon } from '@grandlinex/core';
|
|
3
|
+
import CoreDBPrefab from '@grandlinex/core/dist/classes/CoreDBPrefab';
|
|
4
|
+
import { IKernelDb } from '../lib';
|
|
4
5
|
import GKey from './entity/GKey';
|
|
5
|
-
export
|
|
6
|
-
|
|
6
|
+
export declare const KERNEL_DB_VERSION = "1";
|
|
7
|
+
export default class KernelDB extends CoreDBPrefab<any> implements IKernelDb {
|
|
8
|
+
private gKey;
|
|
9
|
+
constructor(db: CoreDBCon<any, any>);
|
|
10
|
+
initPrefabDB(): Promise<void>;
|
|
7
11
|
deleteKey(id: number): Promise<void>;
|
|
8
12
|
getKey(id: number): Promise<GKey | null>;
|
|
9
|
-
initNewDB(): Promise<void>;
|
|
10
13
|
setKey(secret: string, iv: Buffer, auth: Buffer): Promise<number>;
|
|
11
14
|
}
|
|
@@ -14,51 +14,102 @@ 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
|
-
|
|
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
|
+
}
|
|
35
52
|
};
|
|
36
53
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
54
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
55
|
};
|
|
39
56
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
|
|
57
|
+
exports.KERNEL_DB_VERSION = void 0;
|
|
58
|
+
var core_1 = require("@grandlinex/core");
|
|
59
|
+
var CoreDBPrefab_1 = __importDefault(require("@grandlinex/core/dist/classes/CoreDBPrefab"));
|
|
60
|
+
var crypto_1 = require("crypto");
|
|
41
61
|
var GKey_1 = __importDefault(require("./entity/GKey"));
|
|
42
|
-
|
|
62
|
+
exports.KERNEL_DB_VERSION = '1';
|
|
43
63
|
var KernelDB = /** @class */ (function (_super) {
|
|
44
64
|
__extends(KernelDB, _super);
|
|
45
|
-
function KernelDB(
|
|
46
|
-
var _this = _super.call(this,
|
|
47
|
-
_this.registerEntity(new GKey_1.default());
|
|
65
|
+
function KernelDB(db) {
|
|
66
|
+
var _this = _super.call(this, db) || this;
|
|
67
|
+
_this.gKey = _this.registerEntity(new GKey_1.default());
|
|
48
68
|
return _this;
|
|
49
69
|
}
|
|
70
|
+
KernelDB.prototype.initPrefabDB = function () {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
+
var seed;
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
switch (_a.label) {
|
|
75
|
+
case 0:
|
|
76
|
+
seed = (0, core_1.generateSeed)();
|
|
77
|
+
return [4 /*yield*/, this.setConfig('seed', seed)];
|
|
78
|
+
case 1:
|
|
79
|
+
_a.sent();
|
|
80
|
+
return [4 /*yield*/, this.setConfig('uid', (0, crypto_1.randomUUID)())];
|
|
81
|
+
case 2:
|
|
82
|
+
_a.sent();
|
|
83
|
+
return [2 /*return*/];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
};
|
|
50
88
|
KernelDB.prototype.deleteKey = function (id) {
|
|
51
|
-
return
|
|
89
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
+
return __generator(this, function (_a) {
|
|
91
|
+
switch (_a.label) {
|
|
92
|
+
case 0: return [4 /*yield*/, this.gKey.delete(id)];
|
|
93
|
+
case 1:
|
|
94
|
+
_a.sent();
|
|
95
|
+
return [2 /*return*/];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
});
|
|
52
99
|
};
|
|
53
100
|
KernelDB.prototype.getKey = function (id) {
|
|
54
|
-
return
|
|
55
|
-
};
|
|
56
|
-
KernelDB.prototype.initNewDB = function () {
|
|
57
|
-
return DBF.initNewDB(this);
|
|
101
|
+
return this.gKey.getObjById(id);
|
|
58
102
|
};
|
|
59
103
|
KernelDB.prototype.setKey = function (secret, iv, auth) {
|
|
60
|
-
return
|
|
104
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
105
|
+
return __generator(this, function (_a) {
|
|
106
|
+
switch (_a.label) {
|
|
107
|
+
case 0: return [4 /*yield*/, this.gKey.createObject({ secret: secret, iv: iv, auth: auth })];
|
|
108
|
+
case 1: return [2 /*return*/, (_a.sent()).e_id];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
61
112
|
};
|
|
62
113
|
return KernelDB;
|
|
63
|
-
}(
|
|
114
|
+
}(CoreDBPrefab_1.default));
|
|
64
115
|
exports.default = KernelDB;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import Kernel from './Kernel';
|
|
6
6
|
import KernelModule from './KernelModule';
|
|
7
|
+
import KernelDB from './database/KernelDB';
|
|
8
|
+
import GKey from './database/entity/GKey';
|
|
7
9
|
export * from './actions';
|
|
8
10
|
export * from './api';
|
|
9
11
|
export * from './classes';
|
|
10
12
|
export * from './modules/crypto';
|
|
11
|
-
export * from './database';
|
|
12
13
|
export * from './lib';
|
|
13
14
|
export * from '@grandlinex/core';
|
|
14
15
|
export * as bundlePostgreSQL from '@grandlinex/bundle-postgresql';
|
|
@@ -16,5 +17,5 @@ export * as bundleSQLight from '@grandlinex/bundle-sqlight';
|
|
|
16
17
|
export * as bundleELogger from '@grandlinex/bundle-elogger';
|
|
17
18
|
export { SQLCon } from '@grandlinex/bundle-sqlight';
|
|
18
19
|
export { PGCon } from '@grandlinex/bundle-postgresql';
|
|
19
|
-
export { KernelModule, Kernel };
|
|
20
|
+
export { KernelModule, Kernel, KernelDB, GKey };
|
|
20
21
|
export default Kernel;
|
package/dist/index.js
CHANGED
|
@@ -25,7 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.Kernel = exports.KernelModule = exports.PGCon = exports.SQLCon = exports.bundleELogger = exports.bundleSQLight = exports.bundlePostgreSQL = void 0;
|
|
28
|
+
exports.GKey = exports.KernelDB = exports.Kernel = exports.KernelModule = exports.PGCon = exports.SQLCon = exports.bundleELogger = exports.bundleSQLight = exports.bundlePostgreSQL = void 0;
|
|
29
29
|
/**
|
|
30
30
|
* @name Kernel Main Module
|
|
31
31
|
* @author David Nagy
|
|
@@ -34,11 +34,14 @@ var Kernel_1 = __importDefault(require("./Kernel"));
|
|
|
34
34
|
exports.Kernel = Kernel_1.default;
|
|
35
35
|
var KernelModule_1 = __importDefault(require("./KernelModule"));
|
|
36
36
|
exports.KernelModule = KernelModule_1.default;
|
|
37
|
+
var KernelDB_1 = __importDefault(require("./database/KernelDB"));
|
|
38
|
+
exports.KernelDB = KernelDB_1.default;
|
|
39
|
+
var GKey_1 = __importDefault(require("./database/entity/GKey"));
|
|
40
|
+
exports.GKey = GKey_1.default;
|
|
37
41
|
__exportStar(require("./actions"), exports);
|
|
38
42
|
__exportStar(require("./api"), exports);
|
|
39
43
|
__exportStar(require("./classes"), exports);
|
|
40
44
|
__exportStar(require("./modules/crypto"), exports);
|
|
41
|
-
__exportStar(require("./database"), exports);
|
|
42
45
|
__exportStar(require("./lib"), exports);
|
|
43
46
|
__exportStar(require("@grandlinex/core"), exports);
|
|
44
47
|
exports.bundlePostgreSQL = __importStar(require("@grandlinex/bundle-postgresql"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grandlinex/kernel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.1",
|
|
4
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",
|
|
@@ -27,21 +27,21 @@
|
|
|
27
27
|
},
|
|
28
28
|
"license": "BSD-3-Clause",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@grandlinex/bundle-elogger": "^0.
|
|
31
|
-
"@grandlinex/bundle-postgresql": "^0.
|
|
32
|
-
"@grandlinex/bundle-sqlight": "^0.
|
|
33
|
-
"@grandlinex/core": "^0.
|
|
30
|
+
"@grandlinex/bundle-elogger": "^0.17.3",
|
|
31
|
+
"@grandlinex/bundle-postgresql": "^0.17.3",
|
|
32
|
+
"@grandlinex/bundle-sqlight": "^0.17.3",
|
|
33
|
+
"@grandlinex/core": "^0.17.4",
|
|
34
34
|
"axios": "^0.24.0",
|
|
35
|
-
"body-parser": "^1.19.
|
|
36
|
-
"express": "^4.17.
|
|
35
|
+
"body-parser": "^1.19.1",
|
|
36
|
+
"express": "^4.17.2",
|
|
37
37
|
"jsonwebtoken": "^8.5.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@grandlinex/docs-to-openapi": "^0.6.0",
|
|
41
41
|
"@types/express": "^4.17.13",
|
|
42
|
-
"@types/jest": "^27.0
|
|
42
|
+
"@types/jest": "^27.4.0",
|
|
43
43
|
"@types/jsonwebtoken": "^8.5.6",
|
|
44
|
-
"@types/node": "^16.11.
|
|
44
|
+
"@types/node": "^16.11.12",
|
|
45
45
|
"@typescript-eslint/eslint-plugin": "^5.5.0",
|
|
46
46
|
"@typescript-eslint/parser": "^5.5.0",
|
|
47
47
|
"cross-env": "^7.0.3",
|
|
@@ -49,21 +49,21 @@
|
|
|
49
49
|
"eslint-config-airbnb": "^19.0.2",
|
|
50
50
|
"eslint-config-airbnb-typescript": "^16.1.0",
|
|
51
51
|
"eslint-config-prettier": "^8.3.0",
|
|
52
|
-
"eslint-plugin-import": "^2.25.
|
|
53
|
-
"eslint-plugin-jest": "^25.3.
|
|
52
|
+
"eslint-plugin-import": "^2.25.4",
|
|
53
|
+
"eslint-plugin-jest": "^25.3.4",
|
|
54
54
|
"eslint-plugin-jsx-a11y": "^6.5.1",
|
|
55
55
|
"eslint-plugin-prettier": "^4.0.0",
|
|
56
56
|
"eslint-plugin-react": "^7.27.1",
|
|
57
57
|
"eslint-plugin-react-hooks": "^4.3.0",
|
|
58
58
|
"html-webpack-plugin": "^5.5.0",
|
|
59
|
-
"jest": "^27.4.
|
|
59
|
+
"jest": "^27.4.5",
|
|
60
60
|
"jest-junit": "^13.0.0",
|
|
61
61
|
"prettier": "^2.5.1",
|
|
62
|
-
"ts-jest": "^27.1.
|
|
62
|
+
"ts-jest": "^27.1.2",
|
|
63
63
|
"ts-loader": "^9.2.6",
|
|
64
64
|
"ts-node": "^10.4.0",
|
|
65
65
|
"typedoc": "^0.22.10",
|
|
66
|
-
"typescript": "^4.5.
|
|
66
|
+
"typescript": "^4.5.4"
|
|
67
67
|
},
|
|
68
68
|
"repository": {
|
|
69
69
|
"type": "git",
|
|
@@ -1,10 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,118 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import SQLCon from '@grandlinex/bundle-sqlight';
|
|
3
|
-
import { IBaseKernelModule, IKernelDb } from '../lib';
|
|
4
|
-
import GKey from './entity/GKey';
|
|
5
|
-
export default class KernelDBLight extends SQLCon implements IKernelDb {
|
|
6
|
-
constructor(module: IBaseKernelModule<any, any, any, any>);
|
|
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>;
|
|
11
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
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 __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;
|
|
35
|
-
};
|
|
36
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
-
};
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
var bundle_sqlight_1 = __importDefault(require("@grandlinex/bundle-sqlight"));
|
|
41
|
-
var GKey_1 = __importDefault(require("./entity/GKey"));
|
|
42
|
-
var DBF = __importStar(require("./DBFunctions"));
|
|
43
|
-
var KernelDBLight = /** @class */ (function (_super) {
|
|
44
|
-
__extends(KernelDBLight, _super);
|
|
45
|
-
function KernelDBLight(module) {
|
|
46
|
-
var _this = _super.call(this, module, DBF.KERNEL_DB_VERSION) || this;
|
|
47
|
-
_this.registerEntity(new GKey_1.default());
|
|
48
|
-
return _this;
|
|
49
|
-
}
|
|
50
|
-
KernelDBLight.prototype.deleteKey = function (id) {
|
|
51
|
-
return DBF.deleteKey(this, id);
|
|
52
|
-
};
|
|
53
|
-
KernelDBLight.prototype.getKey = function (id) {
|
|
54
|
-
return DBF.getKey(this, id);
|
|
55
|
-
};
|
|
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);
|
|
61
|
-
};
|
|
62
|
-
return KernelDBLight;
|
|
63
|
-
}(bundle_sqlight_1.default));
|
|
64
|
-
exports.default = KernelDBLight;
|
package/dist/database/index.d.ts
DELETED
package/dist/database/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
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.KernelDBLight = exports.KernelDB = void 0;
|
|
7
|
-
var KernelDB_1 = __importDefault(require("./KernelDB"));
|
|
8
|
-
exports.KernelDB = KernelDB_1.default;
|
|
9
|
-
var KernelDBLight_1 = __importDefault(require("./KernelDBLight"));
|
|
10
|
-
exports.KernelDBLight = KernelDBLight_1.default;
|