@scalemule/nextjs 0.1.23 → 0.1.26

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, A as ApiError } from './index-DTWyUcyd.mjs';
1
+ import { a8 as StorageAdapter, A as ApiError } from './index-zQloSkpW.mjs';
2
2
 
3
3
  /**
4
4
  * ScaleMule API Client
@@ -137,6 +137,19 @@ declare class ScaleMuleClient {
137
137
  * Set session after login
138
138
  */
139
139
  setSession(token: string, userId: string): Promise<void>;
140
+ /**
141
+ * Token-only setter for member-auth surfaces.
142
+ *
143
+ * Unlike `setSession(token, userId)`, this does NOT persist a userId or
144
+ * write to local storage — useful when the host platform owns identity
145
+ * (e.g. ScaleMule's member dashboards use `MemberAuthProvider` and the
146
+ * token comes from a `${env}_member_access_token` cookie). The token is
147
+ * applied in-memory and used as a `Bearer` Authorization header on
148
+ * subsequent requests.
149
+ *
150
+ * Pass `null` to clear without touching userId/storage.
151
+ */
152
+ setSessionToken(token: string | null): void;
140
153
  /**
141
154
  * Clear session on logout
142
155
  */
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a8 as StorageAdapter, A as ApiError } from './index-DTWyUcyd.js';
1
+ import { a8 as StorageAdapter, A as ApiError } from './index-zQloSkpW.js';
2
2
 
3
3
  /**
4
4
  * ScaleMule API Client
@@ -137,6 +137,19 @@ declare class ScaleMuleClient {
137
137
  * Set session after login
138
138
  */
139
139
  setSession(token: string, userId: string): Promise<void>;
140
+ /**
141
+ * Token-only setter for member-auth surfaces.
142
+ *
143
+ * Unlike `setSession(token, userId)`, this does NOT persist a userId or
144
+ * write to local storage — useful when the host platform owns identity
145
+ * (e.g. ScaleMule's member dashboards use `MemberAuthProvider` and the
146
+ * token comes from a `${env}_member_access_token` cookie). The token is
147
+ * applied in-memory and used as a `Bearer` Authorization header on
148
+ * subsequent requests.
149
+ *
150
+ * Pass `null` to clear without touching userId/storage.
151
+ */
152
+ setSessionToken(token: string | null): void;
140
153
  /**
141
154
  * Clear session on logout
142
155
  */
package/dist/client.js CHANGED
@@ -433,6 +433,24 @@ var ScaleMuleClient = class {
433
433
  console.log("[ScaleMule] Session set for user:", userId);
434
434
  }
435
435
  }
436
+ /**
437
+ * Token-only setter for member-auth surfaces.
438
+ *
439
+ * Unlike `setSession(token, userId)`, this does NOT persist a userId or
440
+ * write to local storage — useful when the host platform owns identity
441
+ * (e.g. ScaleMule's member dashboards use `MemberAuthProvider` and the
442
+ * token comes from a `${env}_member_access_token` cookie). The token is
443
+ * applied in-memory and used as a `Bearer` Authorization header on
444
+ * subsequent requests.
445
+ *
446
+ * Pass `null` to clear without touching userId/storage.
447
+ */
448
+ setSessionToken(token) {
449
+ this.sessionToken = token;
450
+ if (this.debug) {
451
+ console.log("[ScaleMule] Session token", token ? "set (token-only)" : "cleared (token-only)");
452
+ }
453
+ }
436
454
  /**
437
455
  * Clear session on logout
438
456
  */
@@ -497,6 +515,8 @@ var ScaleMuleClient = class {
497
515
  console.log(`[ScaleMule] ${options.method || "GET"} ${path}`);
498
516
  }
499
517
  let lastError = null;
518
+ const MAX_REFRESH_ATTEMPTS = 1;
519
+ let refreshAttempts = 0;
500
520
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
501
521
  const controller = new AbortController();
