@openfort/react-native 0.1.20 → 0.1.21
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/components/AuthBoundary.js +4 -1
- package/dist/core/index.js +1 -1
- package/dist/core/provider.js +0 -1
- package/dist/hooks/auth/useEmailAuth.js +90 -3
- package/dist/hooks/core/useOpenfort.js +3 -17
- package/dist/hooks/wallet/index.js +4 -2
- package/dist/hooks/wallet/solanaProvider.js +77 -0
- package/dist/hooks/wallet/useEmbeddedEthereumWallet.js +465 -0
- package/dist/hooks/wallet/useEmbeddedSolanaWallet.js +391 -0
- package/dist/hooks/wallet/utils.js +75 -0
- package/dist/lib/hookConsistency.js +6 -0
- package/dist/native/oauth.js +13 -0
- package/dist/native/storage.js +4 -0
- package/dist/native/webview.js +15 -1
- package/dist/types/components/AuthBoundary.d.ts +1 -0
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/hooks/auth/useEmailAuth.d.ts +6 -7
- package/dist/types/hooks/auth/useGuestAuth.d.ts +1 -2
- package/dist/types/hooks/auth/useOAuth.d.ts +1 -2
- package/dist/types/hooks/core/useOpenfort.d.ts +2 -13
- package/dist/types/hooks/wallet/index.d.ts +2 -1
- package/dist/types/hooks/wallet/solanaProvider.d.ts +75 -0
- package/dist/types/hooks/wallet/useEmbeddedEthereumWallet.d.ts +53 -0
- package/dist/types/hooks/wallet/useEmbeddedSolanaWallet.d.ts +47 -0
- package/dist/types/hooks/wallet/utils.d.ts +17 -0
- package/dist/types/index.js +1 -2
- package/dist/types/lib/hookConsistency.d.ts +6 -0
- package/dist/types/native/oauth.d.ts +13 -0
- package/dist/types/native/storage.d.ts +4 -0
- package/dist/types/native/webview.d.ts +14 -0
- package/dist/types/types/auth.d.ts +0 -41
- package/dist/types/types/index.d.ts +3 -30
- package/dist/types/types/oauth.d.ts +0 -38
- package/dist/types/types/wallet.d.ts +120 -216
- package/package.json +1 -1
- package/dist/hooks/auth/useCreateWalletPostAuth.js +0 -34
- package/dist/hooks/wallet/useWallets.js +0 -436
- package/dist/types/config.js +0 -1
- package/dist/types/hooks/auth/useCreateWalletPostAuth.d.ts +0 -1
- package/dist/types/hooks/wallet/useWallets.d.ts +0 -78
- package/dist/types/predicates.js +0 -120
- package/dist/types/types/config.d.ts +0 -39
- package/dist/types/types/predicates.d.ts +0 -118
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { OAuthProvider, type AuthPlayerResponse as OpenfortUser } from '@openfort/openfort-js';
|
|
2
2
|
import type { OpenfortHookOptions } from '../../types/hookOption';
|
|
3
3
|
import { OpenfortError } from '../../types/openfortError';
|
|
4
|
-
import type { CreateWalletPostAuthOptions } from './useCreateWalletPostAuth';
|
|
5
4
|
export type InitializeOAuthOptions = {
|
|
6
5
|
provider: OAuthProvider;
|
|
7
6
|
redirectTo?: string;
|
|
@@ -17,7 +16,7 @@ export type InitOAuthReturnType = {
|
|
|
17
16
|
};
|
|
18
17
|
export type AuthHookOptions = {
|
|
19
18
|
redirectTo?: string;
|
|
20
|
-
} & OpenfortHookOptions<StoreCredentialsResult | InitOAuthReturnType
|
|
19
|
+
} & OpenfortHookOptions<StoreCredentialsResult | InitOAuthReturnType>;
|
|
21
20
|
/**
|
|
22
21
|
* Hook for OAuth-based authentication with supported providers.
|
|
23
22
|
*
|
|
@@ -2,7 +2,7 @@ import type { UseOpenfort } from '../../types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Hook that exposes the core state of the Openfort SDK.
|
|
4
4
|
*
|
|
5
|
-
* This hook provides access to the current
|
|
5
|
+
* This hook provides access to the current SDK initialization status.
|
|
6
6
|
*
|
|
7
7
|
* @returns The Openfort SDK's core state and methods.
|
|
8
8
|
*
|
|
@@ -12,7 +12,7 @@ import type { UseOpenfort } from '../../types';
|
|
|
12
12
|
* import { useOpenfort } from '@openfort/react-native/hooks';
|
|
13
13
|
*
|
|
14
14
|
* export function HomeScreen() {
|
|
15
|
-
* const {
|
|
15
|
+
* const { isReady, error } = useOpenfort();
|
|
16
16
|
*
|
|
17
17
|
* if (!isReady) {
|
|
18
18
|
* return <ActivityIndicator size="large" />;
|
|
@@ -22,17 +22,6 @@ import type { UseOpenfort } from '../../types';
|
|
|
22
22
|
* return <Text>{`Failed to initialise: ${error.message}`}</Text>;
|
|
23
23
|
* }
|
|
24
24
|
*
|
|
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
25
|
* ```
|
|
37
26
|
*/
|
|
38
27
|
export declare function useOpenfort(): UseOpenfort;
|
|
@@ -3,4 +3,5 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This module re-exports all wallet-related hooks for convenient importing.
|
|
5
5
|
*/
|
|
6
|
-
export {
|
|
6
|
+
export { useEmbeddedEthereumWallet } from './useEmbeddedEthereumWallet';
|
|
7
|
+
export { useEmbeddedSolanaWallet } from './useEmbeddedSolanaWallet';
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { EmbeddedAccount } from '@openfort/openfort-js';
|
|
2
|
+
import type { OpenfortEmbeddedSolanaWalletProvider } from '../../types/wallet';
|
|
3
|
+
type SignMessageRequestArguments = {
|
|
4
|
+
method: 'signMessage';
|
|
5
|
+
params: {
|
|
6
|
+
message: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
type SignTransactionRequestArguments<T = any> = {
|
|
10
|
+
method: 'signTransaction';
|
|
11
|
+
params: {
|
|
12
|
+
transaction: T;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Embedded Solana wallet provider implementation for Openfort.
|
|
17
|
+
*
|
|
18
|
+
* This provider implements the request-based API pattern similar to EIP-1193
|
|
19
|
+
* but adapted for Solana operations.
|
|
20
|
+
*/
|
|
21
|
+
export declare class OpenfortSolanaProvider implements OpenfortEmbeddedSolanaWalletProvider {
|
|
22
|
+
private _account;
|
|
23
|
+
private _signTransaction;
|
|
24
|
+
private _signAllTransactions;
|
|
25
|
+
private _signMessage;
|
|
26
|
+
/**
|
|
27
|
+
* Legacy API for reading the public key for this provider.
|
|
28
|
+
* @deprecated Use publicKey getter instead
|
|
29
|
+
*/
|
|
30
|
+
readonly _publicKey: string;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a new OpenfortSolanaProvider instance
|
|
33
|
+
* @param params - Provider configuration
|
|
34
|
+
* @param params.account - The embedded account to use for this provider
|
|
35
|
+
* @param params.signTransaction - Function to sign a single transaction
|
|
36
|
+
* @param params.signAllTransactions - Function to sign multiple transactions
|
|
37
|
+
* @param params.signMessage - Function to sign a message
|
|
38
|
+
*/
|
|
39
|
+
constructor(params: {
|
|
40
|
+
account: EmbeddedAccount;
|
|
41
|
+
signTransaction: (transaction: any) => Promise<any>;
|
|
42
|
+
signAllTransactions: (transactions: any[]) => Promise<any[]>;
|
|
43
|
+
signMessage: (message: string) => Promise<string>;
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* The public key of the wallet (Solana address)
|
|
47
|
+
*/
|
|
48
|
+
get publicKey(): string;
|
|
49
|
+
/**
|
|
50
|
+
* Request-based API for wallet operations
|
|
51
|
+
*/
|
|
52
|
+
request(args: SignMessageRequestArguments): Promise<{
|
|
53
|
+
signature: string;
|
|
54
|
+
}>;
|
|
55
|
+
request(args: SignTransactionRequestArguments): Promise<{
|
|
56
|
+
signedTransaction: any;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Sign a single transaction (direct method)
|
|
60
|
+
*/
|
|
61
|
+
signTransaction(transaction: any): Promise<any>;
|
|
62
|
+
/**
|
|
63
|
+
* Sign multiple transactions (direct method)
|
|
64
|
+
*/
|
|
65
|
+
signAllTransactions(transactions: any[]): Promise<any[]>;
|
|
66
|
+
/**
|
|
67
|
+
* Sign a message (direct method)
|
|
68
|
+
*/
|
|
69
|
+
signMessage(message: string): Promise<string>;
|
|
70
|
+
/**
|
|
71
|
+
* Pretty log output for when an instance of this class is `console.log`'d
|
|
72
|
+
*/
|
|
73
|
+
toJSON(): string;
|
|
74
|
+
}
|
|
75
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type EmbeddedAccount } from '@openfort/openfort-js';
|
|
2
|
+
import { OpenfortError } from '../../types/openfortError';
|
|
3
|
+
import type { ConnectedEmbeddedEthereumWallet, EmbeddedEthereumWalletState, OpenfortEmbeddedEthereumWalletProvider } from '../../types/wallet';
|
|
4
|
+
type UseEmbeddedEthereumWalletOptions = {
|
|
5
|
+
chainId?: number;
|
|
6
|
+
onCreateSuccess?: (account: EmbeddedAccount, provider: OpenfortEmbeddedEthereumWalletProvider) => void;
|
|
7
|
+
onCreateError?: (error: OpenfortError) => void;
|
|
8
|
+
onSetActiveSuccess?: (wallet: ConnectedEmbeddedEthereumWallet, provider: OpenfortEmbeddedEthereumWalletProvider) => void;
|
|
9
|
+
onSetActiveError?: (error: OpenfortError) => void;
|
|
10
|
+
onSetRecoverySuccess?: () => void;
|
|
11
|
+
onSetRecoveryError?: (error: OpenfortError) => void;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Hook for managing embedded Ethereum wallets.
|
|
15
|
+
*
|
|
16
|
+
* This hook provides comprehensive Ethereum wallet management including creation, activation,
|
|
17
|
+
* and recovery. It returns a discriminated union state that enables type-safe wallet interactions.
|
|
18
|
+
*
|
|
19
|
+
* @param options - Configuration with default chainId and callback functions
|
|
20
|
+
* @returns Discriminated union state object. The `status` field determines available properties.
|
|
21
|
+
* Possible states: 'disconnected', 'connecting', 'reconnecting', 'creating', 'needs-recovery',
|
|
22
|
+
* 'connected', 'error'. When connected, includes `provider` and `activeWallet`. All states include
|
|
23
|
+
* `create`, `setActive`, `setRecovery`, `exportPrivateKey`, and `wallets` methods/properties.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* import { useEmbeddedEthereumWallet, isConnected, isLoading } from '@openfort/react-native';
|
|
28
|
+
*
|
|
29
|
+
* const ethereum = useEmbeddedEthereumWallet({
|
|
30
|
+
* chainId: 1,
|
|
31
|
+
* onCreateSuccess: (account, provider) => console.log('Wallet created:', account.address),
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* if (isLoading(ethereum)) {
|
|
35
|
+
* return <ActivityIndicator />;
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* if (isConnected(ethereum)) {
|
|
39
|
+
* // TypeScript knows provider and activeWallet are available
|
|
40
|
+
* const tx = await ethereum.provider.request({
|
|
41
|
+
* method: 'eth_sendTransaction',
|
|
42
|
+
* params: [{ from: ethereum.activeWallet.address, to: '0x...', value: '0x0' }]
|
|
43
|
+
* });
|
|
44
|
+
* }
|
|
45
|
+
*
|
|
46
|
+
* // Create wallet if none exist
|
|
47
|
+
* if (ethereum.status === 'disconnected' && ethereum.wallets.length === 0) {
|
|
48
|
+
* await ethereum.create({ chainId: 1 });
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function useEmbeddedEthereumWallet(options?: UseEmbeddedEthereumWalletOptions): EmbeddedEthereumWalletState;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type EmbeddedAccount } from '@openfort/openfort-js';
|
|
2
|
+
import { OpenfortError } from '../../types/openfortError';
|
|
3
|
+
import type { ConnectedEmbeddedSolanaWallet, EmbeddedSolanaWalletState, OpenfortEmbeddedSolanaWalletProvider } from '../../types/wallet';
|
|
4
|
+
type UseEmbeddedSolanaWalletOptions = {
|
|
5
|
+
onCreateSuccess?: (account: EmbeddedAccount, provider: OpenfortEmbeddedSolanaWalletProvider) => void;
|
|
6
|
+
onCreateError?: (error: OpenfortError) => void;
|
|
7
|
+
onSetActiveSuccess?: (wallet: ConnectedEmbeddedSolanaWallet, provider: OpenfortEmbeddedSolanaWalletProvider) => void;
|
|
8
|
+
onSetActiveError?: (error: OpenfortError) => void;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Hook for managing embedded Solana wallets.
|
|
12
|
+
*
|
|
13
|
+
* This hook provides comprehensive Solana wallet management including creation, activation,
|
|
14
|
+
* and recovery. It returns a discriminated union state that enables type-safe wallet interactions.
|
|
15
|
+
*
|
|
16
|
+
* @param options - Configuration with callback functions
|
|
17
|
+
* @returns Discriminated union state object. The `status` field determines available properties.
|
|
18
|
+
* Possible states: 'disconnected', 'connecting', 'reconnecting', 'creating', 'needs-recovery',
|
|
19
|
+
* 'connected', 'error'. When connected, includes `provider` and `activeWallet`. All states include
|
|
20
|
+
* `create`, `setActive`, and `wallets` methods/properties.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* import { useEmbeddedSolanaWallet, isConnected, isLoading } from '@openfort/react-native';
|
|
25
|
+
*
|
|
26
|
+
* const solana = useEmbeddedSolanaWallet({
|
|
27
|
+
* onCreateSuccess: (account, provider) => console.log('Wallet created:', account.address),
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* if (isLoading(solana)) {
|
|
31
|
+
* return <ActivityIndicator />;
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* if (isConnected(solana)) {
|
|
35
|
+
* // TypeScript knows provider and activeWallet are available
|
|
36
|
+
* const signed = await solana.provider.signTransaction(transaction);
|
|
37
|
+
* const publicKey = solana.provider.publicKey;
|
|
38
|
+
* }
|
|
39
|
+
*
|
|
40
|
+
* // Create wallet if none exist
|
|
41
|
+
* if (solana.status === 'disconnected' && solana.wallets.length === 0) {
|
|
42
|
+
* await solana.create({ recoveryMethod: 'automatic' });
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function useEmbeddedSolanaWallet(options?: UseEmbeddedSolanaWalletOptions): EmbeddedSolanaWalletState;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RecoveryParams } from '@openfort/openfort-js';
|
|
2
|
+
import type { EmbeddedWalletConfiguration } from '../../core/provider';
|
|
3
|
+
/**
|
|
4
|
+
* Builds recovery parameters from options and wallet configuration.
|
|
5
|
+
*
|
|
6
|
+
* This utility constructs the appropriate RecoveryParams object based on whether
|
|
7
|
+
* a recovery password is provided or automatic recovery should be used.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Options containing optional recovery password
|
|
10
|
+
* @param walletConfig - The embedded wallet configuration from the provider
|
|
11
|
+
* @returns A promise that resolves to RecoveryParams for the SDK
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildRecoveryParams(options: {
|
|
16
|
+
recoveryPassword?: string;
|
|
17
|
+
} | undefined, walletConfig?: EmbeddedWalletConfiguration): Promise<RecoveryParams>;
|
package/dist/types/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { canTransact, getActionText, getStateDescription, hasError, isConnected, isConnecting, isCreating, isDisconnected, isLoading, isNotCreated, isReady, isReconnecting, isStable, needsRecovery, needsUserAction, } from './predicates';
|
|
1
|
+
export {};
|
|
@@ -7,6 +7,9 @@ import type { OpenfortError } from '../types/openfortError';
|
|
|
7
7
|
* ensuring consistent callback execution across all hooks in the SDK.
|
|
8
8
|
*
|
|
9
9
|
* @param params - Object containing hook options and success data
|
|
10
|
+
* @param params.hookOptions - Primary hook options (from the hook itself)
|
|
11
|
+
* @param params.options - Secondary hook options (from the action call)
|
|
12
|
+
* @param params.data - The success data to pass to callbacks
|
|
10
13
|
* @returns The success data that was passed in
|
|
11
14
|
*
|
|
12
15
|
* @example
|
|
@@ -31,6 +34,9 @@ export declare const onSuccess: <T>({ hookOptions, options, data, }: {
|
|
|
31
34
|
* and optionally throws the error if throwOnError is configured.
|
|
32
35
|
*
|
|
33
36
|
* @param params - Object containing hook options and error information
|
|
37
|
+
* @param params.hookOptions - Primary hook options (from the hook itself)
|
|
38
|
+
* @param params.options - Secondary hook options (from the action call)
|
|
39
|
+
* @param params.error - The error that occurred during the operation
|
|
34
40
|
* @returns Object containing the error, or throws if throwOnError is enabled
|
|
35
41
|
*
|
|
36
42
|
* @example
|
|
@@ -29,10 +29,21 @@ export interface OAuthSessionConfig {
|
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* Opens an OAuth authentication session
|
|
32
|
+
*
|
|
33
|
+
* @param config - OAuth session configuration
|
|
34
|
+
* @param config.url - OAuth provider URL to open
|
|
35
|
+
* @param config.redirectUri - Redirect URI for OAuth flow callback
|
|
36
|
+
* @returns Promise resolving to OAuth result indicating success, cancellation, or error
|
|
32
37
|
*/
|
|
33
38
|
export declare function openOAuthSession(config: OAuthSessionConfig): Promise<OAuthResult>;
|
|
34
39
|
/**
|
|
35
40
|
* Handles Apple Sign-In authentication for iOS
|
|
41
|
+
*
|
|
42
|
+
* @param options - Options for Apple authentication
|
|
43
|
+
* @param options.state - State parameter for the OAuth flow
|
|
44
|
+
* @param options.isLogin - Whether this is a login or link operation (affects error codes)
|
|
45
|
+
* @returns Promise resolving to Apple authentication result with authorization code and user info
|
|
46
|
+
* @throws {Error} When not running on iOS platform or authentication fails
|
|
36
47
|
*/
|
|
37
48
|
export declare function authenticateWithApple(options: {
|
|
38
49
|
state: string;
|
|
@@ -40,6 +51,8 @@ export declare function authenticateWithApple(options: {
|
|
|
40
51
|
}): Promise<AppleAuthResult>;
|
|
41
52
|
/**
|
|
42
53
|
* Checks if Apple Sign-In is available on the current device
|
|
54
|
+
*
|
|
55
|
+
* @returns Promise resolving to true if Apple Sign-In is available, false otherwise
|
|
43
56
|
*/
|
|
44
57
|
export declare function isAppleSignInAvailable(): Promise<boolean>;
|
|
45
58
|
/**
|
|
@@ -36,10 +36,14 @@ export declare function handleSecureStorageMessage(message: SecureStorageMessage
|
|
|
36
36
|
export declare const NativeStorageUtils: {
|
|
37
37
|
/**
|
|
38
38
|
* Checks if secure storage is available on the current platform.
|
|
39
|
+
*
|
|
40
|
+
* @returns True if the platform is iOS or Android, false otherwise
|
|
39
41
|
*/
|
|
40
42
|
isAvailable(): boolean;
|
|
41
43
|
/**
|
|
42
44
|
* Gets the platform-specific storage options.
|
|
45
|
+
*
|
|
46
|
+
* @returns Secure store options with keychain accessibility configuration
|
|
43
47
|
*/
|
|
44
48
|
getStorageOptions(): SecureStore.SecureStoreOptions;
|
|
45
49
|
/**
|
|
@@ -16,6 +16,8 @@ interface EmbeddedWalletWebViewProps {
|
|
|
16
16
|
* WebView component for embedded wallet integration
|
|
17
17
|
* Handles secure communication between React Native and the embedded wallet WebView
|
|
18
18
|
* This component is hidden and only used for wallet communication
|
|
19
|
+
*
|
|
20
|
+
* @param props - Component props, see {@link EmbeddedWalletWebViewProps}
|
|
19
21
|
*/
|
|
20
22
|
export declare const EmbeddedWalletWebView: React.FC<EmbeddedWalletWebViewProps>;
|
|
21
23
|
/**
|
|
@@ -24,18 +26,28 @@ export declare const EmbeddedWalletWebView: React.FC<EmbeddedWalletWebViewProps>
|
|
|
24
26
|
export declare const WebViewUtils: {
|
|
25
27
|
/**
|
|
26
28
|
* Checks if WebView is supported on the current platform
|
|
29
|
+
*
|
|
30
|
+
* @returns True if the platform is iOS or Android, false otherwise
|
|
27
31
|
*/
|
|
28
32
|
isSupported(): boolean;
|
|
29
33
|
/**
|
|
30
34
|
* Gets platform-specific WebView configuration
|
|
35
|
+
*
|
|
36
|
+
* @returns Platform-specific WebView configuration object
|
|
31
37
|
*/
|
|
32
38
|
getPlatformConfig(): Partial<React.ComponentProps<typeof WebView>>;
|
|
33
39
|
/**
|
|
34
40
|
* Creates a secure message for WebView communication
|
|
41
|
+
*
|
|
42
|
+
* @param data - Data to include in the message
|
|
43
|
+
* @returns JSON-stringified message with timestamp and platform information
|
|
35
44
|
*/
|
|
36
45
|
createSecureMessage(data: any): string;
|
|
37
46
|
/**
|
|
38
47
|
* Validates a message received from WebView
|
|
48
|
+
*
|
|
49
|
+
* @param message - JSON string message to validate
|
|
50
|
+
* @returns Validation result with parsed data or error information
|
|
39
51
|
*/
|
|
40
52
|
validateMessage(message: string): {
|
|
41
53
|
isValid: boolean;
|
|
@@ -44,6 +56,8 @@ export declare const WebViewUtils: {
|
|
|
44
56
|
};
|
|
45
57
|
/**
|
|
46
58
|
* Gets WebView user agent for the current platform
|
|
59
|
+
*
|
|
60
|
+
* @returns User agent string including platform and version information
|
|
47
61
|
*/
|
|
48
62
|
getUserAgent(): string;
|
|
49
63
|
};
|
|
@@ -43,10 +43,6 @@ export type RecoveryFlowState = {
|
|
|
43
43
|
* Authentication success callback
|
|
44
44
|
*/
|
|
45
45
|
export type AuthSuccessCallback = (user: OpenfortUser, isNewUser?: boolean) => void;
|
|
46
|
-
/**
|
|
47
|
-
* Authentication link success callback
|
|
48
|
-
*/
|
|
49
|
-
export type AuthLinkSuccessCallback = (user: OpenfortUser) => void;
|
|
50
46
|
/**
|
|
51
47
|
* Error callback
|
|
52
48
|
*/
|
|
@@ -58,13 +54,6 @@ export interface EmailLoginHookOptions {
|
|
|
58
54
|
onError?: ErrorCallback;
|
|
59
55
|
onSuccess?: AuthSuccessCallback;
|
|
60
56
|
}
|
|
61
|
-
/**
|
|
62
|
-
* Email link hook options
|
|
63
|
-
*/
|
|
64
|
-
export interface EmailLinkHookOptions {
|
|
65
|
-
onError?: ErrorCallback;
|
|
66
|
-
onSuccess?: AuthLinkSuccessCallback;
|
|
67
|
-
}
|
|
68
57
|
/**
|
|
69
58
|
* Email login hook result
|
|
70
59
|
*/
|
|
@@ -80,16 +69,6 @@ export interface EmailLoginHookResult {
|
|
|
80
69
|
}) => Promise<OpenfortUser | undefined>;
|
|
81
70
|
state: PasswordFlowState;
|
|
82
71
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Email link hook result
|
|
85
|
-
*/
|
|
86
|
-
export interface EmailLinkHookResult {
|
|
87
|
-
link: (credentials: {
|
|
88
|
-
email: string;
|
|
89
|
-
password: string;
|
|
90
|
-
}) => Promise<OpenfortUser | undefined>;
|
|
91
|
-
state: PasswordFlowState;
|
|
92
|
-
}
|
|
93
72
|
/**
|
|
94
73
|
* SIWE message generation response
|
|
95
74
|
*/
|
|
@@ -118,14 +97,6 @@ export interface SiweLoginHookOptions {
|
|
|
118
97
|
onSuccess?: AuthSuccessCallback;
|
|
119
98
|
onGenerateMessage?: (message: string) => void;
|
|
120
99
|
}
|
|
121
|
-
/**
|
|
122
|
-
* SIWE link hook options
|
|
123
|
-
*/
|
|
124
|
-
export interface SiweLinkHookOptions {
|
|
125
|
-
onError?: ErrorCallback;
|
|
126
|
-
onSuccess?: AuthLinkSuccessCallback;
|
|
127
|
-
onGenerateMessage?: (message: string) => void;
|
|
128
|
-
}
|
|
129
100
|
/**
|
|
130
101
|
* SIWE login hook result
|
|
131
102
|
*/
|
|
@@ -139,15 +110,3 @@ export interface SiweLoginHookResult {
|
|
|
139
110
|
disableSignup?: boolean;
|
|
140
111
|
}) => Promise<OpenfortUser>;
|
|
141
112
|
}
|
|
142
|
-
/**
|
|
143
|
-
* SIWE link hook result
|
|
144
|
-
*/
|
|
145
|
-
export interface SiweLinkHookResult {
|
|
146
|
-
generateSiweMessage: GenerateSiweMessage;
|
|
147
|
-
state: SiweFlowState;
|
|
148
|
-
linkWithSiwe: (opts: {
|
|
149
|
-
signature: string;
|
|
150
|
-
messageOverride?: string;
|
|
151
|
-
walletAddress: string;
|
|
152
|
-
}) => Promise<OpenfortUser>;
|
|
153
|
-
}
|
|
@@ -2,37 +2,10 @@
|
|
|
2
2
|
* Core Openfort hook interface.
|
|
3
3
|
*/
|
|
4
4
|
export interface UseOpenfort {
|
|
5
|
-
/** The current authenticated user, or null when unauthenticated. */
|
|
6
|
-
user: import('@openfort/openfort-js').AuthPlayerResponse | null;
|
|
7
|
-
/** Whether or not the SDK has initialized and is ready for use. */
|
|
8
5
|
isReady: boolean;
|
|
9
6
|
/** Any error encountered during SDK initialization. */
|
|
10
7
|
error: Error | null;
|
|
11
|
-
/** A function that logs the current user out and clears any stored tokens. */
|
|
12
|
-
logout: () => Promise<void>;
|
|
13
|
-
/** A function that gets the current authenticated user's access token. */
|
|
14
|
-
getAccessToken: () => Promise<string | null>;
|
|
15
8
|
}
|
|
16
|
-
export type {
|
|
17
|
-
export type {
|
|
18
|
-
export type {
|
|
19
|
-
export { canTransact, getActionText, getStateDescription, hasError, isConnected, isConnecting, isCreating, isDisconnected, isLoading, isNotCreated, isReady, isReconnecting, isStable, needsRecovery, needsUserAction, } from './predicates';
|
|
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';
|
|
21
|
-
/**
|
|
22
|
-
* Embedded wallet hook options with callbacks.
|
|
23
|
-
*/
|
|
24
|
-
export type UseEmbeddedEthereumWallet = {
|
|
25
|
-
onCreateWalletSuccess?: (provider: import('@openfort/openfort-js').Provider) => void;
|
|
26
|
-
onCreateWalletError?: (error: Error) => void;
|
|
27
|
-
onSetWalletRecoverySuccess?: (result: {
|
|
28
|
-
user: import('@openfort/openfort-js').AuthPlayerResponse;
|
|
29
|
-
}) => void;
|
|
30
|
-
onSetWalletRecoveryError?: (error: Error) => void;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Embedded Solana wallet hook options with callbacks.
|
|
34
|
-
*/
|
|
35
|
-
export type UseEmbeddedSolanaWallet = {
|
|
36
|
-
onCreateWalletSuccess?: (account: import('@openfort/openfort-js').EmbeddedAccount) => void;
|
|
37
|
-
onCreateWalletError?: (error: Error) => void;
|
|
38
|
-
};
|
|
9
|
+
export type { AuthSuccessCallback, EmailLoginHookOptions, EmailLoginHookResult, ErrorCallback, GenerateSiweMessage, GenerateSiweMessageResponse, PasswordFlowState, RecoveryFlowState, SiweFlowState, SiweLoginHookOptions, SiweLoginHookResult, } from './auth';
|
|
10
|
+
export type { LinkWithOAuthInput, LoginWithOAuthInput, OAuthFlowState, UseLoginWithOAuth, } from './oauth';
|
|
11
|
+
export type { ConnectedEmbeddedEthereumWallet, ConnectedEmbeddedSolanaWallet, CreateSolanaEmbeddedWalletOpts, EmbeddedEthereumWalletState, EmbeddedSolanaWalletState, OpenfortEmbeddedEthereumWalletProvider, OpenfortEmbeddedSolanaWalletProvider, } from './wallet';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { OAuthProvider } from '@openfort/openfort-js';
|
|
2
|
-
import type { AuthSuccessCallback, ErrorCallback } from './auth';
|
|
3
2
|
/**
|
|
4
3
|
* OAuth authentication flow state
|
|
5
4
|
*/
|
|
@@ -16,22 +15,6 @@ export declare const mapOAuthStatus: (status: OAuthFlowState) => {
|
|
|
16
15
|
isSuccess: boolean;
|
|
17
16
|
error: Error | null | undefined;
|
|
18
17
|
};
|
|
19
|
-
/**
|
|
20
|
-
* OAuth tokens interface
|
|
21
|
-
*/
|
|
22
|
-
export interface OAuthTokens {
|
|
23
|
-
[key: string]: any;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* OAuth tokens hook options
|
|
27
|
-
*/
|
|
28
|
-
export interface UseOAuthTokensOptions {
|
|
29
|
-
/**
|
|
30
|
-
* Callback function triggered when OAuth tokens are granted to the user after any OAuth Authorization flow.
|
|
31
|
-
* @param tokens - The set of OAuth tokens granted to the user.
|
|
32
|
-
*/
|
|
33
|
-
onOAuthTokenGrant: (tokens: OAuthTokens) => void;
|
|
34
|
-
}
|
|
35
18
|
/**
|
|
36
19
|
* Login with OAuth input parameters
|
|
37
20
|
*/
|
|
@@ -51,24 +34,3 @@ export interface UseLoginWithOAuth {
|
|
|
51
34
|
state: OAuthFlowState;
|
|
52
35
|
login: (input: LoginWithOAuthInput) => Promise<import('@openfort/openfort-js').AuthPlayerResponse | undefined>;
|
|
53
36
|
}
|
|
54
|
-
/**
|
|
55
|
-
* Link with OAuth hook interface
|
|
56
|
-
*/
|
|
57
|
-
export interface UseLinkWithOAuth {
|
|
58
|
-
state: OAuthFlowState;
|
|
59
|
-
link: (input: LinkWithOAuthInput) => Promise<import('@openfort/openfort-js').AuthPlayerResponse | undefined>;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Unlink OAuth hook options
|
|
63
|
-
*/
|
|
64
|
-
export interface UnlinkOAuthOptions {
|
|
65
|
-
onError?: ErrorCallback;
|
|
66
|
-
onSuccess?: AuthSuccessCallback;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Unlink OAuth parameters
|
|
70
|
-
*/
|
|
71
|
-
export interface UnlinkOAuthParams {
|
|
72
|
-
provider: OAuthProvider;
|
|
73
|
-
subject: string;
|
|
74
|
-
}
|