@bounded-sh/client 0.0.48 → 0.0.51

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 (68) hide show
  1. package/README.md +21 -0
  2. package/dist/auth/index.d.ts +8 -1
  3. package/dist/auth/providers/guest-auth-provider.d.ts +7 -0
  4. package/dist/auth/providers/guest-keystore.d.ts +2 -0
  5. package/dist/builds/apps.d.ts +32 -0
  6. package/dist/builds/client.d.ts +74 -0
  7. package/dist/builds/index.d.ts +20 -0
  8. package/dist/builds/types.d.ts +127 -0
  9. package/dist/builds/watch.d.ts +20 -0
  10. package/dist/{email-auth-provider-GRj8IOg2.mjs → email-auth-provider-Bh2fDYcb.mjs} +2 -2
  11. package/dist/{email-auth-provider-GRj8IOg2.mjs.map → email-auth-provider-Bh2fDYcb.mjs.map} +1 -1
  12. package/dist/{email-auth-provider-DyxZTpx6.js → email-auth-provider-Bm6vmoy3.js} +2 -2
  13. package/dist/{email-auth-provider-DyxZTpx6.js.map → email-auth-provider-Bm6vmoy3.js.map} +1 -1
  14. package/dist/{email-auth-provider-CTyjwhLb.mjs → email-auth-provider-CdbhqElf.mjs} +2 -2
  15. package/dist/{email-auth-provider-CTyjwhLb.mjs.map → email-auth-provider-CdbhqElf.mjs.map} +1 -1
  16. package/dist/{email-auth-provider-CmunfauO.js → email-auth-provider-CnHsY8U-.js} +2 -2
  17. package/dist/{email-auth-provider-CmunfauO.js.map → email-auth-provider-CnHsY8U-.js.map} +1 -1
  18. package/dist/global.d.ts +6 -4
  19. package/dist/{guest-auth-provider-D54uHbov.js → guest-auth-provider-CHqB_uN0.js} +98 -14
  20. package/dist/guest-auth-provider-CHqB_uN0.js.map +1 -0
  21. package/dist/{guest-auth-provider-Dk_km5tF.mjs → guest-auth-provider-Dgmr7e0Z.mjs} +98 -14
  22. package/dist/guest-auth-provider-Dgmr7e0Z.mjs.map +1 -0
  23. package/dist/{guest-auth-provider-C4BuTNIa.mjs → guest-auth-provider-Xir8zyfZ.mjs} +98 -14
  24. package/dist/guest-auth-provider-Xir8zyfZ.mjs.map +1 -0
  25. package/dist/{guest-auth-provider-B68XT2lU.js → guest-auth-provider-fjOMwfpW.js} +98 -14
  26. package/dist/guest-auth-provider-fjOMwfpW.js.map +1 -0
  27. package/dist/hooks/useBuildRun.d.ts +13 -0
  28. package/dist/{index.native-BZCc0gO-.js → index-BsrZb496.js} +918 -29
  29. package/dist/index-BsrZb496.js.map +1 -0
  30. package/dist/{index.native-CytJPNQV.mjs → index-Cy0IRs6U.mjs} +907 -31
  31. package/dist/index-Cy0IRs6U.mjs.map +1 -0
  32. package/dist/index.d.ts +8 -1
  33. package/dist/index.js +18 -1
  34. package/dist/index.js.map +1 -1
  35. package/dist/index.mjs +2 -2
  36. package/dist/{index-C0pR5b7j.mjs → index.native-B29WKXlr.mjs} +725 -151
  37. package/dist/index.native-B29WKXlr.mjs.map +1 -0
  38. package/dist/{index-JBeYYsGm.js → index.native-BaEZwiWd.js} +732 -153
  39. package/dist/index.native-BaEZwiWd.js.map +1 -0
  40. package/dist/index.native.d.ts +5 -0
  41. package/dist/index.native.js +10 -1
  42. package/dist/index.native.js.map +1 -1
  43. package/dist/index.native.mjs +1 -1
  44. package/dist/{injected-evm-wallet-provider-_eeYB1ww.js → injected-evm-wallet-provider-CEWIg-_U.js} +2 -2
  45. package/dist/{injected-evm-wallet-provider-_eeYB1ww.js.map → injected-evm-wallet-provider-CEWIg-_U.js.map} +1 -1
  46. package/dist/{injected-evm-wallet-provider-T-EF9C3W.js → injected-evm-wallet-provider-DUyX7Xj9.js} +2 -2
  47. package/dist/{injected-evm-wallet-provider-T-EF9C3W.js.map → injected-evm-wallet-provider-DUyX7Xj9.js.map} +1 -1
  48. package/dist/{injected-evm-wallet-provider-BOMLGGHM.mjs → injected-evm-wallet-provider-DWnpa6Yx.mjs} +2 -2
  49. package/dist/{injected-evm-wallet-provider-BOMLGGHM.mjs.map → injected-evm-wallet-provider-DWnpa6Yx.mjs.map} +1 -1
  50. package/dist/{injected-evm-wallet-provider-CxAiNN7R.mjs → injected-evm-wallet-provider-DkyIMRce.mjs} +2 -2
  51. package/dist/{injected-evm-wallet-provider-CxAiNN7R.mjs.map → injected-evm-wallet-provider-DkyIMRce.mjs.map} +1 -1
  52. package/dist/{injected-wallet-provider-BBZym7YQ.js → injected-wallet-provider-C65NiItg.js} +2 -2
  53. package/dist/{injected-wallet-provider-BBZym7YQ.js.map → injected-wallet-provider-C65NiItg.js.map} +1 -1
  54. package/dist/{injected-wallet-provider-B2T7JEvn.js → injected-wallet-provider-DpJvuK73.js} +2 -2
  55. package/dist/{injected-wallet-provider-B2T7JEvn.js.map → injected-wallet-provider-DpJvuK73.js.map} +1 -1
  56. package/dist/{injected-wallet-provider-B1uq3r4r.mjs → injected-wallet-provider-DqBpuASt.mjs} +2 -2
  57. package/dist/{injected-wallet-provider-B1uq3r4r.mjs.map → injected-wallet-provider-DqBpuASt.mjs.map} +1 -1
  58. package/dist/{injected-wallet-provider-DCwygA3j.mjs → injected-wallet-provider-DsesEVnZ.mjs} +2 -2
  59. package/dist/{injected-wallet-provider-DCwygA3j.mjs.map → injected-wallet-provider-DsesEVnZ.mjs.map} +1 -1
  60. package/package.json +2 -2
  61. package/dist/guest-auth-provider-B68XT2lU.js.map +0 -1
  62. package/dist/guest-auth-provider-C4BuTNIa.mjs.map +0 -1
  63. package/dist/guest-auth-provider-D54uHbov.js.map +0 -1
  64. package/dist/guest-auth-provider-Dk_km5tF.mjs.map +0 -1
  65. package/dist/index-C0pR5b7j.mjs.map +0 -1
  66. package/dist/index-JBeYYsGm.js.map +0 -1
  67. package/dist/index.native-BZCc0gO-.js.map +0 -1
  68. package/dist/index.native-CytJPNQV.mjs.map +0 -1
