@openfort/react-native 0.1.18 → 0.1.20

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.
@@ -69,7 +69,7 @@ function startEmbeddedStatePolling(client, onChange, intervalMs = 1000) {
69
69
  * }
70
70
  * ```
71
71
  */
72
- export const OpenfortProvider = ({ children, publishableKey, customAuth, supportedChains, walletConfig, overrides, thirdPartyAuth, verbose = false, }) => {
72
+ export const OpenfortProvider = ({ children, publishableKey, supportedChains, walletConfig, overrides, thirdPartyAuth, verbose = false, }) => {
73
73
  // Validate environment variables before anything else
74
74
  validateEnvironment({
75
75
  publishableKey,
@@ -215,33 +215,10 @@ export const OpenfortProvider = ({ children, publishableKey, customAuth, support
215
215
  cancelled = true;
216
216
  };
217
217
  }, [client, isUserInitialized, handleUserChange, refreshUserState]);
218
- // Custom auth state management
219
- useEffect(() => {
220
- if (customAuth?.enabled && isUserInitialized && isClientReady) {
221
- ;
222
- (async () => {
223
- try {
224
- const { getCustomAccessToken, isLoading } = customAuth;
225
- if (isLoading)
226
- return;
227
- const customToken = await getCustomAccessToken();
228
- if (customToken) {
229
- // Custom auth sync implementation would go here
230
- // This would typically handle SIWE authentication with the custom token
231
- logger.debug('Custom token available for authentication sync');
232
- }
233
- }
234
- catch (err) {
235
- logger.error('Custom auth sync failed', err);
236
- }
237
- })();
238
- }
239
- }, [client, customAuth, isUserInitialized, isClientReady]);
240
218
  // Determine if SDK is ready
241
219
  const isReady = useMemo(() => {
242
- const customAuthReady = !customAuth?.enabled || !customAuth.isLoading;
243
- return isUserInitialized && isClientReady && customAuthReady;
244
- }, [isUserInitialized, isClientReady, customAuth?.enabled, customAuth?.isLoading]);
220
+ return isUserInitialized && isClientReady;
221
+ }, [isUserInitialized, isClientReady]);
245
222
  // Context value
246
223
  const contextValue = useMemo(() => ({
247
224
  client,
@@ -8,32 +8,6 @@ import { NativeStorageUtils } from '../native';
8
8
  * providing read-after-write consistency while keeping `save` synchronous.
9
9
  */
10
10
  const pendingWrites = new Map();
11
- /**
12
- * Creates a scope prefix from the publishable key.
13
- * Extracts the unique project identifier after the "pk_test_" or "pk_live_" prefix.
14
- * Uses the first 8 characters of that unique part to keep keys readable.
15
- *
16
- * e.g., "pk_test_abc123xyz789" -> "abc123xy"
17
- */
18
- function createScope(publishableKey) {
19
- // Remove the "pk_test_" or "pk_live_" prefix (8 characters)
20
- const uniquePart = publishableKey.substring(8);
21
- // Use first 8 characters of the unique part as scope
22
- return uniquePart.substring(0, 8);
23
- }
24
- // Define the StorageKeys enum values that match the Openfort SDK
25
- var StorageKeys;
26
- (function (StorageKeys) {
27
- StorageKeys["AUTHENTICATION"] = "openfort.authentication";
28
- StorageKeys["SIGNER"] = "openfort.signer";
29
- StorageKeys["CONFIGURATION"] = "openfort.configuration";
30
- StorageKeys["ACCOUNT"] = "openfort.account";
31
- StorageKeys["TEST"] = "openfort.test";
32
- StorageKeys["RECOVERY"] = "openfort.recovery";
33
- StorageKeys["SESSION"] = "openfort.session";
34
- StorageKeys["PKCE_STATE"] = "openfort.pkce_state";
35
- StorageKeys["PKCE_VERIFIER"] = "openfort.pkce_verifier";
36
- })(StorageKeys || (StorageKeys = {}));
37
11
  /**
38
12
  * Storage adapter backed by {@link SecureStore} that matches the {@link Storage} interface expected by `@openfort/openfort-js`.
39
13
  *
@@ -118,85 +92,36 @@ function normalizeKey(key) {
118
92
  return key.replaceAll(':', '-');
119
93
  }
120
94
  /**
121
- * Creates a type-safe storage adapter that bridges the Openfort SDK storage API with the React Native implementation.
122
- * Storage keys are scoped by publishable key to isolate data between different projects.
95
+ * Creates a storage adapter that bridges the Openfort SDK storage API with the React Native implementation.
96
+ * The core SDK's ScopedStorage handles key scoping, so this adapter simply passes keys through.
123
97
  *
124
- * @param publishableKey - The publishable key used to scope storage keys.
98
+ * @param _publishableKey - Unused. Key scoping is handled by the core SDK.
125
99
  * @param customStorage - Optional custom storage implementation. When omitted the {@link SecureStorageAdapter} is used.
126
100
  * @returns An object that satisfies the {@link Storage} interface expected by `@openfort/openfort-js`.
127
101
  */
128
- export function createNormalizedStorage(publishableKey, customStorage) {
102
+ export function createNormalizedStorage(_publishableKey, customStorage) {
129
103
  const baseStorage = customStorage || SecureStorageAdapter;
130
- const scope = createScope(publishableKey);
131
- /**
132
- * Prefixes a storage key with the scope.
133
- * e.g., "openfort.authentication" -> "abc123xy.openfort.authentication"
134
- */
135
- function scopeKey(key) {
136
- return `${scope}.${key}`;
137
- }
138
104
  return {
139
105
  async get(key) {
140
- // Convert the unknown key to our StorageKeys enum
141
- const storageKey = keyToStorageKeys(key);
142
- const scopedKey = scopeKey(storageKey);
143
- const result = await baseStorage.get(scopedKey);
144
- return result;
106
+ const keyString = String(key);
107
+ return baseStorage.get(keyString);
145
108
  },
146
109
  save(key, value) {
147
- logger.info(`Saving to storage key: ${key}, value: ${value}`);
148
- const storageKey = keyToStorageKeys(key);
149
- const scopedKey = scopeKey(storageKey);
110
+ const keyString = String(key);
150
111
  // Fire and forget - don't await as the SDK expects synchronous behavior
151
- baseStorage.save(scopedKey, value).catch((error) => {
112
+ baseStorage.save(keyString, value).catch((error) => {
152
113
  logger.error('Failed to save to storage', error);
153
114
  });
154
115
  },
155
116
  remove(key) {
156
- logger.info(`Removing from storage key: ${key}`);
157
- const storageKey = keyToStorageKeys(key);
158
- const scopedKey = scopeKey(storageKey);
117
+ const keyString = String(key);
159
118
  // Fire and forget - don't await as the SDK expects synchronous behavior
160
- baseStorage.remove(scopedKey).catch((error) => {
119
+ baseStorage.remove(keyString).catch((error) => {
161
120
  logger.error('Failed to remove from storage', error);
162
121
  });
163
122
  },
164
123
  flush() {
165
- logger.info('Flushing storage');
166
- // Remove all scoped keys for this project
167
- for (const key of Object.values(StorageKeys)) {
168
- const scopedKey = scopeKey(key);
169
- baseStorage.remove(scopedKey).catch((error) => {
170
- logger.error('Failed to remove from storage during flush', error);
171
- });
172
- }
124
+ baseStorage.flush();
173
125
  },
174
126
  };
175
127
  }
176
- /**
177
- * Converts a key provided by the Openfort SDK to the local {@link StorageKeys} enum.
178
- *
179
- * @param key - Value provided by the Openfort SDK. Can be a string or an enum-like
180
- * object.
181
- * @returns The matching {@link StorageKeys} value.
182
- * @throws {Error} When the key cannot be mapped to one of the known storage keys.
183
- */
184
- function keyToStorageKeys(key) {
185
- if (typeof key === 'string') {
186
- // Check if the string matches one of our enum values
187
- const storageKey = Object.values(StorageKeys).find((value) => value === key);
188
- if (storageKey) {
189
- return storageKey;
190
- }
191
- }
192
- // If it's an enum-like object, try to get its value
193
- if (typeof key === 'object' && key !== null && 'toString' in key) {
194
- const keyString = key.toString();
195
- const storageKey = Object.values(StorageKeys).find((value) => value === keyString);
196
- if (storageKey) {
197
- return storageKey;
198
- }
199
- }
200
- // Fallback: throw an error for unknown keys
201
- throw new Error(`Unknown storage key: ${key}. Expected one of: ${Object.values(StorageKeys).join(', ')}`);
202
- }
@@ -51,7 +51,7 @@ export function useWallets(hookOptions = {}) {
51
51
  const { client, user, supportedChains, walletConfig, embeddedState, _internal } = useOpenfortContext();
52
52
  const [embeddedAccounts, setEmbeddedAccounts] = useState([]);
53
53
  const recoverPromiseRef = useRef(null);
54
- const [activeWalletId, setActiveWalletId] = useState(null); // OPENFORT-JS Should provide this
54
+ const [activeWalletId, setActiveWalletId] = useState(null);
55
55
  const [status, setStatus] = useState({
56
56
  status: 'idle',
57
57
  });
@@ -154,7 +154,7 @@ export function useWallets(hookOptions = {}) {
154
154
  if (!embeddedAccountToRecover) {
155
155
  const errorMsg = walletConfig?.accountType === AccountTypeEnum.EOA
156
156
  ? `No embedded EOA account found for address ${address}`
157
- : `No embedded account found for address ${address} on chain ID ${chainId}`;
157
+ : `No embedded smart account found for address ${address} on chain ID ${chainId}`;
158
158
  throw new OpenfortError(errorMsg, OpenfortErrorType.WALLET_ERROR);
159
159
  }
160
160
  else {
@@ -319,10 +319,9 @@ export function useWallets(hookOptions = {}) {
319
319
  // Use the first supported chain as default
320
320
  chainId = supportedChains[0].id;
321
321
  }
322
- else {
322
+ else if (options?.chainType !== ChainTypeEnum.SVM) {
323
323
  throw new OpenfortError('No supported chains available for wallet creation', OpenfortErrorType.WALLET_ERROR);
324
324
  }
325
- logger.info('Using chain ID for wallet creation', chainId);
326
325
  let recoveryParams;
327
326
  if (options?.recoveryPassword) {
328
327
  recoveryParams = {
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@
11
11
  // Re-export commonly used types from @openfort/openfort-js
12
12
  // Re-export enums and values from @openfort/openfort-js
13
13
  // Re-export event listener functionality from @openfort/openfort-js
14
- export { AccountTypeEnum, EmbeddedState, OAuthProvider, Openfort as OpenfortClient, OpenfortConfiguration, OpenfortError, OpenfortEvents, openfortEvents, RecoveryMethod, ShieldConfiguration, } from '@openfort/openfort-js';
14
+ export { AccountTypeEnum, ChainTypeEnum, EmbeddedState, OAuthProvider, Openfort as OpenfortClient, OpenfortConfiguration, OpenfortError, OpenfortEvents, openfortEvents, RecoveryMethod, ShieldConfiguration, } from '@openfort/openfort-js';
15
15
  // Re-export all components and UI elements
16
16
  export * from './components';
17
17
  // Re-export constants
@@ -19,9 +19,7 @@
19
19
  */
20
20
  export const onSuccess = ({ hookOptions, options, data, }) => {
21
21
  hookOptions?.onSuccess?.(data);
22
- hookOptions?.onSettled?.(data, null);
23
22
  options?.onSuccess?.(data);
24
- options?.onSettled?.(data, null);
25
23
  return data;
26
24
  };
27
25
  /**
@@ -49,9 +47,7 @@ export const onSuccess = ({ hookOptions, options, data, }) => {
49
47
  */
50
48
  export const onError = ({ hookOptions, options, error, }) => {
51
49
  hookOptions?.onError?.(error);
52
- hookOptions?.onSettled?.(null, error);
53
50
  options?.onError?.(error);
54
- options?.onSettled?.(null, error);
55
51
  if (hookOptions?.throwOnError || options?.throwOnError)
56
52
  throw error;
57
53
  return { error };
@@ -1,13 +1,5 @@
1
1
  import { type AccountTypeEnum, type SDKOverrides, type ThirdPartyAuthConfiguration } from '@openfort/openfort-js';
2
2
  import React from 'react';
3
- /**
4
- * Shape for configuring custom authentication synchronization behavior.
5
- */
6
- interface CustomAuthConfig {
7
- enabled: boolean;
8
- isLoading: boolean;
9
- getCustomAccessToken: () => Promise<string | null>;
10
- }
11
3
  type PolicyConfig = string | Record<number, string>;
12
4
  export type CommonEmbeddedWalletConfiguration = {
13
5
  /** Publishable key for the Shield API. */
@@ -88,7 +80,6 @@ export type Chain = {
88
80
  */
89
81
  export interface OpenfortProviderProps {
90
82
  children: React.ReactNode;
91
- customAuth?: CustomAuthConfig;
92
83
  /**
93
84
  * Openfort application ID (can be found in the Openfort developer dashboard).
94
85
  */
@@ -142,5 +133,5 @@ export interface OpenfortProviderProps {
142
133
  * }
143
134
  * ```
