@bounded-sh/client 0.0.17 → 0.0.18

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.
Files changed (37) hide show
  1. package/README.md +2 -1
  2. package/dist/auth/index.d.ts +2 -4
  3. package/dist/auth/providers/phantom-wallet-provider.d.ts +3 -2
  4. package/dist/auth/providers/privy-wallet-provider.d.ts +10 -7
  5. package/dist/auth/providers/solana-mobile-wallet-provider.d.ts +3 -2
  6. package/dist/auth/solana-rpc.d.ts +8 -0
  7. package/dist/index.js +246 -188
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +246 -188
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/{index.native-DlMO7aHv.mjs → index.native-DahSrHrM.mjs} +138 -62
  12. package/dist/index.native-DahSrHrM.mjs.map +1 -0
  13. package/dist/{index.native-DoiNBZlU.js → index.native-Dr3FOz16.js} +141 -64
  14. package/dist/index.native-Dr3FOz16.js.map +1 -0
  15. package/dist/index.native.js +1 -1
  16. package/dist/index.native.mjs +1 -1
  17. package/dist/{phantom-wallet-provider-DUdnFoyb.js → phantom-wallet-provider-CeLJEdcL.js} +7 -18
  18. package/dist/phantom-wallet-provider-CeLJEdcL.js.map +1 -0
  19. package/dist/{phantom-wallet-provider-DWG1LVJf.mjs → phantom-wallet-provider-l-CNnHPs.mjs} +7 -18
  20. package/dist/phantom-wallet-provider-l-CNnHPs.mjs.map +1 -0
  21. package/dist/{privy-wallet-provider-Kv6H3xcS.js → privy-wallet-provider-BSwx78fY.js} +69 -90
  22. package/dist/privy-wallet-provider-BSwx78fY.js.map +1 -0
  23. package/dist/{privy-wallet-provider-CyNLekvY.mjs → privy-wallet-provider-BWM8TNO9.mjs} +68 -89
  24. package/dist/privy-wallet-provider-BWM8TNO9.mjs.map +1 -0
  25. package/dist/{solana-mobile-wallet-provider-BfHBucO0.js → solana-mobile-wallet-provider-BvCrAgk8.js} +39 -25
  26. package/dist/solana-mobile-wallet-provider-BvCrAgk8.js.map +1 -0
  27. package/dist/{solana-mobile-wallet-provider-CKOSbLRd.mjs → solana-mobile-wallet-provider-C78VWmM-.mjs} +39 -25
  28. package/dist/solana-mobile-wallet-provider-C78VWmM-.mjs.map +1 -0
  29. package/package.json +2 -2
  30. package/dist/index.native-DlMO7aHv.mjs.map +0 -1
  31. package/dist/index.native-DoiNBZlU.js.map +0 -1
  32. package/dist/phantom-wallet-provider-DUdnFoyb.js.map +0 -1
  33. package/dist/phantom-wallet-provider-DWG1LVJf.mjs.map +0 -1
  34. package/dist/privy-wallet-provider-CyNLekvY.mjs.map +0 -1
  35. package/dist/privy-wallet-provider-Kv6H3xcS.js.map +0 -1
  36. package/dist/solana-mobile-wallet-provider-BfHBucO0.js.map +0 -1
  37. package/dist/solana-mobile-wallet-provider-CKOSbLRd.mjs.map +0 -1
package/dist/index.mjs CHANGED
@@ -6673,6 +6673,50 @@ const MODAL_CSS = `
6673
6673
  #bounded-auth-modal .hidden{display:none;}
6674
6674
  @media (max-width:480px){#bounded-auth-modal .ba-card{max-width:none;border-radius:16px;}}`;
6675
6675
 
6676
+ const SURFNET_RPC_URL = "https://surfpool.fly.dev";
6677
+ const SUPPORTED_SOLANA_NETWORKS = new Set([
6678
+ "solana_devnet",
6679
+ "solana_mainnet",
6680
+ "surfnet",
6681
+ ]);
6682
+ function normalizeSolanaRpcUrl(rpcUrl) {
6683
+ if (typeof rpcUrl !== "string")
6684
+ return null;
6685
+ const trimmed = rpcUrl.trim();
6686
+ return trimmed.length > 0 ? trimmed : null;
6687
+ }
6688
+ function isSupportedSolanaRpcNetwork(network) {
6689
+ return typeof network === "string" && SUPPORTED_SOLANA_NETWORKS.has(network);
6690
+ }
6691
+ function resolveSolanaWalletStandardChain(network, context) {
6692
+ switch (network) {
6693
+ case "solana_devnet":
6694
+ return "solana:devnet";
6695
+ case "solana_mainnet":
6696
+ return "solana:mainnet";
6697
+ case "surfnet":
6698
+ return "solana:localnet";
6699
+ case undefined:
6700
+ case null:
6701
+ case "":
6702
+ throw new Error(`${context} requires an explicit Solana network. ` +
6703
+ `Provide one of: solana_devnet, solana_mainnet, surfnet.`);
6704
+ default:
6705
+ throw new Error(`${context} does not support Solana network "${network}". ` +
6706
+ `Expected one of: solana_devnet, solana_mainnet, surfnet.`);
6707
+ }
6708
+ }
6709
+ function resolveSolanaRpcUrl(explicitRpcUrl, network, context) {
6710
+ if (network != null && network !== "" && !isSupportedSolanaRpcNetwork(network)) {
6711
+ throw new Error(`${context} does not support Solana network "${network}". ` +
6712
+ `Expected one of: solana_devnet, solana_mainnet, surfnet.`);
6713
+ }
6714
+ const rpcUrl = normalizeSolanaRpcUrl(explicitRpcUrl);
6715
+ if (rpcUrl)
6716
+ return rpcUrl;
6717
+ throw new Error(`${context} requires an explicit Solana RPC URL. Pass config.rpcUrl before signing or submitting onchain transactions.`);
6718
+ }
6719
+
6676
6720
  const PKCE_STORE_KEY = 'bounded.oidc.pkce';
6677
6721
  // Active session store (Web on web, RN on React Native) — selected by config,
6678
6722
  // not by `typeof window` (truthy on RN). OIDC redirect/popup is web-only, but the
