@oasisprotocol/privana-sdk 0.2.0 → 0.3.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
@@ -10,7 +10,7 @@ var networks = {
10
10
  chainId: 23295,
11
11
  name: "Sapphire Testnet",
12
12
  accountingContract: "0xaF8e5de153A584528B57DD4B9B0195956BBDF571",
13
- apiUrl: "https://flexvaults-staging.rofl.build"
13
+ apiUrl: "https://testnet.privana.finance"
14
14
  },
15
15
  mainnet: {
16
16
  chainId: 23294,
@@ -219,6 +219,7 @@ interface DepositCheckResponse {
219
219
  detail?: string;
220
220
  }
221
221
  interface TransactionSubmissionResponse {
222
+ submission_id: string;
222
223
  status: string;
223
224
  detail?: string;
224
225
  }
@@ -662,6 +663,32 @@ interface SignWithdrawFromLockParams {
662
663
  }
663
664
  declare function signWithdrawFromLockMessage({ walletClient, chainId, verifyingContract, message, }: SignWithdrawFromLockParams): Promise<`0x${string}`>;
664
665
 
666
+ type SiweAuthSession = {
667
+ address: Address;
668
+ };
669
+ type SiweAuthTokens = Pick<SiweLoginResponse, 'siwe_token' | 'jwt_access_token' | 'jwt_refresh_token' | 'address'>;
670
+ interface SiweAuthContextValue {
671
+ isAuthenticated: boolean;
672
+ isLoading: boolean;
673
+ error: Error | null;
674
+ session: SiweAuthSession | null;
675
+ accessToken: string | undefined;
676
+ tokens: SiweAuthTokens | null;
677
+ login: () => Promise<void>;
678
+ logout: () => Promise<void>;
679
+ }
680
+ interface SiweAuthConfig {
681
+ autoLogin?: boolean;
682
+ statement?: string;
683
+ }
684
+ interface SiweAuthProviderProps extends SiweAuthConfig {
685
+ children: ReactNode;
686
+ client: PrivanaClient;
687
+ networkConfig: NetworkConfig;
688
+ }
689
+ declare function SiweAuthProvider({ children, client, networkConfig, autoLogin, statement, }: SiweAuthProviderProps): react_jsx_runtime.JSX.Element;
690
+ declare function useSiweAuth(): SiweAuthContextValue;
691
+
665
692
  type TokensStatus = 'loading' | 'ready' | 'error';
666
693
  interface PrivanaContextValue {
667
694
  client: PrivanaClient;
@@ -710,8 +737,16 @@ interface PrivanaProviderProps {
710
737
  * Optional hosted redirect auth configuration for cross-domain browser apps.
711
738
  */
712
739
  hostedAuth?: HostedAuthConfig;
740
+ /**
741
+ * Optional direct (in-app) SIWE auth. When provided, the connected wallet
742
+ * signs an EIP-4361 message in-app and `useSiweAuth()` becomes available.
743
+ * Mutually exclusive with `hostedAuth`: providing both throws, because
744
+ * `usePrivateReadRequest()` prefers `hostedAuthConfig` and would otherwise
745
+ * ignore the SIWE login.
746
+ */
747
+ siweAuth?: SiweAuthConfig;
713
748
  }
714
- declare function PrivanaProvider({ children, networkConfig: networkConfigOverride, tokens, chains, pollingInterval, serviceAddress, hostedAuth, }: PrivanaProviderProps): react_jsx_runtime.JSX.Element;
749
+ declare function PrivanaProvider({ children, networkConfig: networkConfigOverride, tokens, chains, pollingInterval, serviceAddress, hostedAuth, siweAuth, }: PrivanaProviderProps): react_jsx_runtime.JSX.Element;
715
750
  declare function usePrivanaContext(): PrivanaContextValue;
716
751
  declare function useSafePrivanaContext(): PrivanaContextValue | null;
717
752
 
@@ -962,9 +997,11 @@ interface UseHistoryResult {
962
997
  }
963
998
  declare function useHistory(options?: UseHistoryOptions): UseHistoryResult;
964
999
 
1000
+ type AccountStatus = 'connecting' | 'reconnecting' | 'connected' | 'disconnected';
965
1001
  interface SafeAccountResult {
966
1002
  address: Address$1 | undefined;
967
1003
  isConnected: boolean;
1004
+ status: AccountStatus;
968
1005
  }
969
1006
  declare function useSafeAccount(): SafeAccountResult;
970
1007
 
@@ -1056,4 +1093,4 @@ declare function Skeleton({ className, ...props }: React.ComponentProps<'div'>):
1056
1093
  declare function getTokenIcon(symbol: string, size?: number): react_jsx_runtime.JSX.Element;
1057
1094
  declare function getChainIcon(chainId: number, size?: number): react_jsx_runtime.JSX.Element;
1058
1095
 
1059
- 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 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, useTokenInfo, useTokenList, useTotalLockedBalance, useTransfer, useUnlockFunds, useWithdraw };
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 };