mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 16:27:40 +00:00
attempt to fix crypto.subtle issue
This commit is contained in:
@@ -13,10 +13,10 @@ export const checkIsPasswordBreached = async (password: string) => {
|
|||||||
const encodedPwd = textEncoder.encode(password);
|
const encodedPwd = textEncoder.encode(password);
|
||||||
console.log("encodedPwd:", encodedPwd); // delete later!!!
|
console.log("encodedPwd:", encodedPwd); // delete later!!!
|
||||||
|
|
||||||
const hashBuffer = await crypto.subtle.digest("SHA-1", encodedPwd); // returns promise
|
const hash = crypto.createHash("sha1").update(encodedPwd).digest();
|
||||||
console.log("hashBuffer:", hashBuffer); // delete later!!!
|
console.log("hash:", hash); // delete later!!!
|
||||||
|
|
||||||
const hashedPwd = Array.from(new Uint8Array(hashBuffer))
|
const hashedPwd = Array.from(new Uint8Array(hash))
|
||||||
.map((byte) => byte.toString(16).padStart(2, "0"))
|
.map((byte) => byte.toString(16).padStart(2, "0"))
|
||||||
.join("")
|
.join("")
|
||||||
.toUpperCase();
|
.toUpperCase();
|
||||||
@@ -33,7 +33,8 @@ export const checkIsPasswordBreached = async (password: string) => {
|
|||||||
console.log("isBreachedPassword:", isBreachedPassword); // delete later!!!
|
console.log("isBreachedPassword:", isBreachedPassword); // delete later!!!
|
||||||
|
|
||||||
// Clear the hashed password from memory
|
// Clear the hashed password from memory
|
||||||
crypto.subtle.digest("SHA-1", encodedPwd);
|
const zeroBuffer = new Uint8Array(encodedPwd.length);
|
||||||
|
encodedPwd.set(zeroBuffer);
|
||||||
|
|
||||||
return isBreachedPassword;
|
return isBreachedPassword;
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
|
|||||||
Reference in New Issue
Block a user