@indra.ai/deva 1.6.50 → 1.6.52

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 (3) hide show
  1. package/index.js +12 -2
  2. package/lib/index.js +5 -7
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -872,12 +872,21 @@ class Deva {
872
872
  else {
873
873
  packet_answer.text = result;
874
874
  }
875
-
876
- packet_answer.md5 = this.lib.hash(packet_answer);
875
+
876
+ packet_answer.md5 = this.lib.hash(packet_answer 'md5');
877
877
  packet_answer.sha256 = this.lib.hash(packet_answer, 'sha256');
878
878
  packet_answer.sha512 = this.lib.hash(packet_answer, 'sha512');
879
879
 
880
+ packet.q.agent = agent;
880
881
  packet.a = packet_answer;
882
+
883
+ delete packet.md5;
884
+ delete packet.sha256;
885
+ delete packet.sha512;
886
+ packet.md5 = this.lib.hash(packet 'md5');
887
+ packet.sha256 = this.lib.hash(packet, 'sha256');
888
+ packet.sha512 = this.lib.hash(packet, 'sha512');
889
+
881
890
  this.talk(config.events.answer, this.lib.copy(packet)); // global talk event
882
891
  this.talk(`${agent.key}:ask:${packet.id.uid}`, packet);
883
892
  }).catch(err => {
@@ -1129,6 +1138,7 @@ class Deva {
1129
1138
  data.sha512 = this.lib.hash(data, 'sha512');
1130
1139
 
1131
1140
  this.lib.setClient(this.client());
1141
+ this.lib.setAgent(this.agent());
1132
1142
 
1133
1143
  this.state('ready', data.id.uid);
1134
1144
  this.talk(config.events.ready, data);
package/lib/index.js CHANGED
@@ -18,7 +18,7 @@ class Node {
18
18
  class LIB {
19
19
  constructor(opts) {
20
20
  this.pkg = opts.pkg || {};
21
- this.agent = opts.agent || false;
21
+ this.agent = false;
22
22
  this.client = false;
23
23
  this.lang = opts.lang || 'en';
24
24
  this.locale = opts.locale || 'US';
@@ -31,12 +31,10 @@ class LIB {
31
31
  }
32
32
 
33
33
  setClient(client) {
34
- if (this.client) return;
35
34
  this.client = client;
36
- this.agent.md5 = this.hash(this.agent, 'md5');
37
- this.agent.sha256 = this.hash(this.agent, 'sha256');
38
- this.agent.sha512 = this.hash(this.agent, 'sha512');
39
- console.log('agent hash', this.agent);
35
+ }
36
+ setAgent(agent) {
37
+ this.agent = agent;
40
38
  }
41
39
 
42
40
  help(msg, help_dir) {
@@ -122,7 +120,7 @@ class LIB {
122
120
  const {q, id} = packet;
123
121
 
124
122
  const {meta, agent, client, text} = q;
125
- const {invalid_agent,invalid_client} = this.agent._messages;
123
+ const {invalid_agent,invalid_client} = this.pkg.config.messages;
126
124
  const agent_hash = this.agent.sha256 === agent.sha256 ? this.agent.sha256 : invalid_agent;
127
125
  const client_hash = this.client === client.sha256 ? this.client : invalid_client;
128
126
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": 45958588982385560000,
3
3
  "name": "@indra.ai/deva",
4
- "version": "1.6.50",
4
+ "version": "1.6.52",
5
5
  "description": "The Deva Core",
6
6
  "main": "index.js",
7
7
  "license": "VLA:45958588982385558603 LICENSE.md",