@indra.ai/deva.security 0.21.3 → 0.22.0

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 (2) hide show
  1. package/feature/methods.js +55 -51
  2. package/package.json +1 -1
@@ -44,8 +44,8 @@ export default {
44
44
  `${this.box.begin}:${status}`,
45
45
  `uid: ${id.uid}`,
46
46
  `time: ${id.time}`,
47
- `iso: ${id.iso}`,
48
47
  `utc: ${id.utc}`,
48
+ `iso: ${id.iso}`,
49
49
  `date: ${id.date}`,
50
50
  `warning: ${id.warning}`,
51
51
  `tags: ${id.tags}`,
@@ -91,7 +91,7 @@ export default {
91
91
  const text = [
92
92
  `write: #${data.key}.${data.method}.${data.opts} ${data.text}`,
93
93
  '\n',
94
- `${this.box.begin}${data.method}:${data.id.uid}`,
94
+ `${this.box.begin}:${data.method}:${data.id.uid}`,
95
95
  `sign: ${data.client.fullname} ${data.client.emojis}`,
96
96
  `uid: ${data.id.uid}`,
97
97
  `time: ${data.time}`,
@@ -130,56 +130,66 @@ export default {
130
130
  params: packet
131
131
  describe: Return system md5, sha256, sha512 hash from value.
132
132
  ***************/
133
- async hash(packet) {
133
+ async hash(packet) {
134
134
  const id = this.uid();
135
135
  const {q} = packet;
136
136
  this.feature('security', `hash:${id.uid}`);
137
- const {global, personal} = this.security();
138
- const agent = this.agent()
139
- const client = this.client();
140
-
137
+ this.belief('security', `hash:${id.uid}`)
141
138
  this.zone('security', `hash:${id.uid}`);
142
139
  this.action('method', `hash:${id.uid}`);
143
140
 
144
- const {params} = q.meta; // set params from the meta information.
145
-
146
- this.state('set', `hash:algo:${id.uid}`); //set the meta state for the proxy
147
- const algo = params[1] || personal.hash || global.hash
148
-
149
- this.state('set', `hash:${id.uid}`); //set the meta state for the proxy
150
- const hash = this.hash(q.text, algo);
151
-
152
- const data = {
153
- id,
154
- algo,
155
- text: q.text,
156
- hash,
157
- };
158
-
159
- const status = `${agent.key}:hash:${data.id.uid}`;
160
-
161
- const text = [
162
- `${this.box.begin}:${status}`,
163
- `uid: ${data.id.uid}`,
164
- `algo: ${data.algo}`,
165
- `text: ${data.text}`,
166
- `hash: ${data.hash}`,
167
- `time: ${data.id.time}`,
168
- `date: ${data.id.date}`,
169
- `warning: ${data.id.warning}`,
170
- `license: ${data.id.license}`,
171
- `copyright: ${data.id.copyright}`,
172
- `${this.box.end}:${status}`,
173
- ].join('\n');
141
+ return new Promise((resolve, reject) => {
142
+ const {global, personal} = this.security();
174
143
 
175
- this.action('return', `hash:${data.id.uid}`);
176
- this.state('valid', `hash:${data.id.uid}`);
177
- this.intent('good', `hash:${data.id.uid}`);
178
- return {
179
- text,
180
- html: false,
181
- data,
182
- };
144
+ const agent = this.agent()
145
+ const client = this.client();
146
+
147
+ const {params} = q.meta; // set params from the meta information.
148
+
149
+ this.state('set', `hash:${id.uid}`); //set the meta state for the proxy
150
+ const algo = params[1] || personal.hash || global.hash
151
+
152
+ this.state('set', `hash:${id.uid}`); //set the meta state for the proxy
153
+ const hash = this.hash(q.text, algo);
154
+
155
+ const data = {
156
+ id,
157
+ algo,
158
+ text: q.text,
159
+ hash,
160
+ };
161
+
162
+ const status = `${agent.key}:hash:${data.id.uid}`;
163
+
164
+ const text = [
165
+ `${this.box.begin}:${status}`,
166
+ `uid: ${data.id.uid}`,
167
+ `time: ${data.id.time}`,
168
+ `utc: ${data.id.utc}`,
169
+ `iso: ${data.id.iso}`,
170
+ `date: ${data.id.date}`,
171
+ `text: ${data.text}`,
172
+ `${data.algo}: ${data.hash}`,
173
+ `license: ${data.id.license}`,
174
+ // `warning: ${data.id.warning}`,
175
+ `copyright: ${data.id.copyright}`,
176
+ `${this.box.end}:${status}`,
177
+ ].join('\n');
178
+
179
+ this.question(`${this.askChr}feecting parse ${text}`, {vars:this.vars}).then(parsed => {
180
+ this.belief('vedic', `hash:${id.uid}`);
181
+ this.state('valid', `hash:${id.uid}`);
182
+ this.action('resolve', `hash:${id.uid}`);
183
+ this.intent('good', `hash:${id.uid}`);
184
+ return resolve({
185
+ text: parsed.a.text,
186
+ html: parsed.a.html,
187
+ data,
188
+ });
189
+ }).catch(err => {
190
+ return this.err(err, packet, reject);
191
+ });
192
+ });
183
193
  },
184
194
 
185
195
  /**************
@@ -332,12 +342,8 @@ export default {
332
342
  date,
333
343
  }
334
344
 
335
- this.action('hash', `date:data:md5:${id.uid}`); // set action hash
336
- data.md5 = this.hash(date, 'md5');
337
345
  this.action('hash', `date:data:sha256:${id.uid}`); // set action hash
338
346
  data.sha256 = this.hash(date, 'sha256');
339
- this.action('hash', `date:data:sha512:${id.uid}`); // set action hash
340
- data.sha512 = this.hash(date, 'sha512');
341
347
 
342
348
  const text = [
343
349
  `${this.box.begin}:${key}:date:${data.id.uid}`,
@@ -345,9 +351,7 @@ export default {
345
351
  `time: ${data.time}`,
346
352
  `date: ${data.date}`,
347
353
  `copyright: ${data.id.copyright}`,
348
- `md5: ${data.md5}`,
349
354
  `sha256: ${data.sha256}`,
350
- `sha512: ${data.sha512}`,
351
355
  `${this.box.end}:${key}:date:${data.id.uid}`
352
356
  ].join('\n');
353
357
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "40899039373337698066",
3
3
  "name": "@indra.ai/deva.security",
4
- "version": "0.21.3",
4
+ "version": "0.22.0",
5
5
  "license": "VLA:40899039373337698066 LICENSE.md",
6
6
  "VLA": {
7
7
  "uid": "72981472549283584069",