@indra.ai/deva.security 0.0.61 → 0.0.63

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 +33 -132
  2. package/package.json +2 -2
@@ -21,23 +21,34 @@ export default {
21
21
  describe: Return a system id to the user from the Log Buddy.
22
22
  ***************/
23
23
  uid(packet) {
24
+ console.log('uid packet', packet);
24
25
  const uid = packet.q.text ? true : false
25
- this.feature('security');
26
+ this.feature('security', `uid:${packet.id.uid}`);
26
27
  const id = this.lib.uid(uid);
27
- const {key} = this.agent();
28
-
29
- const data = [
30
- '',
28
+ const agent = this.agent();
29
+ console.log('before or after uid');
30
+ const {key} = agent;
31
+ const text = [
32
+ '→',
31
33
  `::begin:uid:${key}:${id.uid}`,
32
34
  `uid: ${id.uid}`,
33
- `time: ${id.created}`,
34
- `date: ${this.lib.formatDate(id.created, 'short', true)}`,
35
+ `time: ${id.time}`,
36
+ `date: ${id.date}`,
37
+ `agent: ${id.agent}`,
38
+ `client: ${id.client}`,
39
+ `pkg: ${id.pkg}`,
40
+ `machine: ${id.machine}`,
41
+ `warning: ${id.warning}`,
35
42
  `md5: ${id.md5}`,
36
43
  `sha256: ${id.sha256}`,
37
44
  `sha512: ${id.sha512}`,
38
45
  `::end:uid:${key}:${id.uid}`,
39
46
  ].join('\n');
40
- return Promise.resolve(data);
47
+ return Promise.resolve({
48
+ text,
49
+ html: false,
50
+ data: id,
51
+ });
41
52
  },
42
53
 
43
54
  /**************
@@ -111,130 +122,21 @@ export default {
111
122
  },
112
123
 
113
124
 
114
- async sign(key, type, packet) {
115
- this.state('set', `${key}:sign:${type}:${packet.id.uid}`);
116
- const transport = packet.id; // set the transport id from the packet id.
117
-
118
- this.zone(key, `${key}:sign:${type}:${transport.uid}`); // set the zone
119
- this.feature(key, `${key}:sign:${type}:${transport.uid}`); // set the feature
120
- this.context(key, `${key}:sign:${type}:${transport.uid}`); // set the agent context to proxy.
121
- this.action('method', `${key}:sign:${type}:${transport.uid}`); // set the action method to proxy.
122
-
123
- this.state('set', `${key}:sign:${type}:uid:${transport.uid}`); //set the uid state
124
- const id = this.lib.uid(true); // The UID
125
-
126
- this.state('set', `${key}:sign:${type}:time:${transport.uid}`); //set the time state
127
- const time = Date.now(); // current timestamp
128
-
129
- this.state('created', `${key}:sign:${type}:created:${transport.uid}`); //set the created state
130
- const created = this.lib.formatDate(time, 'long', true); // Formatted created date.
131
-
132
- this.state('set', `${key}:sign:${type}:concerns:${transport.uid}`); //set the concerns
133
- const {concerns} = this[key](); // load the Guard profile
134
-
135
- this.state('set', `${key}:sign:${type}:agent:${transport.uid}`); //set the agent state
136
- const agent = this.agent(); // the agent processing the proxy
137
-
138
- this.state('set', `${key}:sign:${type}:client:${transport.uid}`); //set the client state
139
- const client = this.client(); // the client requesting the proxy
140
-
141
- this.state('set', `${key}:sign:${type}:expires:${transport.uid}`); //set the time state
142
- const expires = time + (client.expires || agent.expires || 10000); // signature expires in milliseconds
143
-
144
- this.state('set', `${key}:sign:${type}:meta:${transport.uid}`); //set the meta state
145
- const {meta} = packet.q; // set the meta information from the packet question.
146
-
147
- this.state('set', `${key}:sign:${type}:params:${transport.uid}`); //set the meta state
148
- const {params} = meta; // set params from the meta information.
149
-
150
- this.state('set', `${key}:sign:${type}:opts:${transport.uid}`); //set the opts state
151
- const opts = this.lib.copy(params); // copy the params and set as opts.
152
-
153
- this.state('set', `${key}:sign:${type}:command:${transport.uid}`); //set the opts state
154
- const command = opts.shift(); // extract the command first array item out of opts.
155
-
156
- this.state('set', `${key}:sign:${type}:message:${transport.uid}`); //set the message state
157
- const message = packet.q.text; // set packet.q.text as the message of the proxy.
158
-
159
- this.state('set', `${key}:sign:${type}:container:${transport.uid}`); //set the message state
160
- const container = `OM:${key.toUpperCase()}:${transport.uid}`; // set container string.
161
-
162
- this.state('set', `${key}:sign:${type}:write:${transport.uid}`); //set the message state
163
- const write = client.profile.write; // set write string.
164
-
165
- // hash the agent profile for security
166
- this.state('hash', `${key}:sign:${type}:packet:sha256:${transport.uid}`);
167
- const packet_hash = this.lib.hash(packet, 'sha256');
168
-
169
- // hash the agent profile for security
170
- this.state('hash', `${key}:sign:${type}:agent:sha256:${transport.uid}`);
171
- const agent_hash = this.lib.hash(agent, 'sha256');
172
-
173
- // hash the agent profile for security
174
- this.state('hash', `${key}:sign:${type}:client:sha256:${transport.uid}`);
175
- const client_hash = this.lib.hash(client, 'sha256');
176
-
177
- // hash the agent profile for security
178
- this.state('hash', `${key}:sign:${type}:laws:sha256:${transport.uid}`);
179
- const laws_hash = this.lib.hash(agent.laws || client.laws, 'sha256');
180
-
181
- // hash the agent profile for security
182
- this.state('hash', `${key}:sign:${type}:token:${transport.uid}`);
183
- const token = this.lib.hash(`${key} client:${client.profile.id} fullname:${client.profile.fullname} transport:${transport.uid}`, 'sha256');
184
-
185
-
186
- this.state('set', `${key}:sign:${type}:write:${transport.uid}`); // set the state to set data
187
- // data packet
188
- const data = {
189
- id,
190
- transport,
191
- time,
192
- expires,
193
- container,
194
- write,
195
- message,
196
- caseid: client.profile.caseid,
197
- opts: opts.length? `.${opts.join('.')}` : '',
198
- name: client.profile.name,
199
- fullname: client.profile.fullname,
200
- emojis: client.profile.emojis,
201
- company: client.profile.company,
202
- client: client_hash,
203
- agent: agent_hash,
204
- packet: packet_hash,
205
- laws: laws_hash,
206
- warning: agent.warning || client.warning || 'none',
207
- token,
208
- concerns,
209
- meta,
210
- params,
211
- command,
212
- created,
213
- copyright: client.profile.copyright,
214
- };
215
-
216
- this.state('hash', `${key}:sign:${type}:md5:${transport.uid}`); // set state to secure hashing
217
- data.md5 = this.lib.hash(data, 'md5'); // hash data packet into md5 and inert into data.
218
-
219
- this.state('hash', `${key}:sign:${type}:sha256:${transport.uid}`); // set state to secure hashing
220
- data.sha256 = this.lib.hash(data, 'sha256'); // hash data into sha 256 then set in data.
221
-
222
- this.state('hash', `${key}:sign:${type}:sha512:${transport.uid}`); // set state to secure hashing
223
- data.sha512 = this.lib.hash(data, 'sha512'); // hash data into sha 512 then set in data.
224
-
125
+ async sign(packet) {
126
+ console.log('sign packet', packet);
127
+
128
+ const data = this.lib.sign(packet);
225
129
  // Text data that is joined by line breaks and then trimmed.
226
- this.state('set', `${key}:sign:${type}:text:${transport.uid}`); // set state to text for output formatting.
130
+ this.state('set', `${data.key}:${data.method}:text:${data.id.uid}`); // set state to text for output formatting.
227
131
  const text = [
228
- `::::`,
132
+ '→',
229
133
  `::BEGIN:${data.container}`,
230
- `#${key}.${type}${data.opts} ${write}? if true ${write} ${data.message}`,
134
+ `${data.write} #${data.key}.${data.method}${data.opts}? if true ${data.write} ${data.text}`,
231
135
  '\n---\n',
232
- 'Signed',
233
- data.fullname,
234
- data.emojis,
136
+ `sign:${data.fullname}${data.emojis}`,
235
137
  '\n',
236
- `::begin:${key}:${type}:${transport.uid}`,
237
- `transport: ${data.transport.uid}`,
138
+ `::begin:${data.method}:${data.key}:${data.id.uid}`,
139
+ `transport: ${data.id.uid}`,
238
140
  `time: ${data.time}`,
239
141
  `expires: ${data.expires}`,
240
142
  `name: ${data.name}`,
@@ -252,16 +154,15 @@ export default {
252
154
  `md5: ${data.md5}`,
253
155
  `sha256: ${data.sha256}`,
254
156
  `sha512: ${data.sha512}`,
255
- `::end:${key}:${type}${data.transport.uid}`,
157
+ `::end:${data.method}:${data.key}:${data.id.uid}`,
256
158
  `::END:${data.container}`,
257
- `::::`
258
159
  ].join('\n').trim();
259
160
 
260
161
  // send the text data to #feecting to parse and return valid text, html, and data.
261
- this.action('question', `${key}:sign:${type}:write:${transport.uid}`); // action set to feecting parse
262
- const feecting = await this.question(`${this.askChr}feecting parse:${transport.uid} ${text}`); // parse with feecting agent.
162
+ this.action('parse', `${data.key}:${data.method}:parse:${data.id.uid}`); // action set to feecting parse
163
+ const feecting = await this.question(`${this.askChr}feecting parse:${data.id.uid} ${text}`); // parse with feecting agent.
263
164
 
264
- this.state('return', `${key}:sign:${type}:return:${transport.uid}`); // set the state to return proxy
165
+ this.action('return', `${data.key}:${data.method}:${data.id.uid}`); // set the state to return proxy
265
166
  return {
266
167
  text: feecting.a.text,
267
168
  html: feecting.a.html,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "31477276110836980722",
3
3
  "name": "@indra.ai/deva.security",
4
- "version": "0.0.61",
4
+ "version": "0.0.63",
5
5
  "license": "VLA:36687315706419437672 LICENSE.md",
6
6
  "author": {
7
7
  "name": "Quinn A Michaels",
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "homepage": "https://deva.space/devas/security",
44
44
  "dependencies": {
45
- "@indra.ai/deva": "^1.6.9"
45
+ "@indra.ai/deva": "^1.6.35"
46
46
  },
47
47
  "data": {
48
48
  "agent": {