@pooflabs/web 0.0.47 → 0.0.49

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.
@@ -13031,138 +13031,7 @@ function requireBuffer () {
13031
13031
 
13032
13032
  var bufferExports = requireBuffer();
13033
13033
 
13034
- const VALID_PROVIDERS = ['injected', 'google', 'apple', 'deeplink'];
13035
- // Storage key for preserving the original path before OAuth redirect
13036
- const PHANTOM_ORIGINAL_PATH_KEY = 'phantom_oauth_original_path';
13037
- /**
13038
- * Check if the current URL contains Phantom OAuth callback parameters.
13039
- * Phantom uses various params like phantom_encryption_public_key, data, nonce for deeplink callbacks,
13040
- * and wallet_id, session_id for social login callbacks.
13041
- */
13042
- function hasPhantomOAuthParams() {
13043
- if (typeof window === 'undefined')
13044
- return false;
13045
- const url = new URL(window.location.href);
13046
- const params = url.searchParams;
13047
- const hash = url.hash;
13048
- // Check for Phantom OAuth callback params in query string
13049
- // These are common params used by Phantom for OAuth callbacks
13050
- const oauthParams = [
13051
- 'phantom_encryption_public_key',
13052
- 'data',
13053
- 'nonce',
13054
- 'wallet_id',
13055
- 'session_id',
13056
- 'errorCode',
13057
- 'errorMessage'
13058
- ];
13059
- for (const param of oauthParams) {
13060
- if (params.has(param)) {
13061
- return true;
13062
- }
13063
- }
13064
- // Also check hash fragment for encoded auth data
13065
- if (hash && (hash.includes('phantom') || hash.includes('wallet_id') || hash.includes('session_id'))) {
13066
- return true;
13067
- }
13068
- return false;
13069
- }
13070
- /**
13071
- * Store the current path before OAuth redirect so we can restore it after.
13072
- */
13073
- function storeOriginalPath() {
13074
- if (typeof window === 'undefined' || typeof sessionStorage === 'undefined')
13075
- return;
13076
- const currentPath = window.location.pathname + window.location.search;
13077
- // Only store if not already on the root path
13078
- if (currentPath !== '/' && currentPath !== '') {
13079
- try {
13080
- sessionStorage.setItem(PHANTOM_ORIGINAL_PATH_KEY, currentPath);
13081
- }
13082
- catch (_a) {
13083
- // sessionStorage might not be available
13084
- }
13085
- }
13086
- }
13087
- /**
13088
- * Get and clear the stored original path after OAuth callback.
13089
- * Returns the path to redirect to, or null if no redirect needed.
13090
- */
13091
- function getAndClearOriginalPath() {
13092
- if (typeof window === 'undefined' || typeof sessionStorage === 'undefined')
13093
- return null;
13094
- try {
13095
- const originalPath = sessionStorage.getItem(PHANTOM_ORIGINAL_PATH_KEY);
13096
- if (originalPath) {
13097
- sessionStorage.removeItem(PHANTOM_ORIGINAL_PATH_KEY);
13098
- // Only return if we're not already on that path
13099
- const currentPath = window.location.pathname + window.location.search;
13100
- if (originalPath !== currentPath) {
13101
- return originalPath;
13102
- }
13103
- }
13104
- }
13105
- catch (_a) {
13106
- // sessionStorage might not be available
13107
- }
13108
- return null;
13109
- }
13110
- /**
13111
- * Remove OAuth callback parameters from the current URL without a full page reload.
13112
- * Uses history.replaceState to update the URL in place.
13113
- */
13114
- function cleanupOAuthParams() {
13115
- if (typeof window === 'undefined')
13116
- return;
13117
- const url = new URL(window.location.href);
13118
- const paramsToRemove = [
13119
- 'response_type',
13120
- 'phantom_encryption_public_key',
13121
- 'data',
13122
- 'nonce',
13123
- 'wallet_id',
13124
- 'session_id',
13125
- 'organization_id',
13126
- 'selected_account_index',
13127
- 'expires_in_ms',
13128
- 'auth_user_id',
13129
- 'errorCode',
13130
- 'errorMessage'
13131
- ];
13132
- let hasChanges = false;
13133
- for (const param of paramsToRemove) {
13134
- if (url.searchParams.has(param)) {
13135
- url.searchParams.delete(param);
13136
- hasChanges = true;
13137
- }
13138
- }
13139
- if (hasChanges) {
13140
- // Use replaceState to update URL without page reload
13141
- window.history.replaceState({}, '', url.pathname + url.search + url.hash);
13142
- }
13143
- }
13144
- /**
13145
- * Get the effective redirect URL for Phantom OAuth.
13146
- * If OAuth callback params are detected in the current URL, use the current URL
13147
- * to ensure the SDK can process them. Otherwise, use the configured redirect URL
13148
- * or fall back to the origin (base URL without path).
13149
- */
13150
- function getEffectiveRedirectUrl(configuredRedirectUrl) {
13151
- if (typeof window === 'undefined')
13152
- return '';
13153
- // If we detect OAuth params in current URL, use the current URL
13154
- // This ensures the SDK can process the callback regardless of path
13155
- if (hasPhantomOAuthParams()) {
13156
- return window.location.href;
13157
- }
13158
- // If explicitly configured, use that
13159
- if (configuredRedirectUrl) {
13160
- return configuredRedirectUrl;
13161
- }
13162
- // Default to origin (base URL) - this is safer than using the full href
13163
- // because OAuth callbacks are typically configured for specific URLs
13164
- return window.location.origin;
13165
- }
13034
+ const VALID_PROVIDERS = ['injected', 'google', 'apple', 'deeplink', 'phantom'];
13166
13035
  // Dynamically import React and Phantom SDK - only when needed
13167
13036
  let React$1;
13168
13037
  let ReactDOM$1;
@@ -13183,7 +13052,7 @@ async function loadDependencies() {
13183
13052
  const [reactModule, reactDomModule, phantomModule] = await Promise.all([
13184
13053
  import('react'),
13185
13054
  import('react-dom/client'),
13186
- import('./index-R_GFZpLo.esm.js')
13055
+ import('./index-B-RIRJEL.esm.js')
13187
13056
  ]);
13188
13057
  // Extract default export from ESM module namespace
13189
13058
  // Dynamic import() returns { default: Module, ...exports }, not the module directly
@@ -13204,7 +13073,7 @@ class PhantomWalletProvider {
13204
13073
  this.loginInProgress = false;
13205
13074
  this.autoLoginInProgress = false;
13206
13075
  this.initPromise = null;
13207
- /** Callback to swap to a Privy provider when the user clicks "Log in with Privy instead" */
13076
+ /** Callback to swap to a Privy provider when the user clicks "Log in with email" */
13208
13077
  this.onSwitchToPrivy = null;
13209
13078
  this.networkUrl = networkUrl;
13210
13079
  this.config = config;
@@ -13244,14 +13113,18 @@ class PhantomWalletProvider {
13244
13113
  const configProviders = this.config.providers;
13245
13114
  this.resolvedProviders = configProviders.filter((p) => VALID_PROVIDERS.includes(p));
13246
13115
  if (this.resolvedProviders.length === 0) {
13247
- this.resolvedProviders = ['injected', 'deeplink'];
13116
+ this.resolvedProviders = ['injected'];
13248
13117
  }
13249
13118
  }
13250
13119
  else if (this.config.appId) {
13251
13120
  this.resolvedProviders = ['injected', 'google', 'apple', 'deeplink'];
13252
13121
  }
13253
13122
  else {
13254
- this.resolvedProviders = ['injected', 'deeplink'];
13123
+ this.resolvedProviders = ['injected'];
13124
+ }
13125
+ // When Privy handles social logins, strip them from Phantom
13126
+ if (this.config.enablePrivyFallback) {
13127
+ this.resolvedProviders = this.resolvedProviders.filter(p => p !== 'google' && p !== 'apple');
13255
13128
  }
13256
13129
  }
13257
13130
  initialize() {
@@ -13335,17 +13208,6 @@ class PhantomWalletProvider {
13335
13208
  if (existingSession && existingSession.address === publicKey) {
13336
13209
  // Already have a valid session, just set user
13337
13210
  setCurrentUser({ provider: that, address: publicKey });
13338
- // If this was an OAuth callback, clean up the URL
13339
- if (hasPhantomOAuthParams()) {
13340
- const originalPath = getAndClearOriginalPath();
13341
- if (originalPath) {
13342
- window.location.replace(originalPath);
13343
- }
13344
- else {
13345
- // No stored path (e.g., user was on root), clean up OAuth params in place
13346
- cleanupOAuthParams();
13347
- }
13348
- }
13349
13211
  return;
13350
13212
  }
13351
13213
  // No valid session - try to create one automatically
@@ -13361,23 +13223,15 @@ class PhantomWalletProvider {
13361
13223
  const signature = bufferExports.Buffer.from(signatureBytes).toString('base64');
13362
13224
  const createSessionResult = await createSessionWithSignature(publicKey, messageText, signature);
13363
13225
  await WebSessionManager.storeSession(publicKey, createSessionResult.accessToken, createSessionResult.idToken, createSessionResult.refreshToken);
13364
- setCurrentUser({ provider: that, address: publicKey });
13365
- // If this was an OAuth callback, clean up the URL
13366
- if (hasPhantomOAuthParams()) {
13367
- const originalPath = getAndClearOriginalPath();
13368
- if (originalPath) {
13369
- window.location.replace(originalPath);
13370
- }
13371
- else {
13372
- // No stored path (e.g., user was on root), clean up OAuth params in place
13373
- cleanupOAuthParams();
13374
- }
13226
+ // Mark auth method so clearIncompatibleSession() doesn't wipe this session
13227
+ try {
13228
+ localStorage.setItem('tarobase_last_auth_method', 'phantom');
13375
13229
  }
13230
+ catch (_b) { }
13231
+ setCurrentUser({ provider: that, address: publicKey });
13376
13232
  }
13377
13233
  catch (error) {
13378
13234
  // User rejected signing or other error - disconnect fully
13379
- // Clear stored path since login failed
13380
- getAndClearOriginalPath();
13381
13235
  try {
13382
13236
  await disconnect();
13383
13237
  }
@@ -13458,6 +13312,11 @@ class PhantomWalletProvider {
13458
13312
  const signature = bufferExports.Buffer.from(signatureBytes).toString('base64');
13459
13313
  const createSessionResult = await createSessionWithSignature(publicKey, messageText, signature);
13460
13314
  await WebSessionManager.storeSession(publicKey, createSessionResult.accessToken, createSessionResult.idToken, createSessionResult.refreshToken);
13315
+ // Mark auth method so clearIncompatibleSession() doesn't wipe this session
13316
+ try {
13317
+ localStorage.setItem('tarobase_last_auth_method', 'phantom');
13318
+ }
13319
+ catch (_b) { }
13461
13320
  const user = { provider: that, address: publicKey };
13462
13321
  setCurrentUser(user);
13463
13322
  that.pendingLogin.resolve(user);
@@ -13480,33 +13339,79 @@ class PhantomWalletProvider {
13480
13339
  };
13481
13340
  handleConnectionSuccess();
13482
13341
  }, [phantom === null || phantom === void 0 ? void 0 : phantom.isConnected, phantom === null || phantom === void 0 ? void 0 : phantom.addresses, solana, solana === null || solana === void 0 ? void 0 : solana.connected, solanaHook.isAvailable]);
13483
- // Inject "Log in with Privy instead" button into the Phantom modal
13484
- // The Phantom modal renders plain divs with inline styles (no Shadow DOM, no portal):
13485
- // overlay (position:fixed, z-index:9999) > modal card (max-width:350px) > height wrapper > content
13342
+ // When enablePrivyFallback is true, enhance the Phantom modal:
13343
+ // 1. Auto-click "Other Wallets" to skip to the wallet list view
13344
+ // 2. Hide the "Other Wallets" header and back arrow
13345
+ // 3. Inject "Log in with email" button styled to match Phantom SDK buttons
13486
13346
  React$1.useEffect(() => {
13487
13347
  if (!that.config.enablePrivyFallback || !modal.isOpened) {
13488
13348
  return;
13489
13349
  }
13490
- let buttonContainer = null;
13491
- const injectButton = () => {
13492
- var _a;
13493
- if (buttonContainer)
13494
- return;
13495
- // Find the Phantom overlay within our own container (scoped to avoid false matches)
13496
- // The modal renders inline (not portaled), so it's inside our [data-phantom-provider] div
13350
+ let socialBtnContainer = null;
13351
+ let didAutoClick = false;
13352
+ const enhanceModal = () => {
13353
+ var _a, _b;
13497
13354
  const overlayEl = ((_a = that.containerElement) === null || _a === void 0 ? void 0 : _a.querySelector('div[style*="z-index"]'))
13498
13355
  || document.querySelector('div[style*="z-index: 9999"]');
13499
13356
  const modalCard = overlayEl === null || overlayEl === void 0 ? void 0 : overlayEl.firstElementChild;
13500
13357
  if (!modalCard)
13501
13358
  return;
13502
- buttonContainer = document.createElement('div');
13503
- buttonContainer.setAttribute('data-privy-fallback-btn', 'true');
13504
- buttonContainer.style.cssText = 'text-align:center;padding:12px 16px 16px;';
13359
+ // Auto-click "Other Wallets" button to jump to wallet list
13360
+ if (!didAutoClick) {
13361
+ const buttons = modalCard.querySelectorAll('button');
13362
+ for (const b of buttons) {
13363
+ if ((_b = b.textContent) === null || _b === void 0 ? void 0 : _b.includes('Other Wallets')) {
13364
+ didAutoClick = true;
13365
+ b.click();
13366
+ return; // Modal re-renders; observer fires again
13367
+ }
13368
+ }
13369
+ }
13370
+ const allDivs = modalCard.querySelectorAll('div');
13371
+ for (const div of allDivs) {
13372
+ const style = div.getAttribute('style') || '';
13373
+ if (style.includes('28px 32px 0') && style.includes('32px')) {
13374
+ const children = div.children;
13375
+ for (let i = 0; i < children.length; i++) {
13376
+ const child = children[i];
13377
+ const childStyle = child.getAttribute('style') || '';
13378
+ // Keep the close button (positioned right), hide everything else
13379
+ if (childStyle.includes('right:'))
13380
+ continue;
13381
+ child.style.display = 'none';
13382
+ }
13383
+ break;
13384
+ }
13385
+ }
13386
+ // Inject the email login button if not already present
13387
+ if (socialBtnContainer || modalCard.querySelector('[data-privy-fallback-btn]'))
13388
+ return;
13389
+ socialBtnContainer = document.createElement('div');
13390
+ socialBtnContainer.setAttribute('data-privy-fallback-btn', 'true');
13391
+ socialBtnContainer.style.cssText = 'padding:0 32px 16px;';
13505
13392
  const btn = document.createElement('button');
13506
- btn.textContent = 'Log in with Privy instead';
13507
- btn.style.cssText = 'background:none;border:none;color:#8B8B8B;font-size:13px;cursor:pointer;padding:8px 16px;text-decoration:underline;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;';
13508
- btn.addEventListener('mouseenter', () => { btn.style.color = '#FFFFFF'; });
13509
- btn.addEventListener('mouseleave', () => { btn.style.color = '#8B8B8B'; });
13393
+ btn.style.cssText = [
13394
+ 'display:flex',
13395
+ 'align-items:center',
13396
+ 'justify-content:center',
13397
+ 'width:100%',
13398
+ 'height:56px',
13399
+ 'padding:12px 16px',
13400
+ 'border:none',
13401
+ 'border-radius:16px',
13402
+ 'background-color:rgba(152,151,156,0.1)',
13403
+ 'color:#FFFFFF',
13404
+ 'font-family:"SF Pro Text",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif',
13405
+ 'font-size:14px',
13406
+ 'font-weight:600',
13407
+ 'line-height:17px',
13408
+ 'letter-spacing:-0.14px',
13409
+ 'cursor:pointer',
13410
+ 'transition:background-color 0.2s',
13411
+ ].join(';') + ';';
13412
+ btn.textContent = 'Log in with email';
13413
+ btn.addEventListener('mouseenter', () => { btn.style.backgroundColor = 'rgba(152,151,156,0.15)'; });
13414
+ btn.addEventListener('mouseleave', () => { btn.style.backgroundColor = 'rgba(152,151,156,0.1)'; });
13510
13415
  btn.addEventListener('click', async () => {
13511
13416
  // Clear loginInProgress BEFORE closing modal so the modal-close
13512
13417
  // handler doesn't race and reject pendingLogin with "User cancelled"
@@ -13521,7 +13426,6 @@ class PhantomWalletProvider {
13521
13426
  that.pendingLogin = null;
13522
13427
  }
13523
13428
  else if (that.pendingLogin) {
13524
- // User cancelled Privy login (returned null)
13525
13429
  that.pendingLogin.reject(new Error('User cancelled login'));
13526
13430
  that.pendingLogin = null;
13527
13431
  }
@@ -13534,18 +13438,18 @@ class PhantomWalletProvider {
13534
13438
  }
13535
13439
  }
13536
13440
  });
13537
- buttonContainer.appendChild(btn);
13538
- modalCard.appendChild(buttonContainer);
13441
+ socialBtnContainer.appendChild(btn);
13442
+ modalCard.appendChild(socialBtnContainer);
13539
13443
  };
13540
13444
  // Try immediately, then watch for DOM changes (modal may render async)
13541
- injectButton();
13542
- const observer = new MutationObserver(() => injectButton());
13445
+ enhanceModal();
13446
+ const observer = new MutationObserver(() => enhanceModal());
13543
13447
  observer.observe(document.body, { childList: true, subtree: true });
13544
13448
  return () => {
13545
13449
  observer.disconnect();
13546
- if (buttonContainer)
13547
- buttonContainer.remove();
13548
- buttonContainer = null;
13450
+ if (socialBtnContainer)
13451
+ socialBtnContainer.remove();
13452
+ socialBtnContainer = null;
13549
13453
  };
13550
13454
  }, [modal.isOpened]);
13551
13455
  return null; // Invisible component
@@ -13563,13 +13467,6 @@ class PhantomWalletProvider {
13563
13467
  if (that.config.appId) {
13564
13468
  config.appId = that.config.appId;
13565
13469
  }
13566
- // Set authOptions with redirectUrl for social login callback handling
13567
- // Use getEffectiveRedirectUrl to handle OAuth callbacks from any path
13568
- if (that.hasSocialProviders()) {
13569
- config.authOptions = {
13570
- redirectUrl: getEffectiveRedirectUrl(that.config.redirectUrl),
13571
- };
13572
- }
13573
13470
  return config;
13574
13471
  }, []);
13575
13472
  const theme = that.config.theme === 'light' ? lightTheme : darkTheme;
@@ -13656,8 +13553,8 @@ class PhantomWalletProvider {
13656
13553
  }
13657
13554
  /**
13658
13555
  * Login using the Phantom connect modal.
13659
- * Opens the native Phantom connect UI where users can choose their preferred login method
13660
- * (Google, Apple, Phantom, or browser extension).
13556
+ * When enablePrivyFallback is true, the modal is enhanced via React effect to
13557
+ * auto-skip to the wallet list and show a "Log in with email" button.
13661
13558
  */
13662
13559
  async login() {
13663
13560
  var _a, _b;
@@ -13684,11 +13581,6 @@ class PhantomWalletProvider {
13684
13581
  return new Promise((resolve, reject) => {
13685
13582
  this.pendingLogin = { resolve, reject };
13686
13583
  this.loginInProgress = true;
13687
- // Store current path before OAuth redirect (for social login providers)
13688
- // so we can redirect back after auth completes
13689
- if (this.hasSocialProviders()) {
13690
- storeOriginalPath();
13691
- }
13692
13584
  // Open the Phantom connect modal
13693
13585
  this.phantomMethods.openModal();
13694
13586
  // Safety timeout
@@ -32616,7 +32508,7 @@ const defaultPrivyConfig = {
32616
32508
  }
32617
32509
  },
32618
32510
  appearance: {
32619
- walletChainType: 'solana-only',
32511
+ walletChainType: 'solana-only'
32620
32512
  },
32621
32513
  externalWallets: { solana: { connectors: q() } }
32622
32514
  }
@@ -32657,6 +32549,13 @@ class PrivyWalletProvider {
32657
32549
  this.privyConfig.config.appearance.logo = appLogoUrl;
32658
32550
  }
32659
32551
  }
32552
+ // Ensure externalWallets connectors are always configured — required for
32553
+ // useWallets().ready to resolve even when no browser extension is present
32554
+ if (!this.privyConfig.config.externalWallets) {
32555
+ this.privyConfig.config.externalWallets = {
32556
+ solana: { connectors: q() }
32557
+ };
32558
+ }
32660
32559
  // Add Solana RPC configuration for v3
32661
32560
  let devnetUrl = SOLANA_DEVNET_RPC_URL;
32662
32561
  let mainnetUrl = SOLANA_MAINNET_RPC_URL;
@@ -32845,7 +32744,7 @@ class PrivyWalletProvider {
32845
32744
  }
32846
32745
  });
32847
32746
  React.useEffect(() => {
32848
- if (privy.ready && walletReady) {
32747
+ if (privy.ready) {
32849
32748
  that.privyMethods = {
32850
32749
  ready: privy.ready,
32851
32750
  walletReady: walletReady,
@@ -32934,7 +32833,7 @@ class PrivyWalletProvider {
32934
32833
  }
32935
32834
  async runTransaction(_evmTransactionData, solTransactionData, options) {
32936
32835
  var _a;
32937
- await this.ensureReady();
32836
+ await this.ensureReady({ waitForWallets: true });
32938
32837
  let session = await WebSessionManager.getSession();
32939
32838
  let sessionAddress = session === null || session === void 0 ? void 0 : session.address;
32940
32839
  let privyWallets = (_a = this.privyMethods) === null || _a === void 0 ? void 0 : _a.wallets;
@@ -33040,7 +32939,7 @@ class PrivyWalletProvider {
33040
32939
  */
33041
32940
  async signTransaction(transaction) {
33042
32941
  var _a;
33043
- await this.ensureReady();
32942
+ await this.ensureReady({ waitForWallets: true });
33044
32943
  let privyWallets = (_a = this.privyMethods) === null || _a === void 0 ? void 0 : _a.wallets;
33045
32944
  let session = await WebSessionManager.getSession();
33046
32945
  let sessionAddress = session === null || session === void 0 ? void 0 : session.address;
@@ -33114,7 +33013,7 @@ class PrivyWalletProvider {
33114
33013
  */
33115
33014
  async signAndSubmitTransaction(transaction, feePayer) {
33116
33015
  var _a;
33117
- await this.ensureReady();
33016
+ await this.ensureReady({ waitForWallets: true });
33118
33017
  let privyWallets = (_a = this.privyMethods) === null || _a === void 0 ? void 0 : _a.wallets;
33119
33018
  let session = await WebSessionManager.getSession();
33120
33019
  let sessionAddress = session === null || session === void 0 ? void 0 : session.address;
@@ -33288,7 +33187,7 @@ class PrivyWalletProvider {
33288
33187
  }
33289
33188
  async signMessage(message) {
33290
33189
  var _a, _b;
33291
- await this.ensureReady();
33190
+ await this.ensureReady({ waitForWallets: true });
33292
33191
  const session = await WebSessionManager.getSession();
33293
33192
  let sessionAddress = session === null || session === void 0 ? void 0 : session.address;
33294
33193
  // If there's already a pending sign message, throw an error to prevent overlapping calls
@@ -33354,17 +33253,26 @@ class PrivyWalletProvider {
33354
33253
  const createSessionResult = await createSessionWithPrivy(accessToken, address, idToken);
33355
33254
  await WebSessionManager.storeSession(address, createSessionResult.accessToken, createSessionResult.idToken, createSessionResult.refreshToken);
33356
33255
  }
33357
- async ensureReady() {
33358
- var _a, _b;
33359
- if (((_a = this.privyMethods) === null || _a === void 0 ? void 0 : _a.ready) && ((_b = this.privyMethods) === null || _b === void 0 ? void 0 : _b.walletReady)) {
33256
+ async ensureReady({ waitForWallets = false, timeoutMs = 15000 } = {}) {
33257
+ const isReady = () => {
33258
+ var _a, _b;
33259
+ if (!((_a = this.privyMethods) === null || _a === void 0 ? void 0 : _a.ready))
33260
+ return false;
33261
+ if (waitForWallets && !((_b = this.privyMethods) === null || _b === void 0 ? void 0 : _b.walletReady))
33262
+ return false;
33263
+ return true;
33264
+ };
33265
+ if (isReady())
33360
33266
  return;
33361
- }
33362
- return new Promise((resolve) => {
33267
+ return new Promise((resolve, reject) => {
33268
+ const startTime = Date.now();
33363
33269
  const check = () => {
33364
- var _a, _b;
33365
- if (((_a = this.privyMethods) === null || _a === void 0 ? void 0 : _a.ready) && ((_b = this.privyMethods) === null || _b === void 0 ? void 0 : _b.walletReady)) {
33270
+ if (isReady()) {
33366
33271
  resolve();
33367
33272
  }
33273
+ else if (Date.now() - startTime > timeoutMs) {
33274
+ reject(new Error('Login provider failed to initialize. This can happen in incognito mode or when third-party cookies are blocked. Try using a regular browser window.'));
33275
+ }
33368
33276
  else {
33369
33277
  setTimeout(check, 100);
33370
33278
  }
@@ -34250,9 +34158,19 @@ function clearIncompatibleSession() {
34250
34158
  return true;
34251
34159
  }
34252
34160
  async function hotSwapToPrivyProvider(config) {
34253
- var _a, _b, _c;
34161
+ var _a, _b, _c, _d, _e, _f, _g, _h;
34254
34162
  const rpcUrl = (_a = config.rpcUrl) !== null && _a !== void 0 ? _a : null;
34255
- const privyProvider = new PrivyWalletProvider((_b = config.name) !== null && _b !== void 0 ? _b : null, (_c = config.logoUrl) !== null && _c !== void 0 ? _c : null, config.privyConfig, rpcUrl);
34163
+ // Build an email-only Privy config: hide wallet connectors, show only email login.
34164
+ // Must include embeddedWallets so Privy auto-creates Solana wallets for email login users.
34165
+ const fallbackPrivyConfig = {
34166
+ appId: (_c = (_b = config.privyConfig) === null || _b === void 0 ? void 0 : _b.appId) !== null && _c !== void 0 ? _c : 'cm4ve714908o27dk2yurpnfhd',
34167
+ config: Object.assign(Object.assign({}, (_d = config.privyConfig) === null || _d === void 0 ? void 0 : _d.config), { loginMethods: ['email'], embeddedWallets: {
34168
+ solana: {
34169
+ createOnLogin: 'users-without-wallets'
34170
+ }
34171
+ }, appearance: Object.assign(Object.assign({}, (_f = (_e = config.privyConfig) === null || _e === void 0 ? void 0 : _e.config) === null || _f === void 0 ? void 0 : _f.appearance), { walletChainType: 'solana-only', showWalletLoginFirst: false, theme: 'dark', walletList: [] }) })
34172
+ };
34173
+ const privyProvider = new PrivyWalletProvider((_g = config.name) !== null && _g !== void 0 ? _g : null, (_h = config.logoUrl) !== null && _h !== void 0 ? _h : null, fallbackPrivyConfig, rpcUrl);
34256
34174
  let provider = privyProvider;
34257
34175
  if (config.chain === "offchain") {
34258
34176
  provider = new OffchainAuthProvider(privyProvider);
@@ -34324,9 +34242,6 @@ async function getAuthProvider(config) {
34324
34242
  console.log("[Offchain] Wrapping auth provider for Poofnet transaction tracking");
34325
34243
  currentAuthProvider = new OffchainAuthProvider(currentAuthProvider);
34326
34244
  }
34327
- // Update core config to reflect the actual auth method being used
34328
- const coreConfig = await getConfig();
34329
- coreConfig.authMethod = authMethod;
34330
34245
  return currentAuthProvider;
34331
34246
  }
34332
34247
  async function login$1() {
@@ -34335,6 +34250,7 @@ async function login$1() {
34335
34250
  currentAuthProvider = await getAuthProvider(initConfig);
34336
34251
  const coreConfig = await getConfig();
34337
34252
  coreConfig.authProvider = currentAuthProvider;
34253
+ coreConfig.authMethod = currentAuthMethod;
34338
34254
  setAuthProviderInstance(currentAuthProvider);
34339
34255
  }
34340
34256
  if (!currentAuthProvider) {
@@ -34348,6 +34264,9 @@ async function login$1() {
34348
34264
  }
34349
34265
  return null;
34350
34266
  }
34267
+ function getCurrentAuthMethod() {
34268
+ return currentAuthMethod;
34269
+ }
34351
34270
  async function logout$1() {
34352
34271
  if (!currentAuthProvider) {
34353
34272
  throw new Error("Auth provider not initialized. Please call init() first.");
@@ -34371,6 +34290,12 @@ async function init(newConfig) {
34371
34290
  authProviderInstance = await getAuthProvider(newConfig);
34372
34291
  // Initialize config with auth provider
34373
34292
  await init$1(Object.assign(Object.assign({}, newConfig), { authProvider: authProviderInstance }));
34293
+ // Now that core is initialized, update the auth method on the config
34294
+ const authMethod = getCurrentAuthMethod();
34295
+ if (authMethod) {
34296
+ const coreConfig = await getConfig();
34297
+ coreConfig.authMethod = authMethod;
34298
+ }
34374
34299
  // Wait for restoreSession to complete
34375
34300
  // The appId check is done in SessionManager.getSession which is called by restoreSession
34376
34301
  // If there's an appId mismatch, the session will be cleared and restoreSession will return null
@@ -34514,4 +34439,4 @@ async function getIdToken() {
34514
34439
  }
34515
34440
 
34516
34441
  export { useAuth as A, getIdToken as B, PrivyWalletProvider as C, DEFAULT_TEST_ADDRESS as D, EventEmitter4 as E, buildSetDocumentsTransaction as F, clearCache as G, closeAllSubscriptions as H, convertRemainingAccounts as I, createSessionWithPrivy as J, createSessionWithSignature as K, genAuthNonce as L, MockAuthProvider as M, genSolanaMessage as N, OffchainAuthProvider as O, PhantomWalletProvider as P, getCachedData as Q, reconnectWithNewAuth as R, ServerSessionManager as S, refreshSession as T, signSessionCreateMessage as U, WebSessionManager as W, bs58 as a, bufferExports as b, commonjsRequire as c, onAuthLoadingChanged as d, getAuthLoading as e, logout as f, getCurrentUser as g, getConfig as h, init as i, getAuthProvider as j, get$2 as k, login as l, setMany as m, setFile as n, onAuthStateChanged as o, getFiles as p, runQuery as q, require$$0$1 as r, set$1 as s, runQueryMany as t, runExpression as u, runExpressionMany as v, signMessage as w, signTransaction as x, signAndSubmitTransaction as y, subscribe as z };
34517
- //# sourceMappingURL=index-B6X0fhJf.esm.js.map
34442
+ //# sourceMappingURL=index-DbpX94X9.esm.js.map