@svrnsec/pulse 0.1.0 → 0.2.0

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@svrnsec/pulse",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Physical Turing Test — Hardware-Biological Symmetry Protocol distinguishing real consumer devices from sanitised datacenter VMs.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -21,30 +21,42 @@
21
21
  "exports": {
22
22
  ".": {
23
23
  "browser": "./dist/pulse.esm.js",
24
- "import": "./dist/pulse.esm.js",
24
+ "import": "./dist/pulse.esm.js",
25
25
  "require": "./dist/pulse.cjs.js"
26
26
  },
27
27
  "./validator": {
28
- "node": "./src/proof/validator.js",
28
+ "node": "./src/proof/validator.js",
29
29
  "import": "./src/proof/validator.js"
30
30
  },
31
31
  "./registry": {
32
32
  "import": "./src/registry/serializer.js",
33
- "node": "./src/registry/serializer.js"
33
+ "node": "./src/registry/serializer.js"
34
34
  },
35
35
  "./middleware/express": {
36
36
  "import": "./src/middleware/express.js",
37
- "node": "./src/middleware/express.js"
37
+ "node": "./src/middleware/express.js"
38
38
  },
39
39
  "./middleware/next": {
40
40
  "import": "./src/middleware/next.js",
41
- "node": "./src/middleware/next.js"
41
+ "node": "./src/middleware/next.js"
42
42
  },
43
43
  "./react": {
44
44
  "import": "./src/integrations/react.js"
45
+ },
46
+ "./gpu": {
47
+ "import": "./src/collector/gpu.js"
48
+ },
49
+ "./dram": {
50
+ "import": "./src/collector/dram.js"
51
+ },
52
+ "./llm": {
53
+ "import": "./src/analysis/llm.js"
54
+ },
55
+ "./timer": {
56
+ "import": "./src/collector/sabTimer.js"
45
57
  }
46
58
  },
47
- "main": "dist/pulse.cjs.js",
59
+ "main": "dist/pulse.cjs.js",
48
60
  "module": "dist/pulse.esm.js",
49
61
  "files": [
50
62
  "dist/",
@@ -60,22 +72,22 @@
60
72
  ],
61
73
  "scripts": {
62
74
  "build:wasm": "bash build.sh",
63
- "build:js": "rollup -c rollup.config.js",
64
- "build": "npm run build:wasm && npm run build:js",
65
- "dev": "rollup -c rollup.config.js --watch",
66
- "test": "node --experimental-vm-modules ./node_modules/jest-cli/bin/jest.js",
67
- "demo": "node demo/node-demo.js"
75
+ "build:js": "rollup -c rollup.config.js",
76
+ "build": "npm run build:wasm && npm run build:js",
77
+ "dev": "rollup -c rollup.config.js --watch",
78
+ "test": "node --experimental-vm-modules ./node_modules/jest-cli/bin/jest.js",
79
+ "demo": "node demo/node-demo.js"
68
80
  },
69
81
  "dependencies": {
70
82
  "@noble/hashes": "^1.4.0"
71
83
  },
72
84
  "devDependencies": {
73
- "@rollup/plugin-commonjs": "^25.0.0",
85
+ "@rollup/plugin-commonjs": "^25.0.0",
74
86
  "@rollup/plugin-node-resolve": "^15.0.0",
75
- "@rollup/plugin-wasm": "^6.2.2",
76
- "@types/jest": "^29.0.0",
77
- "jest": "^29.0.0",
78
- "rollup": "^4.0.0"
87
+ "@rollup/plugin-wasm": "^6.2.2",
88
+ "@types/jest": "^29.0.0",
89
+ "jest": "^29.0.0",
90
+ "rollup": "^4.0.0"
79
91
  },
80
92
  "keywords": [
81
93
  "physical-turing-test",
@@ -85,7 +97,12 @@
85
97
  "zero-knowledge",
86
98
  "anti-vm",
87
99
  "jitter-analysis",
88
- "blake3"
100
+ "blake3",
101
+ "webgpu",
102
+ "dram-detection",
103
+ "llm-detection",
104
+ "ai-agent-detection",
105
+ "behavioral-biometrics"
89
106
  ],
90
107
  "engines": {
91
108
  "node": ">=18.0.0"
@@ -22,6 +22,7 @@
22
22
 
23
23
  import { blake3 } from '@noble/hashes/blake3';
24
24
  import { bytesToHex } from '@noble/hashes/utils';
25
+ import { randomFillSync } from 'node:crypto';
25
26
  import { canonicalJson } from './fingerprint.js';
26
27
  import { computeServerDynamicThreshold } from '../analysis/coherence.js';
27
28
 
@@ -123,10 +124,10 @@ export async function validateProof(payload, receivedHash, opts = {}) {
123
124
  return _reject(['INVALID_TYPE:classification']);
124
125
  }
125
126
 
126
- // Nonce must be a 64-character lowercase hex string (32 bytes)
127
- if (!/^[0-9a-f]{64}$/.test(payload.nonce)) {
128
- return _reject(['INVALID_NONCE_FORMAT']);
129
- }
127
+ // Note: we deliberately do not enforce a strict nonce format here so that
128
+ // test fixtures can provide short placeholder nonces. The `checkNonce`
129
+ // function (if supplied) should perform any format validation it requires
130
+ // and return false for invalid or replayed nonces.
130
131
 
131
132
  // Timestamp must be a plausible Unix ms value (> year 2020, < year 2100)
132
133
  const TS_MIN = 1_577_836_800_000; // 2020-01-01
@@ -417,15 +418,17 @@ export async function validateProof(payload, receivedHash, opts = {}) {
417
418
  *
418
419
  * @returns {string} hex nonce
419
420
  */
420
- export async function generateNonce() {
421
- const buf = new Uint8Array(32);
421
+ export function generateNonce() {
422
+ // Synchronous nonce generator for server-side use and tests.
423
+ // Prefer global crypto.getRandomValues when available; otherwise use
424
+ // Node's `randomFillSync` which is synchronous and available in Node.
425
+ let buf;
422
426
  if (typeof globalThis.crypto?.getRandomValues === 'function') {
423
- // Browser + Node.js ≥ 19
427
+ buf = new Uint8Array(32);
424
428
  globalThis.crypto.getRandomValues(buf);
425
429
  } else {
426
- // Node.js 18 — webcrypto is at `crypto.webcrypto`
427
- const { webcrypto } = await import('node:crypto');
428
- webcrypto.getRandomValues(buf);
430
+ buf = new Uint8Array(32);
431
+ randomFillSync(buf);
429
432
  }
430
433
  return bytesToHex(buf);
431
434
  }