Safe storage: keep the sign-in's Direct Authority Mode for an added key, and recognise one key that is both posting and active
Problem and intended result
Two gaps in how safe storage (and WIF sessions) learn which keys a session holds, left by #1212 (closed) ("let a session hold both keys").
1. An added key ignores the sign-in's Direct Authority Mode
The safe-storage sign-in (packages/smart-signer/components/auth/methods/safestorage.tsx, also safestorage-key-update.tsx) has a "Direct Authority Mode" checkbox. It is passed to hb-auth as register(..., keyType, strict). Unchecked (non-strict), a key from an account listed in the user's account_auths is accepted, and hb-auth records settings.authorizedAccounts[keyType].
#1212 (closed) added a second way to register a key: SignerHbauth.registerKey in packages/smart-signer/lib/signer/signer-hbauth.ts. It is reached via addKey, which the "Add posting/active key" menu item and the Wallet's active-key notice call, and via requireOtherKey, the one-time prompt during an operation. It calls authClient.register(this.username, password, keyToUse, keyType) without strict, and hb-auth defaults strict = true.
Result: a user who signed in non-strict, with a key from an account that holds authority over theirs, cannot add the other key from that same account. hb-auth's strict check refuses it.
The other half of the same problem: checkAuth sets this.authorityUsername from settings.authorizedAccounts[keyType] for the session's key only. authorityUsername is used as the image-upload owner (apps/blog/features/post-editor/lib/utils.ts, post-form.tsx).
Intended:
- An added key is registered with the same Direct Authority setting the account's sign-in key was registered with (
getUserSettings(username).strict[sessionKeyType]). Default to strict when it is unknown. authorityUsernamereflects the key actually used to sign, where that matters.
2. One key that is both the posting and the active key is not recognised
Some accounts use the same key pair for posting and active. Denser tracks which key types a session holds (packages/smart-signer/lib/auth/login-authority.ts getLoginAuthority), not which keys they are, so:
- Safe-storage posting session whose key is also the active key:
- The Wallet shows the active-key-required notice.
- The menu offers "Add active key", which asks for the same key again.
- The header reads "Posting key" instead of "Posting + active key".
- WIF session (
signer-wif.ts):signTransactionthrowsMissingAuthorityErrorfor an active operation unless an active WIF is stored separately, although the session's key would sign it.- The WIF Wallet session is likewise treated as posting-only.
- The reverse (active session, same key as posting) has the same problem: a vote asks for the posting key.
Intended:
- When a key is entered for one type, compare its public key with the account's authorities (
packages/smart-signer/lib/validators/key-role.tsfindKeyRolereports only the strongest role; add a helper returning every role whosekey_authslist it). - If it is also the other type's key, the session holds both:
- Safe storage: register it for the other type too, with the same password and strict setting.
- WIF: store it for both types.
- The menu, badge and Wallet then show "Posting + active key" with no second prompt.
- Do this wherever a key enters:
- the safe-storage sign-in;
- the WIF sign-in;
registerKey(adding the other key);- the WIF password dialog.
- When the account's authorities cannot be read, fall back to the current per-type behaviour.
Acceptance criteria
- A non-strict safe-storage session (sign-in key from an authorized account) can add the other key from the same authorized account. hb-auth's settings show
strictfalse for both types, andauthorizedAccountsis set for the added type. - A strict session's added key is still registered strict (unchanged).
- An account whose posting and active public keys are the same, signing in with that key by safe storage or WIF (either key type chosen):
- the header and menu show "Posting + active key" and offer no add-key action;
- the Wallet opens without the active-key notice;
- a vote and a transfer both sign with no further key prompt.
- An account with distinct keys behaves as today, including #1212 (closed)'s specs (loginKeyIndicator, postingSessionActiveKey, missingAuthorityError) on both apps.
- Unit tests for the role-matching helper and for the strict propagation in
registerKey. Fixture specs for the shared-key account on Blog and Wallet: add a fixture account, or patch the recordedfind_accounts/condenser_api.get_accountsresponse so its posting and activekey_authshold the same key.
Verification
aidev test run --slot full.
Integration points
packages/smart-signer/lib/signer/signer-hbauth.ts—registerKeypasses the account's strict setting; registers a shared key for both typespackages/smart-signer/components/auth/methods/safestorage.tsx,safestorage-key-update.tsx— sign-in registers a shared key for both typespackages/smart-signer/lib/signer/signer-wif.tsand the WIF sign-in — a shared key is stored and used for both typespackages/smart-signer/lib/validators/key-role.ts— all roles a public key holdspackages/smart-signer/lib/auth/login-authority.ts/use-login-authority.ts— header, menu and Wallet reflect both keys
Scope boundary
Safe-storage and WIF key registration only. Keychain, PeakVault, MetaMask, HiveAuth and Google signers are unchanged. The owner key is out of scope.