import type { MemWalCredentials } from "./auth.js"; export type RecoveryOutcome = /** Nothing was pending. The overwhelmingly common case. */ "no-pending" /** Key was registered; `credentials.json` has been rebuilt from it. */ | "recovered" /** A newer sign-in already happened — the pending key is stale. */ | "superseded" /** Relayer would not authenticate the key. Deliberately non-destructive. */ | "rejected" /** Relayer unreachable or erroring. Record kept for a later attempt. */ | "unavailable"; export interface RecoveryResult { outcome: RecoveryOutcome; /** Set when a key may be registered on-chain but is not usable locally. */ strandedPublicKey?: string; credentials?: MemWalCredentials; replacementNotice?: string; } /** * Build the exact string the relayer will rebuild and verify against. * * `services/server/src/auth.rs` calls itself the single source of truth for * this format, and it is reproduced here rather than imported because the two * live in different languages. That duplication is the risk: get it subtly * wrong — a trimmed trailing separator, a missing empty field — and every * recovery attempt fails with an opaque 401 that no type checker would have * caught. Exported so a test can pin it against the identical literal asserted * in `routes::accounts::tests::whoami_recovery_request_canonical_message_is_stable`. * * `accountId` is empty for recovery: not knowing it is the reason we are here, * and the server defaults its hint to `""` when the header is absent. */ export declare function canonicalRequestMessage(parts: { timestamp: string; method: string; path: string; bodyHash: string; nonce: string; accountId?: string; }): string; /** sha256 of an empty body. A GET sends none; the server hashes it anyway. */ export declare const EMPTY_BODY_SHA256: string; /** * Attempt to turn a stranded pending login into usable credentials. * * Never throws, and never deletes a record that might still be recoverable — * a stranded key is the user's paid-for property, and the cost of keeping it * around until its TTL is a file that grants nothing. */ export declare function recoverPendingLogin(): Promise; /** * The line to show the user when a stranded key could not be reclaimed. * * Names the key so the user can find the registration they paid for in the * dashboard. Signing in again reuses this key, and the dashboard's * `add_delegate_key` aborts on one that is already registered, so a key the * user approved has to be removed there before a new sign-in can finish. A * user told only "login failed" can do neither. */ export declare function formatStrandedLoginNotice(result: RecoveryResult): string | null; //# sourceMappingURL=recovery.d.ts.map