mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
🔐 fix: token not using webcrypto (#4005)
* fix: token * style: auth pages updated `|` color
This commit is contained in:
parent
aea01f0bc5
commit
c3dc03b063
6 changed files with 23 additions and 14 deletions
|
|
@ -102,4 +102,14 @@ async function hashToken(str) {
|
|||
return Buffer.from(hashBuffer).toString('hex');
|
||||
}
|
||||
|
||||
module.exports = { encrypt, decrypt, encryptV2, decryptV2, hashToken };
|
||||
async function getRandomValues(length) {
|
||||
if (!Number.isInteger(length) || length <= 0) {
|
||||
throw new Error('Length must be a positive integer');
|
||||
}
|
||||
|
||||
const randomValues = new Uint8Array(length);
|
||||
webcrypto.getRandomValues(randomValues);
|
||||
return Buffer.from(randomValues).toString('hex');
|
||||
}
|
||||
|
||||
module.exports = { encrypt, decrypt, encryptV2, decryptV2, hashToken, getRandomValues };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue