@indra.ai/deva 1.6.53 → 1.6.55

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 CHANGED
@@ -42,11 +42,8 @@ class Deva {
42
42
  this._systems = false; // inherited Systems features.
43
43
  this._networks = false; // inherited Systems features.
44
44
  this.events = opts.events || new EventEmitter({}); // Event Bus
45
-
46
- const _lib = new lib({pkg, agent:opts.agent});
47
- this.lib = _lib; // used for loading library functions
48
-
49
- this.utils = opts.utils || {}; // parse function
45
+ this.lib = new lib({pkg}); // used for loading library functions
46
+ this.utils = opts.utils || {}; // parse functions inside the deva
50
47
  this.devas = opts.devas || {}; // Devas which are loaded
51
48
  this.vars = opts.vars || {}; // Variables object
52
49
  this.listeners = opts.listeners || {}; // local Listeners
@@ -187,7 +184,7 @@ class Deva {
187
184
  ***************/
188
185
  _methodNotFound(packet) {
189
186
  if (!this._active) return this._messages.offline; // check the active status
190
- const id = this.lib.uid();
187
+ const id = this.uid();
191
188
  const agent = this.agent() || false;
192
189
  const client = this.client() || false;
193
190
  const {meta, params} = packet.q;
@@ -279,7 +276,7 @@ class Deva {
279
276
  client presented data.
280
277
  ***************/
281
278
  Feature(feature, resolve, reject) {
282
- const _id = this.lib.uid();
279
+ const _id = this.uid();
283
280
  this.feature(feature, _id.uid);
284
281
  this.zone(feature, _id.uid);
285
282
  const _cl = this.client(); // set local copy of client data
@@ -655,11 +652,11 @@ class Deva {
655
652
  describe:
656
653
  ***************/
657
654
  question(TEXT=false, DATA=false) {
658
- const id = this.lib.uid(); // generate a unique id for transport.
655
+ const id = this.uid(); // generate a unique id for transport.
659
656
  // check the active status
660
657
  if (!this._active) return Promise.resolve(this._messages.offline);
661
- this.zone('question', id);
662
- this.action('question', id);
658
+ this.zone('question', id.uid);
659
+ this.action('question', id.uid);
663
660
  const t_split = TEXT.split(' '); // split the text on spaces to get words.
664
661
  const data = DATA; // set the DATA to data
665
662
 
@@ -685,7 +682,7 @@ class Deva {
685
682
  return new Promise((resolve, reject) => {
686
683
  // resolve with the no text message if the client says nothing.
687
684
  if (!TEXT) return resolve(this._messages.notext, resolve);
688
- this.state('try', `question:${id}`);
685
+ this.state('try', `question:${id.uid}`);
689
686
  try { // try to answer the question
690
687
  if (isAsk) { // determine if hte question isAsk
691
688
  // if:isAsk split the agent key and remove first command character
@@ -694,19 +691,19 @@ class Deva {
694
691
  params = t_split[1] ? t_split[1].split(':') : false;
695
692
  method = params[0]; // the method to check is then params index 0
696
693
  text = t_split.slice(2).join(' ').trim(); // rejoin the text with space
697
- this.state('ask', `${key}:${method}:${id}`);
694
+ this.state('ask', `${key}:${method}:${id.uid}`);
698
695
  }
699
696
  else if (isCmd) { // determine if the question is a command
700
697
  //if:isCmd use text split index 1 as the parameter block
701
698
  params = t_split[0] ? t_split[0].split(':') : false;
702
699
  method = t_split[0].split(':')[0].substring(1); // if:isCmd use the 0 index as the command
703
700
  text = t_split.slice(1).join(' ').trim(); // if:isCmd rejoin the string on the space after removing first index
704
- this.state('cmd', `${method}:${id}`); // set the state to cmd.
701
+ this.state('cmd', `${method}:${id.uid}`); // set the state to cmd.
705
702
  }
706
703
 
707
- this.state('set', `question:${method}:${id}`)
704
+ this.state('set', `question:${method}:${id.uid}`)
708
705
  packet.q = { // build packet.q container
709
- id: this.lib.uid(), // set the transport id for the question.
706
+ id: this.uid(), // set the transport id for the question.
710
707
  agent: this.agent(), // set the agent
711
708
  client: this.client(), // set the client
712
709
  meta: { // build the meta container
@@ -720,7 +717,7 @@ class Deva {
720
717
  }
721
718
 
722
719
  // hash the question
723
- packet.q.md5 = this.lib.hash(packet.q);
720
+ packet.q.md5 = this.lib.hash(packet.q, 'md5');
724
721
  packet.q.sha256 = this.lib.hash(packet.q, 'sha256');
725
722
  packet.q.sha512 = this.lib.hash(packet.q, 'sha512');
726
723
 
@@ -741,7 +738,7 @@ class Deva {
741
738
  }
742
739
  }
743
740
  catch(e) {
744
- this.state('catch', 'question');
741
+ this.state('catch', `${id.uid}`);
745
742
  return this.err(e); // if a overall error happens this witll call this.err
746
743
  }
747
744
  });
@@ -758,9 +755,9 @@ class Deva {
758
755
  from the agent from the pre-determined method.
759
756
  ***************/
760
757
  answer(packet, resolve, reject) {
761
- const id = this.lib.uid();
758
+ const id = this.uid();
762
759
  if (!this._active) return Promise.resolve(this._messages.offline);
763
- this.zone('answer', id); // set zone to answer
760
+ this.zone('answer', id.uid); // set zone to answer
764
761
  const agent = this.agent();
765
762
  const client = this.client();
766
763
  // check if method exists and is of type function
@@ -848,7 +845,7 @@ class Deva {
848
845
 
849
846
  this.state('set', `ask:${method}:packet_answer:${packet.id.uid}`);
850
847
  const packet_answer = {
851
- id: this.lib.uid(),
848
+ id: this.uid(),
852
849
  agent,
853
850
  client,
854
851
  meta: {
@@ -873,16 +870,19 @@ class Deva {
873
870
  packet_answer.text = result;
874
871
  }
875
872
 
876
- packet_answer.md5 = this.lib.hash(packet_answer, 'md5');
877
- packet_answer.sha256 = this.lib.hash(packet_answer, 'sha256');
878
- packet_answer.sha512 = this.lib.hash(packet_answer, 'sha512');
873
+ packet_answer.md5 = this.lib.hash(packet_answer, 'md5'); // md5 the answer.
874
+ packet_answer.sha256 = this.lib.hash(packet_answer, 'sha256'); // sha256 the answer.
875
+ packet_answer.sha512 = this.lib.hash(packet_answer, 'sha512'); // sha512 the answer
879
876
 
880
- packet.q.agent = agent;
881
- packet.a = packet_answer;
877
+ packet.q.agent = agent; // set the question agent as the ask agent.
878
+ packet.a = packet_answer; // set the packet answer.
882
879
 
880
+ // delete previous hashes before creating new ones.
883
881
  delete packet.md5;
884
882
  delete packet.sha256;
885
883
  delete packet.sha512;
884
+
885
+ // create new hashes for the packet before return.
886
886
  packet.md5 = this.lib.hash(packet, 'md5');
887
887
  packet.sha256 = this.lib.hash(packet, 'sha256');
888
888
  packet.sha512 = this.lib.hash(packet, 'sha512');
@@ -926,7 +926,7 @@ class Deva {
926
926
  const agent = this.agent();
927
927
 
928
928
  const data = {
929
- id: this.lib.uid(),
929
+ id: this.uid(),
930
930
  key: 'init',
931
931
  value: agent.key,
932
932
  agent,
@@ -1026,7 +1026,7 @@ class Deva {
1026
1026
  if (!this._active) return resolve(this._messages.offline);
1027
1027
 
1028
1028
  this.action('start', data.id.uid);
1029
- const id = this.lib.uid();
1029
+ const id = this.uid();
1030
1030
 
1031
1031
  delete data.md5;
1032
1032
  delete data.sha256;
@@ -1137,9 +1137,6 @@ class Deva {
1137
1137
  data.sha256 = this.lib.hash(data, 'sha256');
1138
1138
  data.sha512 = this.lib.hash(data, 'sha512');
1139
1139
 
1140
- this.lib.setClient(this.client());
1141
- this.lib.setAgent(this.agent());
1142
-
1143
1140
  this.state('ready', data.id.uid);
1144
1141
  this.talk(config.events.ready, data);
1145
1142
  return hasOnReady ? this.onReady(data, resolve) : resolve(data);
@@ -1219,7 +1216,7 @@ class Deva {
1219
1216
  this.stop()
1220
1217
  ***************/
1221
1218
  stop() {
1222
- const id = this.lib.uid();
1219
+ const id = this.uid();
1223
1220
  this.zone('stop', id);
1224
1221
  if (!this._active) return Promise.resolve(this._messages.offline);
1225
1222
 
@@ -1257,7 +1254,7 @@ class Deva {
1257
1254
  function.
1258
1255
  ***************/
1259
1256
  exit() {
1260
- const id = this.lib.uid();
1257
+ const id = this.uid();
1261
1258
  this.zone('exit', id);
1262
1259
  if (!this._active) return Promise.resolve(this._messages.offline);
1263
1260
 
@@ -1318,7 +1315,7 @@ class Deva {
1318
1315
  const lookup = this._states[value]; // set the local states lookup
1319
1316
  const text = extra ? `${lookup} ${extra}` : lookup; // set text from lookup with extra
1320
1317
  const data = { // build the data object
1321
- id: this.lib.uid(), // set the data id
1318
+ id: this.uid(), // set the data id
1322
1319
  agent: this.agent(), // set the agent
1323
1320
  client: this.client(), // set the client
1324
1321
  key: 'state', // set the key to state
@@ -1344,7 +1341,7 @@ class Deva {
1344
1341
  describe: returns the avaiable staets values.
1345
1342
  ***************/
1346
1343
  states() {
1347
- const id = this.lib.uid();
1344
+ const id = this.uid();
1348
1345
  this.action('states', id);
1349
1346
  const data = {
1350
1347
  id,
@@ -1368,7 +1365,7 @@ class Deva {
1368
1365
  describe
1369
1366
  ***************/
1370
1367
  zone(value=false, extra=false) {
1371
- const id = this.lib.uid();
1368
+ const id = this.uid();
1372
1369
  if (!value || !this._zones[value] || value === this._zone) return;
1373
1370
 
1374
1371
  try {
@@ -1404,7 +1401,7 @@ class Deva {
1404
1401
  describe: returns a listing of zones currently in the system.
1405
1402
  ***************/
1406
1403
  zones() {
1407
- const id = this.lib.uid();
1404
+ const id = this.uid();
1408
1405
  this.action('zones', id.uid);
1409
1406
  this.state('return', `zones:${id.uid}`);
1410
1407
 
@@ -1432,7 +1429,7 @@ class Deva {
1432
1429
  describe
1433
1430
  ***************/
1434
1431
  action(value=false, extra=false) {
1435
- const id = this.lib.uid();
1432
+ const id = this.uid();
1436
1433
  try {
1437
1434
  if (!value || !this._actions[value] || value === this._action) return;
1438
1435
  this._action = value; // set the local action variable
@@ -1471,7 +1468,7 @@ class Deva {
1471
1468
  describe: Returns a list of available actions in the system.
1472
1469
  ***************/
1473
1470
  actions() {
1474
- const id = this.lib.uid();
1471
+ const id = this.uid();
1475
1472
  this.action('actions', id.uid);
1476
1473
  const data = {
1477
1474
  id, // set the id with a uuid
@@ -1498,7 +1495,7 @@ class Deva {
1498
1495
  describe
1499
1496
  ***************/
1500
1497
  feature(value=false, extra=false) {
1501
- const id = this.lib.uid();
1498
+ const id = this.uid();
1502
1499
  try {
1503
1500
  if (!value || !this._features[value]) return; // check feature value
1504
1501
 
@@ -1533,7 +1530,7 @@ class Deva {
1533
1530
  ***************/
1534
1531
  features() {
1535
1532
  if (!this._active) return this._messages.offline; // check the active status
1536
- const id = this.lib.uid();
1533
+ const id = this.uid();
1537
1534
  this.action('features', id.uid);
1538
1535
  const data = {
1539
1536
  id, // set the object id
@@ -1561,7 +1558,7 @@ class Deva {
1561
1558
  ***************/
1562
1559
  context(value=false, extra=false) {
1563
1560
  if (!this._active) return this._messages.offline; // check the active status
1564
- const id = this.lib.uid();
1561
+ const id = this.uid();
1565
1562
  try {
1566
1563
  if (!value) return;
1567
1564
  this._context = value;
@@ -1592,7 +1589,7 @@ class Deva {
1592
1589
 
1593
1590
  contexts() {
1594
1591
  if (!this._active) return this._messages.offline; // check the active status
1595
- const id = this.lib.uid();
1592
+ const id = this.uid();
1596
1593
  this.action('contexts', id);
1597
1594
  if (!this._active) return this._messages.offline; // check the active status
1598
1595
  const data = {
@@ -1934,7 +1931,7 @@ class Deva {
1934
1931
  ***************/
1935
1932
  prompt(text) {
1936
1933
  if (!this._active) return this._messages.offline;
1937
- const id = this.lib.uid();
1934
+ const id = this.uid();
1938
1935
  // Talk a global prompt event for the client
1939
1936
  const agent = this.agent();
1940
1937
  const client = this.client();
@@ -1963,7 +1960,7 @@ class Deva {
1963
1960
  ***************/
1964
1961
  core() {
1965
1962
  if (!this._active) return this._messages.offline;
1966
- const id = this.lib.uid();
1963
+ const id = this.uid();
1967
1964
  this.action('core', id);
1968
1965
 
1969
1966
  // check the active status
@@ -1986,7 +1983,7 @@ class Deva {
1986
1983
  ***************/
1987
1984
  info() {
1988
1985
  if (!this._active) return this._messages.offline;
1989
- const id = this.lib.uid();
1986
+ const id = this.uid();
1990
1987
  this.action('info', id);
1991
1988
 
1992
1989
  const data = this.lib.copy(this._info);
@@ -2014,7 +2011,7 @@ class Deva {
2014
2011
  ***************/
2015
2012
  status() {
2016
2013
  if (!this._active) return this._messages.offline;
2017
- const id = this.lib.uid();
2014
+ const id = this.uid();
2018
2015
  this.action('status', id);
2019
2016
  // check the active status
2020
2017
 
@@ -2038,7 +2035,7 @@ class Deva {
2038
2035
  help(msg, help_dir) {
2039
2036
  return new Promise((resolve, reject) => {
2040
2037
  let helpDoc = false;
2041
- const id = this.lib.uid();
2038
+ const id = this.uid();
2042
2039
  this.zone('help', id);
2043
2040
  if (!this._active) return resolve(this._messages.offline);
2044
2041
 
@@ -2097,7 +2094,7 @@ class Deva {
2097
2094
  usage: this.err(err, data, reject);
2098
2095
  ***************/
2099
2096
  err(err,packet,reject=false) {
2100
- const id = this.lib.uid();
2097
+ const id = this.uid();
2101
2098
  this.zone('error', id.uid);
2102
2099
  this.feature('error', id.uid);
2103
2100
 
@@ -2132,6 +2129,116 @@ class Deva {
2132
2129
  this.context('error', id.uid);
2133
2130
  if (hasOnError) return this.onError(err, packet, reject);
2134
2131
  else return reject ? reject(err) : Promise.reject(err);
2132
+ }
2133
+
2134
+ /**************
2135
+ func: uid
2136
+ params:
2137
+ - guid: This is a true false flag for generating a guid.
2138
+ describe:
2139
+ The uid function can create two types of id for you.
2140
+ 1. random GUID - this is good for when you need a uinique record id returned
2141
+ 2. transport uid - The transport id is a number generated to provide a
2142
+ secure numerical number used for transporting records
2143
+ across networks without collision or needing to store system uuid.
2144
+ 3. the uid is then returned with a created, md5, sha256, and sha512 hash of the value
2145
+ copyright: 2025 Quinn A Michaels. All rights reserved.
2146
+ ***************/
2147
+ uid(guid=false) {
2148
+ const time = Date.now(); // set time to local constant
2149
+ const date = this.lib.formatDate(time, 'long', true); // set date to local constant
2150
+
2151
+ const pkg_hash = this.lib.hash(pkg, 'sha256');
2152
+ const client_hash = this.client().sha256 || false;
2153
+ const agent_hash = this.agent().sha256 || false;
2154
+ const machine_hash = this.lib.machine();
2155
+
2156
+ const data = {
2157
+ uid: false,
2158
+ time,
2159
+ date,
2160
+ client: client_hash,
2161
+ agent: agent_hash,
2162
+ pkg: pkg_hash,
2163
+ machine: machine_hash,
2164
+ warning: config.messages.uid_warning,
2165
+ }
2166
+ if (guid) {
2167
+ const uid = randomUUID(); // set uid into local constant.
2168
+ data.uid = uid; // set base data object.
2169
+ }
2170
+ else {
2171
+ const min = Math.floor(time - (time / Math.PI)); // generate min time from Math.PI divisor.
2172
+ const max = Math.ceil(time + (time * Math.PI)); // generate max time form Math.PI multiplier.
2173
+ const begin_random = Math.floor(Math.random() * (max - min) + min); // generate random number between min and max.
2174
+ const {end_min, end_max} = config.uid; // set end min and max in to constant
2175
+ 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.
2176
+
2177
+ const uid = `${begin_random}${end_random}`; // set uid to local constant
2178
+ data.uid = uid; // set base data object.
2179
+ }
2180
+ data.md5 = this.lib.hash(data, 'md5'); // md5 the uid and created.
2181
+ data.sha256 = this.lib.hash(data, 'sha256'); // sha256 the uid, created, md5
2182
+ data.sha512 = this.lib.hash(data, 'sha512'); // sha512 the uid, created, md5, sha256.
2183
+ return data; // return the complete uid data.
2135
2184
  }
2185
+
2186
+ sign(packet) {
2187
+ const time = Date.now();
2188
+ const client = this.client();
2189
+ const agent = this.agent();
2190
+ const {q, id} = packet;
2191
+ const transport = id.uid; // set the transport id from the packet id.
2192
+
2193
+ const {meta, text} = q;
2194
+ const {key, method, params} = meta;
2195
+ const opts = this.lib.copy(params); // copy the params and set as opts.
2196
+
2197
+ const {invalid_agent,invalid_client} = config.messages;
2198
+
2199
+ const agent_hash = agent.sha256 === packet.q.agent.sha256 ? agent.sha256 : invalid_agent;
2200
+ const client_hash = client.sha256 === packet.q.client.sha256 ? client.sha256 : invalid_client;
2201
+
2202
+ const created = this.lib.formatDate(time, 'long', true); // Formatted created date.
2203
+
2204
+ const container = `OM:O:${key.toUpperCase()}:${transport}`; // set container string.
2205
+ const {write} = client.profile; // set write string.
2206
+
2207
+ const token = this.lib.hash(`${key} client:${client.profile.id} fullname:${client.profile.fullname} transport:${transport}`, 'sha256');
2208
+
2209
+ // build the main data packet.
2210
+ const data = {
2211
+ id,
2212
+ text,
2213
+ time,
2214
+ container,
2215
+ write,
2216
+ cient: {
2217
+ key: client.key,
2218
+ name: client.profile.name,
2219
+ fullname: client.profile.fullname,
2220
+ emojis: client.profile.emojis,
2221
+ company: client.profile.company,
2222
+ expires: client.expires ? time + client.expires : 'none',
2223
+ caseid: client.profile.caseid || 'none',
2224
+ token,
2225
+ sha256: client.sha256,
2226
+ },
2227
+ agent: {
2228
+ key: agent.key,
2229
+ name: agent.profile.name,
2230
+ sha256: agent.sha256,
2231
+ },
2232
+ created,
2233
+ warning: client.warning || agent.warning || 'none',
2234
+ copyright: client.profile.copyright || agent.profile.copyright,
2235
+ };
2236
+ data.md5 = this.lib.hash(data, 'md5'); // hash data packet into md5 and inert into data.
2237
+ data.sha256 = this.lib.hash(data, 'sha256'); // hash data into sha 256 then set in data.
2238
+ data.sha512 = this.lib.hash(data, 'sha512'); // hash data into sha 512 then set in data.
2239
+ console.log('sign data', data);
2240
+ return data;
2241
+ }
2242
+
2136
2243
  }
2137
2244
  export default Deva;
package/lib/index.js CHANGED
@@ -18,23 +18,15 @@ class Node {
18
18
  class LIB {
19
19
  constructor(opts) {
20
20
  this.pkg = opts.pkg || {};
21
- this.agent = false;
22
- this.client = false;
23
21
  this.lang = opts.lang || 'en';
24
- this.locale = opts.locale || 'US';
22
+ this.locale = opts.locale || 'en-US';
25
23
  this.currency = opts.currency || 'USD';
26
24
  this.os = os;
27
25
  this.fs = fs;
28
26
  this.path = path;
29
27
  this.exec = exec;
30
28
  this.spawn = spawn;
31
- }
32
-
33
- setClient(client) {
34
- this.client = client;
35
- }
36
- setAgent(agent) {
37
- this.agent = agent;
29
+ this.randomUUID = randomUUID;
38
30
  }
39
31
 
40
32
  help(msg, help_dir) {
@@ -53,127 +45,7 @@ class LIB {
53
45
  }
54
46
 
55
47
 
56
- /**************
57
- func: uid
58
- params:
59
- - guid: This is a true false flag for generating a guid.
60
- describe:
61
- The uid function can create two types of id for you.
62
- 1. random GUID - this is good for when you need a uinique record id returned
63
- 2. transport uid - The transport id is a number generated to provide a
64
- secure numerical number used for transporting records
65
- across networks without collision or needing to store system uuid.
66
- 3. the uid is then returned with a created, md5, sha256, and sha512 hash of the value
67
- copyright: 2025 Quinn A Michaels. All rights reserved.
68
- ***************/
69
- uid(guid=false) {
70
- const time = Date.now(); // set time to local constant
71
- const date = this.formatDate(time, 'long', true); // set date to local constant
72
- const machine = {
73
- arch: os.arch(),
74
- hostname: os.hostname(),
75
- network: os.networkInterfaces(),
76
- platform: os.platform(),
77
- release: os.release(),
78
- type: os.type(),
79
- user: os.userInfo(),
80
- version: os.version(),
81
- uptime: os.uptime(),
82
- cpus: os.cpus(),
83
- };
84
48
 
85
- const machine_hash = this.hash(machine, 'sha256');
86
- const pkg_hash = this.hash(this.pkg, 'sha256');
87
-
88
- const data = {
89
- uid: false,
90
- time,
91
- date,
92
- client: this.client,
93
- agent: this.agent,
94
- pkg: pkg_hash,
95
- machine: machine_hash,
96
- warning: this.pkg.config.messages.uid_warning,
97
- }
98
- if (guid) {
99
- const uid = randomUUID(); // set uid into local constant.
100
- data.uid = uid; // set base data object.
101
- }
102
- else {
103
- const min = Math.floor(time - (time / Math.PI)); // generate min time from Math.PI divisor.
104
- const max = Math.ceil(time + (time * Math.PI)); // generate max time form Math.PI multiplier.
105
- const begin_random = Math.floor(Math.random() * (max - min) + min); // generate random number between min and max.
106
- const {end_min, end_max} = this.pkg.config.uid; // set end min and max in to constant
107
- 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.
108
-
109
- const uid = `${begin_random}${end_random}`; // set uid to local constant
110
- data.uid = uid; // set base data object.
111
- }
112
- data.md5 = this.hash(data, 'md5'); // md5 the uid and created.
113
- data.sha256 = this.hash(data, 'sha256'); // sha256 the uid, created, md5
114
- data.sha512 = this.hash(data, 'sha512'); // sha512 the uid, created, md5, sha256.
115
- return data; // return the complete uid data.
116
- }
117
-
118
- sign(packet, concerns) {
119
- const time = Date.now();
120
- const {q, id} = packet;
121
-
122
- const {meta, agent, client, text} = q;
123
- const {invalid_agent,invalid_client} = this.pkg.config.messages;
124
- const agent_hash = this.agent.sha256 === agent.sha256 ? this.agent.sha256 : invalid_agent;
125
- const client_hash = this.client === client.sha256 ? this.client : invalid_client;
126
-
127
- const {key, method, params} = meta;
128
- const opts = this.copy(params); // copy the params and set as opts.
129
-
130
- const transport = id.uid; // set the transport id from the packet id.
131
- const created = this.formatDate(time, 'long', true); // Formatted created date.
132
-
133
- const expr = client.expires || agent.expires || false;
134
- const expires = expr ? time + expr : expr; // signature expires in milliseconds
135
- const command = opts.shift(); // extract the command first array item out of opts.
136
- const container = `OM:O:${key.toUpperCase()}:${transport}`; // set container string.
137
- const {write} = client.profile; // set write string.
138
- const packet_hash = this.hash(packet, 'sha256');
139
- const laws_hash = this.hash(agent.laws || client.laws, 'sha256');
140
- const token = this.hash(`${key} client:${client.profile.id} fullname:${client.profile.fullname} transport:${transport}`, 'sha256');
141
-
142
- // build the main data packet.
143
- const data = {
144
- id,
145
- key,
146
- method,
147
- transport,
148
- time,
149
- expires,
150
- container,
151
- write,
152
- text,
153
- caseid: client.profile.caseid || false,
154
- opts: opts.length? `.${opts.join('.')}` : '',
155
- name: client.profile.name,
156
- fullname: client.profile.fullname,
157
- emojis: client.profile.emojis,
158
- company: client.profile.company,
159
- client: client_hash,
160
- agent: agent_hash,
161
- packet: packet_hash,
162
- laws: laws_hash,
163
- warning: client.warning || agent.warning || 'none',
164
- token,
165
- concerns,
166
- meta,
167
- params,
168
- command,
169
- created,
170
- copyright: client.profile.copyright || agent.profile.copyright,
171
- };
172
- data.md5 = this.hash(data, 'md5'); // hash data packet into md5 and inert into data.
173
- data.sha256 = this.hash(data, 'sha256'); // hash data into sha 256 then set in data.
174
- data.sha512 = this.hash(data, 'sha512'); // hash data into sha 512 then set in data.
175
- return data;
176
- }
177
49
 
178
50
  /**************
179
51
  func: hash
@@ -368,5 +240,23 @@ class LIB {
368
240
  }
369
241
  });
370
242
  }
243
+
244
+ // machine returns the sha256 machine fingerprint
245
+ machine() {
246
+ const machine = {
247
+ arch: os.arch(),
248
+ hostname: os.hostname(),
249
+ network: os.networkInterfaces(),
250
+ platform: os.platform(),
251
+ release: os.release(),
252
+ type: os.type(),
253
+ user: os.userInfo(),
254
+ version: os.version(),
255
+ uptime: os.uptime(),
256
+ cpus: os.cpus(),
257
+ };
258
+ const machine_hash = this.hash(machine, 'sha256');
259
+ return machine_hash;
260
+ }
371
261
  };
372
262
  export default LIB
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": 45958588982385560000,
3
3
  "name": "@indra.ai/deva",
4
- "version": "1.6.53",
4
+ "version": "1.6.55",
5
5
  "description": "The Deva Core",
6
6
  "main": "index.js",
7
7
  "license": "VLA:45958588982385558603 LICENSE.md",
package/tests/client.json CHANGED
@@ -24,7 +24,9 @@
24
24
  },
25
25
  "profile": {
26
26
  "name": "Test User",
27
+ "fullname": "Test User Client Profile",
27
28
  "eamil": "test@example.com",
29
+ "company": "Inside The Net, Inc.",
28
30
  "describe": "The Test User",
29
31
  "emoji": "/public/devas/test/avatar.png",
30
32
  "avatar": "/public/devas/test/avatar.png",
@@ -32,7 +34,8 @@
32
34
  "gender": "splendid",
33
35
  "lang": "en",
34
36
  "locale": "en-US",
35
- "currency": "USD"
37
+ "currency": "USD",
38
+ "copyright": "©2025 Quinn A Michaels; All rights reserved."
36
39
  },
37
40
  "features": {
38
41
  "license": {
package/tests/index.js CHANGED
@@ -109,14 +109,42 @@ const DevaTest = new Deva({
109
109
  const text = this._state
110
110
  const core = this.core();
111
111
  const info = this.info();
112
+ const uid = this.uid();
113
+
114
+ const sign_packet = {
115
+ id: this.uid(),
116
+ created: Date.now(),
117
+ q: {
118
+ id: this.uid(),
119
+ client: this.client(),
120
+ agent: this.agent(),
121
+ meta: {
122
+ key: 'test',
123
+ method: 'sign',
124
+ params: ['/sign', 'test'],
125
+ },
126
+ text: `Test text`,
127
+ data: false,
128
+ md5: packet.md5,
129
+ sha256: packet.sha256,
130
+ sha512: packet.sha512,
131
+ }
132
+ };
133
+ const sign = this.sign(sign_packet);
112
134
  const data = [
113
135
  '🧪 TEST RESULTS',
136
+ `::BEGIN:UID:${info.id.uid}`,
137
+ JSON.stringify(uid,null,2),
138
+ `::END:UID:${info.id.uid}`,
114
139
  `::BEGIN:CORE:${core.id.uid}`,
115
140
  JSON.stringify(core,null,2),
116
141
  `::END:CORE:${core.id.uid}`,
117
142
  `::BEGIN:INFO:${info.id.uid}`,
118
143
  JSON.stringify(info,null,2),
119
- `::END:INFO:${info.id.uid}`,
144
+ `::END:INFO:${info.id.uid}`,
145
+ `::BEGIN:SIGN:${info.id.uid}`,
146
+ JSON.stringify(sign,null,2),
147
+ `::END:SIGN:${info.id.uid}`,
120
148
  ];
121
149
  return {
122
150
  text: data.join('\n'),
@@ -127,8 +155,9 @@ const DevaTest = new Deva({
127
155
  methods: {
128
156
  test(packet) {
129
157
  this.context('test');
130
- return this.func.test(packet);
131
- }
158
+ const test = this.func.test(packet)
159
+ return test;
160
+ },
132
161
  },
133
162
  onStart(data, resolve) {
134
163
  this.context('start', data.id.uid);