@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
34 lines • 1.92 kB
TypeScript
import { Observable } from "rxjs";
import { OnboardingState } from "./extractOnboardingState";
export type OnboardingStatePollingResult = {
onboardingState: OnboardingState | null;
allowedError: Error | null;
lockedDevice: boolean;
};
export type GetOnboardingStatePollingResult = Observable<OnboardingStatePollingResult>;
export type GetOnboardingStatePollingArgs = {
deviceId: string;
deviceName: string | null;
pollingPeriodMs: number;
transportAbortTimeoutMs?: number;
safeGuardTimeoutMs?: number;
allowedErrorChecks?: ((error: unknown) => boolean)[];
};
/**
* Polls the device onboarding state at a given frequency
*
* @param deviceId A device id
* @param pollingPeriodMs The period in ms after which the device onboarding state is fetched again
* @param transportAbortTimeoutMs Depending on the transport implementation, an "abort timeout" will be set (and throw an error) when:
* - opening a transport instance
* - on called commands (where `getVersion`)
* Default to (pollingPeriodMs - 100) ms
* @param safeGuardTimeoutMs For Transport implementations not implementing an "abort timeout", a timeout will be triggered (and throw an error) at this function call level
* @returns An Observable that polls the device onboarding state and pushes an object containing:
* - onboardingState: the device state during the onboarding
* - allowedError: any error that is allowed and does not stop the polling
* - lockedDevice: a boolean set to true if the device is currently locked, false otherwise
*/
export declare const getOnboardingStatePolling: ({ deviceId, deviceName, pollingPeriodMs, transportAbortTimeoutMs, safeGuardTimeoutMs, allowedErrorChecks, }: GetOnboardingStatePollingArgs) => GetOnboardingStatePollingResult;
export declare const isAllowedOnboardingStatePollingError: (error: unknown) => boolean;
//# sourceMappingURL=getOnboardingStatePolling.d.ts.map