@scalemule/nextjs 0.0.37 → 0.0.38

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.
package/dist/client.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a8 as StorageAdapter } from './index-BIIUrnPr.mjs';
1
+ import { a7 as StorageAdapter } from './index-BoENfro3.mjs';
2
2
 
3
3
  /**
4
4
  * ScaleMule API Client
@@ -34,10 +34,6 @@ interface ClientConfig {
34
34
  * preventing race conditions where requests fire before the auth token is available.
35
35
  */
36
36
  pendingSessionInit?: boolean;
37
- /** Enable the account switcher */
38
- enableAccountSwitcher?: boolean;
39
- /** Privacy level for account switcher */
40
- accountSwitcherPrivacy?: 'full' | 'masked' | 'minimal';
41
37
  }
42
38
  interface RequestOptions extends RequestInit {
43
39
  /** Skip adding auth headers (for public endpoints) */
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a8 as StorageAdapter } from './index-BIIUrnPr.js';
1
+ import { a7 as StorageAdapter } from './index-BoENfro3.js';
2
2
 
3
3
  /**
4
4
  * ScaleMule API Client
@@ -34,10 +34,6 @@ interface ClientConfig {
34
34
  * preventing race conditions where requests fire before the auth token is available.
35
35
  */
36
36
  pendingSessionInit?: boolean;
37
- /** Enable the account switcher */
38
- enableAccountSwitcher?: boolean;
39
- /** Privacy level for account switcher */
40
- accountSwitcherPrivacy?: 'full' | 'masked' | 'minimal';
41
37
  }
