@indra.ai/deva.security 0.0.62 → 0.0.64

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 +41 -131
  2. package/package.json +2 -2
@@ -21,23 +21,42 @@ export default {
21
21
  describe: Return a system id to the user from the Log Buddy.
22
22
  ***************/
23
23
  uid(packet) {
24
+ this.feature('security', `uid:${packet.id.uid}`);
25
+ this.zone('security', `uid:${packet.id.uid}`);
26
+
24
27
  const uid = packet.q.text ? true : false
25
- this.feature('security');
26
28
  const id = this.lib.uid(uid);
27
- const {key} = this.agent();
29
+
30
+ const {client} = packet.q;
31
+
32
+ const agent = this.agent();
33
+ const {key} = agent;
34
+
35
+ console.log('client sha uid\n', client.sha256, '\n', id.client);
36
+ console.log('agent sha uid\n', agent.sha256, '\n', id.agent);
28
37
 
29
- const data = [
30
- '',
38
+ console.log('agent uid', agent);
39
+ const text = [
40
+ '→',
31
41
  `::begin:uid:${key}:${id.uid}`,
32
42
  `uid: ${id.uid}`,
33
- `time: ${id.created}`,
34
- `date: ${this.lib.formatDate(id.created, 'short', true)}`,
43
+ `time: ${id.time}`,
44
+ `date: ${id.date}`,
45
+ `agent: ${id.agent}`,
46
+ `client: ${id.client}`,
47
+ `pkg: ${id.pkg}`,
48
+ `machine: ${id.machine}`,
49
+ `warning: ${id.warning}`,
35
50
  `md5: ${id.md5}`,
36
51
  `sha256: ${id.sha256}`,
37
52
  `sha512: ${id.sha512}`,
38
53
  `::end:uid:${key}:${id.uid}`,
39
54
  ].join('\n');
40
- return Promise.resolve(data);
55
+ return Promise.resolve({
56
+ text,
57
+ html: false,
58
+ data: id,
59
+ });
41
60
  },
42
61
 
43
62
  /**************
@@ -111,130 +130,22 @@ export default {
111
130
  },
112
131
 
113
132
 
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: client.profile.warning || agent.profile.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
-
133
+ async sign(packet) {
134
+ console.log('client sha sign', packet.q.client.sha256);
135
+ console.log('agent sha sign', packet.q.agent.sha256);
136
+
137
+ const data = this.lib.sign(packet);
225
138
  // 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.
139
+ this.state('set', `${data.key}:${data.method}:text:${data.id.uid}`); // set state to text for output formatting.
227
140
  const text = [
228
- `::::`,
141
+ '→',
229
142
  `::BEGIN:${data.container}`,
230
- `#${key}.${type}${data.opts} ${write}? if true ${write} ${data.message}`,
143
+ `${data.write} #${data.key}.${data.method}${data.opts}? if true ${data.write} ${data.text}`,
231
144
  '\n---\n',
232
- 'Signed',
233
- data.fullname,
234
- data.emojis,
145
+ `sign:${data.fullname}${data.emojis}`,
235
146
  '\n',
236
- `::begin:${key}:${type}:${transport.uid}`,
237
- `transport: ${data.transport.uid}`,
147
+ `::begin:${data.method}:${data.key}:${data.id.uid}`,
148
+ `transport: ${data.id.uid}`,
238
149
  `time: ${data.time}`,
239
150
  `expires: ${data.expires}`,
240
151
  `name: ${data.name}`,
@@ -252,16 +163,15 @@ export default {
252
163
  `md5: ${data.md5}`,
253
164
  `sha256: ${data.sha256}`,
254
165
  `sha512: ${data.sha512}`,
255
- `::end:${key}:${type}${data.transport.uid}`,
166
+ `::end:${data.method}:${data.key}:${data.id.uid}`,
256
167
  `::END:${data.container}`,
257
- `::::`
258
168
  ].join('\n').trim();
259
169
 
260
170
  // 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.
171
+ this.action('parse', `${data.key}:${data.method}:parse:${data.id.uid}`); // action set to feecting parse
172
+ const feecting = await this.question(`${this.askChr}feecting parse:${data.id.uid} ${text}`); // parse with feecting agent.
263
173
 
264
- this.state('return', `${key}:sign:${type}:return:${transport.uid}`); // set the state to return proxy
174
+ this.action('return', `${data.key}:${data.method}:${data.id.uid}`); // set the state to return proxy
265
175
  return {
266
176
  text: feecting.a.text,
267
177
  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.62",
4
+ "version": "0.0.64",
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.42"
46
46
  },
47
47
  "data": {
48
48
  "agent": {