144
135
  */
145
- export declare const OpenfortProvider: ({ children, publishableKey, customAuth, supportedChains, walletConfig, overrides, thirdPartyAuth, verbose, }: OpenfortProviderProps) => React.JSX.Element;
136
+ export declare const OpenfortProvider: ({ children, publishableKey, supportedChains, walletConfig, overrides, thirdPartyAuth, verbose, }: OpenfortProviderProps) => React.JSX.Element;
146
137
  export {};
@@ -18,12 +18,12 @@ interface OpenfortStorage {
18
18
  */
19
19
  export declare const SecureStorageAdapter: OpenfortStorage;
20
20
  /**
21
- * Creates a type-safe storage adapter that bridges the Openfort SDK storage API with the React Native implementation.
22
- * Storage keys are scoped by publishable key to isolate data between different projects.
21
+ * Creates a storage adapter that bridges the Openfort SDK storage API with the React Native implementation.
22
+ * The core SDK's ScopedStorage handles key scoping, so this adapter simply passes keys through.
23
23
  *
24
- * @param publishableKey - The publishable key used to scope storage keys.
24
+ * @param _publishableKey - Unused. Key scoping is handled by the core SDK.
25
25
  * @param customStorage - Optional custom storage implementation. When omitted the {@link SecureStorageAdapter} is used.
26
26
  * @returns An object that satisfies the {@link Storage} interface expected by `@openfort/openfort-js`.
27
27
  */
28
- export declare function createNormalizedStorage(publishableKey: string, customStorage?: OpenfortStorage): Storage;
28
+ export declare function createNormalizedStorage(_publishableKey: string, customStorage?: OpenfortStorage): Storage;
29
29
  export {};
@@ -7,7 +7,7 @@
7
7
  * required to integrate Openfort authentication and embedded wallets into React Native and
8
8
  * Expo applications.
9
9
  */
10
- export { AccountTypeEnum, AuthInitPayload, AuthPlayerResponse, AuthResponse, EmbeddedAccount, EmbeddedState, OAuthProvider, Openfort as OpenfortClient, OpenfortConfiguration, OpenfortError, OpenfortEventMap, OpenfortEvents, openfortEvents, Provider, RecoveryMethod, RecoveryParams, ShieldConfiguration, SignedMessagePayload, } from '@openfort/openfort-js';
10
+ export { AccountTypeEnum, AuthInitPayload, AuthPlayerResponse, AuthResponse, ChainTypeEnum, EmbeddedAccount, EmbeddedState, OAuthProvider, Openfort as OpenfortClient, OpenfortConfiguration, OpenfortError, OpenfortEventMap, OpenfortEvents, openfortEvents, Provider, RecoveryMethod, RecoveryParams, ShieldConfiguration, SignedMessagePayload, } from '@openfort/openfort-js';
11
11
  export * from './components';
12
12
  export * from './constants';
13
13
  export * from './core';
@@ -39,21 +39,6 @@ export type SiweFlowState = {
39
39
  export type RecoveryFlowState = {
40
40
  status: 'initial' | 'creating-wallet' | 'upgrading-recovery' | 'recovering';
41
41
  };
42
- /**
43
- * Custom authentication flow state
44
- */
45
- export type CustomAuthFlowState = {
46
- status: 'initial';
47
- } | {
48
- status: 'loading';
49
- } | {
50
- status: 'not-enabled';
51
- } | {
52
- status: 'done';
53
- } | {
54
- status: 'error';
55
- error: Error | null;
56
- };
57
42
  /**
58
43
  * Authentication success callback
59
44
  */
@@ -1,23 +1,3 @@
1
- /**
2
- * Custom authentication provider configuration
3
- */
4
- export type CustomAuthProviderConfig = {
5
- /**
6
- * If true, enable custom authentication integration.
7
- * This enables a JWT from a custom auth provider to be used to authenticate Openfort embedded wallets.
8
- * Defaults to true.
9
- */
10
- enabled?: boolean;
11
- /**
12
- * A callback that returns the user's custom auth provider's access token as a string.
13
- * Can be left blank if using cookies to store and send access tokens
14
- */
15
- getCustomAccessToken: () => Promise<string | undefined>;
16
- /**
17
- * Custom auth providers loading state
18
- */
19
- isLoading: boolean;
20
- };
21
1
  /**
22
2
  * Create guest account interface
23
3
  */
@@ -4,6 +4,5 @@ export type OpenfortHookOptions<T = {
4
4
  }> = {
5
5
  onSuccess?: (data: T) => void;
6
6
  onError?: (error: OpenfortError) => void;
7
- onSettled?: (data: T | undefined | null, error: OpenfortError | null) => void;
8
7
  throwOnError?: boolean;
9
8
  };
@@ -13,8 +13,8 @@ export interface UseOpenfort {
13
13
  /** A function that gets the current authenticated user's access token. */
14
14
  getAccessToken: () => Promise<string | null>;
15
15
  }
16
- export type { AuthLinkSuccessCallback, AuthSuccessCallback, CustomAuthFlowState, EmailLinkHookOptions, EmailLinkHookResult, EmailLoginHookOptions, EmailLoginHookResult, ErrorCallback, GenerateSiweMessage, GenerateSiweMessageResponse, PasswordFlowState, RecoveryFlowState, SiweFlowState, SiweLinkHookOptions, SiweLinkHookResult, SiweLoginHookOptions, SiweLoginHookResult, } from './auth';
17
- export type { CustomAuthProviderConfig, SetRecoveryParams, UseGuestAuth, UseOnEmbeddedWalletStateChange, UseSetEmbeddedWalletRecovery, UseSetEmbeddedWalletRecoveryResult, } from './config';
16
+ export type { AuthLinkSuccessCallback, AuthSuccessCallback, EmailLinkHookOptions, EmailLinkHookResult, EmailLoginHookOptions, EmailLoginHookResult, ErrorCallback, GenerateSiweMessage, GenerateSiweMessageResponse, PasswordFlowState, RecoveryFlowState, SiweFlowState, SiweLinkHookOptions, SiweLinkHookResult, SiweLoginHookOptions, SiweLoginHookResult, } from './auth';
17
+ export type { SetRecoveryParams, UseGuestAuth, UseOnEmbeddedWalletStateChange, UseSetEmbeddedWalletRecovery, UseSetEmbeddedWalletRecoveryResult, } from './config';
18
18
  export type { LinkWithOAuthInput, LoginWithOAuthInput, OAuthFlowState, OAuthTokens, UnlinkOAuthOptions, UnlinkOAuthParams, UseLinkWithOAuth, UseLoginWithOAuth, UseOAuthTokensOptions, } from './oauth';
19
19
  export { canTransact, getActionText, getStateDescription, hasError, isConnected, isConnecting, isCreating, isDisconnected, isLoading, isNotCreated, isReady, isReconnecting, isStable, needsRecovery, needsUserAction, } from './predicates';
20
20
  export type { ConnectedEmbeddedEthereumWallet, ConnectedEmbeddedSolanaWallet, CreateSolanaEmbeddedWalletOpts, EmbeddedEthereumWalletActions, EmbeddedEthereumWalletState, EmbeddedSolanaWalletActions, EmbeddedSolanaWalletConnectedState, EmbeddedSolanaWalletConnectingState, EmbeddedSolanaWalletCreatingState, EmbeddedSolanaWalletDisconnectedState, EmbeddedSolanaWalletErrorState, EmbeddedSolanaWalletNeedsRecoveryState, EmbeddedSolanaWalletReconnectingState, EmbeddedSolanaWalletState, EmbeddedSolanaWalletStatus, EmbeddedWalletStatus, OpenfortEmbeddedWalletAccount, RecoverSolanaEmbeddedWalletOpts, RecoveryMethodOptions, SolanaWalletRecoveryCallbacks, UserWallet, WalletRecoveryCallbacks, } from './wallet';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@openfort/react-native",
3
3
  "main": "dist/index.js",
4
- "version": "0.1.18",
4
+ "version": "0.1.20",
5
5
  "license": "MIT",
6
6
  "description": "React Native SDK for Openfort platform integration",
7
7
  "types": "dist/types/index.d.ts",