import { TerminalAdapter, UserSession } from '@parity/product-sdk-terminal'; import { PolkadotSigner } from 'polkadot-api'; import { A as AllocatableResource, O as OnExistingAllowancePolicy, a as AllocationOutcome } from './allocations-CEPeZr6T.js'; /** * Per-product configuration injected into `createAuthClient`. Lifting the * sign-in glue out of playground-cli (issue #411) means the env-specific * constants playground hard-coded in its `config.ts` (DAPP_ID, product id, * metadata URL, People-chain endpoints) become consumer-supplied so the same * package serves `playground` and `dot` (and future products) unchanged. */ interface AuthConfig { /** The dApp identity string. Scopes the on-disk session namespace * (`~/.polkadot-apps/${dappId}_*`) and the SSO pairing — each product * gets its own, independently-revocable session. */ dappId: string; /** Product id used to derive the product account (`/product/{productId}/{index}`). */ productId: string; /** Derivation index of the product account (0 = default). */ derivationIndex: number; /** Wallet-facing app name shown on the Sign-In screen (sent inline at pairing). */ hostName: string; /** Host app version sent inline at pairing. */ hostVersion: string; /** People-parachain RPC endpoints the terminal adapter connects to. */ peopleEndpoints: string[]; } /** * The three addresses we surface from a paired session. * * - `rootAddress` — SS58 of `session.rootAccountId`, the `rootUserAccountId` * the mobile app sent over the SSO handshake (bare-mnemonic sr25519 root on * current mobile builds). Keyed by `Resources.Consumers` on the People * parachain, so it's the right input for `lookupUsername`. * - `productAddress` — SS58 of the product account derived via * `product/{productId}/{index}` from `rootAccountId`. This is what actually * signs on-chain transactions from the CLI. * - `productH160` — the same product pubkey as a 20-byte EVM address (Revive / * contracts view). Derived from the SAME pubkey as `productAddress`. */ interface SessionAddresses { rootAddress: string; productAddress: string; productH160: `0x${string}`; } type ConnectResult = { kind: "existing"; address: string; addresses: SessionAddresses; } | { kind: "qr"; qrCode: string; login: LoginHandle; }; type LoginStatus = { step: "waiting"; } | { step: "paired"; } | { step: "pending"; stage: string; } | { step: "success"; address: string; addresses: SessionAddresses; } | { step: "error"; message: string; }; interface LoginHandle { adapter: TerminalAdapter; /** The authenticate() promise — already running since connect(). */ authPromise: ReturnType; } /** * A session signer bundle — the signer plus an explicit `destroy()` that tears * down the long-lived adapter the signer depends on. Callers MUST invoke * `destroy()` once done — the WebSocket keeps the event loop alive. * * `adapter` is exposed so callers that need to send a host request (e.g. * `requestResourceAllocation`) can pass it without creating a second WebSocket. */ interface SessionHandle { address: string; addresses: SessionAddresses; signer: PolkadotSigner; userSession: UserSession; adapter: TerminalAdapter; destroy(): void; } type LogoutStatus = { step: "disconnecting"; address: string; } | { step: "success"; address: string; } | { step: "partial"; address: string; reason: string; } | { step: "error"; message: string; }; interface LogoutHandle { adapter: TerminalAdapter; address: string; session: UserSession; } /** The product-bound auth surface returned by `createAuthClient`. */ interface AuthClient { connect(): Promise; waitForLogin(handle: LoginHandle, onStatus: (status: LoginStatus) => void): Promise; getSessionSigner(): Promise; findSession(): Promise; waitForLogout(handle: LogoutHandle, onStatus: (status: LogoutStatus) => void): Promise; requestAllocation(session: UserSession, adapter: TerminalAdapter, resources?: AllocatableResource[], onExisting?: OnExistingAllowancePolicy): Promise; clearLocalAppStorage(dir?: string): Promise; } /** * Build an auth client bound to a product's `AuthConfig`. All adapter creation, * address derivation, and session-storage scoping read from `config`, so the * same code serves any product. */ declare function createAuthClient(config: AuthConfig): AuthClient; export { type AuthClient as A, type ConnectResult as C, type LoginHandle as L, type SessionAddresses as S, type AuthConfig as a, type LoginStatus as b, type LogoutHandle as c, type LogoutStatus as d, type SessionHandle as e, createAuthClient as f };