@liorandb/core 1.0.1 ā 1.0.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 +1 -1
- package/src/utils/secureKey.js +17 -56
- package/test.js +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liorandb/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "LioranDB is a lightweight, local-first, peer-to-peer, file-based database with a MongoDB-style Node.js API and a simple CLI for seamless distributed development.",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
package/src/utils/secureKey.js
CHANGED
|
@@ -1,61 +1,22 @@
|
|
|
1
1
|
import crypto from "crypto";
|
|
2
2
|
import os from "os";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Returns a 256-bit master key derived from machine hardware.
|
|
6
|
+
* No env vars. No files. Machine-bound.
|
|
7
|
+
*/
|
|
6
8
|
export function getMasterKey() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
console.error("\nā After setting the variable, restart your terminal.");
|
|
22
|
-
process.exit(1);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
key = key.trim();
|
|
26
|
-
|
|
27
|
-
if (key.length !== 64) {
|
|
28
|
-
console.error("\nā ERROR: Invalid master key length.");
|
|
29
|
-
console.error("Required: 64 hex characters (256-bit)\n");
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return key;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function printSetupCommand(key) {
|
|
37
|
-
const platform = os.platform();
|
|
38
|
-
|
|
39
|
-
console.error("========================================");
|
|
40
|
-
|
|
41
|
-
if (platform === "win32") {
|
|
42
|
-
console.error("š Windows (System Environment Variable):");
|
|
43
|
-
console.error(
|
|
44
|
-
`setx ${VAR_NAME} "${key}" /M`
|
|
45
|
-
);
|
|
46
|
-
} else if (platform === "linux") {
|
|
47
|
-
console.error("š Linux (System-wide, requires sudo):");
|
|
48
|
-
console.error(
|
|
49
|
-
`echo "export ${VAR_NAME}=${key}" | sudo tee -a /etc/environment`
|
|
50
|
-
);
|
|
51
|
-
} else if (platform === "darwin") {
|
|
52
|
-
console.error("š macOS (system/global, requires sudo):");
|
|
53
|
-
console.error(
|
|
54
|
-
`echo "export ${VAR_NAME}=${key}" | sudo tee -a /etc/zshenv`
|
|
55
|
-
);
|
|
56
|
-
} else {
|
|
57
|
-
console.error(`ā Unsupported OS: ${platform}`);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
console.error("========================================");
|
|
9
|
+
const hardwareFingerprint = [
|
|
10
|
+
os.hostname(),
|
|
11
|
+
os.platform(),
|
|
12
|
+
os.arch(),
|
|
13
|
+
os.cpus()?.[0]?.model || "unknown-cpu",
|
|
14
|
+
os.cpus()?.length.toString() || "0",
|
|
15
|
+
os.totalmem().toString()
|
|
16
|
+
].join("|");
|
|
17
|
+
|
|
18
|
+
return crypto
|
|
19
|
+
.createHash("sha256")
|
|
20
|
+
.update(hardwareFingerprint)
|
|
21
|
+
.digest(); // 32 bytes
|
|
61
22
|
}
|
package/test.js
DELETED
|
File without changes
|