502
522
  const timeoutId = setTimeout(() => controller.abort(), timeout);
@@ -520,7 +540,8 @@ var ScaleMuleClient = class {
520
540
  if (!response.ok) {
521
541
  const rawError = responseData?.error;
522
542
  const error = rawError && typeof rawError === "object" ? rawError : { code: `HTTP_${response.status}`, message: typeof rawError === "string" ? rawError : responseData?.message || text || response.statusText };
523
- if (response.status === 401 && this.sessionToken && !options.isAutoRefresh) {
543
+ if (response.status === 401 && this.sessionToken && !options.isAutoRefresh && refreshAttempts < MAX_REFRESH_ATTEMPTS) {
544
+ refreshAttempts++;
524
545
  if (this.debug) console.log("[ScaleMule] 401 received, attempting auto-refresh...");
525
546
  if (!this.refreshPromise) {
526
547
  this.onRefreshStart?.();
package/dist/client.mjs CHANGED
@@ -431,6 +431,24 @@ var ScaleMuleClient = class {
431
431
  console.log("[ScaleMule] Session set for user:", userId);
432
432
  }
433
433
  }
434
+ /**
435
+ * Token-only setter for member-auth surfaces.
436
+ *
437
+ * Unlike `setSession(token, userId)`, this does NOT persist a userId or
438
+ * write to local storage — useful when the host platform owns identity
439
+ * (e.g. ScaleMule's member dashboards use `MemberAuthProvider` and the
440
+ * token comes from a `${env}_member_access_token` cookie). The token is
441
+ * applied in-memory and used as a `Bearer` Authorization header on
442
+ * subsequent requests.
443
+ *
444
+ * Pass `null` to clear without touching userId/storage.
445
+ */
446
+ setSessionToken(token) {
447
+ this.sessionToken = token;
448
+ if (this.debug) {
449
+ console.log("[ScaleMule] Session token", token ? "set (token-only)" : "cleared (token-only)");
450
+ }
451
+ }
434
452
  /**
435
453
  * Clear session on logout
436
454
  */
@@ -495,6 +513,8 @@ var ScaleMuleClient = class {
495
513
  console.log(`[ScaleMule] ${options.method || "GET"} ${path}`);
496
514
  }
497
515
  let lastError = null;
516
+ const MAX_REFRESH_ATTEMPTS = 1;
517
+ let refreshAttempts = 0;
498
518
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
499
519
  const controller = new AbortController();
500
520
  const timeoutId = setTimeout(() => controller.abort(), timeout);
@@ -518,7 +538,8 @@ var ScaleMuleClient = class {
518
538
  if (!response.ok) {
519
539
  const rawError = responseData?.error;
520
540
  const error = rawError && typeof rawError === "object" ? rawError : { code: `HTTP_${response.status}`, message: typeof rawError === "string" ? rawError : responseData?.message || text || response.statusText };
521
- if (response.status === 401 && this.sessionToken && !options.isAutoRefresh) {
541
+ if (response.status === 401 && this.sessionToken && !options.isAutoRefresh && refreshAttempts < MAX_REFRESH_ATTEMPTS) {
542
+ refreshAttempts++;
522
543
  if (this.debug) console.log("[ScaleMule] 401 received, attempting auto-refresh...");
523
544
  if (!this.refreshPromise) {
524
545
  this.onRefreshStart?.();
@@ -248,7 +248,11 @@ interface OAuthCallbackResponse {
248
248
  }
249
249
  interface LinkedAccount {
250
250
  provider: string;
251
- provider_user_id: string;
251
+ /**
252
+ * Not returned by GET /v1/auth/oauth/providers today. Reserved for a
253
+ * future endpoint that exposes the external user id; treat as optional.
254
+ */
255
+ provider_user_id?: string;
252
256
  provider_email?: string;
253
257
  linked_at: string;
254
258
  }
@@ -248,7 +248,11 @@ interface OAuthCallbackResponse {
248
248
  }
249
249
  interface LinkedAccount {
250
250
  provider: string;
251
- provider_user_id: string;
251
+ /**
252
+ * Not returned by GET /v1/auth/oauth/providers today. Reserved for a
253
+ * future endpoint that exposes the external user id; treat as optional.
254
+ */
255
+ provider_user_id?: string;
252
256
  provider_email?: string;
253
257
  linked_at: string;
254
258
  }
package/dist/index.d.mts CHANGED
@@ -1,13 +1,13 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ApiError, RealtimeService, StorageService, PhotoService, VideoService, AudioService, TtsService, TtsJobStatus, FileStatus, TtsAudioInfo } from '@scalemule/sdk';
2
+ import { ApiError, RealtimeService, StorageService, PhotoService, VideoService, AudioService, TtsService, TtsJobStatus, FileStatus } from '@scalemule/sdk';
3
3
  import * as React from 'react';
4
4
  import { 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-DTWyUcyd.mjs';
10
- 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-DTWyUcyd.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-zQloSkpW.mjs';
10
+ 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-zQloSkpW.mjs';
11
11
 
12
12
  /**
13
13
  * Result of a single {@link useMedia} upload call.
@@ -219,7 +219,7 @@ interface ScaleMuleProviderProps extends ScaleMuleConfig {
219
219
  * The platform stores the per-app policy in
220
220
  * `application_storage_settings.media_policy` (Phase 4 / P3, live in
221
221
  * prod). On boot, the provider fetches `GET /v1/storage/policy` (a
222
- * lightweight `EndUserOnly` endpoint added in `@scalemule/sdk@0.0.45`)
222
+ * lightweight `MemberOrEndUser` endpoint added in `@scalemule/sdk@0.0.45`)
223
223
  * and uses the returned policy as the effective default.
224
224
  *
225
225
  * Passing this prop overrides the auto-fetched value — useful for
@@ -227,8 +227,42 @@ interface ScaleMuleProviderProps extends ScaleMuleConfig {
227
227
  * platform config.
228
228
  */
229
229
  mediaPolicy?: MediaPolicy;
230
+ /**
231
+ * Member-auth bridge. When set, the provider runs in **member mode**:
232
+ *
233
+ * - Skips the `/v1/auth/me` end-user lookup and the auth-proxy
234
+ * `/me` flow. Identity is owned upstream (e.g. `MemberAuthProvider`
235
+ * in `web/scalemule-app`).
236
+ * - Calls `getToken()` on mount and propagates the returned token
237
+ * to all three SDK clients (`client`, `baseClient`, `money`) as a
238
+ * `Bearer` Authorization header. Returning `null` clears the token.
239
+ * - Re-polls every {@link memberTokenPollMs} milliseconds (default
240
+ * 60s) so cookie rotation in the host platform is picked up
241
+ * without a full page reload.
242
+ *
243
+ * Use {@link userResolver} alongside this prop to populate `user` from
244
+ * a member-auth endpoint instead of `/v1/auth/me`.
245
+ *
246
+ * Mutually exclusive with `authProxyUrl`. If both are set, `getToken`
247
+ * wins and the auth-proxy path is skipped.
248
+ */
249
+ getToken?: () => string | null | Promise<string | null>;
250
+ /**
251
+ * Resolves the `User` shown to the app in member-auth mode. The
252
+ * provider calls this once after the initial token is set; the host
253
+ * platform typically just returns its own `MemberProfile` mapped to
254
+ * the SDK's `User` shape. Optional — if omitted, `user` stays `null`
255
+ * and the host platform is responsible for surfacing identity.
256
+ */
257
+ userResolver?: () => Promise<User | null>;
258
+ /**
259
+ * Member-mode token poll interval in milliseconds. Default 60_000
260
+ * (1 minute). Pass `null` to disable polling (only the mount-time
261
+ * read happens).
262
+ */
263
+ memberTokenPollMs?: number | null;
230
264
  }
231
- declare function ScaleMuleProvider({ apiKey, applicationId, environment, gatewayUrl, debug, storage, analyticsProxyUrl, authProxyUrl, telemetryEndpoint, publishableKey, enableAccountSwitcher, accountSwitcherPrivacy, children, onLogin, onLogout, onAuthError, bootstrapFlags, mediaPolicy, }: ScaleMuleProviderProps): react_jsx_runtime.JSX.Element;
265
+ declare function ScaleMuleProvider({ apiKey, applicationId, environment, gatewayUrl, debug, storage, analyticsProxyUrl, authProxyUrl, telemetryEndpoint, publishableKey, enableAccountSwitcher, accountSwitcherPrivacy, children, onLogin, onLogout, onAuthError, bootstrapFlags, mediaPolicy, getToken, userResolver, memberTokenPollMs, }: ScaleMuleProviderProps): react_jsx_runtime.JSX.Element;
232
266
  declare function useScaleMule(): ScaleMuleContextValue;
233
267
  declare function useScaleMuleClient(): ScaleMuleClient;
234
268
  declare function useMoneyClient(): MoneyClient;
@@ -850,6 +884,35 @@ interface UseFeedbackResult {
850
884
  */
851
885
  declare function useFeedback(options?: UseFeedbackOptions): UseFeedbackResult;
852
886
 
887
+ interface VoteState {
888
+ /** Caller's current vote: 1 = upvote, -1 = downvote, 0 = no vote. */
889
+ value: 1 | -1 | 0;
890
+ up_count: number;
891
+ down_count: number;
892
+ score: number;
893
+ }
894
+ interface UseVoteOptions {
895
+ /** Application-defined target type. e.g. "weekmob_post", "gistyo_gist". */
896
+ targetType: string;
897
+ targetId: string;
898
+ /** Optional seed (from SSR or list query). */
899
+ initialState?: VoteState | null;
900
+ /** Refetch even when initialState is provided. Default false. */
901
+ refetchOnMount?: boolean;
902
+ /** Skip the initial fetch entirely (anonymous viewers). Default true. */
903
+ enabled?: boolean;
904
+ }
905
+ interface UseVoteReturn {
906
+ state: VoteState;
907
+ isLoading: boolean;
908
+ error: Error | null;
909
+ /** Cast (or change/clear) the caller's vote with optimistic update. */
910
+ cast: (value: 1 | -1 | 0) => Promise<void>;
911
+ /** Refetch the canonical state from the server. */
912
+ refetch: () => Promise<void>;
913
+ }
914
+ declare function useVote({ targetType, targetId, initialState, refetchOnMount, enabled, }: UseVoteOptions): UseVoteReturn;
915
+
853
916
  interface FeedbackWidgetProps {
854
917
  /** Floating-button corner. Default `bottom-right`. */
855
918
  position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
@@ -888,20 +951,32 @@ interface FeedbackWidgetProps {
888
951
  */
889
952
  declare function FeedbackWidget(props: FeedbackWidgetProps): ReactElement | null;
890
953
 
891
- type NarrationPlayerAudio = TtsAudioInfo & {
892
- waveform_peaks?: number[] | null;
893
- ai_generated?: boolean;
894
- };
895
- interface NarrationPlayerProps {
896
- audio: NarrationPlayerAudio;
897
- className?: string;
898
- providerLabel?: string;
899
- narrationLabel?: string;
900
- refreshing?: boolean;
901
- onRefresh?: () => void | Promise<void>;
902
- onPlaybackError?: () => void;
954
+ interface VoteButtonClassNames {
955
+ root?: string;
956
+ upButton?: string;
957
+ upButtonActive?: string;
958
+ downButton?: string;
959
+ downButtonActive?: string;
960
+ score?: string;
961
+ scorePositive?: string;
962
+ scoreNegative?: string;
963
+ }
964
+ interface VoteButtonProps {
965
+ targetType: string;
966
+ targetId: string;
967
+ /** Server-known initial state, e.g. seeded from a list query. */
968
+ initialState?: VoteState | null;
969
+ /** Visual layout. "horizontal" = up | score | down. "stacked" = column. */
970
+ layout?: 'horizontal' | 'stacked';
971
+ size?: 'compact' | 'regular';
972
+ /** Called when an anonymous user clicks vote. */
973
+ onSignInRequired?: () => void;
974
+ onError?: (error: unknown) => void;
975
+ classNames?: VoteButtonClassNames;
976
+ upLabel?: string;
977
+ downLabel?: string;
903
978
  }
904
- declare function NarrationPlayer({ audio, className, providerLabel, narrationLabel, refreshing, onRefresh, onPlaybackError, }: NarrationPlayerProps): react_jsx_runtime.JSX.Element | null;
979
+ declare function VoteButton({ targetType, targetId, initialState, layout, size, onSignInRequired, onError, classNames, upLabel, downLabel, }: VoteButtonProps): react_jsx_runtime.JSX.Element;
905
980
 
906
981
  /**
907
982
  * Client-side validation helpers
@@ -1061,4 +1136,4 @@ declare function createSafeLogger(prefix: string): {
1061
1136
  error: (message: string, data?: unknown) => void;
1062
1137
  };
1063
1138
 
1064
- 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, 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, User, type UsernameValidationResult, composePhone, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAudio, useAuth, useBilling, useContent, useFeatureFlags, useFeedback, useFileStatus, useMedia, useMoney, useMoneyClient, usePushNotifications, useRealtime, useScaleMule, useScaleMuleClient, useShare, useTtsJob, useUser, validateForm, validators };
1139
+ 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, type PasswordValidationResult, type PhoneCountry, type PhoneValidationResult, type RealtimeEvent, type RealtimeMessage, type RealtimeStatus, ScaleMuleClient, ScaleMuleConfig, ScaleMuleMedia, type ScaleMuleMediaProps, ScaleMuleProvider, type ScaleMuleProviderProps, 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 };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ApiError, RealtimeService, StorageService, PhotoService, VideoService, AudioService, TtsService, TtsJobStatus, FileStatus, TtsAudioInfo } from '@scalemule/sdk';
2
+ import { ApiError, RealtimeService, StorageService, PhotoService, VideoService, AudioService, TtsService, TtsJobStatus, FileStatus } from '@scalemule/sdk';
3
3
  import * as React from 'react';
4
4
  import { 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-DTWyUcyd.js';
10
- 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-DTWyUcyd.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-zQloSkpW.js';
10
+ 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-zQloSkpW.js';
11
11
 
12
12
  /**
13
13
  * Result of a single {@link useMedia} upload call.
@@ -219,7 +219,7 @@ interface ScaleMuleProviderProps extends ScaleMuleConfig {
219
219
  * The platform stores the per-app policy in
220
220
  * `application_storage_settings.media_policy` (Phase 4 / P3, live in
221
221
  * prod). On boot, the provider fetches `GET /v1/storage/policy` (a
222
- * lightweight `EndUserOnly` endpoint added in `@scalemule/sdk@0.0.45`)
222
+ * lightweight `MemberOrEndUser` endpoint added in `@scalemule/sdk@0.0.45`)
223
223
  * and uses the returned policy as the effective default.
224
224
  *
225
225
  * Passing this prop overrides the auto-fetched value — useful for
@@ -227,8 +227,42 @@ interface ScaleMuleProviderProps extends ScaleMuleConfig {
227
227
  * platform config.
228
228
  */
229
229
  mediaPolicy?: MediaPolicy;
230
+ /**
231
+ * Member-auth bridge. When set, the provider runs in **member mode**:
232
+ *
233
+ * - Skips the `/v1/auth/me` end-user lookup and the auth-proxy
234
+ * `/me` flow. Identity is owned upstream (e.g. `MemberAuthProvider`
235
+ * in `web/scalemule-app`).
236
+ * - Calls `getToken()` on mount and propagates the returned token
237
+ * to all three SDK clients (`client`, `baseClient`, `money`) as a
238
+ * `Bearer` Authorization header. Returning `null` clears the token.
239
+ * - Re-polls every {@link memberTokenPollMs} milliseconds (default
240
+ * 60s) so cookie rotation in the host platform is picked up
241
+ * without a full page reload.
242
+ *
243
+ * Use {@link userResolver} alongside this prop to populate `user` from
244
+ * a member-auth endpoint instead of `/v1/auth/me`.
245
+ *
246
+ * Mutually exclusive with `authProxyUrl`. If both are set, `getToken`
247
+ * wins and the auth-proxy path is skipped.
248
+ */
249
+ getToken?: () => string | null | Promise<string | null>;
250
+ /**
251
+ * Resolves the `User` shown to the app in member-auth mode. The
252
+ * provider calls this once after the initial token is set; the host
253
+ * platform typically just returns its own `MemberProfile` mapped to
254
+ * the SDK's `User` shape. Optional — if omitted, `user` stays `null`
255
+ * and the host platform is responsible for surfacing identity.
256
+ */
257
+ userResolver?: () => Promise<User | null>;
258
+ /**
259
+ * Member-mode token poll interval in milliseconds. Default 60_000
260
+ * (1 minute). Pass `null` to disable polling (only the mount-time
261
+ * read happens).
262
+ */
263
+ memberTokenPollMs?: number | null;
230
264
  }
231
- declare function ScaleMuleProvider({ apiKey, applicationId, environment, gatewayUrl, debug, storage, analyticsProxyUrl, authProxyUrl, telemetryEndpoint, publishableKey, enableAccountSwitcher, accountSwitcherPrivacy, children, onLogin, onLogout, onAuthError, bootstrapFlags, mediaPolicy, }: ScaleMuleProviderProps): react_jsx_runtime.JSX.Element;
265
+ declare function ScaleMuleProvider({ apiKey, applicationId, environment, gatewayUrl, debug, storage, analyticsProxyUrl, authProxyUrl, telemetryEndpoint, publishableKey, enableAccountSwitcher, accountSwitcherPrivacy, children, onLogin, onLogout, onAuthError, bootstrapFlags, mediaPolicy, getToken, userResolver, memberTokenPollMs, }: ScaleMuleProviderProps): react_jsx_runtime.JSX.Element;
232
266
  declare function useScaleMule(): ScaleMuleContextValue;
233
267
  declare function useScaleMuleClient(): ScaleMuleClient;
234
268
  declare function useMoneyClient(): MoneyClient;
@@ -850,6 +884,35 @@ interface UseFeedbackResult {
850
884
  */
851
885
  declare function useFeedback(options?: UseFeedbackOptions): UseFeedbackResult;
852
886
 
887
+ interface VoteState {
888
+ /** Caller's current vote: 1 = upvote, -1 = downvote, 0 = no vote. */
889
+ value: 1 | -1 | 0;
890
+ up_count: number;
891
+ down_count: number;
892
+ score: number;
893
+ }
894
+ interface UseVoteOptions {
895
+ /** Application-defined target type. e.g. "weekmob_post", "gistyo_gist". */
896
+ targetType: string;
897
+ targetId: string;
898
+ /** Optional seed (from SSR or list query). */
899
+ initialState?: VoteState | null;
900
+ /** Refetch even when initialState is provided. Default false. */
901
+ refetchOnMount?: boolean;
902
+ /** Skip the initial fetch entirely (anonymous viewers). Default true. */
903
+ enabled?: boolean;
904
+ }
905
+ interface UseVoteReturn {
906
+ state: VoteState;
907
+ isLoading: boolean;
908
+ error: Error | null;
909
+ /** Cast (or change/clear) the caller's vote with optimistic update. */
910
+ cast: (value: 1 | -1 | 0) => Promise<void>;
911
+ /** Refetch the canonical state from the server. */
912
+ refetch: () => Promise<void>;
913
+ }
914
+ declare function useVote({ targetType, targetId, initialState, refetchOnMount, enabled, }: UseVoteOptions): UseVoteReturn;
915
+
853
916
  interface FeedbackWidgetProps {
854
917
  /** Floating-button corner. Default `bottom-right`. */
855
918
  position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
@@ -888,20 +951,32 @@ interface FeedbackWidgetProps {
888
951
  */
889
952
  declare function FeedbackWidget(props: FeedbackWidgetProps): ReactElement | null;
890
953
 
891
- type NarrationPlayerAudio = TtsAudioInfo & {
892
- waveform_peaks?: number[] | null;
893
- ai_generated?: boolean;
894
- };
895
- interface NarrationPlayerProps {
896
- audio: NarrationPlayerAudio;
897
- className?: string;
898
- providerLabel?: string;
899
- narrationLabel?: string;
900
- refreshing?: boolean;
901
- onRefresh?: () => void | Promise<void>;
902
- onPlaybackError?: () => void;
954
+ interface VoteButtonClassNames {
955
+ root?: string;
956
+ upButton?: string;
957
+ upButtonActive?: string;
958
+ downButton?: string;
959
+ downButtonActive?: string;
960
+ score?: string;
961
+ scorePositive?: string;
962
+ scoreNegative?: string;
963
+ }
964
+ interface VoteButtonProps {
965
+ targetType: string;
966
+ targetId: string;
967
+ /** Server-known initial state, e.g. seeded from a list query. */
968
+ initialState?: VoteState | null;
969
+ /** Visual layout. "horizontal" = up | score | down. "stacked" = column. */
970
+ layout?: 'horizontal' | 'stacked';
971
+ size?: 'compact' | 'regular';
972
+ /** Called when an anonymous user clicks vote. */
973
+ onSignInRequired?: () => void;
974
+ onError?: (error: unknown) => void;
975
+ classNames?: VoteButtonClassNames;
976
+ upLabel?: string;
977
+ downLabel?: string;
903
978
  }
904
- declare function NarrationPlayer({ audio, className, providerLabel, narrationLabel, refreshing, onRefresh, onPlaybackError, }: NarrationPlayerProps): react_jsx_runtime.JSX.Element | null;
979
+ declare function VoteButton({ targetType, targetId, initialState, layout, size, onSignInRequired, onError, classNames, upLabel, downLabel, }: VoteButtonProps): react_jsx_runtime.JSX.Element;
905
980
 
906
981
  /**
907
982
  * Client-side validation helpers
@@ -1061,4 +1136,4 @@ declare function createSafeLogger(prefix: string): {
1061
1136
  error: (message: string, data?: unknown) => void;
1062
1137
  };
1063
1138
 
1064
- 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, 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, User, type UsernameValidationResult, composePhone, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAudio, useAuth, useBilling, useContent, useFeatureFlags, useFeedback, useFileStatus, useMedia, useMoney, useMoneyClient, usePushNotifications, useRealtime, useScaleMule, useScaleMuleClient, useShare, useTtsJob, useUser, validateForm, validators };
1139
+ 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, type PasswordValidationResult, type PhoneCountry, type PhoneValidationResult, type RealtimeEvent, type RealtimeMessage, type RealtimeStatus, ScaleMuleClient, ScaleMuleConfig, ScaleMuleMedia, type ScaleMuleMediaProps, ScaleMuleProvider, type ScaleMuleProviderProps, 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 };