@indra.ai/deva.guard 0.0.35 → 0.0.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/feature/methods.js +7 -126
- package/package.json +2 -2
package/feature/methods.js
CHANGED
|
@@ -1,130 +1,11 @@
|
|
|
1
1
|
export default {
|
|
2
|
+
/**************
|
|
3
|
+
method: guard
|
|
4
|
+
params: packet
|
|
5
|
+
describe: The global guard feature that installs with every agent
|
|
6
|
+
***************/
|
|
2
7
|
async guard(packet) {
|
|
3
|
-
this.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
this.zone('guard', transport); // set the current zone to guard
|
|
7
|
-
this.feature('guard', transport); // set the Guard feature.
|
|
8
|
-
this.context('guard', transport); // set the agent context to proxy.
|
|
9
|
-
this.action('method', `proxy:${transport}`); // set the action method to proxy.
|
|
10
|
-
|
|
11
|
-
this.state('set', `uid:${transport}`); //set the uid state for the proxy
|
|
12
|
-
const uid = this.lib.uid(true); // The UID for the proxy
|
|
13
|
-
this.state('set', `time:${transport}`); //set the time state for the proxy
|
|
14
|
-
const time = Date.now(); // current timestamp
|
|
15
|
-
this.state('created', `created:${transport}`); //set the uid state for the proxy
|
|
16
|
-
const created = this.lib.formatDate(time, 'long', true); // Formatted created date.
|
|
17
|
-
|
|
18
|
-
this.state('set', `guard:${transport}`); //set the guard state for the proxy
|
|
19
|
-
const guard = this.guard(); // load the Guard profile
|
|
20
|
-
const {concerns} = guard; // load concerns from client guard profile.
|
|
21
|
-
|
|
22
|
-
this.state('set', `guard:agent:${transport}`); //set the agent state for the proxy
|
|
23
|
-
const agent = this.agent(); // the agent processing the proxy
|
|
24
|
-
|
|
25
|
-
this.state('set', `guard:client:${transport}`); //set the client state for the proxy
|
|
26
|
-
const client = this.client(); // the client requesting the proxy
|
|
27
|
-
|
|
28
|
-
this.state('set', `guard:meta:${transport}`); //set the meta state for the proxy
|
|
29
|
-
const {meta} = packet.q; // set the meta information from the packet question.
|
|
30
|
-
|
|
31
|
-
this.state('set', `guard:params:${transport}`); //set the meta state for the proxy
|
|
32
|
-
const {params} = meta; // set params from the meta information.
|
|
33
|
-
|
|
34
|
-
this.state('set', `guard:opts:${transport}`); //set the opts state for the proxy
|
|
35
|
-
const opts = this.lib.copy(params); // copy the params and set as opts.
|
|
36
|
-
|
|
37
|
-
this.state('set', `guard:command:${transport}`); //set the opts state for the proxy
|
|
38
|
-
const command = opts.shift(); // extract the command first array item out of opts.
|
|
39
|
-
|
|
40
|
-
this.state('set', `guard:message:${transport}`); //set the message state for the proxy
|
|
41
|
-
const message = packet.q.text; // set packet.q.text as the message of the proxy.
|
|
42
|
-
|
|
43
|
-
this.state('set', `guard:write:${transport}`); //set the message state for the proxy
|
|
44
|
-
const write = `OM:VECTOR:GUARD:${client.profile.write.split(' ').join(':').toUpperCase()}`; // set proxy write string.
|
|
45
|
-
|
|
46
|
-
// hash the agent profile for security
|
|
47
|
-
this.state('hash', `guard:agent:hash:${transport}`);
|
|
48
|
-
const agent_hash = this.lib.hash(agent, 'sha256');
|
|
49
|
-
|
|
50
|
-
// hash the agent profile for security
|
|
51
|
-
this.state('hash', `guard:client:hash:${transport}`);
|
|
52
|
-
const client_hash = this.lib.hash(client, 'sha256');
|
|
53
|
-
|
|
54
|
-
// hash the agent profile for security
|
|
55
|
-
this.state('hash', `guard:token:${transport}`);
|
|
56
|
-
const token = this.lib.hash(`GUARD ${client.profile.token} ${transport}`, 'sha256');
|
|
57
|
-
|
|
58
|
-
this.state('set', `guard:data:${transport}`); // set the state to set data
|
|
59
|
-
// data packet
|
|
60
|
-
const data = {
|
|
61
|
-
uid,
|
|
62
|
-
transport,
|
|
63
|
-
time,
|
|
64
|
-
write,
|
|
65
|
-
message,
|
|
66
|
-
caseid: client.profile.caseid,
|
|
67
|
-
opts: opts.length? `:${opts.join(':')}` : '',
|
|
68
|
-
agent: agent_hash,
|
|
69
|
-
client: client_hash,
|
|
70
|
-
name: client.profile.name,
|
|
71
|
-
emojis: client.profile.emojis,
|
|
72
|
-
company: client.profile.company,
|
|
73
|
-
warning: client.profile.warning,
|
|
74
|
-
token,
|
|
75
|
-
concerns,
|
|
76
|
-
meta,
|
|
77
|
-
params,
|
|
78
|
-
command,
|
|
79
|
-
created,
|
|
80
|
-
copyright: client.profile.copyright,
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
this.state('hash', `guard:md5:${transport}`); // set state to secure hashing
|
|
84
|
-
data.md5 = this.lib.hash(data, 'md5'); // hash data packet into md5 and inert into data.
|
|
85
|
-
|
|
86
|
-
this.state('hash', `guard:sha256:${transport}`); // set state to secure hashing
|
|
87
|
-
data.sha256 = this.lib.hash(data, 'sha256'); // hash data into sha 256 then set in data.
|
|
88
|
-
|
|
89
|
-
this.state('hash', `guard:sha512:${transport}`); // set state to secure hashing
|
|
90
|
-
data.sha512 = this.lib.hash(data, 'sha512'); // hash data into sha 512 then set in data.
|
|
91
|
-
|
|
92
|
-
// Text data that is joined by line breaks and then trimmed.
|
|
93
|
-
this.state('set', `guard:text:${transport}`); // set state to text for output formatting.
|
|
94
|
-
const text = [
|
|
95
|
-
`:::`,
|
|
96
|
-
`::BEGIN:${data.write}:${data.transport}`,
|
|
97
|
-
`#VectorGuard${data.opts} ${data.message}`,
|
|
98
|
-
`::begin:vector:guard:${transport}:${data.emojis}`,
|
|
99
|
-
`transport: ${data.transport}`,
|
|
100
|
-
`time: ${data.time}`,
|
|
101
|
-
`caseid: ${data.caseid}`,
|
|
102
|
-
`agent: ${data.agent}`,
|
|
103
|
-
`client: ${data.client}`,
|
|
104
|
-
`token: ${data.token}`,
|
|
105
|
-
`name: ${data.name}`,
|
|
106
|
-
`company: ${data.company}`,
|
|
107
|
-
`warning: ${data.warning}`,
|
|
108
|
-
`created: ${data.created}`,
|
|
109
|
-
`copyright: ${data.copyright}`,
|
|
110
|
-
`md5: ${data.md5}`,
|
|
111
|
-
`sha256: ${data.sha256}`,
|
|
112
|
-
`sha512: ${data.sha512}`,
|
|
113
|
-
`::end:vector:guard:${data.transport}:${data.emojis}`,
|
|
114
|
-
`::END:${data.write}:${data.transport}`,
|
|
115
|
-
].join('\n').trim();
|
|
116
|
-
|
|
117
|
-
// send the text data to #feecting to parse and return valid text, html, and data.
|
|
118
|
-
this.action('question', `guard:feecting:parse:${transport}`); // action set to feecting parse
|
|
119
|
-
const feecting = await this.question(`${this.askChr}feecting parse:${transport} ${text}`); // parse with feecting agent.
|
|
120
|
-
|
|
121
|
-
this.state('return', `guard:${transport}`); // set the state to return proxy
|
|
122
|
-
return {
|
|
123
|
-
text: feecting.a.text,
|
|
124
|
-
html: feecting.a.html,
|
|
125
|
-
data,
|
|
126
|
-
}
|
|
8
|
+
const guard = await this.methods.sign('guard', 'default', packet);
|
|
9
|
+
return guard;
|
|
127
10
|
},
|
|
128
|
-
|
|
129
|
-
|
|
130
11
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": 6159528221394,
|
|
3
3
|
"name": "@indra.ai/deva.guard",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.37",
|
|
5
5
|
"author": "Quinn Michaels",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"copyright": "2025",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://deva.space/devas/guard",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@indra.ai/deva": "^1.5.
|
|
30
|
+
"@indra.ai/deva": "^1.5.47"
|
|
31
31
|
},
|
|
32
32
|
"data": {
|
|
33
33
|
"agent": {
|