@scalemule/nextjs 0.1.57 → 0.1.60

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/audio.d.mts CHANGED
@@ -264,6 +264,8 @@ interface ListeningPersistence {
264
264
  /** Network and reader scope. Change this on account changes. */
265
265
  storageKey: string;
266
266
  networkId: string;
267
+ /** New player windows adopt the opener queue instead of restoring an older host queue. */
268
+ restoreQueue?: boolean;
267
269
  hubUrl?: string;
268
270
  allowedOrigins: readonly string[];
269
271
  }
package/dist/audio.d.ts CHANGED
@@ -264,6 +264,8 @@ interface ListeningPersistence {
264
264
  /** Network and reader scope. Change this on account changes. */
265
265
  storageKey: string;
266
266
  networkId: string;
267
+ /** New player windows adopt the opener queue instead of restoring an older host queue. */
268
+ restoreQueue?: boolean;
267
269
  hubUrl?: string;
268
270
  allowedOrigins: readonly string[];
269
271
  }
package/dist/audio.js CHANGED
@@ -1493,7 +1493,7 @@ function persistListening(controller, options) {
1493
1493
  const hubOrigin = options.hubUrl ? new URL(options.hubUrl).origin : null;
1494
1494
  try {
1495
1495
  const saved = JSON.parse(localStorage.getItem(options.storageKey) ?? "null");
1496
- if (validSnapshot(saved) && saved.queue.every((item) => allowed.has(new URL(item.articleUrl).origin))) controller.restore(saved);
1496
+ if (validSnapshot(saved) && saved.queue.every((item) => allowed.has(new URL(item.articleUrl).origin))) controller.restore(options.restoreQueue === false ? { ...saved, queue: [], index: -1, position: 0, duration: 0, hidden: false } : saved);
1497
1497
  } catch {
1498
1498
  }
1499
1499
  const url = new URL(window.location.href);
@@ -1651,8 +1651,8 @@ function NetworkAudioProvider({ children, resolveAudio, connection, host, checkp
1651
1651
  }, [controller, checkpointStorageKey]);
1652
1652
  const persistenceOrigins = JSON.stringify(persistence?.allowedOrigins ?? []);
1653
1653
  (0, import_react2.useEffect)(() => {
1654
- if (persistence) return persistListening(controller, { ...persistence, allowedOrigins: JSON.parse(persistenceOrigins) });
1655
- }, [controller, persistence?.storageKey, persistence?.networkId, persistence?.hubUrl, persistenceOrigins]);
1654
+ if (persistence) return persistListening(controller, { ...persistence, restoreQueue: host && window.opener ? false : persistence.restoreQueue, allowedOrigins: JSON.parse(persistenceOrigins) });
1655
+ }, [controller, persistence?.storageKey, persistence?.networkId, persistence?.hubUrl, persistence?.restoreQueue, host?.networkId, persistenceOrigins]);
1656
1656
  (0, import_react2.useEffect)(() => () => recommendationRequest.current?.abort(), []);
