inslash 1.0.2 → 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/LICENSE +1 -1
- package/package.json +39 -15
- package/cstest.js +0 -49
- package/test.js +0 -22
- /package/{script.js → index.js} +0 -0
package/LICENSE
CHANGED
package/package.json
CHANGED
|
@@ -1,15 +1,39 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "inslash",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "inslash",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "A modern, upgradeable, and secure password hashing utility with passport encoding and hash ancestry.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "node cstest.js"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"password",
|
|
12
|
+
"hash",
|
|
13
|
+
"security",
|
|
14
|
+
"crypto",
|
|
15
|
+
"salt",
|
|
16
|
+
"pepper",
|
|
17
|
+
"upgradeable",
|
|
18
|
+
"passport",
|
|
19
|
+
"nodejs"
|
|
20
|
+
],
|
|
21
|
+
"author": "Reshuk Sapkota",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/reshuk-code/inslash"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/reshuk-code/inslash/issues"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/reshuk-code/inslash#readme",
|
|
31
|
+
"files": [
|
|
32
|
+
"index.js",
|
|
33
|
+
"README.md",
|
|
34
|
+
"LICENSE"
|
|
35
|
+
],
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=16"
|
|
38
|
+
}
|
|
39
|
+
}
|
package/cstest.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
const { hash, verify } = require("./script");
|
|
2
|
-
|
|
3
|
-
const SECRET_KEY = "supersecret";
|
|
4
|
-
|
|
5
|
-
// 1. Rainbow Table Attack
|
|
6
|
-
(async () => {
|
|
7
|
-
const a = await hash("password123", SECRET_KEY);
|
|
8
|
-
const b = await hash("password123", SECRET_KEY);
|
|
9
|
-
console.log("Rainbow Table Test:", a.hash !== b.hash ? "PASS" : "FAIL");
|
|
10
|
-
|
|
11
|
-
// 2. Brute Force Attack (timing)
|
|
12
|
-
console.time("Low Iterations");
|
|
13
|
-
await hash("password123", SECRET_KEY, { iterations: 1000 });
|
|
14
|
-
console.timeEnd("Low Iterations");
|
|
15
|
-
|
|
16
|
-
console.time("High Iterations");
|
|
17
|
-
await hash("password123", SECRET_KEY, { iterations: 200_000 });
|
|
18
|
-
console.timeEnd("High Iterations");
|
|
19
|
-
|
|
20
|
-
// 3. Timing Attack (should use timingSafeEqual)
|
|
21
|
-
const v = await verify("password123", a.passport, SECRET_KEY);
|
|
22
|
-
console.log("Timing Safe Equal Test:", v.valid ? "PASS" : "FAIL");
|
|
23
|
-
|
|
24
|
-
// 4. Salt Storage
|
|
25
|
-
console.log("Salt Unique Test:", a.salt !== b.salt ? "PASS" : "FAIL");
|
|
26
|
-
|
|
27
|
-
// 5. Pepper Security
|
|
28
|
-
process.env.HASH_PEPPER = "pepper";
|
|
29
|
-
const withPepper = await hash("password123", SECRET_KEY);
|
|
30
|
-
process.env.HASH_PEPPER = "";
|
|
31
|
-
const vPepper = await verify("password123", withPepper.passport, SECRET_KEY);
|
|
32
|
-
console.log("Pepper Security Test:", vPepper.valid ? "FAIL" : "PASS");
|
|
33
|
-
|
|
34
|
-
// 6. Upgrade Path
|
|
35
|
-
const vUpgrade = await verify("password123", a.passport, SECRET_KEY, { iterations: 200_000 });
|
|
36
|
-
console.log("Upgrade Path Test:", vUpgrade.needsUpgrade ? "PASS" : "FAIL");
|
|
37
|
-
|
|
38
|
-
// 7. Input Validation
|
|
39
|
-
try {
|
|
40
|
-
await hash(null, SECRET_KEY);
|
|
41
|
-
console.log("Null Input Test: FAIL");
|
|
42
|
-
} catch {
|
|
43
|
-
console.log("Null Input Test: PASS");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// 8. Collision Resistance
|
|
47
|
-
const c = await hash("passwordABC", SECRET_KEY);
|
|
48
|
-
console.log("Collision Resistance Test:", a.hash !== c.hash ? "PASS" : "FAIL");
|
|
49
|
-
})();
|
package/test.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const { hash, verify } = require("./script");
|
|
2
|
-
|
|
3
|
-
const SECRET_KEY = process.env.HASH_SECRET || "abcd";
|
|
4
|
-
|
|
5
|
-
// create hash
|
|
6
|
-
(async () => {
|
|
7
|
-
const result = await hash("Happy", SECRET_KEY, {
|
|
8
|
-
iterations: 150_000
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
console.log(result);
|
|
12
|
-
|
|
13
|
-
// verify
|
|
14
|
-
const verifyResult = await verify(
|
|
15
|
-
"Happy",
|
|
16
|
-
result.passport, // <-- use passport, not salt/hash
|
|
17
|
-
SECRET_KEY,
|
|
18
|
-
{ iterations: result.iterations }
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
console.log(verifyResult); // { valid: true, needsUpgrade: false, upgradedPassport: null }
|
|
22
|
-
})();
|
/package/{script.js → index.js}
RENAMED
|
File without changes
|