@indra.ai/deva 1.5.35 → 1.5.37
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 +35 -5
- package/package.json +1 -1
- package/tests/index.js +4 -8
package/index.js
CHANGED
|
@@ -507,8 +507,8 @@ class Deva {
|
|
|
507
507
|
}
|
|
508
508
|
else if (isCmd) { // determine if the question is a command
|
|
509
509
|
//if:isCmd use text split index 1 as the parameter block
|
|
510
|
-
params = t_split[0] ? t_split[0].split(':')
|
|
511
|
-
method = t_split[0].substring(1); // if:isCmd use the 0 index as the command
|
|
510
|
+
params = t_split[0] ? t_split[0].split(':') : false;
|
|
511
|
+
method = t_split[0].split(':')[0].substring(1); // if:isCmd use the 0 index as the command
|
|
512
512
|
text = t_split.slice(1).join(' ').trim(); // if:isCmd rejoin the string on the space after removing first index
|
|
513
513
|
this.state('cmd', `${method}:${id}`); // set the state to cmd.
|
|
514
514
|
}
|
|
@@ -1377,7 +1377,7 @@ class Deva {
|
|
|
1377
1377
|
usage: this.systems()
|
|
1378
1378
|
***************/
|
|
1379
1379
|
justice() {
|
|
1380
|
-
return this._getFeature('
|
|
1380
|
+
return this._getFeature('justice', this._justice);
|
|
1381
1381
|
}
|
|
1382
1382
|
|
|
1383
1383
|
/**************
|
|
@@ -1515,7 +1515,33 @@ class Deva {
|
|
|
1515
1515
|
this.state('return', `status:${id}`);
|
|
1516
1516
|
return `${this._agent.profile.name} active since ${dateFormat}`; // return final text string
|
|
1517
1517
|
}
|
|
1518
|
+
|
|
1519
|
+
/******
|
|
1520
|
+
func: signature
|
|
1521
|
+
params:
|
|
1522
|
+
- data: the data to sign
|
|
1523
|
+
describe: function to provide a digital signature to data.
|
|
1524
|
+
******/
|
|
1525
|
+
signature(data) {
|
|
1526
|
+
if (!this._active) return this._messages.offline;
|
|
1527
|
+
const id = this.lib.uid();
|
|
1528
|
+
this.action('signature', id);
|
|
1518
1529
|
|
|
1530
|
+
const client = this.client();
|
|
1531
|
+
const agent = this.agent();
|
|
1532
|
+
this.state('set', `signature:${id}`);
|
|
1533
|
+
const signature = {
|
|
1534
|
+
id,
|
|
1535
|
+
uid: this.lib.uid(true),
|
|
1536
|
+
name: client.profile.name,
|
|
1537
|
+
md5: this.lib.hash(data),
|
|
1538
|
+
sha256: this.lib.hash(data, 'sha256'),
|
|
1539
|
+
sha512: this.lib.hash(data, 'sha512'),
|
|
1540
|
+
date: Date.now(),
|
|
1541
|
+
};
|
|
1542
|
+
this.state('return', `signature:${id}`);
|
|
1543
|
+
return signature;
|
|
1544
|
+
}
|
|
1519
1545
|
/**************
|
|
1520
1546
|
func: help
|
|
1521
1547
|
params:
|
|
@@ -1537,10 +1563,13 @@ class Deva {
|
|
|
1537
1563
|
this.state('help', id);
|
|
1538
1564
|
this.context('help', id);
|
|
1539
1565
|
const params = msg.split(' '); // split the msg into an array by spaces.
|
|
1540
|
-
let helpFile = 'main'; // set default help file
|
|
1566
|
+
let helpFile = 'main', helpDoc = false; // set default help file
|
|
1541
1567
|
if (params[0]) helpFile = params[0]; // check the msg for a help file
|
|
1542
1568
|
if (params[1]) helpFile = `${params[0]}_${params[1]}`;
|
|
1543
1569
|
|
|
1570
|
+
const splitText = msg.split(':');
|
|
1571
|
+
const part = splitText[1] ? splitText[1].toUpperCase() : 'MAIN';
|
|
1572
|
+
|
|
1544
1573
|
|
|
1545
1574
|
const helpPath = this.lib.path.join(help_dir, 'help', `${helpFile}.feecting`);
|
|
1546
1575
|
this.state('try', `help:${id}`);
|
|
@@ -1550,7 +1579,8 @@ class Deva {
|
|
|
1550
1579
|
this.state('return', `${this._messages.help_not_found}:${id}`);
|
|
1551
1580
|
return resolve(this._messages.help_not_found);
|
|
1552
1581
|
}
|
|
1553
|
-
|
|
1582
|
+
helpDoc = this.lib.fs.readFileSync(helpPath, 'utf8');
|
|
1583
|
+
helpDoc = helpDoc.split(`::BEGIN:${part}`)[1].split(`::END:${part}`)[0];
|
|
1554
1584
|
this.state('return', `help:${id}`);
|
|
1555
1585
|
return resolve(helpDoc);
|
|
1556
1586
|
} catch (e) {
|
package/package.json
CHANGED
package/tests/index.js
CHANGED
|
@@ -93,6 +93,7 @@ const DevaTest = new Deva({
|
|
|
93
93
|
const info = this.info();
|
|
94
94
|
const date = Date.now();
|
|
95
95
|
const hashstr = `${id}${uid}${date}`;
|
|
96
|
+
const signature = this.signature(hashstr);
|
|
96
97
|
const data = [
|
|
97
98
|
'🧪 TEST RESULTS',
|
|
98
99
|
`::BEGIN:CORE:${core.id}`,
|
|
@@ -101,14 +102,9 @@ const DevaTest = new Deva({
|
|
|
101
102
|
`::BEGIN:INFO:${info.id}`,
|
|
102
103
|
JSON.stringify(info,null,2),
|
|
103
104
|
`::END:INFO:${info.hash}`,
|
|
104
|
-
`::BEGIN:
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
`md5: ${this.lib.hash(hashstr)}`,
|
|
108
|
-
`sha256: ${this.lib.hash(hashstr, 'sha256')}`,
|
|
109
|
-
`sha512: ${this.lib.hash(hashstr, 'sha512')}`,
|
|
110
|
-
`date: ${this.lib.formatDate(date, 'long', true)}`,
|
|
111
|
-
`::END:RESULTS:${this.lib.hash(hashstr)}`,
|
|
105
|
+
`::BEGIN:SIGNATURE:${signature.id}`,
|
|
106
|
+
JSON.stringify(signature, null, 2),
|
|
107
|
+
`::END:SIGNATURE:${signature.md5}`,
|
|
112
108
|
];
|
|
113
109
|
return {
|
|
114
110
|
text: data.join('\n'),
|