@pooflabs/web 0.0.26 → 0.0.27

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.
@@ -1,4 +1,4 @@
1
- export { PhantomWalletProvider, PhantomWalletConfig, } from "./providers/phantom-wallet-provider";
1
+ export { PhantomWalletProvider, PhantomWalletConfig, PhantomProvider, } from "./providers/phantom-wallet-provider";
2
2
  export { PrivyWalletProvider } from "./providers/privy-wallet-provider";
3
3
  export { MockAuthProvider, DEFAULT_TEST_ADDRESS, } from "./providers/mock-auth-provider";
4
4
  export { OffchainAuthProvider, OffchainAuthProviderConfig, } from "./providers/offchain-auth-provider";
@@ -1,8 +1,10 @@
1
1
  import type { EVMTransaction, SolTransaction, TransactionResult, User, AuthProvider, SetOptions } from '@pooflabs/core';
2
2
  import { Transaction, VersionedTransaction } from '@solana/web3.js';
3
+ export type PhantomProvider = 'injected' | 'google' | 'apple' | 'deeplink';
3
4
  export interface PhantomWalletConfig {
4
5
  appId?: string;
5
- providers?: Array<'injected' | 'google' | 'apple' | 'deeplink'>;
6
+ /** Providers to use for authentication. Accepts string[] for convenience (e.g., ["injected"]) */
7
+ providers?: PhantomProvider[] | string[];
6
8
  redirectUrl?: string;
7
9
  autoConnect?: boolean;
8
10
  }
