@indra.ai/deva.security 0.37.7 → 0.37.9

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/README.md +1 -1
  2. package/index.js +76 -76
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -138,7 +138,7 @@ Help lives in Feecting files. `help/main.feecting` is the main help page, with t
138
138
  | Name | Kind | What it does |
139
139
  | --- | --- | --- |
140
140
  | `write_log` | func | Inserts a packet into a named collection in the log database, as described above. It lives in `index.js`. |
141
- | `security`, `uid`, `sign`, `hash`, `encrypt`, `decrypt`, `date`, `time` | feature methods | The commands in `feature/methods.js`, bound at runtime. |
141
+ | `uid`, `sign`, `hash`, `encrypt`, `decrypt`, `date`, `time` | feature methods | The commands in `feature/methods.js`, bound at runtime. |
142
142
  | `translate`, `parse`, `process` | utils | Each returns its input trimmed. |
143
143
  | `onReady` | lifecycle | Builds the MongoDB client from the security feature's `global.mongo` and prompts the ready message. |
144
144
  | `onStop` | lifecycle | Closes the MongoDB client, if there is one, then calls `this.close(data, resolve)`. |
package/index.js CHANGED
@@ -17,84 +17,84 @@ import {fileURLToPath} from 'node:url';
17
17
  const __dirname = dirname(fileURLToPath(import.meta.url));
18
18
 
19
19
  const info = {
20
- id: pkg.id,
21
- name: pkg.name,
22
- describe: pkg.description,
23
- version: pkg.version,
24
- url: pkg.homepage,
25
- dir: __dirname,
26
- git: pkg.repository.url,
27
- bugs: pkg.bugs.url,
28
- author: pkg.author,
29
- license: pkg.license,
30
- VLA: pkg.VLA,
31
- copyright: pkg.copyright,
20
+ id: pkg.id,
21
+ name: pkg.name,
22
+ describe: pkg.description,
23
+ version: pkg.version,
24
+ url: pkg.homepage,
25
+ dir: __dirname,
26
+ git: pkg.repository.url,
27
+ bugs: pkg.bugs.url,
28
+ author: pkg.author,
29
+ license: pkg.license,
30
+ VLA: pkg.VLA,
31
+ copyright: pkg.copyright,
32
32
  };
33
33
 
34
34
  const SecurityDeva = new Deva({
35
- info,
36
- agent,
37
- vars,
38
- utils: {
39
- translate(input) {return input.trim();},
40
- parse(input) {return input.trim();},
41
- process(input) {return input.trim();}
42
- },
43
- listeners: {
44
- // log the answer on finish
45
- 'devacore:finish'(packet) {
46
- if (!this._active) return;
47
- this.func.write_log('finish', this.lib.copy(packet));
48
- },
49
- // log the answer on complete
50
- 'devacore:complete'(packet) {
51
- if (!this._active) return;
52
- this.func.write_log('complete', this.lib.copy(packet));
53
- },
54
- },
55
- modules: {},
56
- devas: {},
57
- func: {
58
- /**************
59
- func: write_log
60
- params: type, packet
61
- describe: this is the log file writer function that handles
62
- writing for finish and complete for complete chain of custody.
63
- ***************/
64
- async write_log(type, packet) {
65
- let result = false;
66
- if (!this.modules.client) return;
67
- try {
68
- const database = this.modules.client.db(this.vars.log);
69
- const collection = database.collection(type);
70
- result = await collection.insertOne(packet);
71
- return result;
72
- }
73
- catch (err) {
74
- return this.err(err, packet);
75
- }
76
- },
77
-
78
- },
79
- methods: {},
80
- onReady(data, resolve) {
81
- const {VLA} = this.info();
82
- const {uri, database, log} = this.security().global?.mongo || {};
83
- if (database) this.vars.database = database; // set the main database
84
- if (log) this.vars.log = log; // set the logging database
85
- if (uri) this.modules.client = new MongoClient(uri); // build the client if uri is set
86
- this.prompt(`${this.vars.messages.ready} > VLA:${VLA.uid}`);
87
- return resolve(data);
88
- },
89
- onStop(data, resolve) {
90
- const {client} = this.modules;
91
- if (!client) return this.close(data, resolve);
92
- return client.close().then(() => this.close(data, resolve)); // close the database before shutdown
93
- },
94
- onError(err, data, reject) {
95
- this.prompt(this.vars.messages.error);
96
- console.error(err);
97
- return reject ? reject(err) : Promise.reject(err);
98
- }
35
+ info,
36
+ agent,
37
+ vars,
38
+ utils: {
39
+ translate(input) {return input.trim();},
40
+ parse(input) {return input.trim();},
41
+ process(input) {return input.trim();}
42
+ },
43
+ listeners: {
44
+ // log the answer on finish
45
+ 'devacore:finish'(packet) {
46
+ if (!this._active) return;
47
+ this.func.write_log('finish', this.lib.copy(packet));
48
+ },
49
+ // log the answer on complete
50
+ 'devacore:complete'(packet) {
51
+ if (!this._active) return;
52
+ this.func.write_log('complete', this.lib.copy(packet));
53
+ },
54
+ },
55
+ modules: {},
56
+ devas: {},
57
+ func: {
58
+ /**************
59
+ func: write_log
60
+ params: type, packet
61
+ describe: this is the log file writer function that handles
62
+ writing for finish and complete for complete chain of custody.
63
+ ***************/
64
+ async write_log(type, packet) {
65
+ let result = false;
66
+ if (!this.modules.client) return;
67
+ try {
68
+ const database = this.modules.client.db(this.vars.log);
69
+ const collection = database.collection(type);
70
+ result = await collection.insertOne(packet);
71
+ return result;
72
+ }
73
+ catch (err) {
74
+ return this.err(err, packet);
75
+ }
76
+ },
77
+
78
+ },
79
+ methods: {},
80
+ onReady(data, resolve) {
81
+ const {VLA} = this.info();
82
+ const {uri, database, log} = this.security().global?.mongo || {};
83
+ if (database) this.vars.database = database; // set the main database
84
+ if (log) this.vars.log = log; // set the logging database
85
+ if (uri) this.modules.client = new MongoClient(uri); // build the client if uri is set
86
+ this.prompt(`${this.vars.messages.ready} > VLA:${VLA.uid}`);
87
+ return resolve(data);
88
+ },
89
+ onStop(data, resolve) {
90
+ const {client} = this.modules;
91
+ if (!client) return this.close(data, resolve);
92
+ return client.close().then(() => this.close(data, resolve)); // close the database before shutdown
93
+ },
94
+ onError(err, data, reject) {
95
+ this.prompt(this.vars.messages.error);
96
+ console.error(err);
97
+ return reject ? reject(err) : Promise.reject(err);
98
+ }
99
99
  });
100
100
  export default SecurityDeva
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "15266350905933520771",
3
3
  "name": "@indra.ai/deva.security",
4
- "version": "0.37.7",
4
+ "version": "0.37.9",
5
5
  "license": "VLA:15266350905933520771 LICENSE.md",
6
6
  "VLA": {
7
7
  "uid": "15266350905933520771",