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

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 (53) hide show
  1. package/dist/auth/bounded-widget-modal.d.ts +24 -2
  2. package/dist/auth/providers/injected-wallet-provider.d.ts +7 -0
  3. package/dist/auth/providers/injected-wallet-types.d.ts +2 -0
  4. package/dist/auth/providers/solana-mobile-registration.d.ts +18 -0
  5. package/dist/{email-auth-provider-BfCH7K6N.mjs → email-auth-provider-Bk5GSpYT.mjs} +2 -2
  6. package/dist/{email-auth-provider-C7RXLVd9.mjs.map → email-auth-provider-Bk5GSpYT.mjs.map} +1 -1
  7. package/dist/{email-auth-provider-DTrCfOJd.js → email-auth-provider-Cr66GaKw.js} +2 -2
  8. package/dist/{email-auth-provider-DTrCfOJd.js.map → email-auth-provider-Cr66GaKw.js.map} +1 -1
  9. package/dist/{email-auth-provider-53sA5_i2.js → email-auth-provider-DeORQbTK.js} +2 -2
  10. package/dist/{email-auth-provider-53sA5_i2.js.map → email-auth-provider-DeORQbTK.js.map} +1 -1
  11. package/dist/{email-auth-provider-C7RXLVd9.mjs → email-auth-provider-nDZjRDpj.mjs} +2 -2
  12. package/dist/{email-auth-provider-BfCH7K6N.mjs.map → email-auth-provider-nDZjRDpj.mjs.map} +1 -1
  13. package/dist/{guest-auth-provider-00KkSNpE.js → guest-auth-provider-5bX-xt6K.js} +2 -2
  14. package/dist/{guest-auth-provider-00KkSNpE.js.map → guest-auth-provider-5bX-xt6K.js.map} +1 -1
  15. package/dist/{guest-auth-provider-Tndt6tzJ.js → guest-auth-provider-CUNkZVFK.js} +2 -2
  16. package/dist/{guest-auth-provider-Tndt6tzJ.js.map → guest-auth-provider-CUNkZVFK.js.map} +1 -1
  17. package/dist/{guest-auth-provider-DjOFjtnk.mjs → guest-auth-provider-DDudqqxY.mjs} +2 -2
  18. package/dist/{guest-auth-provider-DjOFjtnk.mjs.map → guest-auth-provider-DDudqqxY.mjs.map} +1 -1
  19. package/dist/{guest-auth-provider-2J4fnTX5.mjs → guest-auth-provider-ejUTbjCC.mjs} +2 -2
  20. package/dist/{guest-auth-provider-2J4fnTX5.mjs.map → guest-auth-provider-ejUTbjCC.mjs.map} +1 -1
  21. package/dist/{index-D3kdhCpH.mjs → index-BAiLpNEQ.mjs} +190 -53
  22. package/dist/index-BAiLpNEQ.mjs.map +1 -0
  23. package/dist/{index-DJeEMevo.js → index-BZ0X1Z9X.js} +190 -53
  24. package/dist/index-BZ0X1Z9X.js.map +1 -0
  25. package/dist/index.js +1 -1
  26. package/dist/index.mjs +1 -1
  27. package/dist/{index.native-ingNhWPw.js → index.native-DJSOqyKQ.js} +101 -14
  28. package/dist/index.native-DJSOqyKQ.js.map +1 -0
  29. package/dist/{index.native-CAH_ks0s.mjs → index.native-DcW2klyn.mjs} +100 -15
  30. package/dist/index.native-DcW2klyn.mjs.map +1 -0
  31. package/dist/index.native.js +1 -1
  32. package/dist/index.native.mjs +1 -1
  33. package/dist/{injected-evm-wallet-provider-Cao1U0NZ.js → injected-evm-wallet-provider-BDYWjIOQ.js} +2 -2
  34. package/dist/{injected-evm-wallet-provider-Cao1U0NZ.js.map → injected-evm-wallet-provider-BDYWjIOQ.js.map} +1 -1
  35. package/dist/{injected-evm-wallet-provider-DXjwPjLW.mjs → injected-evm-wallet-provider-BQ_kG1vI.mjs} +2 -2
  36. package/dist/{injected-evm-wallet-provider-DXjwPjLW.mjs.map → injected-evm-wallet-provider-BQ_kG1vI.mjs.map} +1 -1
  37. package/dist/{injected-evm-wallet-provider-BtyG1HOX.mjs → injected-evm-wallet-provider-C4aKa2v1.mjs} +2 -2
  38. package/dist/{injected-evm-wallet-provider-BtyG1HOX.mjs.map → injected-evm-wallet-provider-C4aKa2v1.mjs.map} +1 -1
  39. package/dist/{injected-evm-wallet-provider-IlkuKffc.js → injected-evm-wallet-provider-D06arDQD.js} +2 -2
  40. package/dist/{injected-evm-wallet-provider-IlkuKffc.js.map → injected-evm-wallet-provider-D06arDQD.js.map} +1 -1
  41. package/dist/{injected-wallet-provider-BEYwsn6M.js → injected-wallet-provider-B9jvzDM5.js} +51 -22
  42. package/dist/{injected-wallet-provider-BEYwsn6M.js.map → injected-wallet-provider-B9jvzDM5.js.map} +1 -1
  43. package/dist/{injected-wallet-provider-0SSONh1d.mjs → injected-wallet-provider-Dj-F69gb.mjs} +51 -22
  44. package/dist/{injected-wallet-provider-0SSONh1d.mjs.map → injected-wallet-provider-Dj-F69gb.mjs.map} +1 -1
  45. package/dist/{injected-wallet-provider-DSlHfgMU.js → injected-wallet-provider-Dqmk-m4V.js} +67 -26
  46. package/dist/{injected-wallet-provider-DSlHfgMU.js.map → injected-wallet-provider-Dqmk-m4V.js.map} +1 -1
  47. package/dist/{injected-wallet-provider-CfYNIIHd.mjs → injected-wallet-provider-DxPcYxP-.mjs} +67 -26
  48. package/dist/{injected-wallet-provider-CfYNIIHd.mjs.map → injected-wallet-provider-DxPcYxP-.mjs.map} +1 -1
  49. package/package.json +2 -2
  50. package/dist/index-D3kdhCpH.mjs.map +0 -1
  51. package/dist/index-DJeEMevo.js.map +0 -1
  52. package/dist/index.native-CAH_ks0s.mjs.map +0 -1
  53. package/dist/index.native-ingNhWPw.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index_native = require('./index.native-ingNhWPw.js');
