@hive-p2p/browser 1.0.92 → 1.0.94
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/hive-p2p.min.js +2 -2
- package/package.json +1 -1
- package/services/cryptos.mjs +4 -5
package/package.json
CHANGED
package/services/cryptos.mjs
CHANGED
|
@@ -58,18 +58,17 @@ export class Argon2Unified {
|
|
|
58
58
|
this.argon2 = argon2ES6.default;
|
|
59
59
|
return this.argon2;
|
|
60
60
|
};
|
|
61
|
-
/** @param {string} pass @param {string
|
|
61
|
+
/** @param {string} pass @param {string} salt @param {number} time @param {number} mem @param {number} parallelism @param {number} type @param {number} hashLen */
|
|
62
62
|
#createArgon2Params(pass = "averylongpassword123456", salt = "saltsaltsaltsaltsalt", time = 1, mem = 2**10, parallelism = 1, type = 2, hashLen = 32) {
|
|
63
|
-
|
|
64
|
-
? salt.padEnd(16, '0').substring(0, 16) //
|
|
65
|
-
: Buffer.from(fixedSalt); // 32 bytes minimum
|
|
63
|
+
if (typeof salt !== 'string') throw new Error('salt must be a string');
|
|
66
64
|
|
|
65
|
+
const s = salt.padEnd(64, '0').substring(0, 64); // 32 bytes = 64 hex chars, we ensure it's always 32 bytes by padding/truncating
|
|
67
66
|
return {
|
|
68
67
|
type, pass, parallelism,
|
|
69
68
|
time, timeCost: time, // we preserve both for compatibility
|
|
70
69
|
mem, memoryCost: mem, // we preserve both for compatibility
|
|
71
70
|
hashLen, hashLength: hashLen, // we preserve both for compatibility
|
|
72
|
-
salt: IS_BROWSER ?
|
|
71
|
+
salt: IS_BROWSER ? s : Buffer.from(s)
|
|
73
72
|
};
|
|
74
73
|
}
|
|
75
74
|
/** @param {string} encoded - Argon2 encoded string (e.g. $argon2id$v=19$m=1048576,t=1,p=1$c2FsdHNhbHRzYWx0c2FsdHNhbHQ$UamPN/XTTX4quPewQNw4/s3y1JJeS22cRroh5l7OTMM) */
|