1657
1657
  const catchUp = (0, import_react2.useCallback)(async (minutes) => {
1658
1658
  if (!loadRecommendations) return;
package/dist/audio.mjs CHANGED
@@ -1472,7 +1472,7 @@ function persistListening(controller, options) {
1472
1472
  const hubOrigin = options.hubUrl ? new URL(options.hubUrl).origin : null;
1473
1473
  try {
1474
1474
  const saved = JSON.parse(localStorage.getItem(options.storageKey) ?? "null");
1475
- if (validSnapshot(saved) && saved.queue.every((item) => allowed.has(new URL(item.articleUrl).origin))) controller.restore(saved);
1475
+ if (validSnapshot(saved) && saved.queue.every((item) => allowed.has(new URL(item.articleUrl).origin))) controller.restore(options.restoreQueue === false ? { ...saved, queue: [], index: -1, position: 0, duration: 0, hidden: false } : saved);
1476
1476
  } catch {
1477
1477
  }
1478
1478
  const url = new URL(window.location.href);
@@ -1630,8 +1630,8 @@ function NetworkAudioProvider({ children, resolveAudio, connection, host, checkp
1630
1630
  }, [controller, checkpointStorageKey]);
1631
1631
  const persistenceOrigins = JSON.stringify(persistence?.allowedOrigins ?? []);
1632
1632
  useEffect2(() => {
1633
- if (persistence) return persistListening(controller, { ...persistence, allowedOrigins: JSON.parse(persistenceOrigins) });
1634
- }, [controller, persistence?.storageKey, persistence?.networkId, persistence?.hubUrl, persistenceOrigins]);
1633
+ if (persistence) return persistListening(controller, { ...persistence, restoreQueue: host && window.opener ? false : persistence.restoreQueue, allowedOrigins: JSON.parse(persistenceOrigins) });
1634
+ }, [controller, persistence?.storageKey, persistence?.networkId, persistence?.hubUrl, persistence?.restoreQueue, host?.networkId, persistenceOrigins]);
1635
1635
  useEffect2(() => () => recommendationRequest.current?.abort(), []);
1636
1636
  const catchUp = useCallback(async (minutes) => {
1637
1637
  if (!loadRecommendations) return;
package/dist/client.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { ac as StorageAdapter, A as ApiError } from './index-2PnO4RAF.mjs';
1
+ import { ac as StorageAdapter, A as ApiError } from './index-CEi5Nd4L.mjs';
2
2
 
3
3
  /**
4
4
  * ScaleMule API Client
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ac as StorageAdapter, A as ApiError } from './index-2PnO4RAF.js';
1
+ import { ac as StorageAdapter, A as ApiError } from './index-CEi5Nd4L.js';
2
2
 
3
3
  /**
4
4
  * ScaleMule API Client
@@ -173,6 +173,11 @@ interface RegisterRequest {
173
173
  full_name?: string;
174
174
  username?: string;
175
175
  phone?: string;
176
+ /** Hidden honeypot field (e.g. publication_code, website, company, hp_field) */
177
+ publication_code?: string;
178
+ website?: string;
179
+ company?: string;
180
+ hp_field?: string;
176
181
  }
177
182
  interface LoginRequest {
178
183
  challenge_token?: string;
@@ -173,6 +173,11 @@ interface RegisterRequest {
173
173
  full_name?: string;
174
174
  username?: string;
175
175
  phone?: string;
176
+ /** Hidden honeypot field (e.g. publication_code, website, company, hp_field) */
177
+ publication_code?: string;
178
+ website?: string;
179
+ company?: string;
180
+ hp_field?: string;
176
181
  }
177
182
  interface LoginRequest {
178
183
  challenge_token?: string;
package/dist/index.d.mts CHANGED
@@ -1,13 +1,13 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ApiError, RealtimeService, StorageService, PhotoService, VideoService, AudioService, TtsService, SocialService, SocialPolicyService, TtsJobStatus, TtsAudioInfo, FileStatus } from '@scalemule/sdk';
3
3
  import * as React from 'react';
4
- import { ReactNode, ReactElement } from 'react';
4
+ import React__default, { ReactNode, ReactElement } from 'react';
5
5
  import { MoneyClient } from '@scalemule/money';
6
6
  export { MoneyClient, MoneyClientConfig, createMoneyClient } from '@scalemule/money';
7
7
  import { ScaleMuleClient } from './client.mjs';
8
8
  export { ClientConfig, RequestOptions, createClient } from './client.mjs';
9
- import { S as ScaleMuleConfig, U as User, L as LoginResponse, A as ApiError$1, a as UseAuthReturn, b as UseBillingReturn, c as ListFilesParams, d as UseContentReturn, e as UseUserReturn, f as UseAnalyticsOptions, g as UseAnalyticsReturn } from './index-2PnO4RAF.mjs';
10
- export { h as AccountBalance, i as AnalyticsEvent, j as ApiResponse, k as AuthLoginResponse, B as BatchTrackRequest, l as BillingPayment, m as BillingPayout, n as BillingRefund, o as BillingTransaction, C as ChangeEmailRequest, p as ChangePasswordRequest, q as ClientContext, r as ConnectedAccount, s as CookieLoginResponse, t as CookieOAuthCallbackResponse, D as DeviceFingerprint, u as DeviceInfo, E as EnhancedAnalyticsEvent, F as ForgotPasswordRequest, K as KnownAccountInfo, v as LinkedAccount, w as ListFilesResponse, x as LoginDeviceInfo, y as LoginRequest, z as LoginResponseWithMFA, G as LoginRiskInfo, M as MFAChallengeResponse, H as MFAMethod, I as MFASMSSetupResponse, J as MFASetupRequest, N as MFAStatus, O as MFATOTPSetupResponse, P as MFAVerifyRequest, Q as OAuthCallbackRequest, R as OAuthCallbackResponse, T as OAuthConfig, V as OAuthProvider, W as OAuthStartResponse, X as PageViewData, Y as PayoutSchedule, Z as PhoneLoginRequest, _ as PhoneSendCodeRequest, $ as PhoneVerifyRequest, a0 as Profile, a1 as ProxyBearerLoginResponse, a2 as RefreshResponse, a3 as RegisterRequest, a4 as ResetPasswordRequest, a5 as ScaleMuleApiError, a6 as ScaleMuleEnvironment, a7 as Session, a8 as SignedUploadCompleteRequest, a9 as SignedUploadRequest, aa as SignedUploadResponse, ab as SignedUploadUrl, ac as StorageAdapter, ad as StorageFile, ae as TrackEventResponse, af as TransactionSummary, ag as UTMParams, ah as UpdateProfileRequest, ai as UploadOptions, aj as UploadResponse, ak as VerifyEmailRequest } from './index-2PnO4RAF.mjs';
9
+ import { S as ScaleMuleConfig, U as User, L as LoginResponse, A as ApiError$1, a as UseAuthReturn, b as UseBillingReturn, c as ListFilesParams, d as UseContentReturn, e as UseUserReturn, f as UseAnalyticsOptions, g as UseAnalyticsReturn } from './index-CEi5Nd4L.mjs';
10
+ export { h as AccountBalance, i as AnalyticsEvent, j as ApiResponse, k as AuthLoginResponse, B as BatchTrackRequest, l as BillingPayment, m as BillingPayout, n as BillingRefund, o as BillingTransaction, C as ChangeEmailRequest, p as ChangePasswordRequest, q as ClientContext, r as ConnectedAccount, s as CookieLoginResponse, t as CookieOAuthCallbackResponse, D as DeviceFingerprint, u as DeviceInfo, E as EnhancedAnalyticsEvent, F as ForgotPasswordRequest, K as KnownAccountInfo, v as LinkedAccount, w as ListFilesResponse, x as LoginDeviceInfo, y as LoginRequest, z as LoginResponseWithMFA, G as LoginRiskInfo, M as MFAChallengeResponse, H as MFAMethod, I as MFASMSSetupResponse, J as MFASetupRequest, N as MFAStatus, O as MFATOTPSetupResponse, P as MFAVerifyRequest, Q as OAuthCallbackRequest, R as OAuthCallbackResponse, T as OAuthConfig, V as OAuthProvider, W as OAuthStartResponse, X as PageViewData, Y as PayoutSchedule, Z as PhoneLoginRequest, _ as PhoneSendCodeRequest, $ as PhoneVerifyRequest, a0 as Profile, a1 as ProxyBearerLoginResponse, a2 as RefreshResponse, a3 as RegisterRequest, a4 as ResetPasswordRequest, a5 as ScaleMuleApiError, a6 as ScaleMuleEnvironment, a7 as Session, a8 as SignedUploadCompleteRequest, a9 as SignedUploadRequest, aa as SignedUploadResponse, ab as SignedUploadUrl, ac as StorageAdapter, ad as StorageFile, ae as TrackEventResponse, af as TransactionSummary, ag as UTMParams, ah as UpdateProfileRequest, ai as UploadOptions, aj as UploadResponse, ak as VerifyEmailRequest } from './index-CEi5Nd4L.mjs';
11
11
 
12
12
  /**
13
13
  * Tri-state file visibility — `'private' | 'app_public' | 'anonymous_visible'`.
@@ -1073,6 +1073,78 @@ interface VoteButtonProps {
1073
1073
  }
1074
1074
  declare function VoteButton({ targetType, targetId, initialState, layout, size, onSignInRequired, onError, classNames, upLabel, downLabel, }: VoteButtonProps): react_jsx_runtime.JSX.Element;
1075
1075
 
1076
+ type HoneypotFieldName = 'website' | 'company' | 'publication_code' | 'hp_field';
1077
+ interface RegisterHoneypotProps {
1078
+ /**
1079
+ * Field name recognized by ScaleMule honeypot defenses.
1080
+ * Defaults to 'website'.
1081
+ */
1082
+ name?: HoneypotFieldName | string;
1083
+ /**
1084
+ * Controlled value if managing state in React.
1085
+ */
1086
+ value?: string;
1087
+ /**
1088
+ * Change handler for controlled state.
1089
+ */
1090
+ onChange?: (e: React__default.ChangeEvent<HTMLInputElement>) => void;
1091
+ /**
1092
+ * Optional custom id for the hidden input.
1093
+ */
1094
+ id?: string;
1095
+ /**
1096
+ * Optional additional className (field is styled off-screen regardless).
1097
+ */
1098
+ className?: string;
1099
+ /**
1100
+ * Optional custom accessible label text.
1101
+ */
1102
+ label?: string;
1103
+ }
1104
+ /**
1105
+ * RegisterHoneypot — invisible honeypot input component for registration forms.
1106
+ *
1107
+ * Traps automated spam bots that blindly fill every visible and invisible input field.
1108
+ * When submitted with any non-empty value, ScaleMule auth silently absorbs and drops
1109
+ * the registration attempt with a synthetic 201/200 success response, preventing AWS SES
1110
+ * hard bounces, dirty accounts, and email verification spam.
1111
+ *
1112
+ * @example
1113
+ * ```tsx
1114
+ * // Uncontrolled / FormData:
1115
+ * <form onSubmit={handleRegister}>
1116
+ * <RegisterHoneypot />
1117
+ * <input name="email" type="email" />
1118
+ * <input name="password" type="password" />
1119
+ * <button type="submit">Sign Up</button>
1120
+ * </form>
1121
+ *
1122
+ * // Controlled with useHoneypot:
1123
+ * const { honeypotProps, honeypotPayload } = useHoneypot()
1124
+ * ...
1125
+ * await register({ email, password, ...honeypotPayload })
1126
+ * ```
1127
+ */
1128
+ declare function RegisterHoneypot({ name, value, onChange, id, className, label, }: RegisterHoneypotProps): react_jsx_runtime.JSX.Element;
1129
+ interface UseHoneypotReturn {
1130
+ value: string;
1131
+ setValue: React__default.Dispatch<React__default.SetStateAction<string>>;
1132
+ honeypotProps: {
1133
+ name: HoneypotFieldName | string;
1134
+ value: string;
1135
+ onChange: (e: React__default.ChangeEvent<HTMLInputElement>) => void;
1136
+ };
1137
+ /** Object with { [name]: value } ready to spread into register() */
1138
+ honeypotPayload: Record<string, string>;
1139
+ reset: () => void;
1140
+ }
1141
+ /**
1142
+ * Hook to manage controlled honeypot state for React registration forms.
1143
+ *
1144
+ * @param defaultField The honeypot field name (defaults to 'website')
1145
+ */
1146
+ declare function useHoneypot(defaultField?: HoneypotFieldName | string): UseHoneypotReturn;
1147
+
1076
1148
  /**
1077
1149
  * Client-side validation helpers
1078
1150
  *
@@ -1231,4 +1303,4 @@ declare function createSafeLogger(prefix: string): {
1231
1303
  error: (message: string, data?: unknown) => void;
1232
1304
  };
1233
1305
 
1234
- export { ApiError$1 as ApiError, type AudioFile, type AudioUploadResult, type ConversationKind, type FeatureFlagEvaluation, type FeatureFlagEvaluation as FeatureFlagResult, type FeedbackItem, type FeedbackItemInput, type FeedbackPriority, type FeedbackStatus, type FeedbackType, FeedbackWidget, type FeedbackWidgetConfig, type FeedbackWidgetProps, ListFilesParams, LoginResponse, type MediaPolicy, type MediaUploadResult, NarrationPlayer, type NarrationPlayerAudio, type NarrationPlayerProps, type PasswordValidationResult, type PhoneCountry, type PhoneValidationResult, type RealtimeEvent, type RealtimeMessage, type RealtimeStatus, ScaleMuleClient, ScaleMuleConfig, ScaleMuleMedia, type ScaleMuleMediaProps, ScaleMuleProvider, type ScaleMuleProviderProps, type SecurityChallenge, type SecurityChallengePrompt, UseAnalyticsOptions, UseAnalyticsReturn, type UseAudioReturn, type UseAudioUploadOptions, UseAuthReturn, UseBillingReturn, UseContentReturn, type UseFeatureFlagsOptions, type UseFeatureFlagsReturn, type UseFeedbackOptions, type UseFeedbackResult, type UseFileStatusOptions, type UseFileStatusReturn, type UseFeatureFlagsOptions as UseFlagsOptions, type UseFeatureFlagsReturn as UseFlagsReturn, type UseMediaReturn, type UseMediaUploadOptions, type UsePushNotificationsOptions, type UsePushNotificationsReturn, type UseRealtimeOptions, type UseRealtimeReturn, type UseShareOptions, type UseShareReturn, type UseTtsJobOptions, type UseTtsJobReturn, UseUserReturn, type UseVoteOptions, type UseVoteReturn, User, type UsernameValidationResult, VoteButton, type VoteButtonClassNames, type VoteButtonProps, type VoteState, composePhone, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAudio, useAuth, useBilling, useContent, useFeatureFlags, useFeedback, useFileStatus, useMedia, useMoney, useMoneyClient, usePushNotifications, useRealtime, useScaleMule, useScaleMuleClient, useShare, useTtsJob, useUser, useVote, validateForm, validators };
1306
+ export { ApiError$1 as ApiError, type AudioFile, type AudioUploadResult, type ConversationKind, type FeatureFlagEvaluation, type FeatureFlagEvaluation as FeatureFlagResult, type FeedbackItem, type FeedbackItemInput, type FeedbackPriority, type FeedbackStatus, type FeedbackType, FeedbackWidget, type FeedbackWidgetConfig, type FeedbackWidgetProps, type HoneypotFieldName, ListFilesParams, LoginResponse, type MediaPolicy, type MediaUploadResult, NarrationPlayer, type NarrationPlayerAudio, type NarrationPlayerProps, type PasswordValidationResult, type PhoneCountry, type PhoneValidationResult, type RealtimeEvent, type RealtimeMessage, type RealtimeStatus, RegisterHoneypot, type RegisterHoneypotProps, ScaleMuleClient, ScaleMuleConfig, ScaleMuleMedia, type ScaleMuleMediaProps, ScaleMuleProvider, type ScaleMuleProviderProps, type SecurityChallenge, type SecurityChallengePrompt, UseAnalyticsOptions, UseAnalyticsReturn, type UseAudioReturn, type UseAudioUploadOptions, UseAuthReturn, UseBillingReturn, UseContentReturn, type UseFeatureFlagsOptions, type UseFeatureFlagsReturn, type UseFeedbackOptions, type UseFeedbackResult, type UseFileStatusOptions, type UseFileStatusReturn, type UseFeatureFlagsOptions as UseFlagsOptions, type UseFeatureFlagsReturn as UseFlagsReturn, type UseHoneypotReturn, type UseMediaReturn, type UseMediaUploadOptions, type UsePushNotificationsOptions, type UsePushNotificationsReturn, type UseRealtimeOptions, type UseRealtimeReturn, type UseShareOptions, type UseShareReturn, type UseTtsJobOptions, type UseTtsJobReturn, UseUserReturn, type UseVoteOptions, type UseVoteReturn, User, type UsernameValidationResult, VoteButton, type VoteButtonClassNames, type VoteButtonProps, type VoteState, composePhone, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAudio, useAuth, useBilling, useContent, useFeatureFlags, useFeedback, useFileStatus, useHoneypot, useMedia, useMoney, useMoneyClient, usePushNotifications, useRealtime, useScaleMule, useScaleMuleClient, useShare, useTtsJob, useUser, useVote, validateForm, validators };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ApiError, RealtimeService, StorageService, PhotoService, VideoService, AudioService, TtsService, SocialService, SocialPolicyService, TtsJobStatus, TtsAudioInfo, FileStatus } from '@scalemule/sdk';
3
3
  import * as React from 'react';
4
- import { ReactNode, ReactElement } from 'react';
4
+ import React__default, { ReactNode, ReactElement } from 'react';
5
5
  import { MoneyClient } from '@scalemule/money';
6
6
  export { MoneyClient, MoneyClientConfig, createMoneyClient } from '@scalemule/money';
7
7
  import { ScaleMuleClient } from './client.js';
8
8
  export { ClientConfig, RequestOptions, createClient } from './client.js';
9
- import { S as ScaleMuleConfig, U as User, L as LoginResponse, A as ApiError$1, a as UseAuthReturn, b as UseBillingReturn, c as ListFilesParams, d as UseContentReturn, e as UseUserReturn, f as UseAnalyticsOptions, g as UseAnalyticsReturn } from './index-2PnO4RAF.js';
10
- export { h as AccountBalance, i as AnalyticsEvent, j as ApiResponse, k as AuthLoginResponse, B as BatchTrackRequest, l as BillingPayment, m as BillingPayout, n as BillingRefund, o as BillingTransaction, C as ChangeEmailRequest, p as ChangePasswordRequest, q as ClientContext, r as ConnectedAccount, s as CookieLoginResponse, t as CookieOAuthCallbackResponse, D as DeviceFingerprint, u as DeviceInfo, E as EnhancedAnalyticsEvent, F as ForgotPasswordRequest, K as KnownAccountInfo, v as LinkedAccount, w as ListFilesResponse, x as LoginDeviceInfo, y as LoginRequest, z as LoginResponseWithMFA, G as LoginRiskInfo, M as MFAChallengeResponse, H as MFAMethod, I as MFASMSSetupResponse, J as MFASetupRequest, N as MFAStatus, O as MFATOTPSetupResponse, P as MFAVerifyRequest, Q as OAuthCallbackRequest, R as OAuthCallbackResponse, T as OAuthConfig, V as OAuthProvider, W as OAuthStartResponse, X as PageViewData, Y as PayoutSchedule, Z as PhoneLoginRequest, _ as PhoneSendCodeRequest, $ as PhoneVerifyRequest, a0 as Profile, a1 as ProxyBearerLoginResponse, a2 as RefreshResponse, a3 as RegisterRequest, a4 as ResetPasswordRequest, a5 as ScaleMuleApiError, a6 as ScaleMuleEnvironment, a7 as Session, a8 as SignedUploadCompleteRequest, a9 as SignedUploadRequest, aa as SignedUploadResponse, ab as SignedUploadUrl, ac as StorageAdapter, ad as StorageFile, ae as TrackEventResponse, af as TransactionSummary, ag as UTMParams, ah as UpdateProfileRequest, ai as UploadOptions, aj as UploadResponse, ak as VerifyEmailRequest } from './index-2PnO4RAF.js';
9
+ import { S as ScaleMuleConfig, U as User, L as LoginResponse, A as ApiError$1, a as UseAuthReturn, b as UseBillingReturn, c as ListFilesParams, d as UseContentReturn, e as UseUserReturn, f as UseAnalyticsOptions, g as UseAnalyticsReturn } from './index-CEi5Nd4L.js';
10
+ export { h as AccountBalance, i as AnalyticsEvent, j as ApiResponse, k as AuthLoginResponse, B as BatchTrackRequest, l as BillingPayment, m as BillingPayout, n as BillingRefund, o as BillingTransaction, C as ChangeEmailRequest, p as ChangePasswordRequest, q as ClientContext, r as ConnectedAccount, s as CookieLoginResponse, t as CookieOAuthCallbackResponse, D as DeviceFingerprint, u as DeviceInfo, E as EnhancedAnalyticsEvent, F as ForgotPasswordRequest, K as KnownAccountInfo, v as LinkedAccount, w as ListFilesResponse, x as LoginDeviceInfo, y as LoginRequest, z as LoginResponseWithMFA, G as LoginRiskInfo, M as MFAChallengeResponse, H as MFAMethod, I as MFASMSSetupResponse, J as MFASetupRequest, N as MFAStatus, O as MFATOTPSetupResponse, P as MFAVerifyRequest, Q as OAuthCallbackRequest, R as OAuthCallbackResponse, T as OAuthConfig, V as OAuthProvider, W as OAuthStartResponse, X as PageViewData, Y as PayoutSchedule, Z as PhoneLoginRequest, _ as PhoneSendCodeRequest, $ as PhoneVerifyRequest, a0 as Profile, a1 as ProxyBearerLoginResponse, a2 as RefreshResponse, a3 as RegisterRequest, a4 as ResetPasswordRequest, a5 as ScaleMuleApiError, a6 as ScaleMuleEnvironment, a7 as Session, a8 as SignedUploadCompleteRequest, a9 as SignedUploadRequest, aa as SignedUploadResponse, ab as SignedUploadUrl, ac as StorageAdapter, ad as StorageFile, ae as TrackEventResponse, af as TransactionSummary, ag as UTMParams, ah as UpdateProfileRequest, ai as UploadOptions, aj as UploadResponse, ak as VerifyEmailRequest } from './index-CEi5Nd4L.js';
11
11
 
12
12
  /**
13
13
  * Tri-state file visibility — `'private' | 'app_public' | 'anonymous_visible'`.
@@ -1073,6 +1073,78 @@ interface VoteButtonProps {
1073
1073
  }
1074
1074
  declare function VoteButton({ targetType, targetId, initialState, layout, size, onSignInRequired, onError, classNames, upLabel, downLabel, }: VoteButtonProps): react_jsx_runtime.JSX.Element;
1075
1075
 
1076
+ type HoneypotFieldName = 'website' | 'company' | 'publication_code' | 'hp_field';
1077
+ interface RegisterHoneypotProps {
1078
+ /**
1079
+ * Field name recognized by ScaleMule honeypot defenses.
1080
+ * Defaults to 'website'.
1081
+ */
1082
+ name?: HoneypotFieldName | string;
1083
+ /**
1084
+ * Controlled value if managing state in React.
1085
+ */
1086
+ value?: string;
1087
+ /**
1088
+ * Change handler for controlled state.
1089
+ */
1090
+ onChange?: (e: React__default.ChangeEvent<HTMLInputElement>) => void;
1091
+ /**
1092
+ * Optional custom id for the hidden input.
1093
+ */
1094
+ id?: string;
1095
+ /**
1096
+ * Optional additional className (field is styled off-screen regardless).
1097
+ */
1098
+ className?: string;
1099
+ /**
1100
+ * Optional custom accessible label text.
1101
+ */
1102
+ label?: string;
1103
+ }
1104
+ /**
1105
+ * RegisterHoneypot — invisible honeypot input component for registration forms.
1106
+ *
1107
+ * Traps automated spam bots that blindly fill every visible and invisible input field.
1108
+ * When submitted with any non-empty value, ScaleMule auth silently absorbs and drops
1109
+ * the registration attempt with a synthetic 201/200 success response, preventing AWS SES
1110
+ * hard bounces, dirty accounts, and email verification spam.
1111
+ *
1112
+ * @example
1113
+ * ```tsx
1114
+ * // Uncontrolled / FormData:
1115
+ * <form onSubmit={handleRegister}>
1116
+ * <RegisterHoneypot />
1117
+ * <input name="email" type="email" />
1118
+ * <input name="password" type="password" />
1119
+ * <button type="submit">Sign Up</button>
1120
+ * </form>
1121
+ *
1122
+ * // Controlled with useHoneypot:
1123
+ * const { honeypotProps, honeypotPayload } = useHoneypot()
1124
+ * ...
1125
+ * await register({ email, password, ...honeypotPayload })
1126
+ * ```
1127
+ */
1128
+ declare function RegisterHoneypot({ name, value, onChange, id, className, label, }: RegisterHoneypotProps): react_jsx_runtime.JSX.Element;
1129
+ interface UseHoneypotReturn {
1130
+ value: string;
1131
+ setValue: React__default.Dispatch<React__default.SetStateAction<string>>;
1132
+ honeypotProps: {
1133
+ name: HoneypotFieldName | string;
1134
+ value: string;
1135
+ onChange: (e: React__default.ChangeEvent<HTMLInputElement>) => void;
1136
+ };
1137
+ /** Object with { [name]: value } ready to spread into register() */
1138
+ honeypotPayload: Record<string, string>;
1139
+ reset: () => void;
1140
+ }
1141
+ /**
1142
+ * Hook to manage controlled honeypot state for React registration forms.
1143
+ *
1144
+ * @param defaultField The honeypot field name (defaults to 'website')
1145
+ */
1146
+ declare function useHoneypot(defaultField?: HoneypotFieldName | string): UseHoneypotReturn;
1147
+
1076
1148
  /**
1077
1149
  * Client-side validation helpers
1078
1150
  *
@@ -1231,4 +1303,4 @@ declare function createSafeLogger(prefix: string): {
1231
1303
  error: (message: string, data?: unknown) => void;
1232
1304
  };
1233
1305
 
1234
- export { ApiError$1 as ApiError, type AudioFile, type AudioUploadResult, type ConversationKind, type FeatureFlagEvaluation, type FeatureFlagEvaluation as FeatureFlagResult, type FeedbackItem, type FeedbackItemInput, type FeedbackPriority, type FeedbackStatus, type FeedbackType, FeedbackWidget, type FeedbackWidgetConfig, type FeedbackWidgetProps, ListFilesParams, LoginResponse, type MediaPolicy, type MediaUploadResult, NarrationPlayer, type NarrationPlayerAudio, type NarrationPlayerProps, type PasswordValidationResult, type PhoneCountry, type PhoneValidationResult, type RealtimeEvent, type RealtimeMessage, type RealtimeStatus, ScaleMuleClient, ScaleMuleConfig, ScaleMuleMedia, type ScaleMuleMediaProps, ScaleMuleProvider, type ScaleMuleProviderProps, type SecurityChallenge, type SecurityChallengePrompt, UseAnalyticsOptions, UseAnalyticsReturn, type UseAudioReturn, type UseAudioUploadOptions, UseAuthReturn, UseBillingReturn, UseContentReturn, type UseFeatureFlagsOptions, type UseFeatureFlagsReturn, type UseFeedbackOptions, type UseFeedbackResult, type UseFileStatusOptions, type UseFileStatusReturn, type UseFeatureFlagsOptions as UseFlagsOptions, type UseFeatureFlagsReturn as UseFlagsReturn, type UseMediaReturn, type UseMediaUploadOptions, type UsePushNotificationsOptions, type UsePushNotificationsReturn, type UseRealtimeOptions, type UseRealtimeReturn, type UseShareOptions, type UseShareReturn, type UseTtsJobOptions, type UseTtsJobReturn, UseUserReturn, type UseVoteOptions, type UseVoteReturn, User, type UsernameValidationResult, VoteButton, type VoteButtonClassNames, type VoteButtonProps, type VoteState, composePhone, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAudio, useAuth, useBilling, useContent, useFeatureFlags, useFeedback, useFileStatus, useMedia, useMoney, useMoneyClient, usePushNotifications, useRealtime, useScaleMule, useScaleMuleClient, useShare, useTtsJob, useUser, useVote, validateForm, validators };
1306
+ export { ApiError$1 as ApiError, type AudioFile, type AudioUploadResult, type ConversationKind, type FeatureFlagEvaluation, type FeatureFlagEvaluation as FeatureFlagResult, type FeedbackItem, type FeedbackItemInput, type FeedbackPriority, type FeedbackStatus, type FeedbackType, FeedbackWidget, type FeedbackWidgetConfig, type FeedbackWidgetProps, type HoneypotFieldName, ListFilesParams, LoginResponse, type MediaPolicy, type MediaUploadResult, NarrationPlayer, type NarrationPlayerAudio, type NarrationPlayerProps, type PasswordValidationResult, type PhoneCountry, type PhoneValidationResult, type RealtimeEvent, type RealtimeMessage, type RealtimeStatus, RegisterHoneypot, type RegisterHoneypotProps, ScaleMuleClient, ScaleMuleConfig, ScaleMuleMedia, type ScaleMuleMediaProps, ScaleMuleProvider, type ScaleMuleProviderProps, type SecurityChallenge, type SecurityChallengePrompt, UseAnalyticsOptions, UseAnalyticsReturn, type UseAudioReturn, type UseAudioUploadOptions, UseAuthReturn, UseBillingReturn, UseContentReturn, type UseFeatureFlagsOptions, type UseFeatureFlagsReturn, type UseFeedbackOptions, type UseFeedbackResult, type UseFileStatusOptions, type UseFileStatusReturn, type UseFeatureFlagsOptions as UseFlagsOptions, type UseFeatureFlagsReturn as UseFlagsReturn, type UseHoneypotReturn, type UseMediaReturn, type UseMediaUploadOptions, type UsePushNotificationsOptions, type UsePushNotificationsReturn, type UseRealtimeOptions, type UseRealtimeReturn, type UseShareOptions, type UseShareReturn, type UseTtsJobOptions, type UseTtsJobReturn, UseUserReturn, type UseVoteOptions, type UseVoteReturn, User, type UsernameValidationResult, VoteButton, type VoteButtonClassNames, type VoteButtonProps, type VoteState, composePhone, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAudio, useAuth, useBilling, useContent, useFeatureFlags, useFeedback, useFileStatus, useHoneypot, useMedia, useMoney, useMoneyClient, usePushNotifications, useRealtime, useScaleMule, useScaleMuleClient, useShare, useTtsJob, useUser, useVote, validateForm, validators };
package/dist/index.js CHANGED
@@ -1479,6 +1479,26 @@ function useMoneyClient() {
1479
1479
  const { money } = useScaleMule();
1480
1480
  return money;
1481
1481
  }
1482
+
1483
+ // src/session-errors.ts
1484
+ var SESSION_ENDED_CODES = /* @__PURE__ */ new Set([
1485
+ "UNAUTHORIZED",
1486
+ "INVALID_SESSION",
1487
+ "SESSION_EXPIRED",
1488
+ "SESSION_IDLE_EXPIRED",
1489
+ "SESSION_ABSOLUTE_EXPIRED",
1490
+ "SESSION_REVOKED",
1491
+ "TOKEN_EXPIRED",
1492
+ "TOKEN_INVALID"
1493
+ ]);
1494
+ function isSessionEndedError(error) {
1495
+ if (!error || typeof error !== "object") return false;
1496
+ const { status, code } = error;
1497
+ if (status === 401) return true;
1498
+ return typeof code === "string" && SESSION_ENDED_CODES.has(code);
1499
+ }
1500
+
1501
+ // src/hooks/useAuth.ts
1482
1502
  function cookieLoginResult(user) {
1483
1503
  return { authenticated: true, userId: user.id, user };
1484
1504
  }
@@ -1853,11 +1873,13 @@ function useAuth() {
1853
1873
  "refresh"
1854
1874
  );
1855
1875
  if (!response.success) {
1856
- setUser(null);
1857
1876
  const err = response.error || {
1858
1877
  code: "REFRESH_FAILED",
1859
- message: "Session expired"
1878
+ message: "Session refresh failed"
1860
1879
  };
1880
+ if (isSessionEndedError(err)) {
1881
+ setUser(null);
1882
+ }
1861
1883
  setError(err);
1862
1884
  throw err;
1863
1885
  }
@@ -1888,8 +1910,10 @@ function useAuth() {
1888
1910
  await client.setSession(refreshData.session_token, userId);
1889
1911
  }
1890
1912
  } catch (err) {
1891
- await client.clearSession();
1892
- setUser(null);
1913
+ if (isSessionEndedError(err)) {
1914
+ await client.clearSession();
1915
+ setUser(null);
1916
+ }
1893
1917
  if (err instanceof ScaleMuleApiError) {
1894
1918
  setError(err);
1895
1919
  }
@@ -5558,6 +5582,77 @@ function VoteButton({
5558
5582
  downBtn
5559
5583
  ] });
