feat: migrate to v3 vault files - #288
Open
ahmed-tarek-salem wants to merge 3 commits into
Open
ahmed-tarek-salem wants to merge 3 commits into
ahmed-tarek-salem wants to merge 3 commits into
Conversation
ng test failed before running a single spec: the CLI's virtual test entry is rejected by the TS-inclusion check in this setup, and recent Chrome never captures under the old headless mode. Use an explicit src/test.ts main, force --headless=new, and raise karma timeouts so Argon2id unlocks (64 MB, t=3, main-thread) survive the ping window.
Detect the vault file version (legacy v1 JSON vs v3 binary Argon2id
envelope, via @qubic.org/vault) in one helper and route isVaultFile,
importVault and unlockVault through it. A v3 file carries the accounts
themselves rather than an RSA keypair, so importing one creates a fresh
session keypair and re-encrypts every seed under it; unlocking with a
v3 file is a full import (the file is the source of truth). Export
still writes v1 until every wallet ships a v3 reader.
Safety rules carried over from the ts-library-wrapper migration: the
watch-only flag is authoritative, recovered seeds must match
^[a-z]{55}$, and a vault missing seed material is refused as
INVALID VAULT FILE.
exportVault now decrypts every spendable seed with the session key and writes a v3 (Argon2id) vault through @qubic.org/vault instead of the legacy v1 file. The watch-only flag is authoritative: such accounts are written without seed material even when an encrypted seed is still stored for them. Export is refused if a spendable account has no valid seed, rather than producing a backup that cannot restore it. The v1 writer (encryptVault and its base64 helper) is removed as dead code; reading v1 files is unchanged. The read and write paths share one IVaultSeed type. Four specs cover the write path: create-then-unlock round-trip, watch-only never carries a seed, refusal without a valid seed, and rejection under a wrong password.
This branch has not been deployed
This file contains hidden or 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
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.
Adds support for v3 vault files (Argon2id, via the new
@qubic.org/vault@1.2.1dependency) to import, both unlock flows, and export. Reading detects v1 or v3 automatically, so existing v1 files keep working exactly as before. Export now writes v3: spendable seeds are decrypted with the session key and written into the vault, watch-only accounts are written without seed material (the flag is authoritative), and export is refused if a spendable account has no valid seed rather than producing a backup that cannot restore it. Since a v3 file carries the accounts rather than an RSA keypair, importing one creates a fresh session keypair and re-encrypts every seed under it.