• Will Chen's avatar
    fix: trim whitespace from API keys and secrets in encrypt/decrypt (#2518) · 26687a6f
    Will Chen 提交于
    ## Summary
    - Trims whitespace from API keys and secrets during both encryption and
    decryption in `src/main/settings.ts`
    - Prevents issues caused by accidental leading/trailing whitespace or
    newlines in API keys (e.g., from copy-paste)
    - Adds comprehensive tests for the `encrypt`, `decrypt`, and
    `readSettings` whitespace trimming behavior
    
    ## Test plan
    - [x] Unit tests added for `encrypt()` trimming whitespace before
    encrypting
    - [x] Unit tests added for `decrypt()` trimming whitespace from both
    plaintext and electron-safe-storage secrets
    - [x] Unit tests added for `readSettings()` trimming whitespace from
    decrypted API keys
    - [x] All 784 existing tests pass
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    <!-- devin-review-badge-begin -->
    
    ---
    
    <a href="https://app.devin.ai/review/dyad-sh/dyad/pull/2518"
    target="_blank">
      <picture>
    <source media="(prefers-color-scheme: dark)"
    srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1">
    <img
    src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1"
    alt="Open with Devin">
      </picture>
    </a>
    <!-- devin-review-badge-end -->
    
    <!-- CURSOR_SUMMARY -->
    ---
    
    > [!NOTE]
    > <sup>[Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) is
    generating a summary for commit
    d24002f59f18428d78ce55d11e82d4800425d3eb. Configure
    [here](https://cursor.com/dashboard?tab=bugbot).</sup>
    <!-- /CURSOR_SUMMARY -->
    
    <!-- This is an auto-generated description by cubic. -->
    ---
    ## Summary by cubic
    Trim whitespace from API keys and secrets during encryption, decryption,
    and settings reads to prevent auth failures from copy‑pasted spaces or
    newlines. Ensures consistent storage and use of secrets across
    providers.
    
    - **Bug Fixes**
      - encrypt(): trims input before encrypting or storing plaintext
    - decrypt(): trims decrypted strings for both electron-safe-storage and
    plaintext
    - readSettings(): trims whitespace from decrypted and plaintext secrets
    - Added unit tests for encrypt, decrypt, and readSettings trimming
    behavior
    
    <sup>Written for commit d24002f59f18428d78ce55d11e82d4800425d3eb.
    Summary will update on new commits.</sup>
    
    <!-- End of auto-generated description by cubic. -->
    Co-authored-by: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
    26687a6f
名称
最后提交
最后更新
..
__tests__ 正在载入提交数据...
app 正在载入提交数据...
atoms 正在载入提交数据...
client_logic 正在载入提交数据...
components 正在载入提交数据...
constants 正在载入提交数据...
contexts 正在载入提交数据...
db 正在载入提交数据...
hooks 正在载入提交数据...
ipc 正在载入提交数据...
lib 正在载入提交数据...
main 正在载入提交数据...
neon_admin 正在载入提交数据...
pages 正在载入提交数据...
paths 正在载入提交数据...
pro 正在载入提交数据...
prompts 正在载入提交数据...
routes 正在载入提交数据...
shared 正在载入提交数据...
store 正在载入提交数据...
styles 正在载入提交数据...
supabase_admin 正在载入提交数据...
utils 正在载入提交数据...
backup_manager.ts 正在载入提交数据...
main.ts 正在载入提交数据...
preload.ts 正在载入提交数据...
renderer.tsx 正在载入提交数据...
router.ts 正在载入提交数据...