UNPKG

bigblocks

Version:

Complete Bitcoin UI component library - authentication, social, wallet, market, inscriptions, and blockchain interactions for React

129 lines 3.9 kB
/** * HandCash OAuth Provider Integration * * This module provides lazy-loaded integration with HandCash Connect * using their traditional OAuth redirect flow. */ import type { BapMasterBackup, BapMemberBackup } from "bitcoin-backup"; export interface OneSatBackup { ordPk: string; payPk: string; identityPk: string; } export interface WifBackup { wif: string; } export type BackupData = BapMasterBackup | BapMemberBackup | OneSatBackup | WifBackup; export interface HandCashProfile { id: string; handle: string; paymail: string; displayName: string; avatarUrl: string; localCurrencyCode: string; balanceInSatoshis: number; balanceInLocalCurrency: number; } export interface HandCashPaymentRequest { description: string; appAction?: string; receivers: Array<{ destination: string; amount: number; currencyCode?: string; }>; } export interface HandCashPaymentResult { transactionId: string; note: string; satoshiAmount: number; fiatAmount: number; currencyCode: string; } export interface HandCashBalance { spendableFiatBalance: number; spendableSatoshiBalance: number; currencyCode: string; } export interface HandCashPaymentHistoryFilters { from?: number; to?: number; } export interface HandCashAccount { profile: { getCurrentProfile(): Promise<HandCashProfile>; getEncryptionKeypair(): Promise<{ privateKey: string; publicKey: string; }>; }; wallet: { pay(payment: HandCashPaymentRequest): Promise<HandCashPaymentResult>; getBalance(): Promise<HandCashBalance>; getPaymentHistory(filters?: HandCashPaymentHistoryFilters): Promise<HandCashPaymentResult[]>; }; } export interface HandCashConfig { appId: string; redirectUrl?: string; environment?: "prod" | "iae"; } interface HandCashOAuthState { isConnected: boolean; authToken: string | null; profile: HandCashProfile | null; error: string | null; isLoading: boolean; } export declare class HandCashOAuthProvider { private config; private state; private listeners; constructor(config: HandCashConfig); getOAuthUrl(): string; startOAuth(): Promise<void>; handleCallback(authToken: string): Promise<boolean>; private getProfile; encryptData(data: BackupData): Promise<string>; decryptData(encryptedData: string): Promise<BackupData>; disconnect(): Promise<void>; getState(): HandCashOAuthState; subscribe(listener: (state: HandCashOAuthState) => void): () => void; private setState; } export declare function useHandCash(config: HandCashConfig): { startOAuth: () => Promise<void>; handleCallback: (authToken: string) => Promise<boolean>; encryptData: (data: BackupData) => Promise<string>; decryptData: (encryptedData: string) => Promise<BackupData>; disconnect: () => Promise<void>; provider: HandCashOAuthProvider; isConnected: boolean; authToken: string | null; profile: HandCashProfile | null; error: string | null; isLoading: boolean; }; export declare function createHandCashAuthHandler(config: import("./oauth-providers.js").OAuthHandlerConfig): Promise<{ success: boolean; encryptedBackup?: string; idKey?: string; error?: string; authToken?: string; oauthToken?: string; profile?: { handle: string; displayName: string; paymail: string; avatarUrl?: string; address?: string; }; }>; export interface HandCashConnectPromptProps { onConnect?: () => void; className?: string; config: HandCashConfig; } export declare function HandCashConnectPrompt({ onConnect, className, config, }: HandCashConnectPromptProps): import("react/jsx-runtime").JSX.Element; export {}; //# sourceMappingURL=handcash-provider.d.ts.map