@bounded-sh/client 0.0.43 → 0.0.48

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 (63) hide show
  1. package/dist/auth/crossmint-signer-bridge.d.ts +9 -1
  2. package/dist/auth/index.d.ts +1 -1
  3. package/dist/auth/providers/email-auth-provider.d.ts +2 -3
  4. package/dist/auth/providers/guest-auth-provider.d.ts +1 -1
  5. package/dist/auth/providers/injected-evm-wallet-provider.d.ts +37 -0
  6. package/dist/auth/providers/injected-evm-wallet-types.d.ts +65 -0
  7. package/dist/auth/providers/injected-wallet-provider.d.ts +1 -1
  8. package/dist/auth/providers/offchain-auth-provider.d.ts +3 -3
  9. package/dist/auth/providers/phantom-wallet-provider.d.ts +1 -1
  10. package/dist/auth/providers/privy-expo-provider.d.ts +1 -1
  11. package/dist/auth/providers/privy-wallet-provider.d.ts +1 -1
  12. package/dist/auth/providers/sol/sol-utils.d.ts +1 -1
  13. package/dist/auth/providers/transaction-utils.d.ts +1 -1
  14. package/dist/email-auth-provider-CTyjwhLb.mjs +99 -0
  15. package/dist/email-auth-provider-CTyjwhLb.mjs.map +1 -0
  16. package/dist/email-auth-provider-CmunfauO.js +102 -0
  17. package/dist/email-auth-provider-CmunfauO.js.map +1 -0
  18. package/dist/email-auth-provider-DyxZTpx6.js +102 -0
  19. package/dist/email-auth-provider-DyxZTpx6.js.map +1 -0
  20. package/dist/email-auth-provider-GRj8IOg2.mjs +99 -0
  21. package/dist/email-auth-provider-GRj8IOg2.mjs.map +1 -0
  22. package/dist/guest-auth-provider-B68XT2lU.js +193 -0
  23. package/dist/guest-auth-provider-B68XT2lU.js.map +1 -0
  24. package/dist/guest-auth-provider-C4BuTNIa.mjs +191 -0
  25. package/dist/guest-auth-provider-C4BuTNIa.mjs.map +1 -0
  26. package/dist/guest-auth-provider-D54uHbov.js +193 -0
  27. package/dist/guest-auth-provider-D54uHbov.js.map +1 -0
  28. package/dist/guest-auth-provider-Dk_km5tF.mjs +191 -0
  29. package/dist/guest-auth-provider-Dk_km5tF.mjs.map +1 -0
  30. package/dist/index-C0pR5b7j.mjs +5450 -0
  31. package/dist/index-C0pR5b7j.mjs.map +1 -0
  32. package/dist/index-JBeYYsGm.js +5508 -0
  33. package/dist/index-JBeYYsGm.js.map +1 -0
  34. package/dist/index.d.ts +3 -0
  35. package/dist/index.js +82 -5882
  36. package/dist/index.js.map +1 -1
  37. package/dist/index.mjs +2 -5789
  38. package/dist/index.mjs.map +1 -1
  39. package/dist/index.native-BZCc0gO-.js +5353 -0
  40. package/dist/index.native-BZCc0gO-.js.map +1 -0
  41. package/dist/index.native-CytJPNQV.mjs +5299 -0
  42. package/dist/index.native-CytJPNQV.mjs.map +1 -0
  43. package/dist/index.native.js +78 -5814
  44. package/dist/index.native.js.map +1 -1
  45. package/dist/index.native.mjs +2 -5723
  46. package/dist/index.native.mjs.map +1 -1
  47. package/dist/injected-evm-wallet-provider-BOMLGGHM.mjs +406 -0
  48. package/dist/injected-evm-wallet-provider-BOMLGGHM.mjs.map +1 -0
  49. package/dist/injected-evm-wallet-provider-CxAiNN7R.mjs +340 -0
  50. package/dist/injected-evm-wallet-provider-CxAiNN7R.mjs.map +1 -0
  51. package/dist/injected-evm-wallet-provider-T-EF9C3W.js +409 -0
  52. package/dist/injected-evm-wallet-provider-T-EF9C3W.js.map +1 -0
  53. package/dist/injected-evm-wallet-provider-_eeYB1ww.js +343 -0
  54. package/dist/injected-evm-wallet-provider-_eeYB1ww.js.map +1 -0
  55. package/dist/injected-wallet-provider-B1uq3r4r.mjs +260 -0
  56. package/dist/injected-wallet-provider-B1uq3r4r.mjs.map +1 -0
  57. package/dist/injected-wallet-provider-B2T7JEvn.js +263 -0
  58. package/dist/injected-wallet-provider-B2T7JEvn.js.map +1 -0
  59. package/dist/injected-wallet-provider-BBZym7YQ.js +282 -0
  60. package/dist/injected-wallet-provider-BBZym7YQ.js.map +1 -0
  61. package/dist/injected-wallet-provider-DCwygA3j.mjs +279 -0
  62. package/dist/injected-wallet-provider-DCwygA3j.mjs.map +1 -0
  63. package/package.json +132 -127
