@contentgrowth/content-auth 0.0.4 → 0.1.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/dist/backend/index.js
CHANGED
|
@@ -115,8 +115,21 @@ async function hashPassword(password) {
|
|
|
115
115
|
const hashB64 = btoa(String.fromCharCode(...new Uint8Array(hashBuffer)));
|
|
116
116
|
return `pbkdf2:100000:${saltB64}:${hashB64}`;
|
|
117
117
|
}
|
|
118
|
-
async function verifyPassword(
|
|
119
|
-
|
|
118
|
+
async function verifyPassword(passwordOrData, storedHash) {
|
|
119
|
+
let password;
|
|
120
|
+
let hash;
|
|
121
|
+
if (typeof passwordOrData === "object" && passwordOrData !== null) {
|
|
122
|
+
password = passwordOrData.password;
|
|
123
|
+
hash = passwordOrData.hash;
|
|
124
|
+
} else {
|
|
125
|
+
password = passwordOrData;
|
|
126
|
+
hash = storedHash;
|
|
127
|
+
}
|
|
128
|
+
if (!hash) {
|
|
129
|
+
console.error("[Auth] verifyPassword called with empty/undefined hash");
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
const parts = hash.split(":");
|
|
120
133
|
if (parts.length !== 4) return false;
|
|
121
134
|
const [alg, iterationsStr, saltB64, hashB64] = parts;
|
|
122
135
|
if (alg !== "pbkdf2") return false;
|
package/dist/index.js
CHANGED