@bounded-sh/client 0.0.111 → 0.0.112-ux-audit.2

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 (67) hide show
  1. package/dist/auth/index.d.ts +3 -1
  2. package/dist/auth/oidc-auth.d.ts +3 -1
  3. package/dist/auth/providers/email-auth-provider.d.ts +1 -1
  4. package/dist/auth/providers/guest-auth-provider.d.ts +1 -1
  5. package/dist/auth/providers/injected-evm-wallet-provider.d.ts +1 -1
  6. package/dist/auth/providers/injected-wallet-provider.d.ts +1 -1
  7. package/dist/auth/providers/offchain-auth-provider.d.ts +1 -1
  8. package/dist/auth/providers/privy-expo-provider.d.ts +1 -1
  9. package/dist/{email-auth-provider-DxS2WYxM.js → email-auth-provider-53sA5_i2.js} +4 -3
  10. package/dist/email-auth-provider-53sA5_i2.js.map +1 -0
  11. package/dist/{email-auth-provider-CVp6hSCo.mjs → email-auth-provider-BfCH7K6N.mjs} +4 -3
  12. package/dist/email-auth-provider-BfCH7K6N.mjs.map +1 -0
  13. package/dist/{email-auth-provider-BfBvF_4M.mjs → email-auth-provider-C7RXLVd9.mjs} +4 -3
  14. package/dist/email-auth-provider-C7RXLVd9.mjs.map +1 -0
  15. package/dist/{email-auth-provider-CiqhQ1c2.js → email-auth-provider-DTrCfOJd.js} +4 -3
  16. package/dist/email-auth-provider-DTrCfOJd.js.map +1 -0
  17. package/dist/{guest-auth-provider-DDBXeHoo.js → guest-auth-provider-00KkSNpE.js} +10 -5
  18. package/dist/guest-auth-provider-00KkSNpE.js.map +1 -0
  19. package/dist/{guest-auth-provider-Bm_yqQF6.mjs → guest-auth-provider-2J4fnTX5.mjs} +10 -5
  20. package/dist/guest-auth-provider-2J4fnTX5.mjs.map +1 -0
  21. package/dist/{guest-auth-provider-Cc8y4Qd1.mjs → guest-auth-provider-DjOFjtnk.mjs} +10 -5
  22. package/dist/guest-auth-provider-DjOFjtnk.mjs.map +1 -0
  23. package/dist/{guest-auth-provider-D9FGNuP9.js → guest-auth-provider-Tndt6tzJ.js} +10 -5
  24. package/dist/guest-auth-provider-Tndt6tzJ.js.map +1 -0
  25. package/dist/{index-B9__gwTi.mjs → index-D3kdhCpH.mjs} +313 -84
  26. package/dist/index-D3kdhCpH.mjs.map +1 -0
  27. package/dist/{index-BghQ8jX0.js → index-DJeEMevo.js} +312 -83
  28. package/dist/index-DJeEMevo.js.map +1 -0
  29. package/dist/index.js +1 -1
  30. package/dist/index.mjs +1 -1
  31. package/dist/{index.native-BHjpXkKQ.mjs → index.native-CAH_ks0s.mjs} +200 -56
  32. package/dist/index.native-CAH_ks0s.mjs.map +1 -0
  33. package/dist/{index.native-B_AFa0GD.js → index.native-ingNhWPw.js} +199 -55
  34. package/dist/index.native-ingNhWPw.js.map +1 -0
  35. package/dist/index.native.js +1 -1
  36. package/dist/index.native.mjs +1 -1
  37. package/dist/{injected-evm-wallet-provider-CIeCSOPL.mjs → injected-evm-wallet-provider-BtyG1HOX.mjs} +4 -3
  38. package/dist/injected-evm-wallet-provider-BtyG1HOX.mjs.map +1 -0
  39. package/dist/{injected-evm-wallet-provider-DeLUwvGs.js → injected-evm-wallet-provider-Cao1U0NZ.js} +4 -3
  40. package/dist/{injected-evm-wallet-provider-DeLUwvGs.js.map → injected-evm-wallet-provider-Cao1U0NZ.js.map} +1 -1
  41. package/dist/{injected-evm-wallet-provider-BUjqxQxp.mjs → injected-evm-wallet-provider-DXjwPjLW.mjs} +4 -3
  42. package/dist/{injected-evm-wallet-provider-BUjqxQxp.mjs.map → injected-evm-wallet-provider-DXjwPjLW.mjs.map} +1 -1
  43. package/dist/{injected-evm-wallet-provider-Ckb85p6a.js → injected-evm-wallet-provider-IlkuKffc.js} +4 -3
  44. package/dist/injected-evm-wallet-provider-IlkuKffc.js.map +1 -0
  45. package/dist/{injected-wallet-provider-BlzA0J_V.mjs → injected-wallet-provider-0SSONh1d.mjs} +4 -3
  46. package/dist/{injected-wallet-provider-BlzA0J_V.mjs.map → injected-wallet-provider-0SSONh1d.mjs.map} +1 -1
  47. package/dist/{injected-wallet-provider-Cfb4ayCP.js → injected-wallet-provider-BEYwsn6M.js} +4 -3
  48. package/dist/{injected-wallet-provider-Cfb4ayCP.js.map → injected-wallet-provider-BEYwsn6M.js.map} +1 -1
  49. package/dist/{injected-wallet-provider-BEuj4sM3.mjs → injected-wallet-provider-CfYNIIHd.mjs} +4 -3
  50. package/dist/{injected-wallet-provider-BEuj4sM3.mjs.map → injected-wallet-provider-CfYNIIHd.mjs.map} +1 -1
  51. package/dist/{injected-wallet-provider-CUKdAuFu.js → injected-wallet-provider-DSlHfgMU.js} +4 -3
  52. package/dist/{injected-wallet-provider-CUKdAuFu.js.map → injected-wallet-provider-DSlHfgMU.js.map} +1 -1
  53. package/package.json +2 -2
  54. package/dist/email-auth-provider-BfBvF_4M.mjs.map +0 -1
  55. package/dist/email-auth-provider-CVp6hSCo.mjs.map +0 -1
  56. package/dist/email-auth-provider-CiqhQ1c2.js.map +0 -1
  57. package/dist/email-auth-provider-DxS2WYxM.js.map +0 -1
  58. package/dist/guest-auth-provider-Bm_yqQF6.mjs.map +0 -1
  59. package/dist/guest-auth-provider-Cc8y4Qd1.mjs.map +0 -1
  60. package/dist/guest-auth-provider-D9FGNuP9.js.map +0 -1
  61. package/dist/guest-auth-provider-DDBXeHoo.js.map +0 -1
  62. package/dist/index-B9__gwTi.mjs.map +0 -1
  63. package/dist/index-BghQ8jX0.js.map +0 -1
  64. package/dist/index.native-BHjpXkKQ.mjs.map +0 -1
  65. package/dist/index.native-B_AFa0GD.js.map +0 -1
  66. package/dist/injected-evm-wallet-provider-CIeCSOPL.mjs.map +0 -1
  67. package/dist/injected-evm-wallet-provider-Ckb85p6a.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index_native = require('./index.native-B_AFa0GD.js');
3
+ var index_native = require('./index.native-ingNhWPw.js');
4
4
  var core = require('@bounded-sh/core');
5
5
  require('react');
6
6
 
@@ -1,4 +1,4 @@
1
- export { a1 as BUILD_DELEGATED_REVIEW_CAPABILITY_SCHEMA, a0 as BUILD_REVIEW_CAPABILITY_REFRESH_SCHEMA, $ as BUILD_REVIEW_CAPABILITY_SCHEMA, U as BuildsApiError, _ as FAILURE_REASONS, W as NON_TERMINAL_STATES, R as OffchainAuthProvider, Z as PARK_REASONS, S as PrivyExpoProvider, Y as RUN_STATES, X as TERMINAL_STATES, L as apps, T as builds, F as completeLoginFromRedirect, x as getAuthLoading, B as getAuthProvider, u as getCurrentUser, M as getIdToken, G as getLoginReturnError, g as getPlatform, q as init, z as login, H as loginWithPopup, D as loginWithPrivy, E as loginWithRedirect, A as logout, V as mediaAgentTools, w as onAuthLoadingChanged, v as onAuthStateChanged, N as onramp, O as onrampQuote, P as onrampStatus, Q as setPlatform, C as signInAnonymously, I as useAuth, K as useBuildRun, J as useQuery, y as waitForAuthReady } from './index.native-BHjpXkKQ.mjs';
1
+ export { a1 as BUILD_DELEGATED_REVIEW_CAPABILITY_SCHEMA, a0 as BUILD_REVIEW_CAPABILITY_REFRESH_SCHEMA, $ as BUILD_REVIEW_CAPABILITY_SCHEMA, U as BuildsApiError, _ as FAILURE_REASONS, W as NON_TERMINAL_STATES, R as OffchainAuthProvider, Z as PARK_REASONS, S as PrivyExpoProvider, Y as RUN_STATES, X as TERMINAL_STATES, L as apps, T as builds, F as completeLoginFromRedirect, x as getAuthLoading, B as getAuthProvider, u as getCurrentUser, M as getIdToken, G as getLoginReturnError, g as getPlatform, q as init, z as login, H as loginWithPopup, D as loginWithPrivy, E as loginWithRedirect, A as logout, V as mediaAgentTools, w as onAuthLoadingChanged, v as onAuthStateChanged, N as onramp, O as onrampQuote, P as onrampStatus, Q as setPlatform, C as signInAnonymously, I as useAuth, K as useBuildRun, J as useQuery, y as waitForAuthReady } from './index.native-CAH_ks0s.mjs';
2
2
  export * from '@bounded-sh/core';
3
3
  export { AppTokenExchangeError, BoundedDeclineError, DECLINE_EVENT_NAME, ScopedClientReadOnlyError, aggregate, clearAppTokenCache, count, createAppTokenAuthHeaders, createClient, deriveDecline, dispatchDeclineEvent, docId, exchangeAppToken, get, getConfig, getFiles, getMany, queryAggregate, reconcileSetResult, runExpression, runExpressionMany, runQuery, runQueryMany, search, set, setFile, setMany, signAndSubmitTransaction, signMessage, signTransaction, subscribe, waitForSetResult } from '@bounded-sh/core';
4
4
  import 'react';
@@ -1,5 +1,5 @@
1
1
  import { normalizeEvmAddress, getActiveSessionManager, genAuthNonce, getConfig, genSiweMessage, createSessionWithSignature } from '@bounded-sh/core';
2
- import { o as defaultInjectedEvmProvider, j as setAuthLoading, s as setCurrentUser, l as setStoredAuthMethod } from './index-B9__gwTi.mjs';
2
+ import { o as defaultInjectedEvmProvider, j as setAuthLoading, s as setCurrentUser, l as setStoredAuthMethod } from './index-D3kdhCpH.mjs';
3
3
  import 'react';
4
4
 
5
5
  // Must equal the authMethod the registry (auth/index.ts) sets as currentAuthMethod,