package/README.md CHANGED
@@ -132,6 +132,27 @@ async function pay(tx: VersionedTransaction) {
132
132
  `signMessage` and `signTransaction` (sign without submit) throw for embedded smart
133
133
  wallets — they sign and submit atomically, so use `signAndSubmitTransaction`.
134
134
 
135
+ ### Platform app and build control
136
+
137
+ The headless `apps` and `builds` namespaces provision apps and control unified
138
+ build runs from Bounded's own product surfaces. They are for platform first-party
139
+ surfaces only (`bounded.sh`, `oapps.fun`, and localhost): developer-api CORS blocks
140
+ browser calls from generated-app origins. Server-side callers are unaffected by
141
+ that CORS boundary.
142
+
143
+ ```typescript
144
+ import { apps, builds } from '@bounded-sh/client';
145
+
146
+ const app = await apps.create({ prompt, clientToken });
147
+ if (!app.policySeeded) throw new Error('Starter policy is not ready');
148
+
149
+ const submitted = await builds.submit(app.appId, { prompt, intentKey });
150
+ const watcher = builds.watch(app.appId, submitted.runId, ({ run, events }) => {
151
+ console.log(run.state, events);
152
+ });
153
+ // watcher.stop();
154
+ ```
155
+
135
156
  ## Usage
136
157
 
137
158
  ### Get Current User
@@ -52,6 +52,13 @@ export declare function signInAnonymously(): Promise<User | null>;
52
52
  export declare function loginWithPrivy(options?: LoginOptions): Promise<User | null>;
53
53
  export declare function login(options?: LoginOptions): Promise<User | null>;
54
54
  export declare function getCurrentAuthMethod(): string | null;
55
- export declare function logout(): Promise<void>;
55
+ export interface LogoutOptions {
56
+ /** Keep the hosted issuer's browser session alive (skip the top-level bounce
57
+ * through the issuer's /logout). Default false: an explicit logout ends the
58
+ * issuer session too, so the next sign-in is a fresh account choice instead
59
+ * of a silent re-login as the same user. */
60
+ keepIssuerSession?: boolean;
61
+ }
62
+ export declare function logout(options?: LogoutOptions): Promise<void>;
56
63
  export { loginWithRedirect, completeLoginFromRedirect, loginWithPopup, completeLoginInPopup } from './oidc-auth';
57
64
  export type { HostedAuthMethod, OidcLoginOptions, PopupLoginOptions } from './oidc-auth';
@@ -1,8 +1,15 @@
1
1
  import type { AuthProvider, User, TransactionResult, SolTransaction, EVMTransaction, SetOptions } from '@bounded-sh/core';
2
2
  import type { Transaction, VersionedTransaction } from '@solana/web3.js';
3
3
  export declare class GuestAuthProvider implements AuthProvider {
4
+ private loginInternal;
4
5
  login(): Promise<User | null>;
6
+ /** @internal Stage a guest session without exposing mixed provider/user state. */
7
+ loginForProviderSwitch(): Promise<User | null>;
8
+ private tokenIsGuest;
9
+ private restoreSessionInternal;
5
10
  restoreSession(): Promise<User | null>;
11
+ /** @internal Reconcile an applied-yet-error guest mint before committing a switch. */
12
+ restoreSessionForProviderSwitch(): Promise<User | null>;
6
13
  logout(): Promise<void>;
7
14
  /** Wipe the device key — the next login() is a brand-new guest identity. */
8
15
  forgetGuest(): Promise<void>;
@@ -8,5 +8,7 @@ export interface GuestKey {
8
8
  }
9
9
  /** Get (or create) this device's durable guest key. */
10
10
  export declare function getGuestKey(): Promise<GuestKey>;
11
+ /** Read the existing durable guest key without ever minting a replacement. */
12
+ export declare function getExistingGuestKey(): Promise<GuestKey | null>;
11
13
  /** Forget the guest key on this device (a fresh signInAnonymously mints a new one). */
12
14
  export declare function clearGuestKey(): Promise<void>;
@@ -0,0 +1,32 @@
1
+ export interface CreateAppOptions {
2
+ /** Optional display name accepted by the developer API. */
3
+ name?: string;
4
+ prompt?: string;
5
+ clientToken?: string;
6
+ /** Provisioning intent marker; "create-flow" enables never-built-app reuse and starter credit server-side. */
7
+ intent?: string;
8
+ }
9
+ export interface CreatedApp {
10
+ appId: string;
11
+ slug?: string;
12
+ url: string;
13
+ /** Callers must gate the first build on this being true. */
14
+ policySeeded: boolean;
15
+ }
16
+ export interface AppListItem {
17
+ appId: string;
18
+ name: string;
19
+ slug?: string;
20
+ /** Canonical app URL, when supplied by the developer API. */
21
+ url?: string;
22
+ }
23
+ export declare function create(options?: CreateAppOptions): Promise<CreatedApp>;
24
+ export declare function list(): Promise<AppListItem[]>;
25
+ /**
26
+ * Platform first-party surfaces only (bounded.sh, oapps.fun, localhost) —
27
+ * dev-api CORS blocks calls from generated-app origins. Server-side callers unaffected.
28
+ */
29
+ export declare const apps: {
30
+ create: typeof create;
31
+ list: typeof list;
32
+ };
@@ -0,0 +1,74 @@
1
+ import type { BuildCancelResponse, BuildEventsResponse, BuildGateDecisionResponse, BuildGetResponse, BuildListResponse, BuildsApiErrorDetails, BuildSubmitResponse, BuildTopupResponse } from './types';
2
+ type BuildIdempotencyOptions = {
3
+ /** Caller-minted wire key (1-256 characters), passed through unchanged. */
4
+ idempotencyKey: string;
5
+ /** When also supplied, persists the caller-minted key for this logical action. */
6
+ intentKey?: string;
7
+ } | {
8
+ /** Omit to let the SDK mint and persist a wire key before the request. */
9
+ idempotencyKey?: undefined;
10
+ /** Stable logical-action key used to reuse the minted key across page refreshes. */
11
+ intentKey: string;
12
+ };
13
+ /**
14
+ * Build submission plus one idempotency strategy: provide `idempotencyKey`, or
15
+ * provide a stable client-only `intentKey` and let the SDK mint/persist the wire key.
16
+ */
17
+ export type BuildSubmitOptions = {
18
+ prompt: string;
19
+ operation?: 'edit';
20
+ constraints?: object;
21
+ effort?: string;
22
+ profile?: string;
23
+ baseDeploymentId?: string;
24
+ } & BuildIdempotencyOptions;
25
+ /**
26
+ * Gate decision plus one idempotency strategy. A client-only `intentKey` can
27
+ * replace a caller-minted `idempotencyKey` and survives refresh replays.
28
+ */
29
+ export type BuildGateDecisionOptions = {
30
+ decision: 'approve' | 'reject';
31
+ note?: string;
32
+ } & BuildIdempotencyOptions;
33
+ export interface BuildTopupOptions {
34
+ dimension: string;
35
+ amountMicroUsd: number;
36
+ idempotencyKey: string;
37
+ }
38
+ interface DevApiRequest {
39
+ method?: string;
40
+ body?: unknown;
41
+ }
42
+ interface BuildsApiErrorInit<TDetails = BuildsApiErrorDetails> {
43
+ code: string;
44
+ message: string;
45
+ retryable: boolean;
46
+ status: number;
47
+ details?: TDetails;
48
+ retryAfterMs?: number;
49
+ }
50
+ /** A structured non-2xx response from the developer API. */
51
+ export declare class BuildsApiError<TDetails = BuildsApiErrorDetails> extends Error {
52
+ readonly code: string;
53
+ readonly retryable: boolean;
54
+ readonly status: number;
55
+ /**
56
+ * Developer-api error details, preserved verbatim. For
57
+ * `project_limit_exceeded`, `usage`, `limit`, and `dimension` are all present
58
+ * (the exact shape is exported as `ProjectLimitExceededDetails`).
59
+ */
60
+ readonly details?: TDetails;
61
+ /** Parsed Retry-After delay, when a 429 response supplied one. */
62
+ readonly retryAfterMs?: number;
63
+ constructor(init: BuildsApiErrorInit<TDetails>);
64
+ }
65
+ /** @internal Shared authenticated developer-api transport for builds and apps. */
66
+ export declare function requestDevApi<T>(path: string, request?: DevApiRequest): Promise<T>;
67
+ export declare function submit(appId: string, options: BuildSubmitOptions): Promise<BuildSubmitResponse>;
68
+ export declare function get(appId: string, runId: string): Promise<BuildGetResponse>;
69
+ export declare function events(appId: string, runId: string, after?: number): Promise<BuildEventsResponse>;
70
+ export declare function cancel(appId: string, runId: string): Promise<BuildCancelResponse>;
71
+ export declare function decideGate(appId: string, runId: string, gateId: string, options: BuildGateDecisionOptions): Promise<BuildGateDecisionResponse>;
72
+ export declare function topup(appId: string, runId: string, options: BuildTopupOptions): Promise<BuildTopupResponse>;
73
+ export declare function list(appId: string, limit?: number): Promise<BuildListResponse>;
74
+ export {};
@@ -0,0 +1,20 @@
1
+ import { cancel, decideGate, events, get, list, submit, topup } from './client';
2
+ import { watch } from './watch';
3
+ /**
4
+ * Platform first-party surfaces only (bounded.sh, oapps.fun, localhost) —
5
+ * dev-api CORS blocks calls from generated-app origins. Server-side callers unaffected.
6
+ */
7
+ export declare const builds: {
8
+ submit: typeof submit;
9
+ get: typeof get;
10
+ events: typeof events;
11
+ cancel: typeof cancel;
12
+ decideGate: typeof decideGate;
13
+ topup: typeof topup;
14
+ list: typeof list;
15
+ watch: typeof watch;
16
+ };
17
+ export { BuildsApiError } from './client';
18
+ export type { BuildGateDecisionOptions, BuildSubmitOptions, BuildTopupOptions, } from './client';
19
+ export type { BuildRunWatchHandle, BuildRunWatchOptions, BuildRunWatchUpdate, } from './watch';
20
+ export * from './types';
@@ -0,0 +1,127 @@
1
+ export declare const NON_TERMINAL_STATES: readonly ["queued", "admitted", "executing", "preview_ready", "parked", "resuming", "promoting", "quarantined"];
2
+ export declare const TERMINAL_STATES: readonly ["promoted", "failed", "canceled", "rejected", "expired", "rebase_required", "reported"];
3
+ export declare const RUN_STATES: readonly ["queued", "admitted", "executing", "preview_ready", "parked", "resuming", "promoting", "quarantined", "promoted", "failed", "canceled", "rejected", "expired", "rebase_required", "reported"];
4
+ export declare const PARK_REASONS: readonly ["gate", "funding"];
5
+ export declare const FAILURE_REASONS: readonly ["admission_rejected", "dispatch_timeout", "auth_revoked", "owner_changed", "policy_changed", "quarantine_forced", "bind_failed", "internal_error"];
6
+ export type NonTerminalState = (typeof NON_TERMINAL_STATES)[number];
7
+ export type TerminalState = (typeof TERMINAL_STATES)[number];
8
+ export type RunState = (typeof RUN_STATES)[number];
9
+ export type ParkReason = (typeof PARK_REASONS)[number];
10
+ export type FailureReason = (typeof FAILURE_REASONS)[number];
11
+ /** Additive wire:1 build projection returned by developer-api. */
12
+ export interface BuildRunClientView {
13
+ runId: string;
14
+ /** Known values are in RUN_STATES; unknown values must flow through unchanged. */
15
+ state: string;
16
+ parkReason?: string;
17
+ failureReason?: string;
18
+ failureDetail?: string;
19
+ quarantineReason?: string;
20
+ quarantinedAtMs?: number;
21
+ quarantineDetail?: {
22
+ code: string;
23
+ message: string;
24
+ };
25
+ operation: string;
26
+ /** The developer-api app this run targets. */
27
+ appId: string;
28
+ targetAppId: string;
29
+ /** Full submitted prompt, when retained by the owner-only developer-api view. */
30
+ prompt?: string;
31
+ appUrl?: string;
32
+ previewUrl?: string;
33
+ gates: Array<{
34
+ gateId: string;
35
+ type: string;
36
+ expiresAtMs?: number;
37
+ decided: boolean;
38
+ decision?: string;
39
+ }>;
40
+ stageSummaries: Array<{
41
+ stage: string;
42
+ at: number;
43
+ note?: string;
44
+ }>;
45
+ usage?: {
46
+ aiMicroUsd: number;
47
+ infraMicroUsd: number;
48
+ };
49
+ createdAtMs: number;
50
+ updatedAtMs: number;
51
+ }
52
+ export interface RunEventView {
53
+ seq: number;
54
+ type: string;
55
+ atMs: number;
56
+ data?: unknown;
57
+ }
58
+ export interface BuildRunListRow {
59
+ runId: string;
60
+ appId: string;
61
+ createdAtMs: number;
62
+ state?: string;
63
+ promptExcerpt?: string;
64
+ updatedAtMs?: number;
65
+ }
66
+ /**
67
+ * Extensible developer-api error details. Project-limit errors populate the
68
+ * typed fields below; other error codes may add arbitrary fields.
69
+ */
70
+ export interface BuildsApiErrorDetails {
71
+ /** Current usage when `code === "project_limit_exceeded"`. */
72
+ usage?: number;
73
+ /** Allowed usage when `code === "project_limit_exceeded"`. */
74
+ limit?: number;
75
+ /** Limit axis (for example, `maxProjects`) when a quota gate rejects. */
76
+ dimension?: string;
77
+ [key: string]: unknown;
78
+ }
79
+ /** Exact details supplied with a `project_limit_exceeded` error. */
80
+ export interface ProjectLimitExceededDetails extends BuildsApiErrorDetails {
81
+ usage: number;
82
+ limit: number;
83
+ dimension: string;
84
+ }
85
+ export interface BuildsApiErrorEnvelope {
86
+ error: {
87
+ code: string;
88
+ message: string;
89
+ retryable: boolean;
90
+ details?: BuildsApiErrorDetails;
91
+ };
92
+ }
93
+ export interface BuildSubmitResponse {
94
+ wire: 1;
95
+ runId: string;
96
+ targetAppId: string;
97
+ status: string;
98
+ }
99
+ export interface BuildGetResponse {
100
+ wire: 1;
101
+ run: BuildRunClientView;
102
+ }
103
+ export interface BuildEventsResponse {
104
+ wire: 1;
105
+ events: RunEventView[];
106
+ }
107
+ export interface BuildCancelResponse {
108
+ wire: 1;
109
+ runId: string;
110
+ state: string;
111
+ }
112
+ export interface BuildGateDecisionResponse {
113
+ wire: 1;
114
+ runId: string;
115
+ gateId: string;
116
+ decision: 'approve' | 'reject';
117
+ state: string;
118
+ }
119
+ export interface BuildTopupResponse {
120
+ wire: 1;
121
+ runId: string;
122
+ state: string;
123
+ }
124
+ export interface BuildListResponse {
125
+ wire: 1;
126
+ runs: BuildRunListRow[];
127
+ }
@@ -0,0 +1,20 @@
1
+ import type { BuildRunClientView, RunEventView } from './types';
2
+ export interface BuildRunWatchUpdate {
3
+ run: BuildRunClientView;
4
+ /** Events first observed on this poll, ordered as returned by the server. */
5
+ events: RunEventView[];
6
+ }
7
+ export interface BuildRunWatchOptions {
8
+ /** Initial exclusive event cursor. Defaults to zero. */
9
+ after?: number;
10
+ /** Called for transient polling errors; polling continues unless the run is terminal. */
11
+ onError?: (error: unknown) => void;
12
+ }
13
+ export interface BuildRunWatchHandle {
14
+ stop(): void;
15
+ }
16
+ /**
17
+ * Poll a build view and its event cursor until stopped or the run reaches a
18
+ * known terminal state. Unknown state strings remain untouched and nonterminal.
19
+ */
20
+ export declare function watch(appId: string, runId: string, onUpdate: (update: BuildRunWatchUpdate) => void, options?: BuildRunWatchOptions): BuildRunWatchHandle;
@@ -1,5 +1,5 @@
1
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.native-CytJPNQV.mjs';
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.native-B29WKXlr.mjs';
3
3
  import 'react';
4
4
 
5
5
  // Web uses localStorage (WebSessionManager); React Native uses the configured
@@ -96,4 +96,4 @@ class EmailAuthProvider {
96
96
  const emailProviderSingleton = new EmailAuthProvider();
97
97
 
98
98
  export { EmailAuthProvider, emailProviderSingleton };
99
- //# sourceMappingURL=email-auth-provider-GRj8IOg2.mjs.map
99
+ //# sourceMappingURL=email-auth-provider-Bh2fDYcb.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"email-auth-provider-GRj8IOg2.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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IAAI,KAAK,CAAC,uFAAuF,CAAC;AACpH,QAAQ,IAAI,CAAC,oBAAoB,EAAE;AACnC,YAAY,MAAM,IAAI,KAAK,CAAC,gHAAgH,CAAC;AAC7I,QAAQ,OAAO,yBAAyB,CAAC,GAAG,CAAC;AAC7C,IAAI;AACJ,IAAI,MAAM,eAAe,CAAC,EAAE,EAAE;AAC9B,QAAQ,MAAM,IAAI,KAAK,CAAC,iBAAiB,EAAE,GAAG,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;;;;"}
1
+ {"version":3,"file":"email-auth-provider-Bh2fDYcb.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,GAAG,IAAI,IAAI;AACvB,aAAa,IAAI,GAAG,KAAK,CAAC;AAC1B,YAAY,GAAG,IAAI,GAAG;AACtB;AACA,QAAQ,OAA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AQ,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;;;;"}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var core = require('@bounded-sh/core');
4
- var index = require('./index-JBeYYsGm.js');
4
+ var index = require('./index-BsrZb496.js');
5
5
  require('react');
6
6
 
7
7
  // Web uses localStorage (WebSessionManager); React Native uses the configured
@@ -99,4 +99,4 @@ const emailProviderSingleton = new EmailAuthProvider();
99
99
 
100
100
  exports.EmailAuthProvider = EmailAuthProvider;
101
101
  exports.emailProviderSingleton = emailProviderSingleton;
102
- //# sourceMappingURL=email-auth-provider-DyxZTpx6.js.map
102
+ //# sourceMappingURL=email-auth-provider-Bm6vmoy3.js.map
@@ -1 +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,GAA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I,KAAK,CAACH,uBAAiB,EAAE,GAAGC,iCAA2B,GAAG,SAAS,CAAC;AACtF,IAAI;AACJ,IAAI,MAAM,wBAAwB,CAAC,WAAW,EAAE,SAAS,EAAE;AAC3D,QAAQ,IAAI,CAACD,uBAAiB,EAAE;AAChC,YAAY,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC;AACtC,QAAQ,OAAOI,2BAAqB,CAAC,WAAW,CAAC;AACjD,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1C;AACK,MAAC,sBAAsB,GAAG,IAAI,iBAAiB;;;;;"}
1
+ {"version":3,"file":"email-auth-provider-Bm6vmoy3.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,aAAa,IAAI,GAAG,KAAK,CAAC;AAC1B,YAAY,GAAG,IAAI,GAAG;AACtB;AACA,QAAQ,OAAO,IAAI,CAAC,KAAK,CAACC,iBAAW,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,IAAI;AACJ,IAAI,OAAO,EAAE,EAAE;AACf,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AAW,CAAC;AACjD,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1C;AACK,MAAC,sBAAsB,GAAG,IAAI,iBAAiB;;;;;"}
@@ -1,5 +1,5 @@
1
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';
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-Cy0IRs6U.mjs';
3
3
  import 'react';
4
4
 
5
5
  // Web uses localStorage (WebSessionManager); React Native uses the configured
@@ -96,4 +96,4 @@ class EmailAuthProvider {
96
96
  const emailProviderSingleton = new EmailAuthProvider();
97
97
 
98
98
  export { EmailAuthProvider, emailProviderSingleton };
99
- //# sourceMappingURL=email-auth-provider-CTyjwhLb.mjs.map
99
+ //# sourceMappingURL=email-auth-provider-CdbhqElf.mjs.map
@@ -1 +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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,CAAC,iBAAiB,EAAE,GAAG,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;;;;"}
1
+ {"version":3,"file":"email-auth-provider-CdbhqElf.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,GAAG,IAAI,IAAI;AACvB,aAAa,IAAI,GAAG,KAAK,CAAC;AAC1B,YAAY,GAAG,IAAI,GAAG;AACtB;AACA,QAAQ,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,IAAI;AACJ,IAAI,OAAO,EAAE,EAAE;AACf,QAAQ,OAAO,EAAE;AACjB,IAAI;AACJ;AACA,SAAS,eAAe,CAAC,OAAO,EAAE,aAAa,EAAE;AACjD,IAAI,MAAM,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC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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_native = require('./index.native-BZCc0gO-.js');
4
+ var index_native = require('./index.native-BaEZwiWd.js');
5
5
  require('react');
6
6
 
7
7
  // Web uses localStorage (WebSessionManager); React Native uses the configured
@@ -99,4 +99,4 @@ const emailProviderSingleton = new EmailAuthProvider();
99
99
 
100
100
  exports.EmailAuthProvider = EmailAuthProvider;
101
101
  exports.emailProviderSingleton = emailProviderSingleton;
102
- //# sourceMappingURL=email-auth-provider-CmunfauO.js.map
102
+ //# sourceMappingURL=email-auth-provider-CnHsY8U-.js.map
@@ -1 +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,GAAG,IAAI,IAAI;AACvB,aAAa,IAAI,GAAG,KAAK,CAAC;AAC1B,YAAY,GAAG,IAAI,GAAG;AACtB;AACA,QAAQ,OAAO,IAAI,CAAC,KAAK,CAACC,wBAAW,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,IAAI;AACJ,IAAI,OAAO,EAAE,EAAE;A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C,WAAW,CAAC;AACjD,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1C;AACK,MAAC,sBAAsB,GAAG,IAAI,iBAAiB;;;;;"}
1
+ {"version":3,"file":"email-auth-provider-CnHsY8U-.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,aAAa,IAAI,GAAG,KAAK,CAAC;AAC1B,YAAY,GAAG,IAAI,GAAG;AACtB;AACA,QAAQ,OAAO,IAAI,CAAC,KAAK,CAACC,wBAAW,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,IAAI;AACJ,IAAI,OAAO,EAAE,EAAE;AACf,QAAQ,OAAO,EAAE;AACjB,IAAI;AACJ;AACA,SAAS,eAAe,CAAC,OAAO,EAAE,aAAa,EAAE;AACjD,IAAI,MAAM,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC;AAChC,IAAI,MAAM,EAAE,GAAG,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,sBAAsB,CAAC,IAAI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oginOptions, LogoutOptions } from './auth';
3
3
  export declare function init(newConfig: Partial<ClientConfig>): Promise<void>;
4
4
  export declare function onAuthStateChanged(callback: (user: User | null) => void): () => void;
5
5
  export declare function onAuthLoadingChanged(callback: (loading: boolean) => void): () => void;
6
6
  export declare function setAuthLoading(loading: boolean): void;
7
7
  export declare function getAuthLoading(): boolean;
8
8
  export declare function login(options?: LoginOptions): Promise<User | null>;
9
- export type { LoginOptions };
10
- export declare function logout(): Promise<void>;
9
+ export type { LoginOptions, LogoutOptions };
10
+ export declare function logout(options?: LogoutOptions): Promise<void>;
11
11
  export declare function setCurrentUser(user: User | null): void;
12
12
  export declare function getCurrentUser(): User | null;
13
- export declare function setAuthProviderInstance(provider: AuthProvider): void;
13
+ /** @internal Snapshot/restore surface for transactional auth-provider switches. */
14
+ export declare function getAuthProviderInstance(): AuthProvider | null;
15
+ export declare function setAuthProviderInstance(provider: AuthProvider | null): void;