42
38
  interface RequestOptions extends RequestInit {
43
39
  /** Skip adding auth headers (for public endpoints) */
@@ -66,29 +66,6 @@ interface ScaleMuleConfig {
66
66
  * publishableKey: 'sm_pb_production_a1b2c3d4...'
67
67
  */
68
68
  publishableKey?: string;
69
- /**
70
- * Enable the account switcher — remembers which accounts have logged in on
71
- * this device so users can pick an account and re-authenticate.
72
- *
73
- * Stores only display metadata (email, name, avatar) — no tokens.
74
- * Switching accounts always requires re-authentication.
75
- *
76
- * When using auth proxy mode, this works via a non-httpOnly cookie.
77
- * The server route config must also have `enableAccountSwitcher: true`.
78
- *
79
- * Default: false
80
- */
81
- enableAccountSwitcher?: boolean;
82
- /**
83
- * Privacy level for account switcher display metadata.
84
- *
85
- * - 'full': Store email, name, avatar as-is (default)
86
- * - 'masked': Mask email (j***@g***.com), truncate name to initial
87
- * - 'minimal': No PII at all — just a colored "Account" label
88
- *
89
- * Applies to both server-side cookie writes and client-side reads.
90
- */
91
- accountSwitcherPrivacy?: 'full' | 'masked' | 'minimal';
92
69
  }
93
70
  interface StorageAdapter {
94
71
  getItem(key: string): string | null | Promise<string | null>;
@@ -467,36 +444,6 @@ interface UseAuthReturn {
467
444
  verifyPhone: (request: PhoneVerifyRequest) => Promise<void>;
468
445
  /** Login with phone number */
469
446
  loginWithPhone: (request: PhoneLoginRequest) => Promise<LoginResponse>;
470
- /**
471
- * All accounts that have previously logged in on this device.
472
- * Contains display metadata only — no tokens.
473
- * Requires `enableAccountSwitcher: true` in config.
474
- */
475
- knownAccounts: KnownAccountInfo[];
476
- /**
477
- * Switch to a different known account.
478
- * Logs out the current session and returns the target account's info
479
- * so the login form can be pre-filled. User must re-authenticate.
480
- */
481
- switchAccount: (userId: string) => Promise<KnownAccountInfo | null>;
482
- /** Remove a specific account from the known accounts list */
483
- removeKnownAccount: (userId: string) => Promise<void>;
484
- /** Clear all known accounts from this device */
485
- clearKnownAccounts: () => Promise<void>;
486
- }
487
- /**
488
- * Known account info — display metadata only, no tokens.
489
- * Used by the account switcher to show previously logged-in accounts.
490
- */
491
- interface KnownAccountInfo {
492
- userId: string;
493
- email?: string;
494
- fullName?: string;
495
- avatarUrl?: string;
496
- provider?: string;
497
- lastActiveAt: string;
498
- displayLabel?: string;
499
- colorIndex?: number;
500
447
  }
501
448
  interface UseContentReturn {
502
449
  /** User's files */
@@ -895,4 +842,4 @@ interface UseBillingReturn {
895
842
  }) => Promise<string | null>;
896
843
  }
897
844
 
898
- export { type RegisterRequest as $, type ApiError as A, type BatchTrackRequest as B, type ChangeEmailRequest as C, type DeviceFingerprint as D, type EnhancedAnalyticsEvent as E, type ForgotPasswordRequest as F, type MFASetupRequest as G, type MFAStatus as H, type MFATOTPSetupResponse as I, type MFAVerifyRequest as J, type KnownAccountInfo as K, type LoginResponse as L, type MFAChallengeResponse as M, type OAuthCallbackResponse as N, type OAuthCallbackRequest as O, type OAuthConfig as P, type OAuthProvider as Q, type OAuthStartResponse as R, type ScaleMuleConfig as S, type PageViewData as T, type User as U, type PayoutSchedule as V, type PhoneLoginRequest as W, type PhoneSendCodeRequest as X, type PhoneVerifyRequest as Y, type Profile as Z, type RefreshResponse as _, type UseAuthReturn as a, type ResetPasswordRequest as a0, ScaleMuleApiError as a1, type ScaleMuleEnvironment as a2, type Session as a3, type SignedUploadCompleteRequest as a4, type SignedUploadRequest as a5, type SignedUploadResponse as a6, type SignedUploadUrl as a7, type StorageAdapter as a8, type StorageFile as a9, type TrackEventResponse as aa, type TransactionSummary as ab, type UTMParams as ac, type UpdateProfileRequest as ad, type UploadOptions as ae, type UploadResponse as af, type VerifyEmailRequest as ag, type UseBillingReturn as b, type ListFilesParams as c, type UseContentReturn as d, type UseUserReturn as e, type UseAnalyticsOptions as f, type UseAnalyticsReturn as g, type AccountBalance as h, type AnalyticsEvent as i, type ApiResponse as j, type BillingPayment as k, type BillingPayout as l, type BillingRefund as m, type BillingTransaction as n, type ChangePasswordRequest as o, type ClientContext as p, type ConnectedAccount as q, type DeviceInfo as r, type LinkedAccount as s, type ListFilesResponse as t, type LoginDeviceInfo as u, type LoginRequest as v, type LoginResponseWithMFA as w, type LoginRiskInfo as x, type MFAMethod as y, type MFASMSSetupResponse as z };
845
+ export { type ResetPasswordRequest as $, type ApiError as A, type BatchTrackRequest as B, type ChangeEmailRequest as C, type DeviceFingerprint as D, type EnhancedAnalyticsEvent as E, type ForgotPasswordRequest as F, type MFASetupRequest as G, type MFAStatus as H, type MFATOTPSetupResponse as I, type MFAVerifyRequest as J, type OAuthCallbackResponse as K, type LoginResponse as L, type MFAChallengeResponse as M, type OAuthConfig as N, type OAuthCallbackRequest as O, type OAuthProvider as P, type OAuthStartResponse as Q, type PageViewData as R, type ScaleMuleConfig as S, type PayoutSchedule as T, type User as U, type PhoneLoginRequest as V, type PhoneSendCodeRequest as W, type PhoneVerifyRequest as X, type Profile as Y, type RefreshResponse as Z, type RegisterRequest as _, type UseAuthReturn as a, ScaleMuleApiError as a0, type ScaleMuleEnvironment as a1, type Session as a2, type SignedUploadCompleteRequest as a3, type SignedUploadRequest as a4, type SignedUploadResponse as a5, type SignedUploadUrl as a6, type StorageAdapter as a7, type StorageFile as a8, type TrackEventResponse as a9, type TransactionSummary as aa, type UTMParams as ab, type UpdateProfileRequest as ac, type UploadOptions as ad, type UploadResponse as ae, type VerifyEmailRequest as af, type UseBillingReturn as b, type ListFilesParams as c, type UseContentReturn as d, type UseUserReturn as e, type UseAnalyticsOptions as f, type UseAnalyticsReturn as g, type AccountBalance as h, type AnalyticsEvent as i, type ApiResponse as j, type BillingPayment as k, type BillingPayout as l, type BillingRefund as m, type BillingTransaction as n, type ChangePasswordRequest as o, type ClientContext as p, type ConnectedAccount as q, type DeviceInfo as r, type LinkedAccount as s, type ListFilesResponse as t, type LoginDeviceInfo as u, type LoginRequest as v, type LoginResponseWithMFA as w, type LoginRiskInfo as x, type MFAMethod as y, type MFASMSSetupResponse as z };
@@ -66,29 +66,6 @@ interface ScaleMuleConfig {
66
66
  * publishableKey: 'sm_pb_production_a1b2c3d4...'
67
67
  */
68
68
  publishableKey?: string;
69
- /**
70
- * Enable the account switcher — remembers which accounts have logged in on
71
- * this device so users can pick an account and re-authenticate.
72
- *
73
- * Stores only display metadata (email, name, avatar) — no tokens.
74
- * Switching accounts always requires re-authentication.
75
- *
76
- * When using auth proxy mode, this works via a non-httpOnly cookie.
77
- * The server route config must also have `enableAccountSwitcher: true`.
78
- *
79
- * Default: false
80
- */
81
- enableAccountSwitcher?: boolean;
82
- /**
83
- * Privacy level for account switcher display metadata.
84
- *
85
- * - 'full': Store email, name, avatar as-is (default)
86
- * - 'masked': Mask email (j***@g***.com), truncate name to initial
87
- * - 'minimal': No PII at all — just a colored "Account" label
88
- *
89
- * Applies to both server-side cookie writes and client-side reads.
90
- */
91
- accountSwitcherPrivacy?: 'full' | 'masked' | 'minimal';
92
69
  }
93
70
  interface StorageAdapter {
94
71
  getItem(key: string): string | null | Promise<string | null>;
@@ -467,36 +444,6 @@ interface UseAuthReturn {
467
444
  verifyPhone: (request: PhoneVerifyRequest) => Promise<void>;
468
445
  /** Login with phone number */
469
446
  loginWithPhone: (request: PhoneLoginRequest) => Promise<LoginResponse>;
470
- /**
471
- * All accounts that have previously logged in on this device.
472
- * Contains display metadata only — no tokens.
473
- * Requires `enableAccountSwitcher: true` in config.
474
- */
475
- knownAccounts: KnownAccountInfo[];
476
- /**
477
- * Switch to a different known account.
478
- * Logs out the current session and returns the target account's info
479
- * so the login form can be pre-filled. User must re-authenticate.
480
- */
481
- switchAccount: (userId: string) => Promise<KnownAccountInfo | null>;
482
- /** Remove a specific account from the known accounts list */
483
- removeKnownAccount: (userId: string) => Promise<void>;
484
- /** Clear all known accounts from this device */
485
- clearKnownAccounts: () => Promise<void>;
486
- }
487
- /**
488
- * Known account info — display metadata only, no tokens.
489
- * Used by the account switcher to show previously logged-in accounts.
490
- */
491
- interface KnownAccountInfo {
492
- userId: string;
493
- email?: string;
494
- fullName?: string;
495
- avatarUrl?: string;
496
- provider?: string;
497
- lastActiveAt: string;
498
- displayLabel?: string;
499
- colorIndex?: number;
500
447
  }
501
448
  interface UseContentReturn {
502
449
  /** User's files */
@@ -895,4 +842,4 @@ interface UseBillingReturn {
895
842
  }) => Promise<string | null>;
896
843
  }
897
844
 
898
- export { type RegisterRequest as $, type ApiError as A, type BatchTrackRequest as B, type ChangeEmailRequest as C, type DeviceFingerprint as D, type EnhancedAnalyticsEvent as E, type ForgotPasswordRequest as F, type MFASetupRequest as G, type MFAStatus as H, type MFATOTPSetupResponse as I, type MFAVerifyRequest as J, type KnownAccountInfo as K, type LoginResponse as L, type MFAChallengeResponse as M, type OAuthCallbackResponse as N, type OAuthCallbackRequest as O, type OAuthConfig as P, type OAuthProvider as Q, type OAuthStartResponse as R, type ScaleMuleConfig as S, type PageViewData as T, type User as U, type PayoutSchedule as V, type PhoneLoginRequest as W, type PhoneSendCodeRequest as X, type PhoneVerifyRequest as Y, type Profile as Z, type RefreshResponse as _, type UseAuthReturn as a, type ResetPasswordRequest as a0, ScaleMuleApiError as a1, type ScaleMuleEnvironment as a2, type Session as a3, type SignedUploadCompleteRequest as a4, type SignedUploadRequest as a5, type SignedUploadResponse as a6, type SignedUploadUrl as a7, type StorageAdapter as a8, type StorageFile as a9, type TrackEventResponse as aa, type TransactionSummary as ab, type UTMParams as ac, type UpdateProfileRequest as ad, type UploadOptions as ae, type UploadResponse as af, type VerifyEmailRequest as ag, type UseBillingReturn as b, type ListFilesParams as c, type UseContentReturn as d, type UseUserReturn as e, type UseAnalyticsOptions as f, type UseAnalyticsReturn as g, type AccountBalance as h, type AnalyticsEvent as i, type ApiResponse as j, type BillingPayment as k, type BillingPayout as l, type BillingRefund as m, type BillingTransaction as n, type ChangePasswordRequest as o, type ClientContext as p, type ConnectedAccount as q, type DeviceInfo as r, type LinkedAccount as s, type ListFilesResponse as t, type LoginDeviceInfo as u, type LoginRequest as v, type LoginResponseWithMFA as w, type LoginRiskInfo as x, type MFAMethod as y, type MFASMSSetupResponse as z };
845
+ export { type ResetPasswordRequest as $, type ApiError as A, type BatchTrackRequest as B, type ChangeEmailRequest as C, type DeviceFingerprint as D, type EnhancedAnalyticsEvent as E, type ForgotPasswordRequest as F, type MFASetupRequest as G, type MFAStatus as H, type MFATOTPSetupResponse as I, type MFAVerifyRequest as J, type OAuthCallbackResponse as K, type LoginResponse as L, type MFAChallengeResponse as M, type OAuthConfig as N, type OAuthCallbackRequest as O, type OAuthProvider as P, type OAuthStartResponse as Q, type PageViewData as R, type ScaleMuleConfig as S, type PayoutSchedule as T, type User as U, type PhoneLoginRequest as V, type PhoneSendCodeRequest as W, type PhoneVerifyRequest as X, type Profile as Y, type RefreshResponse as Z, type RegisterRequest as _, type UseAuthReturn as a, ScaleMuleApiError as a0, type ScaleMuleEnvironment as a1, type Session as a2, type SignedUploadCompleteRequest as a3, type SignedUploadRequest as a4, type SignedUploadResponse as a5, type SignedUploadUrl as a6, type StorageAdapter as a7, type StorageFile as a8, type TrackEventResponse as a9, type TransactionSummary as aa, type UTMParams as ab, type UpdateProfileRequest as ac, type UploadOptions as ad, type UploadResponse as ae, type VerifyEmailRequest as af, type UseBillingReturn as b, type ListFilesParams as c, type UseContentReturn as d, type UseUserReturn as e, type UseAnalyticsOptions as f, type UseAnalyticsReturn as g, type AccountBalance as h, type AnalyticsEvent as i, type ApiResponse as j, type BillingPayment as k, type BillingPayout as l, type BillingRefund as m, type BillingTransaction as n, type ChangePasswordRequest as o, type ClientContext as p, type ConnectedAccount as q, type DeviceInfo as r, type LinkedAccount as s, type ListFilesResponse as t, type LoginDeviceInfo as u, type LoginRequest as v, type LoginResponseWithMFA as w, type LoginRiskInfo as x, type MFAMethod as y, type MFASMSSetupResponse as z };
package/dist/index.d.mts CHANGED
@@ -3,8 +3,8 @@ import { ReactNode } from 'react';
3
3
  import { RealtimeService } from '@scalemule/sdk';
4
4
  import { ScaleMuleClient } from './client.mjs';
5
5
  export { ClientConfig, RequestOptions, createClient } from './client.mjs';
6
- import { S as ScaleMuleConfig, U as User, L as LoginResponse, A as ApiError, a as UseAuthReturn, b as UseBillingReturn, c as ListFilesParams, d as UseContentReturn, e as UseUserReturn, f as UseAnalyticsOptions, g as UseAnalyticsReturn } from './index-BIIUrnPr.mjs';
7
- export { h as AccountBalance, i as AnalyticsEvent, j as ApiResponse, B as BatchTrackRequest, k as BillingPayment, l as BillingPayout, m as BillingRefund, n as BillingTransaction, C as ChangeEmailRequest, o as ChangePasswordRequest, p as ClientContext, q as ConnectedAccount, D as DeviceFingerprint, r as DeviceInfo, E as EnhancedAnalyticsEvent, F as ForgotPasswordRequest, K as KnownAccountInfo, s as LinkedAccount, t as ListFilesResponse, u as LoginDeviceInfo, v as LoginRequest, w as LoginResponseWithMFA, x as LoginRiskInfo, M as MFAChallengeResponse, y as MFAMethod, z as MFASMSSetupResponse, G as MFASetupRequest, H as MFAStatus, I as MFATOTPSetupResponse, J as MFAVerifyRequest, O as OAuthCallbackRequest, N as OAuthCallbackResponse, P as OAuthConfig, Q as OAuthProvider, R as OAuthStartResponse, T as PageViewData, V as PayoutSchedule, W as PhoneLoginRequest, X as PhoneSendCodeRequest, Y as PhoneVerifyRequest, Z as Profile, _ as RefreshResponse, $ as RegisterRequest, a0 as ResetPasswordRequest, a1 as ScaleMuleApiError, a2 as ScaleMuleEnvironment, a3 as Session, a4 as SignedUploadCompleteRequest, a5 as SignedUploadRequest, a6 as SignedUploadResponse, a7 as SignedUploadUrl, a8 as StorageAdapter, a9 as StorageFile, aa as TrackEventResponse, ab as TransactionSummary, ac as UTMParams, ad as UpdateProfileRequest, ae as UploadOptions, af as UploadResponse, ag as VerifyEmailRequest } from './index-BIIUrnPr.mjs';
6
+ import { S as ScaleMuleConfig, U as User, L as LoginResponse, A as ApiError, a as UseAuthReturn, b as UseBillingReturn, c as ListFilesParams, d as UseContentReturn, e as UseUserReturn, f as UseAnalyticsOptions, g as UseAnalyticsReturn } from './index-BoENfro3.mjs';
7
+ export { h as AccountBalance, i as AnalyticsEvent, j as ApiResponse, B as BatchTrackRequest, k as BillingPayment, l as BillingPayout, m as BillingRefund, n as BillingTransaction, C as ChangeEmailRequest, o as ChangePasswordRequest, p as ClientContext, q as ConnectedAccount, D as DeviceFingerprint, r as DeviceInfo, E as EnhancedAnalyticsEvent, F as ForgotPasswordRequest, s as LinkedAccount, t as ListFilesResponse, u as LoginDeviceInfo, v as LoginRequest, w as LoginResponseWithMFA, x as LoginRiskInfo, M as MFAChallengeResponse, y as MFAMethod, z as MFASMSSetupResponse, G as MFASetupRequest, H as MFAStatus, I as MFATOTPSetupResponse, J as MFAVerifyRequest, O as OAuthCallbackRequest, K as OAuthCallbackResponse, N as OAuthConfig, P as OAuthProvider, Q as OAuthStartResponse, R as PageViewData, T as PayoutSchedule, V as PhoneLoginRequest, W as PhoneSendCodeRequest, X as PhoneVerifyRequest, Y as Profile, Z as RefreshResponse, _ as RegisterRequest, $ as ResetPasswordRequest, a0 as ScaleMuleApiError, a1 as ScaleMuleEnvironment, a2 as Session, a3 as SignedUploadCompleteRequest, a4 as SignedUploadRequest, a5 as SignedUploadResponse, a6 as SignedUploadUrl, a7 as StorageAdapter, a8 as StorageFile, a9 as TrackEventResponse, aa as TransactionSummary, ab as UTMParams, ac as UpdateProfileRequest, ad as UploadOptions, ae as UploadResponse, af as VerifyEmailRequest } from './index-BoENfro3.mjs';
8
8
 
9
9
  interface ScaleMuleContextValue {
10
10
  /** The API client instance */
@@ -31,10 +31,6 @@ interface ScaleMuleContextValue {
31
31
  gatewayUrl?: string;
32
32
  /** Configured environment ('dev' or 'prod') */
33
33
  environment?: string;
34
- /** Whether the account switcher is enabled */
35
- enableAccountSwitcher?: boolean;
36
- /** Privacy level for account switcher */
37
- accountSwitcherPrivacy?: string;
38
34
  /** Server-evaluated flag values to bootstrap the client (eliminates loading flash) */
39
35
  bootstrapFlags?: Record<string, unknown>;
40
36
  }
@@ -49,7 +45,7 @@ interface ScaleMuleProviderProps extends ScaleMuleConfig {
49
45
  /** Server-evaluated flag values to bootstrap the client (eliminates loading flash) */
50
46
  bootstrapFlags?: Record<string, unknown>;
51
47
  }
52
- declare function ScaleMuleProvider({ apiKey, applicationId, environment, gatewayUrl, debug, storage, analyticsProxyUrl, authProxyUrl, publishableKey, enableAccountSwitcher, accountSwitcherPrivacy, children, onLogin, onLogout, onAuthError, bootstrapFlags, }: ScaleMuleProviderProps): react_jsx_runtime.JSX.Element;
48
+ declare function ScaleMuleProvider({ apiKey, applicationId, environment, gatewayUrl, debug, storage, analyticsProxyUrl, authProxyUrl, publishableKey, children, onLogin, onLogout, onAuthError, bootstrapFlags, }: ScaleMuleProviderProps): react_jsx_runtime.JSX.Element;
53
49
  declare function useScaleMule(): ScaleMuleContextValue;
54
50
  declare function useScaleMuleClient(): ScaleMuleClient;
55
51
 
package/dist/index.d.ts CHANGED
@@ -3,8 +3,8 @@ import { ReactNode } from 'react';
3
3
  import { RealtimeService } from '@scalemule/sdk';
4
4
  import { ScaleMuleClient } from './client.js';
5
5
  export { ClientConfig, RequestOptions, createClient } from './client.js';
6
- import { S as ScaleMuleConfig, U as User, L as LoginResponse, A as ApiError, a as UseAuthReturn, b as UseBillingReturn, c as ListFilesParams, d as UseContentReturn, e as UseUserReturn, f as UseAnalyticsOptions, g as UseAnalyticsReturn } from './index-BIIUrnPr.js';
7
- export { h as AccountBalance, i as AnalyticsEvent, j as ApiResponse, B as BatchTrackRequest, k as BillingPayment, l as BillingPayout, m as BillingRefund, n as BillingTransaction, C as ChangeEmailRequest, o as ChangePasswordRequest, p as ClientContext, q as ConnectedAccount, D as DeviceFingerprint, r as DeviceInfo, E as EnhancedAnalyticsEvent, F as ForgotPasswordRequest, K as KnownAccountInfo, s as LinkedAccount, t as ListFilesResponse, u as LoginDeviceInfo, v as LoginRequest, w as LoginResponseWithMFA, x as LoginRiskInfo, M as MFAChallengeResponse, y as MFAMethod, z as MFASMSSetupResponse, G as MFASetupRequest, H as MFAStatus, I as MFATOTPSetupResponse, J as MFAVerifyRequest, O as OAuthCallbackRequest, N as OAuthCallbackResponse, P as OAuthConfig, Q as OAuthProvider, R as OAuthStartResponse, T as PageViewData, V as PayoutSchedule, W as PhoneLoginRequest, X as PhoneSendCodeRequest, Y as PhoneVerifyRequest, Z as Profile, _ as RefreshResponse, $ as RegisterRequest, a0 as ResetPasswordRequest, a1 as ScaleMuleApiError, a2 as ScaleMuleEnvironment, a3 as Session, a4 as SignedUploadCompleteRequest, a5 as SignedUploadRequest, a6 as SignedUploadResponse, a7 as SignedUploadUrl, a8 as StorageAdapter, a9 as StorageFile, aa as TrackEventResponse, ab as TransactionSummary, ac as UTMParams, ad as UpdateProfileRequest, ae as UploadOptions, af as UploadResponse, ag as VerifyEmailRequest } from './index-BIIUrnPr.js';
6
+ import { S as ScaleMuleConfig, U as User, L as LoginResponse, A as ApiError, a as UseAuthReturn, b as UseBillingReturn, c as ListFilesParams, d as UseContentReturn, e as UseUserReturn, f as UseAnalyticsOptions, g as UseAnalyticsReturn } from './index-BoENfro3.js';
7
+ export { h as AccountBalance, i as AnalyticsEvent, j as ApiResponse, B as BatchTrackRequest, k as BillingPayment, l as BillingPayout, m as BillingRefund, n as BillingTransaction, C as ChangeEmailRequest, o as ChangePasswordRequest, p as ClientContext, q as ConnectedAccount, D as DeviceFingerprint, r as DeviceInfo, E as EnhancedAnalyticsEvent, F as ForgotPasswordRequest, s as LinkedAccount, t as ListFilesResponse, u as LoginDeviceInfo, v as LoginRequest, w as LoginResponseWithMFA, x as LoginRiskInfo, M as MFAChallengeResponse, y as MFAMethod, z as MFASMSSetupResponse, G as MFASetupRequest, H as MFAStatus, I as MFATOTPSetupResponse, J as MFAVerifyRequest, O as OAuthCallbackRequest, K as OAuthCallbackResponse, N as OAuthConfig, P as OAuthProvider, Q as OAuthStartResponse, R as PageViewData, T as PayoutSchedule, V as PhoneLoginRequest, W as PhoneSendCodeRequest, X as PhoneVerifyRequest, Y as Profile, Z as RefreshResponse, _ as RegisterRequest, $ as ResetPasswordRequest, a0 as ScaleMuleApiError, a1 as ScaleMuleEnvironment, a2 as Session, a3 as SignedUploadCompleteRequest, a4 as SignedUploadRequest, a5 as SignedUploadResponse, a6 as SignedUploadUrl, a7 as StorageAdapter, a8 as StorageFile, a9 as TrackEventResponse, aa as TransactionSummary, ab as UTMParams, ac as UpdateProfileRequest, ad as UploadOptions, ae as UploadResponse, af as VerifyEmailRequest } from './index-BoENfro3.js';
8
8
 
9
9
  interface ScaleMuleContextValue {
10
10
  /** The API client instance */
@@ -31,10 +31,6 @@ interface ScaleMuleContextValue {
31
31
  gatewayUrl?: string;
32
32
  /** Configured environment ('dev' or 'prod') */
33
33
  environment?: string;
34
- /** Whether the account switcher is enabled */
35
- enableAccountSwitcher?: boolean;
36
- /** Privacy level for account switcher */
37
- accountSwitcherPrivacy?: string;
38
34
  /** Server-evaluated flag values to bootstrap the client (eliminates loading flash) */
39
35
  bootstrapFlags?: Record<string, unknown>;
40
36
  }
@@ -49,7 +45,7 @@ interface ScaleMuleProviderProps extends ScaleMuleConfig {
49
45
  /** Server-evaluated flag values to bootstrap the client (eliminates loading flash) */
50
46
  bootstrapFlags?: Record<string, unknown>;
51
47
  }
52
- declare function ScaleMuleProvider({ apiKey, applicationId, environment, gatewayUrl, debug, storage, analyticsProxyUrl, authProxyUrl, publishableKey, enableAccountSwitcher, accountSwitcherPrivacy, children, onLogin, onLogout, onAuthError, bootstrapFlags, }: ScaleMuleProviderProps): react_jsx_runtime.JSX.Element;
48
+ declare function ScaleMuleProvider({ apiKey, applicationId, environment, gatewayUrl, debug, storage, analyticsProxyUrl, authProxyUrl, publishableKey, children, onLogin, onLogout, onAuthError, bootstrapFlags, }: ScaleMuleProviderProps): react_jsx_runtime.JSX.Element;
53
49
  declare function useScaleMule(): ScaleMuleContextValue;
54
50
  declare function useScaleMuleClient(): ScaleMuleClient;
55
51
 
package/dist/index.js CHANGED
@@ -3217,10 +3217,29 @@ var RealtimeService = class extends ServiceModule {
3217
3217
  // --------------------------------------------------------------------------
3218
3218
  connect() {
3219
3219
  if (this._status === "connecting" || this._status === "connected") return;
3220
- const baseUrl = this.client.getBaseUrl();
3221
- const wsUrl = baseUrl.replace(/^http/, "ws") + "/v1/realtime/ws";
3222
3220
  this.setStatus(this.reconnectAttempt > 0 ? "reconnecting" : "connecting");
3221
+ this.fetchTicketAndConnect();
3222
+ }
3223
+ async fetchTicketAndConnect() {
3224
+ const baseUrl = this.client.getBaseUrl();
3223
3225
  try {
3226
+ const headers = { "Content-Type": "application/json" };
3227
+ const apiKey = this.client.getApiKey();
3228
+ if (apiKey) headers["x-api-key"] = apiKey;
3229
+ const token = this.client.getSessionToken();
3230
+ if (token) headers["Authorization"] = `Bearer ${token}`;
3231
+ const ticketRes = await fetch(`${baseUrl}/v1/realtime/ws/ticket`, {
3232
+ method: "POST",
3233
+ headers
3234
+ });
3235
+ let wsUrl;
3236
+ if (ticketRes.ok) {
3237
+ const ticketData = await ticketRes.json();
3238
+ const ticket = ticketData.ticket;
3239
+ wsUrl = baseUrl.replace(/^http/, "ws") + `/v1/realtime/ws?ticket=${encodeURIComponent(ticket)}`;
3240
+ } else {
3241
+ wsUrl = baseUrl.replace(/^http/, "ws") + "/v1/realtime/ws";
3242
+ }
3224
3243
  this.ws = new WebSocket(wsUrl);
3225
3244
  } catch {
3226
3245
  this.scheduleReconnect();
@@ -6916,8 +6935,6 @@ function ScaleMuleProvider({
6916
6935
  analyticsProxyUrl,
6917
6936
  authProxyUrl,
6918
6937
  publishableKey,
6919
- enableAccountSwitcher,
6920
- accountSwitcherPrivacy,
6921
6938
  children,
6922
6939
  onLogin,
6923
6940
  onLogout,
@@ -7055,11 +7072,9 @@ function ScaleMuleProvider({
7055
7072
  publishableKey,
7056
7073
  gatewayUrl: gatewayUrl || (environment === "dev" ? "https://api-dev.scalemule.com" : "https://api.scalemule.com"),
7057
7074
  environment: environment || void 0,
7058
- enableAccountSwitcher,
7059
- accountSwitcherPrivacy,
7060
7075
  bootstrapFlags
7061
7076
  }),
7062
- [client, baseClient, user, handleSetUser, initializing, error, analyticsProxyUrl, authProxyUrl, publishableKey, gatewayUrl, environment, enableAccountSwitcher, accountSwitcherPrivacy, bootstrapFlags]
7077
+ [client, baseClient, user, handleSetUser, initializing, error, analyticsProxyUrl, authProxyUrl, publishableKey, gatewayUrl, environment, bootstrapFlags]
7063
7078
  );
7064
7079
  return /* @__PURE__ */ jsxRuntime.jsx(ScaleMuleContext.Provider, { value, children });
7065
7080
  }
@@ -7076,41 +7091,6 @@ function useScaleMuleClient() {
7076
7091
  const { client } = useScaleMule();
7077
7092
  return client;
7078
7093
  }
7079
- function maskEmail2(email) {
7080
- const [local, domain] = email.split("@");
7081
- if (!domain) return "***@***.***";
7082
- const tldDot = domain.lastIndexOf(".");
7083
- const tld = tldDot > 0 ? domain.slice(tldDot) : "";
7084
- const domainBase = tldDot > 0 ? domain.slice(0, tldDot) : domain;
7085
- return `${local[0] || "*"}***@${domainBase[0] || "*"}***${tld}`;
7086
- }
7087
- function stableColorIndex2(userId) {
7088
- let hash = 0;
7089
- for (let i = 0; i < userId.length; i++) {
7090
- hash = (hash << 5) - hash + userId.charCodeAt(i) | 0;
7091
- }
7092
- return Math.abs(hash) % 8;
7093
- }
7094
- function applyClientPrivacy(entry, privacy) {
7095
- if (!privacy || privacy === "full") return entry;
7096
- if (privacy === "masked") {
7097
- return {
7098
- userId: entry.userId,
7099
- email: entry.email ? maskEmail2(entry.email) : void 0,
7100
- fullName: entry.fullName ? `${entry.fullName[0].toUpperCase()}.` : void 0,
7101
- provider: entry.provider,
7102
- lastActiveAt: entry.lastActiveAt,
7103
- colorIndex: stableColorIndex2(entry.userId)
7104
- };
7105
- }
7106
- return {
7107
- userId: entry.userId,
7108
- provider: entry.provider,
7109
- lastActiveAt: entry.lastActiveAt,
7110
- displayLabel: "Account",
7111
- colorIndex: stableColorIndex2(entry.userId)
7112
- };
7113
- }
7114
7094
  function getCookie(name) {
7115
7095
  if (typeof document === "undefined") return void 0;
7116
7096
  const match = document.cookie.match(new RegExp(`(?:^|; )${name}=([^;]*)`));
@@ -7139,7 +7119,7 @@ async function proxyFetch(proxyUrl, path, options = {}) {
7139
7119
  return data;
7140
7120
  }
7141
7121
  function useAuth() {
7142
- const { client, user, setUser, initializing, error, setError, authProxyUrl, enableAccountSwitcher, accountSwitcherPrivacy } = useScaleMule();
7122
+ const { client, user, setUser, initializing, error, setError, authProxyUrl } = useScaleMule();
7143
7123
  const register = react.useCallback(
7144
7124
  async (data) => {
7145
7125
  setError(null);
@@ -7747,63 +7727,6 @@ function useAuth() {
7747
7727
  },
7748
7728
  [client, setUser, setError, authProxyUrl]
7749
7729
  );
7750
- const readKnownAccountsCookie = react.useCallback(() => {
7751
- if (!enableAccountSwitcher) return [];
7752
- if (typeof document === "undefined") return [];
7753
- const match = document.cookie.match(/(?:^|; )sm_known_accounts=([^;]*)/);
7754
- if (!match) return [];
7755
- try {
7756
- const decoded = decodeURIComponent(match[1]);
7757
- const accounts = JSON.parse(decoded);
7758
- let entries = Object.values(accounts);
7759
- if (accountSwitcherPrivacy && accountSwitcherPrivacy !== "full") {
7760
- entries = entries.map((e) => applyClientPrivacy(e, accountSwitcherPrivacy));
7761
- }
7762
- return entries;
7763
- } catch {
7764
- return [];
7765
- }
7766
- }, [enableAccountSwitcher, accountSwitcherPrivacy]);
7767
- const [knownAccounts, setKnownAccounts] = react.useState([]);
7768
- react.useEffect(() => {
7769
- setKnownAccounts(readKnownAccountsCookie());
7770
- }, [readKnownAccountsCookie, user]);
7771
- const switchAccount = react.useCallback(
7772
- async (userId) => {
7773
- const target = knownAccounts.find((a) => a.userId === userId) || null;
7774
- if (!target) return null;
7775
- if (authProxyUrl) {
7776
- await proxyFetch(authProxyUrl, "switch-account");
7777
- } else {
7778
- const sessionToken = client.getSessionToken();
7779
- if (sessionToken) {
7780
- try {
7781
- await client.post("/v1/auth/logout", { session_token: sessionToken });
7782
- } catch {
7783
- }
7784
- }
7785
- await client.clearSession();
7786
- }
7787
- setUser(null);
7788
- return target;
7789
- },
7790
- [client, setUser, knownAccounts, authProxyUrl]
7791
- );
7792
- const removeKnownAccount = react.useCallback(
7793
- async (userId) => {
7794
- if (authProxyUrl) {
7795
- await proxyFetch(authProxyUrl, "forget-account", { body: { user_id: userId } });
7796
- }
7797
- setKnownAccounts((prev) => prev.filter((a) => a.userId !== userId));
7798
- },
7799
- [authProxyUrl]
7800
- );
7801
- const clearKnownAccounts = react.useCallback(async () => {
7802
- if (authProxyUrl) {
7803
- await proxyFetch(authProxyUrl, "forget-all-accounts");
7804
- }
7805
- setKnownAccounts([]);
7806
- }, [authProxyUrl]);
7807
7730
  return react.useMemo(
7808
7731
  () => ({
7809
7732
  user,
@@ -7835,12 +7758,7 @@ function useAuth() {
7835
7758
  // Phone auth
7836
7759
  sendPhoneCode,
7837
7760
  verifyPhone,
7838
- loginWithPhone,
7839
- // Account switcher
7840
- knownAccounts,
7841
- switchAccount,
7842
- removeKnownAccount,
7843
- clearKnownAccounts
7761
+ loginWithPhone
7844
7762
  }),
7845
7763
  [
7846
7764
  user,
@@ -7867,11 +7785,7 @@ function useAuth() {
7867
7785
  regenerateBackupCodes,
7868
7786
  sendPhoneCode,
7869
7787
  verifyPhone,
7870
- loginWithPhone,
7871
- knownAccounts,
7872
- switchAccount,
7873
- removeKnownAccount,
7874
- clearKnownAccounts
7788
+ loginWithPhone
7875
7789
  ]
7876
7790
  );
7877
7791
  }
package/dist/index.mjs CHANGED
@@ -3215,10 +3215,29 @@ var RealtimeService = class extends ServiceModule {
3215
3215
  // --------------------------------------------------------------------------
3216
3216
  connect() {
3217
3217
  if (this._status === "connecting" || this._status === "connected") return;
3218
- const baseUrl = this.client.getBaseUrl();
3219
- const wsUrl = baseUrl.replace(/^http/, "ws") + "/v1/realtime/ws";
3220
3218
  this.setStatus(this.reconnectAttempt > 0 ? "reconnecting" : "connecting");
3219
+ this.fetchTicketAndConnect();
3220
+ }
3221
+ async fetchTicketAndConnect() {
3222
+ const baseUrl = this.client.getBaseUrl();
3221
3223
  try {
3224
+ const headers = { "Content-Type": "application/json" };
3225
+ const apiKey = this.client.getApiKey();
3226
+ if (apiKey) headers["x-api-key"] = apiKey;
3227
+ const token = this.client.getSessionToken();
3228
+ if (token) headers["Authorization"] = `Bearer ${token}`;
3229
+ const ticketRes = await fetch(`${baseUrl}/v1/realtime/ws/ticket`, {
3230
+ method: "POST",
3231
+ headers
3232
+ });
3233
+ let wsUrl;
3234
+ if (ticketRes.ok) {
3235
+ const ticketData = await ticketRes.json();
3236
+ const ticket = ticketData.ticket;
3237
+ wsUrl = baseUrl.replace(/^http/, "ws") + `/v1/realtime/ws?ticket=${encodeURIComponent(ticket)}`;
3238
+ } else {
3239
+ wsUrl = baseUrl.replace(/^http/, "ws") + "/v1/realtime/ws";
3240
+ }
3222
3241
  this.ws = new WebSocket(wsUrl);
3223
3242
  } catch {
3224
3243
  this.scheduleReconnect();
@@ -6914,8 +6933,6 @@ function ScaleMuleProvider({
6914
6933
  analyticsProxyUrl,
6915
6934
  authProxyUrl,
6916
6935
  publishableKey,
6917
- enableAccountSwitcher,
6918
- accountSwitcherPrivacy,
6919
6936
  children,
6920
6937
  onLogin,
6921
6938
  onLogout,
@@ -7053,11 +7070,9 @@ function ScaleMuleProvider({
7053
7070
  publishableKey,
7054
7071
  gatewayUrl: gatewayUrl || (environment === "dev" ? "https://api-dev.scalemule.com" : "https://api.scalemule.com"),
7055
7072
  environment: environment || void 0,
7056
- enableAccountSwitcher,
7057
- accountSwitcherPrivacy,
7058
7073
  bootstrapFlags
7059
7074
  }),
7060
- [client, baseClient, user, handleSetUser, initializing, error, analyticsProxyUrl, authProxyUrl, publishableKey, gatewayUrl, environment, enableAccountSwitcher, accountSwitcherPrivacy, bootstrapFlags]
7075
+ [client, baseClient, user, handleSetUser, initializing, error, analyticsProxyUrl, authProxyUrl, publishableKey, gatewayUrl, environment, bootstrapFlags]
7061
7076
  );
7062
7077
  return /* @__PURE__ */ jsx(ScaleMuleContext.Provider, { value, children });
7063
7078
  }
@@ -7074,41 +7089,6 @@ function useScaleMuleClient() {
7074
7089
  const { client } = useScaleMule();
7075
7090
  return client;
7076
7091
  }
7077
- function maskEmail2(email) {
7078
- const [local, domain] = email.split("@");
7079
- if (!domain) return "***@***.***";
7080
- const tldDot = domain.lastIndexOf(".");
7081
- const tld = tldDot > 0 ? domain.slice(tldDot) : "";
7082
- const domainBase = tldDot > 0 ? domain.slice(0, tldDot) : domain;
7083
- return `${local[0] || "*"}***@${domainBase[0] || "*"}***${tld}`;
7084
- }
7085
- function stableColorIndex2(userId) {
7086
- let hash = 0;
7087
- for (let i = 0; i < userId.length; i++) {
7088
- hash = (hash << 5) - hash + userId.charCodeAt(i) | 0;
7089
- }
7090
- return Math.abs(hash) % 8;
7091
- }
7092
- function applyClientPrivacy(entry, privacy) {
7093
- if (!privacy || privacy === "full") return entry;
7094
- if (privacy === "masked") {
7095
- return {
7096
- userId: entry.userId,
7097
- email: entry.email ? maskEmail2(entry.email) : void 0,
7098
- fullName: entry.fullName ? `${entry.fullName[0].toUpperCase()}.` : void 0,
7099
- provider: entry.provider,
7100
- lastActiveAt: entry.lastActiveAt,
7101
- colorIndex: stableColorIndex2(entry.userId)
7102
- };
7103
- }
7104
- return {
7105
- userId: entry.userId,
7106
- provider: entry.provider,
7107
- lastActiveAt: entry.lastActiveAt,
7108
- displayLabel: "Account",
7109
- colorIndex: stableColorIndex2(entry.userId)
7110
- };
7111
- }
7112
7092
  function getCookie(name) {
7113
7093
  if (typeof document === "undefined") return void 0;
7114
7094
  const match = document.cookie.match(new RegExp(`(?:^|; )${name}=([^;]*)`));
@@ -7137,7 +7117,7 @@ async function proxyFetch(proxyUrl, path, options = {}) {
7137
7117
  return data;
7138
7118
  }
7139
7119
  function useAuth() {
7140
- const { client, user, setUser, initializing, error, setError, authProxyUrl, enableAccountSwitcher, accountSwitcherPrivacy } = useScaleMule();
7120
+ const { client, user, setUser, initializing, error, setError, authProxyUrl } = useScaleMule();
7141
7121
  const register = useCallback(
7142
7122
  async (data) => {
7143
7123
  setError(null);
@@ -7745,63 +7725,6 @@ function useAuth() {
7745
7725
  },
7746
7726
  [client, setUser, setError, authProxyUrl]
7747
7727
  );
7748
- const readKnownAccountsCookie = useCallback(() => {
7749
- if (!enableAccountSwitcher) return [];
7750
- if (typeof document === "undefined") return [];
7751
- const match = document.cookie.match(/(?:^|; )sm_known_accounts=([^;]*)/);
7752
- if (!match) return [];
7753
- try {
7754
- const decoded = decodeURIComponent(match[1]);
7755
- const accounts = JSON.parse(decoded);
7756
- let entries = Object.values(accounts);
7757
- if (accountSwitcherPrivacy && accountSwitcherPrivacy !== "full") {
7758
- entries = entries.map((e) => applyClientPrivacy(e, accountSwitcherPrivacy));
7759
- }
7760
- return entries;
7761
- } catch {
7762
- return [];
7763
- }
7764
- }, [enableAccountSwitcher, accountSwitcherPrivacy]);
7765
- const [knownAccounts, setKnownAccounts] = useState([]);
7766
- useEffect(() => {
7767
- setKnownAccounts(readKnownAccountsCookie());
7768
- }, [readKnownAccountsCookie, user]);
7769
- const switchAccount = useCallback(
7770
- async (userId) => {
7771
- const target = knownAccounts.find((a) => a.userId === userId) || null;
7772
- if (!target) return null;
7773
- if (authProxyUrl) {
7774
- await proxyFetch(authProxyUrl, "switch-account");
7775
- } else {
7776
- const sessionToken = client.getSessionToken();
7777
- if (sessionToken) {
7778
- try {
7779
- await client.post("/v1/auth/logout", { session_token: sessionToken });
7780
- } catch {
7781
- }
7782
- }
7783
- await client.clearSession();
7784
- }
7785
- setUser(null);
7786
- return target;
7787
- },
7788
- [client, setUser, knownAccounts, authProxyUrl]
7789
- );
7790
- const removeKnownAccount = useCallback(
7791
- async (userId) => {
7792
- if (authProxyUrl) {
7793
- await proxyFetch(authProxyUrl, "forget-account", { body: { user_id: userId } });
7794
- }
7795
- setKnownAccounts((prev) => prev.filter((a) => a.userId !== userId));
7796
- },
7797
- [authProxyUrl]
7798
- );
7799
- const clearKnownAccounts = useCallback(async () => {
7800
- if (authProxyUrl) {
7801
- await proxyFetch(authProxyUrl, "forget-all-accounts");
7802
- }
7803
- setKnownAccounts([]);
7804
- }, [authProxyUrl]);
7805
7728
  return useMemo(
7806
7729
  () => ({
7807
7730
  user,
@@ -7833,12 +7756,7 @@ function useAuth() {
7833
7756
  // Phone auth
7834
7757
  sendPhoneCode,
7835
7758
  verifyPhone,
7836
- loginWithPhone,
7837
- // Account switcher
7838
- knownAccounts,
7839
- switchAccount,
7840
- removeKnownAccount,
7841
- clearKnownAccounts
7759
+ loginWithPhone
7842
7760
  }),
7843
7761
  [
7844
7762
  user,
@@ -7865,11 +7783,7 @@ function useAuth() {
7865
7783
  regenerateBackupCodes,
7866
7784
  sendPhoneCode,
7867
7785
  verifyPhone,
7868
- loginWithPhone,
7869
- knownAccounts,
7870
- switchAccount,
7871
- removeKnownAccount,
7872
- clearKnownAccounts
7786
+ loginWithPhone
7873
7787
  ]
7874
7788
  );
7875
7789
  }