@indra.ai/deva 1.6.19 β†’ 1.6.21

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 +3 -3
  2. package/lib/index.js +55 -0
  3. package/package.json +15 -12
package/index.js CHANGED
@@ -1889,7 +1889,7 @@ class Deva {
1889
1889
  describe: This function will enable fast loading of Deva into the system.
1890
1890
  ***************/
1891
1891
  load(key, client) {
1892
- this.zone('deva', key);
1892
+ this.zone('load', key);
1893
1893
  this.action('load', key);
1894
1894
  this.state('load', key);
1895
1895
  return this.devas[key].init(client);
@@ -1905,12 +1905,12 @@ class Deva {
1905
1905
  this.zone('unload', key);
1906
1906
  return new Promise((resolve, reject) => {
1907
1907
  try {
1908
- this.action('uload', key);
1908
+ this.action('unload', key);
1909
1909
  this.devas[key].stop().then(exit => {
1910
1910
  delete this.devas[key];
1911
1911
  this.talk(config.events.unload, key);
1912
1912
  });
1913
- this.state('unload', key)
1913
+ this.state('unload', key);
1914
1914
  return resolve(`${this._states.unload}:${key}`);
1915
1915
  } catch (e) {
1916
1916
  return this.err(e, this.devas[key], reject)
package/lib/index.js CHANGED
@@ -113,6 +113,61 @@ class LIB {
113
113
  return data; // return the complete uid data.
114
114
  }
115
115
 
116
+ sign(packet, concerns) {
117
+ const {q, id} = packet;
118
+
119
+ const {meta, agent, client, text} = q;
120
+ const agent_hash = this.hash(agent, 'sha256');
121
+ const client_hash = this.hash(client, 'sha256');
122
+
123
+ const {key, method, params} = meta;
124
+ const opts = this.lib.copy(params); // copy the params and set as opts.
125
+
126
+ const transport = id.uid; // set the transport id from the packet id.
127
+ const created = this.formatDate(time, 'long', true); // Formatted created date.
128
+ const expires = time + (client.expires || agent.expires || 10000); // signature expires in milliseconds
129
+ const command = opts.shift(); // extract the command first array item out of opts.
130
+ const container = `O:${key.toUpperCase()}:${transport}`; // set container string.
131
+ const {write} = client.profile; // set write string.
132
+ const packet_hash = this.hash(packet, 'sha256');
133
+ const laws_hash = this.hash(agent.laws || client.laws, 'sha256');
134
+ const token = this.hash(`${key} client:${client.profile.id} fullname:${client.profile.fullname} transport:${transport}`, 'sha256');
135
+
136
+ const data = {
137
+ id,
138
+ key,
139
+ method,
140
+ transport,
141
+ time,
142
+ expires,
143
+ container,
144
+ write,
145
+ message,
146
+ caseid: client.profile.caseid || false,
147
+ opts: opts.length? `.${opts.join('.')}` : '',
148
+ name: client.profile.name,
149
+ fullname: client.profile.fullname,
150
+ emojis: client.profile.emojis,
151
+ company: client.profile.company,
152
+ client: client_hash,
153
+ agent: agent_hash,
154
+ packet: packet_hash,
155
+ laws: laws_hash,
156
+ warning: client.warning || agent.warning || 'none',
157
+ token,
158
+ concerns,
159
+ meta,
160
+ params,
161
+ command,
162
+ created,
163
+ copyright: client.copyright || agent.copyright,
164
+ };
165
+ data.md5 = this.lib.hash(data, 'md5'); // hash data packet into md5 and inert into data.
166
+ data.sha256 = this.lib.hash(data, 'sha256'); // hash data into sha 256 then set in data.
167
+ data.sha512 = this.lib.hash(data, 'sha512'); // hash data into sha 512 then set in data.
168
+ return data;
169
+ }
170
+
116
171
  /**************
117
172
  func: hash
118
173
  params:
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": 55286864875635310000,
3
3
  "name": "@indra.ai/deva",
4
- "version": "1.6.19",
4
+ "version": "1.6.21",
5
5
  "description": "The Deva Core",
6
6
  "main": "index.js",
7
7
  "license": "VLA:15127963876514842820 LICENSE.md",
@@ -112,8 +112,8 @@
112
112
  "question": "πŸ™‹β€β™‚οΈ Question",
113
113
  "answer": "πŸ‘¨β€πŸ« Answer",
114
114
  "ask": "πŸ“£ Ask",
115
- "load": "πŸš› Load",
116
- "unload": "πŸ›» Unload",
115
+ "load": "πŸ“¦ Load",
116
+ "unload": "πŸ₯‘ Unload",
117
117
  "init": "🟠 Init",
118
118
  "start": "🟒 Start",
119
119
  "enter": "πŸšͺ Enter",
@@ -185,10 +185,8 @@
185
185
  "close": "πŸ“¦ Close",
186
186
  "begin": "πŸ—ΊοΈ Begin",
187
187
  "end": "🎬 End",
188
- "load": "🚚 Load",
189
- "unload": "πŸ›» Unload",
190
- "resolve": "🀝 Resolve",
191
- "reject": "🧱 Reject",
188
+ "load": "πŸ“¦ Load",
189
+ "unload": "πŸ₯‘ Unload",
192
190
  "create": "🎨 Create",
193
191
  "destroy": "πŸ’£ Destroy",
194
192
  "write": "πŸ“ Write",
@@ -222,10 +220,6 @@
222
220
  "try": "🏸 Try",
223
221
  "catch": "⚾️ Catch",
224
222
  "view": "πŸ‘“ View",
225
- "insert": "πŸ‘‰ Insert",
226
- "update": "πŸ‘† Update",
227
- "delete": "πŸ—‘οΈ Delete",
228
- "return": "🀿 Return",
229
223
  "hash": "#️⃣ Hash",
230
224
  "license": "πŸͺͺ License",
231
225
  "indra": "πŸ’« Indra",
@@ -309,7 +303,14 @@
309
303
  "done": "β˜‘οΈ Done",
310
304
  "ready": "⭐️ Ready",
311
305
  "complete": "βœ… Complete",
312
- "parse": "🐩 Parse"
306
+ "insert": "πŸ‘‰ Insert",
307
+ "update": "πŸ‘† Update",
308
+ "delete": "πŸ—‘οΈ Delete",
309
+ "return": "🀿 Return",
310
+ "parse": "🐩 Parse",
311
+ "resolve": "🀝 Resolve",
312
+ "reject": "🧱 Reject",
313
+ "sign": "✍️️ Sign"
313
314
  },
314
315
  "feature": false,
315
316
  "features": {
@@ -355,6 +356,8 @@
355
356
  "nopacket": "⛔️ NO PACKET PROVIDED",
356
357
  "method_not_found": "⛔️ METHOD NOT FOUND",
357
358
  "help_not_found": "⛔️ HELP NOT FOUND",
359
+ "load": "πŸ“¦ Load",
360
+ "unload": "πŸ₯‘ Unload",
358
361
  "uid_warning": "⚠️ Unlawful Use Constitutes Lawful Consent to Forfeit of All Wealth, Property, and Holdings to the Internal Revenue Service (IRS) for Lawful Taxation and Restiuttion to the Rightful Owner of the Machine of Origin."
359
362
  }
360
363
  }