Feature: Key backup import on first-run setup #40

Closed
opened 2026-04-26 16:45:59 +00:00 by icub3d · 0 comments
Owner

Migrated from GitHub issue icub3d/decentcom#51
Original Author: @icub3d
Original Date: 2026-04-16T18:01:30Z


Feature: Key backup import on first-run setup

Overview

The first-run Setup screen currently offers two options: "Create New Identity" (generates a new key + seed phrase) and "Import Existing" (restores from a 24-word BIP39 mnemonic). Users who have a .dckb encrypted key backup file (created by the key recovery feature, #26) have no way to use it during initial setup — they are forced to enter a seed phrase they may not have. This feature adds a third path on the Setup screen: restore from an encrypted backup file.

Background

The key recovery feature (#26) shipped KeyImport as a settings panel for users who are already set up. However, the most common recovery scenario is a fresh device with no keys — exactly when the Settings panel is inaccessible. The Setup page in client/src/pages/Setup.tsx controls the first-run flow and needs to be extended to surface the backup import option.

The Tauri IPC commands key_backup_read_pubkey and key_import already exist and work correctly; this feature is primarily a UI change.

Requirements

  • The Setup screen choice view includes a third option: "Restore from Backup File"
  • Selecting it opens a backup-import flow: file picker → passphrase input → import
  • The selected file's public key is displayed before the user commits to importing (same preview as KeyImport in settings)
  • On successful import the setup flow completes normally (calls onComplete)
  • The flow works both on first launch (no existing identity) and when adding an additional account
  • Error states (wrong passphrase, invalid file) are surfaced clearly to the user
  • A back button returns the user to the choice view without side effects

Design

API / Interface Changes

No new Tauri IPC commands needed. Reuses key_backup_read_pubkey and key_import already registered in lib.rs.

Data Model Changes

None.

Component Changes

client/src/pages/Setup.tsx — add a "backup" view to the existing view state union and render the backup import flow. Extend SetupProps with an onImportBackup callback (or call the identity service directly from within Setup).

client/src/components/backup/KeyImport.tsx — can be reused as-is or lightly adapted (it already has file picker, pubkey preview, passphrase input, and error feedback). The main change is wiring onImported to call onComplete.

client/src/services/identity.ts — no changes needed; keyImport and keyBackupReadPubkey are already exported.

Task List

  • Add "backup" to the view state union in Setup.tsx
  • Add a "Restore from Backup File" button to the choice view in Setup.tsx
  • Render the backup import view when view === "backup" — either inline or by embedding KeyImport with an onImportedonComplete callback
  • Ensure the Back button in the backup view returns to "choice" without leaving partial state
  • Update SeedPhrase.test.tsx / add Setup.test.tsx to cover the new flow

Test List

  • Unit test: Setup renders the "Restore from Backup File" button on the choice view
  • Unit test: clicking "Restore from Backup File" transitions to the backup import view
  • Unit test: back button from backup view returns to choice view
  • Unit test: successful import calls onComplete
  • Manual test: clear all keychain entries, launch the app, restore from a .dckb file, confirm identity loads and authentication to a server works

Open Questions

  • Should KeyImport be reused directly in Setup.tsx, or should a slimmed-down variant be created to avoid the settings-panel styling in the setup context?
  • Should the "Import Existing" (seed phrase) and "Restore from Backup" options be presented at the same level, or should "Import Existing" become a sub-menu with both options?
**Migrated from GitHub issue icub3d/decentcom#51** **Original Author:** @icub3d **Original Date:** 2026-04-16T18:01:30Z --- # Feature: Key backup import on first-run setup ## Overview The first-run Setup screen currently offers two options: "Create New Identity" (generates a new key + seed phrase) and "Import Existing" (restores from a 24-word BIP39 mnemonic). Users who have a `.dckb` encrypted key backup file (created by the key recovery feature, #26) have no way to use it during initial setup — they are forced to enter a seed phrase they may not have. This feature adds a third path on the Setup screen: restore from an encrypted backup file. ## Background The key recovery feature (#26) shipped `KeyImport` as a settings panel for users who are already set up. However, the most common recovery scenario is a fresh device with no keys — exactly when the Settings panel is inaccessible. The `Setup` page in `client/src/pages/Setup.tsx` controls the first-run flow and needs to be extended to surface the backup import option. The Tauri IPC commands `key_backup_read_pubkey` and `key_import` already exist and work correctly; this feature is primarily a UI change. ## Requirements - [x] The Setup screen choice view includes a third option: "Restore from Backup File" - [x] Selecting it opens a backup-import flow: file picker → passphrase input → import - [x] The selected file's public key is displayed before the user commits to importing (same preview as `KeyImport` in settings) - [x] On successful import the setup flow completes normally (calls `onComplete`) - [x] The flow works both on first launch (no existing identity) and when adding an additional account - [x] Error states (wrong passphrase, invalid file) are surfaced clearly to the user - [x] A back button returns the user to the choice view without side effects ## Design ### API / Interface Changes No new Tauri IPC commands needed. Reuses `key_backup_read_pubkey` and `key_import` already registered in `lib.rs`. ### Data Model Changes None. ### Component Changes **`client/src/pages/Setup.tsx`** — add a `"backup"` view to the existing `view` state union and render the backup import flow. Extend `SetupProps` with an `onImportBackup` callback (or call the identity service directly from within Setup). **`client/src/components/backup/KeyImport.tsx`** — can be reused as-is or lightly adapted (it already has file picker, pubkey preview, passphrase input, and error feedback). The main change is wiring `onImported` to call `onComplete`. **`client/src/services/identity.ts`** — no changes needed; `keyImport` and `keyBackupReadPubkey` are already exported. ## Task List - [x] Add `"backup"` to the `view` state union in `Setup.tsx` - [x] Add a "Restore from Backup File" button to the choice view in `Setup.tsx` - [x] Render the backup import view when `view === "backup"` — either inline or by embedding `KeyImport` with an `onImported` → `onComplete` callback - [x] Ensure the Back button in the backup view returns to `"choice"` without leaving partial state - [x] Update `SeedPhrase.test.tsx` / add `Setup.test.tsx` to cover the new flow ## Test List - [x] Unit test: Setup renders the "Restore from Backup File" button on the choice view - [x] Unit test: clicking "Restore from Backup File" transitions to the backup import view - [x] Unit test: back button from backup view returns to choice view - [x] Unit test: successful import calls `onComplete` - [ ] Manual test: clear all keychain entries, launch the app, restore from a `.dckb` file, confirm identity loads and authentication to a server works ## Open Questions - Should `KeyImport` be reused directly in `Setup.tsx`, or should a slimmed-down variant be created to avoid the settings-panel styling in the setup context? - Should the "Import Existing" (seed phrase) and "Restore from Backup" options be presented at the same level, or should "Import Existing" become a sub-menu with both options?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
icub3d/decentcom#40
No description provided.