5560
5584
  }
5585
+ var OFFSCREEN_STYLE = {
5586
+ position: "absolute",
5587
+ left: "-9999px",
5588
+ top: "-9999px",
5589
+ opacity: 0,
5590
+ pointerEvents: "none",
5591
+ width: 0,
5592
+ height: 0,
5593
+ overflow: "hidden",
5594
+ clip: "rect(0, 0, 0, 0)",
5595
+ clipPath: "inset(50%)",
5596
+ border: 0,
5597
+ padding: 0,
5598
+ margin: 0,
5599
+ whiteSpace: "nowrap"
5600
+ };
5601
+ function RegisterHoneypot({
5602
+ name = "website",
5603
+ value,
5604
+ onChange,
5605
+ id,
5606
+ className,
5607
+ label = "Leave this field empty"
5608
+ }) {
5609
+ const inputId = id || `sm_hp_${name}`;
5610
+ return /* @__PURE__ */ jsxRuntime.jsxs(
5611
+ "div",
5612
+ {
5613
+ "aria-hidden": "true",
5614
+ style: OFFSCREEN_STYLE,
5615
+ tabIndex: -1,
5616
+ "data-testid": "sm-register-honeypot",
5617
+ children: [
5618
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: inputId, children: label }),
5619
+ /* @__PURE__ */ jsxRuntime.jsx(
5620
+ "input",
5621
+ {
5622
+ type: "text",
5623
+ id: inputId,
5624
+ name,
5625
+ value,
5626
+ onChange,
5627
+ tabIndex: -1,
5628
+ autoComplete: "off",
5629
+ className
5630
+ }
5631
+ )
5632
+ ]
5633
+ }
5634
+ );
5635
+ }
5636
+ function useHoneypot(defaultField = "website") {
5637
+ const [value, setValue] = React.useState("");
5638
+ const onChange = React.useCallback((e) => {
5639
+ setValue(e.target.value);
5640
+ }, []);
5641
+ const reset = React.useCallback(() => {
5642
+ setValue("");
5643
+ }, []);
5644
+ return {
5645
+ value,
5646
+ setValue,
5647
+ honeypotProps: {
5648
+ name: defaultField,
5649
+ value,
5650
+ onChange
5651
+ },
5652
+ honeypotPayload: value ? { [defaultField]: value } : {},
5653
+ reset
5654
+ };
5655
+ }
5561
5656
 
