@indra.ai/deva 1.20.3 → 1.20.5

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 +1 -1
  2. package/lib/index.js +24 -12
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -2438,7 +2438,7 @@ class Deva {
2438
2438
 
2439
2439
  const client_hash = this.client().sha256; // get client hash
2440
2440
  const agent_hash = this.agent().sha256; // get agent hash
2441
- const warning = this._agent.profile.warning || this._messages.warning; // agent or default warning
2441
+ const warning = this.vars.warning || this._agent.profile.warning || this._messages.warning; // agent or default warning
2442
2442
  const copyright = this._agent.profile.copyright || this._core.copyright; // agent or default copyright
2443
2443
 
2444
2444
  const status = this._agent.profile.status || this._messages.status;
package/lib/index.js CHANGED
@@ -45,21 +45,24 @@ class LIB {
45
45
  }
46
46
 
47
47
  /**************
48
- func: cipher
49
- params: str - string to encrypt
48
+ func: encrypt
49
+ params:
50
+ str - string to encrypt
51
+ opts - options for the encryption.
50
52
  describe:
51
53
  The encrypt function allows for the internal encryption of data based on the
52
54
  defined client security settings.
53
55
  ***************/
54
- cipher(str, opts) {
56
+ encrypt(str, opts) {
55
57
  const {password, algorithm} = opts;
56
- const key = createHash('sha256').update(String(password)).digest('base64');
58
+ const key = createHash('sha512').update(String(password)).digest('base64');
57
59
  const key_in_bytes = Buffer.from(key, 'base64')
58
60
  const iv = randomBytes(16);
59
61
  // create a new cipher
60
62
  const _cipher = createCipheriv(algorithm, key_in_bytes, iv);
61
63
  const encrypted = _cipher.update(String(str), 'utf8', 'hex') + _cipher.final('hex');
62
64
 
65
+ this.action('return', 'decipher');
63
66
  return {
64
67
  iv: iv.toString('base64'),
65
68
  key,
@@ -67,15 +70,24 @@ class LIB {
67
70
  }
68
71
  }
69
72
 
70
- decipher(opt) {
71
- const iv = Buffer.from(opt.iv, 'base64');
72
- const encrypted = Buffer.from(opt.encrypted, 'hex');
73
- const key_in_bytes = Buffer.from(opt.key, 'base64')
74
- const decipher = createDecipheriv( 'aes-256-cbc', key_in_bytes, iv);
75
- const decrypted = decipher.update(encrypted);
76
- const final = Buffer.concat([decrypted, decipher.final()]);
73
+ /**************
74
+ func: decrypt
75
+ params:
76
+ opts - options for the encryption.
77
+ describe:
78
+ The decrypt function allows for the internal decryption of data based on the
79
+ defined options.
80
+ ***************/
81
+ decrypt(opts) {
82
+ const {key, algorithm} = opts;
83
+ const iv = Buffer.from(opts.iv, 'base64');
84
+ const encrypted = Buffer.from(opts.encrypted, 'hex');
85
+ const key_in_bytes = Buffer.from(key, 'base64')
86
+ const decipher = createDecipheriv( algorithm, key_in_bytes, iv);
87
+ const decrypted = decipher.update(encrypted, 'hex', 'utf8');
88
+ const final = Buffer.concat([decrypted, decipher.final('utf8')]);
89
+ this.action('return', 'decipher');
77
90
  return final.toString();
78
- this.state('return', 'decipher');
79
91
  }
80
92
 
81
93
  /**************
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "64907438819979111427",
3
3
  "name": "@indra.ai/deva",
4
- "version": "1.20.3",
4
+ "version": "1.20.5",
5
5
  "description": "Deva Core a Vedic-inspired Event Based Context Aware Feature, Zone, Action, and State Machine integrated Artificial Intelligence Framework",
6
6
  "main": "index.js",
7
7
  "license": "VLA:64907438819979111427 LICENSE.md",