@phantom/browser-sdk 1.0.0-beta.2 → 1.0.0-beta.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.
package/README.md CHANGED
@@ -19,7 +19,7 @@ const sdk = new BrowserSDK({
19
19
  addressTypes: [AddressType.solana, AddressType.ethereum],
20
20
  });
21
21
 
22
- const { addresses } = await sdk.connect();
22
+ const { addresses } = await sdk.connect({ provider: "injected" });
23
23
  console.log("Connected addresses:", addresses);
24
24
 
25
25
  // Chain-specific operations
@@ -44,11 +44,10 @@ import { BrowserSDK, AddressType } from "@phantom/browser-sdk";
44
44
  const sdk = new BrowserSDK({
45
45
  providerType: "embedded",
46
46
  addressTypes: [AddressType.solana, AddressType.ethereum],
47
- apiBaseUrl: "https://api.phantom.app/v1/wallets",
48
- appId: "your-app-id",
47
+ appId: "your-app-id", // Get your app ID from phantom.com/portal
49
48
  });
50
49
 
51
- const { addresses } = await sdk.connect();
50
+ const { addresses } = await sdk.connect({ provider: "phantom" });
52
51
  console.log("Addresses:", addresses);
53
52
 
54
53
  // Use chain-specific APIs
@@ -79,8 +78,8 @@ const sdk = new BrowserSDK({
79
78
  addressTypes: [AddressType.solana, AddressType.ethereum],
80
79
  });
81
80
 
82
- // 2. Connect to wallet
83
- const { addresses } = await sdk.connect();
81
+ // 2. Connect to wallet (provider parameter is required)
82
+ const { addresses } = await sdk.connect({ provider: "injected" });
84
83
  console.log("Connected addresses:", addresses);
85
84
 
86
85
  // 3. Use chain-specific methods