5562
5657
  // src/validation.ts
5563
5658
  var phoneCountries = [
@@ -5860,6 +5955,7 @@ Object.defineProperty(exports, "createMoneyClient", {
5860
5955
  });
5861
5956
  exports.FeedbackWidget = FeedbackWidget;
5862
5957
  exports.NarrationPlayer = NarrationPlayer;
5958
+ exports.RegisterHoneypot = RegisterHoneypot;
5863
5959
  exports.ScaleMuleApiError = ScaleMuleApiError;
5864
5960
  exports.ScaleMuleClient = ScaleMuleClient;
5865
5961
  exports.ScaleMuleMedia = ScaleMuleMedia;
@@ -5879,6 +5975,7 @@ exports.useContent = useContent;
5879
5975
  exports.useFeatureFlags = useFeatureFlags;
5880
5976
  exports.useFeedback = useFeedback;
5881
5977
  exports.useFileStatus = useFileStatus;
5978
+ exports.useHoneypot = useHoneypot;
5882
5979
  exports.useMedia = useMedia;
5883
5980
  exports.useMoney = useMoney;
5884
5981
  exports.useMoneyClient = useMoneyClient;
package/dist/index.mjs CHANGED
@@ -1459,6 +1459,26 @@ function useMoneyClient() {
1459
1459
  const { money } = useScaleMule();
1460
1460
  return money;
1461
1461
  }
1462
+
1463
+ // src/session-errors.ts
1464
+ var SESSION_ENDED_CODES = /* @__PURE__ */ new Set([
1465
+ "UNAUTHORIZED",
1466
+ "INVALID_SESSION",
1467
+ "SESSION_EXPIRED",
1468
+ "SESSION_IDLE_EXPIRED",
1469
+ "SESSION_ABSOLUTE_EXPIRED",
1470
+ "SESSION_REVOKED",
1471
+ "TOKEN_EXPIRED",
1472
+ "TOKEN_INVALID"
1473
+ ]);
1474
+ function isSessionEndedError(error) {
1475
+ if (!error || typeof error !== "object") return false;
1476
+ const { status, code } = error;
1477
+ if (status === 401) return true;
1478
+ return typeof code === "string" && SESSION_ENDED_CODES.has(code);
1479
+ }
1480
+
1481
+ // src/hooks/useAuth.ts
1462
1482
  function cookieLoginResult(user) {
1463
1483
  return { authenticated: true, userId: user.id, user };
1464
1484
  }
@@ -1833,11 +1853,13 @@ function useAuth() {
1833
1853
  "refresh"
1834
1854
  );
1835
1855
  if (!response.success) {
1836
- setUser(null);
1837
1856
  const err = response.error || {
1838
1857
  code: "REFRESH_FAILED",
1839
- message: "Session expired"
1858
+ message: "Session refresh failed"
1840
1859
  };
1860
+ if (isSessionEndedError(err)) {
1861
+ setUser(null);
1862
+ }
1841
1863
  setError(err);
1842
1864
  throw err;
1843
1865
  }
@@ -1868,8 +1890,10 @@ function useAuth() {
1868
1890
  await client.setSession(refreshData.session_token, userId);
1869
1891
  }
1870
1892
  } catch (err) {
1871
- await client.clearSession();
1872
- setUser(null);
1893
+ if (isSessionEndedError(err)) {
1894
+ await client.clearSession();
1895
+ setUser(null);
1896
+ }
1873
1897
  if (err instanceof ScaleMuleApiError) {
1874
1898
  setError(err);
1875
1899
  }
@@ -5538,6 +5562,77 @@ function VoteButton({
5538
5562
  downBtn
5539
5563
  ] });
