{"version":3,"file":"ledger-bridge.cjs","sourceRoot":"","sources":["../src/ledger-bridge.ts"],"names":[],"mappings":"","sourcesContent":["import type LedgerHwAppEth from '@ledgerhq/hw-app-eth';\nimport type Transport from '@ledgerhq/hw-transport';\nimport type { EIP712Message } from '@ledgerhq/types-live';\n\nexport type GetPublicKeyParams = { hdPath: string };\nexport type GetPublicKeyResponse = Awaited<\n  ReturnType<LedgerHwAppEth['getAddress']>\n>;\n\nexport type LedgerSignTransactionParams = { hdPath: string; tx: string };\nexport type LedgerSignTransactionResponse = Awaited<\n  ReturnType<LedgerHwAppEth['signTransaction']>\n>;\n\nexport type LedgerSignMessageParams = { hdPath: string; message: string };\nexport type LedgerSignMessageResponse = Awaited<\n  ReturnType<LedgerHwAppEth['signPersonalMessage']>\n>;\n\nexport type LedgerSignTypedDataParams = {\n  hdPath: string;\n  message: EIP712Message;\n};\nexport type LedgerSignTypedDataResponse = Awaited<\n  ReturnType<LedgerHwAppEth['signEIP712HashedMessage']>\n>;\n\nexport type LedgerSignDelegationAuthorizationParams = {\n  hdPath: string;\n  chainId: number;\n  contractAddress: string;\n  nonce: number;\n};\n\n// TODO: Replace with 7702 return type\nexport type LedgerSignDelegationAuthorizationResponse = Awaited<{\n  s: string;\n  v: string;\n  r: string;\n}>;\n\nexport type GetAppNameAndVersionResponse = {\n  appName: string;\n  version: string;\n};\n\nexport type AppConfigurationResponse = {\n  arbitraryDataEnabled: number; // this is the blind signing support\n  erc20ProvisioningNecessary: number;\n  starkEnabled: number;\n  starkv2Supported: number;\n  version: string;\n};\n\nexport type LedgerBridgeOptions = Record<string, unknown>;\n\nexport type LedgerBridge<T extends LedgerBridgeOptions> = {\n  isDeviceConnected: boolean;\n\n  init(): Promise<void>;\n\n  destroy(): Promise<void>;\n\n  /**\n   * Method to get the current configuration of the ledger bridge keyring.\n   */\n  getOptions(): Promise<T>;\n\n  /**\n   * Method to set the current configuration of the ledger bridge keyring.\n   *\n   * @param opts - An object contains configuration of the bridge.\n   */\n  setOptions(opts: T): Promise<void>;\n\n  attemptMakeApp(): Promise<boolean>;\n\n  updateTransportMethod(transportType: string | Transport): Promise<boolean>;\n\n  getPublicKey(params: GetPublicKeyParams): Promise<GetPublicKeyResponse>;\n\n  deviceSignTransaction(\n    params: LedgerSignTransactionParams,\n  ): Promise<LedgerSignTransactionResponse>;\n\n  deviceSignMessage(\n    params: LedgerSignMessageParams,\n  ): Promise<LedgerSignMessageResponse>;\n\n  deviceSignTypedData(\n    params: LedgerSignTypedDataParams,\n  ): Promise<LedgerSignTypedDataResponse>;\n\n  deviceSignDelegationAuthorization(\n    params: LedgerSignDelegationAuthorizationParams,\n  ): Promise<LedgerSignDelegationAuthorizationResponse>;\n\n  /**\n   * Method to retrieve the name and version of the running application on the Ledger device.\n   *\n   * @returns An object containing appName and version.\n   */\n  getAppNameAndVersion(): Promise<GetAppNameAndVersionResponse>;\n\n  /**\n   * Method to retrieve the configuration of the running application on the Ledger device.\n   *\n   * @returns An object containing the configuration of the running application.\n   */\n  getAppConfiguration(): Promise<AppConfigurationResponse>;\n};\n"]}