@pooflabs/web 0.0.33 → 0.0.34

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.
@@ -12632,7 +12632,7 @@ async function loadDependencies() {
12632
12632
  const [reactModule, reactDomModule, phantomModule] = await Promise.all([
12633
12633
  import('react'),
12634
12634
  import('react-dom/client'),
12635
- import('./index-DtGP-cwj.esm.js')
12635
+ import('./index-C4NtEZJY.esm.js')
12636
12636
  ]);
12637
12637
  React$1 = reactModule;
12638
12638
  ReactDOM$1 = reactDomModule;
@@ -12743,16 +12743,19 @@ class PhantomWalletProvider {
12743
12743
  isModalOpen: modal.isOpened,
12744
12744
  connectError,
12745
12745
  solana: solana && solanaHook.isAvailable ? {
12746
- signMessage: solana.signMessage,
12747
- signTransaction: solana.signTransaction,
12748
- signAllTransactions: solana.signAllTransactions,
12749
- signAndSendTransaction: solana.signAndSendTransaction,
12750
- getPublicKey: solana.getPublicKey,
12746
+ // Wrap methods to preserve 'this' context - direct references lose binding
12747
+ signMessage: (message) => solana.signMessage(message),
12748
+ signTransaction: (tx) => solana.signTransaction(tx),
12749
+ signAllTransactions: (txs) => solana.signAllTransactions(txs),
12750
+ signAndSendTransaction: (tx) => solana.signAndSendTransaction(tx),
12751
+ getPublicKey: () => solana.getPublicKey(),
12751
12752
  isAvailable: solanaHook.isAvailable,
12753
+ connected: solana.connected,
12754
+ connect: (options) => solana.connect(options),
12752
12755
  } : null,
12753
12756
  };
12754
12757
  }
12755
- }, [phantom, phantom === null || phantom === void 0 ? void 0 : phantom.isConnected, phantom === null || phantom === void 0 ? void 0 : phantom.addresses, phantom === null || phantom === void 0 ? void 0 : phantom.isLoading, connect, disconnect, isDisconnecting, modal, modal.isOpened, solana, solanaHook.isAvailable, connectError]);
12758
+ }, [phantom, phantom === null || phantom === void 0 ? void 0 : phantom.isConnected, phantom === null || phantom === void 0 ? void 0 : phantom.addresses, phantom === null || phantom === void 0 ? void 0 : phantom.isLoading, connect, disconnect, isDisconnecting, modal, modal.isOpened, solana, solana === null || solana === void 0 ? void 0 : solana.connected, solanaHook.isAvailable, connectError]);
12756
12759
  // Auto-login: If connected but no Tarobase session, try to create one.
12757
12760
  // This handles social login callbacks where user returns from OAuth already connected.
12758
12761
  React$1.useEffect(() => {
@@ -12762,8 +12765,8 @@ class PhantomWalletProvider {
12762
12765
  if (!(phantom === null || phantom === void 0 ? void 0 : phantom.isConnected) || (phantom === null || phantom === void 0 ? void 0 : phantom.isLoading) || that.loginInProgress || that.autoLoginInProgress || that.pendingLogin) {
12763
12766
  return;
12764
12767
  }
12765
- // Need solana to be available for signing
12766
- if (!solana || !solanaHook.isAvailable) {
12768
+ // Need solana to be available AND connected for signing
12769
+ if (!solana || !solanaHook.isAvailable || !solana.connected) {
12767
12770
  return;
12768
12771
  }
12769
12772
  // Find Solana address
@@ -12809,7 +12812,7 @@ class PhantomWalletProvider {
12809
12812
  }
12810
12813
  };
12811
12814
  autoCreateSession();
12812
- }, [phantom === null || phantom === void 0 ? void 0 : phantom.isConnected, phantom === null || phantom === void 0 ? void 0 : phantom.isLoading, phantom === null || phantom === void 0 ? void 0 : phantom.addresses, solana, solanaHook.isAvailable, disconnect]);
12815
+ }, [phantom === null || phantom === void 0 ? void 0 : phantom.isConnected, phantom === null || phantom === void 0 ? void 0 : phantom.isLoading, phantom === null || phantom === void 0 ? void 0 : phantom.addresses, solana, solana === null || solana === void 0 ? void 0 : solana.connected, solanaHook.isAvailable, disconnect]);
12813
12816
  // Handle modal close without connection
