@openfort/react-native 0.1.8 → 0.1.10

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.
Files changed (56) hide show
  1. package/dist/components/AuthBoundary.js +7 -8
  2. package/dist/components/index.js +3 -6
  3. package/dist/constants/config.js +2 -2
  4. package/dist/core/client.js +31 -10
  5. package/dist/core/context.js +41 -4
  6. package/dist/core/provider.js +35 -4
  7. package/dist/core/storage.js +17 -7
  8. package/dist/hooks/auth/index.js +1 -1
  9. package/dist/hooks/auth/useCreateWalletPostAuth.js +9 -1
  10. package/dist/hooks/auth/useEmailAuth.js +26 -0
  11. package/dist/hooks/auth/useGuestAuth.js +21 -0
  12. package/dist/hooks/auth/useOAuth.js +15 -21
  13. package/dist/hooks/auth/useSignOut.js +32 -0
  14. package/dist/hooks/auth/useWalletAuth.js +25 -0
  15. package/dist/hooks/core/index.js +1 -1
  16. package/dist/hooks/core/useOpenfort.js +24 -27
  17. package/dist/hooks/core/useOpenfortClient.js +8 -13
  18. package/dist/hooks/core/useUser.js +28 -0
  19. package/dist/hooks/index.js +7 -6
  20. package/dist/hooks/wallet/index.js +1 -1
  21. package/dist/hooks/wallet/useWallet.js +27 -0
  22. package/dist/hooks/wallet/useWallets.js +44 -27
  23. package/dist/index.js +5 -6
  24. package/dist/lib/hookConsistency.js +42 -0
  25. package/dist/native/oauth.js +38 -1
  26. package/dist/native/storage.js +23 -8
  27. package/dist/types/components/AuthBoundary.d.ts +7 -8
  28. package/dist/types/components/index.d.ts +3 -6
  29. package/dist/types/constants/config.d.ts +2 -2
  30. package/dist/types/core/client.d.ts +22 -6
  31. package/dist/types/core/context.d.ts +56 -19
  32. package/dist/types/core/provider.d.ts +57 -30
  33. package/dist/types/core/storage.d.ts +7 -4
  34. package/dist/types/hooks/auth/index.d.ts +1 -1
  35. package/dist/types/hooks/auth/useCreateWalletPostAuth.d.ts +9 -0
  36. package/dist/types/hooks/auth/useEmailAuth.d.ts +26 -0
  37. package/dist/types/hooks/auth/useGuestAuth.d.ts +16 -18
  38. package/dist/types/hooks/auth/useOAuth.d.ts +15 -21
  39. package/dist/types/hooks/auth/useSignOut.d.ts +32 -0
  40. package/dist/types/hooks/auth/useWalletAuth.d.ts +25 -3
  41. package/dist/types/hooks/core/index.d.ts +1 -1
  42. package/dist/types/hooks/core/useOpenfort.d.ts +24 -24
  43. package/dist/types/hooks/core/useOpenfortClient.d.ts +8 -16
  44. package/dist/types/hooks/core/useUser.d.ts +28 -0
  45. package/dist/types/hooks/index.d.ts +7 -6
  46. package/dist/types/hooks/wallet/index.d.ts +1 -1
  47. package/dist/types/hooks/wallet/useWallet.d.ts +27 -0
  48. package/dist/types/hooks/wallet/useWallets.d.ts +24 -21
  49. package/dist/types/index.d.ts +5 -6
  50. package/dist/types/lib/hookConsistency.d.ts +42 -0
  51. package/dist/types/native/oauth.d.ts +38 -1
  52. package/dist/types/native/storage.d.ts +21 -9
  53. package/dist/types/predicates.js +20 -1
  54. package/dist/types/types/index.d.ts +8 -8
  55. package/dist/types/types/predicates.d.ts +55 -1
  56. package/package.json +2 -2
@@ -1,18 +1,19 @@
1
1
  import React from 'react';
