@openfort/react-native 0.1.20 → 0.1.22
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 +20 -7
- package/dist/hooks/auth/useEmailAuth.js +108 -8
- package/dist/hooks/auth/useGuestAuth.js +16 -6
- package/dist/hooks/auth/useOAuth.js +14 -5
- package/dist/hooks/auth/useWalletAuth.js +29 -10
- 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 +517 -0
- package/dist/hooks/wallet/useEmbeddedSolanaWallet.js +455 -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/core/provider.d.ts +20 -6
- package/dist/types/hooks/auth/useEmailAuth.d.ts +24 -12
- package/dist/types/hooks/auth/useGuestAuth.d.ts +17 -8
- package/dist/types/hooks/auth/useOAuth.d.ts +15 -7
- package/dist/types/hooks/auth/useWalletAuth.d.ts +29 -10
- 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 +104 -0
- package/dist/types/hooks/wallet/useEmbeddedSolanaWallet.d.ts +111 -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
|
@@ -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
|
-
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ChainTypeEnum } from '@openfort/openfort-js';
|
|
2
|
+
/**
|
|
3
|
+
* Ethereum wallet provider interface for EIP-1193 compatible operations
|
|
4
|
+
*/
|
|
5
|
+
export interface OpenfortEmbeddedEthereumWalletProvider {
|
|
2
6
|
request: (args: {
|
|
3
7
|
method: string;
|
|
4
8
|
params?: any[];
|
|
@@ -7,256 +11,156 @@ interface OpenfortEmbeddedEthereumWalletProvider {
|
|
|
7
11
|
removeListener: (event: string, handler: (...args: any[]) => void) => void;
|
|
8
12
|
[key: string]: any;
|
|
9
13
|
}
|
|
10
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Solana wallet provider interface
|
|
16
|
+
*/
|
|
17
|
+
export interface OpenfortEmbeddedSolanaWalletProvider {
|
|
18
|
+
signMessage: (message: string) => Promise<string>;
|
|
11
19
|
signTransaction: (transaction: any) => Promise<any>;
|
|
12
20
|
signAllTransactions: (transactions: any[]) => Promise<any[]>;
|
|
13
21
|
publicKey: string;
|
|
14
22
|
[key: string]: any;
|
|
15
23
|
}
|
|
16
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Connected Ethereum wallet
|
|
26
|
+
*/
|
|
27
|
+
export type ConnectedEmbeddedEthereumWallet = {
|
|
17
28
|
address: string;
|
|
18
29
|
ownerAddress?: string;
|
|
19
30
|
implementationType?: string;
|
|
20
|
-
chainType:
|
|
21
|
-
walletIndex: number;
|
|
22
|
-
}
|
|
23
|
-
interface OpenfortSolanaEmbeddedWalletAccount {
|
|
24
|
-
address: string;
|
|
25
|
-
chainType: 'solana';
|
|
31
|
+
chainType: ChainTypeEnum.EVM;
|
|
26
32
|
walletIndex: number;
|
|
27
|
-
|
|
28
|
-
import type { ChainTypeEnum } from '@openfort/openfort-js';
|
|
29
|
-
import type { ErrorCallback } from './auth';
|
|
30
|
-
import type { Hex } from './hex';
|
|
31
|
-
/**
|
|
32
|
-
* Openfort embedded wallet account union type
|
|
33
|
-
*/
|
|
34
|
-
export type OpenfortEmbeddedWalletAccount = OpenfortEthereumEmbeddedWalletAccount | OpenfortSolanaEmbeddedWalletAccount;
|
|
35
|
-
/**
|
|
36
|
-
* Wallet recovery callbacks
|
|
37
|
-
*/
|
|
38
|
-
export type WalletRecoveryCallbacks = {
|
|
39
|
-
onError?: ErrorCallback;
|
|
40
|
-
onSuccess?: (provider: OpenfortEmbeddedEthereumWalletProvider) => void;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Solana wallet recovery callbacks
|
|
44
|
-
*/
|
|
45
|
-
export type SolanaWalletRecoveryCallbacks = {
|
|
46
|
-
onError?: ErrorCallback;
|
|
47
|
-
onSuccess?: (provider: OpenfortEmbeddedSolanaWalletProvider) => void;
|
|
33
|
+
getProvider: () => Promise<OpenfortEmbeddedEthereumWalletProvider>;
|
|
48
34
|
};
|
|
49
35
|
/**
|
|
50
|
-
*
|
|
36
|
+
* Connected Solana wallet
|
|
51
37
|
*/
|
|
52
|
-
export type
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
38
|
+
export type ConnectedEmbeddedSolanaWallet = {
|
|
39
|
+
address: string;
|
|
40
|
+
chainType: ChainTypeEnum.SVM;
|
|
41
|
+
walletIndex: number;
|
|
42
|
+
getProvider: () => Promise<OpenfortEmbeddedSolanaWalletProvider>;
|
|
57
43
|
};
|
|
58
44
|
/**
|
|
59
|
-
* Solana wallet creation options
|
|
45
|
+
* Simplified Solana wallet creation options
|
|
60
46
|
*/
|
|
61
|
-
export type CreateSolanaEmbeddedWalletOpts =
|
|
62
|
-
|
|
63
|
-
|
|
47
|
+
export type CreateSolanaEmbeddedWalletOpts = {
|
|
48
|
+
/**
|
|
49
|
+
* Optional recovery password for password-based recovery.
|
|
50
|
+
* If omitted, automatic recovery will be used.
|
|
51
|
+
*/
|
|
52
|
+
recoveryPassword?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Create additional wallet if one already exists
|
|
55
|
+
*/
|
|
64
56
|
createAdditional?: boolean;
|
|
65
57
|
};
|
|
66
58
|
/**
|
|
67
|
-
*
|
|
59
|
+
* Ethereum wallet hook return type - discriminated union based on status
|
|
68
60
|
*/
|
|
69
|
-
export type
|
|
70
|
-
|
|
61
|
+
export type EmbeddedEthereumWalletState = {
|
|
62
|
+
status: 'disconnected';
|
|
63
|
+
activeWallet: null;
|
|
64
|
+
create: (...args: any[]) => Promise<any>;
|
|
65
|
+
wallets: ConnectedEmbeddedEthereumWallet[];
|
|
66
|
+
setActive: (...args: any[]) => Promise<void>;
|
|
67
|
+
setRecovery: (...args: any[]) => Promise<void>;
|
|
68
|
+
exportPrivateKey: (...args: any[]) => Promise<any>;
|
|
71
69
|
} | {
|
|
72
|
-
recoveryMethod: 'password';
|
|
73
|
-
password: string;
|
|
74
|
-
};
|
|
75
|
-
export type UserWallet = {
|
|
76
|
-
address: Hex;
|
|
77
|
-
ownerAddress?: string;
|
|
78
|
-
implementationType?: string;
|
|
79
|
-
chainType: ChainTypeEnum;
|
|
80
|
-
isActive?: boolean;
|
|
81
|
-
isConnecting?: boolean;
|
|
82
|
-
getProvider: () => Promise<OpenfortEmbeddedEthereumWalletProvider>;
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* Connected embedded wallet state
|
|
86
|
-
*/
|
|
87
|
-
interface IEmbeddedEthereumWalletConnectedState {
|
|
88
|
-
status: 'connected';
|
|
89
|
-
provider: OpenfortEmbeddedEthereumWalletProvider;
|
|
90
|
-
activeWallet: UserWallet;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Connecting embedded wallet state
|
|
94
|
-
*/
|
|
95
|
-
interface IEmbeddedEthereumWalletConnectingState {
|
|
96
70
|
status: 'connecting';
|
|
97
|
-
activeWallet:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
71
|
+
activeWallet: ConnectedEmbeddedEthereumWallet;
|
|
72
|
+
create: (...args: any[]) => Promise<any>;
|
|
73
|
+
wallets: ConnectedEmbeddedEthereumWallet[];
|
|
74
|
+
setActive: (...args: any[]) => Promise<void>;
|
|
75
|
+
setRecovery: (...args: any[]) => Promise<void>;
|
|
76
|
+
exportPrivateKey: (...args: any[]) => Promise<any>;
|
|
77
|
+
} | {
|
|
103
78
|
status: 'reconnecting';
|
|
104
|
-
activeWallet:
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
activeWallet: null;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Needs recovery embedded wallet state
|
|
115
|
-
*/
|
|
116
|
-
interface IEmbeddedEthereumWalletNeedsRecoveryState {
|
|
117
|
-
status: 'needs-recovery';
|
|
118
|
-
activeWallet: UserWallet;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Creating embedded wallet state
|
|
122
|
-
*/
|
|
123
|
-
interface IEmbeddedEthereumWalletCreatingState {
|
|
79
|
+
activeWallet: ConnectedEmbeddedEthereumWallet;
|
|
80
|
+
create: (...args: any[]) => Promise<any>;
|
|
81
|
+
wallets: ConnectedEmbeddedEthereumWallet[];
|
|
82
|
+
setActive: (...args: any[]) => Promise<void>;
|
|
83
|
+
setRecovery: (...args: any[]) => Promise<void>;
|
|
84
|
+
exportPrivateKey: (...args: any[]) => Promise<any>;
|
|
85
|
+
} | {
|
|
124
86
|
status: 'creating';
|
|
125
87
|
activeWallet: null;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
88
|
+
create: (...args: any[]) => Promise<any>;
|
|
89
|
+
wallets: ConnectedEmbeddedEthereumWallet[];
|
|
90
|
+
setActive: (...args: any[]) => Promise<void>;
|
|
91
|
+
setRecovery: (...args: any[]) => Promise<void>;
|
|
92
|
+
exportPrivateKey: (...args: any[]) => Promise<any>;
|
|
93
|
+
} | {
|
|
94
|
+
status: 'needs-recovery';
|
|
95
|
+
activeWallet: ConnectedEmbeddedEthereumWallet;
|
|
96
|
+
create: (...args: any[]) => Promise<any>;
|
|
97
|
+
wallets: ConnectedEmbeddedEthereumWallet[];
|
|
98
|
+
setActive: (...args: any[]) => Promise<void>;
|
|
99
|
+
setRecovery: (...args: any[]) => Promise<void>;
|
|
100
|
+
exportPrivateKey: (...args: any[]) => Promise<any>;
|
|
101
|
+
} | {
|
|
102
|
+
status: 'connected';
|
|
103
|
+
activeWallet: ConnectedEmbeddedEthereumWallet;
|
|
104
|
+
provider: OpenfortEmbeddedEthereumWalletProvider;
|
|
105
|
+
create: (...args: any[]) => Promise<any>;
|
|
106
|
+
wallets: ConnectedEmbeddedEthereumWallet[];
|
|
107
|
+
setActive: (...args: any[]) => Promise<void>;
|
|
108
|
+
setRecovery: (...args: any[]) => Promise<void>;
|
|
109
|
+
exportPrivateKey: (...args: any[]) => Promise<any>;
|
|
110
|
+
} | {
|
|
131
111
|
status: 'error';
|
|
132
|
-
activeWallet:
|
|
112
|
+
activeWallet: ConnectedEmbeddedEthereumWallet | null;
|
|
133
113
|
error: string;
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Embedded wallet actions
|
|
137
|
-
*/
|
|
138
|
-
export type EmbeddedEthereumWalletActions = {
|
|
139
|
-
/**
|
|
140
|
-
* Configure an embedded wallet for this user.
|
|
141
|
-
*/
|
|
142
|
-
create: (args?: {
|
|
143
|
-
chainId?: number;
|
|
144
|
-
recoveryPassword?: string;
|
|
145
|
-
policyId?: string;
|
|
146
|
-
}) => Promise<import('@openfort/openfort-js').EmbeddedAccount>;
|
|
147
|
-
/**
|
|
148
|
-
* List of embedded ethereum wallets at each derived HD index.
|
|
149
|
-
*/
|
|
114
|
+
create: (...args: any[]) => Promise<any>;
|
|
150
115
|
wallets: ConnectedEmbeddedEthereumWallet[];
|
|
116
|
+
setActive: (...args: any[]) => Promise<void>;
|
|
117
|
+
setRecovery: (...args: any[]) => Promise<void>;
|
|
118
|
+
exportPrivateKey: (...args: any[]) => Promise<any>;
|
|
151
119
|
};
|
|
152
|
-
type EthereumWalletState = IEmbeddedEthereumWalletConnectedState | IEmbeddedEthereumWalletConnectingState | IEmbeddedEthereumWalletReconnectingState | IEmbeddedEthereumWalletDisconnectedState | IEmbeddedEthereumWalletNeedsRecoveryState | IEmbeddedEthereumWalletCreatingState | IEmbeddedEthereumWalletErrorState;
|
|
153
|
-
/**
|
|
154
|
-
* Main embedded wallet state union
|
|
155
|
-
*/
|
|
156
|
-
export type EmbeddedEthereumWalletState = EthereumWalletState & EmbeddedEthereumWalletActions;
|
|
157
|
-
/**
|
|
158
|
-
* Embedded wallet status
|
|
159
|
-
*/
|
|
160
|
-
export type EmbeddedWalletStatus = EmbeddedEthereumWalletState['status'];
|
|
161
120
|
/**
|
|
162
|
-
*
|
|
121
|
+
* Solana wallet hook return type - discriminated union based on status
|
|
163
122
|
*/
|
|
164
|
-
|
|
165
|
-
status: 'connected';
|
|
166
|
-
activeWallet: OpenfortSolanaEmbeddedWalletAccount;
|
|
167
|
-
provider: OpenfortEmbeddedEthereumWalletProvider;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Connecting embedded Solana wallet state
|
|
171
|
-
*/
|
|
172
|
-
interface IEmbeddedSolanaWalletConnectingState {
|
|
173
|
-
status: 'connecting';
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Reconnecting embedded Solana wallet state
|
|
177
|
-
*/
|
|
178
|
-
interface IEmbeddedSolanaWalletReconnectingState {
|
|
179
|
-
status: 'reconnecting';
|
|
180
|
-
activeWallet: OpenfortSolanaEmbeddedWalletAccount;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Disconnected embedded Solana wallet state
|
|
184
|
-
*/
|
|
185
|
-
interface IEmbeddedSolanaWalletDisconnectedState {
|
|
123
|
+
export type EmbeddedSolanaWalletState = {
|
|
186
124
|
status: 'disconnected';
|
|
187
125
|
activeWallet: null;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
126
|
+
create: (...args: any[]) => Promise<any>;
|
|
127
|
+
wallets: ConnectedEmbeddedSolanaWallet[];
|
|
128
|
+
setActive: (...args: any[]) => Promise<void>;
|
|
129
|
+
} | {
|
|
130
|
+
status: 'connecting';
|
|
131
|
+
create: (...args: any[]) => Promise<any>;
|
|
132
|
+
wallets: ConnectedEmbeddedSolanaWallet[];
|
|
133
|
+
setActive: (...args: any[]) => Promise<void>;
|
|
134
|
+
} | {
|
|
135
|
+
status: 'reconnecting';
|
|
136
|
+
activeWallet: ConnectedEmbeddedSolanaWallet;
|
|
137
|
+
create: (...args: any[]) => Promise<any>;
|
|
138
|
+
wallets: ConnectedEmbeddedSolanaWallet[];
|
|
139
|
+
setActive: (...args: any[]) => Promise<void>;
|
|
140
|
+
} | {
|
|
200
141
|
status: 'creating';
|
|
201
142
|
activeWallet: null;
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
143
|
+
create: (...args: any[]) => Promise<any>;
|
|
144
|
+
wallets: ConnectedEmbeddedSolanaWallet[];
|
|
145
|
+
setActive: (...args: any[]) => Promise<void>;
|
|
146
|
+
} | {
|
|
147
|
+
status: 'needs-recovery';
|
|
148
|
+
activeWallet: ConnectedEmbeddedSolanaWallet;
|
|
149
|
+
create: (...args: any[]) => Promise<any>;
|
|
150
|
+
wallets: ConnectedEmbeddedSolanaWallet[];
|
|
151
|
+
setActive: (...args: any[]) => Promise<void>;
|
|
152
|
+
} | {
|
|
153
|
+
status: 'connected';
|
|
154
|
+
activeWallet: ConnectedEmbeddedSolanaWallet;
|
|
155
|
+
provider: OpenfortEmbeddedSolanaWalletProvider;
|
|
156
|
+
create: (...args: any[]) => Promise<any>;
|
|
157
|
+
wallets: ConnectedEmbeddedSolanaWallet[];
|
|
158
|
+
setActive: (...args: any[]) => Promise<void>;
|
|
159
|
+
} | {
|
|
207
160
|
status: 'error';
|
|
208
|
-
activeWallet:
|
|
161
|
+
activeWallet: ConnectedEmbeddedSolanaWallet | null;
|
|
209
162
|
error: string;
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Connected embedded Solana wallet
|
|
213
|
-
*/
|
|
214
|
-
export type ConnectedEmbeddedSolanaWallet = {
|
|
215
|
-
address: string;
|
|
216
|
-
chainType: 'solana';
|
|
217
|
-
walletIndex: number;
|
|
218
|
-
getProvider: () => Promise<OpenfortEmbeddedSolanaWalletProvider>;
|
|
219
|
-
};
|
|
220
|
-
/**
|
|
221
|
-
* Embedded Solana wallet actions
|
|
222
|
-
*/
|
|
223
|
-
export type EmbeddedSolanaWalletActions = {
|
|
224
|
-
/**
|
|
225
|
-
* Configure an embedded wallet for this user.
|
|
226
|
-
*/
|
|
227
|
-
create: (args?: {
|
|
228
|
-
chainId?: number;
|
|
229
|
-
recoveryPassword?: string;
|
|
230
|
-
}) => Promise<import('@openfort/openfort-js').EmbeddedAccount>;
|
|
231
|
-
/**
|
|
232
|
-
* List of embedded solana wallets
|
|
233
|
-
*/
|
|
163
|
+
create: (...args: any[]) => Promise<any>;
|
|
234
164
|
wallets: ConnectedEmbeddedSolanaWallet[];
|
|
165
|
+
setActive: (...args: any[]) => Promise<void>;
|
|
235
166
|
};
|
|
236
|
-
export type EmbeddedSolanaWalletConnectedState = EmbeddedSolanaWalletActions & IEmbeddedSolanaWalletConnectedState;
|
|
237
|
-
export type EmbeddedSolanaWalletConnectingState = EmbeddedSolanaWalletActions & IEmbeddedSolanaWalletConnectingState;
|
|
238
|
-
export type EmbeddedSolanaWalletReconnectingState = EmbeddedSolanaWalletActions & IEmbeddedSolanaWalletReconnectingState;
|
|
239
|
-
export type EmbeddedSolanaWalletDisconnectedState = Partial<EmbeddedSolanaWalletActions> & IEmbeddedSolanaWalletDisconnectedState;
|
|
240
|
-
export type EmbeddedSolanaWalletNeedsRecoveryState = EmbeddedSolanaWalletActions & IEmbeddedSolanaWalletNeedsRecoveryState;
|
|
241
|
-
export type EmbeddedSolanaWalletCreatingState = EmbeddedSolanaWalletActions & IEmbeddedSolanaWalletCreatingState;
|
|
242
|
-
export type EmbeddedSolanaWalletErrorState = EmbeddedSolanaWalletActions & IEmbeddedSolanaWalletErrorState;
|
|
243
|
-
/**
|
|
244
|
-
* Main embedded Solana wallet state union
|
|
245
|
-
*/
|
|
246
|
-
export type EmbeddedSolanaWalletState = EmbeddedSolanaWalletConnectedState | EmbeddedSolanaWalletConnectingState | EmbeddedSolanaWalletReconnectingState | EmbeddedSolanaWalletDisconnectedState | EmbeddedSolanaWalletNeedsRecoveryState | EmbeddedSolanaWalletCreatingState | EmbeddedSolanaWalletErrorState;
|
|
247
|
-
/**
|
|
248
|
-
* Embedded Solana wallet status
|
|
249
|
-
*/
|
|
250
|
-
export type EmbeddedSolanaWalletStatus = EmbeddedSolanaWalletState['status'];
|
|
251
|
-
/**
|
|
252
|
-
* Connected Ethereum wallet
|
|
253
|
-
*/
|
|
254
|
-
export type ConnectedEmbeddedEthereumWallet = {
|
|
255
|
-
address: string;
|
|
256
|
-
ownerAddress?: string;
|
|
257
|
-
implementationType?: string;
|
|
258
|
-
chainType: 'ethereum';
|
|
259
|
-
walletIndex: number;
|
|
260
|
-
getProvider: () => Promise<OpenfortEmbeddedEthereumWalletProvider>;
|
|
261
|
-
};
|
|
262
|
-
export {};
|
package/package.json
CHANGED