12814
12817
  React$1.useEffect(() => {
12815
12818
  // Detect when modal was open and is now closed
@@ -12840,9 +12843,9 @@ class PhantomWalletProvider {
12840
12843
  if (!(phantom === null || phantom === void 0 ? void 0 : phantom.isConnected) || !((_a = phantom === null || phantom === void 0 ? void 0 : phantom.addresses) === null || _a === void 0 ? void 0 : _a.length) || !that.pendingLogin || !that.loginInProgress) {
12841
12844
  return;
12842
12845
  }
12843
- // Solana must be available for signing
12844
- // If not ready yet, just return - this effect will re-run when solanaHook.isAvailable changes
12845
- if (!solana || !solanaHook.isAvailable) {
12846
+ // Solana must be available AND connected for signing
12847
+ // If not ready yet, just return - this effect will re-run when solana.connected changes
12848
+ if (!solana || !solanaHook.isAvailable || !solana.connected) {
12846
12849
  return;
12847
12850
  }
12848
12851
  try {
@@ -12897,7 +12900,7 @@ class PhantomWalletProvider {
12897
12900
  }
12898
12901
  };
12899
12902
  handleConnectionSuccess();
12900
- }, [phantom === null || phantom === void 0 ? void 0 : phantom.isConnected, phantom === null || phantom === void 0 ? void 0 : phantom.addresses, solana, solanaHook.isAvailable]);
12903
+ }, [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]);
12901
12904
  return null; // Invisible component
12902
12905
  };
12903
12906
  // Wrapper component with PhantomProvider