@@ -11,6 +13,7 @@ export declare class PhantomWalletProvider implements AuthProvider {
11
13
  private networkUrl;
12
14
  private sdk;
13
15
  private config;
16
+ private resolvedProviders;
14
17
  constructor(networkUrl?: string | null, config?: PhantomWalletConfig);
15
18
  private init;
16
19
  private getSDK;
@@ -22,6 +25,12 @@ export declare class PhantomWalletProvider implements AuthProvider {
22
25
  * Get the injected Phantom provider for direct wallet operations
23
26
  */
24
27
  private getInjectedProvider;
28
+ /**
29
+ * Connect to the wallet using the configured providers.
30
+ * If only 'injected' is configured, connects directly to the injected provider.
31
+ * If multiple providers are configured, lets the SDK show the provider selection modal.
32
+ */
33
+ private connectWithProviders;
25
34
  /**
26
35
  * Ensures the wallet is connected and returns the SDK
27
36
  * This method will attempt to connect if not already connected.
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export { subscribe } from "@pooflabs/core";
6
6
  export * from "@pooflabs/core";
7
7
  export { useAuth } from "./auth/hooks/useAuth";
8
8
  export { getIdToken } from "./utils";
9
- export { PhantomWalletProvider, PhantomWalletConfig, } from "./auth/providers/phantom-wallet-provider";
9
+ export { PhantomWalletProvider, PhantomWalletConfig, PhantomProvider, } from "./auth/providers/phantom-wallet-provider";
10
10
  export { PrivyWalletProvider } from "./auth/providers/privy-wallet-provider";
11
11
  export { MockAuthProvider, DEFAULT_TEST_ADDRESS, } from "./auth/providers/mock-auth-provider";
12
12
  export { OffchainAuthProvider, OffchainAuthProviderConfig, } from "./auth/providers/offchain-auth-provider";
package/dist/index.esm.js CHANGED
@@ -27425,9 +27425,11 @@ var BrowserSDK = class {
27425
27425
  }
27426
27426
  };
27427
27427
 
27428
+ const VALID_PROVIDERS = ['injected', 'google', 'apple', 'deeplink'];
27428
27429
  class PhantomWalletProvider {
27429
27430
  constructor(networkUrl = null, config = {}) {
27430
27431
  this.sdk = null;
27432
+ this.resolvedProviders = ['injected'];
27431
27433
  this.networkUrl = networkUrl;
27432
27434
  this.config = config;
27433
27435
  this.initialized = this.init();
@@ -27438,10 +27440,17 @@ class PhantomWalletProvider {
27438
27440
  return;
27439
27441
  try {
27440
27442
  // Determine providers based on config
27441
- // If appId is provided, use all providers; otherwise just 'injected'
27443
+ // If providers are explicitly specified (and not empty), use them
27444
+ // If appId is provided (but no providers), use all providers
27445
+ // Otherwise, default to just 'injected'
27442
27446
  let providers;
27443
- if (this.config.providers) {
27444
- providers = this.config.providers;
27447
+ if (this.config.providers && this.config.providers.length > 0) {
27448
+ // Filter to only valid providers (handles string[] input gracefully)
27449
+ providers = this.config.providers.filter((p) => VALID_PROVIDERS.includes(p));
27450
+ // If no valid providers after filtering, default to 'injected'
27451
+ if (providers.length === 0) {
27452
+ providers = ['injected'];
27453
+ }
27445
27454
  }
27446
27455
  else if (this.config.appId) {
27447
27456
  providers = ['injected', 'google', 'apple', 'deeplink'];
@@ -27449,6 +27458,8 @@ class PhantomWalletProvider {
27449
27458
  else {
27450
27459
  providers = ['injected'];
27451
27460
  }
27461
+ // Store the resolved providers for use in connect calls
27462
+ this.resolvedProviders = providers;
27452
27463
  // Build SDK config
27453
27464
  const sdkConfig = {
27454
27465
  providers,
@@ -27496,6 +27507,23 @@ class PhantomWalletProvider {
27496
27507
  }
27497
27508
  return window.phantom.solana;
27498
27509
  }
27510
+ /**
27511
+ * Connect to the wallet using the configured providers.
27512
+ * If only 'injected' is configured, connects directly to the injected provider.
27513
+ * If multiple providers are configured, lets the SDK show the provider selection modal.
27514
+ */
27515
+ async connectWithProviders() {
27516
+ const sdk = await this.getSDK();
27517
+ // If only 'injected' is configured, connect directly to avoid unnecessary modal
27518
+ if (this.resolvedProviders.length === 1 && this.resolvedProviders[0] === 'injected') {
27519
+ return await sdk.connect({ provider: 'injected' });
27520
+ }
27521
+ // For multiple providers, default to 'injected' if available, otherwise use first provider
27522
+ const defaultProvider = this.resolvedProviders.includes('injected')
27523
+ ? 'injected'
27524
+ : this.resolvedProviders[0];
27525
+ return await sdk.connect({ provider: defaultProvider });
27526
+ }
27499
27527
  /**
27500
27528
  * Ensures the wallet is connected and returns the SDK
27501
27529
  * This method will attempt to connect if not already connected.
@@ -27505,8 +27533,8 @@ class PhantomWalletProvider {
27505
27533
  const sdk = await this.getSDK();
27506
27534
  // Check if wallet is already connected
27507
27535
  if (!sdk.isConnected()) {
27508
- // Connect to Phantom wallet
27509
- const response = await sdk.connect({ provider: 'injected' });
27536
+ // Connect to Phantom wallet using configured providers
27537
+ const response = await this.connectWithProviders();
27510
27538
  if (response.addresses.length === 0) {
27511
27539
  throw new Error('No addresses returned from Phantom wallet');
27512
27540
  }
@@ -27548,8 +27576,8 @@ class PhantomWalletProvider {
27548
27576
  await this.initialized;
27549
27577
  try {
27550
27578
  const sdk = await this.getSDK();
27551
- // Connect to Phantom wallet
27552
- const response = await sdk.connect({ provider: 'injected' });
27579
+ // Connect to Phantom wallet using configured providers
27580
+ const response = await this.connectWithProviders();
27553
27581
  if (response.addresses.length === 0) {
27554
27582
  throw new Error('No addresses returned from Phantom wallet');
27555
27583
  }
@@ -27791,7 +27819,7 @@ class PhantomWalletProvider {
27791
27819
  }
27792
27820
  // Verify wallet is connected and matches session
27793
27821
  if (!sdk.isConnected()) {
27794
- const response = await sdk.connect({ provider: 'injected' });
27822
+ const response = await this.connectWithProviders();
27795
27823
  if (response.addresses.length === 0) {
27796
27824
  throw new Error('No addresses returned from Phantom wallet');
27797
27825
  }
@@ -45328,10 +45356,6 @@ class OffchainAuthProvider {
45328
45356
  this.modalContainer = null;
45329
45357
  this.wrappedProvider = wrappedProvider;
45330
45358
  this.config = config;
45331
- // Signal to API layer that this client supports offchain transaction signing
45332
- if (typeof window !== "undefined") {
45333
- window.TAROBASE_SUPPORTS_OFFCHAIN_SIGNING = true;
45334
- }
45335
45359
  }
45336
45360
  // ============ Delegated Methods ============
45337
45361
  async login() {