UNPKG

@metamask/eth-ledger-bridge-keyring

Version:
95 lines 4.57 kB
/// <reference types="web" /> import { AppConfigurationResponse, GetAppNameAndVersionResponse, GetPublicKeyParams, GetPublicKeyResponse, LedgerBridge, LedgerSignDelegationAuthorizationParams, LedgerSignDelegationAuthorizationResponse, LedgerSignMessageParams, LedgerSignMessageResponse, LedgerSignTransactionParams, LedgerSignTransactionResponse, LedgerSignTypedDataParams, LedgerSignTypedDataResponse } from "./ledger-bridge.cjs"; export declare enum IFrameMessageAction { LedgerIsIframeReady = "ledger-is-iframe-ready", LedgerConnectionChange = "ledger-connection-change", LedgerUnlock = "ledger-unlock", LedgerMakeApp = "ledger-make-app", LedgerUpdateTransport = "ledger-update-transport", LedgerSignTransaction = "ledger-sign-transaction", LedgerSignPersonalMessage = "ledger-sign-personal-message", LedgerSignTypedData = "ledger-sign-typed-data", LedgerGetAppNameAndVersion = "ledger-get-app-name-and-version", LedgerGetAppConfiguration = "ledger-get-app-configuration" } type IFrameMessageResponseStub<SuccessResult extends Record<string, unknown>, FailureResult = Error> = { messageId: number; } & ({ success: true; payload: SuccessResult; } | { success: false; payload: { error: FailureResult; }; }); type LedgerConnectionChangeActionResponse = { messageId: number; action: IFrameMessageAction.LedgerConnectionChange; payload: { connected: boolean; }; }; type LedgerMakeAppActionResponse = { messageId: number; action: IFrameMessageAction.LedgerMakeApp; } & ({ success: true; } | { success: false; error?: unknown; }); type LedgerUpdateTransportActionResponse = { messageId: number; action: IFrameMessageAction.LedgerUpdateTransport; success: boolean; }; type LedgerUnlockActionResponse = { action: IFrameMessageAction.LedgerUnlock; } & IFrameMessageResponseStub<GetPublicKeyResponse>; type LedgerSignTransactionActionResponse = { action: IFrameMessageAction.LedgerSignTransaction; } & IFrameMessageResponseStub<LedgerSignTransactionResponse>; type LedgerSignPersonalMessageActionResponse = { action: IFrameMessageAction.LedgerSignPersonalMessage; } & IFrameMessageResponseStub<LedgerSignMessageResponse>; type LedgerSignTypedDataActionResponse = { action: IFrameMessageAction.LedgerSignTypedData; } & IFrameMessageResponseStub<LedgerSignTypedDataResponse>; type LedgerGetAppNameAndVersionActionResponse = { action: IFrameMessageAction.LedgerGetAppNameAndVersion; } & IFrameMessageResponseStub<GetAppNameAndVersionResponse>; type LedgerGetAppConfigurationActionResponse = { action: IFrameMessageAction.LedgerGetAppConfiguration; } & IFrameMessageResponseStub<AppConfigurationResponse>; export type IFrameMessageResponse = LedgerConnectionChangeActionResponse | LedgerMakeAppActionResponse | LedgerUpdateTransportActionResponse | LedgerUnlockActionResponse | LedgerSignTransactionActionResponse | LedgerSignPersonalMessageActionResponse | LedgerSignTypedDataActionResponse | LedgerGetAppNameAndVersionActionResponse | LedgerGetAppConfigurationActionResponse; export type LedgerIframeBridgeOptions = { bridgeUrl: string; }; export declare class LedgerIframeBridge implements LedgerBridge<LedgerIframeBridgeOptions> { #private; iframe?: HTMLIFrameElement; iframeLoaded: boolean; eventListener?: (eventMessage: { origin: string; data: IFrameMessageResponse; }) => void; isDeviceConnected: boolean; currentMessageId: number; constructor(opts?: LedgerIframeBridgeOptions); init(): Promise<void>; destroy(): Promise<void>; getOptions(): Promise<LedgerIframeBridgeOptions>; setOptions(opts: LedgerIframeBridgeOptions): Promise<void>; attemptMakeApp(): Promise<boolean>; updateTransportMethod(transportType: string): Promise<boolean>; getPublicKey(params: GetPublicKeyParams): Promise<GetPublicKeyResponse>; deviceSignTransaction(params: LedgerSignTransactionParams): Promise<LedgerSignTransactionResponse>; deviceSignMessage(params: LedgerSignMessageParams): Promise<LedgerSignMessageResponse>; deviceSignTypedData(params: LedgerSignTypedDataParams): Promise<LedgerSignTypedDataResponse>; deviceSignDelegationAuthorization(_params: LedgerSignDelegationAuthorizationParams): Promise<LedgerSignDelegationAuthorizationResponse>; getAppNameAndVersion(): Promise<GetAppNameAndVersionResponse>; getAppConfiguration(): Promise<AppConfigurationResponse>; } export {}; //# sourceMappingURL=ledger-iframe-bridge.d.cts.map