5540
5564
  }
5565
+ var OFFSCREEN_STYLE = {
5566
+ position: "absolute",
5567
+ left: "-9999px",
5568
+ top: "-9999px",
5569
+ opacity: 0,
5570
+ pointerEvents: "none",
5571
+ width: 0,
5572
+ height: 0,
5573
+ overflow: "hidden",
5574
+ clip: "rect(0, 0, 0, 0)",
5575
+ clipPath: "inset(50%)",
5576
+ border: 0,
5577
+ padding: 0,
5578
+ margin: 0,
5579
+ whiteSpace: "nowrap"
5580
+ };
5581
+ function RegisterHoneypot({
5582
+ name = "website",
5583
+ value,
5584
+ onChange,
5585
+ id,
5586
+ className,
5587
+ label = "Leave this field empty"
5588
+ }) {
5589
+ const inputId = id || `sm_hp_${name}`;
5590
+ return /* @__PURE__ */ jsxs(
5591
+ "div",
5592
+ {
5593
+ "aria-hidden": "true",
5594
+ style: OFFSCREEN_STYLE,
5595
+ tabIndex: -1,
5596
+ "data-testid": "sm-register-honeypot",
5597
+ children: [
5598
+ /* @__PURE__ */ jsx("label", { htmlFor: inputId, children: label }),
5599
+ /* @__PURE__ */ jsx(
5600
+ "input",
5601
+ {
5602
+ type: "text",
5603
+ id: inputId,
5604
+ name,
5605
+ value,
5606
+ onChange,
5607
+ tabIndex: -1,
5608
+ autoComplete: "off",
5609
+ className
5610
+ }
5611
+ )
5612
+ ]
5613
+ }
5614
+ );
5615
+ }
5616
+ function useHoneypot(defaultField = "website") {
5617
+ const [value, setValue] = useState("");
5618
+ const onChange = useCallback((e) => {
5619
+ setValue(e.target.value);
5620
+ }, []);
5621
+ const reset = useCallback(() => {
5622
+ setValue("");
5623
+ }, []);
5624
+ return {
5625
+ value,
5626
+ setValue,
5627
+ honeypotProps: {
5628
+ name: defaultField,
5629
+ value,
5630
+ onChange
5631
+ },
5632
+ honeypotPayload: value ? { [defaultField]: value } : {},
5633
+ reset
5634
+ };
5635
+ }
5541
5636
 
5542
5637
  // src/validation.ts
5543
5638
  var phoneCountries = [
@@ -5830,4 +5925,4 @@ function createSafeLogger(prefix) {
5830
5925
  };
5831
5926
  }
5832
5927
 
