Skip to content
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

fix: make secret encrypt to async #6407

Merged
merged 6 commits into from
Jan 3, 2025
Merged

fix: make secret encrypt to async #6407

merged 6 commits into from
Jan 3, 2025

Conversation

sidmorizon
Copy link
Contributor

@sidmorizon sidmorizon commented Dec 25, 2024

Summary by CodeRabbit

Based on the comprehensive summary, here are the release notes:

Release Notes

  • Encryption Improvements

    • Transitioned core encryption methods to fully asynchronous implementations
    • Enhanced security and performance of sensitive data handling
    • Updated encryption functions to use promises and async/await patterns
  • Testing Enhancements

    • Expanded test coverage for cryptographic operations
    • Updated test suites to support asynchronous encryption methods
    • Improved mocking and setup for testing environments
  • Error Handling

    • Refined error management for password and credential encryption
    • Added more robust validation for cryptographic inputs
    • Improved handling of edge cases in encryption processes
  • Performance

    • Optimized encryption and decryption workflows
    • Introduced more efficient handling of sensitive data operations

These changes represent a significant upgrade to the encryption and security infrastructure, focusing on improved asynchronous processing and more robust error management.

Copy link

codesandbox bot commented Dec 25, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link
Contributor

coderabbitai bot commented Dec 25, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request introduces a comprehensive transition from synchronous to asynchronous encryption methods across multiple files in the project. The changes primarily focus on updating encryption and decryption functions to use async/await, ensuring proper handling of sensitive data operations. Key modifications include replacing synchronous encrypt methods with encryptAsync, updating method signatures, and adding await to function calls that now return promises.

Changes

File Path Change Summary
jest-setup.js Added mocks for global variables and modules, introduced LocalStorageMock
jest.config.js Updated Jest HTML reporter page title
packages/core/@tests/coreTestsUtils.ts Made encryptImportedCredential calls asynchronous
Multiple Vault files Updated getPrivateKeyFromImported methods to be asynchronous
Multiple Secret files Transitioned encryption methods to async, added encryptAsync and encryptStringAsync
Various Service files Updated encryption and sensitive text encoding to use async methods

Sequence Diagram

sequenceDiagram
    participant Caller
    participant EncryptionMethod
    participant AsyncEncryptor

    Caller->>EncryptionMethod: Call with data
    EncryptionMethod->>AsyncEncryptor: Await encryption
    AsyncEncryptor-->>EncryptionMethod: Return encrypted data
    EncryptionMethod-->>Caller: Return promise with result
Loading

The diagram illustrates the new asynchronous flow of encryption methods, highlighting the use of await and promises in handling sensitive data encryption.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 101f26d and b997104.

📒 Files selected for processing (33)
  • jest-setup.js (1 hunks)
  • jest.config.js (1 hunks)
  • packages/core/@tests/coreTestsUtils.ts (2 hunks)
  • packages/core/src/base/CoreChainApiBase.ts (4 hunks)
  • packages/core/src/chains/ada/CoreChainSoftware.ts (2 hunks)
  • packages/core/src/chains/btc/CoreChainSoftware.ts (5 hunks)
  • packages/core/src/chains/dot/CoreChainSoftware.ts (3 hunks)
  • packages/core/src/chains/lightning/sdkLightning/account.ts (1 hunks)
  • packages/core/src/secret/__tests__/secret-aes256.test.ts (9 hunks)
  • packages/core/src/secret/__tests__/secret.test.ts (62 hunks)
  • packages/core/src/secret/bip32.ts (1 hunks)
  • packages/core/src/secret/encryptors/__tests__/aes256.test.ts (1 hunks)
  • packages/core/src/secret/encryptors/aes256.ts (9 hunks)
  • packages/core/src/secret/index.test.ts (5 hunks)
  • packages/core/src/secret/index.ts (15 hunks)
  • packages/kit-bg/src/dbs/local/LocalDbBase.ts (6 hunks)
  • packages/kit-bg/src/dbs/local/realm/RealmDBAgent.ts (1 hunks)
  • packages/kit-bg/src/migrations/v4ToV5Migration/V4MigrationForAccount.ts (2 hunks)
  • packages/kit-bg/src/migrations/v4ToV5Migration/v4local/V4LocalDbBase.ts (6 hunks)
  • packages/kit-bg/src/services/ServiceAccount/ServiceAccount.ts (3 hunks)
  • packages/kit-bg/src/services/ServiceAddressBook.ts (1 hunks)
  • packages/kit-bg/src/services/ServiceCloudBackup/index.ts (5 hunks)
  • packages/kit-bg/src/services/ServicePassword/biologyAuthUtils.ts (2 hunks)
  • packages/kit-bg/src/services/ServicePassword/index.ts (3 hunks)
  • packages/kit-bg/src/vaults/base/VaultBase.ts (1 hunks)
  • packages/kit-bg/src/vaults/impls/ada/Vault.ts (1 hunks)
  • packages/kit-bg/src/vaults/impls/algo/Vault.ts (1 hunks)
  • packages/kit-bg/src/vaults/impls/btc/Vault.ts (2 hunks)
  • packages/kit-bg/src/vaults/impls/fil/Vault.ts (2 hunks)
  • packages/kit-bg/src/vaults/impls/kaspa/Vault.ts (1 hunks)
  • packages/kit-bg/src/vaults/impls/near/Vault.ts (2 hunks)
  • packages/kit-bg/src/vaults/impls/sol/Vault.ts (1 hunks)
  • packages/kit-bg/src/vaults/impls/xrp/Vault.ts (1 hunks)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or Summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@sidmorizon sidmorizon force-pushed the fix/secret-encrypt-async branch from 27566a0 to 7448421 Compare January 2, 2025 03:08
@sidmorizon sidmorizon force-pushed the fix/secret-encrypt-async branch from 029e6f4 to ea5a439 Compare January 2, 2025 04:07
@sidmorizon sidmorizon marked this pull request as ready for review January 2, 2025 04:10
@sidmorizon sidmorizon enabled auto-merge (squash) January 2, 2025 04:10
@sidmorizon sidmorizon changed the title Fix/secret encrypt async fix: make secret encrypt to async Jan 2, 2025
@sidmorizon sidmorizon merged commit bb104ae into x Jan 3, 2025
7 of 8 checks passed
@sidmorizon sidmorizon deleted the fix/secret-encrypt-async branch January 3, 2025 03:50
Copy link

sentry-io bot commented Jan 3, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ Error: webembedApiProxy not ready yet encryptAsync(home/expo/workingdir/build/package... View Issue

Did you find this useful? React with a 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants