@scalemule/nextjs 0.1.60 → 0.1.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/package.json +2 -2
  2. package/dist/audio.css +0 -857
  3. package/dist/audio.d.mts +0 -334
  4. package/dist/audio.d.ts +0 -334
  5. package/dist/audio.js +0 -2178
  6. package/dist/audio.mjs +0 -2156
  7. package/dist/client.d.mts +0 -240
  8. package/dist/client.d.ts +0 -240
  9. package/dist/client.js +0 -938
  10. package/dist/client.mjs +0 -935
  11. package/dist/index-CEi5Nd4L.d.mts +0 -980
  12. package/dist/index-CEi5Nd4L.d.ts +0 -980
  13. package/dist/index.d.mts +0 -1306
  14. package/dist/index.d.ts +0 -1306
  15. package/dist/index.js +0 -5991
  16. package/dist/index.mjs +0 -5928
  17. package/dist/ledvery-CxPzZpxP.d.mts +0 -44
  18. package/dist/ledvery-CxPzZpxP.d.ts +0 -44
  19. package/dist/listening-hub.global.js +0 -1
  20. package/dist/server/auth.d.mts +0 -43
  21. package/dist/server/auth.d.ts +0 -43
  22. package/dist/server/auth.js +0 -1988
  23. package/dist/server/auth.mjs +0 -1982
  24. package/dist/server/index.d.mts +0 -1302
  25. package/dist/server/index.d.ts +0 -1302
  26. package/dist/server/index.js +0 -3633
  27. package/dist/server/index.mjs +0 -3554
  28. package/dist/server/ledvery.d.mts +0 -1
  29. package/dist/server/ledvery.d.ts +0 -1
  30. package/dist/server/ledvery.js +0 -336
  31. package/dist/server/ledvery.mjs +0 -333
  32. package/dist/server/webhook-handler.d.mts +0 -3
  33. package/dist/server/webhook-handler.d.ts +0 -3
  34. package/dist/server/webhook-handler.js +0 -59
  35. package/dist/server/webhook-handler.mjs +0 -57
  36. package/dist/testing.d.mts +0 -109
  37. package/dist/testing.d.ts +0 -109
  38. package/dist/testing.js +0 -144
  39. package/dist/testing.mjs +0 -138
  40. package/dist/webhook-handler-B2GL4SDl.d.ts +0 -826
  41. package/dist/webhook-handler-D--VG8bN.d.mts +0 -826
@@ -1,980 +0,0 @@
1
- /**
2
- * ScaleMule SDK Types
3
- *
4
- * These types mirror the ScaleMule API responses and requests.
5
- */
6
- type ScaleMuleEnvironment = 'dev' | 'prod';
7
- interface ScaleMuleConfig {
8
- /** Explicit legacy bearer transport; auth proxies default to HTTP-only cookie transport. */
9
- sessionMode?: 'cookie' | 'bearer';
10
- /** Your ScaleMule API key */
11
- apiKey: string;
12
- /** Your ScaleMule Application ID (required for realtime features) */
13
- applicationId?: string;
14
- /** Environment: 'dev' or 'prod' - automatically sets gateway URL */
15
- environment?: ScaleMuleEnvironment;
16
- /** Custom gateway URL (overrides environment preset) */
17
- gatewayUrl?: string;
18
- /** Enable debug logging */
19
- debug?: boolean;
20
- /** Custom storage for session persistence (defaults to localStorage) */
21
- storage?: StorageAdapter;
22
- /**
23
- * Proxy URL for analytics events (e.g., '/api/analytics' or '/api/t/e')
24
- *
25
- * When set, the SDK sends analytics events to this URL instead of directly
26
- * to ScaleMule. Use this when you don't want to expose your API key in the
27
- * browser. Your server-side route should use createAnalyticsRoutes() from
28
- * '@scalemule/nextjs/server' to forward events to ScaleMule.
29
- *
30
- * @example
31
- * // In your provider config:
32
- * analyticsProxyUrl: '/api/analytics'
33
- *
34
- * // In your server route (app/api/analytics/[...path]/route.ts):
35
- * import { createAnalyticsRoutes } from '@scalemule/nextjs/server'
36
- * export const { POST } = createAnalyticsRoutes()
37
- */
38
- analyticsProxyUrl?: string;
39
- /**
40
- * Proxy URL for authentication operations (e.g., '/api/auth')
41
- *
42
- * When set, the SDK routes all auth calls (login, register, logout, etc.)
43
- * through this URL instead of making direct browser requests to ScaleMule.
44
- * This keeps the secret API key on the server and uses httpOnly cookies
45
- * for session management.
46
- *
47
- * Your server-side route should handle auth operations using
48
- * createServerClient() from '@scalemule/nextjs/server'.
49
- *
50
- * @example
51
- * // In your provider config:
52
- * authProxyUrl: '/api/auth'
53
- *
54
- * // In your server route (app/api/auth/[...path]/route.ts):
55
- * // Handle register, login, logout, etc. using ScaleMule server client
56
- */
57
- authProxyUrl?: string;
58
- /**
59
- * Endpoint to ship SDK error logs to (fire-and-forget POST).
60
- *
61
- * When set, every non-2xx response from the auth proxy (and any other
62
- * SDK call that throws a ScaleMuleApiError) will be reported to this
63
- * URL as a structured log entry, alongside the regular setError() and
64
- * thrown ScaleMuleApiError. This makes API failures visible in your
65
- * platform's error logger even when the calling code catches the
66
- * error and surfaces a UI message — the case the global window.onerror
67
- * / unhandledrejection / React error-boundary collectors all miss by
68
- * design.
69
- *
70
- * Recommended value: '/api/telemetry/errors' (the same endpoint your
71
- * host-app's client-side error collector already POSTs to). The body
72
- * shape matches what `createTelemetryRoutes()` expects:
73
- * `{ logs: [{ message, metadata, timestamp }] }`.
74
- *
75
- * @example
76
- * telemetryEndpoint: '/api/telemetry/errors'
77
- */
78
- telemetryEndpoint?: string;
79
- /**
80
- * Publishable API key for browser-safe operations (e.g., analytics)
81
- *
82
- * Publishable keys (sm_pb_*) are origin-locked and safe to expose in
83
- * browser code. They have restricted access compared to secret keys.
84
- *
85
- * When set, the analytics hook uses this key for direct browser-to-API
86
- * calls instead of going through the analytics proxy.
87
- *
88
- * @example
89
- * publishableKey: 'sm_pb_production_a1b2c3d4...'
90
- */
91
- publishableKey?: string;
92
- /**
93
- * Enable the account switcher — remembers which accounts have logged in on
94
- * this device so users can pick an account and re-authenticate.
95
- *
96
- * Stores only display metadata (email, name, avatar) — no tokens.
97
- * Switching accounts always requires re-authentication.
98
- *
99
- * When using auth proxy mode, this works via a non-httpOnly cookie.
100
- * The server route config must also have `enableAccountSwitcher: true`.
101
- *
102
- * Default: false
103
- */
104
- enableAccountSwitcher?: boolean;
105
- /**
106
- * Privacy level for account switcher display metadata.
107
- *
108
- * - 'full': Store email, name, avatar as-is (default)
109
- * - 'masked': Mask email (j***@g***.com), truncate name to initial
110
- * - 'minimal': No PII at all — just a colored "Account" label
111
- *
112
- * Applies to both server-side cookie writes and client-side reads.
113
- */
114
- accountSwitcherPrivacy?: 'full' | 'masked' | 'minimal';
115
- }
116
- interface StorageAdapter {
117
- getItem(key: string): string | null | Promise<string | null>;
118
- setItem(key: string, value: string): void | Promise<void>;
119
- removeItem(key: string): void | Promise<void>;
120
- }
121
- declare class ScaleMuleApiError extends Error {
122
- code: string;
123
- status?: number;
124
- field?: string;
125
- details?: unknown;
126
- /**
127
- * Correlation id for the failed request. Comes from the response envelope
128
- * (`meta.request_id`), falling back to the `x-request-id` response header
129
- * echoed by the gateway. Surface this in support flows.
130
- */
131
- requestId?: string;
132
- /** Distributed-trace id, when the backend supplies `meta.trace_id`. */
133
- traceId?: string;
134
- /**
135
- * The raw `error` object from the response body, unmodified. Escape hatch
136
- * for consumers (such as `@scalemule/signals` `fromError`) that need fields
137
- * this class does not model yet.
138
- */
139
- problem?: unknown;
140
- constructor(error: ApiError, status?: number);
141
- }
142
- interface ApiResponse<T> {
143
- success: boolean;
144
- data?: T;
145
- error?: ApiError;
146
- }
147
- interface ApiError {
148
- code: string;
149
- message: string;
150
- field?: string;
151
- /** Correlation id: envelope `meta.request_id`, else the `x-request-id` header. */
152
- requestId?: string;
153
- /** Distributed-trace id from envelope `meta.trace_id`. */
154
- traceId?: string;
155
- /** The raw body `error` object, passed through untouched. */
156
- problem?: unknown;
157
- }
158
- interface User {
159
- id: string;
160
- email: string;
161
- email_verified: boolean;
162
- phone: string | null;
163
- phone_verified: boolean;
164
- full_name: string | null;
165
- username: string | null;
166
- avatar_url: string | null;
167
- status: 'active' | 'suspended' | 'pending_verification';
168
- created_at: string;
169
- }
170
- interface RegisterRequest {
171
- email: string;
172
- password: string;
173
- full_name?: string;
174
- username?: string;
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;
181
- }
182
- interface LoginRequest {
183
- challenge_token?: string;
184
- challenge_code?: string;
185
- email: string;
186
- password: string;
187
- remember_me?: boolean;
188
- device_fingerprint?: DeviceFingerprint;
189
- }
190
- interface DeviceFingerprint {
191
- screen?: string;
192
- timezone?: string;
193
- language?: string;
194
- platform?: string;
195
- cookie_enabled?: boolean;
196
- do_not_track?: string;
197
- }
198
- interface LoginResponse {
199
- session_token: string;
200
- user: User;
201
- expires_at: string;
202
- absolute_expires_at: string;
203
- access_token?: string;
204
- refresh_token?: string;
205
- access_token_expires_in?: number;
206
- device?: LoginDeviceInfo;
207
- risk?: LoginRiskInfo;
208
- }
209
- /** Browser auth succeeds through an HTTP-only cookie; no token is returned. */
210
- interface CookieLoginResponse {
211
- authenticated: true;
212
- user: User;
213
- userId: string;
214
- }
215
- /** Legacy custom proxies may omit the backend's session expiry metadata. */
216
- type ProxyBearerLoginResponse = Pick<LoginResponse, 'session_token' | 'user'> & Partial<Omit<LoginResponse, 'session_token' | 'user'>>;
217
- type AuthLoginResponse = LoginResponse | CookieLoginResponse | ProxyBearerLoginResponse;
218
- type CookieOAuthCallbackResponse = Omit<OAuthCallbackResponse, 'session_token'> & {
219
- authenticated: true;
220
- };
221
- interface LoginDeviceInfo {
222
- id: string;
223
- name: string;
224
- trust_level: string;
225
- is_new: boolean;
226
- }
227
- interface LoginRiskInfo {
228
- score: number;
229
- action: string;
230
- factors: string[];
231
- action_required?: boolean;
232
- }
233
- interface RefreshResponse {
234
- session_token: string;
235
- expires_at: string;
236
- }
237
- interface ForgotPasswordRequest {
238
- email: string;
239
- }
240
- interface ResetPasswordRequest {
241
- token: string;
242
- new_password: string;
243
- }
244
- interface VerifyEmailRequest {
245
- token: string;
246
- }
247
- interface ChangePasswordRequest {
248
- current_password: string;
249
- new_password: string;
250
- }
251
- interface ChangeEmailRequest {
252
- new_email: string;
253
- password: string;
254
- }
255
- type OAuthProvider = 'google' | 'apple' | 'github' | 'facebook' | 'twitter' | 'linkedin';
256
- interface OAuthConfig {
257
- /** OAuth provider */
258
- provider: OAuthProvider;
259
- /** URL to redirect to after OAuth completes */
260
- redirectUrl?: string;
261
- /** Additional scopes to request */
262
- scopes?: string[];
263
- /** State parameter for CSRF protection */
264
- state?: string;
265
- }
266
- interface OAuthStartResponse {
267
- /** URL to redirect user to for OAuth flow */
268
- authorization_url: string;
269
- /** State token for verification */
270
- state: string;
271
- }
272
- interface OAuthCallbackRequest {
273
- /** OAuth provider */
274
- provider: OAuthProvider;
275
- /** Authorization code from OAuth provider */
276
- code: string;
277
- /** State token for verification */
278
- state: string;
279
- }
280
- interface OAuthCallbackResponse {
281
- /** Session token for the authenticated user */
282
- session_token: string;
283
- /** The authenticated user */
284
- user: User;
285
- /** When the session expires */
286
- expires_at: string;
287
- /** Whether this is a new user (just registered via OAuth) */
288
- is_new_user: boolean;
289
- }
290
- interface LinkedAccount {
291
- provider: string;
292
- /**
293
- * Not returned by GET /v1/auth/oauth/providers today. Reserved for a
294
- * future endpoint that exposes the external user id; treat as optional.
295
- */
296
- provider_user_id?: string;
297
- provider_email?: string;
298
- linked_at: string;
299
- }
300
- type MFAMethod = 'totp' | 'sms' | 'email';
301
- interface MFASetupRequest {
302
- method: MFAMethod;
303
- /** Phone number for SMS (required if method is 'sms') */
304
- phone?: string;
305
- }
306
- interface MFATOTPSetupResponse {
307
- /** Secret key for TOTP */
308
- secret: string;
309
- /** QR code URI for authenticator apps (otpauth:// format) */
310
- qr_code_uri: string;
311
- /** Issuer name shown in authenticator app */
312
- issuer: string;
313
- /** Account name shown in authenticator app */
314
- account_name: string;
315
- }
316
- interface MFASMSSetupResponse {
317
- /** Whether setup was successful */
318
- success: boolean;
319
- /** Status message */
320
- message: string;
321
- /** Last digits of the phone number for display */
322
- phone_last_digits: string;
323
- }
324
- interface MFAVerifyRequest {
325
- /** The MFA code entered by user */
326
- code: string;
327
- /** MFA method being verified */
328
- method: MFAMethod;
329
- /** Whether this is during login challenge */
330
- is_login_challenge?: boolean;
331
- }
332
- interface MFAChallengeResponse {
333
- /** Challenge token for completing MFA */
334
- challenge_token: string;
335
- /** Available MFA methods for this user */
336
- available_methods: MFAMethod[];
337
- /** Hint for the method (e.g., last 4 digits of phone) */
338
- hint?: string;
339
- }
340
- interface MFAStatus {
341
- mfa_enabled: boolean;
342
- mfa_method?: string;
343
- totp_configured: boolean;
344
- sms_configured: boolean;
345
- email_configured: boolean;
346
- backup_codes_remaining: number;
347
- allowed_methods: string[];
348
- mfa_required: boolean;
349
- requirement_source: string;
350
- }
351
- interface LoginResponseWithMFA extends Omit<LoginResponse, 'session_token'> {
352
- /** Whether MFA challenge is required */
353
- requires_mfa: boolean;
354
- /** MFA challenge details (if requires_mfa is true) */
355
- mfa_challenge?: MFAChallengeResponse;
356
- /** Session token (only present if MFA not required or already completed) */
357
- session_token?: string;
358
- }
359
- interface PhoneSendCodeRequest {
360
- /** Phone number in E.164 format */
361
- phone: string;
362
- /** Purpose of the code */
363
- purpose: 'login' | 'verify' | 'register';
364
- }
365
- interface PhoneVerifyRequest {
366
- /** Phone number in E.164 format */
367
- phone: string;
368
- /** Verification code from SMS */
369
- code: string;
370
- }
371
- interface PhoneLoginRequest {
372
- /** Phone number in E.164 format */
373
- phone: string;
374
- /** Verification code from SMS */
375
- code: string;
376
- /** Full name (required for new users) */
377
- full_name?: string;
378
- }
379
- interface Session {
380
- token: string;
381
- userId: string;
382
- expiresAt: Date;
383
- }
384
- /**
385
- * Client context information to forward when making server-to-server calls
386
- * on behalf of end users. This ensures that ScaleMule captures the actual
387
- * end user's information instead of the server's information.
388
- *
389
- * Used primarily for uploads where tracking the uploader's IP, user agent,
390
- * and device fingerprint is important for security (e.g., identifying bad actors).
391
- */
392
- interface ClientContext {
393
- /** End user's IP address (from X-Forwarded-For or X-Real-IP) */
394
- ip?: string;
395
- /** End user's browser user agent */
396
- userAgent?: string;
397
- /** End user's device fingerprint (if collected) */
398
- deviceFingerprint?: string;
399
- /** HTTP Referer header (the page that linked to this one) */
400
- referrer?: string;
401
- /**
402
- * End user's anonymous visitor ID, forwarded as `x-anonymous-id`.
403
- * Populated by `extractClientContext()` from the upstream `x-anonymous-id`
404
- * header so server-to-gateway calls (auth proxy) carry the same value the
405
- * browser sent. The backend uses this header to link pre-auth analytics
406
- * activity to a registered user during register/login.
407
- */
408
- anonymousId?: string;
409
- }
410
- interface StorageFile {
411
- id: string;
412
- filename: string;
413
- content_type: string;
414
- size_bytes: number;
415
- is_public: boolean;
416
- created_at: string;
417
- scan_status?: string;
418
- url?: string;
419
- checksum?: string;
420
- scanned_at?: string;
421
- }
422
- interface UploadOptions {
423
- /** Make file publicly accessible */
424
- is_public?: boolean;
425
- /** Custom filename (defaults to original) */
426
- filename?: string;
427
- /** File category for organization */
428
- category?: string;
429
- /** Progress callback (0-100) */
430
- onProgress?: (progress: number) => void;
431
- }
432
- interface ListFilesParams {
433
- /** Filter by content type prefix (e.g., 'image/', 'video/') */
434
- content_type?: string;
435
- /** Search in filename */
436
- search?: string;
437
- /** Number of results (max 100) */
438
- limit?: number;
439
- /** Offset for pagination */
440
- offset?: number;
441
- }
442
- interface ListFilesResponse {
443
- files: StorageFile[];
444
- total: number;
445
- limit: number;
446
- offset: number;
447
- }
448
- interface UploadResponse {
449
- id: string;
450
- filename: string;
451
- content_type: string;
452
- size_bytes: number;
453
- url: string;
454
- }
455
- interface SignedUploadUrl {
456
- upload_url: string;
457
- file_id: string;
458
- expires_at: string;
459
- }
460
- interface SignedUploadRequest {
461
- /** Original filename */
462
- filename: string;
463
- /** MIME content type */
464
- content_type: string;
465
- /** File size in bytes */
466
- size_bytes: number;
467
- /** Make file publicly accessible */
468
- is_public?: boolean;
469
- }
470
- interface SignedUploadResponse {
471
- /** Pre-signed URL for direct upload */
472
- upload_url: string;
473
- /** File ID for reference */
474
- file_id: string;
475
- /** When the signed URL expires */
476
- expires_at: string;
477
- /** Headers to include in the upload request */
478
- required_headers: Record<string, string>;
479
- }
480
- interface SignedUploadCompleteRequest {
481
- /** File ID from signed upload response */
482
- file_id: string;
483
- }
484
- interface UpdateProfileRequest {
485
- full_name?: string;
486
- username?: string;
487
- avatar_url?: string;
488
- }
489
- interface Profile extends User {
490
- }
491
- interface UseAuthReturn {
492
- /** Current user or null if not logged in */
493
- user: User | null;
494
- /** True while loading initial auth state */
495
- loading: boolean;
496
- /** True if user is authenticated */
497
- isAuthenticated: boolean;
498
- /** Last auth error */
499
- error: ApiError | null;
500
- /** Register a new user */
501
- register: (data: RegisterRequest) => Promise<User>;
502
- /** Login with email/password (may return MFA challenge) */
503
- login: (data: LoginRequest) => Promise<AuthLoginResponse | LoginResponseWithMFA>;
504
- /** Logout current user */
505
- logout: () => Promise<void>;
506
- /** Request password reset email */
507
- forgotPassword: (email: string) => Promise<void>;
508
- /** Reset password with token */
509
- resetPassword: (token: string, newPassword: string) => Promise<void>;
510
- /** Verify email with token */
511
- verifyEmail: (token: string) => Promise<void>;
512
- /** Resend verification email (optional email for unauthenticated resend) */
513
- resendVerification: (email?: string) => Promise<void>;
514
- /** Refresh session token */
515
- refreshSession: () => Promise<void>;
516
- /** Start OAuth flow for a provider */
517
- startOAuth: (config: OAuthConfig) => Promise<OAuthStartResponse>;
518
- /** Complete OAuth flow after redirect */
519
- completeOAuth: (request: OAuthCallbackRequest) => Promise<OAuthCallbackResponse | CookieOAuthCallbackResponse>;
520
- /** Get list of linked OAuth accounts */
521
- getLinkedAccounts: () => Promise<LinkedAccount[]>;
522
- /** Link a new OAuth account */
523
- linkAccount: (config: OAuthConfig) => Promise<OAuthStartResponse>;
524
- /** Unlink an OAuth account */
525
- unlinkAccount: (provider: OAuthProvider) => Promise<void>;
526
- /** Get current MFA status */
527
- getMFAStatus: () => Promise<MFAStatus>;
528
- /** Start MFA setup for a method */
529
- setupMFA: (request: MFASetupRequest) => Promise<MFATOTPSetupResponse | MFASMSSetupResponse>;
530
- /** Verify and enable MFA */
531
- verifyMFA: (request: MFAVerifyRequest) => Promise<void>;
532
- /** Complete MFA challenge during login */
533
- completeMFAChallenge: (challengeToken: string, code: string, method: MFAMethod) => Promise<AuthLoginResponse>;
534
- /** Disable MFA */
535
- disableMFA: (password: string) => Promise<void>;
536
- /** Regenerate backup codes */
537
- regenerateBackupCodes: (password: string) => Promise<string[]>;
538
- /** Send verification code to phone */
539
- sendPhoneCode: (request: PhoneSendCodeRequest) => Promise<void>;
540
- /** Verify phone number */
541
- verifyPhone: (request: PhoneVerifyRequest) => Promise<void>;
542
- /** Login with phone number */
543
- loginWithPhone: (request: PhoneLoginRequest) => Promise<AuthLoginResponse>;
544
- /**
545
- * All accounts that have previously logged in on this device.
546
- * Contains display metadata only — no tokens.
547
- * Requires `enableAccountSwitcher: true` in config.
548
- */
549
- knownAccounts: KnownAccountInfo[];
550
- /**
551
- * Switch to a different known account.
552
- * Logs out the current session and returns the target account's info
553
- * so the login form can be pre-filled. User must re-authenticate.
554
- */
555
- switchAccount: (userId: string) => Promise<KnownAccountInfo | null>;
556
- /** Remove a specific account from the known accounts list */
557
- removeKnownAccount: (userId: string) => Promise<void>;
558
- /** Clear all known accounts from this device */
559
- clearKnownAccounts: () => Promise<void>;
560
- }
561
- /**
562
- * Known account info — display metadata only, no tokens.
563
- * Used by the account switcher to show previously logged-in accounts.
564
- */
565
- interface KnownAccountInfo {
566
- userId: string;
567
- email?: string;
568
- fullName?: string;
569
- avatarUrl?: string;
570
- provider?: string;
571
- lastActiveAt: string;
572
- displayLabel?: string;
573
- colorIndex?: number;
574
- }
575
- interface UseContentReturn {
576
- /** User's files */
577
- files: StorageFile[];
578
- /** True while loading */
579
- loading: boolean;
580
- /** Upload progress (0-100) when upload is in progress */
581
- uploadProgress: number | null;
582
- /** Last error */
583
- error: ApiError | null;
584
- /** Upload a file (direct upload through SDK) */
585
- upload: (file: File, options?: UploadOptions) => Promise<UploadResponse>;
586
- /** List user's files */
587
- list: (params?: ListFilesParams) => Promise<ListFilesResponse>;
588
- /** Delete a file */
589
- remove: (fileId: string) => Promise<void>;
590
- /** Get a single file's info */
591
- get: (fileId: string) => Promise<StorageFile>;
592
- /** Refresh the file list */
593
- refresh: () => Promise<void>;
594
- /** Get a signed URL for direct upload (bypasses SDK, uploads directly to storage) */
595
- getSignedUploadUrl: (request: SignedUploadRequest) => Promise<SignedUploadResponse>;
596
- /** Upload file directly to signed URL (call this yourself with fetch/xhr) */
597
- uploadToSignedUrl: (signedUrl: string, file: File, headers: Record<string, string>, onProgress?: (progress: number) => void) => Promise<void>;
598
- /** Mark signed upload as complete */
599
- completeSignedUpload: (fileId: string) => Promise<StorageFile>;
600
- }
601
- interface UseUserReturn {
602
- /** Current user profile */
603
- profile: Profile | null;
604
- /** True while loading */
605
- loading: boolean;
606
- /** Last error */
607
- error: ApiError | null;
608
- /** Update profile */
609
- update: (data: UpdateProfileRequest) => Promise<Profile>;
610
- /** Change password */
611
- changePassword: (currentPassword: string, newPassword: string) => Promise<void>;
612
- /** Change email */
613
- changeEmail: (newEmail: string, password: string) => Promise<void>;
614
- /** Delete account */
615
- deleteAccount: (password: string) => Promise<void>;
616
- /** Request data export */
617
- exportData: () => Promise<{
618
- download_url: string;
619
- }>;
620
- }
621
- /**
622
- * Analytics event to track
623
- */
624
- interface AnalyticsEvent {
625
- /** Event name (e.g., 'page_viewed', 'button_clicked', 'purchase_completed') */
626
- event_name: string;
627
- /** Event category for grouping (e.g., 'engagement', 'conversion', 'navigation') */
628
- event_category?: string;
629
- /** Additional event properties as key-value pairs */
630
- properties?: Record<string, unknown>;
631
- /** User ID to associate with event (auto-filled if user is logged in) */
632
- user_id?: string;
633
- /** Session ID for tracking user journey (auto-generated if not provided) */
634
- session_id?: string;
635
- /** Anonymous ID for tracking before login (auto-generated if not provided) */
636
- anonymous_id?: string;
637
- /** Client timestamp (auto-filled if not provided) */
638
- client_timestamp?: string;
639
- /** Session duration in seconds at event time (auto-filled) */
640
- session_duration_seconds?: number;
641
- }
642
- /**
643
- * Page view event data
644
- */
645
- interface PageViewData {
646
- /** Page URL (auto-filled from window.location if not provided) */
647
- page_url?: string;
648
- /** Page title (auto-filled from document.title if not provided) */
649
- page_title?: string;
650
- /** Referrer URL (auto-filled from document.referrer if not provided) */
651
- referrer?: string;
652
- /** Additional properties */
653
- properties?: Record<string, unknown>;
654
- }
655
- /**
656
- * UTM parameters for campaign tracking
657
- */
658
- interface UTMParams {
659
- /** Traffic source (e.g., 'google', 'newsletter', 'facebook') */
660
- utm_source?: string;
661
- /** Marketing medium (e.g., 'cpc', 'email', 'social') */
662
- utm_medium?: string;
663
- /** Campaign name or ID */
664
- utm_campaign?: string;
665
- /** Search term for paid search */
666
- utm_term?: string;
667
- /** Content identifier for A/B testing */
668
- utm_content?: string;
669
- /** Ad group name or ID */
670
- utm_adgroup?: string;
671
- /** Google Ads click ID (auto-appended by Google) */
672
- gclid?: string;
673
- /** Google Ads click ID for iOS (app attribution) */
674
- gbraid?: string;
675
- /** Google Ads click ID for web (cross-domain) */
676
- wbraid?: string;
677
- /** Facebook/Meta click ID (auto-appended by Meta) */
678
- fbclid?: string;
679
- /** Google Ads campaign ID (via ValueTrack {campaignid}) */
680
- gad_campaignid?: string;
681
- /** Google Ads ad group ID (via ValueTrack {adgroupid}) */
682
- gad_adgroupid?: string;
683
- /** Google Ads network: g=search, d=display, y=youtube */
684
- gad_network?: string;
685
- /** Google Ads match type: b=broad, p=phrase, e=exact */
686
- gad_matchtype?: string;
687
- /** Google Ads device: m=mobile, c=desktop, t=tablet */
688
- gad_device?: string;
689
- /** Google Ads placement (display/youtube site) */
690
- gad_placement?: string;
691
- /** Google Ads source identifier */
692
- gad_source?: string;
693
- }
694
- /**
695
- * Device information for analytics
696
- */
697
- interface DeviceInfo {
698
- /** Device type (mobile, tablet, desktop) */
699
- device_type?: string;
700
- /** Device brand (Apple, Samsung, etc.) */
701
- device_brand?: string;
702
- /** Device model */
703
- device_model?: string;
704
- /** Operating system */
705
- os?: string;
706
- /** OS version */
707
- os_version?: string;
708
- /** Browser name */
709
- browser?: string;
710
- /** Browser version */
711
- browser_version?: string;
712
- /** Screen resolution (e.g., '1920x1080') */
713
- screen_resolution?: string;
714
- /** Viewport size (e.g., '1200x800') */
715
- viewport_size?: string;
716
- }
717
- /**
718
- * Enhanced event with all tracking data
719
- */
720
- interface EnhancedAnalyticsEvent extends AnalyticsEvent {
721
- /** UTM campaign parameters */
722
- utm?: UTMParams;
723
- /** Device information */
724
- device?: DeviceInfo;
725
- /** Page URL */
726
- page_url?: string;
727
- /** Page title */
728
- page_title?: string;
729
- /** Landing page URL (first page user visited) */
730
- landing_page?: string;
731
- }
732
- /**
733
- * Track event response
734
- */
735
- interface TrackEventResponse {
736
- /** Number of events tracked */
737
- tracked: number;
738
- /** Event ID (for v2 events) */
739
- event_id?: string;
740
- /** Session ID */
741
- session_id?: string;
742
- }
743
- /**
744
- * Batch track request
745
- */
746
- interface BatchTrackRequest {
747
- /** Array of events to track */
748
- events: AnalyticsEvent[];
749
- }
750
- /**
751
- * Options for analytics hook
752
- */
753
- interface UseAnalyticsOptions {
754
- /** Auto-track page views on route changes (default: true) */
755
- autoTrackPageViews?: boolean;
756
- /** Auto-capture UTM params from URL (default: true) */
757
- autoCaptureUtmParams?: boolean;
758
- /** @deprecated Typo kept for backward compatibility. Use autoCaptureUtmParams. */
759
- autoCapturUtmParams?: boolean;
760
- /** Auto-generate session ID (default: true) */
761
- autoGenerateSessionId?: boolean;
762
- /** Session ID storage key (default: 'sm_session_id') */
763
- sessionStorageKey?: string;
764
- /**
765
- * @deprecated The anonymous ID is now owned by the underlying ScaleMule
766
- * client (`@scalemule/sdk`), which uses the canonical
767
- * `scalemule_anonymous_id` localStorage key shared across all client
768
- * packages. Setting this option no longer has any effect — overriding the
769
- * storage key here would fragment a visitor's identity between the
770
- * analytics hook and the auth/request headers, which is the bug this
771
- * deprecation closes. Will be removed in a future release.
772
- */
773
- anonymousStorageKey?: string;
774
- /** Use v2 enhanced tracking (default: true) */
775
- useV2?: boolean;
776
- /**
777
- * Minimum milliseconds between duplicate events with the same event_name.
778
- * Prevents inflated analytics from event bubbling, double-bound listeners,
779
- * or rapid-fire IntersectionObserver callbacks.
780
- * Set to 0 to disable dedup. Default: 300ms.
781
- */
782
- eventDedupMs?: number;
783
- }
784
- /**
785
- * Analytics hook return type
786
- */
787
- interface UseAnalyticsReturn {
788
- /** True while an analytics operation is in progress */
789
- loading: boolean;
790
- /** Last error from analytics operations */
791
- error: ApiError | null;
792
- /** Current session ID */
793
- sessionId: string | null;
794
- /** Current anonymous ID */
795
- anonymousId: string | null;
796
- /** Stored UTM parameters from URL */
797
- utmParams: UTMParams | null;
798
- /**
799
- * Track a custom event
800
- * @param event - Event data to track
801
- * @returns Promise with track response
802
- * @example
803
- * ```tsx
804
- * await trackEvent({
805
- * event_name: 'button_clicked',
806
- * event_category: 'engagement',
807
- * properties: { button_id: 'signup', location: 'header' }
808
- * })
809
- * ```
810
- */
811
- trackEvent: (event: AnalyticsEvent) => Promise<TrackEventResponse>;
812
- /**
813
- * Track a page view
814
- * @param data - Optional page view data (auto-filled from browser if not provided)
815
- * @example
816
- * ```tsx
817
- * // Auto-detect page info
818
- * await trackPageView()
819
- *
820
- * // Custom page info
821
- * await trackPageView({
822
- * page_url: '/checkout',
823
- * page_title: 'Checkout',
824
- * properties: { cart_value: 99.99 }
825
- * })
826
- * ```
827
- */
828
- trackPageView: (data?: PageViewData) => Promise<TrackEventResponse>;
829
- /**
830
- * Track multiple events in a batch
831
- * @param events - Array of events to track
832
- * @example
833
- * ```tsx
834
- * await trackBatch([
835
- * { event_name: 'item_added', properties: { item_id: '123' } },
836
- * { event_name: 'cart_updated', properties: { total: 49.99 } }
837
- * ])
838
- * ```
839
- */
840
- trackBatch: (events: AnalyticsEvent[]) => Promise<TrackEventResponse>;
841
- /**
842
- * Identify user for analytics (call after login)
843
- * Merges anonymous activity with user profile
844
- * @param userId - User ID to associate with events
845
- * @param traits - Optional user traits
846
- */
847
- identify: (userId: string, traits?: Record<string, unknown>) => Promise<void>;
848
- /**
849
- * Reset analytics session (call on logout)
850
- * Clears user association but keeps anonymous ID
851
- */
852
- reset: () => void;
853
- /**
854
- * Set UTM parameters manually (auto-captured from URL by default)
855
- */
856
- setUtmParams: (params: UTMParams) => void;
857
- /**
858
- * Get device info for current browser/device
859
- */
860
- getDeviceInfo: () => DeviceInfo;
861
- }
862
- interface ConnectedAccount {
863
- id: string;
864
- email: string;
865
- country: string;
866
- status: 'pending' | 'onboarding' | 'active' | 'restricted' | 'disabled';
867
- charges_enabled: boolean;
868
- payouts_enabled: boolean;
869
- onboarding_complete: boolean;
870
- details_submitted: boolean;
871
- metadata?: Record<string, unknown>;
872
- created_at: string;
873
- updated_at: string;
874
- }
875
- interface AccountBalance {
876
- currency: string;
877
- available_cents: number;
878
- pending_cents: number;
879
- reserved_cents: number;
880
- }
881
- interface BillingPayment {
882
- id: string;
883
- customer_id: string;
884
- connected_account_id?: string;
885
- amount_cents: number;
886
- currency: string;
887
- platform_fee_cents: number;
888
- provider_fee_cents: number;
889
- creator_net_cents: number;
890
- status: string;
891
- payment_type?: string;
892
- client_secret?: string;
893
- metadata?: Record<string, unknown>;
894
- created_at: string;
895
- }
896
- interface BillingRefund {
897
- id: string;
898
- payment_id: string;
899
- amount_cents: number;
900
- platform_fee_reversal_cents: number;
901
- reason?: string;
902
- status: string;
903
- created_at: string;
904
- }
905
- interface BillingPayout {
906
- id: string;
907
- amount_cents: number;
908
- currency: string;
909
- status: string;
910
- arrival_date?: string;
911
- created_at: string;
912
- }
913
- interface PayoutSchedule {
914
- schedule_interval: string;
915
- minimum_amount_cents: number;
916
- day_of_week?: number;
917
- day_of_month?: number;
918
- }
919
- interface BillingTransaction {
920
- id: string;
921
- entry_type: string;
922
- account_type: string;
923
- amount_cents: number;
924
- currency: string;
925
- category: string;
926
- reference_type: string;
927
- description?: string;
928
- created_at: string;
929
- }
930
- interface TransactionSummary {
931
- gross_cents: number;
932
- platform_fee_cents: number;
933
- net_cents: number;
934
- payout_cents: number;
935
- refund_cents: number;
936
- }
937
- interface UseBillingReturn {
938
- loading: boolean;
939
- error: ApiError | null;
940
- createConnectedAccount: (data: {
941
- email: string;
942
- country?: string;
943
- }) => Promise<ConnectedAccount | null>;
944
- getMyConnectedAccount: () => Promise<ConnectedAccount | null>;
945
- getConnectedAccount: (id: string) => Promise<ConnectedAccount | null>;
946
- createOnboardingLink: (id: string, data: {
947
- return_url: string;
948
- refresh_url: string;
949
- }) => Promise<string | null>;
950
- getAccountBalance: (id: string) => Promise<AccountBalance | null>;
951
- createPayment: (data: {
952
- amount_cents: number;
953
- currency?: string;
954
- connected_account_id?: string;
955
- platform_fee_percent?: number;
956
- platform_fee_cents?: number;
957
- payment_type?: string;
958
- metadata?: Record<string, unknown>;
959
- }) => Promise<BillingPayment | null>;
960
- getPayment: (id: string) => Promise<BillingPayment | null>;
961
- listPayments: (params?: Record<string, unknown>) => Promise<BillingPayment[]>;
962
- refundPayment: (id: string, data?: {
963
- amount_cents?: number;
964
- reason?: string;
965
- }) => Promise<BillingRefund | null>;
966
- getPayoutHistory: (accountId: string, params?: Record<string, unknown>) => Promise<BillingPayout[]>;
967
- getPayoutSchedule: (accountId: string) => Promise<PayoutSchedule | null>;
968
- setPayoutSchedule: (accountId: string, data: {
969
- schedule_interval: string;
970
- minimum_amount_cents?: number;
971
- }) => Promise<PayoutSchedule | null>;
972
- getTransactions: (params?: Record<string, unknown>) => Promise<BillingTransaction[]>;
973
- getTransactionSummary: (params?: Record<string, unknown>) => Promise<TransactionSummary | null>;
974
- createSetupSession: (data: {
975
- return_url: string;
976
- cancel_url: string;
977
- }) => Promise<string | null>;
978
- }
979
-
980
- export { type PhoneVerifyRequest as $, type ApiError as A, type BatchTrackRequest as B, type ChangeEmailRequest as C, type DeviceFingerprint as D, type EnhancedAnalyticsEvent as E, type ForgotPasswordRequest as F, type LoginRiskInfo as G, type MFAMethod as H, type MFASMSSetupResponse as I, type MFASetupRequest as J, type KnownAccountInfo as K, type LoginResponse as L, type MFAChallengeResponse as M, type MFAStatus as N, type MFATOTPSetupResponse as O, type MFAVerifyRequest as P, type OAuthCallbackRequest as Q, type OAuthCallbackResponse as R, type ScaleMuleConfig as S, type OAuthConfig as T, type User as U, type OAuthProvider as V, type OAuthStartResponse as W, type PageViewData as X, type PayoutSchedule as Y, type PhoneLoginRequest as Z, type PhoneSendCodeRequest as _, type UseAuthReturn as a, type Profile as a0, type ProxyBearerLoginResponse as a1, type RefreshResponse as a2, type RegisterRequest as a3, type ResetPasswordRequest as a4, ScaleMuleApiError as a5, type ScaleMuleEnvironment as a6, type Session as a7, type SignedUploadCompleteRequest as a8, type SignedUploadRequest as a9, type SignedUploadResponse as aa, type SignedUploadUrl as ab, type StorageAdapter as ac, type StorageFile as ad, type TrackEventResponse as ae, type TransactionSummary as af, type UTMParams as ag, type UpdateProfileRequest as ah, type UploadOptions as ai, type UploadResponse as aj, type VerifyEmailRequest as ak, type UseBillingReturn as b, type ListFilesParams as c, type UseContentReturn as d, type UseUserReturn as e, type UseAnalyticsOptions as f, type UseAnalyticsReturn as g, type AccountBalance as h, type AnalyticsEvent as i, type ApiResponse as j, type AuthLoginResponse as k, type BillingPayment as l, type BillingPayout as m, type BillingRefund as n, type BillingTransaction as o, type ChangePasswordRequest as p, type ClientContext as q, type ConnectedAccount as r, type CookieLoginResponse as s, type CookieOAuthCallbackResponse as t, type DeviceInfo as u, type LinkedAccount as v, type ListFilesResponse as w, type LoginDeviceInfo as x, type LoginRequest as y, type LoginResponseWithMFA as z };