@@ -134,8 +134,9 @@ class InjectedEvmWalletProvider {
134
134
  markAuthMethod() {
135
135
  setStoredAuthMethod(INJECTED_EVM_AUTH_METHOD);
136
136
  }
137
- async restoreSession() {
137
+ async restoreSession(beforeCommit) {
138
138
  const session = await getActiveSessionManager().getSession();
139
+ beforeCommit === null || beforeCommit === void 0 ? void 0 : beforeCommit();
139
140
  if (!session)
140
141
  return null;
141
142
  // An EVM-wallet session stores the EVM address as its address; @user.address
@@ -182,4 +183,4 @@ class InjectedEvmWalletProvider {
182
183
  InjectedEvmWalletProvider.instance = null;
183
184
 
184
185
  export { InjectedEvmWalletProvider, defaultInjectedEvmProvider };
185
- //# sourceMappingURL=injected-evm-wallet-provider-CIeCSOPL.mjs.map
186
+ //# sourceMappingURL=injected-evm-wallet-provider-BtyG1HOX.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"injected-evm-wallet-provider-BtyG1HOX.mjs","sources":["../.rollup-tmp/auth/providers/injected-evm-wallet-provider.js"],"sourcesContent":["import { getActiveSessionManager as SessionManager, createSessionWithSignature, genAuthNonce, genSiweMessage, getConfig, normalizeEvmAddress, } from '@bounded-sh/core';\nimport { setCurrentUser, setAuthLoading } from '../../global';\nimport { setStoredAuthMethod } from '../stored-auth-method';\nimport { defaultInjectedEvmProvider, } from './injected-evm-wallet-types';\n// Re-export the type surface + discovery helper for callers who import the\n// provider module directly.\nexport { defaultInjectedEvmProvider };\n// Must equal the authMethod the registry (auth/index.ts) sets as currentAuthMethod,\n// so clearIncompatibleSession() keeps (not wipes) this session on the next init().\nconst INJECTED_EVM_AUTH_METHOD = 'evm-wallet';\n// The /session issuer's discriminator for the SIWE (EIP-4361 secp256k1) exchange.\nconst SIWE_SESSION_METHOD = 'siwe';\nconst NO_WALLET_ERR = 'No injected EVM wallet found. Install a wallet like MetaMask (metamask.io) or Rabby and try again, ' +\n 'or pass config.evmWalletConfig.getProvider to point at your wallet.';\nconst NO_SOL_TX_ERR = 'EVM wallet login is a LOGIN-ONLY surface (SIWE + personal_sign) and has no Solana ' +\n 'transaction surface: signTransaction/signAndSubmitTransaction are unavailable.';\nfunction normalizeConfig(config) {\n if (config.chainId !== undefined && (!Number.isSafeInteger(config.chainId) || config.chainId <= 0)) {\n throw new Error('EVM wallet chainId must be a positive safe integer');\n }\n return Object.assign({}, config);\n}\nexport class InjectedEvmWalletProvider {\n constructor(config = {}) {\n this.authenticatedAddress = null;\n if (typeof window === 'undefined') {\n throw new Error('InjectedEvmWalletProvider can only be instantiated in a browser environment');\n }\n const normalized = normalizeConfig(config);\n // Singleton so the SDK reuses one instance (mirrors the other providers).\n if (InjectedEvmWalletProvider.instance) {\n InjectedEvmWalletProvider.instance.config = normalized;\n InjectedEvmWalletProvider.instance.authenticatedAddress = null;\n return InjectedEvmWalletProvider.instance;\n }\n this.config = normalized;\n InjectedEvmWalletProvider.instance = this;\n }\n // @user.address (the Solana wallet) is null for an EVM-wallet login: the user\n // authenticated with an EVM wallet and has no Solana address. User.address is\n // typed `string | null`, so this is a plain null, not a cast.\n evmUser(address) {\n return { id: address, address: null, evmAddress: address, provider: this };\n }\n resolveProvider() {\n var _a;\n const provider = (_a = (this.config.getProvider ? this.config.getProvider() : null)) !== null && _a !== void 0 ? _a : defaultInjectedEvmProvider();\n if (!provider)\n throw new Error(NO_WALLET_ERR);\n return provider;\n }\n /** Connect the injected wallet and return its canonical lowercase EVM address. */\n async connectAddress(provider) {\n const accounts = await provider.request({ method: 'eth_requestAccounts' });\n const raw = Array.isArray(accounts) ? accounts[0] : undefined;\n const address = normalizeEvmAddress(raw);\n if (!address)\n throw new Error('Wallet did not return a valid EVM address on connect');\n return address;\n }\n /** Current chain id the wallet is connected to (EIP-155 number), or null. */\n async currentChainId(provider) {\n try {\n const hex = await provider.request({ method: 'eth_chainId' });\n if (typeof hex !== 'string' || !/^0x[0-9a-fA-F]+$/.test(hex))\n return null;\n const n = Number(BigInt(hex));\n return Number.isSafeInteger(n) && n > 0 ? n : null;\n }\n catch (_a) {\n return null;\n }\n }\n async login() {\n var _a;\n setAuthLoading(true);\n try {\n const provider = this.resolveProvider();\n const address = await this.connectAddress(provider);\n // Reuse a still-valid session for THIS wallet.\n const existing = await SessionManager().getSession();\n if (existing && existing.address === address) {\n const user = this.evmUser(address);\n this.authenticatedAddress = address;\n setCurrentUser(user);\n this.markAuthMethod();\n return user;\n }\n // SIWE: nonce -> canonical EIP-4361 prompt -> the wallet personal_sign's it.\n const nonce = await genAuthNonce();\n const appId = (await getConfig()).appId;\n const chainId = (_a = this.config.chainId) !== null && _a !== void 0 ? _a : await this.currentChainId(provider);\n if (chainId === null)\n throw new Error('Could not verify the EVM wallet chain for SIWE login');\n const message = genSiweMessage(address, nonce, appId, this.resolveDomain(), this.resolveUri(), { chainId });\n // personal_sign(message, address) -> 0x r‖s‖v hex (the shape the\n // bounded-auth verifier's recoverSiweSigner consumes). The raw UTF-8\n // message is signed under the EIP-191 envelope the verifier hashes.\n const signature = await provider.request({\n method: 'personal_sign',\n params: [message, address],\n });\n const result = await createSessionWithSignature(address, message, signature, SIWE_SESSION_METHOD);\n await SessionManager().storeSession(address, result.accessToken, result.idToken, result.refreshToken);\n this.markAuthMethod();\n const user = this.evmUser(address);\n this.authenticatedAddress = address;\n setCurrentUser(user);\n return user;\n }\n finally {\n setAuthLoading(false);\n }\n }\n resolveDomain() {\n const actual = window.location.host.toLowerCase();\n if (this.config.domain && this.config.domain.toLowerCase() !== actual) {\n throw new Error('SIWE domain override must match the current browser origin');\n }\n return actual;\n }\n resolveUri() {\n const actual = window.location.origin.toLowerCase();\n if (this.config.uri) {\n let configured;\n try {\n configured = new URL(this.config.uri).origin.toLowerCase();\n }\n catch (_a) {\n throw new Error('SIWE URI override must be an absolute URL');\n }\n if (configured !== actual)\n throw new Error('SIWE URI override must match the current browser origin');\n }\n return actual;\n }\n markAuthMethod() {\n setStoredAuthMethod(INJECTED_EVM_AUTH_METHOD);\n }\n async restoreSession(beforeCommit) {\n const session = await SessionManager().getSession();\n beforeCommit === null || beforeCommit === void 0 ? void 0 : beforeCommit();\n if (!session)\n return null;\n // An EVM-wallet session stores the EVM address as its address; @user.address\n // (the Solana wallet) is null for this login.\n const address = normalizeEvmAddress(session.address);\n if (!address) {\n await SessionManager().clearSession();\n return null;\n }\n this.authenticatedAddress = address;\n const user = this.evmUser(address);\n setCurrentUser(user);\n return user;\n }\n async logout() {\n // EIP-1193 has no standard disconnect; clearing the Bounded session is the\n // logout. (wallet_revokePermissions is non-standard/opt-in — skip it.)\n await SessionManager().clearSession();\n this.authenticatedAddress = null;\n setCurrentUser(null);\n }\n // --- Signing surface -------------------------------------------------------\n /** App-facing message signing: EIP-191 personal_sign, returns 0x r‖s‖v hex. */\n async signMessage(message) {\n const provider = this.resolveProvider();\n const address = await this.connectAddress(provider);\n if (!this.authenticatedAddress || address !== this.authenticatedAddress) {\n throw new Error('The connected EVM wallet account changed after login. Sign in again before signing.');\n }\n return provider.request({ method: 'personal_sign', params: [message, address] });\n }\n // Solana-typed methods are structurally unsupported on an EVM wallet, and\n // this provider is login-only, so there is no transaction surface at all.\n async signTransaction(_transaction) {\n throw new Error(NO_SOL_TX_ERR);\n }\n async signAndSubmitTransaction(_transaction, _feePayer) {\n throw new Error(NO_SOL_TX_ERR);\n }\n async getNativeMethods() {\n return this.resolveProvider();\n }\n}\nInjectedEvmWalletProvider.instance = null;\n"],"names":["SessionManager"],"mappings":";;;;AAOA;AACA;AACA,MAAM,wBAAwB,GAAG,YAAY;AAC7C;AACA,MAAM,mBAAmB,GAAG,MAAM;AAClC,MAAM,aAAa,GAAG,qGAAqG;AAC3H,IAAI,qEAAqE;AACzE,MAAM,aAAa,GAAG,oFAAoF;AAC1G,IAAI,gFAAgF;AACpF,SAAS,eAAe,CAAC,MAAM,EAAE;AACjC,IAAI,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,IAAI,CAAC,CAAC,EAAE;AACxG,QAAQ,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC;AAC7E,IAAI;AACJ,IAAI,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC;AACpC;AACO,MAAM,yBAAyB,CAAC;AACvC,IAAI,WAAW,CAAC,MAAM,GAAG,EAAE,EAAE;AAC7B,QAAQ,IAAI,CAAC,oBAAoB,GAAG,IAAI;AACxC,QAAQ,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AAC3C,YAAY,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC;AAC1G,QAAQ;AACR,QAAQ,MAAM,UAAU,GAAG,eAAe,CAAC,MAAM,CAAC;AAClD;AACA,QAAQ,IAAI,yBAAyB,CAAC,QAAQ,EAAE;AAChD,YAAY,yBAAyB,CAAC,QAAQ,CAAC,MAAM,GAAG,UAAU;AAClE,YAAY,yBAAyB,CAAC,QAAQ,CAAC,oBAAoB,GAAG,IAAI;AAC1E,YAAY,OAAO,yBAAyB,CAAC,QAAQ;AACr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,IAAI;AACJ;AACA,yBAAyB,CAAC,QAAQ,GAAG,IAAI;;;;"}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var core = require('@bounded-sh/core');
4
- var index_native = require('./index.native-B_AFa0GD.js');
4
+ var index_native = require('./index.native-ingNhWPw.js');
5
5
  require('react');
6
6
 
7
7
  // injected-evm-wallet-types.ts — tiny, dependency-free surface for the EVM
@@ -202,8 +202,9 @@ class InjectedEvmWalletProvider {
202
202
  markAuthMethod() {
203
203
  index_native.setStoredAuthMethod(INJECTED_EVM_AUTH_METHOD);
204
204
  }
205
- async restoreSession() {
205
+ async restoreSession(beforeCommit) {
206
206
  const session = await core.getActiveSessionManager().getSession();
207
+ beforeCommit === null || beforeCommit === void 0 ? void 0 : beforeCommit();
207
208
  if (!session)
208
209
  return null;
209
210
  // An EVM-wallet session stores the EVM address as its address; @user.address
@@ -251,4 +252,4 @@ InjectedEvmWalletProvider.instance = null;
251
252
 
252
253
  exports.InjectedEvmWalletProvider = InjectedEvmWalletProvider;
253
254
  exports.defaultInjectedEvmProvider = defaultInjectedEvmProvider;
254
- //# sourceMappingURL=injected-evm-wallet-provider-DeLUwvGs.js.map
255
+ //# sourceMappingURL=injected-evm-wallet-provider-Cao1U0NZ.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"injected-evm-wallet-provider-DeLUwvGs.js","sources":["../.rollup-tmp/auth/providers/injected-evm-wallet-types.js","../.rollup-tmp/auth/providers/injected-evm-wallet-provider.js"],"sourcesContent":["// injected-evm-wallet-types.ts — tiny, dependency-free surface for the EVM\n// WALLET LOGIN path (BYO wallet via SIWE). The EVM twin of\n// injected-wallet-types.ts: kept separate from injected-evm-wallet-provider.ts\n// so the SDK entry can eagerly export the type surface + the provider-discovery\n// helper WITHOUT dragging the provider class into the default bundle. The\n// provider is lazy-loaded by getAuthProvider() when an app opts into\n// authMethod:'evm-wallet'.\n//\n// It rides the standard EIP-1193 injected provider a browser wallet exposes\n// (MetaMask / Rabby / Coinbase Wallet / any window.ethereum), discovered via\n// EIP-6963 (multi-wallet, collision-free) with a window.ethereum fallback. It\n// needs NO viem/ethers and NO React — EIP-1193 request() + hex strings suffice.\n// EIP-6963 is announcement-based: wallets add an `eip6963:requestProvider`\n// listener and synchronously dispatch `eip6963:announceProvider` in response. We\n// keep a persistent collector so announcements (including late ones) are\n// captured, and re-request on demand.\nconst announcedProviders = [];\nlet announceListenerAttached = false;\nfunction attachAnnounceListener() {\n if (announceListenerAttached || typeof window === 'undefined')\n return;\n announceListenerAttached = true;\n window.addEventListener('eip6963:announceProvider', (event) => {\n const detail = event === null || event === void 0 ? void 0 : event.detail;\n if (detail &&\n detail.provider &&\n typeof detail.provider.request === 'function' &&\n !announcedProviders.some((d) => { var _a, _b; return ((_a = d.info) === null || _a === void 0 ? void 0 : _a.uuid) === ((_b = detail.info) === null || _b === void 0 ? void 0 : _b.uuid); })) {\n announcedProviders.push(detail);\n }\n });\n}\n/**\n * Request + collect EIP-6963 providers. Dispatches `eip6963:requestProvider`\n * (synchronous — already-loaded wallets announce in the same tick) and returns\n * every wallet announced so far. Kept synchronous so it works inside a user\n * gesture and can be eagerly exported from the SDK entry.\n */\nexport function requestEip6963Providers() {\n if (typeof window === 'undefined')\n return [];\n attachAnnounceListener();\n try {\n window.dispatchEvent(new Event('eip6963:requestProvider'));\n }\n catch (_a) {\n /* older browsers without Event constructor — fall through to window.ethereum */\n }\n return announcedProviders.slice();\n}\n/**\n * Default EVM provider discovery: EIP-6963 first (multi-wallet, collision-free),\n * then legacy `window.ethereum`. Returns null when no injected wallet is present.\n */\nexport function defaultInjectedEvmProvider() {\n if (typeof window === 'undefined')\n return null;\n const details = requestEip6963Providers();\n if (details.length > 0)\n return details[0].provider;\n const eth = window.ethereum;\n if (eth && typeof eth.request === 'function')\n return eth;\n return null;\n}\n","import { getActiveSessionManager as SessionManager, createSessionWithSignature, genAuthNonce, genSiweMessage, getConfig, normalizeEvmAddress, } from '@bounded-sh/core';\nimport { setCurrentUser, setAuthLoading } from '../../global';\nimport { setStoredAuthMethod } from '../stored-auth-method';\nimport { defaultInjectedEvmProvider, } from './injected-evm-wallet-types';\n// Re-export the type surface + discovery helper for callers who import the\n// provider module directly.\nexport { defaultInjectedEvmProvider };\n// Must equal the authMethod the registry (auth/index.ts) sets as currentAuthMethod,\n// so clearIncompatibleSession() keeps (not wipes) this session on the next init().\nconst INJECTED_EVM_AUTH_METHOD = 'evm-wallet';\n// The /session issuer's discriminator for the SIWE (EIP-4361 secp256k1) exchange.\nconst SIWE_SESSION_METHOD = 'siwe';\nconst NO_WALLET_ERR = 'No injected EVM wallet found. Install a wallet like MetaMask (metamask.io) or Rabby and try again, ' +\n 'or pass config.evmWalletConfig.getProvider to point at your wallet.';\nconst NO_SOL_TX_ERR = 'EVM wallet login is a LOGIN-ONLY surface (SIWE + personal_sign) and has no Solana ' +\n 'transaction surface: signTransaction/signAndSubmitTransaction are unavailable.';\nfunction normalizeConfig(config) {\n if (config.chainId !== undefined && (!Number.isSafeInteger(config.chainId) || config.chainId <= 0)) {\n throw new Error('EVM wallet chainId must be a positive safe integer');\n }\n return Object.assign({}, config);\n}\nexport class InjectedEvmWalletProvider {\n constructor(config = {}) {\n this.authenticatedAddress = null;\n if (typeof window === 'undefined') {\n throw new Error('InjectedEvmWalletProvider can only be instantiated in a browser environment');\n }\n const normalized = normalizeConfig(config);\n // Singleton so the SDK reuses one instance (mirrors the other providers).\n if (InjectedEvmWalletProvider.instance) {\n InjectedEvmWalletProvider.instance.config = normalized;\n InjectedEvmWalletProvider.instance.authenticatedAddress = null;\n return InjectedEvmWalletProvider.instance;\n }\n this.config = normalized;\n InjectedEvmWalletProvider.instance = this;\n }\n // @user.address (the Solana wallet) is null for an EVM-wallet login: the user\n // authenticated with an EVM wallet and has no Solana address. User.address is\n // typed `string | null`, so this is a plain null, not a cast.\n evmUser(address) {\n return { id: address, address: null, evmAddress: address, provider: this };\n }\n resolveProvider() {\n var _a;\n const provider = (_a = (this.config.getProvider ? this.config.getProvider() : null)) !== null && _a !== void 0 ? _a : defaultInjectedEvmProvider();\n if (!provider)\n throw new Error(NO_WALLET_ERR);\n return provider;\n }\n /** Connect the injected wallet and return its canonical lowercase EVM address. */\n async connectAddress(provider) {\n const accounts = await provider.request({ method: 'eth_requestAccounts' });\n const raw = Array.isArray(accounts) ? accounts[0] : undefined;\n const address = normalizeEvmAddress(raw);\n if (!address)\n throw new Error('Wallet did not return a valid EVM address on connect');\n return address;\n }\n /** Current chain id the wallet is connected to (EIP-155 number), or null. */\n async currentChainId(provider) {\n try {\n const hex = await provider.request({ method: 'eth_chainId' });\n if (typeof hex !== 'string' || !/^0x[0-9a-fA-F]+$/.test(hex))\n return null;\n const n = Number(BigInt(hex));\n return Number.isSafeInteger(n) && n > 0 ? n : null;\n }\n catch (_a) {\n return null;\n }\n }\n async login() {\n var _a;\n setAuthLoading(true);\n try {\n const provider = this.resolveProvider();\n const address = await this.connectAddress(provider);\n // Reuse a still-valid session for THIS wallet.\n const existing = await SessionManager().getSession();\n if (existing && existing.address === address) {\n const user = this.evmUser(address);\n this.authenticatedAddress = address;\n setCurrentUser(user);\n this.markAuthMethod();\n return user;\n }\n // SIWE: nonce -> canonical EIP-4361 prompt -> the wallet personal_sign's it.\n const nonce = await genAuthNonce();\n const appId = (await getConfig()).appId;\n const chainId = (_a = this.config.chainId) !== null && _a !== void 0 ? _a : await this.currentChainId(provider);\n if (chainId === null)\n throw new Error('Could not verify the EVM wallet chain for SIWE login');\n const message = genSiweMessage(address, nonce, appId, this.resolveDomain(), this.resolveUri(), { chainId });\n // personal_sign(message, address) -> 0x r‖s‖v hex (the shape the\n // bounded-auth verifier's recoverSiweSigner consumes). The raw UTF-8\n // message is signed under the EIP-191 envelope the verifier hashes.\n const signature = await provider.request({\n method: 'personal_sign',\n params: [message, address],\n });\n const result = await createSessionWithSignature(address, message, signature, SIWE_SESSION_METHOD);\n await SessionManager().storeSession(address, result.accessToken, result.idToken, result.refreshToken);\n this.markAuthMethod();\n const user = this.evmUser(address);\n this.authenticatedAddress = address;\n setCurrentUser(user);\n return user;\n }\n finally {\n setAuthLoading(false);\n }\n }\n resolveDomain() {\n const actual = window.location.host.toLowerCase();\n if (this.config.domain && this.config.domain.toLowerCase() !== actual) {\n throw new Error('SIWE domain override must match the current browser origin');\n }\n return actual;\n }\n resolveUri() {\n const actual = window.location.origin.toLowerCase();\n if (this.config.uri) {\n let configured;\n try {\n configured = new URL(this.config.uri).origin.toLowerCase();\n }\n catch (_a) {\n throw new Error('SIWE URI override must be an absolute URL');\n }\n if (configured !== actual)\n throw new Error('SIWE URI override must match the current browser origin');\n }\n return actual;\n }\n markAuthMethod() {\n setStoredAuthMethod(INJECTED_EVM_AUTH_METHOD);\n }\n async restoreSession() {\n const session = await SessionManager().getSession();\n if (!session)\n return null;\n // An EVM-wallet session stores the EVM address as its address; @user.address\n // (the Solana wallet) is null for this login.\n const address = normalizeEvmAddress(session.address);\n if (!address) {\n await SessionManager().clearSession();\n return null;\n }\n this.authenticatedAddress = address;\n const user = this.evmUser(address);\n setCurrentUser(user);\n return user;\n }\n async logout() {\n // EIP-1193 has no standard disconnect; clearing the Bounded session is the\n // logout. (wallet_revokePermissions is non-standard/opt-in — skip it.)\n await SessionManager().clearSession();\n this.authenticatedAddress = null;\n setCurrentUser(null);\n }\n // --- Signing surface -------------------------------------------------------\n /** App-facing message signing: EIP-191 personal_sign, returns 0x r‖s‖v hex. */\n async signMessage(message) {\n const provider = this.resolveProvider();\n const address = await this.connectAddress(provider);\n if (!this.authenticatedAddress || address !== this.authenticatedAddress) {\n throw new Error('The connected EVM wallet account changed after login. Sign in again before signing.');\n }\n return provider.request({ method: 'personal_sign', params: [message, address] });\n }\n // Solana-typed methods are structurally unsupported on an EVM wallet, and\n // this provider is login-only, so there is no transaction surface at all.\n async signTransaction(_transaction) {\n throw new Error(NO_SOL_TX_ERR);\n }\n async signAndSubmitTransaction(_transaction, _feePayer) {\n throw new Error(NO_SOL_TX_ERR);\n }\n async getNativeMethods() {\n return this.resolveProvider();\n }\n}\nInjectedEvmWalletProvider.instance = null;\n"],"names":["normalizeEvmAddress","setAuthLoading","SessionManager","setCurrentUser","genAuthNonce","getConfig","genSiweMessage","createSessionWithSignature","setStoredAuthMethod"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,kBAAkB,GAAG,EAAE;AAC7B,IAAI,wBAAwB,GAAG,KAAK;AACpC,SAAS,sBAAsB,GAAG;AAClC,IAAI,IAAI,wBAAwB,IAAI,OAAO,MAAM,KAAK,WAAW;AACjE,QAAQ;AACR,IAAI,wBAAwB,GAAG,IAAI;AACnC,IAAI,MAAM,CAAC,gBAAgB,CAAC,0BAA0B,EAAE,CAAC,KAAK,KAAK;AACnE,QAAQ,MAAM,MAAM,GAAG,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM;AACjF,QAAQ,IAAI,MAAM;AAClB,YAAY,MAAM,CAAC,QAAQ;AAC3B,YAAY,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,KAAK,UAAU;AACzD,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;AACzM,YAAY,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC;AAC3C,QAAQ;AACR,IAAI,CAAC,CAAC;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AAC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AC;AAClH,QAAQ;AACR,QAAQ,OAAO,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC;AACxF,IAAI;AACJ;AACA;AACA,IAAI,MAAM,eAAe,CAAC,YAAY,EAAE;AACxC,QAAQ,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC;AACtC,IAAI;AACJ,IAAI,MAAM,wBAAwB,CAAC,YAAY,EAAE,SAAS,EAAE;AAC5D,QAAQ,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC;AACtC,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,IAAI,CAAC,eAAe,EAAE;AACrC,IAAI;AACJ;AACA,yBAAyB,CAAC,QAAQ,GAAG,IAAI;;;;;"}
1
+ {"version":3,"file":"injected-evm-wallet-provider-Cao1U0NZ.js","sources":["../.rollup-tmp/auth/providers/injected-evm-wallet-types.js","../.rollup-tmp/auth/providers/injected-evm-wallet-provider.js"],"sourcesContent":["// injected-evm-wallet-types.ts — tiny, dependency-free surface for the EVM\n// WALLET LOGIN path (BYO wallet via SIWE). The EVM twin of\n// injected-wallet-types.ts: kept separate from injected-evm-wallet-provider.ts\n// so the SDK entry can eagerly export the type surface + the provider-discovery\n// helper WITHOUT dragging the provider class into the default bundle. The\n// provider is lazy-loaded by getAuthProvider() when an app opts into\n// authMethod:'evm-wallet'.\n//\n// It rides the standard EIP-1193 injected provider a browser wallet exposes\n// (MetaMask / Rabby / Coinbase Wallet / any window.ethereum), discovered via\n// EIP-6963 (multi-wallet, collision-free) with a window.ethereum fallback. It\n// needs NO viem/ethers and NO React — EIP-1193 request() + hex strings suffice.\n// EIP-6963 is announcement-based: wallets add an `eip6963:requestProvider`\n// listener and synchronously dispatch `eip6963:announceProvider` in response. We\n// keep a persistent collector so announcements (including late ones) are\n// captured, and re-request on demand.\nconst announcedProviders = [];\nlet announceListenerAttached = false;\nfunction attachAnnounceListener() {\n if (announceListenerAttached || typeof window === 'undefined')\n return;\n announceListenerAttached = true;\n window.addEventListener('eip6963:announceProvider', (event) => {\n const detail = event === null || event === void 0 ? void 0 : event.detail;\n if (detail &&\n detail.provider &&\n typeof detail.provider.request === 'function' &&\n !announcedProviders.some((d) => { var _a, _b; return ((_a = d.info) === null || _a === void 0 ? void 0 : _a.uuid) === ((_b = detail.info) === null || _b === void 0 ? void 0 : _b.uuid); })) {\n announcedProviders.push(detail);\n }\n });\n}\n/**\n * Request + collect EIP-6963 providers. Dispatches `eip6963:requestProvider`\n * (synchronous — already-loaded wallets announce in the same tick) and returns\n * every wallet announced so far. Kept synchronous so it works inside a user\n * gesture and can be eagerly exported from the SDK entry.\n */\nexport function requestEip6963Providers() {\n if (typeof window === 'undefined')\n return [];\n attachAnnounceListener();\n try {\n window.dispatchEvent(new Event('eip6963:requestProvider'));\n }\n catch (_a) {\n /* older browsers without Event constructor — fall through to window.ethereum */\n }\n return announcedProviders.slice();\n}\n/**\n * Default EVM provider discovery: EIP-6963 first (multi-wallet, collision-free),\n * then legacy `window.ethereum`. Returns null when no injected wallet is present.\n */\nexport function defaultInjectedEvmProvider() {\n if (typeof window === 'undefined')\n return null;\n const details = requestEip6963Providers();\n if (details.length > 0)\n return details[0].provider;\n const eth = window.ethereum;\n if (eth && typeof eth.request === 'function')\n return eth;\n return null;\n}\n","import { getActiveSessionManager as SessionManager, createSessionWithSignature, genAuthNonce, genSiweMessage, getConfig, normalizeEvmAddress, } from '@bounded-sh/core';\nimport { setCurrentUser, setAuthLoading } from '../../global';\nimport { setStoredAuthMethod } from '../stored-auth-method';\nimport { defaultInjectedEvmProvider, } from './injected-evm-wallet-types';\n// Re-export the type surface + discovery helper for callers who import the\n// provider module directly.\nexport { defaultInjectedEvmProvider };\n// Must equal the authMethod the registry (auth/index.ts) sets as currentAuthMethod,\n// so clearIncompatibleSession() keeps (not wipes) this session on the next init().\nconst INJECTED_EVM_AUTH_METHOD = 'evm-wallet';\n// The /session issuer's discriminator for the SIWE (EIP-4361 secp256k1) exchange.\nconst SIWE_SESSION_METHOD = 'siwe';\nconst NO_WALLET_ERR = 'No injected EVM wallet found. Install a wallet like MetaMask (metamask.io) or Rabby and try again, ' +\n 'or pass config.evmWalletConfig.getProvider to point at your wallet.';\nconst NO_SOL_TX_ERR = 'EVM wallet login is a LOGIN-ONLY surface (SIWE + personal_sign) and has no Solana ' +\n 'transaction surface: signTransaction/signAndSubmitTransaction are unavailable.';\nfunction normalizeConfig(config) {\n if (config.chainId !== undefined && (!Number.isSafeInteger(config.chainId) || config.chainId <= 0)) {\n throw new Error('EVM wallet chainId must be a positive safe integer');\n }\n return Object.assign({}, config);\n}\nexport class InjectedEvmWalletProvider {\n constructor(config = {}) {\n this.authenticatedAddress = null;\n if (typeof window === 'undefined') {\n throw new Error('InjectedEvmWalletProvider can only be instantiated in a browser environment');\n }\n const normalized = normalizeConfig(config);\n // Singleton so the SDK reuses one instance (mirrors the other providers).\n if (InjectedEvmWalletProvider.instance) {\n InjectedEvmWalletProvider.instance.config = normalized;\n InjectedEvmWalletProvider.instance.authenticatedAddress = null;\n return InjectedEvmWalletProvider.instance;\n }\n this.config = normalized;\n InjectedEvmWalletProvider.instance = this;\n }\n // @user.address (the Solana wallet) is null for an EVM-wallet login: the user\n // authenticated with an EVM wallet and has no Solana address. User.address is\n // typed `string | null`, so this is a plain null, not a cast.\n evmUser(address) {\n return { id: address, address: null, evmAddress: address, provider: this };\n }\n resolveProvider() {\n var _a;\n const provider = (_a = (this.config.getProvider ? this.config.getProvider() : null)) !== null && _a !== void 0 ? _a : defaultInjectedEvmProvider();\n if (!provider)\n throw new Error(NO_WALLET_ERR);\n return provider;\n }\n /** Connect the injected wallet and return its canonical lowercase EVM address. */\n async connectAddress(provider) {\n const accounts = await provider.request({ method: 'eth_requestAccounts' });\n const raw = Array.isArray(accounts) ? accounts[0] : undefined;\n const address = normalizeEvmAddress(raw);\n if (!address)\n throw new Error('Wallet did not return a valid EVM address on connect');\n return address;\n }\n /** Current chain id the wallet is connected to (EIP-155 number), or null. */\n async currentChainId(provider) {\n try {\n const hex = await provider.request({ method: 'eth_chainId' });\n if (typeof hex !== 'string' || !/^0x[0-9a-fA-F]+$/.test(hex))\n return null;\n const n = Number(BigInt(hex));\n return Number.isSafeInteger(n) && n > 0 ? n : null;\n }\n catch (_a) {\n return null;\n }\n }\n async login() {\n var _a;\n setAuthLoading(true);\n try {\n const provider = this.resolveProvider();\n const address = await this.connectAddress(provider);\n // Reuse a still-valid session for THIS wallet.\n const existing = await SessionManager().getSession();\n if (existing && existing.address === address) {\n const user = this.evmUser(address);\n this.authenticatedAddress = address;\n setCurrentUser(user);\n this.markAuthMethod();\n return user;\n }\n // SIWE: nonce -> canonical EIP-4361 prompt -> the wallet personal_sign's it.\n const nonce = await genAuthNonce();\n const appId = (await getConfig()).appId;\n const chainId = (_a = this.config.chainId) !== null && _a !== void 0 ? _a : await this.currentChainId(provider);\n if (chainId === null)\n throw new Error('Could not verify the EVM wallet chain for SIWE login');\n const message = genSiweMessage(address, nonce, appId, this.resolveDomain(), this.resolveUri(), { chainId });\n // personal_sign(message, address) -> 0x r‖s‖v hex (the shape the\n // bounded-auth verifier's recoverSiweSigner consumes). The raw UTF-8\n // message is signed under the EIP-191 envelope the verifier hashes.\n const signature = await provider.request({\n method: 'personal_sign',\n params: [message, address],\n });\n const result = await createSessionWithSignature(address, message, signature, SIWE_SESSION_METHOD);\n await SessionManager().storeSession(address, result.accessToken, result.idToken, result.refreshToken);\n this.markAuthMethod();\n const user = this.evmUser(address);\n this.authenticatedAddress = address;\n setCurrentUser(user);\n return user;\n }\n finally {\n setAuthLoading(false);\n }\n }\n resolveDomain() {\n const actual = window.location.host.toLowerCase();\n if (this.config.domain && this.config.domain.toLowerCase() !== actual) {\n throw new Error('SIWE domain override must match the current browser origin');\n }\n return actual;\n }\n resolveUri() {\n const actual = window.location.origin.toLowerCase();\n if (this.config.uri) {\n let configured;\n try {\n configured = new URL(this.config.uri).origin.toLowerCase();\n }\n catch (_a) {\n throw new Error('SIWE URI override must be an absolute URL');\n }\n if (configured !== actual)\n throw new Error('SIWE URI override must match the current browser origin');\n }\n return actual;\n }\n markAuthMethod() {\n setStoredAuthMethod(INJECTED_EVM_AUTH_METHOD);\n }\n async restoreSession(beforeCommit) {\n const session = await SessionManager().getSession();\n beforeCommit === null || beforeCommit === void 0 ? void 0 : beforeCommit();\n if (!session)\n return null;\n // An EVM-wallet session stores the EVM address as its address; @user.address\n // (the Solana wallet) is null for this login.\n const address = normalizeEvmAddress(session.address);\n if (!address) {\n await SessionManager().clearSession();\n return null;\n }\n this.authenticatedAddress = address;\n const user = this.evmUser(address);\n setCurrentUser(user);\n return user;\n }\n async logout() {\n // EIP-1193 has no standard disconnect; clearing the Bounded session is the\n // logout. (wallet_revokePermissions is non-standard/opt-in — skip it.)\n await SessionManager().clearSession();\n this.authenticatedAddress = null;\n setCurrentUser(null);\n }\n // --- Signing surface -------------------------------------------------------\n /** App-facing message signing: EIP-191 personal_sign, returns 0x r‖s‖v hex. */\n async signMessage(message) {\n const provider = this.resolveProvider();\n const address = await this.connectAddress(provider);\n if (!this.authenticatedAddress || address !== this.authenticatedAddress) {\n throw new Error('The connected EVM wallet account changed after login. Sign in again before signing.');\n }\n return provider.request({ method: 'personal_sign', params: [message, address] });\n }\n // Solana-typed methods are structurally unsupported on an EVM wallet, and\n // this provider is login-only, so there is no transaction surface at all.\n async signTransaction(_transaction) {\n throw new Error(NO_SOL_TX_ERR);\n }\n async signAndSubmitTransaction(_transaction, _feePayer) {\n throw new Error(NO_SOL_TX_ERR);\n }\n async getNativeMethods() {\n return this.resolveProvider();\n }\n}\nInjectedEvmWalletProvider.instance = null;\n"],"names":["normalizeEvmAddress","setAuthLoading","SessionManager","setCurrentUser","genAuthNonce","getConfig","genSiweMessage","createSessionWithSignature","setStoredAuthMethod"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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E,OAAO,CAAC,EAAE,CAAC;AACxF,IAAI;AACJ;AACA;AACA,IAAI,MAAM,eAAe,CAAC,YAAY,EAAE;AACxC,QAAQ,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC;AACtC,IAAI;AACJ,IAAI,MAAM,wBAAwB,CAAC,YAAY,EAAE,SAAS,EAAE;AAC5D,QAAQ,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC;AACtC,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,IAAI,CAAC,eAAe,EAAE;AACrC,IAAI;AACJ;AACA,yBAAyB,CAAC,QAAQ,GAAG,IAAI;;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { normalizeEvmAddress, getActiveSessionManager, genAuthNonce, getConfig, genSiweMessage, createSessionWithSignature } from '@bounded-sh/core';
2
- import { k as setAuthLoading, s as setCurrentUser, m as setStoredAuthMethod } from './index.native-BHjpXkKQ.mjs';
2
+ import { k as setAuthLoading, s as setCurrentUser, m as setStoredAuthMethod } from './index.native-CAH_ks0s.mjs';
3
3
  import 'react';
4
4
 
5
5
  // injected-evm-wallet-types.ts — tiny, dependency-free surface for the EVM
@@ -200,8 +200,9 @@ class InjectedEvmWalletProvider {
200
200
  markAuthMethod() {
201
201
  setStoredAuthMethod(INJECTED_EVM_AUTH_METHOD);
202
202
  }
203
- async restoreSession() {
203
+ async restoreSession(beforeCommit) {
204
204
  const session = await getActiveSessionManager().getSession();
205
+ beforeCommit === null || beforeCommit === void 0 ? void 0 : beforeCommit();
205
206
  if (!session)
206
207
  return null;
207
208
  // An EVM-wallet session stores the EVM address as its address; @user.address
@@ -248,4 +249,4 @@ class InjectedEvmWalletProvider {
248
249
  InjectedEvmWalletProvider.instance = null;
249
250
 
250
251
  export { InjectedEvmWalletProvider, defaultInjectedEvmProvider };
251
- //# sourceMappingURL=injected-evm-wallet-provider-BUjqxQxp.mjs.map
252
+ //# sourceMappingURL=injected-evm-wallet-provider-DXjwPjLW.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"injected-evm-wallet-provider-BUjqxQxp.mjs","sources":["../.rollup-tmp/auth/providers/injected-evm-wallet-types.js","../.rollup-tmp/auth/providers/injected-evm-wallet-provider.js"],"sourcesContent":["// injected-evm-wallet-types.ts — tiny, dependency-free surface for the EVM\n// WALLET LOGIN path (BYO wallet via SIWE). The EVM twin of\n// injected-wallet-types.ts: kept separate from injected-evm-wallet-provider.ts\n// so the SDK entry can eagerly export the type surface + the provider-discovery\n// helper WITHOUT dragging the provider class into the default bundle. The\n// provider is lazy-loaded by getAuthProvider() when an app opts into\n// authMethod:'evm-wallet'.\n//\n// It rides the standard EIP-1193 injected provider a browser wallet exposes\n// (MetaMask / Rabby / Coinbase Wallet / any window.ethereum), discovered via\n// EIP-6963 (multi-wallet, collision-free) with a window.ethereum fallback. It\n// needs NO viem/ethers and NO React — EIP-1193 request() + hex strings suffice.\n// EIP-6963 is announcement-based: wallets add an `eip6963:requestProvider`\n// listener and synchronously dispatch `eip6963:announceProvider` in response. We\n// keep a persistent collector so announcements (including late ones) are\n// captured, and re-request on demand.\nconst announcedProviders = [];\nlet announceListenerAttached = false;\nfunction attachAnnounceListener() {\n if (announceListenerAttached || typeof window === 'undefined')\n return;\n announceListenerAttached = true;\n window.addEventListener('eip6963:announceProvider', (event) => {\n const detail = event === null || event === void 0 ? void 0 : event.detail;\n if (detail &&\n detail.provider &&\n typeof detail.provider.request === 'function' &&\n !announcedProviders.some((d) => { var _a, _b; return ((_a = d.info) === null || _a === void 0 ? void 0 : _a.uuid) === ((_b = detail.info) === null || _b === void 0 ? void 0 : _b.uuid); })) {\n announcedProviders.push(detail);\n }\n });\n}\n/**\n * Request + collect EIP-6963 providers. Dispatches `eip6963:requestProvider`\n * (synchronous — already-loaded wallets announce in the same tick) and returns\n * every wallet announced so far. Kept synchronous so it works inside a user\n * gesture and can be eagerly exported from the SDK entry.\n */\nexport function requestEip6963Providers() {\n if (typeof window === 'undefined')\n return [];\n attachAnnounceListener();\n try {\n window.dispatchEvent(new Event('eip6963:requestProvider'));\n }\n catch (_a) {\n /* older browsers without Event constructor — fall through to window.ethereum */\n }\n return announcedProviders.slice();\n}\n/**\n * Default EVM provider discovery: EIP-6963 first (multi-wallet, collision-free),\n * then legacy `window.ethereum`. Returns null when no injected wallet is present.\n */\nexport function defaultInjectedEvmProvider() {\n if (typeof window === 'undefined')\n return null;\n const details = requestEip6963Providers();\n if (details.length > 0)\n return details[0].provider;\n const eth = window.ethereum;\n if (eth && typeof eth.request === 'function')\n return eth;\n return null;\n}\n","import { getActiveSessionManager as SessionManager, createSessionWithSignature, genAuthNonce, genSiweMessage, getConfig, normalizeEvmAddress, } from '@bounded-sh/core';\nimport { setCurrentUser, setAuthLoading } from '../../global';\nimport { setStoredAuthMethod } from '../stored-auth-method';\nimport { defaultInjectedEvmProvider, } from './injected-evm-wallet-types';\n// Re-export the type surface + discovery helper for callers who import the\n// provider module directly.\nexport { defaultInjectedEvmProvider };\n// Must equal the authMethod the registry (auth/index.ts) sets as currentAuthMethod,\n// so clearIncompatibleSession() keeps (not wipes) this session on the next init().\nconst INJECTED_EVM_AUTH_METHOD = 'evm-wallet';\n// The /session issuer's discriminator for the SIWE (EIP-4361 secp256k1) exchange.\nconst SIWE_SESSION_METHOD = 'siwe';\nconst NO_WALLET_ERR = 'No injected EVM wallet found. Install a wallet like MetaMask (metamask.io) or Rabby and try again, ' +\n 'or pass config.evmWalletConfig.getProvider to point at your wallet.';\nconst NO_SOL_TX_ERR = 'EVM wallet login is a LOGIN-ONLY surface (SIWE + personal_sign) and has no Solana ' +\n 'transaction surface: signTransaction/signAndSubmitTransaction are unavailable.';\nfunction normalizeConfig(config) {\n if (config.chainId !== undefined && (!Number.isSafeInteger(config.chainId) || config.chainId <= 0)) {\n throw new Error('EVM wallet chainId must be a positive safe integer');\n }\n return Object.assign({}, config);\n}\nexport class InjectedEvmWalletProvider {\n constructor(config = {}) {\n this.authenticatedAddress = null;\n if (typeof window === 'undefined') {\n throw new Error('InjectedEvmWalletProvider can only be instantiated in a browser environment');\n }\n const normalized = normalizeConfig(config);\n // Singleton so the SDK reuses one instance (mirrors the other providers).\n if (InjectedEvmWalletProvider.instance) {\n InjectedEvmWalletProvider.instance.config = normalized;\n InjectedEvmWalletProvider.instance.authenticatedAddress = null;\n return InjectedEvmWalletProvider.instance;\n }\n this.config = normalized;\n InjectedEvmWalletProvider.instance = this;\n }\n // @user.address (the Solana wallet) is null for an EVM-wallet login: the user\n // authenticated with an EVM wallet and has no Solana address. User.address is\n // typed `string | null`, so this is a plain null, not a cast.\n evmUser(address) {\n return { id: address, address: null, evmAddress: address, provider: this };\n }\n resolveProvider() {\n var _a;\n const provider = (_a = (this.config.getProvider ? this.config.getProvider() : null)) !== null && _a !== void 0 ? _a : defaultInjectedEvmProvider();\n if (!provider)\n throw new Error(NO_WALLET_ERR);\n return provider;\n }\n /** Connect the injected wallet and return its canonical lowercase EVM address. */\n async connectAddress(provider) {\n const accounts = await provider.request({ method: 'eth_requestAccounts' });\n const raw = Array.isArray(accounts) ? accounts[0] : undefined;\n const address = normalizeEvmAddress(raw);\n if (!address)\n throw new Error('Wallet did not return a valid EVM address on connect');\n return address;\n }\n /** Current chain id the wallet is connected to (EIP-155 number), or null. */\n async currentChainId(provider) {\n try {\n const hex = await provider.request({ method: 'eth_chainId' });\n if (typeof hex !== 'string' || !/^0x[0-9a-fA-F]+$/.test(hex))\n return null;\n const n = Number(BigInt(hex));\n return Number.isSafeInteger(n) && n > 0 ? n : null;\n }\n catch (_a) {\n return null;\n }\n }\n async login() {\n var _a;\n setAuthLoading(true);\n try {\n const provider = this.resolveProvider();\n const address = await this.connectAddress(provider);\n // Reuse a still-valid session for THIS wallet.\n const existing = await SessionManager().getSession();\n if (existing && existing.address === address) {\n const user = this.evmUser(address);\n this.authenticatedAddress = address;\n setCurrentUser(user);\n this.markAuthMethod();\n return user;\n }\n // SIWE: nonce -> canonical EIP-4361 prompt -> the wallet personal_sign's it.\n const nonce = await genAuthNonce();\n const appId = (await getConfig()).appId;\n const chainId = (_a = this.config.chainId) !== null && _a !== void 0 ? _a : await this.currentChainId(provider);\n if (chainId === null)\n throw new Error('Could not verify the EVM wallet chain for SIWE login');\n const message = genSiweMessage(address, nonce, appId, this.resolveDomain(), this.resolveUri(), { chainId });\n // personal_sign(message, address) -> 0x r‖s‖v hex (the shape the\n // bounded-auth verifier's recoverSiweSigner consumes). The raw UTF-8\n // message is signed under the EIP-191 envelope the verifier hashes.\n const signature = await provider.request({\n method: 'personal_sign',\n params: [message, address],\n });\n const result = await createSessionWithSignature(address, message, signature, SIWE_SESSION_METHOD);\n await SessionManager().storeSession(address, result.accessToken, result.idToken, result.refreshToken);\n this.markAuthMethod();\n const user = this.evmUser(address);\n this.authenticatedAddress = address;\n setCurrentUser(user);\n return user;\n }\n finally {\n setAuthLoading(false);\n }\n }\n resolveDomain() {\n const actual = window.location.host.toLowerCase();\n if (this.config.domain && this.config.domain.toLowerCase() !== actual) {\n throw new Error('SIWE domain override must match the current browser origin');\n }\n return actual;\n }\n resolveUri() {\n const actual = window.location.origin.toLowerCase();\n if (this.config.uri) {\n let configured;\n try {\n configured = new URL(this.config.uri).origin.toLowerCase();\n }\n catch (_a) {\n throw new Error('SIWE URI override must be an absolute URL');\n }\n if (configured !== actual)\n throw new Error('SIWE URI override must match the current browser origin');\n }\n return actual;\n }\n markAuthMethod() {\n setStoredAuthMethod(INJECTED_EVM_AUTH_METHOD);\n }\n async restoreSession() {\n const session = await SessionManager().getSession();\n if (!session)\n return null;\n // An EVM-wallet session stores the EVM address as its address; @user.address\n // (the Solana wallet) is null for this login.\n const address = normalizeEvmAddress(session.address);\n if (!address) {\n await SessionManager().clearSession();\n return null;\n }\n this.authenticatedAddress = address;\n const user = this.evmUser(address);\n setCurrentUser(user);\n return user;\n }\n async logout() {\n // EIP-1193 has no standard disconnect; clearing the Bounded session is the\n // logout. (wallet_revokePermissions is non-standard/opt-in — skip it.)\n await SessionManager().clearSession();\n this.authenticatedAddress = null;\n setCurrentUser(null);\n }\n // --- Signing surface -------------------------------------------------------\n /** App-facing message signing: EIP-191 personal_sign, returns 0x r‖s‖v hex. */\n async signMessage(message) {\n const provider = this.resolveProvider();\n const address = await this.connectAddress(provider);\n if (!this.authenticatedAddress || address !== this.authenticatedAddress) {\n throw new Error('The connected EVM wallet account changed after login. Sign in again before signing.');\n }\n return provider.request({ method: 'personal_sign', params: [message, address] });\n }\n // Solana-typed methods are structurally unsupported on an EVM wallet, and\n // this provider is login-only, so there is no transaction surface at all.\n async signTransaction(_transaction) {\n throw new Error(NO_SOL_TX_ERR);\n }\n async signAndSubmitTransaction(_transaction, _feePayer) {\n throw new Error(NO_SOL_TX_ERR);\n }\n async getNativeMethods() {\n return this.resolveProvider();\n }\n}\nInjectedEvmWalletProvider.instance = null;\n"],"names":["SessionManager"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,kBAAkB,GAAG,EAAE;AAC7B,IAAI,wBAAwB,GAAG,KAAK;AACpC,SAAS,sBAAsB,GAAG;AAClC,IAAI,IAAI,wBAAwB,IAAI,OAAO,MAAM,KAAK,WAAW;AACjE,QAAQ;AACR,IAAI,wBAAwB,GAAG,IAAI;AACnC,IAAI,MAAM,CAAC,gBAAgB,CAAC,0BAA0B,EAAE,CAAC,KAAK,KAAK;AACnE,QAAQ,MAAM,MAAM,GAAG,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM;AACjF,QAAQ,IAAI,MAAM;AAClB,YAAY,MAAM,CAAC,QAAQ;AAC3B,YAAY,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,KAAK,UAAU;AACzD,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,GAAG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AAI,CAAC;AAC5B,IAAI;AACJ;AACA;AACA,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;AAC/B,QAAQ,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,EAAE;AAC/C,QAAQ,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC;AAC3D,QAAQ,IAAI,CAAC,IAAI,CAAC,oBAAoB,IAAI,OAAO,KAAK,IAAI,CAAC,oBAAoB,EAAE;AACjF,YAAY,MAAM,IAAI,KAAK,CAAC,qFAAqF,CAAC;AAClH,QAAQ;AACR,QAAQ,OAAO,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC;AACxF,IAAI;AACJ;AACA;AACA,IAAI,MAAM,eAAe,CAAC,YAAY,EAAE;AACxC,QAAQ,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC;AACtC,IAAI;AACJ,IAAI,MAAM,wBAAwB,CAAC,YAAY,EAAE,SAAS,EAAE;AAC5D,QAAQ,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC;AACtC,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,IAAI,CAAC,eAAe,EAAE;AACrC,IAAI;AACJ;AACA,yBAAyB,CAAC,QAAQ,GAAG,IAAI;;;;"}
1
+ {"version":3,"file":"injected-evm-wallet-provider-DXjwPjLW.mjs","sources":["../.rollup-tmp/auth/providers/injected-evm-wallet-types.js","../.rollup-tmp/auth/providers/injected-evm-wallet-provider.js"],"sourcesContent":["// injected-evm-wallet-types.ts — tiny, dependency-free surface for the EVM\n// WALLET LOGIN path (BYO wallet via SIWE). The EVM twin of\n// injected-wallet-types.ts: kept separate from injected-evm-wallet-provider.ts\n// so the SDK entry can eagerly export the type surface + the provider-discovery\n// helper WITHOUT dragging the provider class into the default bundle. The\n// provider is lazy-loaded by getAuthProvider() when an app opts into\n// authMethod:'evm-wallet'.\n//\n// It rides the standard EIP-1193 injected provider a browser wallet exposes\n// (MetaMask / Rabby / Coinbase Wallet / any window.ethereum), discovered via\n// EIP-6963 (multi-wallet, collision-free) with a window.ethereum fallback. It\n// needs NO viem/ethers and NO React — EIP-1193 request() + hex strings suffice.\n// EIP-6963 is announcement-based: wallets add an `eip6963:requestProvider`\n// listener and synchronously dispatch `eip6963:announceProvider` in response. We\n// keep a persistent collector so announcements (including late ones) are\n// captured, and re-request on demand.\nconst announcedProviders = [];\nlet announceListenerAttached = false;\nfunction attachAnnounceListener() {\n if (announceListenerAttached || typeof window === 'undefined')\n return;\n announceListenerAttached = true;\n window.addEventListener('eip6963:announceProvider', (event) => {\n const detail = event === null || event === void 0 ? void 0 : event.detail;\n if (detail &&\n detail.provider &&\n typeof detail.provider.request === 'function' &&\n !announcedProviders.some((d) => { var _a, _b; return ((_a = d.info) === null || _a === void 0 ? void 0 : _a.uuid) === ((_b = detail.info) === null || _b === void 0 ? void 0 : _b.uuid); })) {\n announcedProviders.push(detail);\n }\n });\n}\n/**\n * Request + collect EIP-6963 providers. Dispatches `eip6963:requestProvider`\n * (synchronous — already-loaded wallets announce in the same tick) and returns\n * every wallet announced so far. Kept synchronous so it works inside a user\n * gesture and can be eagerly exported from the SDK entry.\n */\nexport function requestEip6963Providers() {\n if (typeof window === 'undefined')\n return [];\n attachAnnounceListener();\n try {\n window.dispatchEvent(new Event('eip6963:requestProvider'));\n }\n catch (_a) {\n /* older browsers without Event constructor — fall through to window.ethereum */\n }\n return announcedProviders.slice();\n}\n/**\n * Default EVM provider discovery: EIP-6963 first (multi-wallet, collision-free),\n * then legacy `window.ethereum`. Returns null when no injected wallet is present.\n */\nexport function defaultInjectedEvmProvider() {\n if (typeof window === 'undefined')\n return null;\n const details = requestEip6963Providers();\n if (details.length > 0)\n return details[0].provider;\n const eth = window.ethereum;\n if (eth && typeof eth.request === 'function')\n return eth;\n return null;\n}\n","import { getActiveSessionManager as SessionManager, createSessionWithSignature, genAuthNonce, genSiweMessage, getConfig, normalizeEvmAddress, } from '@bounded-sh/core';\nimport { setCurrentUser, setAuthLoading } from '../../global';\nimport { setStoredAuthMethod } from '../stored-auth-method';\nimport { defaultInjectedEvmProvider, } from './injected-evm-wallet-types';\n// Re-export the type surface + discovery helper for callers who import the\n// provider module directly.\nexport { defaultInjectedEvmProvider };\n// Must equal the authMethod the registry (auth/index.ts) sets as currentAuthMethod,\n// so clearIncompatibleSession() keeps (not wipes) this session on the next init().\nconst INJECTED_EVM_AUTH_METHOD = 'evm-wallet';\n// The /session issuer's discriminator for the SIWE (EIP-4361 secp256k1) exchange.\nconst SIWE_SESSION_METHOD = 'siwe';\nconst NO_WALLET_ERR = 'No injected EVM wallet found. Install a wallet like MetaMask (metamask.io) or Rabby and try again, ' +\n 'or pass config.evmWalletConfig.getProvider to point at your wallet.';\nconst NO_SOL_TX_ERR = 'EVM wallet login is a LOGIN-ONLY surface (SIWE + personal_sign) and has no Solana ' +\n 'transaction surface: signTransaction/signAndSubmitTransaction are unavailable.';\nfunction normalizeConfig(config) {\n if (config.chainId !== undefined && (!Number.isSafeInteger(config.chainId) || config.chainId <= 0)) {\n throw new Error('EVM wallet chainId must be a positive safe integer');\n }\n return Object.assign({}, config);\n}\nexport class InjectedEvmWalletProvider {\n constructor(config = {}) {\n this.authenticatedAddress = null;\n if (typeof window === 'undefined') {\n throw new Error('InjectedEvmWalletProvider can only be instantiated in a browser environment');\n }\n const normalized = normalizeConfig(config);\n // Singleton so the SDK reuses one instance (mirrors the other providers).\n if (InjectedEvmWalletProvider.instance) {\n InjectedEvmWalletProvider.instance.config = normalized;\n InjectedEvmWalletProvider.instance.authenticatedAddress = null;\n return InjectedEvmWalletProvider.instance;\n }\n this.config = normalized;\n InjectedEvmWalletProvider.instance = this;\n }\n // @user.address (the Solana wallet) is null for an EVM-wallet login: the user\n // authenticated with an EVM wallet and has no Solana address. User.address is\n // typed `string | null`, so this is a plain null, not a cast.\n evmUser(address) {\n return { id: address, address: null, evmAddress: address, provider: this };\n }\n resolveProvider() {\n var _a;\n const provider = (_a = (this.config.getProvider ? this.config.getProvider() : null)) !== null && _a !== void 0 ? _a : defaultInjectedEvmProvider();\n if (!provider)\n throw new Error(NO_WALLET_ERR);\n return provider;\n }\n /** Connect the injected wallet and return its canonical lowercase EVM address. */\n async connectAddress(provider) {\n const accounts = await provider.request({ method: 'eth_requestAccounts' });\n const raw = Array.isArray(accounts) ? accounts[0] : undefined;\n const address = normalizeEvmAddress(raw);\n if (!address)\n throw new Error('Wallet did not return a valid EVM address on connect');\n return address;\n }\n /** Current chain id the wallet is connected to (EIP-155 number), or null. */\n async currentChainId(provider) {\n try {\n const hex = await provider.request({ method: 'eth_chainId' });\n if (typeof hex !== 'string' || !/^0x[0-9a-fA-F]+$/.test(hex))\n return null;\n const n = Number(BigInt(hex));\n return Number.isSafeInteger(n) && n > 0 ? n : null;\n }\n catch (_a) {\n return null;\n }\n }\n async login() {\n var _a;\n setAuthLoading(true);\n try {\n const provider = this.resolveProvider();\n const address = await this.connectAddress(provider);\n // Reuse a still-valid session for THIS wallet.\n const existing = await SessionManager().getSession();\n if (existing && existing.address === address) {\n const user = this.evmUser(address);\n this.authenticatedAddress = address;\n setCurrentUser(user);\n this.markAuthMethod();\n return user;\n }\n // SIWE: nonce -> canonical EIP-4361 prompt -> the wallet personal_sign's it.\n const nonce = await genAuthNonce();\n const appId = (await getConfig()).appId;\n const chainId = (_a = this.config.chainId) !== null && _a !== void 0 ? _a : await this.currentChainId(provider);\n if (chainId === null)\n throw new Error('Could not verify the EVM wallet chain for SIWE login');\n const message = genSiweMessage(address, nonce, appId, this.resolveDomain(), this.resolveUri(), { chainId });\n // personal_sign(message, address) -> 0x r‖s‖v hex (the shape the\n // bounded-auth verifier's recoverSiweSigner consumes). The raw UTF-8\n // message is signed under the EIP-191 envelope the verifier hashes.\n const signature = await provider.request({\n method: 'personal_sign',\n params: [message, address],\n });\n const result = await createSessionWithSignature(address, message, signature, SIWE_SESSION_METHOD);\n await SessionManager().storeSession(address, result.accessToken, result.idToken, result.refreshToken);\n this.markAuthMethod();\n const user = this.evmUser(address);\n this.authenticatedAddress = address;\n setCurrentUser(user);\n return user;\n }\n finally {\n setAuthLoading(false);\n }\n }\n resolveDomain() {\n const actual = window.location.host.toLowerCase();\n if (this.config.domain && this.config.domain.toLowerCase() !== actual) {\n throw new Error('SIWE domain override must match the current browser origin');\n }\n return actual;\n }\n resolveUri() {\n const actual = window.location.origin.toLowerCase();\n if (this.config.uri) {\n let configured;\n try {\n configured = new URL(this.config.uri).origin.toLowerCase();\n }\n catch (_a) {\n throw new Error('SIWE URI override must be an absolute URL');\n }\n if (configured !== actual)\n throw new Error('SIWE URI override must match the current browser origin');\n }\n return actual;\n }\n markAuthMethod() {\n setStoredAuthMethod(INJECTED_EVM_AUTH_METHOD);\n }\n async restoreSession(beforeCommit) {\n const session = await SessionManager().getSession();\n beforeCommit === null || beforeCommit === void 0 ? void 0 : beforeCommit();\n if (!session)\n return null;\n // An EVM-wallet session stores the EVM address as its address; @user.address\n // (the Solana wallet) is null for this login.\n const address = normalizeEvmAddress(session.address);\n if (!address) {\n await SessionManager().clearSession();\n return null;\n }\n this.authenticatedAddress = address;\n const user = this.evmUser(address);\n setCurrentUser(user);\n return user;\n }\n async logout() {\n // EIP-1193 has no standard disconnect; clearing the Bounded session is the\n // logout. (wallet_revokePermissions is non-standard/opt-in — skip it.)\n await SessionManager().clearSession();\n this.authenticatedAddress = null;\n setCurrentUser(null);\n }\n // --- Signing surface -------------------------------------------------------\n /** App-facing message signing: EIP-191 personal_sign, returns 0x r‖s‖v hex. */\n async signMessage(message) {\n const provider = this.resolveProvider();\n const address = await this.connectAddress(provider);\n if (!this.authenticatedAddress || address !== this.authenticatedAddress) {\n throw new Error('The connected EVM wallet account changed after login. Sign in again before signing.');\n }\n return provider.request({ method: 'personal_sign', params: [message, address] });\n }\n // Solana-typed methods are structurally unsupported on an EVM wallet, and\n // this provider is login-only, so there is no transaction surface at all.\n async signTransaction(_transaction) {\n throw new Error(NO_SOL_TX_ERR);\n }\n async signAndSubmitTransaction(_transaction, _feePayer) {\n throw new Error(NO_SOL_TX_ERR);\n }\n async getNativeMethods() {\n return this.resolveProvider();\n }\n}\nInjectedEvmWalletProvider.instance = null;\n"],"names":["SessionManager"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,kBAAkB,GAAG,EAAE;AAC7B,IAAI,wBAAwB,GAAG,KAAK;AACpC,SAAS,sBAAsB,GAAG;AAClC,IAAI,IAAI,wBAAwB,IAAI,OAAO,MAAM,KAAK,WAAW;AACjE,QAAQ;AACR,IAAI,wBAAwB,GAAG,IAAI;AACnC,IAAI,MAAM,CAAC,gBAAgB,CAAC,0BAA0B,EAAE,CAAC,KAAK,KAAK;AACnE,QAAQ,MAAM,MAAM,GAAG,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM;AACjF,QAAQ,IAAI,MAAM;AAClB,YAAY,MAAM,CAAC,QAAQ;AAC3B,YAAY,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,KAAK,UAAU;AACzD,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;AACzM,YAAY,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC;AAC3C,QAAQ;AACR,IAAI,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,IAAI,CAAC,IAAI,CAAC,oBAAoB,IAAI,OAAO,KAAK,IAAI,CAAC,oBAAoB,EAAE;AACjF,YAAY,MAAM,IAAI,KAAK,CAAC,qFAAqF,CAAC;AAClH,QAAQ;AACR,QAAQ,OAAO,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC;AACxF,IAAI;AACJ;AACA;AACA,IAAI,MAAM,eAAe,CAAC,YAAY,EAAE;AACxC,QAAQ,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC;AACtC,IAAI;AACJ,IAAI,MAAM,wBAAwB,CAAC,YAAY,EAAE,SAAS,EAAE;AAC5D,QAAQ,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC;AACtC,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,IAAI,CAAC,eAAe,EAAE;AACrC,IAAI;AACJ;AACA,yBAAyB,CAAC,QAAQ,GAAG,IAAI;;;;"}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var core = require('@bounded-sh/core');
4
- var index = require('./index-BghQ8jX0.js');
4
+ var index = require('./index-DJeEMevo.js');
5
5
  require('react');
6
6
 
7
7
  // Must equal the authMethod the registry (auth/index.ts) sets as currentAuthMethod,
@@ -136,8 +136,9 @@ class InjectedEvmWalletProvider {
136
136
  markAuthMethod() {
137
137
  index.setStoredAuthMethod(INJECTED_EVM_AUTH_METHOD);
138
138
  }
139
- async restoreSession() {
139
+ async restoreSession(beforeCommit) {
140
140
  const session = await core.getActiveSessionManager().getSession();
141
+ beforeCommit === null || beforeCommit === void 0 ? void 0 : beforeCommit();
141
142
  if (!session)
142
143
  return null;
143
144
  // An EVM-wallet session stores the EVM address as its address; @user.address
@@ -185,4 +186,4 @@ InjectedEvmWalletProvider.instance = null;
185
186
 
186
187
  exports.defaultInjectedEvmProvider = index.defaultInjectedEvmProvider;
187
188
  exports.InjectedEvmWalletProvider = InjectedEvmWalletProvider;
188
- //# sourceMappingURL=injected-evm-wallet-provider-Ckb85p6a.js.map
189
+ //# sourceMappingURL=injected-evm-wallet-provider-IlkuKffc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"injected-evm-wallet-provider-IlkuKffc.js","sources":["../.rollup-tmp/auth/providers/injected-evm-wallet-provider.js"],"sourcesContent":["import { getActiveSessionManager as SessionManager, createSessionWithSignature, genAuthNonce, genSiweMessage, getConfig, normalizeEvmAddress, } from '@bounded-sh/core';\nimport { setCurrentUser, setAuthLoading } from '../../global';\nimport { setStoredAuthMethod } from '../stored-auth-method';\nimport { defaultInjectedEvmProvider, } from './injected-evm-wallet-types';\n// Re-export the type surface + discovery helper for callers who import the\n// provider module directly.\nexport { defaultInjectedEvmProvider };\n// Must equal the authMethod the registry (auth/index.ts) sets as currentAuthMethod,\n// so clearIncompatibleSession() keeps (not wipes) this session on the next init().\nconst INJECTED_EVM_AUTH_METHOD = 'evm-wallet';\n// The /session issuer's discriminator for the SIWE (EIP-4361 secp256k1) exchange.\nconst SIWE_SESSION_METHOD = 'siwe';\nconst NO_WALLET_ERR = 'No injected EVM wallet found. Install a wallet like MetaMask (metamask.io) or Rabby and try again, ' +\n 'or pass config.evmWalletConfig.getProvider to point at your wallet.';\nconst NO_SOL_TX_ERR = 'EVM wallet login is a LOGIN-ONLY surface (SIWE + personal_sign) and has no Solana ' +\n 'transaction surface: signTransaction/signAndSubmitTransaction are unavailable.';\nfunction normalizeConfig(config) {\n if (config.chainId !== undefined && (!Number.isSafeInteger(config.chainId) || config.chainId <= 0)) {\n throw new Error('EVM wallet chainId must be a positive safe integer');\n }\n return Object.assign({}, config);\n}\nexport class InjectedEvmWalletProvider {\n constructor(config = {}) {\n this.authenticatedAddress = null;\n if (typeof window === 'undefined') {\n throw new Error('InjectedEvmWalletProvider can only be instantiated in a browser environment');\n }\n const normalized = normalizeConfig(config);\n // Singleton so the SDK reuses one instance (mirrors the other providers).\n if (InjectedEvmWalletProvider.instance) {\n InjectedEvmWalletProvider.instance.config = normalized;\n InjectedEvmWalletProvider.instance.authenticatedAddress = null;\n return InjectedEvmWalletProvider.instance;\n }\n this.config = normalized;\n InjectedEvmWalletProvider.instance = this;\n }\n // @user.address (the Solana wallet) is null for an EVM-wallet login: the user\n // authenticated with an EVM wallet and has no Solana address. User.address is\n // typed `string | null`, so this is a plain null, not a cast.\n evmUser(address) {\n return { id: address, address: null, evmAddress: address, provider: this };\n }\n resolveProvider() {\n var _a;\n const provider = (_a = (this.config.getProvider ? this.config.getProvider() : null)) !== null && _a !== void 0 ? _a : defaultInjectedEvmProvider();\n if (!provider)\n throw new Error(NO_WALLET_ERR);\n return provider;\n }\n /** Connect the injected wallet and return its canonical lowercase EVM address. */\n async connectAddress(provider) {\n const accounts = await provider.request({ method: 'eth_requestAccounts' });\n const raw = Array.isArray(accounts) ? accounts[0] : undefined;\n const address = normalizeEvmAddress(raw);\n if (!address)\n throw new Error('Wallet did not return a valid EVM address on connect');\n return address;\n }\n /** Current chain id the wallet is connected to (EIP-155 number), or null. */\n async currentChainId(provider) {\n try {\n const hex = await provider.request({ method: 'eth_chainId' });\n if (typeof hex !== 'string' || !/^0x[0-9a-fA-F]+$/.test(hex))\n return null;\n const n = Number(BigInt(hex));\n return Number.isSafeInteger(n) && n > 0 ? n : null;\n }\n catch (_a) {\n return null;\n }\n }\n async login() {\n var _a;\n setAuthLoading(true);\n try {\n const provider = this.resolveProvider();\n const address = await this.connectAddress(provider);\n // Reuse a still-valid session for THIS wallet.\n const existing = await SessionManager().getSession();\n if (existing && existing.address === address) {\n const user = this.evmUser(address);\n this.authenticatedAddress = address;\n setCurrentUser(user);\n this.markAuthMethod();\n return user;\n }\n // SIWE: nonce -> canonical EIP-4361 prompt -> the wallet personal_sign's it.\n const nonce = await genAuthNonce();\n const appId = (await getConfig()).appId;\n const chainId = (_a = this.config.chainId) !== null && _a !== void 0 ? _a : await this.currentChainId(provider);\n if (chainId === null)\n throw new Error('Could not verify the EVM wallet chain for SIWE login');\n const message = genSiweMessage(address, nonce, appId, this.resolveDomain(), this.resolveUri(), { chainId });\n // personal_sign(message, address) -> 0x r‖s‖v hex (the shape the\n // bounded-auth verifier's recoverSiweSigner consumes). The raw UTF-8\n // message is signed under the EIP-191 envelope the verifier hashes.\n const signature = await provider.request({\n method: 'personal_sign',\n params: [message, address],\n });\n const result = await createSessionWithSignature(address, message, signature, SIWE_SESSION_METHOD);\n await SessionManager().storeSession(address, result.accessToken, result.idToken, result.refreshToken);\n this.markAuthMethod();\n const user = this.evmUser(address);\n this.authenticatedAddress = address;\n setCurrentUser(user);\n return user;\n }\n finally {\n setAuthLoading(false);\n }\n }\n resolveDomain() {\n const actual = window.location.host.toLowerCase();\n if (this.config.domain && this.config.domain.toLowerCase() !== actual) {\n throw new Error('SIWE domain override must match the current browser origin');\n }\n return actual;\n }\n resolveUri() {\n const actual = window.location.origin.toLowerCase();\n if (this.config.uri) {\n let configured;\n try {\n configured = new URL(this.config.uri).origin.toLowerCase();\n }\n catch (_a) {\n throw new Error('SIWE URI override must be an absolute URL');\n }\n if (configured !== actual)\n throw new Error('SIWE URI override must match the current browser origin');\n }\n return actual;\n }\n markAuthMethod() {\n setStoredAuthMethod(INJECTED_EVM_AUTH_METHOD);\n }\n async restoreSession(beforeCommit) {\n const session = await SessionManager().getSession();\n beforeCommit === null || beforeCommit === void 0 ? void 0 : beforeCommit();\n if (!session)\n return null;\n // An EVM-wallet session stores the EVM address as its address; @user.address\n // (the Solana wallet) is null for this login.\n const address = normalizeEvmAddress(session.address);\n if (!address) {\n await SessionManager().clearSession();\n return null;\n }\n this.authenticatedAddress = address;\n const user = this.evmUser(address);\n setCurrentUser(user);\n return user;\n }\n async logout() {\n // EIP-1193 has no standard disconnect; clearing the Bounded session is the\n // logout. (wallet_revokePermissions is non-standard/opt-in — skip it.)\n await SessionManager().clearSession();\n this.authenticatedAddress = null;\n setCurrentUser(null);\n }\n // --- Signing surface -------------------------------------------------------\n /** App-facing message signing: EIP-191 personal_sign, returns 0x r‖s‖v hex. */\n async signMessage(message) {\n const provider = this.resolveProvider();\n const address = await this.connectAddress(provider);\n if (!this.authenticatedAddress || address !== this.authenticatedAddress) {\n throw new Error('The connected EVM wallet account changed after login. Sign in again before signing.');\n }\n return provider.request({ method: 'personal_sign', params: [message, address] });\n }\n // Solana-typed methods are structurally unsupported on an EVM wallet, and\n // this provider is login-only, so there is no transaction surface at all.\n async signTransaction(_transaction) {\n throw new Error(NO_SOL_TX_ERR);\n }\n async signAndSubmitTransaction(_transaction, _feePayer) {\n throw new Error(NO_SOL_TX_ERR);\n }\n async getNativeMethods() {\n return this.resolveProvider();\n }\n}\nInjectedEvmWalletProvider.instance = null;\n"],"names":["defaultInjectedEvmProvider","normalizeEvmAddress","setAuthLoading","SessionManager","setCurrentUser","genAuthNonce","getConfig","genSiweMessage","createSessionWithSignature","setStoredAuthMethod"],"mappings":";;;;;;AAOA;AACA;AACA,MAAM,wBAAwB,GAAG,YAAY;AAC7C;AACA,MAAM,mBAAmB,GAAG,MAAM;AAClC,MAAM,aAAa,GAAG,qGAAqG;AAC3H,IAAI,qEAAqE;AACzE,MAAM,aAAa,GAAG,oFAAoF;AAC1G,IAAI,gFAAgF;AACpF,SAAS,eAAe,CAAC,MAAM,EAAE;AACjC,IAAI,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,IAAI,CAAC,CAAC,EAAE;AACxG,QAAQ,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC;AAC7E,IAAI;AACJ,IAAI,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC;AACpC;AACO,MAAM,yBAAyB,CAAC;AACvC,IAAI,WAAW,CAAC,MAAM,GAAG,EAAE,EAAE;AAC7B,QAAQ,IAAI,CAAC,oBAAoB,GAAG,IAAI;AACx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,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC;AACxF,IAAI;AACJ;AACA;AACA,IAAI,MAAM,eAAe,CAAC,YAAY,EAAE;AACxC,QAAQ,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC;AACtC,IAAI;AACJ,IAAI,MAAM,wBAAwB,CAAC,YAAY,EAAE,SAAS,EAAE;AAC5D,QAAQ,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC;AACtC,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,IAAI,CAAC,eAAe,EAAE;AACrC,IAAI;AACJ;AACA,yBAAyB,CAAC,QAAQ,GAAG,IAAI;;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { getActiveSessionManager, genAuthNonce, genSolanaSignInRequest, createSessionWithSignature } from '@bounded-sh/core';
2
- import { e as bs58, n as normalizeSolanaRpcUrl, f as defaultInjectedProvider, i as firstStandardWalletProvider, j as setAuthLoading, s as setCurrentUser, k as bufferExports, l as setStoredAuthMethod, g as getPlatform, t as transactionHasSignature, m as confirmAndCheckTransaction, r as resolveSolanaRpcUrl } from './index-B9__gwTi.mjs';
2
+ import { e as bs58, n as normalizeSolanaRpcUrl, f as defaultInjectedProvider, i as firstStandardWalletProvider, j as setAuthLoading, s as setCurrentUser, k as bufferExports, l as setStoredAuthMethod, g as getPlatform, t as transactionHasSignature, m as confirmAndCheckTransaction, r as resolveSolanaRpcUrl } from './index-D3kdhCpH.mjs';
3
3
  import 'react';
4
4
 
5
5
  const crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
@@ -2631,8 +2631,9 @@ class InjectedWalletProvider {
2631
2631
  // wallet session on the next init().
2632
2632
  setStoredAuthMethod(INJECTED_AUTH_METHOD);
2633
2633
  }
2634
- async restoreSession() {
2634
+ async restoreSession(beforeCommit) {
2635
2635
  const session = await getActiveSessionManager().getSession();
2636
+ beforeCommit === null || beforeCommit === void 0 ? void 0 : beforeCommit();
2636
2637
  if (!session)
2637
2638
  return null;
2638
2639
  this.authenticatedAddress = session.address;
@@ -2812,4 +2813,4 @@ class InjectedWalletProvider {
2812
2813
  }
2813
2814
 
2814
2815
  export { InjectedWalletProvider, WALLET_SIGN_IN_UNSUPPORTED_ERR, defaultInjectedProvider };
2815
- //# sourceMappingURL=injected-wallet-provider-BlzA0J_V.mjs.map
2816
+ //# sourceMappingURL=injected-wallet-provider-0SSONh1d.mjs.map