import * as polkadot_api from 'polkadot-api'; import { TerminalAdapter, UserSession } from '@parity/product-sdk-terminal'; import { AllocatableResource, OnExistingAllowancePolicy } from '@parity/product-sdk-terminal/host'; export { AllocatableResource, OnExistingAllowancePolicy } from '@parity/product-sdk-terminal/host'; /** * Outcome of one allocation. We don't read the inner `Allocated` payload * (allowance slot keys, derivation secrets) — the host stores them and uses * them transparently on subsequent calls. We just need the tag to know * whether the allocation succeeded. */ type AllocationOutcome = { tag: "Allocated"; value: unknown; } | { tag: "Rejected"; value: undefined; } | { tag: "NotAvailable"; value: undefined; }; /** Tag-only view, handy for downstream code that doesn't care about payloads. */ type ResourceTag = AllocatableResource["tag"]; /** * Default mobile-granted resource set for a CLI product account: write access * to the statement store + Bulletin, plus PGAS sponsoring for the default * (index 0) product account. */ declare const DEFAULT_RESOURCES: AllocatableResource[]; /** * The BulletInAllowance resource singleton. Callers that only need this one * resource (e.g. createSlotAccountSigner) use this constant instead of * constructing the literal — keeps the SSO codec spelling in one place. */ declare const BULLETIN_RESOURCE: AllocatableResource; /** * Send a `host_request_resource_allocation` request over the user's active * session. The host (mobile wallet) prompts the user to approve and returns * one outcome per requested resource in order. Granted key material is cached * to disk by the terminal facet (`{productId}_AllowanceKeys.json`) so subsequent * calls (and the storage-signer reader) find it without a second wallet prompt. * * Throws on transport-level failures (Statement Store unreachable, encryption * error, etc.). Per-resource refusals are reported as `Rejected`/`NotAvailable` * outcomes — callers inspect the array to decide whether to proceed. * * `onExisting` is pinned to "Ignore": return existing cached keys if any, else * allocate a new slot. Auto-pick would give "Increase" when all slot-table * resources are already cached, which re-prompts the user unnecessarily. */ declare function requestResourceAllocation(session: UserSession, adapter: TerminalAdapter, productId: string, resources?: AllocatableResource[], onExisting?: OnExistingAllowancePolicy): Promise; interface AllocationSummary { granted: AllocatableResource[]; rejected: AllocatableResource[]; unavailable: AllocatableResource[]; } /** * Bucket allocation outcomes by tag. Order-sensitive: `outcomes[i]` maps to * `resources[i]`. Outcomes without a matching resource are silently dropped. */ declare function summarizeOutcomes(outcomes: AllocationOutcome[], resources: AllocatableResource[]): AllocationSummary; /** * Read a previously allocated slot signer from the terminal cache * (`{productId}_AllowanceKeys.json`) written by `requestResourceAllocation`. * * Returns `null` on a cache miss — never triggers a phone prompt. Use this * instead of `adapter.allowance.getBulletinSigner()` when the allocation has * already been claimed in the same session (e.g. after a successful * `requestResourceAllocation(DEFAULT_RESOURCES)` call) so that step 2 of the * login flow is a guaranteed cache-hit with zero additional wallet interaction. * * Throws only for SmartContractAllowance / AutoSigning resources (not applicable * to BulletInAllowance). Returns `null` for BulletInAllowance when no cached * entry exists. */ declare function createSlotAccountSigner(adapter: TerminalAdapter, resource: AllocatableResource, productId: string): Promise; export { type AllocationOutcome, type AllocationSummary, BULLETIN_RESOURCE, DEFAULT_RESOURCES, type ResourceTag, createSlotAccountSigner, requestResourceAllocation, summarizeOutcomes };