@openfort/react-native 0.1.21 → 0.1.23
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/core/provider.js +20 -6
- package/dist/hooks/auth/useEmailAuth.js +18 -5
- 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/wallet/solanaProvider.js +1 -4
- package/dist/hooks/wallet/useEmbeddedEthereumWallet.js +79 -27
- package/dist/hooks/wallet/useEmbeddedSolanaWallet.js +93 -30
- package/dist/types/core/provider.d.ts +20 -6
- package/dist/types/hooks/auth/useEmailAuth.d.ts +18 -5
- package/dist/types/hooks/auth/useGuestAuth.d.ts +16 -6
- package/dist/types/hooks/auth/useOAuth.d.ts +14 -5
- package/dist/types/hooks/auth/useWalletAuth.d.ts +29 -10
- package/dist/types/hooks/wallet/solanaProvider.d.ts +8 -21
- package/dist/types/hooks/wallet/useEmbeddedEthereumWallet.d.ts +76 -25
- package/dist/types/hooks/wallet/useEmbeddedSolanaWallet.d.ts +86 -22
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/types/wallet.d.ts +225 -86
- package/package.json +1 -1
|
@@ -1,25 +1,105 @@
|
|
|
1
|
-
import type { ChainTypeEnum } from '@openfort/openfort-js';
|
|
1
|
+
import type { AccountTypeEnum, ChainTypeEnum, EmbeddedAccount, RecoveryParams } from '@openfort/openfort-js';
|
|
2
|
+
import type { Hex } from './hex';
|
|
3
|
+
import type { OpenfortHookOptions } from './hookOption';
|
|
4
|
+
import type { OpenfortError } from './openfortError';
|
|
2
5
|
/**
|
|
3
|
-
*
|
|
6
|
+
* JSON-RPC request arguments following EIP-1193 spec
|
|
7
|
+
*/
|
|
8
|
+
export type EIP1193RequestArguments = {
|
|
9
|
+
readonly method: string;
|
|
10
|
+
readonly params?: readonly unknown[] | object;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* EIP-1193 event names
|
|
14
|
+
*/
|
|
15
|
+
export type EIP1193EventName = 'accountsChanged' | 'chainChanged' | 'connect' | 'disconnect' | 'message';
|
|
16
|
+
/**
|
|
17
|
+
* EIP-1193 provider event handler
|
|
18
|
+
*/
|
|
19
|
+
export type EIP1193EventHandler = (...args: unknown[]) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Ethereum wallet provider interface following EIP-1193 spec
|
|
22
|
+
*
|
|
23
|
+
* @see https://eips.ethereum.org/EIPS/eip-1193
|
|
4
24
|
*/
|
|
5
25
|
export interface OpenfortEmbeddedEthereumWalletProvider {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Submit a JSON-RPC request to the provider
|
|
28
|
+
*/
|
|
29
|
+
request(args: EIP1193RequestArguments): Promise<unknown>;
|
|
30
|
+
/**
|
|
31
|
+
* Subscribe to provider events
|
|
32
|
+
*/
|
|
33
|
+
on(event: EIP1193EventName | string, handler: EIP1193EventHandler): void;
|
|
34
|
+
/**
|
|
35
|
+
* Unsubscribe from provider events
|
|
36
|
+
*/
|
|
37
|
+
removeListener(event: EIP1193EventName | string, handler: EIP1193EventHandler): void;
|
|
13
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Represents a Solana transaction that can be signed.
|
|
41
|
+
* Supports multiple formats:
|
|
42
|
+
* - @solana/web3.js Transaction (has serializeMessage method)
|
|
43
|
+
* - @solana/kit compiled transaction (has messageBytes property)
|
|
44
|
+
* - Raw Uint8Array
|
|
45
|
+
*/
|
|
46
|
+
export type SolanaTransaction = {
|
|
47
|
+
messageBytes: Uint8Array;
|
|
48
|
+
} | {
|
|
49
|
+
serializeMessage(): Uint8Array;
|
|
50
|
+
} | Uint8Array;
|
|
51
|
+
/**
|
|
52
|
+
* Result of signing a Solana transaction
|
|
53
|
+
*/
|
|
54
|
+
export type SignedSolanaTransaction = {
|
|
55
|
+
signature: string;
|
|
56
|
+
publicKey: string;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Solana provider request arguments
|
|
60
|
+
*/
|
|
61
|
+
export type SolanaSignMessageRequest = {
|
|
62
|
+
method: 'signMessage';
|
|
63
|
+
params: {
|
|
64
|
+
message: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
export type SolanaSignTransactionRequest = {
|
|
68
|
+
method: 'signTransaction';
|
|
69
|
+
params: {
|
|
70
|
+
transaction: SolanaTransaction;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export type SolanaRequestArguments = SolanaSignMessageRequest | SolanaSignTransactionRequest;
|
|
14
74
|
/**
|
|
15
75
|
* Solana wallet provider interface
|
|
16
76
|
*/
|
|
17
77
|
export interface OpenfortEmbeddedSolanaWalletProvider {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
publicKey: string;
|
|
22
|
-
|
|
78
|
+
/**
|
|
79
|
+
* The public key (address) of the wallet
|
|
80
|
+
*/
|
|
81
|
+
readonly publicKey: string;
|
|
82
|
+
/**
|
|
83
|
+
* Sign a message and return the signature
|
|
84
|
+
*/
|
|
85
|
+
signMessage(message: string): Promise<string>;
|
|
86
|
+
/**
|
|
87
|
+
* Sign a single transaction
|
|
88
|
+
*/
|
|
89
|
+
signTransaction(transaction: SolanaTransaction): Promise<SignedSolanaTransaction>;
|
|
90
|
+
/**
|
|
91
|
+
* Sign multiple transactions
|
|
92
|
+
*/
|
|
93
|
+
signAllTransactions(transactions: SolanaTransaction[]): Promise<SignedSolanaTransaction[]>;
|
|
94
|
+
/**
|
|
95
|
+
* Request-based API (similar to EIP-1193 pattern)
|
|
96
|
+
*/
|
|
97
|
+
request(args: SolanaSignMessageRequest): Promise<{
|
|
98
|
+
signature: string;
|
|
99
|
+
}>;
|
|
100
|
+
request(args: SolanaSignTransactionRequest): Promise<{
|
|
101
|
+
signedTransaction: SignedSolanaTransaction;
|
|
102
|
+
}>;
|
|
23
103
|
}
|
|
24
104
|
/**
|
|
25
105
|
* Connected Ethereum wallet
|
|
@@ -41,6 +121,52 @@ export type ConnectedEmbeddedSolanaWallet = {
|
|
|
41
121
|
walletIndex: number;
|
|
42
122
|
getProvider: () => Promise<OpenfortEmbeddedSolanaWalletProvider>;
|
|
43
123
|
};
|
|
124
|
+
/**
|
|
125
|
+
* Result of creating an Ethereum wallet
|
|
126
|
+
*/
|
|
127
|
+
export type CreateEthereumWalletResult = {
|
|
128
|
+
error?: OpenfortError;
|
|
129
|
+
account?: EmbeddedAccount;
|
|
130
|
+
provider?: OpenfortEmbeddedEthereumWalletProvider;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Options for creating an Ethereum wallet
|
|
134
|
+
*/
|
|
135
|
+
export type CreateEthereumWalletOptions = {
|
|
136
|
+
chainId?: number;
|
|
137
|
+
recoveryPassword?: string;
|
|
138
|
+
accountType?: AccountTypeEnum;
|
|
139
|
+
policyId?: string;
|
|
140
|
+
} & OpenfortHookOptions<CreateEthereumWalletResult>;
|
|
141
|
+
/**
|
|
142
|
+
* Result of setting active Ethereum wallet
|
|
143
|
+
*/
|
|
144
|
+
export type SetActiveEthereumWalletResult = {
|
|
145
|
+
error?: OpenfortError;
|
|
146
|
+
wallet?: ConnectedEmbeddedEthereumWallet;
|
|
147
|
+
provider?: OpenfortEmbeddedEthereumWalletProvider;
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Options for setting active Ethereum wallet
|
|
151
|
+
*/
|
|
152
|
+
export type SetActiveEthereumWalletOptions = {
|
|
153
|
+
address: Hex;
|
|
154
|
+
chainId?: number;
|
|
155
|
+
recoveryPassword?: string;
|
|
156
|
+
} & OpenfortHookOptions<SetActiveEthereumWalletResult>;
|
|
157
|
+
/**
|
|
158
|
+
* Result of setting recovery method
|
|
159
|
+
*/
|
|
160
|
+
export type SetRecoveryResult = {
|
|
161
|
+
error?: OpenfortError;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Options for setting recovery method
|
|
165
|
+
*/
|
|
166
|
+
export type SetRecoveryOptions = {
|
|
167
|
+
previousRecovery: RecoveryParams;
|
|
168
|
+
newRecovery: RecoveryParams;
|
|
169
|
+
} & OpenfortHookOptions<SetRecoveryResult>;
|
|
44
170
|
/**
|
|
45
171
|
* Simplified Solana wallet creation options
|
|
46
172
|
*/
|
|
@@ -55,112 +181,125 @@ export type CreateSolanaEmbeddedWalletOpts = {
|
|
|
55
181
|
*/
|
|
56
182
|
createAdditional?: boolean;
|
|
57
183
|
};
|
|
184
|
+
/**
|
|
185
|
+
* Result of creating a Solana wallet
|
|
186
|
+
*/
|
|
187
|
+
export type CreateSolanaWalletResult = {
|
|
188
|
+
error?: OpenfortError;
|
|
189
|
+
account?: EmbeddedAccount;
|
|
190
|
+
provider?: OpenfortEmbeddedSolanaWalletProvider;
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Options for creating a Solana wallet
|
|
194
|
+
*/
|
|
195
|
+
export type CreateSolanaWalletOptions = CreateSolanaEmbeddedWalletOpts & OpenfortHookOptions<CreateSolanaWalletResult>;
|
|
196
|
+
/**
|
|
197
|
+
* Result of setting active Solana wallet
|
|
198
|
+
*/
|
|
199
|
+
export type SetActiveSolanaWalletResult = {
|
|
200
|
+
error?: OpenfortError;
|
|
201
|
+
wallet?: ConnectedEmbeddedSolanaWallet;
|
|
202
|
+
provider?: OpenfortEmbeddedSolanaWalletProvider;
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* Options for setting active Solana wallet
|
|
206
|
+
*/
|
|
207
|
+
export type SetActiveSolanaWalletOptions = {
|
|
208
|
+
address: string;
|
|
209
|
+
recoveryPassword?: string;
|
|
210
|
+
} & OpenfortHookOptions<SetActiveSolanaWalletResult>;
|
|
211
|
+
/**
|
|
212
|
+
* Common actions available on all Ethereum wallet states
|
|
213
|
+
*/
|
|
214
|
+
export interface EthereumWalletActions {
|
|
215
|
+
/**
|
|
216
|
+
* Create a new embedded Ethereum wallet
|
|
217
|
+
*/
|
|
218
|
+
create(options?: CreateEthereumWalletOptions): Promise<EmbeddedAccount>;
|
|
219
|
+
/**
|
|
220
|
+
* List of available wallets
|
|
221
|
+
*/
|
|
222
|
+
wallets: ConnectedEmbeddedEthereumWallet[];
|
|
223
|
+
/**
|
|
224
|
+
* Set a wallet as active (recover/connect to it)
|
|
225
|
+
*/
|
|
226
|
+
setActive(options: SetActiveEthereumWalletOptions): Promise<void>;
|
|
227
|
+
/**
|
|
228
|
+
* Update the recovery method for the wallet
|
|
229
|
+
*/
|
|
230
|
+
setRecovery(options: SetRecoveryOptions): Promise<void>;
|
|
231
|
+
/**
|
|
232
|
+
* Export the private key of the active wallet
|
|
233
|
+
*/
|
|
234
|
+
exportPrivateKey(): Promise<string>;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Common actions available on all Solana wallet states
|
|
238
|
+
*/
|
|
239
|
+
export interface SolanaWalletActions {
|
|
240
|
+
/**
|
|
241
|
+
* Create a new embedded Solana wallet
|
|
242
|
+
*/
|
|
243
|
+
create(options?: CreateSolanaWalletOptions): Promise<EmbeddedAccount>;
|
|
244
|
+
/**
|
|
245
|
+
* List of available wallets
|
|
246
|
+
*/
|
|
247
|
+
wallets: ConnectedEmbeddedSolanaWallet[];
|
|
248
|
+
/**
|
|
249
|
+
* Set a wallet as active (recover/connect to it)
|
|
250
|
+
*/
|
|
251
|
+
setActive(options: SetActiveSolanaWalletOptions): Promise<void>;
|
|
252
|
+
}
|
|
58
253
|
/**
|
|
59
254
|
* Ethereum wallet hook return type - discriminated union based on status
|
|
60
255
|
*/
|
|
61
|
-
export type EmbeddedEthereumWalletState = {
|
|
256
|
+
export type EmbeddedEthereumWalletState = (EthereumWalletActions & {
|
|
62
257
|
status: 'disconnected';
|
|
63
258
|
activeWallet: null;
|
|
64
|
-
|
|
65
|
-
wallets: ConnectedEmbeddedEthereumWallet[];
|
|
66
|
-
setActive: (...args: any[]) => Promise<void>;
|
|
67
|
-
setRecovery: (...args: any[]) => Promise<void>;
|
|
68
|
-
exportPrivateKey: (...args: any[]) => Promise<any>;
|
|
69
|
-
} | {
|
|
259
|
+
}) | (EthereumWalletActions & {
|
|
70
260
|
status: 'connecting';
|
|
71
261
|
activeWallet: ConnectedEmbeddedEthereumWallet;
|
|
72
|
-
|
|
73
|
-
wallets: ConnectedEmbeddedEthereumWallet[];
|
|
74
|
-
setActive: (...args: any[]) => Promise<void>;
|
|
75
|
-
setRecovery: (...args: any[]) => Promise<void>;
|
|
76
|
-
exportPrivateKey: (...args: any[]) => Promise<any>;
|
|
77
|
-
} | {
|
|
262
|
+
}) | (EthereumWalletActions & {
|
|
78
263
|
status: 'reconnecting';
|
|
79
264
|
activeWallet: ConnectedEmbeddedEthereumWallet;
|
|
80
|
-
|
|
81
|
-
wallets: ConnectedEmbeddedEthereumWallet[];
|
|
82
|
-
setActive: (...args: any[]) => Promise<void>;
|
|
83
|
-
setRecovery: (...args: any[]) => Promise<void>;
|
|
84
|
-
exportPrivateKey: (...args: any[]) => Promise<any>;
|
|
85
|
-
} | {
|
|
265
|
+
}) | (EthereumWalletActions & {
|
|
86
266
|
status: 'creating';
|
|
87
267
|
activeWallet: null;
|
|
88
|
-
|
|
89
|
-
wallets: ConnectedEmbeddedEthereumWallet[];
|
|
90
|
-
setActive: (...args: any[]) => Promise<void>;
|
|
91
|
-
setRecovery: (...args: any[]) => Promise<void>;
|
|
92
|
-
exportPrivateKey: (...args: any[]) => Promise<any>;
|
|
93
|
-
} | {
|
|
268
|
+
}) | (EthereumWalletActions & {
|
|
94
269
|
status: 'needs-recovery';
|
|
95
270
|
activeWallet: ConnectedEmbeddedEthereumWallet;
|
|
96
|
-
|
|
97
|
-
wallets: ConnectedEmbeddedEthereumWallet[];
|
|
98
|
-
setActive: (...args: any[]) => Promise<void>;
|
|
99
|
-
setRecovery: (...args: any[]) => Promise<void>;
|
|
100
|
-
exportPrivateKey: (...args: any[]) => Promise<any>;
|
|
101
|
-
} | {
|
|
271
|
+
}) | (EthereumWalletActions & {
|
|
102
272
|
status: 'connected';
|
|
103
273
|
activeWallet: ConnectedEmbeddedEthereumWallet;
|
|
104
274
|
provider: OpenfortEmbeddedEthereumWalletProvider;
|
|
105
|
-
|
|
106
|
-
wallets: ConnectedEmbeddedEthereumWallet[];
|
|
107
|
-
setActive: (...args: any[]) => Promise<void>;
|
|
108
|
-
setRecovery: (...args: any[]) => Promise<void>;
|
|
109
|
-
exportPrivateKey: (...args: any[]) => Promise<any>;
|
|
110
|
-
} | {
|
|
275
|
+
}) | (EthereumWalletActions & {
|
|
111
276
|
status: 'error';
|
|
112
277
|
activeWallet: ConnectedEmbeddedEthereumWallet | null;
|
|
113
278
|
error: string;
|
|
114
|
-
|
|
115
|
-
wallets: ConnectedEmbeddedEthereumWallet[];
|
|
116
|
-
setActive: (...args: any[]) => Promise<void>;
|
|
117
|
-
setRecovery: (...args: any[]) => Promise<void>;
|
|
118
|
-
exportPrivateKey: (...args: any[]) => Promise<any>;
|
|
119
|
-
};
|
|
279
|
+
});
|
|
120
280
|
/**
|
|
121
281
|
* Solana wallet hook return type - discriminated union based on status
|
|
122
282
|
*/
|
|
123
|
-
export type EmbeddedSolanaWalletState = {
|
|
283
|
+
export type EmbeddedSolanaWalletState = (SolanaWalletActions & {
|
|
124
284
|
status: 'disconnected';
|
|
125
285
|
activeWallet: null;
|
|
126
|
-
|
|
127
|
-
wallets: ConnectedEmbeddedSolanaWallet[];
|
|
128
|
-
setActive: (...args: any[]) => Promise<void>;
|
|
129
|
-
} | {
|
|
286
|
+
}) | (SolanaWalletActions & {
|
|
130
287
|
status: 'connecting';
|
|
131
|
-
|
|
132
|
-
wallets: ConnectedEmbeddedSolanaWallet[];
|
|
133
|
-
setActive: (...args: any[]) => Promise<void>;
|
|
134
|
-
} | {
|
|
288
|
+
}) | (SolanaWalletActions & {
|
|
135
289
|
status: 'reconnecting';
|
|
136
290
|
activeWallet: ConnectedEmbeddedSolanaWallet;
|
|
137
|
-
|
|
138
|
-
wallets: ConnectedEmbeddedSolanaWallet[];
|
|
139
|
-
setActive: (...args: any[]) => Promise<void>;
|
|
140
|
-
} | {
|
|
291
|
+
}) | (SolanaWalletActions & {
|
|
141
292
|
status: 'creating';
|
|
142
293
|
activeWallet: null;
|
|
143
|
-
|
|
144
|
-
wallets: ConnectedEmbeddedSolanaWallet[];
|
|
145
|
-
setActive: (...args: any[]) => Promise<void>;
|
|
146
|
-
} | {
|
|
294
|
+
}) | (SolanaWalletActions & {
|
|
147
295
|
status: 'needs-recovery';
|
|
148
296
|
activeWallet: ConnectedEmbeddedSolanaWallet;
|
|
149
|
-
|
|
150
|
-
wallets: ConnectedEmbeddedSolanaWallet[];
|
|
151
|
-
setActive: (...args: any[]) => Promise<void>;
|
|
152
|
-
} | {
|
|
297
|
+
}) | (SolanaWalletActions & {
|
|
153
298
|
status: 'connected';
|
|
154
299
|
activeWallet: ConnectedEmbeddedSolanaWallet;
|
|
155
300
|
provider: OpenfortEmbeddedSolanaWalletProvider;
|
|
156
|
-
|
|
157
|
-
wallets: ConnectedEmbeddedSolanaWallet[];
|
|
158
|
-
setActive: (...args: any[]) => Promise<void>;
|
|
159
|
-
} | {
|
|
301
|
+
}) | (SolanaWalletActions & {
|
|
160
302
|
status: 'error';
|
|
161
303
|
activeWallet: ConnectedEmbeddedSolanaWallet | null;
|
|
162
304
|
error: string;
|
|
163
|
-
|
|
164
|
-
wallets: ConnectedEmbeddedSolanaWallet[];
|
|
165
|
-
setActive: (...args: any[]) => Promise<void>;
|
|
166
|
-
};
|
|
305
|
+
});
|
package/package.json
CHANGED