2
2
  import { SDKOverrides, AccountTypeEnum, ThirdPartyAuthConfiguration } from '@openfort/openfort-js';
3
3
  /**
4
- * Custom auth configuration
4
+ * Shape for configuring custom authentication synchronisation behaviour.
5
5
  */
6
6
  interface CustomAuthConfig {
7
7
  enabled: boolean;
8
8
  isLoading: boolean;
9
9
  getCustomAccessToken: () => Promise<string | null>;
10
10
  }
11
+ type PolicyConfig = string | Record<number, string>;
11
12
  export type CommonEmbeddedWalletConfiguration = {
12
- /** Publishable key for the Shield API */
13
+ /** Publishable key for the Shield API. */
13
14
  shieldPublishableKey: string;
14
- /** Policy ID (pol_...) for the embedded signer */
15
- ethereumProviderPolicyId?: string;
15
+ /** Policy ID (pol_...) for the embedded signer. */
16
+ ethereumProviderPolicyId?: PolicyConfig;
16
17
  accountType?: AccountTypeEnum;
17
18
  debug?: boolean;
18
19
  };
@@ -26,16 +27,13 @@ export type EncryptionSession = {
26
27
  getEncryptionSession?: never;
27
28
  };
28
29
  /**
29
- * Configuration for automatic recovery.
30
- * - An encryption session is required.
30
+ * Configuration for enabling embedded wallet recovery flows.
31
31
  *
32
- * Configuration for password-based recovery.
33
- * - An encryption session, OR
34
- * - A `shieldEncryptionKey` without an encryption session.
35
- *
36
- * Encryption session can be created using either:
37
- * - `createEncryptedSessionEndpoint` as a string, OR
38
- * - `getEncryptionSession.` as a function that returns a promise.
32
+ * Automatic recovery requires an encryption session, while password-based recovery may either use
33
+ * an encryption session or a Shield encryption key. Provide a
34
+ * {@link EncryptionSession.getEncryptionSession | getEncryptionSession} callback to surface the
35
+ * session identifier. TODO: add support for `createEncryptedSessionEndpoint` once the native
36
+ * hooks implement that pathway.
39
37
  */
40
38
  export type EmbeddedWalletConfiguration = CommonEmbeddedWalletConfiguration & EncryptionSession;
41
39
  /**
@@ -48,7 +46,7 @@ type RpcUrls = {
48
46
  };
49
47
  type NativeCurrency = {
50
48
  name: string;
51
- /** 2-6 characters long */
49
+ /** 2-6 characters long. */
52
50
  symbol: string;
53
51
  decimals: number;
54
52
  };
@@ -56,62 +54,91 @@ type BlockExplorer = {
56
54
  name: string;
57
55
  url: string;
58
56
  };
59
- /** A subset of WAGMI's chain type
57
+ /**
58
+ * A subset of WAGMI's chain type.
59
+ *
60
60
  * https://github.com/wagmi-dev/references/blob/6aea7ee9c65cfac24f33173ab3c98176b8366f05/packages/chains/src/types.ts#L8
61
61
  */
62
62
  export type Chain = {
63
- /** Id in number form */
63
+ /** Chain identifier in number form. */
64
64
  id: number;
65
- /** Human readable name */
65
+ /** Human readable name. */
66
66
  name: string;
67
- /** Internal network name */
67
+ /** Internal network name. */
68
68
  network?: string;
69
- /** Currency used by chain */
69
+ /** Currency used by chain. */
70
70
  nativeCurrency: NativeCurrency;
71
- /** Collection of block explorers */
71
+ /** Collection of block explorers. */
72
72
  blockExplorers?: {
73
73
  [key: string]: BlockExplorer;
74
74
  default: BlockExplorer;
75
75
  };
76
- /** Collection of RPC endpoints */
76
+ /** Collection of RPC endpoints. */
77
77
  rpcUrls: {
78
78
  [key: string]: RpcUrls;
79
79
  default: RpcUrls;
80
80
  };
81
- /** Flag for test networks */
81
+ /** Flag for test networks. */
82
82
  testnet?: boolean;
83
83
  };
