/** * Identity resolution for People chain (Resources pallet). * * A standalone module that queries People chain RPC endpoints using fetch(). * No smoldot dependency. The caller provides an IdentityEncoder (typically * the WASM IdentityHandle) for key building and SCALE decoding. * * @example * ```ts * import { resolveUsername, POLKADOT_PEOPLE_TRANSPORT } from "@polkadot-apps/host-sdk/identity"; * // encoder is the WASM IdentityHandle instance * const accountId = await resolveUsername("alice", POLKADOT_PEOPLE_TRANSPORT, encoder); * ``` */ /** Transport backed by direct HTTP fetch to People chain RPC nodes. */ export type PeopleChainEndpoints = { kind: "fetch"; endpoints: string[]; }; /** * Transport for People chain RPC calls. * * - "fetch": tries the listed endpoints in order until one succeeds. * - "custom": delegates to the provided send function. */ export type IdentityTransport = PeopleChainEndpoints | { kind: "custom"; send: (request: string) => Promise; }; /** Decoded consumer info from Resources.Consumers storage. */ export interface ConsumerInfo { identifierKey: Uint8Array; fullUsername: string | null; liteUsername: string; credibility: { type: "Lite"; } | { type: "Person"; alias: Uint8Array; lastUpdate: number; }; } /** * Pure encoding and decoding helpers for identity storage keys and responses. * * Implemented by the WASM IdentityHandle. Tests may pass a mock. */ export interface IdentityEncoder { /** Build the state_getStorage hex key for Resources.UsernameOwnerOf. */ usernameOwnerOfKey(username: string): string; /** Build the state_getStorage hex key for Resources.Consumers. */ consumersKey(accountIdHex: string): string; /** Decode SCALE Option bytes → 0x-prefixed hex string or null. */ decodeAccountOfUsername(data: Uint8Array): string | null; /** Decode SCALE ConsumerInfo bytes → ConsumerInfo or null. */ decodeConsumerInfo(data: Uint8Array): ConsumerInfo | null; } /** RPC endpoints for the Polkadot People chain. */ export declare const POLKADOT_PEOPLE_TRANSPORT: PeopleChainEndpoints; /** RPC endpoints for the Paseo People chain (testnet). */ export declare const PASEO_PEOPLE_TRANSPORT: PeopleChainEndpoints; /** * Resolve a username to its owner account ID on the People chain. * * @param username - The username to look up. ASCII, [a-z0-9.], 1–32 chars. * Case-insensitive: the string is lowercased before querying. * @param transport - RPC transport to use for the state_getStorage call. * @param encoder - IdentityEncoder (WASM IdentityHandle or mock). * @returns The 0x-prefixed hex account ID, or null if the username is not * registered. * @throws If the username is invalid, the RPC call fails, or the SCALE data * is malformed. */ export declare function resolveUsername(username: string, transport: IdentityTransport, encoder: IdentityEncoder): Promise; /** * Resolve an account's identity info from the People chain. * * @param accountIdHex - The 0x-prefixed 64-char hex account ID to look up. * @param transport - RPC transport to use for the state_getStorage call. * @param encoder - IdentityEncoder (WASM IdentityHandle or mock). * @returns A ConsumerInfo object, or null if the account has no identity. * @throws If the account ID is invalid, the RPC call fails, or the SCALE data * is malformed. */ export declare function resolveIdentity(accountIdHex: string, transport: IdentityTransport, encoder: IdentityEncoder): Promise; //# sourceMappingURL=identity.d.ts.map