5833
- export { FeedbackWidget, NarrationPlayer, ScaleMuleApiError, ScaleMuleClient, ScaleMuleMedia, ScaleMuleProvider, VoteButton, composePhone, createClient, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAudio, useAuth, useBilling, useContent, useFeatureFlags, useFeedback, useFileStatus, useMedia, useMoney, useMoneyClient, usePushNotifications, useRealtime, useScaleMule, useScaleMuleClient, useShare, useTtsJob, useUser, useVote, validateForm, validators };
5928
+ export { FeedbackWidget, NarrationPlayer, RegisterHoneypot, ScaleMuleApiError, ScaleMuleClient, ScaleMuleMedia, ScaleMuleProvider, VoteButton, composePhone, createClient, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAudio, useAuth, useBilling, useContent, useFeatureFlags, useFeedback, useFileStatus, useHoneypot, useMedia, useMoney, useMoneyClient, usePushNotifications, useRealtime, useScaleMule, useScaleMuleClient, useShare, useTtsJob, useUser, useVote, validateForm, validators };
@@ -230,6 +230,9 @@ var ScaleMuleServer = class {
230
230
  refresh: async (sessionToken, options) => {
231
231
  return this.request("POST", "/v1/auth/refresh", {
232
232
  sessionToken,
233
+ // The auth service reads the token to rotate from the body, not the
234
+ // Authorization header; without it every refresh is rejected.
235
+ body: { session_token: sessionToken },
233
236
  clientContext: options?.clientContext,
234
237
  isAutoRefresh: options?.isAutoRefresh,
235
238
  onTokenRotated: options?.onTokenRotated
@@ -869,12 +872,12 @@ var ScaleMuleServer = class {
869
872
  if (this.debug) console.error("[ScaleMule Server] Auto-refresh failed:", refreshErr);
870
873
  const refreshApiError = refreshErr instanceof ScaleMuleApiError ? { code: refreshErr.code, message: refreshErr.message } : { code: "REFRESH_FAILED", message: "Auto-refresh failed" };
871
874
  this.onAutoRefreshFailed?.(refreshApiError);
872
- throw new ScaleMuleApiError(error2);
875
+ throw new ScaleMuleApiError(error2, response.status);
873
876
  } finally {
874
877
  this.onRefreshEnd?.();
875
878
  }
876
879
  }
877
- throw new ScaleMuleApiError(error2);
880
+ throw new ScaleMuleApiError(error2, response.status);
878
881
  }
879
882
  const data = responseData?.data !== void 0 ? responseData.data : responseData;
880
883
  return data;
@@ -981,13 +984,25 @@ function withRefreshedSession(sessionToken, userId, responseBody, options = {})
981
984
  function clearSession(responseBody, options = {}, status = 200) {
982
985
  const headers2 = new Headers();
983
986
  headers2.set("Content-Type", "application/json");
987
+ appendClearSessionCookies(headers2, options);
988
+ return new Response(JSON.stringify({ success: status < 300, data: responseBody }), {
989
+ status,
990
+ headers: headers2
991
+ });
992
+ }
993
+ function appendClearSessionCookies(headers2, options) {
984
994
  if (options.partitioned) {
985
995
  headers2.append("Set-Cookie", createClearCookieHeader(SESSION_COOKIE_NAME, { ...options, partitioned: false }));
986
996
  headers2.append("Set-Cookie", createClearCookieHeader(USER_ID_COOKIE_NAME, { ...options, partitioned: false }));
987
997
  }
988
998
  headers2.append("Set-Cookie", createClearCookieHeader(SESSION_COOKIE_NAME, options));
989
999
  headers2.append("Set-Cookie", createClearCookieHeader(USER_ID_COOKIE_NAME, options));
990
- return new Response(JSON.stringify({ success: status < 300, data: responseBody }), {
1000
+ }
1001
+ function clearSessionWithError(error2, options = {}, status = 401) {
1002
+ const headers2 = new Headers();
1003
+ headers2.set("Content-Type", "application/json");
1004
+ appendClearSessionCookies(headers2, options);
1005
+ return new Response(JSON.stringify({ success: false, error: error2 }), {
991
1006
  status,
992
1007
  headers: headers2
993
1008
  });
@@ -1343,6 +1358,24 @@ async function browserProxy(request, path, config) {
1343
1358
  }
1344
1359
  }
1345
1360
 
1361
+ // src/session-errors.ts
1362
+ var SESSION_ENDED_CODES = /* @__PURE__ */ new Set([
1363
+ "UNAUTHORIZED",
1364
+ "INVALID_SESSION",
1365
+ "SESSION_EXPIRED",
1366
+ "SESSION_IDLE_EXPIRED",
1367
+ "SESSION_ABSOLUTE_EXPIRED",
1368
+ "SESSION_REVOKED",
1369
+ "TOKEN_EXPIRED",
1370
+ "TOKEN_INVALID"
1371
+ ]);
1372
+ function isSessionEndedError(error2) {
1373
+ if (!error2 || typeof error2 !== "object") return false;
1374
+ const { status, code } = error2;
1375
+ if (status === 401) return true;
1376
+ return typeof code === "string" && SESSION_ENDED_CODES.has(code);
1377
+ }
1378
+
1346
1379
  // src/server/routes.ts
1347
1380
  function errorResponse(code, message, status) {
1348
1381
  return new Response(
@@ -1380,10 +1413,24 @@ function createAuthRoutes(config = {}) {
1380
1413
  switch (path) {
1381
1414
  // ==================== Register ====================
1382
1415
  case "register": {
1383
- const { email, password, full_name, username, phone } = body;
1416
+ const { email, password, full_name, username, phone, publication_code, website, company, hp_field } = body;
1384
1417
  if (!email || !password) {
1385
1418
  return errorResponse("VALIDATION_ERROR", "Email and password required", 400);
1386
1419
  }
1420
+ const honeypotVal = publication_code || website || company || hp_field;
1421
+ if (typeof honeypotVal === "string" && honeypotVal.trim().length > 0) {
1422
+ return successResponse(
1423
+ {
1424
+ user: {
1425
+ id: "01000000-0000-7000-8000-000000000000",
1426
+ email,
1427
+ full_name: full_name ?? null
1428
+ },
1429
+ message: "Registration successful"
1430
+ },
1431
+ 201
1432
+ );
1433
+ }
1387
1434
  let registeredUser;
1388
1435
  try {
1389
1436
  registeredUser = await sm.auth.register({ email, password, full_name, username, phone }, { clientContext });
@@ -1631,11 +1678,18 @@ function createAuthRoutes(config = {}) {
1631
1678
  let refreshData;
1632
1679
  try {
1633
1680
  refreshData = await sm.auth.refresh(session.sessionToken);
1634
- } catch {
1635
- return clearSession(
1636
- { message: "Session expired" },
1637
- cookieOptions,
1638
- 401
1681
+ } catch (err) {
1682
+ const apiErr = err instanceof ScaleMuleApiError ? err : null;
1683
+ if (isSessionEndedError(apiErr)) {
1684
+ return clearSessionWithError(
1685
+ { code: apiErr?.code || "SESSION_EXPIRED", message: apiErr?.message || "Session expired" },
1686
+ cookieOptions
1687
+ );
1688
+ }
1689
+ return errorResponse(
1690
+ apiErr?.code || "REFRESH_FAILED",
1691
+ apiErr?.message || "Session refresh failed",
1692
+ apiErr?.status && apiErr.status >= 400 ? apiErr.status : 503
1639
1693
  );
1640
1694
  }
1641
1695
  return withRefreshedSession(
@@ -228,6 +228,9 @@ var ScaleMuleServer = class {
228
228
  refresh: async (sessionToken, options) => {
229
229
  return this.request("POST", "/v1/auth/refresh", {
230
230
  sessionToken,
231
+ // The auth service reads the token to rotate from the body, not the
232
+ // Authorization header; without it every refresh is rejected.
233
+ body: { session_token: sessionToken },
231
234
  clientContext: options?.clientContext,
232
235
  isAutoRefresh: options?.isAutoRefresh,
233
236
  onTokenRotated: options?.onTokenRotated
@@ -867,12 +870,12 @@ var ScaleMuleServer = class {
867
870
  if (this.debug) console.error("[ScaleMule Server] Auto-refresh failed:", refreshErr);
868
871
  const refreshApiError = refreshErr instanceof ScaleMuleApiError ? { code: refreshErr.code, message: refreshErr.message } : { code: "REFRESH_FAILED", message: "Auto-refresh failed" };
869
872
  this.onAutoRefreshFailed?.(refreshApiError);
870
- throw new ScaleMuleApiError(error2);
873
+ throw new ScaleMuleApiError(error2, response.status);
871
874
  } finally {
872
875
  this.onRefreshEnd?.();
873
876
  }
874
877
  }
875
- throw new ScaleMuleApiError(error2);
878
+ throw new ScaleMuleApiError(error2, response.status);
876
879
  }
877
880
  const data = responseData?.data !== void 0 ? responseData.data : responseData;
878
881
  return data;
@@ -979,13 +982,25 @@ function withRefreshedSession(sessionToken, userId, responseBody, options = {})
979
982
  function clearSession(responseBody, options = {}, status = 200) {
980
983
  const headers2 = new Headers();
981
984
  headers2.set("Content-Type", "application/json");
985
+ appendClearSessionCookies(headers2, options);
986
+ return new Response(JSON.stringify({ success: status < 300, data: responseBody }), {
987
+ status,
988
+ headers: headers2
989
+ });
990
+ }
991
+ function appendClearSessionCookies(headers2, options) {
982
992
  if (options.partitioned) {
983
993
  headers2.append("Set-Cookie", createClearCookieHeader(SESSION_COOKIE_NAME, { ...options, partitioned: false }));
984
994
  headers2.append("Set-Cookie", createClearCookieHeader(USER_ID_COOKIE_NAME, { ...options, partitioned: false }));
985
995
  }
986
996
  headers2.append("Set-Cookie", createClearCookieHeader(SESSION_COOKIE_NAME, options));
987
997
  headers2.append("Set-Cookie", createClearCookieHeader(USER_ID_COOKIE_NAME, options));
988
- return new Response(JSON.stringify({ success: status < 300, data: responseBody }), {
998
+ }
999
+ function clearSessionWithError(error2, options = {}, status = 401) {
1000
+ const headers2 = new Headers();
1001
+ headers2.set("Content-Type", "application/json");
1002
+ appendClearSessionCookies(headers2, options);
1003
+ return new Response(JSON.stringify({ success: false, error: error2 }), {
989
1004
  status,
990
1005
  headers: headers2
991
1006
  });
@@ -1341,6 +1356,24 @@ async function browserProxy(request, path, config) {
1341
1356
  }
1342
1357
  }
1343
1358
 
1359
+ // src/session-errors.ts
1360
+ var SESSION_ENDED_CODES = /* @__PURE__ */ new Set([
1361
+ "UNAUTHORIZED",
1362
+ "INVALID_SESSION",
1363
+ "SESSION_EXPIRED",
1364
+ "SESSION_IDLE_EXPIRED",
1365
+ "SESSION_ABSOLUTE_EXPIRED",
1366
+ "SESSION_REVOKED",
1367
+ "TOKEN_EXPIRED",
1368
+ "TOKEN_INVALID"
1369
+ ]);
1370
+ function isSessionEndedError(error2) {
1371
+ if (!error2 || typeof error2 !== "object") return false;
1372
+ const { status, code } = error2;
1373
+ if (status === 401) return true;
1374
+ return typeof code === "string" && SESSION_ENDED_CODES.has(code);
1375
+ }
1376
+
1344
1377
  // src/server/routes.ts
1345
1378
  function errorResponse(code, message, status) {
1346
1379
  return new Response(
@@ -1378,10 +1411,24 @@ function createAuthRoutes(config = {}) {
1378
1411
  switch (path) {
1379
1412
  // ==================== Register ====================
1380
1413
  case "register": {
1381
- const { email, password, full_name, username, phone } = body;
1414
+ const { email, password, full_name, username, phone, publication_code, website, company, hp_field } = body;
1382
1415
  if (!email || !password) {
1383
1416
  return errorResponse("VALIDATION_ERROR", "Email and password required", 400);
1384
1417
  }
1418
+ const honeypotVal = publication_code || website || company || hp_field;
1419
+ if (typeof honeypotVal === "string" && honeypotVal.trim().length > 0) {
1420
+ return successResponse(
1421
+ {
1422
+ user: {
1423
+ id: "01000000-0000-7000-8000-000000000000",
1424
+ email,
1425
+ full_name: full_name ?? null
1426
+ },
1427
+ message: "Registration successful"
1428
+ },
1429
+ 201
1430
+ );
1431
+ }
1385
1432
  let registeredUser;
1386
1433
  try {
1387
1434
  registeredUser = await sm.auth.register({ email, password, full_name, username, phone }, { clientContext });
@@ -1629,11 +1676,18 @@ function createAuthRoutes(config = {}) {
1629
1676
  let refreshData;
1630
1677
  try {
1631
1678
  refreshData = await sm.auth.refresh(session.sessionToken);
1632
- } catch {
1633
- return clearSession(
1634
- { message: "Session expired" },
1635
- cookieOptions,
1636
- 401
1679
+ } catch (err) {
1680
+ const apiErr = err instanceof ScaleMuleApiError ? err : null;
1681
+ if (isSessionEndedError(apiErr)) {
1682
+ return clearSessionWithError(
1683
+ { code: apiErr?.code || "SESSION_EXPIRED", message: apiErr?.message || "Session expired" },
1684
+ cookieOptions
1685
+ );
1686
+ }
1687
+ return errorResponse(
1688
+ apiErr?.code || "REFRESH_FAILED",
1689
+ apiErr?.message || "Session refresh failed",
1690
+ apiErr?.status && apiErr.status >= 400 ? apiErr.status : 503
1637
1691
  );
1638
1692
  }
1639
1693
  return withRefreshedSession(
@@ -1,6 +1,6 @@
1
- import { S as ServerConfig } from '../webhook-handler-DNpCXDDA.mjs';
2
- export { a as ScaleMuleServer, V as VideoFailedEvent, b as VideoReadyEvent, c as VideoTranscodedEvent, d as VideoUploadedEvent, W as WebhookEvent, e as WebhookRoutesConfig, f as createServerClient, g as createWebhookHandler, h as createWebhookRoutes, p as parseWebhookEvent, r as registerVideoWebhook, i as resolveGatewayUrl, v as verifyWebhookSignature } from '../webhook-handler-DNpCXDDA.mjs';
3
- import { q as ClientContext, A as ApiError } from '../index-2PnO4RAF.mjs';
1
+ import { S as ServerConfig } from '../webhook-handler-D--VG8bN.mjs';
2
+ export { a as ScaleMuleServer, V as VideoFailedEvent, b as VideoReadyEvent, c as VideoTranscodedEvent, d as VideoUploadedEvent, W as WebhookEvent, e as WebhookRoutesConfig, f as createServerClient, g as createWebhookHandler, h as createWebhookRoutes, p as parseWebhookEvent, r as registerVideoWebhook, i as resolveGatewayUrl, v as verifyWebhookSignature } from '../webhook-handler-D--VG8bN.mjs';
3
+ import { q as ClientContext, A as ApiError } from '../index-CEi5Nd4L.mjs';
4
4
  export { L as LedveryRoutesConfig, a as LedverySessionData, S as SM_LEDVERY_ACCESS_TOKEN_COOKIE, b as SM_LEDVERY_ID_TOKEN_COOKIE, c as SM_LEDVERY_NONCE_COOKIE, d as SM_LEDVERY_PKCE_VERIFIER_COOKIE, e as SM_LEDVERY_STATE_COOKIE, f as createLedveryRoutes, g as getLedverySession } from '../ledvery-CxPzZpxP.mjs';
5
5
  import { NextRequest, NextResponse } from 'next/server';
6
6
  import '@scalemule/money';
@@ -1,6 +1,6 @@
1
- import { S as ServerConfig } from '../webhook-handler-1nnrmWT0.js';
2
- export { a as ScaleMuleServer, V as VideoFailedEvent, b as VideoReadyEvent, c as VideoTranscodedEvent, d as VideoUploadedEvent, W as WebhookEvent, e as WebhookRoutesConfig, f as createServerClient, g as createWebhookHandler, h as createWebhookRoutes, p as parseWebhookEvent, r as registerVideoWebhook, i as resolveGatewayUrl, v as verifyWebhookSignature } from '../webhook-handler-1nnrmWT0.js';
3
- import { q as ClientContext, A as ApiError } from '../index-2PnO4RAF.js';
1
+ import { S as ServerConfig } from '../webhook-handler-B2GL4SDl.js';
2
+ export { a as ScaleMuleServer, V as VideoFailedEvent, b as VideoReadyEvent, c as VideoTranscodedEvent, d as VideoUploadedEvent, W as WebhookEvent, e as WebhookRoutesConfig, f as createServerClient, g as createWebhookHandler, h as createWebhookRoutes, p as parseWebhookEvent, r as registerVideoWebhook, i as resolveGatewayUrl, v as verifyWebhookSignature } from '../webhook-handler-B2GL4SDl.js';
3
+ import { q as ClientContext, A as ApiError } from '../index-CEi5Nd4L.js';
4
4
  export { L as LedveryRoutesConfig, a as LedverySessionData, S as SM_LEDVERY_ACCESS_TOKEN_COOKIE, b as SM_LEDVERY_ID_TOKEN_COOKIE, c as SM_LEDVERY_NONCE_COOKIE, d as SM_LEDVERY_PKCE_VERIFIER_COOKIE, e as SM_LEDVERY_STATE_COOKIE, f as createLedveryRoutes, g as getLedverySession } from '../ledvery-CxPzZpxP.js';
5
5
  import { NextRequest, NextResponse } from 'next/server';
6
6
  import '@scalemule/money';
@@ -304,6 +304,9 @@ var ScaleMuleServer = class {
304
304
  refresh: async (sessionToken, options) => {
305
305
  return this.request("POST", "/v1/auth/refresh", {
306
306
  sessionToken,
307
+ // The auth service reads the token to rotate from the body, not the
308
+ // Authorization header; without it every refresh is rejected.
309
+ body: { session_token: sessionToken },
307
310
  clientContext: options?.clientContext,
308
311
  isAutoRefresh: options?.isAutoRefresh,
309
312
  onTokenRotated: options?.onTokenRotated
@@ -943,12 +946,12 @@ var ScaleMuleServer = class {
943
946
  if (this.debug) console.error("[ScaleMule Server] Auto-refresh failed:", refreshErr);
944
947
  const refreshApiError = refreshErr instanceof ScaleMuleApiError ? { code: refreshErr.code, message: refreshErr.message } : { code: "REFRESH_FAILED", message: "Auto-refresh failed" };
945
948
  this.onAutoRefreshFailed?.(refreshApiError);
946
- throw new ScaleMuleApiError(error2);
949
+ throw new ScaleMuleApiError(error2, response.status);
947
950
  } finally {
948
951
  this.onRefreshEnd?.();
949
952
  }
950
953
  }
951
- throw new ScaleMuleApiError(error2);
954
+ throw new ScaleMuleApiError(error2, response.status);
952
955
  }
953
956
  const data = responseData?.data !== void 0 ? responseData.data : responseData;
954
957
  return data;
@@ -1055,13 +1058,25 @@ function withRefreshedSession(sessionToken, userId, responseBody, options = {})
1055
1058
  function clearSession(responseBody, options = {}, status = 200) {
1056
1059
  const headers3 = new Headers();
1057
1060
  headers3.set("Content-Type", "application/json");
1061
+ appendClearSessionCookies(headers3, options);
1062
+ return new Response(JSON.stringify({ success: status < 300, data: responseBody }), {
1063
+ status,
1064
+ headers: headers3
1065
+ });
1066
+ }
1067
+ function appendClearSessionCookies(headers3, options) {
1058
1068
  if (options.partitioned) {
1059
1069
  headers3.append("Set-Cookie", createClearCookieHeader(SESSION_COOKIE_NAME, { ...options, partitioned: false }));
1060
1070
  headers3.append("Set-Cookie", createClearCookieHeader(USER_ID_COOKIE_NAME, { ...options, partitioned: false }));
1061
1071
  }
1062
1072
  headers3.append("Set-Cookie", createClearCookieHeader(SESSION_COOKIE_NAME, options));
1063
1073
  headers3.append("Set-Cookie", createClearCookieHeader(USER_ID_COOKIE_NAME, options));
1064
- return new Response(JSON.stringify({ success: status < 300, data: responseBody }), {
1074
+ }
1075
+ function clearSessionWithError(error2, options = {}, status = 401) {
1076
+ const headers3 = new Headers();
1077
+ headers3.set("Content-Type", "application/json");
1078
+ appendClearSessionCookies(headers3, options);
1079
+ return new Response(JSON.stringify({ success: false, error: error2 }), {
1065
1080
  status,
1066
1081
  headers: headers3
1067
1082
  });
@@ -1514,6 +1529,24 @@ async function browserProxy(request, path, config) {
1514
1529
  }
1515
1530
  }
1516
1531
 
1532
+ // src/session-errors.ts
1533
+ var SESSION_ENDED_CODES = /* @__PURE__ */ new Set([
1534
+ "UNAUTHORIZED",
1535
+ "INVALID_SESSION",
1536
+ "SESSION_EXPIRED",
1537
+ "SESSION_IDLE_EXPIRED",
1538
+ "SESSION_ABSOLUTE_EXPIRED",
1539
+ "SESSION_REVOKED",
1540
+ "TOKEN_EXPIRED",
1541
+ "TOKEN_INVALID"
1542
+ ]);
1543
+ function isSessionEndedError(error2) {
1544
+ if (!error2 || typeof error2 !== "object") return false;
1545
+ const { status, code } = error2;
1546
+ if (status === 401) return true;
1547
+ return typeof code === "string" && SESSION_ENDED_CODES.has(code);
1548
+ }
1549
+
1517
1550
  // src/server/routes.ts
1518
1551
  function errorResponse(code, message, status) {
1519
1552
  return new Response(
@@ -1551,10 +1584,24 @@ function createAuthRoutes(config = {}) {
1551
1584
  switch (path) {
1552
1585
  // ==================== Register ====================
1553
1586
  case "register": {
1554
- const { email, password, full_name, username, phone } = body;
1587
+ const { email, password, full_name, username, phone, publication_code, website, company, hp_field } = body;
1555
1588
  if (!email || !password) {
1556
1589
  return errorResponse("VALIDATION_ERROR", "Email and password required", 400);
1557
1590
  }
1591
+ const honeypotVal = publication_code || website || company || hp_field;
1592
+ if (typeof honeypotVal === "string" && honeypotVal.trim().length > 0) {
1593
+ return successResponse(
1594
+ {
1595
+ user: {
1596
+ id: "01000000-0000-7000-8000-000000000000",
1597
+ email,
1598
+ full_name: full_name ?? null
1599
+ },
1600
+ message: "Registration successful"
1601
+ },
1602
+ 201
1603
+ );
1604
+ }
1558
1605
  let registeredUser;
1559
1606
  try {
1560
1607
  registeredUser = await sm.auth.register({ email, password, full_name, username, phone }, { clientContext });
@@ -1802,11 +1849,18 @@ function createAuthRoutes(config = {}) {
1802
1849
  let refreshData;
1803
1850
  try {
1804
1851
  refreshData = await sm.auth.refresh(session.sessionToken);
1805
- } catch {
1806
- return clearSession(
1807
- { message: "Session expired" },
1808
- cookieOptions,
1809
- 401
1852
+ } catch (err) {
1853
+ const apiErr = err instanceof ScaleMuleApiError ? err : null;
1854
+ if (isSessionEndedError(apiErr)) {
1855
+ return clearSessionWithError(
1856
+ { code: apiErr?.code || "SESSION_EXPIRED", message: apiErr?.message || "Session expired" },
1857
+ cookieOptions
1858
+ );
1859
+ }
1860
+ return errorResponse(
1861
+ apiErr?.code || "REFRESH_FAILED",
1862
+ apiErr?.message || "Session refresh failed",
1863
+ apiErr?.status && apiErr.status >= 400 ? apiErr.status : 503
1810
1864
  );
1811
1865
  }
1812
1866
  return withRefreshedSession(
@@ -302,6 +302,9 @@ var ScaleMuleServer = class {
302
302
  refresh: async (sessionToken, options) => {
303
303
  return this.request("POST", "/v1/auth/refresh", {
304
304
  sessionToken,
305
+ // The auth service reads the token to rotate from the body, not the
306
+ // Authorization header; without it every refresh is rejected.
307
+ body: { session_token: sessionToken },
305
308
  clientContext: options?.clientContext,
306
309
  isAutoRefresh: options?.isAutoRefresh,
307
310
  onTokenRotated: options?.onTokenRotated
@@ -941,12 +944,12 @@ var ScaleMuleServer = class {
941
944
  if (this.debug) console.error("[ScaleMule Server] Auto-refresh failed:", refreshErr);
942
945
  const refreshApiError = refreshErr instanceof ScaleMuleApiError ? { code: refreshErr.code, message: refreshErr.message } : { code: "REFRESH_FAILED", message: "Auto-refresh failed" };
943
946
  this.onAutoRefreshFailed?.(refreshApiError);
944
- throw new ScaleMuleApiError(error2);
947
+ throw new ScaleMuleApiError(error2, response.status);
945
948
  } finally {
946
949
  this.onRefreshEnd?.();
947
950
  }
948
951
  }
949
- throw new ScaleMuleApiError(error2);
952
+ throw new ScaleMuleApiError(error2, response.status);
950
953
  }
951
954
  const data = responseData?.data !== void 0 ? responseData.data : responseData;
952
955
  return data;
@@ -1053,13 +1056,25 @@ function withRefreshedSession(sessionToken, userId, responseBody, options = {})
1053
1056
  function clearSession(responseBody, options = {}, status = 200) {
1054
1057
  const headers3 = new Headers();
1055
1058
  headers3.set("Content-Type", "application/json");
1059
+ appendClearSessionCookies(headers3, options);
1060
+ return new Response(JSON.stringify({ success: status < 300, data: responseBody }), {
1061
+ status,
1062
+ headers: headers3
1063
+ });
1064
+ }
1065
+ function appendClearSessionCookies(headers3, options) {
1056
1066
  if (options.partitioned) {
1057
1067
  headers3.append("Set-Cookie", createClearCookieHeader(SESSION_COOKIE_NAME, { ...options, partitioned: false }));
1058
1068
  headers3.append("Set-Cookie", createClearCookieHeader(USER_ID_COOKIE_NAME, { ...options, partitioned: false }));
1059
1069
  }
1060
1070
  headers3.append("Set-Cookie", createClearCookieHeader(SESSION_COOKIE_NAME, options));
1061
1071
  headers3.append("Set-Cookie", createClearCookieHeader(USER_ID_COOKIE_NAME, options));
1062
- return new Response(JSON.stringify({ success: status < 300, data: responseBody }), {
1072
+ }
1073
+ function clearSessionWithError(error2, options = {}, status = 401) {
1074
+ const headers3 = new Headers();
1075
+ headers3.set("Content-Type", "application/json");
1076
+ appendClearSessionCookies(headers3, options);
1077
+ return new Response(JSON.stringify({ success: false, error: error2 }), {
1063
1078
  status,
1064
1079
  headers: headers3
1065
1080
  });
@@ -1512,6 +1527,24 @@ async function browserProxy(request, path, config) {
1512
1527
  }
1513
1528
  }
1514
1529
 
1530
+ // src/session-errors.ts
1531
+ var SESSION_ENDED_CODES = /* @__PURE__ */ new Set([
1532
+ "UNAUTHORIZED",
1533
+ "INVALID_SESSION",
1534
+ "SESSION_EXPIRED",
1535
+ "SESSION_IDLE_EXPIRED",
1536
+ "SESSION_ABSOLUTE_EXPIRED",
1537
+ "SESSION_REVOKED",
1538
+ "TOKEN_EXPIRED",
1539
+ "TOKEN_INVALID"
1540
+ ]);
1541
+ function isSessionEndedError(error2) {
1542
+ if (!error2 || typeof error2 !== "object") return false;
1543
+ const { status, code } = error2;
1544
+ if (status === 401) return true;
1545
+ return typeof code === "string" && SESSION_ENDED_CODES.has(code);
1546
+ }
1547
+
1515
1548
  // src/server/routes.ts
1516
1549
  function errorResponse(code, message, status) {
1517
1550
  return new Response(
@@ -1549,10 +1582,24 @@ function createAuthRoutes(config = {}) {
1549
1582
  switch (path) {
1550
1583
  // ==================== Register ====================
1551
1584
  case "register": {
1552
- const { email, password, full_name, username, phone } = body;
1585
+ const { email, password, full_name, username, phone, publication_code, website, company, hp_field } = body;
1553
1586
  if (!email || !password) {
1554
1587
  return errorResponse("VALIDATION_ERROR", "Email and password required", 400);
1555
1588
  }
1589
+ const honeypotVal = publication_code || website || company || hp_field;
1590
+ if (typeof honeypotVal === "string" && honeypotVal.trim().length > 0) {
1591
+ return successResponse(
1592
+ {
1593
+ user: {
1594
+ id: "01000000-0000-7000-8000-000000000000",
1595
+ email,
1596
+ full_name: full_name ?? null
1597
+ },
1598
+ message: "Registration successful"
1599
+ },
1600
+ 201
1601
+ );
1602
+ }
1556
1603
  let registeredUser;
1557
1604
  try {
1558
1605
  registeredUser = await sm.auth.register({ email, password, full_name, username, phone }, { clientContext });
@@ -1800,11 +1847,18 @@ function createAuthRoutes(config = {}) {
1800
1847
  let refreshData;
1801
1848
  try {
1802
1849
  refreshData = await sm.auth.refresh(session.sessionToken);
1803
- } catch {
1804
- return clearSession(
1805
- { message: "Session expired" },
1806
- cookieOptions,
1807
- 401
1850
+ } catch (err) {
1851
+ const apiErr = err instanceof ScaleMuleApiError ? err : null;
1852
+ if (isSessionEndedError(apiErr)) {
1853
+ return clearSessionWithError(
1854
+ { code: apiErr?.code || "SESSION_EXPIRED", message: apiErr?.message || "Session expired" },
1855
+ cookieOptions
1856
+ );
1857
+ }
1858
+ return errorResponse(
1859
+ apiErr?.code || "REFRESH_FAILED",
1860
+ apiErr?.message || "Session refresh failed",
1861
+ apiErr?.status && apiErr.status >= 400 ? apiErr.status : 503
1808
1862
  );
1809
1863
  }
1810
1864
  return withRefreshedSession(
@@ -1,3 +1,3 @@
1
- export { g as createWebhookHandler } from '../webhook-handler-DNpCXDDA.mjs';
1
+ export { g as createWebhookHandler } from '../webhook-handler-D--VG8bN.mjs';
2
2
  import '@scalemule/money';
3
- import '../index-2PnO4RAF.mjs';
3
+ import '../index-CEi5Nd4L.mjs';
@@ -1,3 +1,3 @@
1
- export { g as createWebhookHandler } from '../webhook-handler-1nnrmWT0.js';
1
+ export { g as createWebhookHandler } from '../webhook-handler-B2GL4SDl.js';
2
2
  import '@scalemule/money';
3
- import '../index-2PnO4RAF.js';
3
+ import '../index-CEi5Nd4L.js';
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
- import { U as User, A as ApiError, ad as StorageFile } from './index-2PnO4RAF.mjs';
3
+ import { U as User, A as ApiError, ad as StorageFile } from './index-CEi5Nd4L.mjs';
4
4
 
5
5
  interface MockUserOptions {
6
6
  id?: string;
package/dist/testing.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
- import { U as User, A as ApiError, ad as StorageFile } from './index-2PnO4RAF.js';
3
+ import { U as User, A as ApiError, ad as StorageFile } from './index-CEi5Nd4L.js';
4
4
 
5
5
  interface MockUserOptions {
6
6
  id?: string;
@@ -1,5 +1,5 @@
1
1
  import { MoneyClient } from '@scalemule/money';
2
- import { A as ApiError, a3 as RegisterRequest, q as ClientContext, U as User, L as LoginResponse, y as LoginRequest, c as ListFilesParams, w as ListFilesResponse, ad as StorageFile, aj as UploadResponse } from './index-2PnO4RAF.js';
2
+ import { A as ApiError, a3 as RegisterRequest, q as ClientContext, U as User, L as LoginResponse, y as LoginRequest, c as ListFilesParams, w as ListFilesResponse, ad as StorageFile, aj as UploadResponse } from './index-CEi5Nd4L.js';
3
3
 
4
4
  /**
5
5
  * Server-Side ScaleMule Client
@@ -1,5 +1,5 @@
1
1
  import { MoneyClient } from '@scalemule/money';
2
- import { A as ApiError, a3 as RegisterRequest, q as ClientContext, U as User, L as LoginResponse, y as LoginRequest, c as ListFilesParams, w as ListFilesResponse, ad as StorageFile, aj as UploadResponse } from './index-2PnO4RAF.mjs';
2
+ import { A as ApiError, a3 as RegisterRequest, q as ClientContext, U as User, L as LoginResponse, y as LoginRequest, c as ListFilesParams, w as ListFilesResponse, ad as StorageFile, aj as UploadResponse } from './index-CEi5Nd4L.mjs';
3
3
 
4
4
  /**
5
5
  * Server-Side ScaleMule Client
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalemule/nextjs",
3
- "version": "0.1.57",
3
+ "version": "0.1.60",
4
4
  "description": "ScaleMule SDK for Next.js applications - authentication, storage, and user management",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",