84
84
  /**
85
- * Props for the OpenfortProvider component
85
+ * Props for the {@link OpenfortProvider} component.
86
86
  */
87
87
  export interface OpenfortProviderProps {
88
88
  children: React.ReactNode;
89
89
  customAuth?: CustomAuthConfig;
90
90
  /**
91
- * Openfort application ID (can be found in openfort developer dashboard)
91
+ * Openfort application ID (can be found in the Openfort developer dashboard).
92
92
  */
93
93
  publishableKey: string;
94
94
  supportedChains?: [Chain, ...Chain[]];
95
95
  /**
96
- * Embedded signer configuration for Shield integration
96
+ * Embedded signer configuration for Shield integration.
97
97
  */
98
98
  walletConfig?: EmbeddedWalletConfiguration;
99
99
  /**
100
- * SDK overrides configuration for advanced customization
100
+ * SDK overrides configuration for advanced customization.
101
101
  */
102
102
  overrides?: SDKOverrides;
103
103
  /**
104
- * Third party auth configuration for integrating with external auth providers
104
+ * Third party auth configuration for integrating with external auth providers.
105
105
  */
106
106
  thirdPartyAuth?: ThirdPartyAuthConfiguration;
107
107
  /**
108
- * Enable verbose logging for debugging purposes
108
+ * Enable verbose logging for debugging purposes.
109
109
  */
110
110
  verbose?: boolean;
111
111
  }
112
112
  /**
113
- * Main provider component that wraps the entire application and provides
114
- * Openfort SDK functionality through React context
113
+ * Provider component that initialises the Openfort SDK and exposes its state via {@link OpenfortContext}
114
+ *
115
+ * This component must wrap your React Native app to provide Openfort functionality to all child components.
116
+ * It initializes the SDK with the provided configuration and manages authentication state.
117
+ *
118
+ * @param props - Provider configuration including the publishable key and optional overrides
119
+ * @returns A React element that provides the Openfort context to its children
120
+ *
121
+ * @example
122
+ * ```tsx
123
+ * import { OpenfortProvider } from '@openfort/react-native';
124
+ * import { polygon, polygonMumbai } from 'viem/chains';
125
+ *
126
+ * function App() {
127
+ * return (
128
+ * <OpenfortProvider
129
+ * publishableKey="pk_test_..."
130
+ * supportedChains={[polygon, polygonMumbai]}
131
+ * walletConfig={{
132
+ * shieldPublishableKey: "shield_pk_...",
133
+ * getEncryptionSession: () => fetchEncryptionSession(),
134
+ * }}
135
+ * verbose={true}
136
+ * >
137
+ * <YourAppContent />
138
+ * </OpenfortProvider>
139
+ * );
140
+ * }
141
+ * ```
115
142
  */
116
143
  export declare const OpenfortProvider: ({ children, publishableKey, customAuth, supportedChains, walletConfig, overrides, thirdPartyAuth, verbose, }: OpenfortProviderProps) => React.JSX.Element;
117
144
  export {};
@@ -23,13 +23,16 @@ interface OpenfortStorage {
23
23
  }>;
24
24
  }
25
25
  /**
26
- * Storage adapter using `expo-secure-store` intended for
27
- * use with `Openfort` class from `@openfort/openfort-js`.
26
+ * Storage adapter backed by {@link SecureStore} that matches the {@link Storage} interface expected by `@openfort/openfort-js`.
27
+ *
28
+ * The adapter normalises the keys provided by the Openfort SDK so they can be safely persisted via Expo Secure Store.
28
29
  */
29
30
  export declare const SecureStorageAdapter: OpenfortStorage;
