@grandlinex/kernel 0.20.0 → 0.22.1-alpha.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +71 -71
  2. package/LICENSE +29 -29
  3. package/README.md +30 -30
  4. package/dist/Kernel.d.ts +22 -21
  5. package/dist/Kernel.js +68 -60
  6. package/dist/KernelModule.d.ts +8 -10
  7. package/dist/KernelModule.js +89 -105
  8. package/dist/actions/ApiAuthTestAction.d.ts +27 -27
  9. package/dist/actions/ApiAuthTestAction.js +93 -92
  10. package/dist/actions/ApiVersionAction.d.ts +30 -30
  11. package/dist/actions/ApiVersionAction.js +96 -96
  12. package/dist/actions/GetTokenAction.d.ts +43 -43
  13. package/dist/actions/GetTokenAction.js +135 -133
  14. package/dist/actions/index.d.ts +4 -4
  15. package/dist/actions/index.js +12 -12
  16. package/dist/api/KernelEndpoint.d.ts +3 -3
  17. package/dist/api/KernelEndpoint.js +29 -29
  18. package/dist/api/index.d.ts +2 -2
  19. package/dist/api/index.js +8 -8
  20. package/dist/classes/BaseAction.d.ts +13 -13
  21. package/dist/classes/BaseAction.js +103 -103
  22. package/dist/classes/BaseApiAction.d.ts +8 -8
  23. package/dist/classes/BaseApiAction.js +67 -61
  24. package/dist/classes/BaseAuthProvider.d.ts +23 -16
  25. package/dist/classes/BaseAuthProvider.js +8 -8
  26. package/dist/classes/BaseEndpoint.d.ts +12 -12
  27. package/dist/classes/BaseEndpoint.js +61 -61
  28. package/dist/classes/BaseKernelModule.d.ts +5 -5
  29. package/dist/classes/BaseKernelModule.js +26 -26
  30. package/dist/classes/index.d.ts +8 -7
  31. package/dist/classes/index.js +34 -23
  32. package/dist/database/KernelDB.d.ts +14 -14
  33. package/dist/database/KernelDB.js +115 -115
  34. package/dist/database/entity/GKey.d.ts +8 -8
  35. package/dist/database/entity/GKey.js +61 -61
  36. package/dist/index.d.ts +14 -21
  37. package/dist/index.js +31 -54
  38. package/dist/lib/index.d.ts +31 -38
  39. package/dist/lib/index.js +2 -2
  40. package/dist/modules/crypto/CryptoClient.d.ts +19 -19
  41. package/dist/modules/crypto/CryptoClient.js +152 -170
  42. package/dist/modules/crypto/index.d.ts +3 -3
  43. package/dist/modules/crypto/index.js +19 -19
  44. package/dist/modules/crypto/utils/cors.d.ts +3 -3
  45. package/dist/modules/crypto/utils/cors.js +10 -10
  46. package/package.json +69 -72
