@svrnsec/pulse 0.1.0 → 0.1.1
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/dist/pulse.cjs.js +14 -10
- package/dist/pulse.cjs.js.map +1 -1
- package/dist/pulse.esm.js +14 -10
- package/dist/pulse.esm.js.map +1 -1
- package/package.json +17 -17
- package/src/proof/validator.js +13 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svrnsec/pulse",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
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,30 @@
|
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
23
|
"browser": "./dist/pulse.esm.js",
|
|
24
|
-
"import":
|
|
24
|
+
"import": "./dist/pulse.esm.js",
|
|
25
25
|
"require": "./dist/pulse.cjs.js"
|
|
26
26
|
},
|
|
27
27
|
"./validator": {
|
|
28
|
-
"node":
|
|
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":
|
|
33
|
+
"node": "./src/registry/serializer.js"
|
|
34
34
|
},
|
|
35
35
|
"./middleware/express": {
|
|
36
36
|
"import": "./src/middleware/express.js",
|
|
37
|
-
"node":
|
|
37
|
+
"node": "./src/middleware/express.js"
|
|
38
38
|
},
|
|
39
39
|
"./middleware/next": {
|
|
40
40
|
"import": "./src/middleware/next.js",
|
|
41
|
-
"node":
|
|
41
|
+
"node": "./src/middleware/next.js"
|
|
42
42
|
},
|
|
43
43
|
"./react": {
|
|
44
44
|
"import": "./src/integrations/react.js"
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
|
-
"main":
|
|
47
|
+
"main": "dist/pulse.cjs.js",
|
|
48
48
|
"module": "dist/pulse.esm.js",
|
|
49
49
|
"files": [
|
|
50
50
|
"dist/",
|
|
@@ -60,22 +60,22 @@
|
|
|
60
60
|
],
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build:wasm": "bash build.sh",
|
|
63
|
-
"build:js":
|
|
64
|
-
"build":
|
|
65
|
-
"dev":
|
|
66
|
-
"test":
|
|
67
|
-
"demo":
|
|
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"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"@noble/hashes": "^1.4.0"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
|
-
"@rollup/plugin-commonjs":
|
|
73
|
+
"@rollup/plugin-commonjs": "^25.0.0",
|
|
74
74
|
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
75
|
-
"@rollup/plugin-wasm":
|
|
76
|
-
"@types/jest":
|
|
77
|
-
"jest":
|
|
78
|
-
"rollup":
|
|
75
|
+
"@rollup/plugin-wasm": "^6.2.2",
|
|
76
|
+
"@types/jest": "^29.0.0",
|
|
77
|
+
"jest": "^29.0.0",
|
|
78
|
+
"rollup": "^4.0.0"
|
|
79
79
|
},
|
|
80
80
|
"keywords": [
|
|
81
81
|
"physical-turing-test",
|
package/src/proof/validator.js
CHANGED
|
@@ -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
|
-
//
|
|
127
|
-
|
|
128
|
-
|
|
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
|
|
421
|
-
|
|
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
|
-
|
|
427
|
+
buf = new Uint8Array(32);
|
|
424
428
|
globalThis.crypto.getRandomValues(buf);
|
|
425
429
|
} else {
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
webcrypto.getRandomValues(buf);
|
|
430
|
+
buf = new Uint8Array(32);
|
|
431
|
+
randomFillSync(buf);
|
|
429
432
|
}
|
|
430
433
|
return bytesToHex(buf);
|
|
431
434
|
}
|