-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🕸️ refactor: Migrate from crypto
to Web Crypto API
#3357
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
update encrypt/decrypt forgot await
danny-avila
changed the title
Migrate from crypto to Web Crypto API
🕸️ refactor: Migrate from Aug 5, 2024
crypto
to Web Crypto API
danny-avila
approved these changes
Aug 5, 2024
6 tasks
@danny-avila Thanks! Sorry about that, I was out of town. |
danny-avila
added a commit
that referenced
this pull request
Aug 17, 2024
* 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>
1 task
kenshinsamue
pushed a commit
to intelequia/LibreChat
that referenced
this pull request
Sep 17, 2024
* 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>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Why Web Crypto API?
crypto
calls are both very heavy on the processor and blocking calls. Slowing down the entire instance.References
Node.js Support
Change Type
Please delete any irrelevant options.
Testing
Running in production for my major deploy of LibreChat.
Checklist
Please delete any irrelevant options.
Copilot Summary
This pull request introduces significant changes to the encryption and decryption methods in the codebase. The most important changes include migrating from Node's built-in
crypto
module to thewebcrypto
API, and introducing an asynchronoushashToken
function. These changes affect multiple files and functions, includingSession.js
,AuthController.js
,AuthService.js
,ActionService.js
, andcrypto.js
.Migration from
crypto
towebcrypto
:api/models/Session.js
: Replaced thecrypto
module with thehashToken
function fromcrypto.js
to hash refresh tokens. [1] [2]api/server/controllers/AuthController.js
: Replaced thecrypto
module with thehashToken
function fromcrypto.js
to hash refresh tokens. [1] [2] [3]api/server/services/AuthService.js
: Replaced thecrypto
module with thehashToken
function fromcrypto.js
to hash refresh tokens. [1] [2] [3]api/strategies/openidStrategy.js
: Replaced thecrypto
module with thehashToken
function fromcrypto.js
to hash OpenID user identifiers. [1] [2]Introduction of asynchronous encryption and decryption:
api/server/services/ActionService.js
: UpdatedcreateActionTool
,encryptMetadata
, anddecryptMetadata
functions to be asynchronous and use the newencrypt
anddecrypt
functions fromcrypto.js
. [1] [2] [3]api/server/services/PluginService.js
: UpdatedgetUserPluginAuthValue
andupdateUserPluginAuth
functions to use the new asynchronousencrypt
anddecrypt
functions fromcrypto.js
. [1] [2]api/server/services/UserService.js
: UpdatedgetUserKey
,getUserKeyExpiry
, andupdateUserKey
functions to use the new asynchronousencrypt
anddecrypt
functions fromcrypto.js
. [1] [2]api/server/utils/crypto.js
: Replaced thecrypto
module with thewebcrypto
API and made all encryption and decryption functions asynchronous. Also introduced a newhashToken
function.