@@ -6979,7 +7023,7 @@ async function exchangeCode(code, verifier, redirectUri) {
6979
7023
  let currentAuthProvider = null;
6980
7024
  let currentAuthMethod = null;
6981
7025
  let initConfig = null;
6982
- // --- localStorage helpers: track which auth method the user last logged in with ---
7026
+ // --- localStorage helpers: track which auth method created the active session ---
6983
7027
  const STORED_AUTH_METHOD_KEY$1 = 'bounded_last_auth_method';
6984
7028
  function getStoredAuthMethod() {
6985
7029
  try {
@@ -7003,7 +7047,7 @@ function setStoredAuthMethod(method) {
7003
7047
  }
7004
7048
  }
7005
7049
  /**
7006
- * Clears the session if it was created before auth method tracking (legacy session).
7050
+ * Clears the session if it was created by a different auth method.
7007
7051
  * Returns true if the session was cleared, false if the session is compatible.
7008
7052
  *
7009
7053
  * Dispatches to the correct session manager based on the current auth method
@@ -7011,18 +7055,17 @@ function setStoredAuthMethod(method) {
7011
7055
  * are properly cleared.
7012
7056
  */
7013
7057
  function clearIncompatibleSession() {
7014
- if (getStoredAuthMethod() !== null) {
7015
- return false; // Auth method is tracked — session is compatible
7058
+ if (getStoredAuthMethod() === currentAuthMethod) {
7059
+ return false;
7016
7060
  }
7017
- // Legacy session (no stored auth method) — clear it so the user re-authenticates
7018
- // with the correct provider.
7019
- // Clear both managers — on web the RN manager is a no-op (not configured),
7020
- // on RN the web manager is a no-op (no localStorage).
7061
+ // Clear both managers: on web the RN manager is a no-op (not configured),
7062
+ // and on RN the web manager is a no-op (no localStorage).
7021
7063
  WebSessionManager.clearSession();
7022
7064
  try {
7023
7065
  ReactNativeSessionManager.clearSession();
7024
7066
  }
7025
7067
  catch ( /* not configured on web */_a) { /* not configured on web */ }
7068
+ setStoredAuthMethod(null);
7026
7069
  return true;
7027
7070
  }
7028
7071
  // Lazy loaders for web-only providers.
@@ -7041,17 +7084,67 @@ async function loadSolanaMobileWalletProvider() {
7041
7084
  const mod = await Promise.resolve().then(function () { return solanaMobileWalletProvider; });
7042
7085
  return mod.SolanaMobileWalletProvider;
7043
7086
  }
7087
+ function requireWebPrivyConfig(config) {
7088
+ if (!config.privyConfig || typeof config.privyConfig.appId !== 'string' || config.privyConfig.appId.trim() === '') {
7089
+ throw new Error('Privy auth requires config.privyConfig.appId; no default Privy app is used.');
7090
+ }
7091
+ if (!config.privyConfig.config || typeof config.privyConfig.config !== 'object') {
7092
+ throw new Error('Privy auth requires config.privyConfig.config for the app-scoped Privy provider.');
7093
+ }
7094
+ return config.privyConfig;
7095
+ }
7096
+ function getConfiguredSolanaNetwork(config) {
7097
+ if (typeof config.chain !== 'string')
7098
+ return null;
7099
+ const chain = config.chain.trim();
7100
+ if (chain === '' || chain === 'offchain')
7101
+ return null;
7102
+ return chain;
7103
+ }
7104
+ function mobileWalletClusterFromNetwork(network) {
7105
+ switch (network) {
7106
+ case "solana_devnet":
7107
+ return "devnet";
7108
+ case "solana_mainnet":
7109
+ return "mainnet-beta";
7110
+ case "surfnet":
7111
+ return "localnet";
7112
+ case null:
7113
+ return null;
7114
+ default:
7115
+ resolveSolanaWalletStandardChain(network, "Mobile wallet auth");
7116
+ return null;
7117
+ }
7118
+ }
7119
+ function requireMobileWalletConfig(config) {
7120
+ var _a, _b, _c;
7121
+ const configuredNetwork = getConfiguredSolanaNetwork(config);
7122
+ const cluster = (_b = (_a = config.mobileWalletConfig) === null || _a === void 0 ? void 0 : _a.cluster) !== null && _b !== void 0 ? _b : mobileWalletClusterFromNetwork(configuredNetwork);
7123
+ if (!cluster) {
7124
+ throw new Error("Mobile wallet auth requires an explicit Solana network. " +
7125
+ "Pass config.chain as solana_devnet, solana_mainnet, or surfnet, " +
7126
+ "or pass mobileWalletConfig.cluster.");
7127
+ }
7128
+ return Object.assign(Object.assign({}, ((_c = config.mobileWalletConfig) !== null && _c !== void 0 ? _c : {})), { cluster });
7129
+ }
7044
7130
  async function hotSwapToMWAProvider(config) {
7045
- var _a, _b;
7046
- const rpcUrl = (_a = config.rpcUrl) !== null && _a !== void 0 ? _a : null;
7131
+ var _a;
7132
+ const rpcUrl = normalizeSolanaRpcUrl(config.rpcUrl);
7133
+ const configuredNetwork = getConfiguredSolanaNetwork(config);
7047
7134
  const SolanaMobileWalletProvider = await loadSolanaMobileWalletProvider();
7048
- const mwaConfig = (_b = config.mobileWalletConfig) !== null && _b !== void 0 ? _b : {
7049
- appIdentity: {
7050
- name: config.name || undefined,
7051
- uri: getPlatform().getLocationOrigin(),
7052
- },
7053
- };
7054
- const mwaProvider = new SolanaMobileWalletProvider(rpcUrl, mwaConfig);
7135
+ const mwaConfig = config.mobileWalletConfig
7136
+ ? requireMobileWalletConfig(config)
7137
+ : {
7138
+ appIdentity: {
7139
+ name: config.name || undefined,
7140
+ uri: getPlatform().getLocationOrigin(),
7141
+ },
7142
+ cluster: (_a = mobileWalletClusterFromNetwork(configuredNetwork)) !== null && _a !== void 0 ? _a : undefined,
7143
+ };
7144
+ if (!mwaConfig.cluster) {
7145
+ throw new Error("Mobile wallet auth requires config.chain or mobileWalletConfig.cluster before switching providers.");
7146
+ }
7147
+ const mwaProvider = new SolanaMobileWalletProvider(rpcUrl, mwaConfig, configuredNetwork);
7055
7148
  let provider = mwaProvider;
7056
7149
  if (config.chain === "offchain") {
7057
7150
  provider = new OffchainAuthProvider(mwaProvider);
@@ -7066,11 +7159,8 @@ async function hotSwapToMWAProvider(config) {
7066
7159
  setAuthProviderInstance(provider);
7067
7160
  return provider;
7068
7161
  }
7069
- const SOLANA_DEVNET_RPC_URL = "https://idelle-8nxsep-fast-devnet.helius-rpc.com";
7070
- const SOLANA_MAINNET_RPC_URL = "https://celestia-cegncv-fast-mainnet.helius-rpc.com";
7071
- const SURFNET_RPC_URL$2 = "https://surfpool.fly.dev";
7072
7162
  async function getAuthProvider(config) {
7073
- var _a, _b, _c;
7163
+ var _a, _b;
7074
7164
  if (currentAuthProvider) {
7075
7165
  return currentAuthProvider;
7076
7166
  }
@@ -7084,17 +7174,12 @@ async function getAuthProvider(config) {
7084
7174
  currentAuthProvider = new MockAuthProvider();
7085
7175
  return currentAuthProvider;
7086
7176
  }
7087
- // If the user previously logged in with a specific method, use that instead
7088
- const validAuthMethods = ['email', 'phantom', 'wallet', 'rainbowkit', 'coinbase-smart-wallet', 'onboard', 'mobile-wallet-adapter', 'guest', 'privy', 'privy-expo', 'none'];
7089
- const storedMethod = getStoredAuthMethod();
7090
- const authMethod = (storedMethod && validAuthMethods.includes(storedMethod))
7091
- ? storedMethod
7092
- : (config.authMethod || "email");
7093
- if (storedMethod && !validAuthMethods.includes(storedMethod)) {
7094
- // Invalid stored value — clear it
7095
- setStoredAuthMethod(null);
7096
- }
7097
- const rpcUrl = (_a = config.rpcUrl) !== null && _a !== void 0 ? _a : null;
7177
+ const authMethod = config.authMethod;
7178
+ if (!authMethod) {
7179
+ throw new Error("authMethod is required to initialize auth provider; configure the single intended auth method explicitly.");
7180
+ }
7181
+ const rpcUrl = normalizeSolanaRpcUrl(config.rpcUrl);
7182
+ const configuredNetwork = getConfiguredSolanaNetwork(config);
7098
7183
  currentAuthMethod = authMethod;
7099
7184
  // Clear, actionable error when the BROWSER build (`bounded-sh`) is loaded in a
7100
7185
  // non-browser (Node) runtime. The wallet providers below need `window`; without
@@ -7124,7 +7209,7 @@ async function getAuthProvider(config) {
7124
7209
  break;
7125
7210
  case "phantom": {
7126
7211
  const { PhantomWalletProvider } = await loadPhantomWalletProvider();
7127
- currentAuthProvider = new PhantomWalletProvider(rpcUrl, config.phantomConfig);
7212
+ currentAuthProvider = new PhantomWalletProvider(rpcUrl, config.phantomConfig, configuredNetwork);
7128
7213
  // MWA hot-swap is always available (custom modal shows MWA button on Android)
7129
7214
  currentAuthProvider.onSwitchToMWA =
7130
7215
  () => hotSwapToMWAProvider(config);
@@ -7134,8 +7219,9 @@ async function getAuthProvider(config) {
7134
7219
  // Web Privy: a co-equal login route alongside email/phantom/guest. The
7135
7220
  // Privy embedded/external Solana wallet signs the SIWS challenge, so the
7136
7221
  // session is minted through the same wallet path as Phantom.
7222
+ const privyConfig = requireWebPrivyConfig(config);
7137
7223
  const PrivyWalletProvider = await loadPrivyWalletProvider();
7138
- currentAuthProvider = new PrivyWalletProvider((_b = config.name) !== null && _b !== void 0 ? _b : null, (_c = config.logoUrl) !== null && _c !== void 0 ? _c : null, config.privyConfig, rpcUrl);
7224
+ currentAuthProvider = new PrivyWalletProvider((_a = config.name) !== null && _a !== void 0 ? _a : null, (_b = config.logoUrl) !== null && _b !== void 0 ? _b : null, privyConfig, rpcUrl, configuredNetwork);
7139
7225
  break;
7140
7226
  }
7141
7227
  case "privy-expo":
@@ -7150,7 +7236,7 @@ async function getAuthProvider(config) {
7150
7236
  break;
7151
7237
  case "mobile-wallet-adapter": {
7152
7238
  const SolanaMobileWalletProvider = await loadSolanaMobileWalletProvider();
7153
- currentAuthProvider = new SolanaMobileWalletProvider(rpcUrl, config.mobileWalletConfig);
7239
+ currentAuthProvider = new SolanaMobileWalletProvider(rpcUrl, requireMobileWalletConfig(config), configuredNetwork);
7154
7240
  break;
7155
7241
  }
7156
7242
  case "onboard":
@@ -7220,13 +7306,14 @@ async function signInAnonymously() {
7220
7306
  * (web localStorage / RN storage) and identity model. `init()` must have run first.
7221
7307
  */
7222
7308
  async function loginWithPrivy(options) {
7223
- var _a, _b, _c;
7309
+ var _a, _b;
7224
7310
  assertBrowserAuthEnv('loginWithPrivy');
7225
7311
  const coreConfig = await getConfig();
7226
7312
  let provider;
7227
7313
  if (getPlatform().hasDOM) {
7314
+ const privyConfig = requireWebPrivyConfig(coreConfig);
7228
7315
  const PrivyWalletProvider = await loadPrivyWalletProvider();
7229
- provider = new PrivyWalletProvider((_a = coreConfig.name) !== null && _a !== void 0 ? _a : null, (_b = coreConfig.logoUrl) !== null && _b !== void 0 ? _b : null, coreConfig.privyConfig, (_c = coreConfig.rpcUrl) !== null && _c !== void 0 ? _c : null);
7316
+ provider = new PrivyWalletProvider((_a = coreConfig.name) !== null && _a !== void 0 ? _a : null, (_b = coreConfig.logoUrl) !== null && _b !== void 0 ? _b : null, privyConfig, normalizeSolanaRpcUrl(coreConfig.rpcUrl), getConfiguredSolanaNetwork(coreConfig));
7230
7317
  currentAuthMethod = 'privy';
7231
7318
  }
7232
7319
  else {
@@ -7372,15 +7459,13 @@ async function logout$1() {
7372
7459
  throw new Error("Auth provider not initialized. Please call init() first.");
7373
7460
  }
7374
7461
  // Revoke the refresh-token family server-side BEFORE the provider clears the
7375
- // local session (so we still have the token + issuer to revoke). Best-effort:
7376
- // revokeSession swallows errors so logout never hangs/fails on a network blip.
7377
- try {
7378
- const sm = getActiveSessionManager();
7379
- const refreshToken = sm.getRefreshToken();
7380
- if (refreshToken)
7381
- await revokeSession(refreshToken, (_a = sm.getIssuer()) !== null && _a !== void 0 ? _a : undefined);
7382
- }
7383
- catch ( /* proceed with local logout regardless */_b) { /* proceed with local logout regardless */ }
7462
+ // local session (so we still have the token + issuer to revoke). If revoke
7463
+ // fails, surface the error and leave local state intact so callers do not
7464
+ // mistake a local-only logout for server revocation.
7465
+ const sm = getActiveSessionManager();
7466
+ const refreshToken = sm.getRefreshToken();
7467
+ if (refreshToken)
7468
+ await revokeSession(refreshToken, (_a = sm.getIssuer()) !== null && _a !== void 0 ? _a : undefined);
7384
7469
  await currentAuthProvider.logout();
7385
7470
  setStoredAuthMethod(null);
7386
7471
  currentAuthProvider = null;
@@ -7835,7 +7920,7 @@ class PhantomWalletProvider {
7835
7920
  setLoginOverrides(opts) {
7836
7921
  this.loginOverrides = opts;
7837
7922
  }
7838
- constructor(networkUrl = null, config = {}) {
7923
+ constructor(networkUrl = null, config = {}, configuredNetwork = null) {
7839
7924
  this.containerElement = null;
7840
7925
  this.root = null;
7841
7926
  this.phantomMethods = null;
@@ -7848,6 +7933,7 @@ class PhantomWalletProvider {
7848
7933
  /** Callback to swap to a Mobile Wallet Adapter provider when the user clicks "Connect Mobile Wallet" */
7849
7934
  this.onSwitchToMWA = null;
7850
7935
  this.networkUrl = networkUrl;
7936
+ this.configuredNetwork = configuredNetwork;
7851
7937
  this.config = config;
7852
7938
  if (typeof window === 'undefined') {
7853
7939
  throw new Error('PhantomWalletProvider can only be instantiated in a browser environment');
@@ -7874,9 +7960,9 @@ class PhantomWalletProvider {
7874
7960
  hasSocialProviders() {
7875
7961
  return this.resolvedProviders.some(p => p !== 'injected');
7876
7962
  }
7877
- static getInstance(networkUrl, config) {
7963
+ static getInstance(networkUrl, config, configuredNetwork = null) {
7878
7964
  if (!PhantomWalletProvider.instance) {
7879
- new PhantomWalletProvider(networkUrl, config);
7965
+ new PhantomWalletProvider(networkUrl, config, configuredNetwork);
7880
7966
  }
7881
7967
  return PhantomWalletProvider.instance;
7882
7968
  }
@@ -8778,7 +8864,7 @@ class PhantomWalletProvider {
8778
8864
  }
8779
8865
  const rpcUrl = this.getRpcUrl(solTransactionData.network);
8780
8866
  const connection = new Connection(rpcUrl, 'confirmed');
8781
- const isSurfnet = rpcUrl === SURFNET_RPC_URL$2;
8867
+ const isSurfnet = rpcUrl === SURFNET_RPC_URL;
8782
8868
  try {
8783
8869
  const remainingAccounts = convertRemainingAccounts(solTransactionData.txArgs[0].remainingAccounts);
8784
8870
  const app_id = solTransactionData.appId;
@@ -9000,7 +9086,7 @@ class PhantomWalletProvider {
9000
9086
  }
9001
9087
  const rpcUrl = this.getRpcUrl();
9002
9088
  const connection = new Connection(rpcUrl, 'confirmed');
9003
- const isSurfnet = rpcUrl === SURFNET_RPC_URL$2;
9089
+ const isSurfnet = rpcUrl === SURFNET_RPC_URL;
9004
9090
  try {
9005
9091
  // Get fresh blockhash and set it on the transaction before signing
9006
9092
  const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed');
@@ -9133,19 +9219,7 @@ class PhantomWalletProvider {
9133
9219
  * Private Helpers
9134
9220
  * ----------------------------------------------------------- */
9135
9221
  getRpcUrl(network) {
9136
- if (this.networkUrl) {
9137
- return this.networkUrl;
9138
- }
9139
- if (network === 'solana_devnet') {
9140
- return SOLANA_DEVNET_RPC_URL;
9141
- }
9142
- else if (network === 'solana_mainnet') {
9143
- return SOLANA_MAINNET_RPC_URL;
9144
- }
9145
- else if (network === 'surfnet') {
9146
- return SURFNET_RPC_URL$2;
9147
- }
9148
- return SOLANA_MAINNET_RPC_URL; // default to mainnet
9222
+ return resolveSolanaRpcUrl(this.networkUrl, network !== null && network !== void 0 ? network : this.configuredNetwork, "Phantom wallet Solana transaction");
9149
9223
  }
9150
9224
  async signAndSendViaPhantom(transaction) {
9151
9225
  var _a, _b, _c;
@@ -9592,8 +9666,10 @@ async function signWithFreshActivation(theme, signFn, noResultError = 'MWA retur
9592
9666
  * normalized to `solana:mainnet`.
9593
9667
  */
9594
9668
  function mapChainToWalletStandard(input) {
9595
- if (!input)
9596
- return 'solana:mainnet';
9669
+ if (!input) {
9670
+ throw new Error("Solana mobile wallet auth requires an explicit cluster. " +
9671
+ "Pass mobileWalletConfig.cluster or config.chain.");
9672
+ }
9597
9673
  let s = String(input).toLowerCase();
9598
9674
  while (s.startsWith('solana:'))
9599
9675
  s = s.slice('solana:'.length);
@@ -9605,7 +9681,22 @@ function mapChainToWalletStandard(input) {
9605
9681
  return 'solana:testnet';
9606
9682
  if (s === 'localnet')
9607
9683
  return 'solana:localnet';
9608
- return 'solana:mainnet';
9684
+ throw new Error(`Solana mobile wallet auth does not support cluster "${input}". ` +
9685
+ "Expected mainnet-beta, devnet, testnet, or localnet.");
9686
+ }
9687
+ function mapClusterToRpcNetwork(input) {
9688
+ if (!input)
9689
+ return null;
9690
+ let s = String(input).toLowerCase();
9691
+ while (s.startsWith('solana:'))
9692
+ s = s.slice('solana:'.length);
9693
+ if (s === 'mainnet-beta' || s === 'mainnet')
9694
+ return 'solana_mainnet';
9695
+ if (s === 'devnet')
9696
+ return 'solana_devnet';
9697
+ if (s === 'localnet')
9698
+ return 'surfnet';
9699
+ return null;
9609
9700
  }
9610
9701
  /**
9611
9702
  * Serialize a Transaction/VersionedTransaction to a Uint8Array wire payload
@@ -9781,7 +9872,8 @@ async function registerMobileWalletAdapter(config) {
9781
9872
  * acceptable given the alternative was broken on Seeker.
9782
9873
  */
9783
9874
  class SolanaMobileWalletProvider {
9784
- constructor(networkUrl = null, config = {}) {
9875
+ constructor(networkUrl = null, config = {}, configuredNetwork = null) {
9876
+ var _a;
9785
9877
  /** LocalSolanaMobileWalletAdapterWallet, lazy-constructed in ensureWallet(). */
9786
9878
  this.wallet = null;
9787
9879
  /**
@@ -9795,6 +9887,7 @@ class SolanaMobileWalletProvider {
9795
9887
  /** Cached public key string for the connected MWA wallet (native). */
9796
9888
  this.nativeAddress = null;
9797
9889
  this.networkUrl = networkUrl;
9890
+ this.configuredNetwork = configuredNetwork;
9798
9891
  this.config = config;
9799
9892
  // Allow construction in true React Native environments: getPlatform().hasDOM
9800
9893
  // is false there even though `typeof window === 'object'` (RN exposes a
@@ -9823,7 +9916,7 @@ class SolanaMobileWalletProvider {
9823
9916
  name: 'Bounded App',
9824
9917
  uri: fallbackUri,
9825
9918
  };
9826
- this.cluster = config.cluster || 'mainnet-beta';
9919
+ this.cluster = (_a = config.cluster) !== null && _a !== void 0 ? _a : '';
9827
9920
  // Hydrate cached MWA auth_token from storage on native so we can
9828
9921
  // skip the wallet-pick popup after a cold-start when the underlying
9829
9922
  // wallet authorization is still valid. Sync storage call per the
@@ -9840,15 +9933,15 @@ class SolanaMobileWalletProvider {
9840
9933
  }
9841
9934
  }
9842
9935
  }
9843
- catch (_a) {
9936
+ catch (_b) {
9844
9937
  // Corrupt or unreadable cache — ignore. login() will re-auth.
9845
9938
  }
9846
9939
  }
9847
9940
  SolanaMobileWalletProvider.instance = this;
9848
9941
  }
9849
- static getInstance(networkUrl, config) {
9942
+ static getInstance(networkUrl, config, configuredNetwork = null) {
9850
9943
  if (!SolanaMobileWalletProvider.instance) {
9851
- new SolanaMobileWalletProvider(networkUrl, config);
9944
+ new SolanaMobileWalletProvider(networkUrl, config, configuredNetwork);
9852
9945
  }
9853
9946
  return SolanaMobileWalletProvider.instance;
9854
9947
  }
@@ -9903,7 +9996,13 @@ class SolanaMobileWalletProvider {
9903
9996
  return wallet.accounts[0];
9904
9997
  }
9905
9998
  /** Returns the active wallet-standard chain identifier (e.g. 'solana:mainnet'). */
9906
- getChain() {
9999
+ getChain(network) {
10000
+ if (network) {
10001
+ return resolveSolanaWalletStandardChain(network, "Solana mobile wallet transaction");
10002
+ }
10003
+ if (this.configuredNetwork) {
10004
+ return resolveSolanaWalletStandardChain(this.configuredNetwork, "Solana mobile wallet transaction");
10005
+ }
9907
10006
  return mapChainToWalletStandard(this.cluster);
9908
10007
  }
9909
10008
  /**
@@ -10365,7 +10464,7 @@ class SolanaMobileWalletProvider {
10365
10464
  const connectedPubkey = new PublicKey(this.nativeAddress);
10366
10465
  const rpcUrl = this.getRpcUrl();
10367
10466
  const connection = new Connection(rpcUrl, 'confirmed');
10368
- const isSurfnet = rpcUrl === SURFNET_RPC_URL$2;
10467
+ const isSurfnet = rpcUrl === SURFNET_RPC_URL;
10369
10468
  const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed');
10370
10469
  const isLegacyTransaction = 'recentBlockhash' in transaction && !('message' in transaction && 'staticAccountKeys' in transaction.message);
10371
10470
  if (isLegacyTransaction) {
@@ -10423,7 +10522,7 @@ class SolanaMobileWalletProvider {
10423
10522
  const chain = this.getChain();
10424
10523
  const rpcUrl = this.getRpcUrl();
10425
10524
  const connection = new Connection(rpcUrl, 'confirmed');
10426
- const isSurfnet = rpcUrl === SURFNET_RPC_URL$2;
10525
+ const isSurfnet = rpcUrl === SURFNET_RPC_URL;
10427
10526
  try {
10428
10527
  // Preserve existing prep: refresh blockhash and set fee payer.
10429
10528
  const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed');
@@ -10503,10 +10602,10 @@ class SolanaMobileWalletProvider {
10503
10602
  const account = await this.ensureAuthorized();
10504
10603
  const connectedPubkey = new PublicKey(account.publicKey);
10505
10604
  const wallet = await this.ensureWallet();
10506
- const chain = this.getChain();
10605
+ const chain = this.getChain(solTransactionData.network);
10507
10606
  const rpcUrl = this.getRpcUrl(solTransactionData.network);
10508
10607
  const connection = new Connection(rpcUrl, 'confirmed');
10509
- const isSurfnet = rpcUrl === SURFNET_RPC_URL$2;
10608
+ const isSurfnet = rpcUrl === SURFNET_RPC_URL;
10510
10609
  try {
10511
10610
  const remainingAccounts = convertRemainingAccounts(solTransactionData.txArgs[0].remainingAccounts);
10512
10611
  const app_id = solTransactionData.appId;
@@ -10682,19 +10781,8 @@ class SolanaMobileWalletProvider {
10682
10781
  * Private Helpers
10683
10782
  * ----------------------------------------------------------- */
10684
10783
  getRpcUrl(network) {
10685
- if (this.networkUrl) {
10686
- return this.networkUrl;
10687
- }
10688
- if (network === 'solana_devnet') {
10689
- return SOLANA_DEVNET_RPC_URL;
10690
- }
10691
- else if (network === 'solana_mainnet') {
10692
- return SOLANA_MAINNET_RPC_URL;
10693
- }
10694
- else if (network === 'surfnet') {
10695
- return SURFNET_RPC_URL$2;
10696
- }
10697
- return SOLANA_MAINNET_RPC_URL;
10784
+ var _a;
10785
+ return resolveSolanaRpcUrl(this.networkUrl, (_a = network !== null && network !== void 0 ? network : this.configuredNetwork) !== null && _a !== void 0 ? _a : mapClusterToRpcNetwork(this.cluster), "Solana mobile wallet transaction");
10698
10786
  }
10699
10787
  }
10700
10788
  SolanaMobileWalletProvider.instance = null;
@@ -10706,7 +10794,6 @@ var solanaMobileWalletProvider = /*#__PURE__*/Object.freeze({
10706
10794
  registerMobileWalletAdapter: registerMobileWalletAdapter
10707
10795
  });
10708
10796
 
10709
- const SURFNET_RPC_URL$1 = "https://surfpool.fly.dev";
10710
10797
  // @privy-io/react-auth(/solana) are OPTIONAL peer deps. They are loaded lazily
10711
10798
  // via dynamic import() rather than a static top-level import: a static import
10712
10799
  // would (a) in the ESM bundle still be a bare `import` the consumer resolves —
@@ -10739,31 +10826,28 @@ async function loadSolanaKit() {
10739
10826
  }
10740
10827
  return solanaKit;
10741
10828
  }
10742
- const getDefaultPrivyConfig = () => ({
10743
- appId: "cm4ve714908o27dk2yurpnfhd",
10744
- config: {
10745
- embeddedWallets: {
10746
- solana: {
10747
- createOnLogin: "users-without-wallets"
10748
- }
10749
- },
10750
- appearance: {
10751
- walletChainType: 'solana-only'
10752
- },
10753
- externalWallets: { solana: { connectors: privySolana.toSolanaWalletConnectors() } }
10829
+ function requirePrivyWalletConfig(privyConfig) {
10830
+ if (!privyConfig || typeof privyConfig.appId !== 'string' || privyConfig.appId.trim() === '') {
10831
+ throw new Error('Privy auth requires config.privyConfig.appId; no default Privy app is used.');
10754
10832
  }
10755
- });
10833
+ if (!privyConfig.config || typeof privyConfig.config !== 'object') {
10834
+ throw new Error('Privy auth requires config.privyConfig.config for the app-scoped Privy provider.');
10835
+ }
10836
+ return {
10837
+ appId: privyConfig.appId,
10838
+ config: privyConfig.config,
10839
+ };
10840
+ }
10756
10841
  class PrivyWalletProvider {
10757
- constructor(appName, appLogoUrl, privyConfig, networkUrl = null) {
10842
+ constructor(appName, appLogoUrl, privyConfig, networkUrl = null, configuredNetwork = null) {
10758
10843
  this.containerElement = null;
10759
- this.chainId = 'solana:mainnet';
10844
+ this.chainId = null;
10760
10845
  this.root = null;
10761
10846
  this.privyMethods = null;
10762
10847
  this.pendingLogin = null;
10763
10848
  // Resolved Solana RPC URLs (computed in the constructor; consumed in
10764
10849
  // initialize() where @solana/kit is lazily loaded to build the transports).
10765
- this.rpcDevnetUrl = SOLANA_DEVNET_RPC_URL;
10766
- this.rpcMainnetUrl = SOLANA_MAINNET_RPC_URL;
10850
+ this.configuredRpcUrl = null;
10767
10851
  // This is used to store the pending transaction until the wallet is connected for workaround for the wallet not being connected after login completion
10768
10852
  this.pendingTransaction = null;
10769
10853
  // This is used to store pending signTransaction calls until the wallet is connected
@@ -10772,41 +10856,37 @@ class PrivyWalletProvider {
10772
10856
  this.pendingSignMessage = null;
10773
10857
  // This is used to store pending signAndSubmitTransaction calls until the wallet is connected
10774
10858
  this.pendingSignAndSubmitTransaction = null;
10775
- this.networkUrl = networkUrl;
10859
+ this.networkUrl = normalizeSolanaRpcUrl(networkUrl);
10860
+ this.configuredNetwork = configuredNetwork;
10776
10861
  if (typeof window === 'undefined') {
10777
10862
  throw new Error('PrivyWalletProvider can only be instantiated in a browser environment');
10778
10863
  }
10864
+ const requiredPrivyConfig = requirePrivyWalletConfig(privyConfig);
10779
10865
  if (PrivyWalletProvider.instance) {
10780
10866
  return PrivyWalletProvider.instance;
10781
10867
  }
10782
10868
  this.containerElement = null;
10783
10869
  this.root = null;
10784
10870
  this.privyMethods = null;
10785
- this.privyConfig = privyConfig !== null && privyConfig !== void 0 ? privyConfig : getDefaultPrivyConfig();
10786
- // Only use the appName and appLogoUrl if no privyConfig is provided
10787
- if (privyConfig == null) {
10788
- if (appName != null && appName != '') {
10789
- this.privyConfig.config.appearance.landingHeader = appName;
10790
- }
10791
- if (appLogoUrl != null && appLogoUrl != '') {
10792
- this.privyConfig.config.appearance.logo = appLogoUrl;
10793
- }
10871
+ this.privyConfig = requiredPrivyConfig;
10872
+ if (!this.privyConfig.config.appearance) {
10873
+ this.privyConfig.config.appearance = {};
10874
+ }
10875
+ if (appName != null && appName != '' && !this.privyConfig.config.appearance.landingHeader) {
10876
+ this.privyConfig.config.appearance.landingHeader = appName;
10877
+ }
10878
+ if (appLogoUrl != null && appLogoUrl != '' && !this.privyConfig.config.appearance.logo) {
10879
+ this.privyConfig.config.appearance.logo = appLogoUrl;
10794
10880
  }
10795
10881
  // (externalWallets connectors are configured in initialize() once the
10796
10882
  // Privy SDK is lazily loaded — see loadPrivyModules.)
10797
10883
  // Resolve Solana RPC URLs for v3. The @solana/kit transports are built
10798
10884
  // lazily in initialize() so a non-Privy consumer never needs @solana/kit.
10799
- this.rpcDevnetUrl = SOLANA_DEVNET_RPC_URL;
10800
- this.rpcMainnetUrl = SOLANA_MAINNET_RPC_URL;
10801
- if (networkUrl != null) {
10802
- if (networkUrl.includes('mainnet')) {
10803
- this.rpcMainnetUrl = networkUrl;
10804
- this.chainId = 'solana:mainnet';
10805
- }
10806
- else if (networkUrl.includes('devnet')) {
10807
- this.rpcDevnetUrl = networkUrl;
10808
- this.chainId = 'solana:devnet';
10809
- }
10885
+ if (this.networkUrl || configuredNetwork) {
10886
+ this.configuredRpcUrl = resolveSolanaRpcUrl(this.networkUrl, configuredNetwork, "Privy Solana RPC");
10887
+ }
10888
+ if (configuredNetwork) {
10889
+ this.chainId = resolveSolanaWalletStandardChain(configuredNetwork, "Privy Solana transaction");
10810
10890
  }
10811
10891
  const existingProviders = document.querySelectorAll('[data-privy-provider]');
10812
10892
  existingProviders.forEach(el => el.remove());
@@ -10821,9 +10901,9 @@ class PrivyWalletProvider {
10821
10901
  PrivyWalletProvider.instance = this;
10822
10902
  }
10823
10903
  // Optional: Provide a static method to get the instance
10824
- static getInstance(appName, appLogoUrl, privyConfig) {
10904
+ static getInstance(appName, appLogoUrl, privyConfig, networkUrl = null, configuredNetwork = null) {
10825
10905
  if (!PrivyWalletProvider.instance) {
10826
- new PrivyWalletProvider(appName, appLogoUrl, privyConfig);
10906
+ new PrivyWalletProvider(appName, appLogoUrl, privyConfig, networkUrl, configuredNetwork);
10827
10907
  }
10828
10908
  return PrivyWalletProvider.instance;
10829
10909
  }
@@ -10833,19 +10913,17 @@ class PrivyWalletProvider {
10833
10913
  // Build the Solana RPC transports now that we're on the async path, so
10834
10914
  // @solana/kit can be lazily imported (kept out of the entry bundle).
10835
10915
  const { createSolanaRpc, createSolanaRpcSubscriptions } = await loadSolanaKit();
10836
- if (!this.privyConfig.config.solana) {
10916
+ if (this.configuredRpcUrl && this.chainId && !this.privyConfig.config.solana) {
10837
10917
  this.privyConfig.config.solana = {};
10838
10918
  }
10839
- this.privyConfig.config.solana.rpcs = {
10840
- 'solana:devnet': {
10841
- rpc: createSolanaRpc(this.rpcDevnetUrl),
10842
- rpcSubscriptions: createSolanaRpcSubscriptions(this.rpcDevnetUrl.replace('https://', 'wss://'))
10843
- },
10844
- 'solana:mainnet': {
10845
- rpc: createSolanaRpc(this.rpcMainnetUrl),
10846
- rpcSubscriptions: createSolanaRpcSubscriptions(this.rpcMainnetUrl.replace('https://', 'wss://'))
10847
- }
10848
- };
10919
+ if (this.configuredRpcUrl && this.chainId) {
10920
+ this.privyConfig.config.solana.rpcs = {
10921
+ [this.chainId]: {
10922
+ rpc: createSolanaRpc(this.configuredRpcUrl),
10923
+ rpcSubscriptions: createSolanaRpcSubscriptions(this.configuredRpcUrl.replace('https://', 'wss://'))
10924
+ }
10925
+ };
10926
+ }
10849
10927
  // Ensure externalWallets connectors are always configured — required for
10850
10928
  // useWallets().ready to resolve even when no browser extension is present.
10851
10929
  if (!this.privyConfig.config.externalWallets && privySolana) {
@@ -11181,7 +11259,7 @@ class PrivyWalletProvider {
11181
11259
  try {
11182
11260
  if ((options === null || options === void 0 ? void 0 : options.shouldSubmitTx) === false) {
11183
11261
  // Just sign, don't submit - return raw signed bytes (same as original runTransaction)
11184
- const signedTx = await this.signTransactionRaw(tx, privyWallet);
11262
+ const signedTx = await this.signTransactionRaw(tx, privyWallet, solTransactionData.network);
11185
11263
  return {
11186
11264
  signedTransaction: signedTx, // Raw Uint8Array from Privy
11187
11265
  blockNumber: 0,
@@ -11190,7 +11268,7 @@ class PrivyWalletProvider {
11190
11268
  };
11191
11269
  }
11192
11270
  // Sign and submit using shared helper
11193
- const { signature, txInfo } = await this.signAndSubmitInternal(tx, privyWallet, rpcUrl, connection);
11271
+ const { signature, txInfo } = await this.signAndSubmitInternal(tx, privyWallet, rpcUrl, connection, solTransactionData.network);
11194
11272
  return {
11195
11273
  transactionSignature: signature,
11196
11274
  blockNumber: (txInfo === null || txInfo === void 0 ? void 0 : txInfo.slot) || 0,
@@ -11362,26 +11440,25 @@ class PrivyWalletProvider {
11362
11440
  }
11363
11441
  // ============ Private Helpers ============
11364
11442
  getRpcUrl(network) {
11365
- if (this.networkUrl) {
11366
- return this.networkUrl;
11367
- }
11368
- if (network === 'solana_devnet') {
11369
- return SOLANA_DEVNET_RPC_URL;
11370
- }
11371
- else if (network === 'solana_mainnet') {
11372
- return SOLANA_MAINNET_RPC_URL;
11443
+ return resolveSolanaRpcUrl(this.networkUrl, network !== null && network !== void 0 ? network : this.configuredNetwork, "Privy Solana transaction");
11444
+ }
11445
+ getChainId(network) {
11446
+ if (network) {
11447
+ return resolveSolanaWalletStandardChain(network, "Privy Solana transaction");
11373
11448
  }
11374
- else if (network === 'surfnet') {
11375
- return SURFNET_RPC_URL$1;
11449
+ if (this.chainId)
11450
+ return this.chainId;
11451
+ if (this.configuredNetwork) {
11452
+ return resolveSolanaWalletStandardChain(this.configuredNetwork, "Privy Solana transaction");
11376
11453
  }
11377
- return SOLANA_MAINNET_RPC_URL; // default to mainnet
11454
+ throw new Error("Privy Solana transaction requires config.chain as solana_devnet, solana_mainnet, or surfnet.");
11378
11455
  }
11379
11456
  /**
11380
11457
  * Internal sign transaction - serializes and signs via Privy
11381
11458
  * Returns the raw result from Privy (Uint8Array)
11382
11459
  * This mirrors exactly what runTransaction was doing
11383
11460
  */
11384
- async signTransactionRaw(transaction, privyWallet) {
11461
+ async signTransactionRaw(transaction, privyWallet, network) {
11385
11462
  var _a;
11386
11463
  // Serialize the transaction
11387
11464
  // Use duck typing instead of instanceof to handle multiple @solana/web3.js versions
@@ -11397,7 +11474,7 @@ class PrivyWalletProvider {
11397
11474
  const result = await ((_a = this.privyMethods) === null || _a === void 0 ? void 0 : _a.signTransaction({
11398
11475
  transaction: serializedForSign,
11399
11476
  wallet: privyWallet,
11400
- chain: this.chainId
11477
+ chain: this.getChainId(network)
11401
11478
  }));
11402
11479
  // Privy returns { signedTransaction: Uint8Array }, unwrap it
11403
11480
  const signedTx = (result === null || result === void 0 ? void 0 : result.signedTransaction) || result;
@@ -11442,13 +11519,13 @@ class PrivyWalletProvider {
11442
11519
  * For Surfnet: sign with signTransactionRaw, then sendRawTransaction
11443
11520
  * For non-Surfnet: use Privy's signAndSendTransaction (combined operation)
11444
11521
  */
11445
- async signAndSubmitInternal(transaction, privyWallet, rpcUrl, connection) {
11522
+ async signAndSubmitInternal(transaction, privyWallet, rpcUrl, connection, network) {
11446
11523
  var _a;
11447
- const isSurfnet = rpcUrl === SURFNET_RPC_URL$1;
11524
+ const isSurfnet = rpcUrl === SURFNET_RPC_URL;
11448
11525
  let signature;
11449
11526
  if (isSurfnet) {
11450
11527
  // For Surfnet: sign with signTransactionRaw, then sendRawTransaction
11451
- const signedTx = await this.signTransactionRaw(transaction, privyWallet);
11528
+ const signedTx = await this.signTransactionRaw(transaction, privyWallet, network);
11452
11529
  signature = await connection.sendRawTransaction(signedTx);
11453
11530
  }
11454
11531
  else {
@@ -11466,7 +11543,7 @@ class PrivyWalletProvider {
11466
11543
  const result = await ((_a = this.privyMethods) === null || _a === void 0 ? void 0 : _a.useSendTransactionSolana.signAndSendTransaction({
11467
11544
  transaction: serializedTx,
11468
11545
  wallet: privyWallet,
11469
- chain: this.chainId
11546
+ chain: this.getChainId(network)
11470
11547
  }));
11471
11548
  // Handle case where signature might be bytes instead of string
11472
11549
  const rawSig = result.signature;
@@ -11533,16 +11610,7 @@ class PrivyWalletProvider {
11533
11610
  }
11534
11611
  let privyWallet = this.privyMethods.wallets.find((wallet) => wallet.address === sessionAddress);
11535
11612
  if (!privyWallet) {
11536
- // Session address is not a privy wallet, just default to the first wallet
11537
- const accessToken = await this.privyMethods.getAccessToken();
11538
- await this.createSession(this.privyMethods.wallets[0].address, accessToken, this.privyMethods.identityToken);
11539
- setCurrentUser({ address: this.privyMethods.wallets[0].address, provider: this });
11540
- const session = await getActiveSessionManager().getSession();
11541
- sessionAddress = session === null || session === void 0 ? void 0 : session.address;
11542
- if (!sessionAddress) {
11543
- throw new Error('No wallet connected or logged in to sign message');
11544
- }
11545
- privyWallet = this.privyMethods.wallets[0];
11613
+ throw new Error('Active Privy wallets do not include the authenticated session wallet; please log in again.');
11546
11614
  }
11547
11615
  // Use the Privy signMessage hook for Solana wallets
11548
11616
  // The message needs to be passed as a Uint8Array
@@ -11572,22 +11640,21 @@ class PrivyWalletProvider {
11572
11640
  // Privy-specific token verification — it arrives as a Solana signature and is
11573
11641
  // recorded server-side as authMethod 'phantom'.
11574
11642
  async createSession(address, _accessToken, _idToken) {
11575
- var _a, _b, _c, _d, _e, _f, _g;
11576
- // Resolve the Privy wallet for this address (fall back to the first wallet).
11577
- const privyWallet = (_c = (_b = (_a = this.privyMethods) === null || _a === void 0 ? void 0 : _a.wallets) === null || _b === void 0 ? void 0 : _b.find((w) => w.address === address)) !== null && _c !== void 0 ? _c : (_e = (_d = this.privyMethods) === null || _d === void 0 ? void 0 : _d.wallets) === null || _e === void 0 ? void 0 : _e[0];
11643
+ var _a, _b, _c, _d;
11644
+ const privyWallet = (_b = (_a = this.privyMethods) === null || _a === void 0 ? void 0 : _a.wallets) === null || _b === void 0 ? void 0 : _b.find((w) => w.address === address);
11578
11645
  if (!privyWallet) {
11579
- throw new Error('No Privy Solana wallet available to mint a session.');
11646
+ throw new Error('No Privy Solana wallet matching the requested session address is available.');
11580
11647
  }
11581
11648
  const nonce = await genAuthNonce();
11582
11649
  const message = await genSolanaMessage(address, nonce);
11583
11650
  const messageBytes = getPlatform().textEncode(message);
11584
11651
  // Low-level Privy sign hook — signs WITHOUT touching the session (the public
11585
11652
  // signMessage() bootstraps sessions, which would recurse here).
11586
- const signResult = await ((_f = this.privyMethods) === null || _f === void 0 ? void 0 : _f.signMessage({
11653
+ const signResult = await ((_c = this.privyMethods) === null || _c === void 0 ? void 0 : _c.signMessage({
11587
11654
  message: messageBytes,
11588
11655
  wallet: privyWallet,
11589
11656
  }));
11590
- const signatureBytes = (_g = signResult === null || signResult === void 0 ? void 0 : signResult.signature) !== null && _g !== void 0 ? _g : signResult;
11657
+ const signatureBytes = (_d = signResult === null || signResult === void 0 ? void 0 : signResult.signature) !== null && _d !== void 0 ? _d : signResult;
11591
11658
  // base64-encoded detached signature (matches Phantom + guest providers).
11592
11659
  const signature = bufferExports.Buffer.from(signatureBytes).toString('base64');
11593
11660
  const createSessionResult = await createSessionWithSignature(address, message, signature);
@@ -11669,7 +11736,6 @@ var privyWalletProvider = /*#__PURE__*/Object.freeze({
11669
11736
  * to host Privy's React context, this provider expects the RN app itself
11670
11737
  * to render <PrivyProvider> and then bridge the hooks via setPrivyMethods().
11671
11738
  */
11672
- const SURFNET_RPC_URL = 'https://surfpool.fly.dev';
11673
11739
  // -----------------------------------------------------------------------
11674
11740
  // Provider implementation
11675
11741
  // -----------------------------------------------------------------------
@@ -11677,7 +11743,7 @@ class PrivyExpoProvider {
11677
11743
  constructor(appId, networkUrl = null) {
11678
11744
  this.privyMethods = null;
11679
11745
  this.appId = appId;
11680
- this.networkUrl = networkUrl;
11746
+ this.networkUrl = normalizeSolanaRpcUrl(networkUrl);
11681
11747
  }
11682
11748
  /**
11683
11749
  * Bridge Privy hooks from the app's React tree into this provider.
@@ -11962,15 +12028,7 @@ class PrivyExpoProvider {
11962
12028
  return { signature, txInfo };
11963
12029
  }
11964
12030
  getRpcUrl(network) {
11965
- if (this.networkUrl)
11966
- return this.networkUrl;
11967
- if (network === 'solana_devnet')
11968
- return SOLANA_DEVNET_RPC_URL;
11969
- if (network === 'solana_mainnet')
11970
- return SOLANA_MAINNET_RPC_URL;
11971
- if (network === 'surfnet')
11972
- return SURFNET_RPC_URL;
11973
- return SOLANA_MAINNET_RPC_URL;
12031
+ return resolveSolanaRpcUrl(this.networkUrl, network, "Privy Expo Solana transaction");
11974
12032
  }
11975
12033
  async ensureReady(timeoutMs = 15000) {
11976
12034
  if (!this.privyMethods) {