mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
🕸️ refactor: Migrate from crypto to Web Crypto API (#3357)
* move crypto to async webcrypto update encrypt/decrypt forgot await * chore: import order - openidStrategy.js * chore: import order - Session.js * chore: import order - AuthController.js * Update AuthService.js --------- Co-authored-by: Danny Avila <danacordially@gmail.com>
This commit is contained in:
parent
b6fe7e5570
commit
3e0f95458f
10 changed files with 108 additions and 51 deletions
|
|
@ -1,4 +1,3 @@
|
|||
const crypto = require('crypto');
|
||||
const bcrypt = require('bcryptjs');
|
||||
const { SystemRoles, errorsToString } = require('librechat-data-provider');
|
||||
const {
|
||||
|
|
@ -12,6 +11,7 @@ const {
|
|||
} = require('~/models/userMethods');
|
||||
const { sendEmail, checkEmailConfig } = require('~/server/utils');
|
||||
const { registerSchema } = require('~/strategies/validators');
|
||||
const { hashToken } = require('~/server/utils/crypto');
|
||||
const isDomainAllowed = require('./isDomainAllowed');
|
||||
const Token = require('~/models/schema/tokenSchema');
|
||||
const Session = require('~/models/Session');
|
||||
|
|
@ -34,7 +34,7 @@ const genericVerificationMessage = 'Please check your email to verify your email
|
|||
*/
|
||||
const logoutUser = async (userId, refreshToken) => {
|
||||
try {
|
||||
const hash = crypto.createHash('sha256').update(refreshToken).digest('hex');
|
||||
const hash = await hashToken(refreshToken);
|
||||
|
||||
// Find the session with the matching user and refreshTokenHash
|
||||
const session = await Session.findOne({ user: userId, refreshTokenHash: hash });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue