import { Event as Event_2 } from 'nostr-tools'; import { JSX as JSX_2 } from '@emotion/react/jsx-runtime'; import { NwcRequester as NwcRequester_2 } from '../../../../../../../../../src/NwcRequester'; import { PersistOptions } from 'zustand/middleware'; import { Relay } from 'nostr-tools'; import { StoreApi } from 'zustand'; import { UnsignedEvent } from 'nostr-tools'; import { UseBoundStore } from 'zustand'; declare interface AuthConfig { identityNpub: string; identityRelayUrl: string; redirectUri: string; requiredCommands?: string[] | undefined; optionalCommands?: string[] | undefined; budget?: BudgetConfig | undefined; } declare interface BudgetConfig { amountInLowestDenom: string; currency: string; period: string; } export declare type BudgetCurrency = { code: string; name: string; symbol: string; decimals: number; total_budget: number; used_budget: number; }; export declare type BudgetRenewalPeriod = "daily" | "weekly" | "monthly" | "yearly" | "never"; export declare type Currency = { code: string; name: string; symbol: string; decimals: number; }; export declare type CurrencyPreference = { currency: Currency; multiplier: number; min: number; max: number; }; export declare type ExecuteQuoteRequest = { payment_hash: string; }; export declare type ExecuteQuoteResponse = { preimage: string; }; export declare type FetchQuoteRequest = { receiver: Receiver; sending_currency_code: string; receiving_currency_code: string; locked_currency_side: "SENDING" | "RECEIVING"; locked_currency_amount: number; }; export declare type GetBalanceRequest = { currency_code?: string; }; export declare type GetBalanceResponse = { balance: number; currency?: Currency; }; export declare type GetBudgetResponse = { used_budget?: number; total_budget?: number; renews_at?: number; renewal_period?: BudgetRenewalPeriod; currency?: BudgetCurrency; }; export declare type GetInfoResponse = { alias: string; color: string; pubkey: string; network: string; block_height: number; block_hash: string; methods: Method[]; lud16?: string; currencies?: CurrencyPreference[]; }; export declare interface ListTransactionsRequest { from?: number; until?: number; limit?: number; offset?: number; unpaid?: boolean; type?: "incoming" | "outgoing"; } export declare type ListTransactionsResponse = { transactions: Transaction[]; }; export declare type LookupInvoiceRequest = { payment_hash: string; }; export declare type LookupUserRequest = { receiver: Receiver; base_sending_currency_code?: string; }; export declare type LookupUserResponse = { currencies: CurrencyPreference[]; }; export declare type MakeInvoiceRequest = { amount: number; description?: string; description_hash?: string; expiry?: number; }; export declare type Method = "get_info" | "get_balance" | "get_budget" | "make_invoice" | "pay_invoice" | "pay_keysend" | "lookup_invoice" | "list_transactions" | "lookup_user" | "fetch_quote" | "execute_quote" | "pay_to_address"; declare namespace Nip47 { { Method, GetInfoResponse, GetBalanceRequest, GetBalanceResponse, BudgetCurrency, BudgetRenewalPeriod, GetBudgetResponse, PayResponse, ListTransactionsRequest, ListTransactionsResponse, TransactionFx, Transaction, Currency, CurrencyPreference, PayInvoiceRequest, PayKeysendRequest, MakeInvoiceRequest, LookupInvoiceRequest, Receiver, LookupUserRequest, LookupUserResponse, FetchQuoteRequest, Quote, ExecuteQuoteRequest, ExecuteQuoteResponse, PayToAddressRequest, PayToAddressResponse, Nip47Error, Nip47WalletError, Nip47TimeoutError, Nip47PublishTimeoutError, Nip47ReplyTimeoutError, Nip47PublishError, Nip47ResponseDecodingError, Nip47ResponseValidationError, Nip47UnexpectedResponseError } } export declare class Nip47Error extends Error { code: string; constructor(message: string, code: string); } export declare class Nip47PublishError extends Nip47Error { } export declare class Nip47PublishTimeoutError extends Nip47TimeoutError { } export declare class Nip47ReplyTimeoutError extends Nip47TimeoutError { } export declare class Nip47ResponseDecodingError extends Nip47Error { } export declare class Nip47ResponseValidationError extends Nip47Error { } export declare class Nip47TimeoutError extends Nip47Error { } export declare class Nip47UnexpectedResponseError extends Nip47Error { } /** * A NIP-47 response was received, but with an error code (see https://github.com/nostr-protocol/nips/blob/master/47.md#error-codes) */ export declare class Nip47WalletError extends Nip47Error { } declare interface NwcConnection { relayUrl: string; walletPubkey: string; secret: Uint8Array; lud16?: string; } export declare class NwcRequester { relay: Relay; relayUrl: string; walletPubkey: string; secret: Uint8Array; lud16: string | undefined; useNip44: boolean; cachedWalletInfoEvent: Event_2 | undefined; clearUserAuth: () => void; tokenRefresh?: () => Promise<{ nwcConnectionUri: string; }>; static parseWalletConnectUrl(walletConnectUrl: string): NwcConnection; private initNwcConnection; constructor(url: string, clearUserAuth: () => void, tokenRefresh?: () => Promise<{ nwcConnectionUri: string; }>); get publicKey(): string; signEvent(event: UnsignedEvent): Promise; close(): void; encrypt(pubkey: string, content: string): Promise; decrypt(pubkey: string, content: string): Promise; getInfo(): Promise; getBudget(): Promise; getBalance(request?: Nip47.GetBalanceRequest): Promise; payInvoice(request: Nip47.PayInvoiceRequest): Promise; payKeysend(request: Nip47.PayKeysendRequest): Promise; makeInvoice(request: Nip47.MakeInvoiceRequest): Promise; lookupInvoice(request: Nip47.LookupInvoiceRequest): Promise; listTransactions(request: Nip47.ListTransactionsRequest): Promise; lookupUser(request: Nip47.LookupUserRequest): Promise; fetchQuote(request: Nip47.FetchQuoteRequest): Promise; executeQuote(request: Nip47.ExecuteQuoteRequest): Promise; payToAddress(request: Nip47.PayToAddressRequest): Promise; private executeNip47Request; private _checkConnected; private fetchExistingEvent; } declare interface OAuthState { codeVerifier?: string | undefined; csrfState?: string | undefined; address?: string | undefined; token?: TokenState | undefined; authConfig?: AuthConfig; nwcConnectionUri?: string | undefined; nwcExpiresAt?: number | undefined; setAuthConfig: (config: AuthConfig) => void; setToken: (token?: TokenState) => void; /** Check if the connection is valid or expired. */ isConnectionValid: () => boolean; /** The initial OAuth request that starts the OAuth handshake. */ initialOAuthRequest: (uma: string) => Promise<{ success: boolean; }>; /** OAuth token exchange occurs after the initialOAuthRequest has been made. */ oAuthTokenExchange: () => Promise<{ nwcConnectionUri: string; token: TokenState; codeVerifier: string; nwcExpiresAt: number | undefined; }>; hasValidToken: () => boolean; clearUserAuth: () => void; setNwcConnectionUri: (nwcConnectionUri: string | undefined) => void; setAddress: (address: string) => void; } export declare type PayInvoiceRequest = { invoice: string; amount?: number; }; export declare type PayKeysendRequest = { amount: number; pubkey: string; preimage?: string; tlv_records?: { type: number; value: string; }[]; }; export declare type PayResponse = { preimage: string; }; export declare type PayToAddressRequest = { receiver: Receiver; sending_currency_code: string; sending_currency_amount: number; receiving_currency_code?: string; }; export declare type PayToAddressResponse = { preimage: string; quote: Quote; }; export declare type Quote = { payment_hash: string; sending_currency_code: string; receiving_currency_code: string; total_receiving_amount: number; total_sending_amount: number; multiplier: number; fees: number; expires_at: number; }; export declare type Receiver = { lud16: string; }; declare interface TokenState { accessToken: string; refreshToken: string; expiresAt: number; commands?: string[]; budget?: string | undefined; } export declare type Transaction = { type: string; invoice: string; description: string; description_hash: string; preimage: string; payment_hash: string; amount: number; fees_paid: number; settled_at: number; created_at: number; expires_at: number; fx?: TransactionFx; metadata?: Record; }; export declare type TransactionFx = { receiving_currency_code: string; total_receiving_amount: number; multiplier: number; sending_currency_code?: string; total_sending_amount?: number; fees?: number; }; export declare const UmaConnectButton: (props: Record) => JSX_2.Element; export declare const useNwcRequester: () => { nwcRequester: NwcRequester_2 | undefined; resetNwcRequester: () => void; }; export declare const useOAuth: UseBoundStore, "persist"> & { persist: { setOptions: (options: Partial>) => void; clearStorage: () => void; rehydrate: () => Promise | void; hasHydrated: () => boolean; onHydrate: (fn: (state: OAuthState) => void) => () => void; onFinishHydration: (fn: (state: OAuthState) => void) => () => void; getOptions: () => Partial>; }; }>; export { } declare global { namespace JSX { interface IntrinsicElements { [UmaConnectButtonTagName]: React.DetailedHTMLProps, HTMLElement>; } } }