Skip to content

fix: remove the base64 encoding for the file encryption#23

Merged
rongquan1 merged 2 commits intomainfrom
fix/oa-encrypt-base64
Mar 6, 2026
Merged

fix: remove the base64 encoding for the file encryption#23
rongquan1 merged 2 commits intomainfrom
fix/oa-encrypt-base64

Conversation

@manishdex25
Copy link
Copy Markdown
Contributor

@manishdex25 manishdex25 commented Mar 6, 2026

Summary by CodeRabbit

  • Refactoring
    • Encryption now auto-generates and displays a decryption key instead of collecting one from the user.
    • Decryption prompts now expect the hex-formatted key produced by encryption.
    • Command descriptions simplified for clarity.
    • Error messages refined to more clearly indicate when the provided key is incorrect.

@manishdex25 manishdex25 self-assigned this Mar 6, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 6, 2026

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: f57ab1d9-ba63-4498-af81-3c06ef7ae935

📥 Commits

Reviewing files that changed from the base of the PR and between 65946e9 and cb6c33a.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • package.json

📝 Walkthrough

Walkthrough

Encrypt now generates an internal hex key and prints it; decrypt accepts a provided hex key directly (no internal key derivation). Command descriptions and error text were simplified; tests and package dependency updated to reflect the new flow.

Changes

Cohort / File(s) Summary
Command Implementations
src/commands/oa/encrypt.ts, src/commands/oa/decrypt.ts
Encrypt: removed user key input, generates a key via encryptString() and prints it (using chalk); payload no longer stores a key. Decrypt: removed internal key derivation, prompts for/uses provided hex key directly; refined descriptions and error message.
Tests
tests/commands/oa/encrypt.test.ts, tests/commands/oa/decrypt.test.ts
Tests updated to remove prompt password mocks, consume the generated key returned by encryptString(), assert payload has no key, and expect adjusted decryption error wording.
Dependencies / Manifest
package.json
Bumped @trustvc/trustvc from ^2.10.0 to ^2.11.1 to match updated encryption/decryption API behavior.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EncryptCmd as Encrypt Command
    participant EncryptLib as trustvc.encryptString()
    participant FileIO
    participant DecryptCmd as Decrypt Command
    participant DecryptLib as trustvc.decryptString()

    User->>EncryptCmd: run encrypt (documentPath, outPath)
    EncryptCmd->>FileIO: read document
    FileIO-->>EncryptCmd: document content
    EncryptCmd->>EncryptLib: encryptString(document)
    EncryptLib-->>EncryptCmd: {payload, key}
    EncryptCmd->>FileIO: write payload to outPath
    EncryptCmd->>User: display generated hex key

    User->>DecryptCmd: run decrypt (payloadPath)
    DecryptCmd->>User: prompt for hex key
    User-->>DecryptCmd: provide hex key
    DecryptCmd->>FileIO: read payload
    FileIO-->>DecryptCmd: encrypted payload
    DecryptCmd->>DecryptLib: decryptString(payload, key)
    DecryptLib-->>DecryptCmd: decrypted document
    DecryptCmd->>User: show decrypted document
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A tiny hop, a hex key bright,
I sprout a token in the night.
No questions asked, it hops away—
Keep it safe, and you may play. 🥕🔐


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

@manishdex25 manishdex25 requested a review from rongquan1 March 6, 2026 04:52
@rongquan1 rongquan1 merged commit d4600e4 into main Mar 6, 2026
5 checks passed
@rongquan1 rongquan1 deleted the fix/oa-encrypt-base64 branch March 6, 2026 06:25
tradetrustimda pushed a commit that referenced this pull request Mar 10, 2026
# 1.0.0 (2026-03-10)

### Bug Fixes

* add tamper check for all blockchain functions ([#21](#21)) ([ea64760](ea64760))
* base64 file format removal ([514f18b](514f18b))
* ether signer compatibility ([a3c36de](a3c36de))
* handle network selection and add new fixtures ([#15](#15)) ([62b2031](62b2031))
* one line command and interactive terminal fix ([23fb955](23fb955))
* package lock ([2e40722](2e40722))
* remove test output files ([f63a4b3](f63a4b3))
* remove the base64 encoding for the file encryption ([#23](#23)) ([d4600e4](d4600e4))
* remove unnecessary details in the readme ([6a9b8a2](6a9b8a2))
* update cli process ([#8](#8)) ([472a9e6](472a9e6))
* updated the file handling error and folder creation for outputs ([a07c6a3](a07c6a3))
* wallet creation ([#14](#14)) ([6499276](6499276))

### Features

* add mint function command ([#1](#1)) ([22ea11f](22ea11f))
* add verify command ([#7](#7)) ([da85177](da85177))
* add w3c sign function ([#4](#4)) ([ea31015](ea31015))
* added encrypt/decrypt functions to the OA feature ([6dab3e7](6dab3e7))
* added functionality for transaction cancel ([33d73f2](33d73f2))
* added husky for lint checks ([70f3ea5](70f3ea5))
* added the gracefull error handling ([27ef0cf](27ef0cf))
* credential status command ([fb83698](fb83698))
* deploy document store command ([#16](#16)) ([bee4e7a](bee4e7a))
* document store ownership ([#20](#20)) ([a3906da](a3906da))
* fixed the prettier formats ([661c27e](661c27e))
* issue and revoke command ([#17](#17)) ([1df37ff](1df37ff))
* oa sign command ([6fc14cb](6fc14cb))
* reject commands ([#5](#5)) ([f50ce1b](f50ce1b))
* remove example files ([eecf1fb](eecf1fb))
* return commands ([#6](#6)) ([d999e6c](d999e6c))
* token registry command ([#19](#19)) ([0f5c523](0f5c523))
* transfer commands ([#3](#3)) ([8414130](8414130))
* update command process and tests ([#12](#12)) ([97986f5](97986f5))
* update the transfer commands with new input process ([#10](#10)) ([603e534](603e534))
* updated package version for trustvc ([995b43f](995b43f))
* updated packages ([7f9712c](7f9712c))
* updated the readme ([8fa493a](8fa493a))
* wallet creation encryption ([#13](#13)) ([e4d368c](e4d368c))
* wrap unwrap oa command ([#9](#9)) ([4ca75f0](4ca75f0))
@tradetrustimda
Copy link
Copy Markdown

🎉 This PR is included in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants