@oasisprotocol/privana-sdk 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { A as Address, B as Bytes32, H as HexString, I as IntegerLike, a as HostedAuthResponseMode, S as SignOnRampUrlRequest, b as SignOnRampUrlResponse, C as CreateOnRampIntentRequest, c as CreateOnRampIntentResponse, U as UpdateOnRampRequest, d as UpdateOnRampResponse, P as PendingOnRampsResponse, N as NetworkConfig, T as TokenConfig } from './on-ramp-DIAOtdeU.js';
2
+ export { e as NETWORK_CONFIG, f as Network, O as OnRampRecord, g as OnRampStatus, h as getAccountingContract, i as getApiUrl, j as getChainId, n as normalizeAddress, k as normalizeHex } from './on-ramp-DIAOtdeU.js';
1
3
  import { WalletClient, Address as Address$1 } from 'viem';
2
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
5
  import * as React$1 from 'react';
@@ -5,56 +7,6 @@ import { ReactNode, ComponentProps, ReactElement } from 'react';
5
7
  import * as class_variance_authority_types from 'class-variance-authority/types';
6
8
  import { VariantProps } from 'class-variance-authority';
7
9
 
8
- var networks = {
9
- testnet: {
10
- chainId: 23295,
11
- name: "Sapphire Testnet",
12
- accountingContract: "0xaF8e5de153A584528B57DD4B9B0195956BBDF571",
13
- apiUrl: "https://testnet.privana.finance"
14
- },
15
- mainnet: {
16
- chainId: 23294,
17
- name: "Sapphire Mainnet",
18
- accountingContract: "0x0000000000000000000000000000000000000000",
19
- apiUrl: ""
20
- }
21
- };
22
- var config = {
23
- networks: networks
24
- };
25
-
26
- type Address = `0x${string}`;
27
- type Bytes32 = `0x${string}`;
28
- type HexString = `0x${string}`;
29
- type IntegerLike = string | number;
30
- type HostedAuthResponseMode = 'web_message' | 'redirect';
31
- type Network = keyof typeof config.networks;
32
- interface NetworkConfig {
33
- chainId: number;
34
- name: string;
35
- accountingContract: Address;
36
- apiUrl: string;
37
- }
38
- declare const NETWORK_CONFIG: {
39
- readonly testnet: {
40
- readonly accountingContract: Address;
41
- readonly chainId: number;
42
- readonly name: string;
43
- readonly apiUrl: string;
44
- };
45
- readonly mainnet: {
46
- readonly accountingContract: Address;
47
- readonly chainId: number;
48
- readonly name: string;
49
- readonly apiUrl: string;
50
- };
51
- };
52
- declare function getChainId(network: Network): number;
53
- declare function getAccountingContract(network: Network): Address;
54
- declare function getApiUrl(network: Network): string;
55
- declare function normalizeHex(value: string): HexString;
56
- declare function normalizeAddress(value: string): Address;
57
-
58
10
  interface HostedAuthConfig {
59
11
  clientId: string;
60
12
  redirectUri: string;
@@ -85,15 +37,6 @@ interface HostedAuthCallbackError {
85
37
  }
86
38
  type HostedAuthCallback = HostedAuthCallbackSuccess | HostedAuthCallbackError;
87
39
 
88
- interface TokenConfig {
89
- id: Bytes32;
90
- symbol: string;
91
- decimals: number;
92
- contract: Address;
93
- name: string;
94
- chainId: number;
95
- }
96
-
97
40
  interface ChainConfig {
98
41
  id: number;
99
42
  name: string;
@@ -438,6 +381,10 @@ declare class PrivanaClient {
438
381
  exchangeHostedAuthCode(request: HostedAuthTokenExchangeRequest): Promise<HostedAuthTokenExchangeResponse>;
439
382
  refreshJwtSession(request: JwtRefreshRequest): Promise<JwtRefreshResponse>;
440
383
  logoutJwtSession(request?: JwtLogoutRequest): Promise<JwtLogoutResponse>;
384
+ signOnRampUrl(request: SignOnRampUrlRequest): Promise<SignOnRampUrlResponse>;
385
+ createOnRampIntent(request: CreateOnRampIntentRequest): Promise<CreateOnRampIntentResponse>;
386
+ updateOnRamp(transactionId: string, request: UpdateOnRampRequest): Promise<UpdateOnRampResponse>;
387
+ getPendingOnRamps(): Promise<PendingOnRampsResponse>;
441
388
  setPrivateReadToken(token: string): void;
442
389
  getPrivateReadToken(): string | undefined;
443
390
  clearPrivateReadToken(): void;
@@ -840,6 +787,60 @@ interface UseDepositResult {
840
787
  }
841
788
  declare function useDeposit(options?: UseDepositOptions): UseDepositResult;
842
789
 
790
+ interface VerificationContext {
791
+ /** On-chain transfer that funded the user's Privana deposit address. */
792
+ hash: `0x${string}`;
793
+ /** Chain the transfer was mined on. */
794
+ chainId: number;
795
+ /** Transferred amount in base units (matches the deposit's token decimals). */
796
+ amount: bigint;
797
+ }
798
+ interface UseDepositVerificationOptions {
799
+ /** Fired when the deposit is credited inside the Privana accounting module. */
800
+ onCredited?: (txHash: string, response: DepositCheckResponse) => void;
801
+ /** Fired when polling exceeds `pollTimeout` (the deposit may still be processing). */
802
+ onCheckTimeout?: (txHash: string) => void;
803
+ onError?: (error: Error) => void;
804
+ /** Polling interval in ms (default: 5000). */
805
+ pollInterval?: number;
806
+ /** Retry interval in ms while the source-chain tx is waiting finality (default: pollInterval). */
807
+ finalityRetryInterval?: number;
808
+ /** Max time to wait for credit confirmation in ms (default: 180000). */
809
+ pollTimeout?: number;
810
+ }
811
+ interface UseDepositVerificationResult {
812
+ /** True while phase 1 (checkDeposit) or phase 2 (status polling) is in flight. */
813
+ isVerifying: boolean;
814
+ /** True if polling timed out before a terminal status. */
815
+ didTimeout: boolean;
816
+ /**
817
+ * True when the on-chain transfer exists but the API verification step failed.
818
+ * Funds are still at the deposit address; call `retryVerification()` to re-run
819
+ * without re-sending the transfer.
820
+ */
821
+ verificationFailed: boolean;
822
+ error: Error | null;
823
+ /** Current transfer hash being verified, if any. */
824
+ txHash: `0x${string}` | undefined;
825
+ /** Kick off Phase 1 (checkDeposit) + Phase 2 (poll getDepositStatus) for the given context. */
826
+ verify: (ctx: VerificationContext) => Promise<void>;
827
+ /** Re-run verification against the existing context (after a transient API failure). */
828
+ retryVerification: () => Promise<void>;
829
+ /** Discard local tracking (the deposit may still be credited in the background). */
830
+ reset: () => void;
831
+ }
832
+ /**
833
+ * Phase 1 (POST /deposits/check) + Phase 2 (poll /deposits/status) of the
834
+ * Privana deposit flow, decoupled from the wallet-signing half. Use this
835
+ * directly when the on-chain transfer to the deposit address came from
836
+ * somewhere other than the connected wallet — e.g. a fiat on-ramp that
837
+ * delivers straight to the deposit address.
838
+ *
839
+ * For the full deposit flow (get address → wallet transfer → verify) use
840
+ * `useDeposit`, which composes this hook internally.
841
+ */
842
+ declare function useDepositVerification(options?: UseDepositVerificationOptions): UseDepositVerificationResult;
843
+
843
844
  interface UseWithdrawOptions {
844
845
  onSuccess?: (response: TransactionSubmissionResponse) => void;
845
846
  /** Called when withdrawal is submitted to the backend */
@@ -1093,4 +1094,4 @@ declare function Skeleton({ className, ...props }: React.ComponentProps<'div'>):
1093
1094
  declare function getTokenIcon(symbol: string, size?: number): react_jsx_runtime.JSX.Element;
1094
1095
  declare function getChainIcon(chainId: number, size?: number): react_jsx_runtime.JSX.Element;
1095
1096
 
1096
- export { AccountingApiError, type Address, type BalanceResponse, type BatchBalancesRequest, type BatchBalancesResponse, Button, type Bytes32, type ChainConfig, type DepositAddressRequest, type DepositAddressResponse, type DepositCheckRequest, type DepositCheckResponse, type DepositParams, type EIP712Domain, type ExpiredLocksResponse, HOSTED_AUTH_CLOCK_SKEW_MS, type HexString, type HistoryEntry, type HistoryKind, type HistoryRequest, type HistoryResponse, type HostedAuthAuthorizeUrlRequest, type HostedAuthCallback, type HostedAuthCallbackError, type HostedAuthCallbackSuccess, type HostedAuthConfig, HostedAuthError, type HostedAuthPendingTransaction, HostedAuthRequiredError, type HostedAuthResponseMode, type HostedAuthSession, HostedAuthStateMismatchError, type HostedAuthTokenExchangeRequest, type HostedAuthTokenExchangeResponse, HttpClient, type HttpClientConfig, type IntegerLike, type JwtLogoutRequest, type JwtLogoutResponse, type JwtRefreshRequest, type JwtRefreshResponse, LOCK_TYPES, type LockFundsParams, type LockFundsRequest, type LockInfo, type LockMessage, type LockNonceResponse, type LockedFundsResponse, MODIFY_LOCK_TYPES, type MinDepositAmounts, type ModifyLockMessage, type ModifyLockNonceResponse, type ModifyLockParams, type ModifyLockRequest, NETWORK_CONFIG, type Network, type NetworkConfig, NetworkError, type PendingWithdrawalsResponse, PrivanaButton, type PrivanaButtonProps, PrivanaClient, type PrivanaClientConfig, type PrivanaContextValue, PrivanaInlineModal, PrivanaModal, PrivanaProvider, type PrivanaProviderProps, SUPPORTED_CHAINS, type SignLockParams, type SignModifyLockParams, type SignTransferLockedParams, type SignTransferParams, type SignWithdrawFromLockParams, type SignWithdrawParams, type SiweAuthConfig, type SiweAuthContextValue, SiweAuthProvider, type SiweAuthProviderProps, type SiweAuthSession, type SiweAuthTokens, type SiweDomainResponse, type SiweLoginRequest, type SiweLoginResponse, type SiweNonceResponse, Skeleton, TRANSFER_LOCKED_TYPES, TRANSFER_TYPES, type TokenBalance, type TokenConfig, type TokenInfoResponse, type TokenListResponse, type TokensStatus, type TotalLockedBalanceResponse, type TransactionSubmissionResponse, type TransferFundsRequest, type TransferLockedFundsRequest, type TransferLockedMessage, type TransferLockedNonceResponse, type TransferLockedParams, type TransferMessage, type TransferNonceResponse, type TransferParams, type UnlockAllExpiredRequest, type UnlockFundsParams, type UnlockFundsRequest, type UseBalanceOptions, type UseBalanceResult, type UseBatchBalancesOptions, type UseBatchBalancesResult, type UseDepositOptions, type UseDepositResult, type UseExpiredLocksOptions, type UseExpiredLocksResult, type UseHistoryOptions, type UseHistoryResult, type UseHostedRedirectAuthResult, type UseLockFundsOptions, type UseLockFundsResult, type UseLockedFundsOptions, type UseLockedFundsResult, type UseModifyLockOptions, type UseModifyLockResult, type UsePendingWithdrawalsOptions, type UsePendingWithdrawalsResult, type UseTokenInfoOptions, type UseTokenInfoResult, type UseTokenListOptions, type UseTokenListResult, type UseTotalLockedBalanceOptions, type UseTotalLockedBalanceResult, type UseTransferOptions, type UseTransferResult, type UseUnlockFundsOptions, type UseUnlockFundsResult, type UseWithdrawOptions, type UseWithdrawResult, ValidationError, WITHDRAW_FROM_LOCK_TYPES, WITHDRAW_TYPES, type WithdrawFromLockMessage, type WithdrawFromLockRequest, type WithdrawMessage, type WithdrawParams, type WithdrawStep, type WithdrawalInfo, type WithdrawalInfoResponse, type WithdrawalNonceResponse, type WithdrawalRequest, applyRefreshResponse, buildHostedAuthSession, buttonVariants, clearHostedAuthPendingTransaction, createDomain, createHostedAuthPendingStorageKey, createHostedAuthState, createHostedAuthStorageKey, createLockExpiry, createPkceChallenge, createPkceVerifier, getAccountingContract, getApiUrl, getChainById, getChainIcon, getChainId, getExplorerAddressUrl, getTokenIcon, isHostedAuthRefreshActive, isHostedAuthSessionActive, normalizeAddress, normalizeHex, parseHostedAuthCallback, persistHostedAuthPendingTransaction, readHostedAuthPendingTransaction, readStoredHostedAuthSession, signLockMessage, signModifyLockMessage, signTransferLockedMessage, signTransferMessage, signWithdrawFromLockMessage, signWithdrawMessage, stripHostedAuthCallbackParams, syncHostedAuthSessionToClient, useBalance, useBatchBalances, useDeposit, useExpiredLocks, useHistory, useHostedRedirectAuth, useLockFunds, useLockedFunds, useModifyLock, usePendingWithdrawals, usePrivanaClient, usePrivanaContext, useSafeAccount, useSafePrivanaContext, useSiweAuth, useTokenInfo, useTokenList, useTotalLockedBalance, useTransfer, useUnlockFunds, useWithdraw };
1097
+ export { AccountingApiError, Address, type BalanceResponse, type BatchBalancesRequest, type BatchBalancesResponse, Button, Bytes32, type ChainConfig, CreateOnRampIntentRequest, CreateOnRampIntentResponse, type DepositAddressRequest, type DepositAddressResponse, type DepositCheckRequest, type DepositCheckResponse, type DepositParams, type EIP712Domain, type ExpiredLocksResponse, HOSTED_AUTH_CLOCK_SKEW_MS, HexString, type HistoryEntry, type HistoryKind, type HistoryRequest, type HistoryResponse, type HostedAuthAuthorizeUrlRequest, type HostedAuthCallback, type HostedAuthCallbackError, type HostedAuthCallbackSuccess, type HostedAuthConfig, HostedAuthError, type HostedAuthPendingTransaction, HostedAuthRequiredError, HostedAuthResponseMode, type HostedAuthSession, HostedAuthStateMismatchError, type HostedAuthTokenExchangeRequest, type HostedAuthTokenExchangeResponse, HttpClient, type HttpClientConfig, IntegerLike, type JwtLogoutRequest, type JwtLogoutResponse, type JwtRefreshRequest, type JwtRefreshResponse, LOCK_TYPES, type LockFundsParams, type LockFundsRequest, type LockInfo, type LockMessage, type LockNonceResponse, type LockedFundsResponse, MODIFY_LOCK_TYPES, type MinDepositAmounts, type ModifyLockMessage, type ModifyLockNonceResponse, type ModifyLockParams, type ModifyLockRequest, NetworkConfig, NetworkError, PendingOnRampsResponse, type PendingWithdrawalsResponse, PrivanaButton, type PrivanaButtonProps, PrivanaClient, type PrivanaClientConfig, type PrivanaContextValue, PrivanaInlineModal, PrivanaModal, PrivanaProvider, type PrivanaProviderProps, SUPPORTED_CHAINS, type SignLockParams, type SignModifyLockParams, SignOnRampUrlRequest, SignOnRampUrlResponse, type SignTransferLockedParams, type SignTransferParams, type SignWithdrawFromLockParams, type SignWithdrawParams, type SiweAuthConfig, type SiweAuthContextValue, SiweAuthProvider, type SiweAuthProviderProps, type SiweAuthSession, type SiweAuthTokens, type SiweDomainResponse, type SiweLoginRequest, type SiweLoginResponse, type SiweNonceResponse, Skeleton, TRANSFER_LOCKED_TYPES, TRANSFER_TYPES, type TokenBalance, TokenConfig, type TokenInfoResponse, type TokenListResponse, type TokensStatus, type TotalLockedBalanceResponse, type TransactionSubmissionResponse, type TransferFundsRequest, type TransferLockedFundsRequest, type TransferLockedMessage, type TransferLockedNonceResponse, type TransferLockedParams, type TransferMessage, type TransferNonceResponse, type TransferParams, type UnlockAllExpiredRequest, type UnlockFundsParams, type UnlockFundsRequest, UpdateOnRampRequest, UpdateOnRampResponse, type UseBalanceOptions, type UseBalanceResult, type UseBatchBalancesOptions, type UseBatchBalancesResult, type UseDepositOptions, type UseDepositResult, type UseDepositVerificationOptions, type UseDepositVerificationResult, type UseExpiredLocksOptions, type UseExpiredLocksResult, type UseHistoryOptions, type UseHistoryResult, type UseHostedRedirectAuthResult, type UseLockFundsOptions, type UseLockFundsResult, type UseLockedFundsOptions, type UseLockedFundsResult, type UseModifyLockOptions, type UseModifyLockResult, type UsePendingWithdrawalsOptions, type UsePendingWithdrawalsResult, type UseTokenInfoOptions, type UseTokenInfoResult, type UseTokenListOptions, type UseTokenListResult, type UseTotalLockedBalanceOptions, type UseTotalLockedBalanceResult, type UseTransferOptions, type UseTransferResult, type UseUnlockFundsOptions, type UseUnlockFundsResult, type UseWithdrawOptions, type UseWithdrawResult, ValidationError, type VerificationContext, WITHDRAW_FROM_LOCK_TYPES, WITHDRAW_TYPES, type WithdrawFromLockMessage, type WithdrawFromLockRequest, type WithdrawMessage, type WithdrawParams, type WithdrawStep, type WithdrawalInfo, type WithdrawalInfoResponse, type WithdrawalNonceResponse, type WithdrawalRequest, applyRefreshResponse, buildHostedAuthSession, buttonVariants, clearHostedAuthPendingTransaction, createDomain, createHostedAuthPendingStorageKey, createHostedAuthState, createHostedAuthStorageKey, createLockExpiry, createPkceChallenge, createPkceVerifier, getChainById, getChainIcon, getExplorerAddressUrl, getTokenIcon, isHostedAuthRefreshActive, isHostedAuthSessionActive, parseHostedAuthCallback, persistHostedAuthPendingTransaction, readHostedAuthPendingTransaction, readStoredHostedAuthSession, signLockMessage, signModifyLockMessage, signTransferLockedMessage, signTransferMessage, signWithdrawFromLockMessage, signWithdrawMessage, stripHostedAuthCallbackParams, syncHostedAuthSessionToClient, useBalance, useBatchBalances, useDeposit, useDepositVerification, useExpiredLocks, useHistory, useHostedRedirectAuth, useLockFunds, useLockedFunds, useModifyLock, usePendingWithdrawals, usePrivanaClient, usePrivanaContext, useSafeAccount, useSafePrivanaContext, useSiweAuth, useTokenInfo, useTokenList, useTotalLockedBalance, useTransfer, useUnlockFunds, useWithdraw };