3
+ var index_native = require('./index.native-DJSOqyKQ.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-CAH_ks0s.mjs';
1
+ export { a3 as BUILD_DELEGATED_REVIEW_CAPABILITY_SCHEMA, a2 as BUILD_REVIEW_CAPABILITY_REFRESH_SCHEMA, a1 as BUILD_REVIEW_CAPABILITY_SCHEMA, W as BuildsApiError, a0 as FAILURE_REASONS, Y as NON_TERMINAL_STATES, T as OffchainAuthProvider, $ as PARK_REASONS, U as PrivyExpoProvider, _ as RUN_STATES, Z as TERMINAL_STATES, N as apps, V as builds, H as completeLoginFromRedirect, z as getAuthLoading, D as getAuthProvider, v as getCurrentUser, O as getIdToken, I as getLoginReturnError, g as getPlatform, u as init, B as login, J as loginWithPopup, F as loginWithPrivy, G as loginWithRedirect, C as logout, X as mediaAgentTools, y as onAuthLoadingChanged, x as onAuthStateChanged, P as onramp, Q as onrampQuote, R as onrampStatus, S as setPlatform, E as signInAnonymously, K as useAuth, M as useBuildRun, L as useQuery, A as waitForAuthReady } from './index.native-DcW2klyn.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,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var core = require('@bounded-sh/core');
4
- var index_native = require('./index.native-ingNhWPw.js');
4
+ var index_native = require('./index.native-DJSOqyKQ.js');
5
5
  require('react');
6
6
 
7
7
  // injected-evm-wallet-types.ts — tiny, dependency-free surface for the EVM
@@ -252,4 +252,4 @@ InjectedEvmWalletProvider.instance = null;
252
252
 
253
253
  exports.InjectedEvmWalletProvider = InjectedEvmWalletProvider;
254
254
  exports.defaultInjectedEvmProvider = defaultInjectedEvmProvider;
255
- //# sourceMappingURL=injected-evm-wallet-provider-Cao1U0NZ.js.map
255
+ //# sourceMappingURL=injected-evm-wallet-provider-BDYWjIOQ.js.map
@@ -1 +1 @@
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;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,kBAAkB,GAAG,EAAE;AAC7B,IAAI,wBAAwB,GAAG,KAAK;AACpC,SAAS,sBAAsB,GAAG;AAClC,IA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,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-BDYWjIOQ.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;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,g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C,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-CAH_ks0s.mjs';
2
+ import { l as setAuthLoading, s as setCurrentUser, o as setStoredAuthMethod } from './index.native-DcW2klyn.mjs';
3
3
  import 'react';
4
4
 
5
5
  // injected-evm-wallet-types.ts — tiny, dependency-free surface for the EVM
@@ -249,4 +249,4 @@ class InjectedEvmWalletProvider {
249
249
  InjectedEvmWalletProvider.instance = null;
250
250
 
251
251
  export { InjectedEvmWalletProvider, defaultInjectedEvmProvider };
252
- //# sourceMappingURL=injected-evm-wallet-provider-DXjwPjLW.mjs.map
252
+ //# sourceMappingURL=injected-evm-wallet-provider-BQ_kG1vI.mjs.map
@@ -1 +1 @@
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}\nInj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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-BQ_kG1vI.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;A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C;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 { o as defaultInjectedEvmProvider, j as setAuthLoading, s as setCurrentUser, l as setStoredAuthMethod } from './index-D3kdhCpH.mjs';
2
+ import { o as defaultInjectedEvmProvider, j as setAuthLoading, s as setCurrentUser, l as setStoredAuthMethod } from './index-BAiLpNEQ.mjs';
3
3
  import 'react';
4
4
 
5
5
  // Must equal the authMethod the registry (auth/index.ts) sets as currentAuthMethod,
@@ -183,4 +183,4 @@ class InjectedEvmWalletProvider {
183
183
  InjectedEvmWalletProvider.instance = null;
184
184
 
185
185
  export { InjectedEvmWalletProvider, defaultInjectedEvmProvider };
186
- //# sourceMappingURL=injected-evm-wallet-provider-BtyG1HOX.mjs.map
186
+ //# sourceMappingURL=injected-evm-wallet-provider-C4aKa2v1.mjs.map
@@ -1 +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,YA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;AACJ,IAAI,MAAM,MAAM,GAAG;AACnB;AACA;AACA,QAAQ,MAAMA,uBAAc,EAAE,CAAC,YAAY,EAAE;AAC7C,QAAQ,IAAI,CAAC,oBAAoB,GAAG,IAAI;AACxC,QAAQ,cAAc,CAAC,IAAI,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-C4aKa2v1.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;AACrD,QAAQ;AACR,QAAQ,IAAI,CAAC,MAAM,GAAG,UAAU;AAChC,QAAQ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1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var core = require('@bounded-sh/core');
4
- var index = require('./index-DJeEMevo.js');
4
+ var index = require('./index-BZ0X1Z9X.js');
5
5
  require('react');
6
6
 
7
7
  // Must equal the authMethod the registry (auth/index.ts) sets as currentAuthMethod,
@@ -186,4 +186,4 @@ InjectedEvmWalletProvider.instance = null;
186
186
 
187
187
  exports.defaultInjectedEvmProvider = index.defaultInjectedEvmProvider;
188
188
  exports.InjectedEvmWalletProvider = InjectedEvmWalletProvider;
189
- //# sourceMappingURL=injected-evm-wallet-provider-IlkuKffc.js.map
189
+ //# sourceMappingURL=injected-evm-wallet-provider-D06arDQD.js.map
@@ -1 +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,C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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-D06arDQD.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,mB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,IAAI,MAAM,MAAM,GAAG;AACnB;AACA;AACA,QAAQ,MAAMD,4BAAc,EAAE,CAAC,YAAY,EAAE;AAC7C,QAAQ,IAAI,CAAC,oBAAoB,GAAG,IAAI;AACxC,QAAQC,oBAAc,CAAC,IAAI,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,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var core = require('@bounded-sh/core');
4
- var index = require('./index-DJeEMevo.js');
4
+ var index = require('./index-BZ0X1Z9X.js');
5
5
  require('react');
6
6
 
7
7
  const crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
@@ -2467,37 +2467,66 @@ class InjectedWalletProvider {
2467
2467
  throw new Error('Wallet did not return a public key on connect');
2468
2468
  return pk.toString();
2469
2469
  }
2470
+ /**
2471
+ * The account the wallet already holds open for this page, named WITHOUT a
2472
+ * prompt: a live connection, else a silent connect (an injected wallet that
2473
+ * still trusts the page; the mobile wallet's cached authorization, read from
2474
+ * storage). Null when the wallet would have to ask the user.
2475
+ */
2476
+ async trustedAddress(provider) {
2477
+ try {
2478
+ return await this.connectAddress(provider, true);
2479
+ }
2480
+ catch (_a) {
2481
+ return null;
2482
+ }
2483
+ }
2470
2484
  async login() {
2485
+ var _a;
2471
2486
  index.setAuthLoading(true);
2472
2487
  try {
2473
2488
  const provider = this.resolveProvider();
2474
- const address = await this.connectAddress(provider);
2475
- // Reuse a still-valid session for THIS wallet.
2476
- const existing = await core.getActiveSessionManager().getSession();
2477
- if (existing && existing.address === address) {
2478
- const user = { address, id: address, provider: this };
2479
- this.authenticatedAddress = address;
2489
+ // SEC-01: a wallet without Sign In With Solana is refused before it is
2490
+ // asked anything, never downgraded to plain message signing.
2491
+ if (typeof provider.signIn !== 'function')
2492
+ throw new Error(WALLET_SIGN_IN_UNSUPPORTED_ERR);
2493
+ // Reuse a still-valid session for THIS wallet, when the wallet names its
2494
+ // account without prompting. Nothing here opens the wallet: the sign-in
2495
+ // below is the one interactive step of a login.
2496
+ const trusted = await this.trustedAddress(provider);
2497
+ const existing = trusted ? await core.getActiveSessionManager().getSession() : null;
2498
+ if (trusted && existing && existing.address === trusted) {
2499
+ const user = { address: trusted, id: trusted, provider: this };
2500
+ this.authenticatedAddress = trusted;
2480
2501
  index.setCurrentUser(user);
2481
2502
  this.markAuthMethod();
2482
2503
  return user;
2483
2504
  }
2484
- // Sign In With Solana (SEC-01): the wallet renders the standard sign-in
2485
- // text and, with the domain left unset here, stamps THIS page's host; the
2486
- // issuer refuses any other domain for the request's Origin, so a phishing
2487
- // page cannot obtain a login for another site. Bounded chooses only the nonce,
2488
- // the validity window and the app id (Request ID); a wallet without the
2489
- // feature is refused, never downgraded to plain message signing. The
2490
- // nonce is fetched HERE, after connect, on purpose: a network round trip
2491
- // before the wallet handoff decays the transient activation the mobile
2492
- // wallet's intent navigation needs.
2493
- if (typeof provider.signIn !== 'function')
2494
- throw new Error(WALLET_SIGN_IN_UNSUPPORTED_ERR);
2505
+ // Sign In With Solana (SEC-01) is connect and sign in ONE wallet step:
2506
+ // the wallet authorizes an account, renders the standard sign-in text
2507
+ // for it and, with the domain left unset here, stamps THIS page's host;
2508
+ // the issuer refuses any other domain for the request's Origin, so a
2509
+ // phishing page cannot obtain a login for another site. Bounded chooses
2510
+ // only the nonce, the validity window and the app id (Request ID).
2511
+ // No separate connect comes first: the mobile adapter would answer the
2512
+ // sign-in from the authorization that connect cached, with no sign-in
2513
+ // result in it, and a second wallet prompt is friction for every other
2514
+ // wallet. The nonce is fetched BEFORE the gesture below, so nothing
2515
+ // async sits between the tap and the wallet handoff - a network round
2516
+ // trip there decays the transient activation the mobile wallet's intent
2517
+ // navigation needs.
2495
2518
  const nonce = await core.genAuthNonce();
2496
2519
  const request = await core.genSolanaSignInRequest(nonce);
2497
- await this.freshActivation(provider, 'login', address);
2520
+ await this.freshActivation(provider, 'login', trusted);
2498
2521
  const signedIn = normalizeSignInOutput(await provider.signIn(request));
2499
- if (signedIn.account.address !== address) {
2500
- throw new Error(`The wallet signed in as ${signedIn.account.address}, not the connected account ${address}. Sign in again.`);
2522
+ const address = signedIn.account.address;
2523
+ // The account the wallet now reports as open must be the one that signed
2524
+ // in: a proof for another account would bind this session to an identity
2525
+ // the wallet is not acting as (DS2-0369). A wallet that reports no account
2526
+ // leaves the sign-in output as the only word on which one it is.
2527
+ const active = (_a = provider.publicKey) === null || _a === void 0 ? void 0 : _a.toString();
2528
+ if (active && active !== address) {
2529
+ throw new Error(`The wallet signed in as ${address}, not the connected account ${active}. Sign in again.`);
2501
2530
  }
2502
2531
  // The issuer verifies the signature over the EXACT bytes the wallet signed
2503
2532
  // and parses them, so the text travels as the wallet rendered it.
@@ -2817,4 +2846,4 @@ class InjectedWalletProvider {
2817
2846
  exports.defaultInjectedProvider = index.defaultInjectedProvider;
2818
2847
  exports.InjectedWalletProvider = InjectedWalletProvider;
2819
2848
  exports.WALLET_SIGN_IN_UNSUPPORTED_ERR = WALLET_SIGN_IN_UNSUPPORTED_ERR;
2820
- //# sourceMappingURL=injected-wallet-provider-BEYwsn6M.js.map
2849
+ //# sourceMappingURL=injected-wallet-provider-B9jvzDM5.js.map