@indra.ai/deva 1.6.10 → 1.6.11
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/index.js +1 -2
- package/lib/index.js +29 -15
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -43,7 +43,7 @@ class Deva {
|
|
|
43
43
|
this._systems = false; // inherited Systems features.
|
|
44
44
|
this._networks = false; // inherited Systems features.
|
|
45
45
|
this.events = opts.events || new EventEmitter({}); // Event Bus
|
|
46
|
-
this.lib = new lib({config}); // used for loading library functions
|
|
46
|
+
this.lib = new lib({config, agent:opts.agent}); // used for loading library functions
|
|
47
47
|
this.utils = opts.utils || {}; // parse function
|
|
48
48
|
this.devas = opts.devas || {}; // Devas which are loaded
|
|
49
49
|
this.vars = opts.vars || {}; // Variables object
|
|
@@ -911,7 +911,6 @@ class Deva {
|
|
|
911
911
|
// set client
|
|
912
912
|
this._active = Date.now();
|
|
913
913
|
const agent = this.agent();
|
|
914
|
-
|
|
915
914
|
const data = {
|
|
916
915
|
id: this.lib.uid(),
|
|
917
916
|
key: 'init',
|
package/lib/index.js
CHANGED
|
@@ -18,6 +18,7 @@ class Node {
|
|
|
18
18
|
class LIB {
|
|
19
19
|
constructor(opts) {
|
|
20
20
|
this.config = opts.config || {};
|
|
21
|
+
this.agent = opts.agent || {};
|
|
21
22
|
this.lang = opts.lang || 'en';
|
|
22
23
|
this.locale = opts.locale || 'en-US';
|
|
23
24
|
this.currency = opts.currency || 'USD';
|
|
@@ -27,7 +28,7 @@ class LIB {
|
|
|
27
28
|
this.exec = exec;
|
|
28
29
|
this.spawn = spawn;
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
+
|
|
31
32
|
help(msg, help_dir) {
|
|
32
33
|
return new Promise((resolve, reject) => {
|
|
33
34
|
const params = msg.split(' ');
|
|
@@ -58,15 +59,30 @@ class LIB {
|
|
|
58
59
|
copyright: 2025 Quinn A Michaels. All rights reserved.
|
|
59
60
|
***************/
|
|
60
61
|
uid(guid=false) {
|
|
61
|
-
const time = Date.now();
|
|
62
|
+
const time = Date.now(); // set time to local constant
|
|
63
|
+
const date = this.formatDate(time, 'long', true); // set date to local constant
|
|
64
|
+
const agent_hash = this.hash(this.agent, 'sha256');
|
|
65
|
+
const machine = {
|
|
66
|
+
arch: os.arch(),
|
|
67
|
+
hostname: os.hostname(),
|
|
68
|
+
network: os.networkInterfaces(),
|
|
69
|
+
platform: os.platform(),
|
|
70
|
+
release: os.release(),
|
|
71
|
+
type: os.type(),
|
|
72
|
+
user: os.userInfo(),
|
|
73
|
+
version: os.version(),
|
|
74
|
+
};
|
|
75
|
+
const machine_hash = this.hash(machine, 'sha256');
|
|
76
|
+
const data = {
|
|
77
|
+
uid: false,
|
|
78
|
+
time,
|
|
79
|
+
date,
|
|
80
|
+
agent: agent_hash,
|
|
81
|
+
machine: machine_hash,
|
|
82
|
+
}
|
|
62
83
|
if (guid) {
|
|
63
84
|
const uid = randomUUID(); // set uid into local constant.
|
|
64
|
-
|
|
65
|
-
const data = {uid,created}; // set base data object.
|
|
66
|
-
data.md5 = this.hash(data, 'md5'); // md5 the uid and created.
|
|
67
|
-
data.sha256 = this.hash(data, 'sha256'); // sha256 the uid, created, md5
|
|
68
|
-
data.sha512 = this.hash(data, 'sha512'); // sha512 the uid, created, md5, sha256.
|
|
69
|
-
return data; // return the data.
|
|
85
|
+
data.uid = uid; // set base data object.
|
|
70
86
|
}
|
|
71
87
|
else {
|
|
72
88
|
const min = Math.floor(time - (time / Math.PI)); // generate min time from Math.PI divisor.
|
|
@@ -76,14 +92,12 @@ class LIB {
|
|
|
76
92
|
const end_random = Math.ceil(Math.random() * (end_max - end_min) + end_min); // generate the 5 digit end salt on the number for added randomness.
|
|
77
93
|
|
|
78
94
|
const uid = `${begin_random}${end_random}`; // set uid to local constant
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const data = {uid,created}; // set base data object.
|
|
82
|
-
data.md5 = this.hash(data, 'md5'); // md5 the uid and created.
|
|
83
|
-
data.sha256 = this.hash(data, 'sha256'); // sha256 the uid, created, md5
|
|
84
|
-
data.sha512 = this.hash(data, 'sha512'); // sha512 the uid, created, md5, sha256.
|
|
85
|
-
return data; // return the complete uid data.
|
|
95
|
+
data.uid = uid; // set base data object.
|
|
86
96
|
}
|
|
97
|
+
data.md5 = this.hash(data, 'md5'); // md5 the uid and created.
|
|
98
|
+
data.sha256 = this.hash(data, 'sha256'); // sha256 the uid, created, md5
|
|
99
|
+
data.sha512 = this.hash(data, 'sha512'); // sha512 the uid, created, md5, sha256.
|
|
100
|
+
return data; // return the complete uid data.
|
|
87
101
|
}
|
|
88
102
|
|
|
89
103
|
/**************
|