@phantom/react-native-sdk 1.0.0-beta.21 → 1.0.0-beta.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/README.md +42 -22
- package/dist/index.d.ts +2 -6
- package/dist/index.js +7 -10
- package/dist/index.mjs +13 -11
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -201,7 +201,7 @@ interface PhantomSDKConfig {
|
|
|
201
201
|
scheme: string; // Custom URL scheme for your app
|
|
202
202
|
appId: string; // Your app ID from phantom.com/portal (required)
|
|
203
203
|
addressTypes: [AddressType, ...AddressType[]]; // e.g., [AddressType.solana]
|
|
204
|
-
|
|
204
|
+
|
|
205
205
|
// Optional configuration
|
|
206
206
|
embeddedWalletType?: "user-wallet"; // optional, defaults to "user-wallet", currently the only supported type
|
|
207
207
|
apiBaseUrl?: string; // e.g., "https://api.phantom.app/v1/wallets" (optional, has default)
|
|
@@ -209,7 +209,6 @@ interface PhantomSDKConfig {
|
|
|
209
209
|
authUrl?: string; // Custom auth URL (optional)
|
|
210
210
|
redirectUrl?: string; // Custom redirect URL (optional)
|
|
211
211
|
};
|
|
212
|
-
autoConnect?: boolean; // Auto-connect to existing session on SDK instantiation (optional, defaults to true)
|
|
213
212
|
}
|
|
214
213
|
```
|
|
215
214
|
|
|
@@ -223,9 +222,12 @@ Manages wallet connection functionality.
|
|
|
223
222
|
const { connect, isConnecting, error } = useConnect();
|
|
224
223
|
|
|
225
224
|
// Connect with specific provider
|
|
226
|
-
await connect({ provider: "google" });
|
|
227
|
-
await connect({ provider: "apple" });
|
|
228
|
-
await connect({ provider: "
|
|
225
|
+
await connect({ provider: "google" }); // Google OAuth
|
|
226
|
+
await connect({ provider: "apple" }); // Apple ID
|
|
227
|
+
await connect({ provider: "phantom" }); // Phantom Login
|
|
228
|
+
await connect({ provider: "x" }); // X/Twitter
|
|
229
|
+
await connect({ provider: "tiktok" }); // TikTok
|
|
230
|
+
await connect({ provider: "jwt", jwtToken: "your-jwt-token" }); // Custom JWT
|
|
229
231
|
```
|
|
230
232
|
|
|
231
233
|
#### useAccounts
|
|
@@ -301,18 +303,18 @@ if (isAvailable) {
|
|
|
301
303
|
|
|
302
304
|
**Supported EVM Networks:**
|
|
303
305
|
|
|
304
|
-
| Network
|
|
305
|
-
|
|
306
|
-
| Ethereum Mainnet | `1`
|
|
306
|
+
| Network | Chain ID | Usage |
|
|
307
|
+
| ---------------- | ---------- | -------------------------------- |
|
|
308
|
+
| Ethereum Mainnet | `1` | `ethereum.switchChain(1)` |
|
|
307
309
|
| Ethereum Sepolia | `11155111` | `ethereum.switchChain(11155111)` |
|
|
308
|
-
| Polygon Mainnet
|
|
309
|
-
| Polygon Amoy
|
|
310
|
-
| Base Mainnet
|
|
311
|
-
| Base Sepolia
|
|
312
|
-
| Arbitrum One
|
|
313
|
-
| Arbitrum Sepolia | `421614`
|
|
314
|
-
| Monad Mainnet
|
|
315
|
-
| Monad Testnet
|
|
310
|
+
| Polygon Mainnet | `137` | `ethereum.switchChain(137)` |
|
|
311
|
+
| Polygon Amoy | `80002` | `ethereum.switchChain(80002)` |
|
|
312
|
+
| Base Mainnet | `8453` | `ethereum.switchChain(8453)` |
|
|
313
|
+
| Base Sepolia | `84532` | `ethereum.switchChain(84532)` |
|
|
314
|
+
| Arbitrum One | `42161` | `ethereum.switchChain(42161)` |
|
|
315
|
+
| Arbitrum Sepolia | `421614` | `ethereum.switchChain(421614)` |
|
|
316
|
+
| Monad Mainnet | `143` | `ethereum.switchChain(143)` |
|
|
317
|
+
| Monad Testnet | `10143` | `ethereum.switchChain(10143)` |
|
|
316
318
|
|
|
317
319
|
#### useDisconnect
|
|
318
320
|
|
|
@@ -326,13 +328,32 @@ await disconnect();
|
|
|
326
328
|
|
|
327
329
|
## Authentication Flows
|
|
328
330
|
|
|
329
|
-
###
|
|
331
|
+
### Available Providers
|
|
330
332
|
|
|
331
|
-
The SDK supports multiple
|
|
333
|
+
The SDK supports multiple authentication providers that you specify when calling `connect()`:
|
|
332
334
|
|
|
333
|
-
- **Google** (`provider:
|
|
334
|
-
- **Apple** (`provider:
|
|
335
|
-
- **
|
|
335
|
+
- **Google** (`provider: "google"`) - Google OAuth authentication
|
|
336
|
+
- **Apple** (`provider: "apple"`) - Apple ID authentication
|
|
337
|
+
- **Phantom** (`provider: "phantom"`) - Phantom Login authentication
|
|
338
|
+
- **X** (`provider: "x"`) - X/Twitter authentication
|
|
339
|
+
- **TikTok** (`provider: "tiktok"`) - TikTok authentication
|
|
340
|
+
- **JWT** (`provider: "jwt"`) - Custom JWT authentication (requires `jwtToken` parameter)
|
|
341
|
+
|
|
342
|
+
**Example Usage:**
|
|
343
|
+
|
|
344
|
+
```tsx
|
|
345
|
+
// Google OAuth
|
|
346
|
+
await connect({ provider: "google" });
|
|
347
|
+
|
|
348
|
+
// Apple ID
|
|
349
|
+
await connect({ provider: "apple" });
|
|
350
|
+
|
|
351
|
+
// Phantom Login
|
|
352
|
+
await connect({ provider: "phantom" });
|
|
353
|
+
|
|
354
|
+
// JWT authentication
|
|
355
|
+
await connect({ provider: "jwt", jwtToken: "your-jwt-token" });
|
|
356
|
+
```
|
|
336
357
|
|
|
337
358
|
### Authentication Process
|
|
338
359
|
|
|
@@ -502,4 +523,3 @@ interface PhantomDebugConfig {
|
|
|
502
523
|
enabled?: boolean; // Enable debug logging (default: false)
|
|
503
524
|
}
|
|
504
525
|
```
|
|
505
|
-
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import * as _phantom_embedded_provider_core from '@phantom/embedded-provider-core';
|
|
4
|
-
import { EmbeddedProviderConfig, EmbeddedProvider, WalletAddress, ConnectResult } from '@phantom/embedded-provider-core';
|
|
4
|
+
import { EmbeddedProviderConfig, EmbeddedProviderAuthType, EmbeddedProvider, WalletAddress, ConnectResult } from '@phantom/embedded-provider-core';
|
|
5
5
|
export { ConnectErrorEventData, ConnectEventData, ConnectResult, ConnectStartEventData, DisconnectEventData, EmbeddedProviderEvent, EmbeddedProviderEventMap, EventCallback, SignAndSendTransactionParams, SignMessageParams, SignMessageResult, SignedTransaction, WalletAddress } from '@phantom/embedded-provider-core';
|
|
6
6
|
import { ISolanaChain, IEthereumChain } from '@phantom/chain-interfaces';
|
|
7
7
|
export { AddressType } from '@phantom/client';
|
|
@@ -14,8 +14,6 @@ interface PhantomDebugConfig {
|
|
|
14
14
|
interface PhantomSDKConfig extends Omit<EmbeddedProviderConfig, "apiBaseUrl" | "embeddedWalletType" | "authOptions"> {
|
|
15
15
|
/** Custom URL scheme for your app (e.g., "myapp") */
|
|
16
16
|
scheme: string;
|
|
17
|
-
/** Enable auto-connect to existing sessions (default: true) */
|
|
18
|
-
autoConnect?: boolean;
|
|
19
17
|
/** Base URL for Phantom API (default: "https://api.phantom.app/v1/wallets") */
|
|
20
18
|
apiBaseUrl?: string;
|
|
21
19
|
/** Authentication options */
|
|
@@ -27,9 +25,7 @@ interface PhantomSDKConfig extends Omit<EmbeddedProviderConfig, "apiBaseUrl" | "
|
|
|
27
25
|
}
|
|
28
26
|
interface ConnectOptions {
|
|
29
27
|
/** OAuth provider to use (required) */
|
|
30
|
-
provider:
|
|
31
|
-
/** JWT token for JWT authentication */
|
|
32
|
-
jwtToken?: string;
|
|
28
|
+
provider: EmbeddedProviderAuthType;
|
|
33
29
|
/** Custom authentication data */
|
|
34
30
|
customAuthData?: Record<string, any>;
|
|
35
31
|
}
|
package/dist/index.js
CHANGED
|
@@ -153,7 +153,7 @@ var ExpoAuthProvider = class {
|
|
|
153
153
|
// OAuth session management - defaults to allow refresh unless explicitly clearing after logout
|
|
154
154
|
clear_previous_session: (phantomOptions.clearPreviousSession ?? false).toString(),
|
|
155
155
|
allow_refresh: (phantomOptions.allowRefresh ?? true).toString(),
|
|
156
|
-
sdk_version: "1.0.0-beta.
|
|
156
|
+
sdk_version: "1.0.0-beta.22",
|
|
157
157
|
sdk_type: "react-native",
|
|
158
158
|
platform: import_react_native.Platform.OS
|
|
159
159
|
});
|
|
@@ -185,7 +185,6 @@ var ExpoAuthProvider = class {
|
|
|
185
185
|
const url = new URL(result.url);
|
|
186
186
|
const walletId = url.searchParams.get("wallet_id");
|
|
187
187
|
const organizationId = url.searchParams.get("organization_id");
|
|
188
|
-
const provider2 = url.searchParams.get("provider");
|
|
189
188
|
const accountDerivationIndex = url.searchParams.get("selected_account_index");
|
|
190
189
|
const expiresInMs = url.searchParams.get("expires_in_ms");
|
|
191
190
|
const authUserId = url.searchParams.get("auth_user_id");
|
|
@@ -199,7 +198,7 @@ var ExpoAuthProvider = class {
|
|
|
199
198
|
console.log("[ExpoAuthProvider] Auth redirect parameters", {
|
|
200
199
|
walletId,
|
|
201
200
|
organizationId,
|
|
202
|
-
provider
|
|
201
|
+
provider,
|
|
203
202
|
accountDerivationIndex,
|
|
204
203
|
expiresInMs,
|
|
205
204
|
authUserId
|
|
@@ -207,7 +206,7 @@ var ExpoAuthProvider = class {
|
|
|
207
206
|
return {
|
|
208
207
|
walletId,
|
|
209
208
|
organizationId,
|
|
210
|
-
provider:
|
|
209
|
+
provider: provider || void 0,
|
|
211
210
|
accountDerivationIndex: accountDerivationIndex ? parseInt(accountDerivationIndex) : 0,
|
|
212
211
|
expiresInMs: expiresInMs ? parseInt(expiresInMs) : 0,
|
|
213
212
|
authUserId: authUserId || void 0
|
|
@@ -559,7 +558,7 @@ function PhantomProvider({ children, config, debugConfig }) {
|
|
|
559
558
|
[import_constants2.ANALYTICS_HEADERS.PLATFORM_VERSION]: `${import_react_native3.Platform.Version}`,
|
|
560
559
|
[import_constants2.ANALYTICS_HEADERS.APP_ID]: config.appId,
|
|
561
560
|
[import_constants2.ANALYTICS_HEADERS.WALLET_TYPE]: config.embeddedWalletType,
|
|
562
|
-
[import_constants2.ANALYTICS_HEADERS.SDK_VERSION]: "1.0.0-beta.
|
|
561
|
+
[import_constants2.ANALYTICS_HEADERS.SDK_VERSION]: "1.0.0-beta.22"
|
|
563
562
|
// Replaced at build time
|
|
564
563
|
}
|
|
565
564
|
};
|
|
@@ -611,11 +610,9 @@ function PhantomProvider({ children, config, debugConfig }) {
|
|
|
611
610
|
};
|
|
612
611
|
}, [sdk]);
|
|
613
612
|
(0, import_react.useEffect)(() => {
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
}
|
|
618
|
-
}, [sdk, config.autoConnect]);
|
|
613
|
+
sdk.autoConnect().catch(() => {
|
|
614
|
+
});
|
|
615
|
+
}, [sdk]);
|
|
619
616
|
const value = (0, import_react.useMemo)(
|
|
620
617
|
() => ({
|
|
621
618
|
sdk,
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
// src/PhantomProvider.tsx
|
|
2
2
|
import { createContext, useContext, useState, useEffect, useMemo } from "react";
|
|
3
3
|
import { EmbeddedProvider } from "@phantom/embedded-provider-core";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
ANALYTICS_HEADERS,
|
|
6
|
+
DEFAULT_WALLET_API_URL,
|
|
7
|
+
DEFAULT_EMBEDDED_WALLET_TYPE,
|
|
8
|
+
DEFAULT_AUTH_URL as DEFAULT_AUTH_URL2
|
|
9
|
+
} from "@phantom/constants";
|
|
5
10
|
|
|
6
11
|
// src/providers/embedded/storage.ts
|
|
7
12
|
import * as SecureStore from "expo-secure-store";
|
|
@@ -109,7 +114,7 @@ var ExpoAuthProvider = class {
|
|
|
109
114
|
// OAuth session management - defaults to allow refresh unless explicitly clearing after logout
|
|
110
115
|
clear_previous_session: (phantomOptions.clearPreviousSession ?? false).toString(),
|
|
111
116
|
allow_refresh: (phantomOptions.allowRefresh ?? true).toString(),
|
|
112
|
-
sdk_version: "1.0.0-beta.
|
|
117
|
+
sdk_version: "1.0.0-beta.22",
|
|
113
118
|
sdk_type: "react-native",
|
|
114
119
|
platform: Platform.OS
|
|
115
120
|
});
|
|
@@ -141,7 +146,6 @@ var ExpoAuthProvider = class {
|
|
|
141
146
|
const url = new URL(result.url);
|
|
142
147
|
const walletId = url.searchParams.get("wallet_id");
|
|
143
148
|
const organizationId = url.searchParams.get("organization_id");
|
|
144
|
-
const provider2 = url.searchParams.get("provider");
|
|
145
149
|
const accountDerivationIndex = url.searchParams.get("selected_account_index");
|
|
146
150
|
const expiresInMs = url.searchParams.get("expires_in_ms");
|
|
147
151
|
const authUserId = url.searchParams.get("auth_user_id");
|
|
@@ -155,7 +159,7 @@ var ExpoAuthProvider = class {
|
|
|
155
159
|
console.log("[ExpoAuthProvider] Auth redirect parameters", {
|
|
156
160
|
walletId,
|
|
157
161
|
organizationId,
|
|
158
|
-
provider
|
|
162
|
+
provider,
|
|
159
163
|
accountDerivationIndex,
|
|
160
164
|
expiresInMs,
|
|
161
165
|
authUserId
|
|
@@ -163,7 +167,7 @@ var ExpoAuthProvider = class {
|
|
|
163
167
|
return {
|
|
164
168
|
walletId,
|
|
165
169
|
organizationId,
|
|
166
|
-
provider:
|
|
170
|
+
provider: provider || void 0,
|
|
167
171
|
accountDerivationIndex: accountDerivationIndex ? parseInt(accountDerivationIndex) : 0,
|
|
168
172
|
expiresInMs: expiresInMs ? parseInt(expiresInMs) : 0,
|
|
169
173
|
authUserId: authUserId || void 0
|
|
@@ -515,7 +519,7 @@ function PhantomProvider({ children, config, debugConfig }) {
|
|
|
515
519
|
[ANALYTICS_HEADERS.PLATFORM_VERSION]: `${Platform2.Version}`,
|
|
516
520
|
[ANALYTICS_HEADERS.APP_ID]: config.appId,
|
|
517
521
|
[ANALYTICS_HEADERS.WALLET_TYPE]: config.embeddedWalletType,
|
|
518
|
-
[ANALYTICS_HEADERS.SDK_VERSION]: "1.0.0-beta.
|
|
522
|
+
[ANALYTICS_HEADERS.SDK_VERSION]: "1.0.0-beta.22"
|
|
519
523
|
// Replaced at build time
|
|
520
524
|
}
|
|
521
525
|
};
|
|
@@ -567,11 +571,9 @@ function PhantomProvider({ children, config, debugConfig }) {
|
|
|
567
571
|
};
|
|
568
572
|
}, [sdk]);
|
|
569
573
|
useEffect(() => {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
}
|
|
574
|
-
}, [sdk, config.autoConnect]);
|
|
574
|
+
sdk.autoConnect().catch(() => {
|
|
575
|
+
});
|
|
576
|
+
}, [sdk]);
|
|
575
577
|
const value = useMemo(
|
|
576
578
|
() => ({
|
|
577
579
|
sdk,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phantom/react-native-sdk",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.22",
|
|
4
4
|
"description": "Phantom Wallet SDK for React Native and Expo applications",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"directory": "packages/react-native-sdk"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@phantom/api-key-stamper": "^1.0.0-beta.
|
|
49
|
-
"@phantom/base64url": "^1.0.0-beta.
|
|
50
|
-
"@phantom/chain-interfaces": "^1.0.0-beta.
|
|
51
|
-
"@phantom/client": "^1.0.0-beta.
|
|
52
|
-
"@phantom/constants": "^1.0.0-beta.
|
|
53
|
-
"@phantom/crypto": "^1.0.0-beta.
|
|
54
|
-
"@phantom/embedded-provider-core": "^1.0.0-beta.
|
|
55
|
-
"@phantom/sdk-types": "^1.0.0-beta.
|
|
48
|
+
"@phantom/api-key-stamper": "^1.0.0-beta.10",
|
|
49
|
+
"@phantom/base64url": "^1.0.0-beta.10",
|
|
50
|
+
"@phantom/chain-interfaces": "^1.0.0-beta.10",
|
|
51
|
+
"@phantom/client": "^1.0.0-beta.22",
|
|
52
|
+
"@phantom/constants": "^1.0.0-beta.10",
|
|
53
|
+
"@phantom/crypto": "^1.0.0-beta.10",
|
|
54
|
+
"@phantom/embedded-provider-core": "^1.0.0-beta.22",
|
|
55
|
+
"@phantom/sdk-types": "^1.0.0-beta.10",
|
|
56
56
|
"@types/bs58": "^5.0.0",
|
|
57
57
|
"bs58": "^6.0.0",
|
|
58
58
|
"buffer": "^6.0.3"
|