@@ -1,61 +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 __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- var express_1 = __importDefault(require("express"));
22
- var body_parser_1 = require("body-parser");
23
- var core_1 = require("@grandlinex/core");
24
- var BaseEndpoint = /** @class */ (function (_super) {
25
- __extends(BaseEndpoint, _super);
26
- function BaseEndpoint(chanel, module, port) {
27
- var _this = _super.call(this, "endpoint-".concat(chanel), module) || this;
28
- _this.port = port;
29
- _this.appServer = (0, express_1.default)();
30
- _this.appServer.use((0, body_parser_1.json)());
31
- _this.httpServer = null;
32
- return _this;
33
- }
34
- BaseEndpoint.prototype.start = function () {
35
- var _this = this;
36
- return new Promise(function (resolve) {
37
- _this.httpServer = _this.appServer
38
- .listen(_this.port, function () {
39
- _this.debug("Endpoint listen on ".concat(_this.port));
40
- resolve(true);
41
- })
42
- .on('error', function (err) {
43
- _this.error(err);
44
- resolve(false);
45
- });
46
- });
47
- };
48
- BaseEndpoint.prototype.stop = function () {
49
- var _this = this;
50
- return new Promise(function (resolve) {
51
- if (_this.httpServer) {
52
- _this.httpServer.close(function (err) { return (err ? resolve(false) : resolve(true)); });
53
- }
54
- });
55
- };
56
- BaseEndpoint.prototype.getApp = function () {
57
- return this.appServer;
58
- };
59
- return BaseEndpoint;
60
- }(core_1.CorePresenter));
61
- exports.default = BaseEndpoint;
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 __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ var express_1 = __importDefault(require("express"));
22
+ var body_parser_1 = require("body-parser");
23
+ var core_1 = require("@grandlinex/core");
24
+ var BaseEndpoint = /** @class */ (function (_super) {
25
+ __extends(BaseEndpoint, _super);
26
+ function BaseEndpoint(chanel, module, port) {
27
+ var _this = _super.call(this, "endpoint-".concat(chanel), module) || this;
28
+ _this.port = port;
29
+ _this.appServer = (0, express_1.default)();
30
+ _this.appServer.use((0, body_parser_1.json)());
31
+ _this.httpServer = null;
32
+ return _this;
33
+ }
34
+ BaseEndpoint.prototype.start = function () {
35
+ var _this = this;
36
+ return new Promise(function (resolve) {
37
+ _this.httpServer = _this.appServer
38
+ .listen(_this.port, function () {
39
+ _this.debug("Endpoint listen on ".concat(_this.port));
40
+ resolve(true);
41
+ })
42
+ .on('error', function (err) {
43
+ _this.error(err);
44
+ resolve(false);
45
+ });
46
+ });
47
+ };
48
+ BaseEndpoint.prototype.stop = function () {
49
+ var _this = this;
50
+ return new Promise(function (resolve) {
51
+ if (_this.httpServer) {
52
+ _this.httpServer.close(function (err) { return (err ? resolve(false) : resolve(true)); });
53
+ }
54
+ });
55
+ };
56
+ BaseEndpoint.prototype.getApp = function () {
57
+ return this.appServer;
58
+ };
59
+ return BaseEndpoint;
60
+ }(core_1.CorePresenter));
61
+ exports.default = BaseEndpoint;
@@ -1,5 +1,5 @@
1
- import { CoreKernelModule, IDataBase } from '@grandlinex/core';
2
- import { BaseClient } from 'classes';
3
- import { IBaseCache, IBaseKernelModule, IBasePresenter, IKernel } from '../lib';
4
- export default abstract class BaseKernelModule<T extends IDataBase<any, any> | null, P extends BaseClient | null, C extends IBaseCache | null, E extends IBasePresenter | null> extends CoreKernelModule<IKernel, T, P, C, E> implements IBaseKernelModule<T | null, P | null, C | null, E | null> {
5
- }
1
+ import { CoreKernelModule, IDataBase } from '@grandlinex/core';
2
+ import { BaseClient } from 'classes';
3
+ import { IBaseCache, IBaseKernelModule, IBasePresenter, IKernel } from '../lib';
4
+ export default abstract class BaseKernelModule<T extends IDataBase<any, any> | null, P extends BaseClient | null, C extends IBaseCache | null, E extends IBasePresenter | null> extends CoreKernelModule<IKernel, T, P, C, E> implements IBaseKernelModule<T | null, P | null, C | null, E | null> {
5
+ }
@@ -1,26 +1,26 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
18
- var core_1 = require("@grandlinex/core");
19
- var BaseKernelModule = /** @class */ (function (_super) {
20
- __extends(BaseKernelModule, _super);
21
- function BaseKernelModule() {
22
- return _super !== null && _super.apply(this, arguments) || this;
23
- }
24
- return BaseKernelModule;
25
- }(core_1.CoreKernelModule));
26
- exports.default = BaseKernelModule;
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
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ var core_1 = require("@grandlinex/core");
19
+ var BaseKernelModule = /** @class */ (function (_super) {
20
+ __extends(BaseKernelModule, _super);
21
+ function BaseKernelModule() {
22
+ return _super !== null && _super.apply(this, arguments) || this;
23
+ }
24
+ return BaseKernelModule;
25
+ }(core_1.CoreKernelModule));
26
+ exports.default = BaseKernelModule;
@@ -1,7 +1,8 @@
1
- import { CoreBridge as BaseBridge, CoreCache as BaseCache, CoreClient as BaseClient, CoreElement as BaseElement, CoreLoopService as BaseLoopService, CoreService as BaseService } from '@grandlinex/core';
2
- import BaseAction from './BaseAction';
3
- import BaseEndpoint from './BaseEndpoint';
4
- import BaseKernelModule from './BaseKernelModule';
5
- import BaseApiAction from './BaseApiAction';
6
- import BaseAuthProvider from './BaseAuthProvider';
7
- export { BaseLoopService, BaseAuthProvider, BaseKernelModule, BaseService, BaseApiAction, BaseEndpoint, BaseElement, BaseCache, BaseAction, BaseClient, BaseBridge, };
1
+ import { CoreBridge as BaseBridge, CoreCache as BaseCache, CoreClient as BaseClient, CoreElement as BaseElement, CoreLoopService as BaseLoopService, CoreService as BaseService } from '@grandlinex/core';
2
+ import BaseAction from './BaseAction';
3
+ import BaseEndpoint from './BaseEndpoint';
4
+ import BaseKernelModule from './BaseKernelModule';
5
+ import BaseApiAction from './BaseApiAction';
6
+ import BaseAuthProvider from './BaseAuthProvider';
7
+ export * from './BaseAuthProvider';
8
+ export { BaseLoopService, BaseAuthProvider, BaseKernelModule, BaseService, BaseApiAction, BaseEndpoint, BaseElement, BaseCache, BaseAction, BaseClient, BaseBridge, };
@@ -1,23 +1,34 @@
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.BaseBridge = exports.BaseClient = exports.BaseAction = exports.BaseCache = exports.BaseElement = exports.BaseEndpoint = exports.BaseApiAction = exports.BaseService = exports.BaseKernelModule = exports.BaseAuthProvider = exports.BaseLoopService = void 0;
7
- var core_1 = require("@grandlinex/core");
8
- Object.defineProperty(exports, "BaseBridge", { enumerable: true, get: function () { return core_1.CoreBridge; } });
9
- Object.defineProperty(exports, "BaseCache", { enumerable: true, get: function () { return core_1.CoreCache; } });
10
- Object.defineProperty(exports, "BaseClient", { enumerable: true, get: function () { return core_1.CoreClient; } });
11
- Object.defineProperty(exports, "BaseElement", { enumerable: true, get: function () { return core_1.CoreElement; } });
12
- Object.defineProperty(exports, "BaseLoopService", { enumerable: true, get: function () { return core_1.CoreLoopService; } });
13
- Object.defineProperty(exports, "BaseService", { enumerable: true, get: function () { return core_1.CoreService; } });
14
- var BaseAction_1 = __importDefault(require("./BaseAction"));
15
- exports.BaseAction = BaseAction_1.default;
16
- var BaseEndpoint_1 = __importDefault(require("./BaseEndpoint"));
17
- exports.BaseEndpoint = BaseEndpoint_1.default;
18
- var BaseKernelModule_1 = __importDefault(require("./BaseKernelModule"));
19
- exports.BaseKernelModule = BaseKernelModule_1.default;
20
- var BaseApiAction_1 = __importDefault(require("./BaseApiAction"));
21
- exports.BaseApiAction = BaseApiAction_1.default;
22
- var BaseAuthProvider_1 = __importDefault(require("./BaseAuthProvider"));
23
- exports.BaseAuthProvider = BaseAuthProvider_1.default;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.BaseBridge = exports.BaseClient = exports.BaseAction = exports.BaseCache = exports.BaseElement = exports.BaseEndpoint = exports.BaseApiAction = exports.BaseService = exports.BaseKernelModule = exports.BaseAuthProvider = exports.BaseLoopService = void 0;
17
+ var core_1 = require("@grandlinex/core");
18
+ Object.defineProperty(exports, "BaseBridge", { enumerable: true, get: function () { return core_1.CoreBridge; } });
19
+ Object.defineProperty(exports, "BaseCache", { enumerable: true, get: function () { return core_1.CoreCache; } });
20
+ Object.defineProperty(exports, "BaseClient", { enumerable: true, get: function () { return core_1.CoreClient; } });
21
+ Object.defineProperty(exports, "BaseElement", { enumerable: true, get: function () { return core_1.CoreElement; } });
22
+ Object.defineProperty(exports, "BaseLoopService", { enumerable: true, get: function () { return core_1.CoreLoopService; } });
23
+ Object.defineProperty(exports, "BaseService", { enumerable: true, get: function () { return core_1.CoreService; } });
24
+ var BaseAction_1 = __importDefault(require("./BaseAction"));
25
+ exports.BaseAction = BaseAction_1.default;
26
+ var BaseEndpoint_1 = __importDefault(require("./BaseEndpoint"));
27
+ exports.BaseEndpoint = BaseEndpoint_1.default;
28
+ var BaseKernelModule_1 = __importDefault(require("./BaseKernelModule"));
29
+ exports.BaseKernelModule = BaseKernelModule_1.default;
30
+ var BaseApiAction_1 = __importDefault(require("./BaseApiAction"));
31
+ exports.BaseApiAction = BaseApiAction_1.default;
32
+ var BaseAuthProvider_1 = __importDefault(require("./BaseAuthProvider"));
33
+ exports.BaseAuthProvider = BaseAuthProvider_1.default;
34
+ __exportStar(require("./BaseAuthProvider"), exports);
@@ -1,14 +1,14 @@
1
- /// <reference types="node" />
2
- import { CoreDBCon } from '@grandlinex/core';
3
- import CoreDBPrefab from '@grandlinex/core/dist/classes/CoreDBPrefab';
4
- import { IKernelDb } from '../lib';
5
- import GKey from './entity/GKey';
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>;
11
- deleteKey(id: number): Promise<void>;
12
- getKey(id: number): Promise<GKey | null>;
13
- setKey(secret: string, iv: Buffer, auth: Buffer): Promise<number>;
14
- }
1
+ /// <reference types="node" />
2
+ import { CoreDBCon } from '@grandlinex/core';
3
+ import CoreDBPrefab from '@grandlinex/core/dist/classes/CoreDBPrefab';
4
+ import { IKernelDb } from '../lib';
5
+ import GKey from './entity/GKey';
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>;
11
+ deleteKey(id: number): Promise<void>;
12
+ getKey(id: number): Promise<GKey | null>;
13
+ setKey(secret: string, iv: Buffer, auth: Buffer): Promise<number>;
14
+ }
@@ -1,115 +1,115 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
54
- return (mod && mod.__esModule) ? mod : { "default": mod };
55
- };
56
- Object.defineProperty(exports, "__esModule", { value: true });
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");
61
- var GKey_1 = __importDefault(require("./entity/GKey"));
62
- exports.KERNEL_DB_VERSION = '1';
63
- var KernelDB = /** @class */ (function (_super) {
64
- __extends(KernelDB, _super);
65
- function KernelDB(db) {
66
- var _this = _super.call(this, db) || this;
67
- _this.gKey = _this.registerEntity(new GKey_1.default());
68
- return _this;
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
- };
88
- KernelDB.prototype.deleteKey = function (id) {
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
- });
99
- };
100
- KernelDB.prototype.getKey = function (id) {
101
- return this.gKey.getObjById(id);
102
- };
103
- KernelDB.prototype.setKey = function (secret, iv, auth) {
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
- });
112
- };
113
- return KernelDB;
114
- }(CoreDBPrefab_1.default));
115
- exports.default = KernelDB;
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
54
+ return (mod && mod.__esModule) ? mod : { "default": mod };
55
+ };
56
+ Object.defineProperty(exports, "__esModule", { value: true });
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");
61
+ var GKey_1 = __importDefault(require("./entity/GKey"));
62
+ exports.KERNEL_DB_VERSION = '1';
63
+ var KernelDB = /** @class */ (function (_super) {
64
+ __extends(KernelDB, _super);
65
+ function KernelDB(db) {
66
+ var _this = _super.call(this, db) || this;
67
+ _this.gKey = _this.registerEntity(new GKey_1.default());
68
+ return _this;
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
+ };
88
+ KernelDB.prototype.deleteKey = function (id) {
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
+ });
99
+ };
100
+ KernelDB.prototype.getKey = function (id) {
101
+ return this.gKey.getObjById(id);
102
+ };
103
+ KernelDB.prototype.setKey = function (secret, iv, auth) {
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
+ });
112
+ };
113
+ return KernelDB;
114
+ }(CoreDBPrefab_1.default));
115
+ exports.default = KernelDB;
@@ -1,8 +1,8 @@
1
- /// <reference types="node" />
2
- import { CoreEntity, EProperties } from '@grandlinex/core';
3
- export default class GKey extends CoreEntity {
4
- secret: string;
5
- iv: Buffer;
6
- auth: Buffer;
7
- constructor(props?: EProperties<GKey>);
8
- }
1
+ /// <reference types="node" />
2
+ import { CoreEntity, EProperties } from '@grandlinex/core';
3
+ export default class GKey extends CoreEntity {
4
+ secret: string;
5
+ iv: Buffer;
6
+ auth: Buffer;
7
+ constructor(props?: EProperties<GKey>);
8
+ }