@indra.ai/deva 1.64.2 → 1.64.3

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "31711622713594414221",
3
3
  "name": "@indra.ai/deva",
4
- "version": "1.64.2",
4
+ "version": "1.64.3",
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:31711622713594414221 LICENSE.md",
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ // Deva Core Test Suite: step 3, the md5, sha256 and sha512 hash tiers
3
+ // Copyright ©2000-2026 Quinn Michaels; All rights reserved.
4
+ // Owner Signature Required For Lawful Use.
5
+ // Distributed under VLA:31711622713594414221 LICENSE.md
6
+
7
+ import test from 'node:test';
8
+ import assert from 'node:assert/strict';
9
+ import {createHash} from 'node:crypto';
10
+ import {build, client} from './_deva.js';
11
+
12
+ const TIERS = ['md5', 'sha256', 'sha512'];
13
+
14
+ // independent hash, so the test does not trust deva.hash() to check itself
15
+ const digest = (data, algo) => createHash(algo).update(JSON.stringify(data)).digest('base64');
16
+
17
+ // each tier hashes the data plus every tier before it
18
+ function verifyTiers(stamped, label) {
19
+ const base = {...stamped};
20
+ for (const t of TIERS) delete base[t];
21
+ const walk = {...base};
22
+ for (const t of TIERS) {
23
+ assert.equal(typeof stamped[t], 'string', `${label} has ${t}`);
24
+ assert.equal(stamped[t], digest(walk, t), `${label} ${t} covers the data and the tiers before it`);
25
+ walk[t] = stamped[t];
26
+ }
27
+ }
28
+
29
+ const deva = build();
30
+ test.before(async () => { await deva.init(structuredClone(client)); });
31
+ test.after(async () => { await deva.stop(); });
32
+
33
+ test('hash tiers are md5, sha256, sha512 in that order', () => {
34
+ assert.deepEqual(deva._config.hashes, TIERS);
35
+ });
36
+
37
+ test('hash() matches node:crypto in base64 for each tier', () => {
38
+ const data = {text: 'deva', n: 108};
39
+ for (const t of TIERS) assert.equal(deva.hash(data, t), digest(data, t), t);
40
+ assert.equal(deva.hash(data), digest(data, 'md5'), 'md5 is the default');
41
+ });
42
+
43
+ test('manual hashing sites carry all three cumulative tiers', () => {
44
+ verifyTiers(deva.uid(), 'uid()');
45
+ verifyTiers(deva.client(), 'client()');
46
+ verifyTiers(deva.agent(), 'agent()');
47
+ verifyTiers(deva.machine(), 'machine()');
48
+ verifyTiers(deva.state('valid', 'hash-test'), '_workflow via state()');
49
+ });
50
+
51
+ test('_stamp sites carry all three cumulative tiers', () => {
52
+ verifyTiers(deva.core(), 'core()');
53
+ verifyTiers(deva.info(), 'info()');
54
+ });
55
+
56
+ test('uid() fingerprint is the sha256 of license, client, agent, machine and core', () => {
57
+ const id = deva.uid();
58
+ const expect = digest({
59
+ license: id.license,
60
+ client: id.client,
61
+ agent: id.agent,
62
+ machine: id.machine,
63
+ core_hash: id.core_hash,
64
+ }, 'sha256');
65
+ assert.equal(id.fingerprint, expect);
66
+ assert.equal(id.core_hash, deva._core.sha256);
67
+ });
68
+
69
+ test('changing one field breaks every tier', () => {
70
+ const stamped = deva.client();
71
+ const tampered = {...stamped, key: `${stamped.key}x`};
72
+ assert.throws(() => verifyTiers(tampered, 'tampered'), /md5/);
73
+ });