@@ -94,24 +93,38 @@ const ethResult = await sdk.ethereum.sendTransaction({
94
93
 
95
94
  ### Connection Options
96
95
 
97
- For embedded user-wallets, you can specify authentication providers:
96
+ The `connect()` method requires a `provider` parameter and automatically switches between providers based on the authentication method you specify:
98
97
 
99
98
  ```typescript
100
- // Default: Show provider selection screen
101
- const result = await sdk.connect();
99
+ // Connect with injected provider (Phantom extension)
100
+ // Automatically switches to injected provider if not already using it
101
+ const result = await sdk.connect({
102
+ provider: "injected",
103
+ });
102
104
 
103
- // Google authentication (skips provider selection)
105
+ // Connect with Google authentication (embedded provider)
106
+ // Automatically switches to embedded provider if not already using it
104
107
  const result = await sdk.connect({
105
- authOptions: {
106
- provider: "google",
107
- },
108
+ provider: "google",
108
109
  });
109
110
 
110
- // Apple authentication (skips provider selection)
111
+ // Connect with Apple authentication (embedded provider)
112
+ // Automatically switches to embedded provider if not already using it
111
113
  const result = await sdk.connect({
112
- authOptions: {
113
- provider: "apple",
114
- },
114
+ provider: "apple",
115
+ });
116
+
117
+ // Connect with Phantom authentication (embedded provider)
118
+ // Uses Phantom extension or mobile app for authentication
119
+ // Automatically switches to embedded provider if not already using it
120
+ const result = await sdk.connect({
121
+ provider: "phantom",
122
+ });
123
+
124
+ // Connect with JWT authentication (embedded provider)
125
+ const result = await sdk.connect({
126
+ provider: "jwt",
127
+ jwtToken: "your-jwt-token",
115
128
  });
116
129
  ```
117
130
 
@@ -190,48 +203,29 @@ Creates a non-custodial wallet embedded in your application. Requires API config
190
203
  const sdk = new BrowserSDK({
191
204
  providerType: "embedded",
192
205
  addressTypes: [AddressType.solana, AddressType.ethereum],
193
- apiBaseUrl: "https://api.phantom.app/v1/wallets",
194
- appId: "your-app-id",
195
- embeddedWalletType: "app-wallet", // or 'user-wallet'
206
+ appId: "your-app-id", // Get your app ID from phantom.com/portal
196
207
  authOptions: {
197
- authUrl: "https://auth.phantom.app", // optional, defaults to "https://connect.phantom.app"
208
+ authUrl: "https://connect.phantom.app/login", // optional, defaults to "https://connect.phantom.app/login"
198
209
  redirectUrl: "https://yourapp.com/callback", // optional, defaults to current page
199
210
  },
200
211
  autoConnect: true, // optional, auto-connect to existing session (default: true for embedded)
201
212
  });
202
213
  ```
203
214
 
204
- ### Embedded Wallet Types
205
-
206
- #### App Wallet (`'app-wallet'`)
207
-
208
- - **New wallets** created per application
209
- - **Unfunded** by default - you need to fund them
210
- - **Independent** from user's existing Phantom wallet
211
- - **Perfect for**: Gaming, DeFi protocols, or apps that need fresh wallets
212
-
213
- ```typescript
214
- const sdk = new BrowserSDK({
215
- providerType: "embedded",
216
- embeddedWalletType: "app-wallet",
217
- addressTypes: [AddressType.solana],
218
- // ... other config
219
- });
220
- ```
215
+ ### Embedded Wallet Type
221
216
 
222
217
  #### User Wallet (`'user-wallet'`)
223
218
 
224
219
  - **Uses Phantom authentication** - user logs in with existing Phantom account
225
220
  - **Potentially funded** - brings in user's existing wallet balance
226
221
  - **Connected** to user's Phantom ecosystem
227
- - **Perfect for**: Trading platforms, NFT marketplaces, or apps needing funded wallets
222
+ - **Perfect for**: All embedded wallet use cases
228
223
 
229
224
  ```typescript
230
225
  const sdk = new BrowserSDK({
231
226
  providerType: "embedded",
232
- embeddedWalletType: "user-wallet",
227
+ appId: "your-app-id",
233
228
  addressTypes: [AddressType.solana, AddressType.ethereum],
234
- // ... other config
235
229
  });
236
230
  ```
237
231
 
@@ -242,28 +236,6 @@ const sdk = new BrowserSDK({
242
236
  | `AddressType.solana` | Solana Mainnet, Devnet, Testnet |
243
237
  | `AddressType.ethereum` | Ethereum, Polygon, Arbitrum, and more |
244
238
 
245
- ### Solana Provider Configuration
246
-
247
- When using `AddressType.solana`, you can choose between two Solana libraries:
248
-
249
- ```typescript
250
- const sdk = new BrowserSDK({
251
- providerType: "embedded",
252
- addressTypes: [AddressType.solana],
253
- solanaProvider: "web3js", // or 'kit'
254
- // ... other config
255
- });
256
- ```
257
-
258
- **Provider Options:**
259
-
260
- - `'web3js'` (default) - Uses `@solana/web3.js` library
261
- - `'kit'` - Uses `@solana/kit` library (modern, TypeScript-first)
262
-
263
- **When to use each:**
264
-
265
- - **@solana/web3.js**: Better ecosystem compatibility, wider community support
266
- - **@solana/kit**: Better TypeScript support, modern architecture, smaller bundle size
267
239
 
268
240
  ### Auto-Connect Feature
269
241
 
@@ -272,8 +244,8 @@ The SDK can automatically reconnect to existing sessions when instantiated, prov
272
244
  ```typescript
273
245
  const sdk = new BrowserSDK({
274
246
  providerType: "embedded",
247
+ appId: "your-app-id",
275
248
  addressTypes: [AddressType.solana],
276
- // ... other config
277
249
  autoConnect: true, // Default: true for embedded, false for injected
278
250
  });
279
251
 
@@ -295,8 +267,8 @@ if (sdk.isConnected()) {
295
267
  ```typescript
296
268
  const sdk = new BrowserSDK({
297
269
  providerType: "embedded",
270
+ appId: "your-app-id",
298
271
  addressTypes: [AddressType.solana],
299
- // ... other config
300
272
  autoConnect: false, // Disable auto-connect
301
273
  });
302
274
 
@@ -320,21 +292,24 @@ interface BrowserSDKConfig {
320
292
  addressTypes?: [AddressType, ...AddressType[]]; // Networks to enable (e.g., [AddressType.solana])
321
293
 
322
294
  // Required for embedded provider only
323
- apiBaseUrl?: string; // Phantom API base URL
324
- appId?: string; // Your app ID (required for embedded provider)
295
+ appId?: string; // Your app ID from phantom.com/portal (required for embedded provider)
296
+
297
+ // Optional configuration
298
+ apiBaseUrl?: string; // Phantom API base URL (optional, has default)
325
299
  authOptions?: {
326
- authUrl?: string; // Custom auth URL (default: "https://connect.phantom.app")
327
- redirectUrl?: string; // Custom redirect URL after authentication
300
+ authUrl?: string; // Custom auth URL (optional, defaults to "https://connect.phantom.app/login")
301
+ redirectUrl?: string; // Custom redirect URL after authentication (optional)
328
302
  };
329
- embeddedWalletType?: "app-wallet" | "user-wallet"; // Wallet type
330
- solanaProvider?: "web3js" | "kit"; // Solana library choice (default: 'web3js')
331
- autoConnect?: boolean; // Enable auto-connect to existing sessions (default: true)
303
+ embeddedWalletType?: "user-wallet"; // Wallet type (optional, defaults to "user-wallet", currently the only supported type)
304
+ autoConnect?: boolean; // Enable auto-connect to existing sessions (optional, defaults to true for embedded)
332
305
  }
333
306
  ```
334
307
 
335
308
  ### Extension Detection
336
309
 
337
- For injected provider usage, you can check if the Phantom extension is installed:
310
+ #### waitForPhantomExtension
311
+
312
+ Check if the Phantom extension is installed:
338
313
 
339
314
  ```typescript
340
315
  import { waitForPhantomExtension } from "@phantom/browser-sdk";
@@ -348,15 +323,46 @@ if (isAvailable) {
348
323
  }
349
324
  ```
350
325
 
326
+ #### isPhantomLoginAvailable
327
+
328
+ Check if Phantom Login is available (requires extension to be installed and support the `phantom_login` feature):
329
+
330
+ ```typescript
331
+ import { isPhantomLoginAvailable } from "@phantom/browser-sdk";
332
+
333
+ const isAvailable = await isPhantomLoginAvailable();
334
+
335
+ if (isAvailable) {
336
+ console.log("Phantom Login is available!");
337
+ // Can use provider: "phantom" in connect()
338
+ } else {
339
+ console.log("Phantom Login is not available");
340
+ }
341
+ ```
342
+
351
343
  ### Core Methods
352
344
 
353
- #### connect()
345
+ #### connect(options)
354
346
 
355
347
  Connect to wallet and get addresses for configured AddressTypes.
356
348
 
349
+ **Parameters:**
350
+ - `options: AuthOptions` (required) - Authentication options
351
+ - `provider: "google" | "apple" | "jwt" | "phantom" | "injected"` (required) - Authentication provider to use
352
+ - `jwtToken?: string` (optional) - JWT token (required when `provider` is "jwt")
353
+ - `customAuthData?: Record<string, any>` (optional) - Custom authentication data
354
+
357
355
  ```typescript
358
- const result = await sdk.connect();
359
- // Returns: { walletId?: string, addresses: WalletAddress[] }
356
+ // Connect with injected provider
357
+ const result = await sdk.connect({ provider: "injected" });
358
+
359
+ // Connect with Phantom authentication
360
+ const result = await sdk.connect({ provider: "phantom" });
361
+
362
+ // Connect with Google authentication
363
+ const result = await sdk.connect({ provider: "google" });
364
+
365
+ // Returns: { addresses: WalletAddress[], status: "pending" | "completed", providerType: "embedded" | "injected" }
360
366
  // addresses only includes types from addressTypes config
361
367
  ```
362
368
 
@@ -385,15 +391,6 @@ Check if SDK is connected to a wallet.
385
391
  const connected = sdk.isConnected();
386
392
  ```
387
393
 
388
- #### getWalletId()
389
-
390
- Get the wallet ID (embedded wallets only).
391
-
392
- ```typescript
393
- const walletId = sdk.getWalletId();
394
- // Returns string for embedded wallets, null for injected
395
- ```
396
-
397
394
  ### Solana Chain Methods
398
395
 
399
396
  #### signMessage(message)
@@ -590,6 +587,106 @@ Attempt auto-connection using existing session. Should be called after setting u
590
587
  await sdk.autoConnect();
591
588
  ```
592
589
 
590
+ ### Event Handlers
591
+
592
+ The SDK provides typed event handlers that allow you to listen for connection state changes. This is especially useful for `autoConnect()` flows where you need to track the connection result.
593
+
594
+ #### Available Events
595
+
596
+ ```typescript
597
+ import { BrowserSDK } from '@phantom/browser-sdk';
598
+ import type {
599
+ ConnectEventData,
600
+ ConnectStartEventData,
601
+ ConnectErrorEventData,
602
+ DisconnectEventData
603
+ } from '@phantom/browser-sdk';
604
+
605
+ const sdk = new BrowserSDK({
606
+ providerType: 'embedded',
607
+ appId: 'your-app-id',
608
+ addressTypes: [AddressType.solana],
609
+ });
610
+
611
+ // 1. connect_start - Fired when connection starts
612
+ sdk.on('connect_start', (data: ConnectStartEventData) => {
613
+ console.log('Connection starting:', data.source); // "auto-connect" | "manual-connect"
614
+ console.log('Auth options:', data.authOptions?.provider); // "google" | "apple" | etc.
615
+ });
616
+
617
+ // 2. connect - Fired when connection succeeds (includes full ConnectResult)
618
+ sdk.on('connect', (data: ConnectEventData) => {
619
+ console.log('Connected successfully!');
620
+ console.log('Provider type:', data.providerType); // "embedded" | "injected"
621
+ console.log('Wallet ID:', data.walletId); // only for embedded providers
622
+ console.log('Addresses:', data.addresses); // WalletAddress[]
623
+ console.log('Status:', data.status); // "pending" | "completed"
624
+ console.log('Source:', data.source); // "auto-connect" | "manual-connect" | "manual-existing" | "existing-session" | "manual"
625
+ });
626
+
627
+ // 3. connect_error - Fired when connection fails
628
+ sdk.on('connect_error', (data: ConnectErrorEventData) => {
629
+ console.error('Connection failed:', data.error);
630
+ console.log('Source:', data.source); // "auto-connect" | "manual-connect"
631
+ });
632
+
633
+ // 4. disconnect - Fired when disconnected
634
+ sdk.on('disconnect', (data: DisconnectEventData) => {
635
+ console.log('Disconnected from wallet');
636
+ console.log('Source:', data.source); // "manual"
637
+ });
638
+
639
+ // 5. error - General error handler
640
+ sdk.on('error', (error: unknown) => {
641
+ console.error('SDK error:', error);
642
+ });
643
+
644
+ // Don't forget to remove listeners when done
645
+ sdk.off('connect', handleConnect);
646
+ ```
647
+
648
+ #### Event Types
649
+
650
+ | Event | Payload Type | When Fired | Key Data |
651
+ |-------|-------------|------------|----------|
652
+ | `connect_start` | `ConnectStartEventData` | Connection initiated | `source`, `authOptions` |
653
+ | `connect` | `ConnectEventData` | Connection successful | `providerType`, `addresses`, `status`, `source`, `user`|
654
+ | `connect_error` | `ConnectErrorEventData` | Connection failed | `error`, `source` |
655
+ | `disconnect` | `DisconnectEventData` | Disconnected | `source` |
656
+ | `error` | `unknown` | General SDK errors | Error details |
657
+
658
+ #### Using Events with autoConnect()
659
+
660
+ Event handlers are especially useful with `autoConnect()` since it doesn't return a value:
661
+
662
+ ```typescript
663
+ const sdk = new BrowserSDK({
664
+ providerType: 'embedded',
665
+ appId: 'your-app-id',
666
+ addressTypes: [AddressType.solana],
667
+ autoConnect: true,
668
+ });
669
+
670
+ // Set up event listeners BEFORE autoConnect
671
+ sdk.on('connect', (data: ConnectEventData) => {
672
+ console.log('Auto-connected successfully!');
673
+ console.log('Provider type:', data.providerType);
674
+ console.log('Addresses:', data.addresses);
675
+
676
+ // Update your UI state here
677
+ updateUIWithAddresses(data.addresses);
678
+ });
679
+
680
+ sdk.on('connect_error', (data: ConnectErrorEventData) => {
681
+ console.log('Auto-connect failed:', data.error);
682
+ // Show connect button to user
683
+ showConnectButton();
684
+ });
685
+
686
+ // Auto-connect will trigger events
687
+ await sdk.autoConnect();
688
+ ```
689
+
593
690
  ### Auto-Confirm Methods (Injected Provider Only)
594
691
 
595
692
  The SDK provides auto-confirm functionality that allows automatic transaction confirmation for specified chains. This feature is only available when using the injected provider (Phantom browser extension).
@@ -748,7 +845,7 @@ import { BrowserSDK, DebugLevel } from "@phantom/browser-sdk";
748
845
 
749
846
  const sdk = new BrowserSDK({
750
847
  providerType: "embedded",
751
- // ... other config
848
+ appId: "your-app-id",
752
849
  });
753
850
 
754
851
  // Store debug messages
@@ -815,10 +912,9 @@ import { BrowserSDK, AddressType } from "@phantom/browser-sdk";
815
912
  const sdk = new BrowserSDK({
816
913
  providerType: "injected",
817
914
  addressTypes: [AddressType.solana],
818
- solanaProvider: "web3js",
819
915
  });
820
916
 
821
- await sdk.connect();
917
+ await sdk.connect({ provider: "injected" });
822
918
 
823
919
  // Get recent blockhash
824
920
  const connection = new Connection("https://api.mainnet-beta.solana.com");
@@ -869,10 +965,9 @@ import { BrowserSDK, AddressType } from "@phantom/browser-sdk";
869
965
  const sdk = new BrowserSDK({
870
966
  providerType: "injected",
871
967
  addressTypes: [AddressType.solana],
872
- solanaProvider: "kit",
873
968
  });
874
969
 
875
- await sdk.connect();
970
+ await sdk.connect({ provider: "injected" });
876
971
 
877
972
  // Create transaction with @solana/kit
878
973
  const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
@@ -902,7 +997,7 @@ const sdk = new BrowserSDK({
902
997
  addressTypes: [AddressType.ethereum],
903
998
  });
904
999
 
905
- await sdk.connect();
1000
+ await sdk.connect({ provider: "injected" });
906
1001
 
907
1002
  // Simple ETH transfer
908
1003
  const result = await sdk.ethereum.sendTransaction({
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { EmbeddedProviderConfig, AuthOptions, ConnectResult, WalletAddress, EmbeddedProviderEvent, EventCallback } from '@phantom/embedded-provider-core';
2
- export { AuthOptions, ConnectResult, SignAndSendTransactionParams, SignMessageParams, SignMessageResult, SignedTransaction, WalletAddress } from '@phantom/embedded-provider-core';
3
- import { ISolanaChain, IEthereumChain } from '@phantom/chains';
4
- export { EthTransactionRequest, IEthereumChain, ISolanaChain } from '@phantom/chains';
2
+ export { AuthOptions, ConnectErrorEventData, ConnectEventData, ConnectResult, ConnectStartEventData, DisconnectEventData, EmbeddedProviderEvent, EmbeddedProviderEventMap, EventCallback, SignAndSendTransactionParams, SignMessageParams, SignMessageResult, SignedTransaction, WalletAddress } from '@phantom/embedded-provider-core';
3
+ import { ISolanaChain, IEthereumChain } from '@phantom/chain-interfaces';
4
+ export { EthTransactionRequest, IEthereumChain, ISolanaChain } from '@phantom/chain-interfaces';
5
5
  import { AddressType } from '@phantom/client';
6
6
  export { AddressType } from '@phantom/client';
7
7
  import { AutoConfirmEnableParams, AutoConfirmResult, AutoConfirmSupportedChainsResult } from '@phantom/browser-injected-sdk/auto-confirm';
@@ -52,18 +52,69 @@ declare const DebugCategory: {
52
52
  readonly SESSION: "Session";
53
53
  };
54
54
 
55
+ /**
56
+ * Phantom extension app.login API types
57
+ */
58
+ interface PhantomAppLoginOptions {
59
+ publicKey: string;
60
+ appId: string;
61
+ sessionId: string;
62
+ }
63
+ interface PhantomAppLoginResult {
64
+ walletId: string;
65
+ organizationId: string;
66
+ accountDerivationIndex?: number;
67
+ expiresInMs?: number;
68
+ authUserId?: string;
69
+ }
70
+ interface PhantomApp {
71
+ login(options: PhantomAppLoginOptions): Promise<PhantomAppLoginResult>;
72
+ features(): Promise<{
73
+ features: string[];
74
+ }>;
75
+ getUser(): Promise<{
76
+ authUserId?: string;
77
+ } | undefined>;
78
+ }
79
+ declare global {
80
+ interface Window {
81
+ phantom?: {
82
+ solana?: unknown;
83
+ ethereum?: unknown;
84
+ app?: PhantomApp;
85
+ } | undefined;
86
+ }
87
+ }
88
+
89
+ interface InjectedProviderConfig {
90
+ addressTypes: AddressType[];
91
+ }
92
+
55
93
  interface DebugConfig {
56
94
  enabled?: boolean;
57
95
  level?: DebugLevel;
58
96
  callback?: DebugCallback;
59
97
  }
60
- interface BrowserSDKConfig extends Partial<EmbeddedProviderConfig> {
61
- providerType: "injected" | "embedded" | (string & Record<never, never>);
62
- addressTypes: [AddressType, ...AddressType[]];
63
- apiBaseUrl?: string;
64
- appId?: string;
65
- embeddedWalletType?: "app-wallet" | "user-wallet" | (string & Record<never, never>);
98
+ type BrowserSDKConfig = Prettify<(ExtendedEmbeddedProviderConfig | ExtendedInjectedProviderConfig) & {
66
99
  autoConnect?: boolean;
100
+ }>;
101
+ type Prettify<T> = {
102
+ [K in keyof T]: T[K];
103
+ } & {};
104
+ interface ExtendedEmbeddedProviderConfig extends Omit<EmbeddedProviderConfig, "authOptions" | "apiBaseUrl" | "embeddedWalletType"> {
105
+ providerType: "embedded";
106
+ apiBaseUrl?: string;
107
+ embeddedWalletType?: "app-wallet" | "user-wallet";
108
+ authOptions?: {
109
+ authUrl?: string;
110
+ redirectUrl?: string;
111
+ };
112
+ }
113
+ interface ExtendedInjectedProviderConfig extends InjectedProviderConfig {
114
+ providerType: "injected";
115
+ appId?: never;
116
+ authOptions?: never;
117
+ embeddedWalletType?: never;
67
118
  }
68
119
 
69
120
  interface Provider {
@@ -71,6 +122,7 @@ interface Provider {
71
122
  disconnect(): Promise<void>;
72
123
  getAddresses(): WalletAddress[];
73
124
  isConnected(): boolean;
125
+ autoConnect(): Promise<void>;
74
126
  solana: ISolanaChain;
75
127
  ethereum: IEthereumChain;
76
128
  }
@@ -79,9 +131,6 @@ interface ProviderPreference {
79
131
  type: "injected" | "embedded";
80
132
  embeddedWalletType?: "app-wallet" | "user-wallet";
81
133
  }
82
- interface SwitchProviderOptions {
83
- embeddedWalletType?: "app-wallet" | "user-wallet" | (string & Record<never, never>);
84
- }
85
134
 
86
135
  /**
87
136
  * Browser SDK with chain-specific API
@@ -110,15 +159,11 @@ declare class BrowserSDK {
110
159
  /**
111
160
  * Connect to the wallet
112
161
  */
113
- connect(options?: AuthOptions): Promise<ConnectResult>;
162
+ connect(options: AuthOptions): Promise<ConnectResult>;
114
163
  /**
115
164
  * Disconnect from the wallet
116
165
  */
117
166
  disconnect(): Promise<void>;
118
- /**
119
- * Switch between provider types (injected vs embedded)
120
- */
121
- switchProvider(type: "injected" | "embedded", options?: SwitchProviderOptions): Promise<void>;
122
167
  /**
123
168
  * Check if the SDK is connected to a wallet
124
169
  */
@@ -131,10 +176,6 @@ declare class BrowserSDK {
131
176
  * Get information about the current provider
132
177
  */
133
178
  getCurrentProviderInfo(): ProviderPreference | null;
134
- /**
135
- * Get the wallet ID (for embedded wallets)
136
- */
137
- getWalletId(): string | null;
138
179
  /**
139
180
  * Check if Phantom extension is installed
140
181
  */
@@ -152,7 +193,7 @@ declare class BrowserSDK {
152
193
  /**
153
194
  * Attempt auto-connection using existing session
154
195
  * Should be called after setting up event listeners
155
- * Only works with embedded providers
196
+ * Tries embedded provider first, then injected provider as fallback
156
197
  */
157
198
  autoConnect(): Promise<void>;
158
199
  /**
@@ -205,18 +246,13 @@ declare class BrowserSDK {
205
246
  getSupportedAutoConfirmChains(): Promise<AutoConfirmSupportedChainsResult>;
206
247
  }
207
248
 
208
- /**
209
- * Constants used throughout the browser SDK
210
- */
211
- declare const DEFAULT_AUTH_URL = "https://connect.phantom.app";
212
- declare const DEFAULT_WALLET_API_URL = "https://api.phantom.app/v1/wallets";
213
-
214
249
  /**
215
250
  * Browser detection utility to identify browser name and version
216
251
  */
217
252
  interface BrowserInfo {
218
253
  name: string;
219
254
  version: string;
255
+ userAgent: string;
220
256
  }
221
257
  /**
222
258
  * Parse browser information from a user agent string
@@ -237,6 +273,18 @@ declare function getPlatformName(): string;
237
273
  * Format: "Chrome 120.0" or "Firefox 119.0"
238
274
  */
239
275
  declare function getBrowserDisplayName(): string;
276
+ /**
277
+ * Detect if the current device is a mobile device
278
+ * Checks user agent for mobile indicators and screen size
279
+ */
280
+ declare function isMobileDevice(): boolean;
281
+
282
+ /**
283
+ * Generates a deeplink URL to open the current page in Phantom mobile app
284
+ * @param ref Optional referrer parameter
285
+ * @returns Phantom mobile app deeplink URL
286
+ */
287
+ declare function getDeeplinkToPhantom(ref?: string): string;
240
288
 
241
289
  /**
242
290
  * Wait for Phantom extension to be available with retry logic
@@ -256,4 +304,26 @@ declare function getBrowserDisplayName(): string;
256
304
  */
257
305
  declare function waitForPhantomExtension(timeoutMs?: number): Promise<boolean>;
258
306
 
259
- export { BrowserInfo, BrowserSDK, BrowserSDKConfig, DEFAULT_AUTH_URL, DEFAULT_WALLET_API_URL, DebugCallback, DebugCategory, DebugConfig, DebugLevel, DebugMessage, Provider, debug, detectBrowser, getBrowserDisplayName, getPlatformName, parseBrowserFromUserAgent, waitForPhantomExtension };
307
+ /**
308
+ * Check if Phantom Login is available
309
+ *
310
+ * This function checks if:
311
+ * 1. The Phantom extension is installed
312
+ * 2. The extension supports the phantom_login feature
313
+ *
314
+ * @param timeoutMs - Maximum time to wait for extension in milliseconds (default: 3000)
315
+ * @returns Promise<boolean> - true if Phantom Login is available, false otherwise
316
+ *
317
+ * Usage:
318
+ * ```typescript
319
+ * const isAvailable = await isPhantomLoginAvailable();
320
+ * if (isAvailable) {
321
+ * console.log("Phantom Login is available!");
322
+ * } else {
323
+ * console.log("Phantom Login is not available");
324
+ * }
325
+ * ```
326
+ */
327
+ declare function isPhantomLoginAvailable(timeoutMs?: number): Promise<boolean>;
328
+
329
+ export { BrowserInfo, BrowserSDK, BrowserSDKConfig, DebugCallback, DebugCategory, DebugConfig, DebugLevel, DebugMessage, Provider, debug, detectBrowser, getBrowserDisplayName, getDeeplinkToPhantom, getPlatformName, isMobileDevice, isPhantomLoginAvailable, parseBrowserFromUserAgent, waitForPhantomExtension };