30
31
  /**
31
- * Creates a type-safe storage adapter that bridges between the Openfort SDK's
32
- * expected Storage interface and our React Native implementation
32
+ * Creates a type-safe storage adapter that bridges the Openfort SDK storage API with the React Native implementation.
33
+ *
34
+ * @param customStorage - Optional custom storage implementation. When omitted the {@link SecureStorageAdapter} is used.
35
+ * @returns An object that satisfies the {@link Storage} interface expected by `@openfort/openfort-js`.
33
36
  */
34
37
  export declare function createNormalizedStorage(customStorage?: OpenfortStorage): Storage;
35
38
  export {};
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Authentication hooks index
2
+ * Authentication hooks index.
3
3
  *
4
4
  * This module re-exports all authentication-related hooks for convenient importing.
5
5
  */
@@ -1,4 +1,13 @@
1
1
  export type CreateWalletPostAuthOptions = {};
2
+ /**
3
+ * Hook for creating wallets after user authentication.
4
+ *
5
+ * TODO: the implementation is currently a placeholder that always returns an
6
+ * undefined wallet. Once the post-auth wallet flow is wired up, this helper will
7
+ * attempt to provision or connect an embedded wallet automatically.
8
+ *
9
+ * @returns Object containing wallet creation utilities (placeholder for now).
10
+ */
2
11
  export declare const useCreateWalletPostAuth: () => {
3
12
  tryUseWallet: ({}: CreateWalletPostAuthOptions) => Promise<{
4
13
  wallet: undefined;
@@ -43,6 +43,32 @@ export type EmailVerificationResult = {
43
43
  export type UseEmailHookOptions = {
44
44
  emailVerificationRedirectTo?: string;
45
45
  } & OpenfortHookOptions<EmailAuthResult | EmailVerificationResult> & CreateWalletPostAuthOptions;
46
+ /**
47
+ * Hook for email and password authentication.
48
+ *
49
+ * This hook provides email/password authentication flows including sign-in, sign-up, and
50
+ * account linking. Password reset and verification helpers are exposed but currently stubbed
51
+ * (TODOs) until the SDK wiring is complete.
52
+ *
53
+ * @param hookOptions - Optional configuration with callback functions and email verification settings.
54
+ * @returns Email authentication state and methods with flow status indicators.
55
+ *
56
+ * @example
57
+ * ```tsx
58
+ * const { signInEmail, signUpEmail, linkEmail, isLoading, requiresEmailVerification } = useEmailAuth({
59
+ * onSuccess: ({ user }) => console.log('Email auth successful:', user?.id),
60
+ * onError: ({ error }) => console.error('Email auth failed:', error?.message),
61
+ * });
62
+ *
63
+ * await signUpEmail({ email: 'user@example.com', password: 'securePassword123' });
64
+ *
65
+ * if (requiresEmailVerification) {
66
+ * console.log('Check email for verification code');
67
+ * }
68
+ *
69
+ * await signInEmail({ email: 'user@example.com', password: 'securePassword123' });
70
+ * ```
71
+ */
46
72
  export declare const useEmailAuth: (hookOptions?: UseEmailHookOptions) => {
47
73
  isLoading: boolean;
48
74
  isError: boolean;
@@ -1,35 +1,33 @@
1
- /**
2
- * Hook for creating guest accounts
3
- */
4
1
  import type { AuthPlayerResponse as OpenfortUser } from '@openfort/openfort-js';
5
2
  import { OpenfortHookOptions } from '../../types/hookOption';
6
3
  import { OpenfortError } from '../../types/openfortError';
7
4
  import { CreateWalletPostAuthOptions } from './useCreateWalletPostAuth';
5
+ export type GuestHookResult = {
6
+ error?: OpenfortError;
7
+ user?: OpenfortUser;
8
+ };
9
+ export type GuestHookOptions = OpenfortHookOptions<GuestHookResult> & CreateWalletPostAuthOptions;
8
10
  /**
9
- * Hook for creating guest accounts
11
+ * Hook for creating guest accounts.
10
12
  *
11
- * Guest accounts allow users to access certain features without full authentication.
12
- * These accounts can later be upgraded to full accounts by linking authentication methods.
13
+ * Guest accounts allow users to access certain features without full authentication and can later be upgraded to full accounts
14
+ * by linking additional authentication methods.
13
15
  *
14
- * @param opts - Configuration options including success/error callbacks
15
- * @returns Object with create function
16
+ * @param hookOptions - Configuration options including success and error callbacks.
17
+ * @returns Current guest authentication helpers with flow status indicators.
16
18
  *
17
19
  * @example
18
20
  * ```tsx
19
- * const { create } = useGuestAuth({
20
- * onSuccess: (user) => console.log('Guest account created:', user),
21
- * onError: (error) => console.error('Failed to create guest account:', error),
21
+ * const { signUpGuest, isLoading } = useGuestAuth({
22
+ * onSuccess: ({ user }) => console.log('Guest account created:', user),
23
+ * onError: ({ error }) => console.error('Failed to create guest account:', error),
22
24
  * });
23
25
  *
24
- * // Create a guest account
25
- * const guestUser = await create();
26
+ * if (!isLoading) {
27
+ * await signUpGuest();
28
+ * }
26
29
  * ```
27
30
  */
28
- export type GuestHookResult = {
29
- error?: OpenfortError;
30
- user?: OpenfortUser;
31
- };
32
- export type GuestHookOptions = OpenfortHookOptions<GuestHookResult> & CreateWalletPostAuthOptions;
33
31
  export declare const useGuestAuth: (hookOptions?: GuestHookOptions) => {
34
32
  isLoading: boolean;
35
33
  isError: boolean;
@@ -1,6 +1,3 @@
1
- /**
2
- * Hook for OAuth-based login functionality
3
- */
4
1
  import { OAuthProvider, type AuthPlayerResponse as OpenfortUser } from '@openfort/openfort-js';
5
2
  import { OpenfortHookOptions } from '../../types/hookOption';
6
3
  import { CreateWalletPostAuthOptions } from './useCreateWalletPostAuth';
@@ -22,33 +19,30 @@ export type AuthHookOptions = {
22
19
  redirectTo?: string;
23
20
  } & OpenfortHookOptions<StoreCredentialsResult | InitOAuthReturnType> & CreateWalletPostAuthOptions;
24
21
  /**
25
- * Hook for OAuth-based authentication with supported providers
22
+ * Hook for OAuth-based authentication with supported providers.
26
23
  *
27
- * This hook provides OAuth authentication flow for various providers (Google, Apple, Discord, etc.).
28
- * It opens the provider's web authentication page and handles the OAuth flow automatically.
24
+ * This hook provides helpers for starting OAuth login flows (`initOAuth`) and linking
25
+ * additional providers to an authenticated user (`linkOauth`). Some advanced flows may
26
+ * require manual credential storage via `storeCredentials`, which is currently a TODO.
29
27
  *
30
- * @param opts - Configuration options including success/error callbacks
31
- * @returns Object with login function and current OAuth flow state
28
+ * @param hookOptions - Configuration options including success and error callbacks.
29
+ * @returns OAuth helpers and derived flow state flags.
32
30
  *
33
31
  * @example
34
32
  * ```tsx
35
- * const { login, state } = useLoginWithOAuth({
36
- * onSuccess: (user) => console.log('OAuth login successful:', user),
37
- * onError: (error) => console.error('OAuth login failed:', error),
33
+ * const { initOAuth, linkOauth, isLoading, isError, error } = useOAuth({
34
+ * onSuccess: ({ user }) => console.log('OAuth completed for', user?.id),
38
35
  * });
39
36
  *
40
- * // Login with Google
41
- * const user = await login({ provider: 'google' });
37
+ * // Start a login flow
38
+ * await initOAuth({ provider: OAuthProvider.GOOGLE });
42
39
  *
43
- * // Login with Apple (using legacy web flow on iOS if needed)
44
- * const user = await login({
45
- * provider: 'apple',
46
- * isLegacyAppleIosBehaviorEnabled: true
47
- * });
40
+ * // Later, link another provider for the signed-in user
41
+ * await linkOauth({ provider: OAuthProvider.DISCORD });
48
42
  *
49
- * // Other supported providers
50
- * await login({ provider: 'discord' });
51
- * await login({ provider: 'twitter' });
43
+ * if (isError) {
44
+ * console.warn('Latest OAuth attempt failed', error);
45
+ * }
52
46
  * ```
53
47
  */
54
48
  export declare const useOAuth: (hookOptions?: AuthHookOptions) => {
@@ -1,5 +1,37 @@
1
1
  import { OpenfortHookOptions } from "../../types/hookOption";
2
2
  import { OpenfortError } from "../../types/openfortError";
3
+ /**
4
+ * Hook for user sign out functionality
5
+ *
6
+ * This hook provides secure sign out capabilities that clear user authentication state
7
+ * and refresh the application context to reflect the unauthenticated state.
8
+ *
9
+ * @param hookOptions - Optional configuration with callback functions for handling success and error events
10
+ * @returns Sign out method with loading and error state indicators
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * const { signOut, isLoading, isError, error } = useSignOut({
15
+ * onSuccess: () => console.log('Successfully signed out'),
16
+ * onError: ({ error }) => console.error('Sign out failed:', error?.message),
17
+ * });
18
+ *
19
+ * // Sign out the current user
20
+ * if (!isLoading) {
21
+ * await signOut();
22
+ * }
23
+ *
24
+ * // Handle loading states
25
+ * if (isLoading) {
26
+ * console.log('Signing out...');
27
+ * }
28
+ *
29
+ * // Handle errors
30
+ * if (isError && error) {
31
+ * console.error('Sign out error:', error.message);
32
+ * }
33
+ * ```
34
+ */
3
35
  export declare function useSignOut(hookOptions?: OpenfortHookOptions): {
4
36
  signOut: (options?: OpenfortHookOptions) => Promise<{} | undefined>;
5
37
  isLoading: boolean;
@@ -1,6 +1,3 @@
1
- /**
2
- * Hook for linking Ethereum accounts using SIWE to existing users
3
- */
4
1
  import { AuthPlayerResponse as OpenfortUser } from '@openfort/openfort-js';
5
2
  import { OpenfortHookOptions } from '../../types/hookOption';
6
3
  import { OpenfortError } from '../../types/openfortError';
@@ -33,6 +30,31 @@ type GenerateSiweMessageResult = {
33
30
  error?: OpenfortError;
34
31
  message?: string;
35
32
  };
33
+ /**
34
+ * Hook for handling Sign-In With Ethereum (SIWE) flows.
35
+ *
36
+ * This hook orchestrates SIWE message generation, signature submission, and state
37
+ * tracking so that external wallets can either authenticate a user (`signInWithSiwe`)
38
+ * or be linked to an existing account (`linkSiwe`).
39
+ *
40
+ * @param hookOptions - Optional callbacks for handling success or error events from the SIWE flows.
41
+ * @returns SIWE helpers for generating messages, signing in, linking wallets, and inspecting flow status.
42
+ *
43
+ * @example
44
+ * ```tsx
45
+ * const { generateSiweMessage, signInWithSiwe, linkSiwe, isAwaitingSignature } = useWalletAuth({
46
+ * onSuccess: ({ user }) => console.log('SIWE flow completed for', user?.id),
47
+ * });
48
+ *
49
+ * const { message } = await generateSiweMessage({
50
+ * wallet: connectedWallet.address,
51
+ * from: { domain: 'app.openfort.io', uri: 'https://app.openfort.io' },
52
+ * });
53
+ *
54
+ * const signature = await connectedWallet.signMessage(message);
55
+ * await signInWithSiwe({ walletAddress: connectedWallet.address, signature, messageOverride: message });
56
+ * ```
57
+ */
36
58
  export declare function useWalletAuth(hookOptions?: WalletHookOptions): {
37
59
  isLoading: boolean;
38
60
  isError: boolean;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Core hooks index
2
+ * Core hooks index.
3
3
  *
4
4
  * This module re-exports all core SDK hooks for convenient importing.
5
5
  */
@@ -1,38 +1,38 @@
1
1
  import { UseOpenfort } from '../../types';
2
2
  /**
3
- * Hook that exposes the core state of the Openfort SDK
3
+ * Hook that exposes the core state of the Openfort SDK.
4
4
  *
5
- * This hook provides access to the current authenticated user object,
6
- * SDK initialization status, and core authentication methods.
5
+ * This hook provides access to the current authenticated user object, SDK initialization status, and core authentication methods.
7
6
  *
8
- * @returns The Openfort SDK's core state and methods
7
+ * @returns The Openfort SDK's core state and methods.
9
8
  *
10
9
  * @example
11
10
  * ```tsx
12
- * const { user, isReady, error, logout, getAccessToken } = useOpenfort();
11
+ * import { ActivityIndicator, Button, Text, View } from 'react-native';
12
+ * import { useOpenfort } from '@openfort/react-native/hooks';
13
13
  *
14
- * // Check if SDK is ready
15
- * if (!isReady) {
16
- * return <LoadingSpinner />;
17
- * }
14
+ * export function HomeScreen() {
15
+ * const { user, isReady, error, logout } = useOpenfort();
18
16
  *
19
- * // Handle initialization errors
20
- * if (error) {
21
- * return <ErrorDisplay error={error} />;
22
- * }
17
+ * if (!isReady) {
18
+ * return <ActivityIndicator size="large" />;
19
+ * }
23
20
  *
24
- * // Check authentication status
25
- * if (!user) {
26
- * return <LoginScreen />;
27
- * }
21
+ * if (error) {
22
+ * return <Text>{`Failed to initialise: ${error.message}`}</Text>;
23
+ * }
28
24
  *
29
- * // User is authenticated
30
- * return (
31
- * <div>
32
- * <h1>Welcome, {user.id}!</h1>
33
- * <button onClick={logout}>Logout</button>
34
- * </div>
35
- * );
25
+ * if (!user) {
26
+ * return <Text>Please sign in</Text>;
27
+ * }
28
+ *
29
+ * return (
30
+ * <View>
31
+ * <Text>{`Welcome, ${user.id}`}</Text>
32
+ * <Button title="Log out" onPress={() => void logout()} />
33
+ * </View>
34
+ * );
35
+ * }
36
36
  * ```
37
37
  */
38
38
  export declare function useOpenfort(): UseOpenfort;
@@ -1,29 +1,21 @@
1
- /**
2
- * Hook for accessing the Openfort client instance
3
- */
4
1
  import type { Openfort as OpenfortClient } from '@openfort/openfort-js';
5
2
  /**
6
- * Hook for accessing the Openfort client instance directly
3
+ * Hook for accessing the Openfort client instance directly.
7
4
  *
8
- * This hook provides access to the underlying Openfort client for advanced use cases
9
- * where you need direct access to the client methods.
5
+ * This hook exposes the underlying {@link OpenfortClient} so that advanced consumer code can access low-level methods that are
6
+ * not surfaced through the convenience hooks.
10
7
  *
11
- * @returns The Openfort client instance
8
+ * @returns The current {@link OpenfortClient} instance from context.
12
9
  *
13
10
  * @example
14
11
  * ```tsx
15
12
  * const client = useOpenfortClient();
16
13
  *
17
- * // Use client methods directly
18
- * const customResult = await client.auth.customMethod();
19
- *
20
- * // Access client configuration
21
- * console.log('App ID:', client.config.appId);
14
+ * // Invoke a raw SDK method
15
+ * const token = await client.getAccessToken();
22
16
  *
23
- * // Check client status
24
- * if (client.isInitialized) {
25
- * // Perform operations that require initialization
26
- * }
17
+ * // Access nested services
18
+ * await client.auth.logout();
27
19
  * ```
28
20
  */
29
21
  export declare function useOpenfortClient(): OpenfortClient;
@@ -1,3 +1,31 @@
1
+ /**
2
+ * Hook for accessing current user state and authentication status
3
+ *
4
+ * This hook provides access to the current user's information and authentication state.
5
+ * It automatically updates when the user signs in, signs out, or their profile changes.
6
+ *
7
+ * @returns Current user data, authentication status, and access token getter
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * const { user, isAuthenticated, getAccessToken } = useUser();
12
+ *
13
+ * // Check if user is authenticated
14
+ * if (isAuthenticated && user) {
15
+ * console.log('Authenticated user:', user.id);
16
+ * console.log('User email:', user.email);
17
+ *
18
+ * // Get access token for API calls
19
+ * const token = await getAccessToken();
20
+ * console.log('Access token available:', !!token);
21
+ * } else {
22
+ * console.log('User not authenticated');
23
+ * }
24
+ *
25
+ * // Use in conditional rendering
26
+ * return isAuthenticated ? <Dashboard user={user} /> : <LoginForm />;
27
+ * ```
28
+ */
1
29
  export declare function useUser(): {
2
30
  user: import("@openfort/openfort-js").AuthPlayerResponse | null;
3
31
  isAuthenticated: boolean;
@@ -1,11 +1,12 @@
1
1
  /**
2
- * Openfort React Native SDK Hooks
2
+ * Openfort React Native SDK hooks.
3
3
  *
4
- * This module provides a comprehensive set of React hooks for integrating
5
- * with the Openfort platform in React Native applications.
6
- *
7
- * The hooks are organized into the following categories:
8
- * - Core: Core SDK functionality hooks
4
+ * This barrel re-exports all hook collections that ship with the SDK so consumers can
5
+ * import from `@openfort/react-native/hooks`. The hooks are organised into the
6
+ * following sub-modules:
7
+ * - Core: Lifecycle/state helpers (e.g. `useOpenfort`)
8
+ * - Auth: Authentication helpers (email, OAuth, SIWE, guest)
9
+ * - Wallet: Embedded wallet management utilities
9
10
  */
10
11
  export * from './core';
11
12
  export * from './auth';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Wallet hooks index
2
+ * Wallet hooks index.
3
3
  *
4
4
  * This module re-exports all wallet-related hooks for convenient importing.
5
5
  */
@@ -1 +1,28 @@
1
+ /**
2
+ * Hook for accessing the currently active embedded wallet
3
+ *
4
+ * This hook provides access to the currently active embedded wallet from the wallet collection.
5
+ * It automatically updates when the active wallet changes through other wallet operations.
6
+ *
7
+ * @returns The active embedded wallet when available, otherwise `null`
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * const activeWallet = useWallet();
12
+ *
13
+ * // Check if wallet is available
14
+ * if (activeWallet) {
15
+ * console.log('Active wallet address:', activeWallet.address);
16
+ *
17
+ * // Get provider for transactions
18
+ * const provider = await activeWallet.getProvider();
19
+ *
20
+ * // Use wallet for operations
21
+ * console.log('Wallet chain type:', activeWallet.chainType);
22
+ * console.log('Is connecting:', activeWallet.isConnecting);
23
+ * } else {
24
+ * console.log('No active wallet available');
25
+ * }
26
+ * ```
27
+ */
1
28
  export declare function useWallet(): import("../..").UserWallet | null;