@@ -12955,20 +12958,47 @@ class PhantomWalletProvider {
12955
12958
  async ensureSolanaReady() {
12956
12959
  var _a;
12957
12960
  await this.ensureReady();
12958
- // If connected, also wait for solana methods
12961
+ // If connected at the Phantom level, ensure solana methods are ready
12959
12962
  if ((_a = this.phantomMethods) === null || _a === void 0 ? void 0 : _a.isConnected) {
12960
- await new Promise((resolve) => {
12963
+ const timeoutMs = 10000; // 10 second timeout
12964
+ const startTime = Date.now();
12965
+ // First, wait for solana to be available
12966
+ await new Promise((resolve, reject) => {
12961
12967
  const check = () => {
12962
12968
  var _a, _b;
12963
12969
  if ((_b = (_a = this.phantomMethods) === null || _a === void 0 ? void 0 : _a.solana) === null || _b === void 0 ? void 0 : _b.isAvailable) {
12964
12970
  resolve();
12965
12971
  }
12972
+ else if (Date.now() - startTime > timeoutMs) {
12973
+ reject(new Error('Timeout waiting for Solana provider to be available'));
12974
+ }
12966
12975
  else {
12967
12976
  setTimeout(check, 100);
12968
12977
  }
12969
12978
  };
12970
12979
  check();
12971
12980
  });
12981
+ // Now check if the solana provider is connected, if not try to reconnect
12982
+ // Note: We check our wrapper's `connected` which may be stale, but this is just
12983
+ // an optimization to skip reconnect if we know we're already connected.
12984
+ // The actual signing methods use the SDK's bound methods which check live state.
12985
+ if (!this.phantomMethods.solana.connected) {
12986
+ console.log('Solana provider not connected, attempting to reconnect...');
12987
+ try {
12988
+ // onlyIfTrusted: true means it will reconnect silently if previously approved
12989
+ // If not trusted, it will throw and we'll catch it below
12990
+ await this.phantomMethods.solana.connect({ onlyIfTrusted: true });
12991
+ console.log('Solana provider reconnected successfully');
12992
+ }
12993
+ catch (error) {
12994
+ // If onlyIfTrusted fails, the user may need to re-approve via modal
12995
+ console.error('Failed to reconnect solana provider (silent reconnect failed):', error === null || error === void 0 ? void 0 : error.message);
12996
+ throw new Error('Failed to reconnect Solana provider. Please try logging in again.');
12997
+ }
12998
+ }
12999
+ // Note: We don't do a final connected check here because our wrapper's `connected`
13000
+ // is a snapshot that won't update until React re-renders. If connect() succeeded,
13001
+ // the SDK is connected and signing will work.
12972
13002
  }
12973
13003
  }
12974
13004
  /**
@@ -13040,11 +13070,19 @@ class PhantomWalletProvider {
13040
13070
  return (solAddress === null || solAddress === void 0 ? void 0 : solAddress.address) || null;
13041
13071
  }
13042
13072
  async runTransaction(_evmTransactionData, solTransactionData, options) {
13043
- var _a, _b, _c, _d, _e, _f, _g;
13073
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
13044
13074
  if (!solTransactionData) {
13045
13075
  throw new Error("Solana transaction data is required for Phantom wallet");
13046
13076
  }
13047
- await this.ensureSolanaReady();
13077
+ try {
13078
+ await this.ensureSolanaReady();
13079
+ }
13080
+ catch (error) {
13081
+ // Reconnection failed - log user out and throw
13082
+ console.error('Solana provider reconnection failed, logging out:', error.message);
13083
+ await this.logout();
13084
+ throw new Error('Wallet connection lost. Please reconnect.');
13085
+ }
13048
13086
  // Ensure connected
13049
13087
  if (!((_a = this.phantomMethods) === null || _a === void 0 ? void 0 : _a.isConnected)) {
13050
13088
  const user = await this.login();
@@ -13052,7 +13090,14 @@ class PhantomWalletProvider {
13052
13090
  throw new Error('Failed to connect wallet');
13053
13091
  }
13054
13092
  // Wait for solana to be ready after login
13055
- await this.ensureSolanaReady();
13093
+ try {
13094
+ await this.ensureSolanaReady();
13095
+ }
13096
+ catch (error) {
13097
+ console.error('Solana provider reconnection failed after login, logging out:', error.message);
13098
+ await this.logout();
13099
+ throw new Error('Wallet connection lost. Please reconnect.');
13100
+ }
13056
13101
  }
13057
13102
  if (!((_b = this.phantomMethods) === null || _b === void 0 ? void 0 : _b.solana)) {
13058
13103
  throw new Error('Solana signing not available');
@@ -13147,11 +13192,17 @@ class PhantomWalletProvider {
13147
13192
  };
13148
13193
  }
13149
13194
  catch (error) {
13195
+ // Check if this is a connection error - if so, log out
13196
+ if (((_d = error === null || error === void 0 ? void 0 : error.message) === null || _d === void 0 ? void 0 : _d.includes('not connected')) || ((_e = error === null || error === void 0 ? void 0 : error.message) === null || _e === void 0 ? void 0 : _e.includes('connect first'))) {
13197
+ console.error('Solana provider connection lost during transaction, logging out');
13198
+ await this.logout();
13199
+ throw new Error('Wallet connection lost. Please reconnect.');
13200
+ }
13150
13201
  const isUserRejection = (error === null || error === void 0 ? void 0 : error.code) === 4001 ||
13151
- ((_d = error === null || error === void 0 ? void 0 : error.message) === null || _d === void 0 ? void 0 : _d.toLowerCase().includes('user rejected')) ||
13152
- ((_e = error === null || error === void 0 ? void 0 : error.message) === null || _e === void 0 ? void 0 : _e.toLowerCase().includes('user denied')) ||
13153
- ((_f = error === null || error === void 0 ? void 0 : error.message) === null || _f === void 0 ? void 0 : _f.toLowerCase().includes('user cancelled')) ||
13154
- ((_g = error === null || error === void 0 ? void 0 : error.message) === null || _g === void 0 ? void 0 : _g.toLowerCase().includes('user canceled'));
13202
+ ((_f = error === null || error === void 0 ? void 0 : error.message) === null || _f === void 0 ? void 0 : _f.toLowerCase().includes('user rejected')) ||
13203
+ ((_g = error === null || error === void 0 ? void 0 : error.message) === null || _g === void 0 ? void 0 : _g.toLowerCase().includes('user denied')) ||
13204
+ ((_h = error === null || error === void 0 ? void 0 : error.message) === null || _h === void 0 ? void 0 : _h.toLowerCase().includes('user cancelled')) ||
13205
+ ((_j = error === null || error === void 0 ? void 0 : error.message) === null || _j === void 0 ? void 0 : _j.toLowerCase().includes('user canceled'));
13155
13206
  if (!isUserRejection) {
13156
13207
  console.error('Failed to execute transaction', error);
13157
13208
  }
@@ -13159,14 +13210,29 @@ class PhantomWalletProvider {
13159
13210
  }
13160
13211
  }
13161
13212
  async signTransaction(transaction) {
13162
- var _a, _b;
13163
- await this.ensureSolanaReady();
13213
+ var _a, _b, _c, _d;
13214
+ try {
13215
+ await this.ensureSolanaReady();
13216
+ }
13217
+ catch (error) {
13218
+ // Reconnection failed - log user out and throw
13219
+ console.error('Solana provider reconnection failed, logging out:', error.message);
13220
+ await this.logout();
13221
+ throw new Error('Wallet connection lost. Please reconnect.');
13222
+ }
13164
13223
  if (!((_a = this.phantomMethods) === null || _a === void 0 ? void 0 : _a.isConnected)) {
13165
13224
  const user = await this.login();
13166
13225
  if (!user) {
13167
13226
  throw new Error('Failed to connect wallet');
13168
13227
  }
13169
- await this.ensureSolanaReady();
13228
+ try {
13229
+ await this.ensureSolanaReady();
13230
+ }
13231
+ catch (error) {
13232
+ console.error('Solana provider reconnection failed after login, logging out:', error.message);
13233
+ await this.logout();
13234
+ throw new Error('Wallet connection lost. Please reconnect.');
13235
+ }
13170
13236
  }
13171
13237
  if (!((_b = this.phantomMethods) === null || _b === void 0 ? void 0 : _b.solana)) {
13172
13238
  throw new Error('Solana signing not available');
@@ -13175,18 +13241,39 @@ class PhantomWalletProvider {
13175
13241
  return await this.phantomMethods.solana.signTransaction(transaction);
13176
13242
  }
13177
13243
  catch (error) {
13244
+ // Check if this is a connection error - if so, log out
13245
+ if (((_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.includes('not connected')) || ((_d = error === null || error === void 0 ? void 0 : error.message) === null || _d === void 0 ? void 0 : _d.includes('connect first'))) {
13246
+ console.error('Solana provider connection lost during signing, logging out');
13247
+ await this.logout();
13248
+ throw new Error('Wallet connection lost. Please reconnect.');
13249
+ }
13178
13250
  throw new Error(`Failed to sign transaction: ${error.message}`);
13179
13251
  }
13180
13252
  }
13181
13253
  async signMessage(message) {
13182
- var _a, _b, _c, _d, _e, _f;
13183
- await this.ensureSolanaReady();
13254
+ var _a, _b, _c, _d, _e, _f, _g, _h;
13255
+ try {
13256
+ await this.ensureSolanaReady();
13257
+ }
13258
+ catch (error) {
13259
+ // Reconnection failed - log user out and throw
13260
+ console.error('Solana provider reconnection failed, logging out:', error.message);
13261
+ await this.logout();
13262
+ throw new Error('Wallet connection lost. Please reconnect.');
13263
+ }
13184
13264
  if (!((_a = this.phantomMethods) === null || _a === void 0 ? void 0 : _a.isConnected)) {
13185
13265
  const user = await this.login();
13186
13266
  if (!user) {
13187
13267
  throw new Error('Failed to connect wallet');
13188
13268
  }
13189
- await this.ensureSolanaReady();
13269
+ try {
13270
+ await this.ensureSolanaReady();
13271
+ }
13272
+ catch (error) {
13273
+ console.error('Solana provider reconnection failed after login, logging out:', error.message);
13274
+ await this.logout();
13275
+ throw new Error('Wallet connection lost. Please reconnect.');
13276
+ }
13190
13277
  }
13191
13278
  if (!((_b = this.phantomMethods) === null || _b === void 0 ? void 0 : _b.solana)) {
13192
13279
  throw new Error('Solana signing not available');
@@ -13197,11 +13284,17 @@ class PhantomWalletProvider {
13197
13284
  return bufferExports$1.Buffer.from(result.signature).toString('base64');
13198
13285
  }
13199
13286
  catch (error) {
13287
+ // Check if this is a connection error - if so, log out
13288
+ if (((_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.includes('not connected')) || ((_d = error === null || error === void 0 ? void 0 : error.message) === null || _d === void 0 ? void 0 : _d.includes('connect first'))) {
13289
+ console.error('Solana provider connection lost during signing, logging out');
13290
+ await this.logout();
13291
+ throw new Error('Wallet connection lost. Please reconnect.');
13292
+ }
13200
13293
  const isUserRejection = (error === null || error === void 0 ? void 0 : error.code) === 4001 ||
13201
- ((_c = error === null || error === void 0 ? void 0 : error.message) === null || _c === void 0 ? void 0 : _c.toLowerCase().includes('user rejected')) ||
13202
- ((_d = error === null || error === void 0 ? void 0 : error.message) === null || _d === void 0 ? void 0 : _d.toLowerCase().includes('user denied')) ||
13203
- ((_e = error === null || error === void 0 ? void 0 : error.message) === null || _e === void 0 ? void 0 : _e.toLowerCase().includes('user cancelled')) ||
13204
- ((_f = error === null || error === void 0 ? void 0 : error.message) === null || _f === void 0 ? void 0 : _f.toLowerCase().includes('user canceled'));
13294
+ ((_e = error === null || error === void 0 ? void 0 : error.message) === null || _e === void 0 ? void 0 : _e.toLowerCase().includes('user rejected')) ||
13295
+ ((_f = error === null || error === void 0 ? void 0 : error.message) === null || _f === void 0 ? void 0 : _f.toLowerCase().includes('user denied')) ||
13296
+ ((_g = error === null || error === void 0 ? void 0 : error.message) === null || _g === void 0 ? void 0 : _g.toLowerCase().includes('user cancelled')) ||
13297
+ ((_h = error === null || error === void 0 ? void 0 : error.message) === null || _h === void 0 ? void 0 : _h.toLowerCase().includes('user canceled'));
13205
13298
  if (!isUserRejection) {
13206
13299
  console.error('Failed to sign message', error);
13207
13300
  }
@@ -31490,4 +31583,4 @@ async function getIdToken() {
31490
31583
  }
31491
31584
 
31492
31585
  export { createSessionWithPrivy as A, createSessionWithSignature as B, genAuthNonce as C, DEFAULT_TEST_ADDRESS as D, genSolanaMessage as E, refreshSession as F, signSessionCreateMessage as G, MockAuthProvider as M, OffchainAuthProvider as O, PhantomWalletProvider as P, ServerSessionManager as S, WebSessionManager as W, getCurrentUser as a, bufferExports$1 as b, onAuthLoadingChanged as c, getAuthLoading as d, logout as e, getConfig as f, getDefaultExportFromCjs$1 as g, getAuthProvider as h, init as i, get$2 as j, setMany as k, login as l, setFile as m, getFiles as n, onAuthStateChanged as o, runQueryMany as p, runExpression as q, runQuery as r, set$1 as s, runExpressionMany as t, subscribe as u, useAuth as v, getIdToken as w, PrivyWalletProvider as x, buildSetDocumentsTransaction as y, convertRemainingAccounts as z };
31493
- //# sourceMappingURL=index-GsU0usWB.esm.js.map
31586
+ //# sourceMappingURL=index-B4flwOh0.esm.js.map