@@ -1,4 +1,5 @@
1
- import { Transaction, VersionedTransaction } from '@solana/web3.js';
1
+ import type { EVMTransaction, TransactionResult } from '@bounded-sh/core';
2
+ import type { Transaction, VersionedTransaction } from '@solana/web3.js';
2
3
  export type SignerAction = {
3
4
  kind: 'sendToken';
4
5
  recipient: string;
@@ -7,6 +8,9 @@ export type SignerAction = {
7
8
  } | {
8
9
  kind: 'transaction';
9
10
  serializedTransaction: string;
11
+ } | {
12
+ kind: 'evmTransaction';
13
+ transaction: Pick<EVMTransaction, 'to' | 'data' | 'value' | 'chainId'>;
10
14
  };
11
15
  export interface SignerResult {
12
16
  hash?: string;
@@ -29,9 +33,13 @@ export declare function signViaSignerPopup(action: SignerAction): Promise<Signer
29
33
  * route signing through the popup rather than throw "no wallet").
30
34
  */
31
35
  export declare function hasEmbeddedWallet(): boolean;
36
+ /** Whether the active email/social session carries an embedded Crossmint EVM wallet. */
37
+ export declare function hasEmbeddedEvmWallet(): boolean;
32
38
  /** signAndSubmitTransaction for embedded wallets: serialize + route through the
33
39
  * signer popup, resolve with the on-chain transaction signature/hash. */
34
40
  export declare function embeddedSignAndSubmit(transaction: Transaction | VersionedTransaction): Promise<string>;
35
41
  /** Send a token from the embedded wallet (Crossmint `wallet.send`). Convenience
36
42
  * primitive for the common "send crypto" case; returns the tx result. */
37
43
  export declare function embeddedSendToken(recipient: string, token: string, amount: string): Promise<SignerResult>;
44
+ /** Submit a validated BoundedRuntime EVM write through the user's email signer. */
45
+ export declare function embeddedRunEvmTransaction(transaction: EVMTransaction): Promise<TransactionResult>;
@@ -1,4 +1,4 @@
1
- import { AuthProvider, User, ClientConfig } from "@bounded-sh/core";
1
+ import type { AuthProvider, User, ClientConfig } from "@bounded-sh/core";
2
2
  /**
3
3
  * Clears the session if it was created by a different auth method.
4
4
  * Returns true if the session was cleared, false if the session is compatible.
@@ -1,12 +1,11 @@
1
1
  import type { AuthProvider, User, TransactionResult, SolTransaction, EVMTransaction, SetOptions } from '@bounded-sh/core';
2
- import { Transaction, VersionedTransaction } from '@solana/web3.js';
3
- import { PublicKey } from '@solana/web3.js';
2
+ import type { PublicKey, Transaction, VersionedTransaction } from '@solana/web3.js';
4
3
  export declare class EmailAuthProvider implements AuthProvider {
5
4
  login(): Promise<User | null>;
6
5
  restoreSession(): Promise<User | null>;
7
6
  logout(): Promise<void>;
8
7
  signMessage(_message: string): Promise<string>;
9
- runTransaction(_evm?: EVMTransaction, _sol?: SolTransaction, _options?: SetOptions): Promise<TransactionResult>;
8
+ runTransaction(evm?: EVMTransaction, sol?: SolTransaction, options?: SetOptions): Promise<TransactionResult>;
10
9
  signTransaction(_t: Transaction | VersionedTransaction): Promise<Transaction | VersionedTransaction>;
11
10
  signAndSubmitTransaction(transaction: Transaction | VersionedTransaction, _feePayer?: PublicKey): Promise<string>;
12
11
  getNativeMethods(): Promise<any>;
@@ -1,5 +1,5 @@
1
1
  import type { AuthProvider, User, TransactionResult, SolTransaction, EVMTransaction, SetOptions } from '@bounded-sh/core';
2
- import { Transaction, VersionedTransaction } from '@solana/web3.js';
2
+ import type { Transaction, VersionedTransaction } from '@solana/web3.js';
3
3
  export declare class GuestAuthProvider implements AuthProvider {
4
4
  login(): Promise<User | null>;
5
5
  restoreSession(): Promise<User | null>;
@@ -0,0 +1,37 @@
1
+ import type { EVMTransaction, SolTransaction, TransactionResult, User, AuthProvider, SetOptions } from '@bounded-sh/core';
2
+ import type { Transaction, VersionedTransaction, PublicKey } from '@solana/web3.js';
3
+ import { defaultInjectedEvmProvider, type InjectedEvmProvider, type InjectedEvmWalletConfig } from './injected-evm-wallet-types';
4
+ export { defaultInjectedEvmProvider };
5
+ export type { InjectedEvmProvider, InjectedEvmWalletConfig };
6
+ export declare class InjectedEvmWalletProvider implements AuthProvider {
7
+ private static instance;
8
+ private config;
9
+ private authenticatedAddress;
10
+ constructor(config?: InjectedEvmWalletConfig);
11
+ private evmUser;
12
+ private resolveProvider;
13
+ /** Connect the injected wallet and return its canonical lowercase EVM address. */
14
+ private connectAddress;
15
+ /** Current chain id the wallet is connected to (EIP-155 number), or null. */
16
+ private currentChainId;
17
+ login(): Promise<User | null>;
18
+ private resolveDomain;
19
+ private resolveUri;
20
+ private markAuthMethod;
21
+ restoreSession(): Promise<User | null>;
22
+ logout(): Promise<void>;
23
+ /** App-facing message signing: EIP-191 personal_sign, returns 0x r‖s‖v hex. */
24
+ signMessage(message: string): Promise<string>;
25
+ signTransaction(_transaction: Transaction | VersionedTransaction): Promise<Transaction | VersionedTransaction>;
26
+ signAndSubmitTransaction(_transaction: Transaction | VersionedTransaction, _feePayer?: PublicKey): Promise<string>;
27
+ /**
28
+ * Onchain write path: submit the worker's PRE-BUILT EIP-1559 tx via
29
+ * eth_sendTransaction (the injected wallet signs + submits in one step), then
30
+ * poll for the receipt. The EVM branch of operations.ts's 202 dispatch calls
31
+ * this with the pre-built payload in the EVM slot and the Solana slot undefined.
32
+ */
33
+ runTransaction(evmTransactionData?: EVMTransaction, solTransactionData?: SolTransaction, options?: SetOptions): Promise<TransactionResult>;
34
+ /** Poll eth_getTransactionReceipt until it lands (bounded retries) or throw. */
35
+ private waitForReceipt;
36
+ getNativeMethods(): Promise<any>;
37
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Minimal EIP-1193 provider shape. Every browser EVM wallet implements
3
+ * `request({ method, params })`; `on`/`removeListener` are optional (used for
4
+ * chain/account change events, which this path does not require).
5
+ */
6
+ export interface InjectedEvmProvider {
7
+ request(args: {
8
+ method: string;
9
+ params?: any[] | Record<string, any>;
10
+ }): Promise<any>;
11
+ on?(event: string, listener: (...args: any[]) => void): void;
12
+ removeListener?(event: string, listener: (...args: any[]) => void): void;
13
+ isMetaMask?: boolean;
14
+ }
15
+ /** EIP-6963 provider metadata announced by a wallet. */
16
+ export interface Eip6963ProviderInfo {
17
+ uuid: string;
18
+ name: string;
19
+ icon: string;
20
+ rdns: string;
21
+ }
22
+ /** EIP-6963 `eip6963:announceProvider` detail payload. */
23
+ export interface Eip6963ProviderDetail {
24
+ info: Eip6963ProviderInfo;
25
+ provider: InjectedEvmProvider;
26
+ }
27
+ export interface InjectedEvmWalletConfig {
28
+ /**
29
+ * Resolve/pick the injected EVM provider. Defaults to EIP-6963 discovery
30
+ * (first announced wallet) then `window.ethereum`. Pass this to point at a
31
+ * specific wallet, or to bridge a custom/mock provider.
32
+ */
33
+ getProvider?: () => InjectedEvmProvider | null | undefined;
34
+ /**
35
+ * EIP-155 chain id the app expects to write on. Used for the SIWE `Chain ID`
36
+ * line and as the chain-switch guard target in runTransaction (a pre-built tx
37
+ * always carries its own chainId, which takes precedence there).
38
+ */
39
+ chainId?: number;
40
+ /** Explicit RPC URL override (reserved; the injected wallet submits via itself). */
41
+ rpcUrl?: string | null;
42
+ /**
43
+ * Optional assertion of the SIWE `domain`. It must equal
44
+ * window.location.host; cross-origin overrides are rejected.
45
+ */
46
+ domain?: string;
47
+ /** Optional assertion of the SIWE URI. Its origin must equal window.location.origin. */
48
+ uri?: string;
49
+ /** Trusted BoundedRuntime for `chainId`; required for single-chain writes. */
50
+ runtimeAddress?: string;
51
+ /** Trusted per-chain BoundedRuntime allowlist for multi-chain writes. */
52
+ runtimeAddresses?: Record<string, string>;
53
+ }
54
+ /**
55
+ * Request + collect EIP-6963 providers. Dispatches `eip6963:requestProvider`
56
+ * (synchronous — already-loaded wallets announce in the same tick) and returns
57
+ * every wallet announced so far. Kept synchronous so it works inside a user
58
+ * gesture and can be eagerly exported from the SDK entry.
59
+ */
60
+ export declare function requestEip6963Providers(): Eip6963ProviderDetail[];
61
+ /**
62
+ * Default EVM provider discovery: EIP-6963 first (multi-wallet, collision-free),
63
+ * then legacy `window.ethereum`. Returns null when no injected wallet is present.
64
+ */
65
+ export declare function defaultInjectedEvmProvider(): InjectedEvmProvider | null;
@@ -1,5 +1,5 @@
1
1
  import type { EVMTransaction, SolTransaction, TransactionResult, User, AuthProvider, SetOptions } from '@bounded-sh/core';
2
- import { PublicKey, Transaction, VersionedTransaction } from '@solana/web3.js';
2
+ import type { PublicKey, Transaction, VersionedTransaction } from '@solana/web3.js';
3
3
  import { defaultInjectedProvider, type InjectedSolanaProvider, type InjectedWalletConfig } from './injected-wallet-types';
4
4
  export { defaultInjectedProvider };
5
5
  export type { InjectedSolanaProvider, InjectedWalletConfig };
@@ -1,6 +1,6 @@
1
- import { AuthProvider, User, TransactionResult, EVMTransaction, SolTransaction } from "@bounded-sh/core";
2
- import { SetOptions } from "@bounded-sh/core";
3
- import { Transaction, VersionedTransaction } from "@solana/web3.js";
1
+ import type { AuthProvider, User, TransactionResult, EVMTransaction, SolTransaction } from "@bounded-sh/core";
2
+ import type { SetOptions } from "@bounded-sh/core";
3
+ import type { Transaction, VersionedTransaction } from "@solana/web3.js";
4
4
  export interface OffchainAuthProviderConfig {
5
5
  onSigningStart?: () => void;
6
6
  onSigningComplete?: (signature: string) => void;
@@ -1,5 +1,5 @@
1
1
  import type { EVMTransaction, SolTransaction, TransactionResult, User, AuthProvider, SetOptions } from '@bounded-sh/core';
2
- import { PublicKey, Transaction, VersionedTransaction } from '@solana/web3.js';
2
+ import type { PublicKey, Transaction, VersionedTransaction } from '@solana/web3.js';
3
3
  export type PhantomProviderType = 'injected' | 'google' | 'apple' | 'deeplink' | 'phantom';
4
4
  export interface PhantomWalletConfig {
5
5
  appId?: string;
@@ -19,7 +19,7 @@
19
19
  * to render <PrivyProvider> and then bridge the hooks via setPrivyMethods().
20
20
  */
21
21
  import type { EVMTransaction, SolTransaction, TransactionResult, AuthProvider, User, SetOptions } from '@bounded-sh/core';
22
- import { PublicKey, Connection, Transaction, VersionedTransaction } from '@solana/web3.js';
22
+ import type { PublicKey, Connection, Transaction, VersionedTransaction } from '@solana/web3.js';
23
23
  export interface PrivyExpoMethods {
24
24
  /** Whether Privy SDK is fully initialized. */
25
25
  isReady: boolean;
@@ -1,5 +1,5 @@
1
1
  import type { EVMTransaction, SolTransaction, TransactionResult, AuthProvider, User, SetOptions } from '@bounded-sh/core';
2
- import { PublicKey, Transaction, VersionedTransaction } from '@solana/web3.js';
2
+ import type { PublicKey, Transaction, VersionedTransaction } from '@solana/web3.js';
3
3
  type PrivyWalletConfig = {
4
4
  appId: string;
5
5
  config: any;
@@ -1,2 +1,2 @@
1
- import { Transaction, VersionedTransaction } from "@solana/web3.js";
1
+ import type { Transaction, VersionedTransaction } from "@solana/web3.js";
2
2
  export declare function deserializeTransaction(tx: string | Buffer): Promise<Transaction | VersionedTransaction>;
@@ -1,4 +1,4 @@
1
- import { Connection } from '@solana/web3.js';
1
+ import type { Connection } from '@solana/web3.js';
2
2
  /**
3
3
  * Extracts a human-readable error message from Solana transaction logs.
4
4
  */
@@ -0,0 +1,99 @@
1
+ import { getActiveSessionManager } from '@bounded-sh/core';
2
+ import { s as setCurrentUser, E as EMBEDDED_WALLET_UNSUPPORTED, h as hasEmbeddedWallet, a as hasEmbeddedEvmWallet, e as embeddedRunEvmTransaction, b as embeddedSignAndSubmit, g as getPlatform } from './index-C0pR5b7j.mjs';
3
+ import 'react';
4
+
5
+ // Web uses localStorage (WebSessionManager); React Native uses the configured
6
+ // ReactNativeSessionManager. getActiveSessionManager() picks the right one by
7
+ // whether the RN manager was configured (NOT `typeof window`, which is truthy on
8
+ // RN too and would wrongly route to localStorage). Same selector the core
9
+ // request path uses, so hosted Bounded Auth sessions persist + authenticate on BOTH.
10
+ const sessionManager = getActiveSessionManager;
11
+ const NO_WALLET = 'Email login has no embedded wallet. Enable `"auth": { "wallets": true }` in ' +
12
+ 'the app policy so email logins get a non-custodial Crossmint wallet ' +
13
+ '(@user.address), then sign from a user gesture. Otherwise use a wallet ' +
14
+ 'provider (e.g. Phantom) for onchain actions.';
15
+ // ---------------------------------------------------------------------------
16
+ // token / session helpers
17
+ // ---------------------------------------------------------------------------
18
+ function decodeJwt(token) {
19
+ try {
20
+ let b64 = token.split('.')[1].replace(/-/g, '+').replace(/_/g, '/');
21
+ const pad = b64.length % 4;
22
+ if (pad === 2)
23
+ b64 += '==';
24
+ else if (pad === 3)
25
+ b64 += '=';
26
+ // getPlatform().atob is RN-safe (global atob is undefined on Hermes/JSC).
27
+ return JSON.parse(getPlatform().atob(b64));
28
+ }
29
+ catch (_a) {
30
+ return {};
31
+ }
32
+ }
33
+ function userFromIdToken(idToken, fallbackEmail) {
34
+ const c = decodeJwt(idToken);
35
+ const id = c['custom:userId'] || c.sub || c['custom:walletAddress'] || '';
36
+ const email = (c.email || fallbackEmail || null);
37
+ // Email logins have no wallet — address is null (the User type allows it).
38
+ const evmAddress = typeof c['custom:evmWalletAddress'] === 'string' && /^0x[0-9a-fA-F]{40}$/.test(c['custom:evmWalletAddress'])
39
+ ? c['custom:evmWalletAddress'].toLowerCase()
40
+ : null;
41
+ return { id, address: (c['custom:walletAddress'] || null), evmAddress, email, provider: emailProviderSingleton };
42
+ }
43
+ // ---------------------------------------------------------------------------
44
+ // provider
45
+ // ---------------------------------------------------------------------------
46
+ class EmailAuthProvider {
47
+ async login() {
48
+ throw new Error('login() no longer opens inline email OTP. Use loginWithRedirect({ redirectUri }) ' +
49
+ 'or loginWithPopup({ redirectUri }) for hosted Bounded Auth.');
50
+ }
51
+ async restoreSession() {
52
+ const sm = sessionManager();
53
+ const session = await sm.getSession();
54
+ if (!session)
55
+ return null;
56
+ const idToken = sm.getIdToken();
57
+ if (!idToken)
58
+ return null;
59
+ const user = userFromIdToken(idToken);
60
+ setCurrentUser(user);
61
+ return user;
62
+ }
63
+ async logout() {
64
+ sessionManager().clearSession();
65
+ setCurrentUser(null);
66
+ }
67
+ // Crossmint Solana smart wallets sign+submit atomically and cannot produce a
68
+ // raw signature — signMessage/signTransaction are structurally unsupported
69
+ // (throw the clear "use signAndSubmitTransaction" error when a wallet exists;
70
+ // the no-wallet error otherwise). signAndSubmitTransaction routes through the
71
+ // Bounded signer popup for wallets-enabled email logins.
72
+ async signMessage(_message) {
73
+ throw new Error(hasEmbeddedWallet() ? EMBEDDED_WALLET_UNSUPPORTED : NO_WALLET);
74
+ }
75
+ async runTransaction(evm, sol, options) {
76
+ if (evm && sol)
77
+ throw new Error('A transaction cannot target EVM and Solana at the same time.');
78
+ if (!evm)
79
+ throw new Error(NO_WALLET);
80
+ if ((options === null || options === void 0 ? void 0 : options.shouldSubmitTx) === false)
81
+ throw new Error('Embedded EVM wallets sign and submit atomically; shouldSubmitTx:false is unsupported.');
82
+ if (!hasEmbeddedEvmWallet())
83
+ throw new Error('This login has no embedded EVM wallet. Enable auth.wallets on an app with an EVM collection and sign in again.');
84
+ return embeddedRunEvmTransaction(evm);
85
+ }
86
+ async signTransaction(_t) {
87
+ throw new Error(hasEmbeddedWallet() ? EMBEDDED_WALLET_UNSUPPORTED : NO_WALLET);
88
+ }
89
+ async signAndSubmitTransaction(transaction, _feePayer) {
90
+ if (!hasEmbeddedWallet())
91
+ throw new Error(NO_WALLET);
92
+ return embeddedSignAndSubmit(transaction);
93
+ }
94
+ async getNativeMethods() { return {}; }
95
+ }
96
+ const emailProviderSingleton = new EmailAuthProvider();
97
+
98
+ export { EmailAuthProvider, emailProviderSingleton };
99
+ //# sourceMappingURL=email-auth-provider-CTyjwhLb.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email-auth-provider-CTyjwhLb.mjs","sources":["../.rollup-tmp/auth/providers/email-auth-provider.js"],"sourcesContent":["import { getActiveSessionManager } from '@bounded-sh/core';\nimport { setCurrentUser } from '../../global';\nimport { getPlatform } from '../../platform';\nimport { hasEmbeddedWallet, hasEmbeddedEvmWallet, embeddedSignAndSubmit, embeddedRunEvmTransaction, EMBEDDED_WALLET_UNSUPPORTED, } from '../crossmint-signer-bridge';\n// Web uses localStorage (WebSessionManager); React Native uses the configured\n// ReactNativeSessionManager. getActiveSessionManager() picks the right one by\n// whether the RN manager was configured (NOT `typeof window`, which is truthy on\n// RN too and would wrongly route to localStorage). Same selector the core\n// request path uses, so hosted Bounded Auth sessions persist + authenticate on BOTH.\nconst sessionManager = getActiveSessionManager;\nconst NO_WALLET = 'Email login has no embedded wallet. Enable `\"auth\": { \"wallets\": true }` in ' +\n 'the app policy so email logins get a non-custodial Crossmint wallet ' +\n '(@user.address), then sign from a user gesture. Otherwise use a wallet ' +\n 'provider (e.g. Phantom) for onchain actions.';\n// ---------------------------------------------------------------------------\n// token / session helpers\n// ---------------------------------------------------------------------------\nfunction decodeJwt(token) {\n try {\n let b64 = token.split('.')[1].replace(/-/g, '+').replace(/_/g, '/');\n const pad = b64.length % 4;\n if (pad === 2)\n b64 += '==';\n else if (pad === 3)\n b64 += '=';\n // getPlatform().atob is RN-safe (global atob is undefined on Hermes/JSC).\n return JSON.parse(getPlatform().atob(b64));\n }\n catch (_a) {\n return {};\n }\n}\nfunction userFromIdToken(idToken, fallbackEmail) {\n const c = decodeJwt(idToken);\n const id = c['custom:userId'] || c.sub || c['custom:walletAddress'] || '';\n const email = (c.email || fallbackEmail || null);\n // Email logins have no wallet — address is null (the User type allows it).\n const evmAddress = typeof c['custom:evmWalletAddress'] === 'string' && /^0x[0-9a-fA-F]{40}$/.test(c['custom:evmWalletAddress'])\n ? c['custom:evmWalletAddress'].toLowerCase()\n : null;\n return { id, address: (c['custom:walletAddress'] || null), evmAddress, email, provider: emailProviderSingleton };\n}\n// ---------------------------------------------------------------------------\n// provider\n// ---------------------------------------------------------------------------\nexport class EmailAuthProvider {\n async login() {\n throw new Error('login() no longer opens inline email OTP. Use loginWithRedirect({ redirectUri }) ' +\n 'or loginWithPopup({ redirectUri }) for hosted Bounded Auth.');\n }\n async restoreSession() {\n const sm = sessionManager();\n const session = await sm.getSession();\n if (!session)\n return null;\n const idToken = sm.getIdToken();\n if (!idToken)\n return null;\n const user = userFromIdToken(idToken);\n setCurrentUser(user);\n return user;\n }\n async logout() {\n sessionManager().clearSession();\n setCurrentUser(null);\n }\n // Crossmint Solana smart wallets sign+submit atomically and cannot produce a\n // raw signature — signMessage/signTransaction are structurally unsupported\n // (throw the clear \"use signAndSubmitTransaction\" error when a wallet exists;\n // the no-wallet error otherwise). signAndSubmitTransaction routes through the\n // Bounded signer popup for wallets-enabled email logins.\n async signMessage(_message) {\n throw new Error(hasEmbeddedWallet() ? EMBEDDED_WALLET_UNSUPPORTED : NO_WALLET);\n }\n async runTransaction(evm, sol, options) {\n if (evm && sol)\n throw new Error('A transaction cannot target EVM and Solana at the same time.');\n if (!evm)\n throw new Error(NO_WALLET);\n if ((options === null || options === void 0 ? void 0 : options.shouldSubmitTx) === false)\n throw new Error('Embedded EVM wallets sign and submit atomically; shouldSubmitTx:false is unsupported.');\n if (!hasEmbeddedEvmWallet())\n throw new Error('This login has no embedded EVM wallet. Enable auth.wallets on an app with an EVM collection and sign in again.');\n return embeddedRunEvmTransaction(evm);\n }\n async signTransaction(_t) {\n throw new Error(hasEmbeddedWallet() ? EMBEDDED_WALLET_UNSUPPORTED : NO_WALLET);\n }\n async signAndSubmitTransaction(transaction, _feePayer) {\n if (!hasEmbeddedWallet())\n throw new Error(NO_WALLET);\n return embeddedSignAndSubmit(transaction);\n }\n async getNativeMethods() { return {}; }\n}\nconst emailProviderSingleton = new EmailAuthProvider();\nexport { emailProviderSingleton };\n"],"names":[],"mappings":";;;;AAIA;AACA;AACA;AACA;AACA;AACA,MAAM,cAAc,GAAG,uBAAuB;AAC9C,MAAM,SAAS,GAAG,8EAA8E;AAChG,IAAI,sEAAsE;AAC1E,IAAI,yEAAyE;AAC7E,IAAI,8CAA8C;AAClD;AACA;AACA;AACA,SAAS,SAAS,CAAC,KAAK,EAAE;AAC1B,IAAI,IAAI;AACR,QAAQ,IAAI,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;AAC3E,QAAQ,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC;AAClC,QAAQ,IAAI,GAAG,KAAK,CAAC;AACrB,YAAY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AG,2BAA2B,GAAG,SAAS,CAAC;AACtF,IAAI;AACJ,IAAI,MAAM,wBAAwB,CAAC,WAAW,EAAE,SAAS,EAAE;AAC3D,QAAQ,IAAI,CAAC,iBAAiB,EAAE;AAChC,YAAY,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC;AACtC,QAAQ,OAAO,qBAAqB,CAAC,WAAW,CAAC;AACjD,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1C;AACK,MAAC,sBAAsB,GAAG,IAAI,iBAAiB;;;;"}
@@ -0,0 +1,102 @@
1
+ 'use strict';
2
+
3
+ var core = require('@bounded-sh/core');
4
+ var index_native = require('./index.native-BZCc0gO-.js');
5
+ require('react');
6
+
7
+ // Web uses localStorage (WebSessionManager); React Native uses the configured
8
+ // ReactNativeSessionManager. getActiveSessionManager() picks the right one by
9
+ // whether the RN manager was configured (NOT `typeof window`, which is truthy on
10
+ // RN too and would wrongly route to localStorage). Same selector the core
11
+ // request path uses, so hosted Bounded Auth sessions persist + authenticate on BOTH.
12
+ const sessionManager = core.getActiveSessionManager;
13
+ const NO_WALLET = 'Email login has no embedded wallet. Enable `"auth": { "wallets": true }` in ' +
14
+ 'the app policy so email logins get a non-custodial Crossmint wallet ' +
15
+ '(@user.address), then sign from a user gesture. Otherwise use a wallet ' +
16
+ 'provider (e.g. Phantom) for onchain actions.';
17
+ // ---------------------------------------------------------------------------
18
+ // token / session helpers
19
+ // ---------------------------------------------------------------------------
20
+ function decodeJwt(token) {
21
+ try {
22
+ let b64 = token.split('.')[1].replace(/-/g, '+').replace(/_/g, '/');
23
+ const pad = b64.length % 4;
24
+ if (pad === 2)
25
+ b64 += '==';
26
+ else if (pad === 3)
27
+ b64 += '=';
28
+ // getPlatform().atob is RN-safe (global atob is undefined on Hermes/JSC).
29
+ return JSON.parse(index_native.getPlatform().atob(b64));
30
+ }
31
+ catch (_a) {
32
+ return {};
33
+ }
34
+ }
35
+ function userFromIdToken(idToken, fallbackEmail) {
36
+ const c = decodeJwt(idToken);
37
+ const id = c['custom:userId'] || c.sub || c['custom:walletAddress'] || '';
38
+ const email = (c.email || fallbackEmail || null);
39
+ // Email logins have no wallet — address is null (the User type allows it).
40
+ const evmAddress = typeof c['custom:evmWalletAddress'] === 'string' && /^0x[0-9a-fA-F]{40}$/.test(c['custom:evmWalletAddress'])
41
+ ? c['custom:evmWalletAddress'].toLowerCase()
42
+ : null;
43
+ return { id, address: (c['custom:walletAddress'] || null), evmAddress, email, provider: emailProviderSingleton };
44
+ }
45
+ // ---------------------------------------------------------------------------
46
+ // provider
47
+ // ---------------------------------------------------------------------------
48
+ class EmailAuthProvider {
49
+ async login() {
50
+ throw new Error('login() no longer opens inline email OTP. Use loginWithRedirect({ redirectUri }) ' +
51
+ 'or loginWithPopup({ redirectUri }) for hosted Bounded Auth.');
52
+ }
53
+ async restoreSession() {
54
+ const sm = sessionManager();
55
+ const session = await sm.getSession();
56
+ if (!session)
57
+ return null;
58
+ const idToken = sm.getIdToken();
59
+ if (!idToken)
60
+ return null;
61
+ const user = userFromIdToken(idToken);
62
+ index_native.setCurrentUser(user);
63
+ return user;
64
+ }
65
+ async logout() {
66
+ sessionManager().clearSession();
67
+ index_native.setCurrentUser(null);
68
+ }
69
+ // Crossmint Solana smart wallets sign+submit atomically and cannot produce a
70
+ // raw signature — signMessage/signTransaction are structurally unsupported
71
+ // (throw the clear "use signAndSubmitTransaction" error when a wallet exists;
72
+ // the no-wallet error otherwise). signAndSubmitTransaction routes through the
73
+ // Bounded signer popup for wallets-enabled email logins.
74
+ async signMessage(_message) {
75
+ throw new Error(index_native.hasEmbeddedWallet() ? index_native.EMBEDDED_WALLET_UNSUPPORTED : NO_WALLET);
76
+ }
77
+ async runTransaction(evm, sol, options) {
78
+ if (evm && sol)
79
+ throw new Error('A transaction cannot target EVM and Solana at the same time.');
80
+ if (!evm)
81
+ throw new Error(NO_WALLET);
82
+ if ((options === null || options === void 0 ? void 0 : options.shouldSubmitTx) === false)
83
+ throw new Error('Embedded EVM wallets sign and submit atomically; shouldSubmitTx:false is unsupported.');
84
+ if (!index_native.hasEmbeddedEvmWallet())
85
+ throw new Error('This login has no embedded EVM wallet. Enable auth.wallets on an app with an EVM collection and sign in again.');
86
+ return index_native.embeddedRunEvmTransaction(evm);
87
+ }
88
+ async signTransaction(_t) {
89
+ throw new Error(index_native.hasEmbeddedWallet() ? index_native.EMBEDDED_WALLET_UNSUPPORTED : NO_WALLET);
90
+ }
91
+ async signAndSubmitTransaction(transaction, _feePayer) {
92
+ if (!index_native.hasEmbeddedWallet())
93
+ throw new Error(NO_WALLET);
94
+ return index_native.embeddedSignAndSubmit(transaction);
95
+ }
96
+ async getNativeMethods() { return {}; }
97
+ }
98
+ const emailProviderSingleton = new EmailAuthProvider();
99
+
100
+ exports.EmailAuthProvider = EmailAuthProvider;
101
+ exports.emailProviderSingleton = emailProviderSingleton;
102
+ //# sourceMappingURL=email-auth-provider-CmunfauO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email-auth-provider-CmunfauO.js","sources":["../.rollup-tmp/auth/providers/email-auth-provider.js"],"sourcesContent":["import { getActiveSessionManager } from '@bounded-sh/core';\nimport { setCurrentUser } from '../../global';\nimport { getPlatform } from '../../platform';\nimport { hasEmbeddedWallet, hasEmbeddedEvmWallet, embeddedSignAndSubmit, embeddedRunEvmTransaction, EMBEDDED_WALLET_UNSUPPORTED, } from '../crossmint-signer-bridge';\n// Web uses localStorage (WebSessionManager); React Native uses the configured\n// ReactNativeSessionManager. getActiveSessionManager() picks the right one by\n// whether the RN manager was configured (NOT `typeof window`, which is truthy on\n// RN too and would wrongly route to localStorage). Same selector the core\n// request path uses, so hosted Bounded Auth sessions persist + authenticate on BOTH.\nconst sessionManager = getActiveSessionManager;\nconst NO_WALLET = 'Email login has no embedded wallet. Enable `\"auth\": { \"wallets\": true }` in ' +\n 'the app policy so email logins get a non-custodial Crossmint wallet ' +\n '(@user.address), then sign from a user gesture. Otherwise use a wallet ' +\n 'provider (e.g. Phantom) for onchain actions.';\n// ---------------------------------------------------------------------------\n// token / session helpers\n// ---------------------------------------------------------------------------\nfunction decodeJwt(token) {\n try {\n let b64 = token.split('.')[1].replace(/-/g, '+').replace(/_/g, '/');\n const pad = b64.length % 4;\n if (pad === 2)\n b64 += '==';\n else if (pad === 3)\n b64 += '=';\n // getPlatform().atob is RN-safe (global atob is undefined on Hermes/JSC).\n return JSON.parse(getPlatform().atob(b64));\n }\n catch (_a) {\n return {};\n }\n}\nfunction userFromIdToken(idToken, fallbackEmail) {\n const c = decodeJwt(idToken);\n const id = c['custom:userId'] || c.sub || c['custom:walletAddress'] || '';\n const email = (c.email || fallbackEmail || null);\n // Email logins have no wallet — address is null (the User type allows it).\n const evmAddress = typeof c['custom:evmWalletAddress'] === 'string' && /^0x[0-9a-fA-F]{40}$/.test(c['custom:evmWalletAddress'])\n ? c['custom:evmWalletAddress'].toLowerCase()\n : null;\n return { id, address: (c['custom:walletAddress'] || null), evmAddress, email, provider: emailProviderSingleton };\n}\n// ---------------------------------------------------------------------------\n// provider\n// ---------------------------------------------------------------------------\nexport class EmailAuthProvider {\n async login() {\n throw new Error('login() no longer opens inline email OTP. Use loginWithRedirect({ redirectUri }) ' +\n 'or loginWithPopup({ redirectUri }) for hosted Bounded Auth.');\n }\n async restoreSession() {\n const sm = sessionManager();\n const session = await sm.getSession();\n if (!session)\n return null;\n const idToken = sm.getIdToken();\n if (!idToken)\n return null;\n const user = userFromIdToken(idToken);\n setCurrentUser(user);\n return user;\n }\n async logout() {\n sessionManager().clearSession();\n setCurrentUser(null);\n }\n // Crossmint Solana smart wallets sign+submit atomically and cannot produce a\n // raw signature — signMessage/signTransaction are structurally unsupported\n // (throw the clear \"use signAndSubmitTransaction\" error when a wallet exists;\n // the no-wallet error otherwise). signAndSubmitTransaction routes through the\n // Bounded signer popup for wallets-enabled email logins.\n async signMessage(_message) {\n throw new Error(hasEmbeddedWallet() ? EMBEDDED_WALLET_UNSUPPORTED : NO_WALLET);\n }\n async runTransaction(evm, sol, options) {\n if (evm && sol)\n throw new Error('A transaction cannot target EVM and Solana at the same time.');\n if (!evm)\n throw new Error(NO_WALLET);\n if ((options === null || options === void 0 ? void 0 : options.shouldSubmitTx) === false)\n throw new Error('Embedded EVM wallets sign and submit atomically; shouldSubmitTx:false is unsupported.');\n if (!hasEmbeddedEvmWallet())\n throw new Error('This login has no embedded EVM wallet. Enable auth.wallets on an app with an EVM collection and sign in again.');\n return embeddedRunEvmTransaction(evm);\n }\n async signTransaction(_t) {\n throw new Error(hasEmbeddedWallet() ? EMBEDDED_WALLET_UNSUPPORTED : NO_WALLET);\n }\n async signAndSubmitTransaction(transaction, _feePayer) {\n if (!hasEmbeddedWallet())\n throw new Error(NO_WALLET);\n return embeddedSignAndSubmit(transaction);\n }\n async getNativeMethods() { return {}; }\n}\nconst emailProviderSingleton = new EmailAuthProvider();\nexport { emailProviderSingleton };\n"],"names":["getActiveSessionManager","getPlatform","setCurrentUser","hasEmbeddedWallet","EMBEDDED_WALLET_UNSUPPORTED","hasEmbeddedEvmWallet","embeddedRunEvmTransaction","embeddedSignAndSubmit"],"mappings":";;;;;;AAIA;AACA;AACA;AACA;AACA;AACA,MAAM,cAAc,GAAGA,4BAAuB;AAC9C,MAAM,SAAS,GAAG,8EAA8E;AAChG,IAAI,sEAAsE;AAC1E,IAAI,yEAAyE;AAC7E,IAAI,8CAA8C;AAClD;AACA;AACA;AACA,SAAS,SAAS,CAAC,KAAK,EAAE;AAC1B,IAAI,IAAI;AACR,QAAQ,IAAI,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;AAC3E,QAAQ,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC;AAClC,QAAQ,IAAI,GAAG,KAAK,CAAC;AACrB,YAAY,GA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GAAGC,wCAA2B,GAAG,SAAS,CAAC;AACtF,IAAI;AACJ,IAAI,MAAM,wBAAwB,CAAC,WAAW,EAAE,SAAS,EAAE;AAC3D,QAAQ,IAAI,CAACD,8BAAiB,EAAE;AAChC,YAAY,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC;AACtC,QAAQ,OAAOI,kCAAqB,CAAC,WAAW,CAAC;AACjD,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1C;AACK,MAAC,sBAAsB,GAAG,IAAI,iBAAiB;;;;;"}
@@ -0,0 +1,102 @@
1
+ 'use strict';
2
+
3
+ var core = require('@bounded-sh/core');
4
+ var index = require('./index-JBeYYsGm.js');
5
+ require('react');
6
+
7
+ // Web uses localStorage (WebSessionManager); React Native uses the configured
8
+ // ReactNativeSessionManager. getActiveSessionManager() picks the right one by
9
+ // whether the RN manager was configured (NOT `typeof window`, which is truthy on
10
+ // RN too and would wrongly route to localStorage). Same selector the core
11
+ // request path uses, so hosted Bounded Auth sessions persist + authenticate on BOTH.
12
+ const sessionManager = core.getActiveSessionManager;
13
+ const NO_WALLET = 'Email login has no embedded wallet. Enable `"auth": { "wallets": true }` in ' +
14
+ 'the app policy so email logins get a non-custodial Crossmint wallet ' +
15
+ '(@user.address), then sign from a user gesture. Otherwise use a wallet ' +
16
+ 'provider (e.g. Phantom) for onchain actions.';
17
+ // ---------------------------------------------------------------------------
18
+ // token / session helpers
19
+ // ---------------------------------------------------------------------------
20
+ function decodeJwt(token) {
21
+ try {
22
+ let b64 = token.split('.')[1].replace(/-/g, '+').replace(/_/g, '/');
23
+ const pad = b64.length % 4;
24
+ if (pad === 2)
25
+ b64 += '==';
26
+ else if (pad === 3)
27
+ b64 += '=';
28
+ // getPlatform().atob is RN-safe (global atob is undefined on Hermes/JSC).
29
+ return JSON.parse(index.getPlatform().atob(b64));
30
+ }
31
+ catch (_a) {
32
+ return {};
33
+ }
34
+ }
35
+ function userFromIdToken(idToken, fallbackEmail) {
36
+ const c = decodeJwt(idToken);
37
+ const id = c['custom:userId'] || c.sub || c['custom:walletAddress'] || '';
38
+ const email = (c.email || fallbackEmail || null);
39
+ // Email logins have no wallet — address is null (the User type allows it).
40
+ const evmAddress = typeof c['custom:evmWalletAddress'] === 'string' && /^0x[0-9a-fA-F]{40}$/.test(c['custom:evmWalletAddress'])
41
+ ? c['custom:evmWalletAddress'].toLowerCase()
42
+ : null;
43
+ return { id, address: (c['custom:walletAddress'] || null), evmAddress, email, provider: emailProviderSingleton };
44
+ }
45
+ // ---------------------------------------------------------------------------
46
+ // provider
47
+ // ---------------------------------------------------------------------------
48
+ class EmailAuthProvider {
49
+ async login() {
50
+ throw new Error('login() no longer opens inline email OTP. Use loginWithRedirect({ redirectUri }) ' +
51
+ 'or loginWithPopup({ redirectUri }) for hosted Bounded Auth.');
52
+ }
53
+ async restoreSession() {
54
+ const sm = sessionManager();
55
+ const session = await sm.getSession();
56
+ if (!session)
57
+ return null;
58
+ const idToken = sm.getIdToken();
59
+ if (!idToken)
60
+ return null;
61
+ const user = userFromIdToken(idToken);
62
+ index.setCurrentUser(user);
63
+ return user;
64
+ }
65
+ async logout() {
66
+ sessionManager().clearSession();
67
+ index.setCurrentUser(null);
68
+ }
69
+ // Crossmint Solana smart wallets sign+submit atomically and cannot produce a
70
+ // raw signature — signMessage/signTransaction are structurally unsupported
71
+ // (throw the clear "use signAndSubmitTransaction" error when a wallet exists;
72
+ // the no-wallet error otherwise). signAndSubmitTransaction routes through the
73
+ // Bounded signer popup for wallets-enabled email logins.
74
+ async signMessage(_message) {
75
+ throw new Error(index.hasEmbeddedWallet() ? index.EMBEDDED_WALLET_UNSUPPORTED : NO_WALLET);
76
+ }
77
+ async runTransaction(evm, sol, options) {
78
+ if (evm && sol)
79
+ throw new Error('A transaction cannot target EVM and Solana at the same time.');
80
+ if (!evm)
81
+ throw new Error(NO_WALLET);
82
+ if ((options === null || options === void 0 ? void 0 : options.shouldSubmitTx) === false)
83
+ throw new Error('Embedded EVM wallets sign and submit atomically; shouldSubmitTx:false is unsupported.');
84
+ if (!index.hasEmbeddedEvmWallet())
85
+ throw new Error('This login has no embedded EVM wallet. Enable auth.wallets on an app with an EVM collection and sign in again.');
86
+ return index.embeddedRunEvmTransaction(evm);
87
+ }
88
+ async signTransaction(_t) {
89
+ throw new Error(index.hasEmbeddedWallet() ? index.EMBEDDED_WALLET_UNSUPPORTED : NO_WALLET);
90
+ }
91
+ async signAndSubmitTransaction(transaction, _feePayer) {
92
+ if (!index.hasEmbeddedWallet())
93
+ throw new Error(NO_WALLET);
94
+ return index.embeddedSignAndSubmit(transaction);
95
+ }
96
+ async getNativeMethods() { return {}; }
97
+ }
98
+ const emailProviderSingleton = new EmailAuthProvider();
99
+
100
+ exports.EmailAuthProvider = EmailAuthProvider;
101
+ exports.emailProviderSingleton = emailProviderSingleton;
102
+ //# sourceMappingURL=email-auth-provider-DyxZTpx6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email-auth-provider-DyxZTpx6.js","sources":["../.rollup-tmp/auth/providers/email-auth-provider.js"],"sourcesContent":["import { getActiveSessionManager } from '@bounded-sh/core';\nimport { setCurrentUser } from '../../global';\nimport { getPlatform } from '../../platform';\nimport { hasEmbeddedWallet, hasEmbeddedEvmWallet, embeddedSignAndSubmit, embeddedRunEvmTransaction, EMBEDDED_WALLET_UNSUPPORTED, } from '../crossmint-signer-bridge';\n// Web uses localStorage (WebSessionManager); React Native uses the configured\n// ReactNativeSessionManager. getActiveSessionManager() picks the right one by\n// whether the RN manager was configured (NOT `typeof window`, which is truthy on\n// RN too and would wrongly route to localStorage). Same selector the core\n// request path uses, so hosted Bounded Auth sessions persist + authenticate on BOTH.\nconst sessionManager = getActiveSessionManager;\nconst NO_WALLET = 'Email login has no embedded wallet. Enable `\"auth\": { \"wallets\": true }` in ' +\n 'the app policy so email logins get a non-custodial Crossmint wallet ' +\n '(@user.address), then sign from a user gesture. Otherwise use a wallet ' +\n 'provider (e.g. Phantom) for onchain actions.';\n// ---------------------------------------------------------------------------\n// token / session helpers\n// ---------------------------------------------------------------------------\nfunction decodeJwt(token) {\n try {\n let b64 = token.split('.')[1].replace(/-/g, '+').replace(/_/g, '/');\n const pad = b64.length % 4;\n if (pad === 2)\n b64 += '==';\n else if (pad === 3)\n b64 += '=';\n // getPlatform().atob is RN-safe (global atob is undefined on Hermes/JSC).\n return JSON.parse(getPlatform().atob(b64));\n }\n catch (_a) {\n return {};\n }\n}\nfunction userFromIdToken(idToken, fallbackEmail) {\n const c = decodeJwt(idToken);\n const id = c['custom:userId'] || c.sub || c['custom:walletAddress'] || '';\n const email = (c.email || fallbackEmail || null);\n // Email logins have no wallet — address is null (the User type allows it).\n const evmAddress = typeof c['custom:evmWalletAddress'] === 'string' && /^0x[0-9a-fA-F]{40}$/.test(c['custom:evmWalletAddress'])\n ? c['custom:evmWalletAddress'].toLowerCase()\n : null;\n return { id, address: (c['custom:walletAddress'] || null), evmAddress, email, provider: emailProviderSingleton };\n}\n// ---------------------------------------------------------------------------\n// provider\n// ---------------------------------------------------------------------------\nexport class EmailAuthProvider {\n async login() {\n throw new Error('login() no longer opens inline email OTP. Use loginWithRedirect({ redirectUri }) ' +\n 'or loginWithPopup({ redirectUri }) for hosted Bounded Auth.');\n }\n async restoreSession() {\n const sm = sessionManager();\n const session = await sm.getSession();\n if (!session)\n return null;\n const idToken = sm.getIdToken();\n if (!idToken)\n return null;\n const user = userFromIdToken(idToken);\n setCurrentUser(user);\n return user;\n }\n async logout() {\n sessionManager().clearSession();\n setCurrentUser(null);\n }\n // Crossmint Solana smart wallets sign+submit atomically and cannot produce a\n // raw signature — signMessage/signTransaction are structurally unsupported\n // (throw the clear \"use signAndSubmitTransaction\" error when a wallet exists;\n // the no-wallet error otherwise). signAndSubmitTransaction routes through the\n // Bounded signer popup for wallets-enabled email logins.\n async signMessage(_message) {\n throw new Error(hasEmbeddedWallet() ? EMBEDDED_WALLET_UNSUPPORTED : NO_WALLET);\n }\n async runTransaction(evm, sol, options) {\n if (evm && sol)\n throw new Error('A transaction cannot target EVM and Solana at the same time.');\n if (!evm)\n throw new Error(NO_WALLET);\n if ((options === null || options === void 0 ? void 0 : options.shouldSubmitTx) === false)\n throw new Error('Embedded EVM wallets sign and submit atomically; shouldSubmitTx:false is unsupported.');\n if (!hasEmbeddedEvmWallet())\n throw new Error('This login has no embedded EVM wallet. Enable auth.wallets on an app with an EVM collection and sign in again.');\n return embeddedRunEvmTransaction(evm);\n }\n async signTransaction(_t) {\n throw new Error(hasEmbeddedWallet() ? EMBEDDED_WALLET_UNSUPPORTED : NO_WALLET);\n }\n async signAndSubmitTransaction(transaction, _feePayer) {\n if (!hasEmbeddedWallet())\n throw new Error(NO_WALLET);\n return embeddedSignAndSubmit(transaction);\n }\n async getNativeMethods() { return {}; }\n}\nconst emailProviderSingleton = new EmailAuthProvider();\nexport { emailProviderSingleton };\n"],"names":["getActiveSessionManager","getPlatform","setCurrentUser","hasEmbeddedWallet","EMBEDDED_WALLET_UNSUPPORTED","hasEmbeddedEvmWallet","embeddedRunEvmTransaction","embeddedSignAndSubmit"],"mappings":";;;;;;AAIA;AACA;AACA;AACA;AACA;AACA,MAAM,cAAc,GAAGA,4BAAuB;AAC9C,MAAM,SAAS,GAAG,8EAA8E;AAChG,IAAI,sEAAsE;AAC1E,IAAI,yEAAyE;AAC7E,IAAI,8CAA8C;AAClD;AACA;AACA;AACA,SAAS,SAAS,CAAC,KAAK,EAAE;AAC1B,IAAI,IAAI;AACR,QAAQ,IAAI,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;AAC3E,QAAQ,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC;AAClC,QAAQ,IAAI,GAAG,KAAK,CAAC;AACrB,YAAY,GAAG,IAAI,IAAI;AACvB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