nesoi 3.1.6 → 3.1.8
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/lib/compiler/apps/monolyth/stages/4_dump_modules_stage.js +8 -0
- package/lib/compiler/elements/element.d.ts +2 -1
- package/lib/compiler/elements/element.js +1 -0
- package/lib/compiler/elements/topic.element.d.ts +6 -0
- package/lib/compiler/elements/topic.element.js +24 -0
- package/lib/compiler/helpers/name_helpers.js +2 -1
- package/lib/compiler/module.d.ts +2 -1
- package/lib/compiler/module.js +7 -0
- package/lib/compiler/stages/7_dump_stage.js +3 -2
- package/lib/compiler/treeshake.d.ts +3 -0
- package/lib/compiler/treeshake.js +21 -0
- package/lib/compiler/typescript/typescript_compiler.js +1 -0
- package/lib/elements/blocks/block.schema.d.ts +1 -1
- package/lib/elements/blocks/topic/topic.builder.d.ts +36 -0
- package/lib/elements/blocks/topic/topic.builder.js +37 -0
- package/lib/elements/blocks/topic/topic.d.ts +20 -0
- package/lib/elements/blocks/topic/topic.js +44 -0
- package/lib/elements/blocks/topic/topic.schema.d.ts +17 -0
- package/lib/elements/blocks/topic/topic.schema.js +22 -0
- package/lib/elements/edge/controller/adapters/cli.controller_adapter.d.ts +4 -2
- package/lib/elements/edge/controller/adapters/cli.controller_adapter.js +5 -0
- package/lib/elements/edge/controller/adapters/controller_adapter.d.ts +2 -1
- package/lib/elements/edge/controller/adapters/controller_adapter.js +4 -0
- package/lib/elements/edge/controller/controller.builder.d.ts +23 -1
- package/lib/elements/edge/controller/controller.builder.js +51 -2
- package/lib/elements/edge/controller/controller.d.ts +14 -1
- package/lib/elements/edge/controller/controller.js +34 -1
- package/lib/elements/edge/controller/controller.schema.d.ts +16 -1
- package/lib/elements/edge/controller/controller.schema.js +19 -2
- package/lib/elements/entities/bucket/bucket.d.ts +2 -2
- package/lib/elements/entities/bucket/bucket.js +23 -15
- package/lib/elements/entities/bucket/model/bucket_model_field.builder.d.ts +1 -1
- package/lib/elements/entities/bucket/model/bucket_model_field.builder.js +1 -0
- package/lib/elements/index.d.ts +1 -0
- package/lib/elements/index.js +3 -1
- package/lib/engine/apps/inline.app.d.ts +5 -0
- package/lib/engine/apps/inline.app.js +16 -0
- package/lib/engine/daemon.js +1 -1
- package/lib/engine/data/error.d.ts +7 -2
- package/lib/engine/data/error.js +11 -3
- package/lib/engine/module.d.ts +7 -2
- package/lib/engine/module.js +20 -0
- package/lib/engine/space.d.ts +12 -0
- package/lib/engine/space.js +13 -0
- package/lib/engine/transaction/nodes/topic.trx_node.d.ts +17 -0
- package/lib/engine/transaction/nodes/topic.trx_node.js +50 -0
- package/lib/engine/transaction/trx_node.d.ts +3 -1
- package/lib/engine/transaction/trx_node.js +8 -0
- package/lib/engine/util/crypto.d.ts +4 -13
- package/lib/engine/util/crypto.js +26 -37
- package/lib/engine/util/log.d.ts +1 -1
- package/lib/engine/util/log.js +1 -0
- package/lib/schema.d.ts +5 -1
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -11,7 +11,8 @@ import { MachineTrxNode } from './nodes/machine.trx_node';
|
|
|
11
11
|
import { AnyUsers, AuthnRequest } from '../auth/authn';
|
|
12
12
|
import { Enum } from "../../elements/entities/constants/constants";
|
|
13
13
|
import { KeysOfUnion } from '../util/type';
|
|
14
|
-
|
|
14
|
+
import { TopicTrxNode } from './nodes/topic.trx_node';
|
|
15
|
+
type TrxNodeBlock = 'bucket' | 'message' | 'job' | 'resource' | 'machine' | 'queue' | 'topic' | 'controller';
|
|
15
16
|
export type TrxNodeStatus = {
|
|
16
17
|
id: string;
|
|
17
18
|
scope: 'root' | `${string}::${TrxNodeBlock}:${string}` | `${string}::virtual`;
|
|
@@ -58,6 +59,7 @@ export declare class TrxNode<Space extends $Space, M extends $Module, Authn exte
|
|
|
58
59
|
resource<Name extends keyof M['resources'], Resource extends M['resources'][Name]>(name: Name): ResourceTrxNode<M, Resource>;
|
|
59
60
|
machine<Name extends keyof M['machines'], Machine extends M['machines'][Name]>(name: Name): MachineTrxNode<M, Machine>;
|
|
60
61
|
queue<Name extends keyof M['queues'], Queue extends M['queues'][Name]>(name: Name): QueueTrxNode<M, Queue>;
|
|
62
|
+
topic<Name extends keyof M['topics'], topic extends M['topics'][Name]>(name: Name): TopicTrxNode<M, topic>;
|
|
61
63
|
authenticate(authnRequest: AuthnRequest<keyof Authn>): Promise<TrxNode<$Space, $Module, Authn>>;
|
|
62
64
|
token<U extends keyof Authn & keyof M['#authn']>(provider: U): string;
|
|
63
65
|
user<U extends keyof Authn & keyof M['#authn']>(provider: U): M['#authn'][U];
|
|
@@ -12,6 +12,7 @@ const machine_trx_node_1 = require("./nodes/machine.trx_node");
|
|
|
12
12
|
const constants_1 = require("../../elements/entities/constants/constants");
|
|
13
13
|
const i18n_1 = require("../util/i18n");
|
|
14
14
|
const datetime_1 = require("../data/datetime");
|
|
15
|
+
const topic_trx_node_1 = require("./nodes/topic.trx_node");
|
|
15
16
|
/*
|
|
16
17
|
Transaction Node
|
|
17
18
|
*/
|
|
@@ -129,6 +130,13 @@ class TrxNode {
|
|
|
129
130
|
}
|
|
130
131
|
return new queue_trx_node_1.QueueTrxNode(this, queue);
|
|
131
132
|
}
|
|
133
|
+
topic(name) {
|
|
134
|
+
const topic = this.module.topics[name];
|
|
135
|
+
if (!topic) {
|
|
136
|
+
throw error_1.NesoiError.Module.TopicNotIncluded(this.module, name);
|
|
137
|
+
}
|
|
138
|
+
return new topic_trx_node_1.TopicTrxNode(this, topic);
|
|
139
|
+
}
|
|
132
140
|
// Authentication
|
|
133
141
|
async authenticate(authnRequest) {
|
|
134
142
|
const newNode = new TrxNode(this.scope, this.trx, this, this.module, this.authn);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export declare class
|
|
2
|
-
static
|
|
3
|
-
algorithm: string;
|
|
1
|
+
export declare class NesoiCrypto {
|
|
2
|
+
static C: {
|
|
4
3
|
/**
|
|
5
4
|
* NIST recommends 96 bits or 12 bytes IV for GCM
|
|
6
5
|
* to promote interoperability, efficiency, and
|
|
@@ -17,14 +16,6 @@ export declare class Crypto {
|
|
|
17
16
|
* */
|
|
18
17
|
salt_bytes: number;
|
|
19
18
|
};
|
|
20
|
-
/**
|
|
21
|
-
* To prevent rainbow table attacks
|
|
22
|
-
* */
|
|
23
|
-
static getIV(): Buffer;
|
|
24
|
-
/**
|
|
25
|
-
* To prevent rainbow table attacks
|
|
26
|
-
* */
|
|
27
|
-
static getSalt(): Buffer;
|
|
28
19
|
/**
|
|
29
20
|
*
|
|
30
21
|
* @param {Buffer} password - The password to be used for generating key
|
|
@@ -36,7 +27,7 @@ export declare class Crypto {
|
|
|
36
27
|
* @param {string} payload - The clear text message to be encrypted
|
|
37
28
|
* @param {string} key - The key to be used for encryption
|
|
38
29
|
*/
|
|
39
|
-
static encrypt(value: any, key: string): string
|
|
30
|
+
static encrypt(value: any, key: string): Promise<string>;
|
|
40
31
|
/**
|
|
41
32
|
*
|
|
42
33
|
* @param {Buffer} ciphertext - Cipher text
|
|
@@ -46,5 +37,5 @@ export declare class Crypto {
|
|
|
46
37
|
* the Buffer after the decryption to prevent the message text
|
|
47
38
|
* and the key from lingering in the memory
|
|
48
39
|
*/
|
|
49
|
-
static decrypt(ciphertext: string, key: string): any
|
|
40
|
+
static decrypt(ciphertext: string, key: string): Promise<any>;
|
|
50
41
|
}
|
|
@@ -6,28 +6,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
6
6
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.NesoiCrypto = void 0;
|
|
10
10
|
const crypto_1 = __importDefault(require("crypto"));
|
|
11
|
-
class
|
|
12
|
-
/**
|
|
13
|
-
* To prevent rainbow table attacks
|
|
14
|
-
* */
|
|
15
|
-
static getIV() {
|
|
16
|
-
return crypto_1.default.randomBytes(this.DEFAULTS.iv_bytes);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* To prevent rainbow table attacks
|
|
20
|
-
* */
|
|
21
|
-
static getSalt() {
|
|
22
|
-
return crypto_1.default.randomBytes(this.DEFAULTS.salt_bytes);
|
|
23
|
-
}
|
|
11
|
+
class NesoiCrypto {
|
|
24
12
|
/**
|
|
25
13
|
*
|
|
26
14
|
* @param {Buffer} password - The password to be used for generating key
|
|
27
15
|
*
|
|
28
16
|
*/
|
|
29
17
|
static getKeyFromPassword(password, salt) {
|
|
30
|
-
const buffer = crypto_1.default.scryptSync(password, salt, this.
|
|
18
|
+
const buffer = crypto_1.default.scryptSync(password, salt, this.C.key_bytes);
|
|
31
19
|
const str = buffer.toString();
|
|
32
20
|
buffer.fill(0);
|
|
33
21
|
return str;
|
|
@@ -37,16 +25,15 @@ class Crypto {
|
|
|
37
25
|
* @param {string} payload - The clear text message to be encrypted
|
|
38
26
|
* @param {string} key - The key to be used for encryption
|
|
39
27
|
*/
|
|
40
|
-
static encrypt(value, key) {
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return str;
|
|
28
|
+
static async encrypt(value, key) {
|
|
29
|
+
const iv = crypto_1.default.randomBytes(this.C.iv_bytes);
|
|
30
|
+
const aes_key = await crypto_1.default.subtle.importKey('raw', Buffer.from(key), 'AES-GCM', true, ['encrypt', 'decrypt']);
|
|
31
|
+
const encrypted = await crypto_1.default.subtle.encrypt({
|
|
32
|
+
name: 'AES-GCM',
|
|
33
|
+
iv,
|
|
34
|
+
tagLength: 128,
|
|
35
|
+
}, aes_key, Buffer.from(JSON.stringify(value)));
|
|
36
|
+
return Buffer.concat([Buffer.from(iv), Buffer.from(encrypted)]).toString('base64');
|
|
50
37
|
}
|
|
51
38
|
/**
|
|
52
39
|
*
|
|
@@ -57,20 +44,22 @@ class Crypto {
|
|
|
57
44
|
* the Buffer after the decryption to prevent the message text
|
|
58
45
|
* and the key from lingering in the memory
|
|
59
46
|
*/
|
|
60
|
-
static decrypt(ciphertext, key) {
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
47
|
+
static async decrypt(ciphertext, key) {
|
|
48
|
+
const buffer = Uint8Array.from(Buffer.from(ciphertext, 'base64'));
|
|
49
|
+
const iv = buffer.slice(0, this.C.iv_bytes);
|
|
50
|
+
const payload = buffer.slice(this.C.iv_bytes);
|
|
51
|
+
const aes_key = await crypto_1.default.subtle.importKey('raw', Buffer.from(key), 'AES-GCM', true, ['encrypt', 'decrypt']);
|
|
52
|
+
const decrypted = await crypto_1.default.subtle.decrypt({
|
|
53
|
+
name: 'AES-GCM',
|
|
54
|
+
iv: Buffer.from(iv),
|
|
55
|
+
tagLength: 128
|
|
56
|
+
}, aes_key, Buffer.from(payload));
|
|
57
|
+
const decoded = Buffer.from(decrypted).toString('utf8');
|
|
58
|
+
return JSON.parse(decoded);
|
|
69
59
|
}
|
|
70
60
|
}
|
|
71
|
-
exports.
|
|
72
|
-
|
|
73
|
-
algorithm: 'aes-256',
|
|
61
|
+
exports.NesoiCrypto = NesoiCrypto;
|
|
62
|
+
NesoiCrypto.C = {
|
|
74
63
|
/**
|
|
75
64
|
* NIST recommends 96 bits or 12 bytes IV for GCM
|
|
76
65
|
* to promote interoperability, efficiency, and
|
package/lib/engine/util/log.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { $BlockType } from "../../elements/blocks/block.schema";
|
|
2
2
|
declare const LogLevel: readonly ["off", "error", "warn", "info", "debug", "trace"];
|
|
3
3
|
export type LogLevel = typeof LogLevel[number];
|
|
4
|
-
export type LogScope = $BlockType | 'compiler' | 'trx' | 'daemon' | 'app' | 'module' | 'layer' | 'message' | 'bucket' | 'job' | 'resource' | 'controller' | 'queue' | 'constants' | 'externals';
|
|
4
|
+
export type LogScope = $BlockType | 'compiler' | 'trx' | 'daemon' | 'app' | 'module' | 'layer' | 'message' | 'bucket' | 'job' | 'resource' | 'controller' | 'queue' | 'topic' | 'constants' | 'externals';
|
|
5
5
|
export declare function scopeTag(scope: LogScope, scope_id: string): string;
|
|
6
6
|
export declare function anyScopeTag(scopeWithId: string): string;
|
|
7
7
|
export declare class Log {
|
package/lib/engine/util/log.js
CHANGED
package/lib/schema.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ import { $Job } from './elements/blocks/job/job.schema';
|
|
|
8
8
|
import { $Resource } from './elements/blocks/resource/resource.schema';
|
|
9
9
|
import { $Queue } from './elements/blocks/queue/queue.schema';
|
|
10
10
|
import { $Externals } from './elements/edge/externals/externals.schema';
|
|
11
|
-
|
|
11
|
+
import { $Topic } from './elements/blocks/topic/topic.schema';
|
|
12
|
+
export type BuilderType = 'constants' | 'externals' | 'message' | 'bucket' | 'job' | 'resource' | 'machine' | 'controller' | 'queue' | 'topic';
|
|
12
13
|
export type $Space = {
|
|
13
14
|
authnUsers: {
|
|
14
15
|
[x: string]: User;
|
|
@@ -42,6 +43,9 @@ export type $Module = {
|
|
|
42
43
|
queues: {
|
|
43
44
|
[x: string]: $Queue;
|
|
44
45
|
};
|
|
46
|
+
topics: {
|
|
47
|
+
[x: string]: $Topic;
|
|
48
|
+
};
|
|
45
49
|
'#input': $Message;
|
|
46
50
|
'#authn': AnyUsers;
|
|
47
51
|
'#services': Record<string, any>;
|