@grandlinex/kernel 0.28.2 → 0.30.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/dist/Kernel.d.ts +3 -3
- package/dist/Kernel.js +7 -13
- package/dist/KernelModule.d.ts +3 -3
- package/dist/KernelModule.js +13 -30
- package/dist/actions/ApiAuthTestAction.d.ts +3 -19
- package/dist/actions/ApiAuthTestAction.js +5 -35
- package/dist/actions/ApiVersionAction.d.ts +3 -23
- package/dist/actions/ApiVersionAction.js +6 -40
- package/dist/actions/GetTokenAction.d.ts +3 -4
- package/dist/actions/GetTokenAction.js +26 -41
- package/dist/actions/index.d.ts +3 -3
- package/dist/actions/index.js +4 -12
- package/dist/api/KernelEndpoint.d.ts +1 -1
- package/dist/api/KernelEndpoint.js +2 -8
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +3 -8
- package/dist/classes/BaseAction.d.ts +4 -4
- package/dist/classes/BaseAction.js +37 -52
- package/dist/classes/BaseApiAction.d.ts +2 -2
- package/dist/classes/BaseApiAction.js +2 -8
- package/dist/classes/BaseAuthProvider.d.ts +3 -3
- package/dist/classes/BaseAuthProvider.js +1 -4
- package/dist/classes/BaseEndpoint.d.ts +4 -4
- package/dist/classes/BaseEndpoint.js +11 -20
- package/dist/classes/BaseKernelModule.d.ts +1 -1
- package/dist/classes/BaseKernelModule.js +2 -5
- package/dist/classes/index.d.ts +8 -7
- package/dist/classes/index.js +10 -52
- package/dist/classes/timing/ExpressServerTiming.d.ts +2 -2
- package/dist/classes/timing/ExpressServerTiming.js +7 -26
- package/dist/classes/timing/ServerTiming.d.ts +1 -1
- package/dist/classes/timing/ServerTiming.js +8 -25
- package/dist/classes/timing/ServerTimingElement.js +1 -4
- package/dist/classes/timing/index.d.ts +3 -3
- package/dist/classes/timing/index.js +4 -12
- package/dist/index.d.ts +8 -8
- package/dist/index.js +11 -32
- package/dist/lib/express.js +1 -2
- package/dist/lib/index.d.ts +4 -5
- package/dist/lib/index.js +1 -2
- package/dist/modules/crypto/CryptoClient.d.ts +5 -5
- package/dist/modules/crypto/CryptoClient.js +44 -85
- package/dist/modules/crypto/index.d.ts +2 -2
- package/dist/modules/crypto/index.js +3 -23
- package/dist/modules/crypto/utils/cors.d.ts +1 -1
- package/dist/modules/crypto/utils/cors.js +1 -5
- package/package.json +24 -23
package/CHANGELOG.md
CHANGED
package/dist/Kernel.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ICClient, IKernel } from './lib';
|
|
3
|
-
import { XRequest } from './lib/express';
|
|
1
|
+
import { CoreLogger, CoreKernel } from '@grandlinex/core';
|
|
2
|
+
import { ICClient, IKernel } from './lib/index.js';
|
|
3
|
+
import { XRequest } from './lib/express.js';
|
|
4
4
|
/**
|
|
5
5
|
* @class Kernel
|
|
6
6
|
*/
|
package/dist/Kernel.js
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const core_1 = __importDefault(require("@grandlinex/core"));
|
|
7
|
-
const CryptoClient_1 = __importDefault(require("./modules/crypto/CryptoClient"));
|
|
8
|
-
const KernelModule_1 = __importDefault(require("./KernelModule"));
|
|
1
|
+
import { CoreKernel } from '@grandlinex/core';
|
|
2
|
+
import CryptoClient from './modules/crypto/CryptoClient.js';
|
|
3
|
+
import KernelModule from './KernelModule.js';
|
|
9
4
|
/**
|
|
10
5
|
* @class Kernel
|
|
11
6
|
*/
|
|
12
|
-
class Kernel extends
|
|
7
|
+
export default class Kernel extends CoreKernel {
|
|
13
8
|
/**
|
|
14
9
|
* Default Constructor
|
|
15
10
|
* @param options App Name
|
|
16
11
|
*/
|
|
17
12
|
constructor(options) {
|
|
18
|
-
super(
|
|
19
|
-
this.setBaseModule(new
|
|
13
|
+
super({ ...options });
|
|
14
|
+
this.setBaseModule(new KernelModule(this));
|
|
20
15
|
if (options.portOverride) {
|
|
21
16
|
this.debug(`use custiom api port @ ${options.portOverride}`);
|
|
22
17
|
this.expressPort = options.portOverride;
|
|
@@ -26,7 +21,7 @@ class Kernel extends core_1.default {
|
|
|
26
21
|
}
|
|
27
22
|
const store = this.getConfigStore();
|
|
28
23
|
if (store.has('SERVER_PASSWORD')) {
|
|
29
|
-
this.setCryptoClient(new
|
|
24
|
+
this.setCryptoClient(new CryptoClient(CryptoClient.fromPW(store.get('SERVER_PASSWORD')), this));
|
|
30
25
|
}
|
|
31
26
|
}
|
|
32
27
|
getAppServerPort() {
|
|
@@ -42,4 +37,3 @@ class Kernel extends core_1.default {
|
|
|
42
37
|
}
|
|
43
38
|
}
|
|
44
39
|
}
|
|
45
|
-
exports.default = Kernel;
|
package/dist/KernelModule.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InMemCache } from '@grandlinex/core';
|
|
2
|
-
import BaseKernelModule from './classes/BaseKernelModule';
|
|
3
|
-
import { IKernel } from './lib';
|
|
4
|
-
import KernelEndpoint from './api/KernelEndpoint';
|
|
2
|
+
import BaseKernelModule from './classes/BaseKernelModule.js';
|
|
3
|
+
import { IKernel } from './lib/index.js';
|
|
4
|
+
import KernelEndpoint from './api/KernelEndpoint.js';
|
|
5
5
|
export default class KernelModule extends BaseKernelModule<IKernel, null, null, InMemCache, KernelEndpoint> {
|
|
6
6
|
constructor(kernel: IKernel);
|
|
7
7
|
initModule(): Promise<void>;
|
package/dist/KernelModule.js
CHANGED
|
@@ -1,35 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const core_1 = require("@grandlinex/core");
|
|
16
|
-
const BaseKernelModule_1 = __importDefault(require("./classes/BaseKernelModule"));
|
|
17
|
-
const KernelEndpoint_1 = __importDefault(require("./api/KernelEndpoint"));
|
|
18
|
-
const ApiVersionAction_1 = __importDefault(require("./actions/ApiVersionAction"));
|
|
19
|
-
const GetTokenAction_1 = __importDefault(require("./actions/GetTokenAction"));
|
|
20
|
-
const ApiAuthTestAction_1 = __importDefault(require("./actions/ApiAuthTestAction"));
|
|
21
|
-
class KernelModule extends BaseKernelModule_1.default {
|
|
1
|
+
import { OfflineService } from '@grandlinex/core';
|
|
2
|
+
import BaseKernelModule from './classes/BaseKernelModule.js';
|
|
3
|
+
import KernelEndpoint from './api/KernelEndpoint.js';
|
|
4
|
+
import ApiVersionAction from './actions/ApiVersionAction.js';
|
|
5
|
+
import GetTokenAction from './actions/GetTokenAction.js';
|
|
6
|
+
import ApiAuthTestAction from './actions/ApiAuthTestAction.js';
|
|
7
|
+
export default class KernelModule extends BaseKernelModule {
|
|
22
8
|
constructor(kernel) {
|
|
23
9
|
super('base-mod', kernel);
|
|
24
|
-
this.addAction(new
|
|
10
|
+
this.addAction(new ApiVersionAction(this), new ApiAuthTestAction(this), new GetTokenAction(this));
|
|
25
11
|
}
|
|
26
|
-
initModule() {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
yield this.getKernel().triggerFunction('load');
|
|
32
|
-
});
|
|
12
|
+
async initModule() {
|
|
13
|
+
this.addService(new OfflineService(this));
|
|
14
|
+
const endpoint = new KernelEndpoint('api', this, this.getKernel().getAppServerPort());
|
|
15
|
+
this.setPresenter(endpoint);
|
|
16
|
+
await this.getKernel().triggerFunction('load');
|
|
33
17
|
}
|
|
34
18
|
}
|
|
35
|
-
exports.default = KernelModule;
|
|
@@ -1,25 +1,9 @@
|
|
|
1
|
-
import { IBaseKernelModule } from '../lib';
|
|
2
|
-
import { BaseApiAction, JwtToken } from '../classes';
|
|
3
|
-
import { XRequest, XResponse } from '../lib/express';
|
|
1
|
+
import { IBaseKernelModule } from '../lib/index.js';
|
|
2
|
+
import { BaseApiAction, JwtToken } from '../classes/index.js';
|
|
3
|
+
import { XRequest, XResponse } from '../lib/express.js';
|
|
4
4
|
/**
|
|
5
5
|
* @name ApiAuthTestAction
|
|
6
6
|
*
|
|
7
|
-
* @openapi
|
|
8
|
-
* /test/auth:
|
|
9
|
-
* get:
|
|
10
|
-
* summary: test call for valid access rights
|
|
11
|
-
* tags:
|
|
12
|
-
* - Kernel
|
|
13
|
-
* responses:
|
|
14
|
-
* 200:
|
|
15
|
-
* description: OK
|
|
16
|
-
* content:
|
|
17
|
-
* text/plain:
|
|
18
|
-
* schema:
|
|
19
|
-
* type: string
|
|
20
|
-
* 401:
|
|
21
|
-
* description: invalid token / not authorized
|
|
22
|
-
*
|
|
23
7
|
*/
|
|
24
8
|
export default class ApiAuthTestAction extends BaseApiAction {
|
|
25
9
|
constructor(module: IBaseKernelModule<any, any, any, any>);
|
|
@@ -1,45 +1,15 @@
|
|
|
1
|
-
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const classes_1 = require("../classes");
|
|
1
|
+
import { BaseApiAction } from '../classes/index.js';
|
|
13
2
|
/**
|
|
14
3
|
* @name ApiAuthTestAction
|
|
15
4
|
*
|
|
16
|
-
* @openapi
|
|
17
|
-
* /test/auth:
|
|
18
|
-
* get:
|
|
19
|
-
* summary: test call for valid access rights
|
|
20
|
-
* tags:
|
|
21
|
-
* - Kernel
|
|
22
|
-
* responses:
|
|
23
|
-
* 200:
|
|
24
|
-
* description: OK
|
|
25
|
-
* content:
|
|
26
|
-
* text/plain:
|
|
27
|
-
* schema:
|
|
28
|
-
* type: string
|
|
29
|
-
* 401:
|
|
30
|
-
* description: invalid token / not authorized
|
|
31
|
-
*
|
|
32
5
|
*/
|
|
33
|
-
class ApiAuthTestAction extends
|
|
6
|
+
export default class ApiAuthTestAction extends BaseApiAction {
|
|
34
7
|
constructor(module) {
|
|
35
8
|
super('GET', '/test/auth', module);
|
|
36
9
|
this.handler = this.handler.bind(this);
|
|
37
10
|
}
|
|
38
|
-
handler(req, res, next, data) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
res.status(200).send("It work's");
|
|
42
|
-
});
|
|
11
|
+
async handler(req, res, next, data) {
|
|
12
|
+
this.debug(data.userid);
|
|
13
|
+
res.status(200).send("It work's");
|
|
43
14
|
}
|
|
44
15
|
}
|
|
45
|
-
exports.default = ApiAuthTestAction;
|
|
@@ -1,29 +1,9 @@
|
|
|
1
|
-
import { IBaseKernelModule } from '../lib';
|
|
2
|
-
import { BaseApiAction } from '../classes';
|
|
3
|
-
import {
|
|
4
|
-
import { XRequest, XResponse } from '../lib/express';
|
|
1
|
+
import { IBaseKernelModule } from '../lib/index.js';
|
|
2
|
+
import { BaseApiAction, IExtensionInterface } from '../classes/index.js';
|
|
3
|
+
import { XRequest, XResponse } from '../lib/express.js';
|
|
5
4
|
/**
|
|
6
5
|
* @name ApiVersionAction
|
|
7
6
|
*
|
|
8
|
-
* @openapi
|
|
9
|
-
* /version:
|
|
10
|
-
* get:
|
|
11
|
-
* summary: get api schema version
|
|
12
|
-
* tags:
|
|
13
|
-
* - Kernel
|
|
14
|
-
* responses:
|
|
15
|
-
* 200:
|
|
16
|
-
* description: OK
|
|
17
|
-
* content:
|
|
18
|
-
* application/json:
|
|
19
|
-
* schema:
|
|
20
|
-
* type: object
|
|
21
|
-
* properties:
|
|
22
|
-
* api:
|
|
23
|
-
* type: number
|
|
24
|
-
* 401:
|
|
25
|
-
* description: invalid token / not authorized
|
|
26
|
-
*
|
|
27
7
|
*/
|
|
28
8
|
export default class ApiVersionAction extends BaseApiAction {
|
|
29
9
|
constructor(module: IBaseKernelModule);
|
|
@@ -1,50 +1,16 @@
|
|
|
1
|
-
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const classes_1 = require("../classes");
|
|
13
|
-
const BaseAction_1 = require("../classes/BaseAction");
|
|
1
|
+
import { BaseApiAction, ActionMode, } from '../classes/index.js';
|
|
14
2
|
/**
|
|
15
3
|
* @name ApiVersionAction
|
|
16
4
|
*
|
|
17
|
-
* @openapi
|
|
18
|
-
* /version:
|
|
19
|
-
* get:
|
|
20
|
-
* summary: get api schema version
|
|
21
|
-
* tags:
|
|
22
|
-
* - Kernel
|
|
23
|
-
* responses:
|
|
24
|
-
* 200:
|
|
25
|
-
* description: OK
|
|
26
|
-
* content:
|
|
27
|
-
* application/json:
|
|
28
|
-
* schema:
|
|
29
|
-
* type: object
|
|
30
|
-
* properties:
|
|
31
|
-
* api:
|
|
32
|
-
* type: number
|
|
33
|
-
* 401:
|
|
34
|
-
* description: invalid token / not authorized
|
|
35
|
-
*
|
|
36
5
|
*/
|
|
37
|
-
class ApiVersionAction extends
|
|
6
|
+
export default class ApiVersionAction extends BaseApiAction {
|
|
38
7
|
constructor(module) {
|
|
39
8
|
super('GET', '/version', module);
|
|
40
9
|
this.handler = this.handler.bind(this);
|
|
41
|
-
this.setMode(
|
|
10
|
+
this.setMode(ActionMode.DMZ);
|
|
42
11
|
}
|
|
43
|
-
handler(req, res, next, data, ex) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
res.status(200).send({ api: 1 });
|
|
47
|
-
});
|
|
12
|
+
async handler(req, res, next, data, ex) {
|
|
13
|
+
ex.done();
|
|
14
|
+
res.status(200).send({ api: 1 });
|
|
48
15
|
}
|
|
49
16
|
}
|
|
50
|
-
exports.default = ApiVersionAction;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { IBaseKernelModule } from '../lib';
|
|
2
|
-
import { BaseApiAction } from '../classes';
|
|
3
|
-
import {
|
|
4
|
-
import { XRequest, XResponse } from '../lib/express';
|
|
1
|
+
import { IBaseKernelModule } from '../lib/index.js';
|
|
2
|
+
import { BaseApiAction, IExtensionInterface } from '../classes/index.js';
|
|
3
|
+
import { XRequest, XResponse } from '../lib/express.js';
|
|
5
4
|
/**
|
|
6
5
|
* @openapi
|
|
7
6
|
* /token:
|
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const classes_1 = require("../classes");
|
|
13
|
-
const BaseAction_1 = require("../classes/BaseAction");
|
|
1
|
+
import { BaseApiAction, ActionMode, } from '../classes/index.js';
|
|
14
2
|
/**
|
|
15
3
|
* @openapi
|
|
16
4
|
* /token:
|
|
@@ -43,7 +31,7 @@ const BaseAction_1 = require("../classes/BaseAction");
|
|
|
43
31
|
* token:
|
|
44
32
|
* type: string
|
|
45
33
|
*/
|
|
46
|
-
class GetTokenAction extends
|
|
34
|
+
export default class GetTokenAction extends BaseApiAction {
|
|
47
35
|
/**
|
|
48
36
|
*
|
|
49
37
|
* @param module Parent Module
|
|
@@ -51,33 +39,30 @@ class GetTokenAction extends classes_1.BaseApiAction {
|
|
|
51
39
|
constructor(module) {
|
|
52
40
|
super('POST', '/token', module);
|
|
53
41
|
this.handler = this.handler.bind(this);
|
|
54
|
-
this.setMode(
|
|
42
|
+
this.setMode(ActionMode.DMZ);
|
|
55
43
|
}
|
|
56
|
-
handler(req, res, next, data, ex) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
});
|
|
44
|
+
async handler(req, res, next, data, ex) {
|
|
45
|
+
const cc = this.getKernel().getCryptoClient();
|
|
46
|
+
if (!req.body.token) {
|
|
47
|
+
res.status(400).send('no token');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (!req.body.username) {
|
|
51
|
+
res.status(401).send('no username');
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const { username, token } = req.body;
|
|
55
|
+
const valid = await ex.timing.startFunc('validation', () => cc.apiTokenValidation(username, token, 'api'));
|
|
56
|
+
if (valid.valid && valid.userId) {
|
|
57
|
+
const jwt = cc.jwtGenerateAccessToken({
|
|
58
|
+
userid: valid.userId,
|
|
59
|
+
username,
|
|
60
|
+
});
|
|
61
|
+
ex.done();
|
|
62
|
+
res.status(200).send({ token: jwt });
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
res.status(403).send('no no no ...');
|
|
66
|
+
}
|
|
81
67
|
}
|
|
82
68
|
}
|
|
83
|
-
exports.default = GetTokenAction;
|
package/dist/actions/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ApiAuthTestAction from './ApiAuthTestAction';
|
|
2
|
-
import ApiVersionAction from './ApiVersionAction';
|
|
3
|
-
import GetTokenAction from './GetTokenAction';
|
|
1
|
+
import ApiAuthTestAction from './ApiAuthTestAction.js';
|
|
2
|
+
import ApiVersionAction from './ApiVersionAction.js';
|
|
3
|
+
import GetTokenAction from './GetTokenAction.js';
|
|
4
4
|
export { ApiVersionAction, ApiAuthTestAction, GetTokenAction };
|
package/dist/actions/index.js
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.GetTokenAction = exports.ApiAuthTestAction = exports.ApiVersionAction = void 0;
|
|
7
|
-
const ApiAuthTestAction_1 = __importDefault(require("./ApiAuthTestAction"));
|
|
8
|
-
exports.ApiAuthTestAction = ApiAuthTestAction_1.default;
|
|
9
|
-
const ApiVersionAction_1 = __importDefault(require("./ApiVersionAction"));
|
|
10
|
-
exports.ApiVersionAction = ApiVersionAction_1.default;
|
|
11
|
-
const GetTokenAction_1 = __importDefault(require("./GetTokenAction"));
|
|
12
|
-
exports.GetTokenAction = GetTokenAction_1.default;
|
|
1
|
+
import ApiAuthTestAction from './ApiAuthTestAction.js';
|
|
2
|
+
import ApiVersionAction from './ApiVersionAction.js';
|
|
3
|
+
import GetTokenAction from './GetTokenAction.js';
|
|
4
|
+
export { ApiVersionAction, ApiAuthTestAction, GetTokenAction };
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const BaseEndpoint_1 = __importDefault(require("../classes/BaseEndpoint"));
|
|
7
|
-
class KernelEndpoint extends BaseEndpoint_1.default {
|
|
1
|
+
import BaseEndpoint from '../classes/BaseEndpoint.js';
|
|
2
|
+
export default class KernelEndpoint extends BaseEndpoint {
|
|
8
3
|
}
|
|
9
|
-
exports.default = KernelEndpoint;
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import KernelEndpoint from './KernelEndpoint';
|
|
1
|
+
import KernelEndpoint from './KernelEndpoint.js';
|
|
2
2
|
export { KernelEndpoint };
|
package/dist/api/index.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.KernelEndpoint = void 0;
|
|
7
|
-
const KernelEndpoint_1 = __importDefault(require("./KernelEndpoint"));
|
|
8
|
-
exports.KernelEndpoint = KernelEndpoint_1.default;
|
|
1
|
+
import KernelEndpoint from './KernelEndpoint.js';
|
|
2
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
3
|
+
export { KernelEndpoint };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CoreAction, IDataBase } from '@grandlinex/core';
|
|
2
|
-
import { IBaseAction, IBaseCache, IBaseClient, IBaseKernelModule, IBasePresenter, IKernel } from '../lib';
|
|
3
|
-
import { JwtToken } from './BaseAuthProvider';
|
|
4
|
-
import { IExtensionInterface } from './timing/
|
|
5
|
-
import { XNextFc, XRequest, XResponse } from '../lib/express';
|
|
2
|
+
import { IBaseAction, IBaseCache, IBaseClient, IBaseKernelModule, IBasePresenter, IKernel } from '../lib/index.js';
|
|
3
|
+
import { JwtToken } from './BaseAuthProvider.js';
|
|
4
|
+
import { IExtensionInterface } from './timing/index.js';
|
|
5
|
+
import { XNextFc, XRequest, XResponse } from '../lib/express.js';
|
|
6
6
|
export declare enum ActionMode {
|
|
7
7
|
'DEFAULT' = 0,
|
|
8
8
|
'DMZ' = 1,
|
|
@@ -1,70 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ActionMode = void 0;
|
|
13
|
-
const core_1 = require("@grandlinex/core");
|
|
14
|
-
const timing_1 = require("./timing");
|
|
15
|
-
var ActionMode;
|
|
1
|
+
import { CoreAction } from '@grandlinex/core';
|
|
2
|
+
import { ExpressServerTiming } from './timing/index.js';
|
|
3
|
+
export var ActionMode;
|
|
16
4
|
(function (ActionMode) {
|
|
17
5
|
ActionMode[ActionMode["DEFAULT"] = 0] = "DEFAULT";
|
|
18
6
|
ActionMode[ActionMode["DMZ"] = 1] = "DMZ";
|
|
19
7
|
ActionMode[ActionMode["DMZ_WITH_USER"] = 2] = "DMZ_WITH_USER";
|
|
20
|
-
})(ActionMode =
|
|
21
|
-
class BaseAction extends
|
|
8
|
+
})(ActionMode = ActionMode || (ActionMode = {}));
|
|
9
|
+
export default class BaseAction extends CoreAction {
|
|
22
10
|
constructor(chanel, module) {
|
|
23
11
|
super(chanel, module);
|
|
24
12
|
this.secureHandler = this.secureHandler.bind(this);
|
|
25
13
|
this.mode = ActionMode.DEFAULT;
|
|
26
14
|
}
|
|
27
|
-
secureHandler(req, res, next) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
req,
|
|
35
|
-
});
|
|
15
|
+
async secureHandler(req, res, next) {
|
|
16
|
+
const extension = this.initExtension(res);
|
|
17
|
+
const auth = extension.timing.start('auth');
|
|
18
|
+
res.on('finish', () => {
|
|
19
|
+
this.getKernel().responseCodeFunction({
|
|
20
|
+
code: res.statusCode,
|
|
21
|
+
req,
|
|
36
22
|
});
|
|
37
|
-
const cc = this.getKernel().getCryptoClient();
|
|
38
|
-
if (!cc) {
|
|
39
|
-
res.status(504).send('internal server error');
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if (this.mode === ActionMode.DMZ) {
|
|
43
|
-
auth.stop();
|
|
44
|
-
yield this.handler(req, res, next, null, extension);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const dat = yield cc.bearerTokenValidation(req);
|
|
48
|
-
auth.stop();
|
|
49
|
-
if (dat && typeof dat !== 'number') {
|
|
50
|
-
yield this.handler(req, res, next, dat, extension);
|
|
51
|
-
}
|
|
52
|
-
else if (this.mode === ActionMode.DMZ_WITH_USER) {
|
|
53
|
-
yield this.handler(req, res, next, null, extension);
|
|
54
|
-
}
|
|
55
|
-
else if (dat) {
|
|
56
|
-
res.sendStatus(dat);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
res.status(401).send('no no no ...');
|
|
60
|
-
}
|
|
61
23
|
});
|
|
24
|
+
const cc = this.getKernel().getCryptoClient();
|
|
25
|
+
if (!cc) {
|
|
26
|
+
res.status(504).send('internal server error');
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (this.mode === ActionMode.DMZ) {
|
|
30
|
+
auth.stop();
|
|
31
|
+
await this.handler(req, res, next, null, extension);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const dat = await cc.bearerTokenValidation(req);
|
|
35
|
+
auth.stop();
|
|
36
|
+
if (dat && typeof dat !== 'number') {
|
|
37
|
+
await this.handler(req, res, next, dat, extension);
|
|
38
|
+
}
|
|
39
|
+
else if (this.mode === ActionMode.DMZ_WITH_USER) {
|
|
40
|
+
await this.handler(req, res, next, null, extension);
|
|
41
|
+
}
|
|
42
|
+
else if (dat) {
|
|
43
|
+
res.sendStatus(dat);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
res.status(401).send('no no no ...');
|
|
47
|
+
}
|
|
62
48
|
}
|
|
63
49
|
setMode(mode) {
|
|
64
50
|
this.mode = mode;
|
|
65
51
|
}
|
|
66
52
|
initExtension(res) {
|
|
67
|
-
const [el, fx] =
|
|
53
|
+
const [el, fx] = ExpressServerTiming.init(this, res);
|
|
68
54
|
return {
|
|
69
55
|
done: () => {
|
|
70
56
|
fx();
|
|
@@ -73,4 +59,3 @@ class BaseAction extends core_1.CoreAction {
|
|
|
73
59
|
};
|
|
74
60
|
}
|
|
75
61
|
}
|
|
76
|
-
exports.default = BaseAction;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IDataBase } from '@grandlinex/core';
|
|
2
|
-
import { ActionTypes, IBaseAction, IBaseCache, IBaseClient, IBaseKernelModule, IBasePresenter, IKernel } from '../lib';
|
|
3
|
-
import BaseAction from './BaseAction';
|
|
2
|
+
import { ActionTypes, IBaseAction, IBaseCache, IBaseClient, IBaseKernelModule, IBasePresenter, IKernel } from '../lib/index.js';
|
|
3
|
+
import BaseAction from './BaseAction.js';
|
|
4
4
|
export default abstract class BaseApiAction<K extends IKernel = IKernel, T extends IDataBase<any, any> | null = any, P extends IBaseClient | null = any, C extends IBaseCache | null = any, E extends IBasePresenter | null = any> extends BaseAction<K, T, P, C, E> implements IBaseAction<K, T, P, C, E> {
|
|
5
5
|
exmod: undefined | IBaseKernelModule<K>;
|
|
6
6
|
type: ActionTypes;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const BaseAction_1 = __importDefault(require("./BaseAction"));
|
|
7
|
-
class BaseApiAction extends BaseAction_1.default {
|
|
1
|
+
import BaseAction from './BaseAction.js';
|
|
2
|
+
export default class BaseApiAction extends BaseAction {
|
|
8
3
|
constructor(type, chanel, module, extMod) {
|
|
9
4
|
super(chanel, module);
|
|
10
5
|
this.exmod = extMod;
|
|
@@ -46,4 +41,3 @@ class BaseApiAction extends BaseAction_1.default {
|
|
|
46
41
|
}
|
|
47
42
|
}
|
|
48
43
|
}
|
|
49
|
-
exports.default = BaseApiAction;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { XRequest } from '../lib/express';
|
|
3
|
-
export interface JwtToken extends JwtPayload {
|
|
1
|
+
import * as jwt from 'jsonwebtoken';
|
|
2
|
+
import { XRequest } from '../lib/express.js';
|
|
3
|
+
export interface JwtToken extends jwt.JwtPayload {
|
|
4
4
|
username: string;
|
|
5
5
|
userid: string;
|
|
6
6
|
}
|