@scalemule/nextjs 0.1.52 → 0.1.53
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/README.md +51 -5
- package/dist/client.d.mts +6 -1
- package/dist/client.d.ts +6 -1
- package/dist/client.js +24 -4
- package/dist/client.mjs +24 -4
- package/dist/{index-BQgmT53x.d.mts → index-2PnO4RAF.d.mts} +19 -5
- package/dist/{index-BQgmT53x.d.ts → index-2PnO4RAF.d.ts} +19 -5
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +88 -39
- package/dist/index.mjs +88 -39
- package/dist/server/auth.d.mts +7 -2
- package/dist/server/auth.d.ts +7 -2
- package/dist/server/auth.js +231 -38
- package/dist/server/auth.mjs +231 -39
- package/dist/server/index.d.mts +24 -5
- package/dist/server/index.d.ts +24 -5
- package/dist/server/index.js +256 -64
- package/dist/server/index.mjs +256 -64
- package/dist/server/webhook-handler.d.mts +2 -2
- package/dist/server/webhook-handler.d.ts +2 -2
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/{webhook-handler-44RRJH-r.d.ts → webhook-handler-1nnrmWT0.d.ts} +11 -1
- package/dist/{webhook-handler-DKt6H8FB.d.mts → webhook-handler-DNpCXDDA.d.mts} +11 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ npm install @scalemule/nextjs
|
|
|
20
20
|
// app/api/auth/[...scalemule]/route.ts
|
|
21
21
|
import { createAuthRoutes } from '@scalemule/nextjs/server'
|
|
22
22
|
|
|
23
|
-
export const { GET, POST, DELETE, PATCH } = createAuthRoutes()
|
|
23
|
+
export const { GET, POST, PUT, DELETE, PATCH } = createAuthRoutes()
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
This creates all auth endpoints automatically:
|
|
@@ -81,7 +81,7 @@ SCALEMULE_COOKIE_DOMAIN=.yourdomain.com # optional, for subdomain sharing
|
|
|
81
81
|
## Auth Route Options
|
|
82
82
|
|
|
83
83
|
```ts
|
|
84
|
-
export const { GET, POST, DELETE, PATCH } = createAuthRoutes({
|
|
84
|
+
export const { GET, POST, PUT, DELETE, PATCH } = createAuthRoutes({
|
|
85
85
|
// CSRF validation (recommended for production)
|
|
86
86
|
csrf: true,
|
|
87
87
|
|
|
@@ -125,7 +125,7 @@ For zero-config auth (reads from env vars):
|
|
|
125
125
|
|
|
126
126
|
```ts
|
|
127
127
|
// app/api/auth/[...scalemule]/route.ts
|
|
128
|
-
export { GET, POST, DELETE, PATCH } from '@scalemule/nextjs/server/auth'
|
|
128
|
+
export { GET, POST, PUT, DELETE, PATCH } from '@scalemule/nextjs/server/auth'
|
|
129
129
|
```
|
|
130
130
|
|
|
131
131
|
## Proxy Mode (keep API keys server-side)
|
|
@@ -134,7 +134,7 @@ If you don't want a real ScaleMule API key in browser bundles, run the SDK in **
|
|
|
134
134
|
|
|
135
135
|
```ts
|
|
136
136
|
// app/api/auth/[...scalemule]/route.ts
|
|
137
|
-
export { GET, POST, DELETE, PATCH } from '@scalemule/nextjs/server/auth'
|
|
137
|
+
export { GET, POST, PUT, DELETE, PATCH } from '@scalemule/nextjs/server/auth'
|
|
138
138
|
```
|
|
139
139
|
|
|
140
140
|
```ts
|
|
@@ -359,7 +359,7 @@ export function middleware(request) {
|
|
|
359
359
|
### Enable in Auth Routes
|
|
360
360
|
|
|
361
361
|
```ts
|
|
362
|
-
export const { GET, POST, DELETE, PATCH } = createAuthRoutes({
|
|
362
|
+
export const { GET, POST, PUT, DELETE, PATCH } = createAuthRoutes({
|
|
363
363
|
csrf: true, // validates x-csrf-token header against cookie
|
|
364
364
|
})
|
|
365
365
|
```
|
|
@@ -458,3 +458,49 @@ For signed URLs, supply `onRefresh(signal)` returning a fresh `AudioPlayerSource
|
|
|
458
458
|
Customize `--sm-audio-accent`, `--sm-audio-ink`, `--sm-audio-muted`, `--sm-audio-track`, and `--sm-audio-wave` on `className` or `style`, retaining accessible contrast. Default accent/track contrast is over 4:1. Keep the player outside a navigation link; links and playback controls need separate interaction targets.
|
|
459
459
|
|
|
460
460
|
This patch adds reusable presentation and bounded playback recovery. It does not change media storage, transcoding, TTS generation or entitlement enforcement.
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
### Cookie-only browser sessions
|
|
464
|
+
|
|
465
|
+
`ScaleMuleProvider` with `authProxyUrl` and `createAuthRoutes()` now keep the
|
|
466
|
+
session token exclusively in HTTP-only cookies. Auth JSON returns identity and
|
|
467
|
+
`authenticated`, never `sessionToken`. The provider clears credentials persisted
|
|
468
|
+
by older SDKs and sends data calls through `<authProxyUrl>/client`. Realtime uses
|
|
469
|
+
30-second, single-use WebSocket tickets; it never receives the session token.
|
|
470
|
+
|
|
471
|
+
Export **GET, POST, PUT, PATCH, DELETE** from your auth catch-all route. Set
|
|
472
|
+
`NEXT_PUBLIC_SCALEMULE_PUBLISHABLE_KEY` (or the factory's `publishableKey`) and use
|
|
473
|
+
the same `NEXT_PUBLIC_SCALEMULE_GATEWAY_URL` as the browser provider. This preserves
|
|
474
|
+
WebSocket ticket routing when server auth uses a dedicated cell gateway. The data
|
|
475
|
+
proxy uses only the publishable key plus the cookie session, rejects cross-origin
|
|
476
|
+
requests, and never forwards a browser-supplied credential or internal header.
|
|
477
|
+
|
|
478
|
+
For an app directly behind an AWS ALB in append mode, set
|
|
479
|
+
`createAuthRoutes({ clientContext: { trustedIpHeader: 'x-forwarded-for' } })`.
|
|
480
|
+
This attests only the final ALB-added hop and ignores `X-Real-IP` and CDN headers.
|
|
481
|
+
Choose a different header only when your actual ingress overwrites it and direct
|
|
482
|
+
access to the origin is restricted. The legacy automatic context helper is kept
|
|
483
|
+
for existing Hosting ingress integrations; it is not a trust-boundary detector.
|
|
484
|
+
|
|
485
|
+
Custom authentication callbacks must set cookies with `withSession`, return user
|
|
486
|
+
identity, and refresh `/api/auth/me` in the browser. Do not return a session token
|
|
487
|
+
in JSON, HTML, postMessage, or browser storage. Direct/native SDK authentication
|
|
488
|
+
and member-auth providers continue to use their existing token transport.
|
|
489
|
+
An explicit temporary compatibility mode, `sessionMode: 'bearer'`, exists on both
|
|
490
|
+
provider and route factory for applications migrating custom transports; it
|
|
491
|
+
exposes the session to JavaScript and should not be used for new browser apps.
|
|
492
|
+
|
|
493
|
+
The built-in sign-in dialog inherits the host's theme through `--sm-security-text`,
|
|
494
|
+
`--sm-security-background`, `--sm-security-border`, and `--sm-security-accent`.
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
For OAuth popups authenticating embedded frames, call
|
|
498
|
+
`createServerClient().auth.createSessionHandoff(sessionToken, audience)` only in
|
|
499
|
+
the server callback after successful OAuth. Send its `code` to the exact opener
|
|
500
|
+
origin. The iframe posts `{ code }` to `<authProxyUrl>/handoff/exchange` and then
|
|
501
|
+
refreshes `/me`. Configure the factory's fixed `handoffAudience` and
|
|
502
|
+
`cookies: { partitioned: true, sameSite: 'none', secure: true }`. This same cookie policy governs login, handoff, rotation and logout. Codes last
|
|
503
|
+
60 seconds, are tenant/audience-bound, consume atomically once, and cannot recover
|
|
504
|
+
a revoked session. The platform requires the customer's secret API key to issue
|
|
505
|
+
or consume them. Never expose a generic browser endpoint for issuing codes from
|
|
506
|
+
an existing cookie, and never place the session itself in a popup payload.
|
package/dist/client.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ac as StorageAdapter, A as ApiError } from './index-2PnO4RAF.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* ScaleMule API Client
|
|
@@ -12,6 +12,8 @@ import { a8 as StorageAdapter, A as ApiError } from './index-BQgmT53x.mjs';
|
|
|
12
12
|
|
|
13
13
|
type ScaleMuleEnvironment = 'dev' | 'prod';
|
|
14
14
|
interface ClientConfig {
|
|
15
|
+
/** Keep sessions exclusively in HTTP-only cookies. */
|
|
16
|
+
cookieSession?: boolean;
|
|
15
17
|
/** Your ScaleMule API key */
|
|
16
18
|
apiKey: string;
|
|
17
19
|
/** Your ScaleMule Application ID (required for realtime features) */
|
|
@@ -68,6 +70,7 @@ declare class ScaleMuleClient {
|
|
|
68
70
|
private gatewayUrl;
|
|
69
71
|
private debug;
|
|
70
72
|
private storage;
|
|
73
|
+
private cookieSession;
|
|
71
74
|
private sessionToken;
|
|
72
75
|
private userId;
|
|
73
76
|
private rateLimitQueue;
|
|
@@ -164,6 +167,8 @@ declare class ScaleMuleClient {
|
|
|
164
167
|
*
|
|
165
168
|
* Pass `null` to clear without touching userId/storage.
|
|
166
169
|
*/
|
|
170
|
+
setCookieSession(userId: string | null): void;
|
|
171
|
+
usesCookieSession(): boolean;
|
|
167
172
|
setSessionToken(token: string | null): void;
|
|
168
173
|
/**
|
|
169
174
|
* Clear session on logout
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ac as StorageAdapter, A as ApiError } from './index-2PnO4RAF.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* ScaleMule API Client
|
|
@@ -12,6 +12,8 @@ import { a8 as StorageAdapter, A as ApiError } from './index-BQgmT53x.js';
|
|
|
12
12
|
|
|
13
13
|
type ScaleMuleEnvironment = 'dev' | 'prod';
|
|
14
14
|
interface ClientConfig {
|
|
15
|
+
/** Keep sessions exclusively in HTTP-only cookies. */
|
|
16
|
+
cookieSession?: boolean;
|
|
15
17
|
/** Your ScaleMule API key */
|
|
16
18
|
apiKey: string;
|
|
17
19
|
/** Your ScaleMule Application ID (required for realtime features) */
|
|
@@ -68,6 +70,7 @@ declare class ScaleMuleClient {
|
|
|
68
70
|
private gatewayUrl;
|
|
69
71
|
private debug;
|
|
70
72
|
private storage;
|
|
73
|
+
private cookieSession;
|
|
71
74
|
private sessionToken;
|
|
72
75
|
private userId;
|
|
73
76
|
private rateLimitQueue;
|
|
@@ -164,6 +167,8 @@ declare class ScaleMuleClient {
|
|
|
164
167
|
*
|
|
165
168
|
* Pass `null` to clear without touching userId/storage.
|
|
166
169
|
*/
|
|
170
|
+
setCookieSession(userId: string | null): void;
|
|
171
|
+
usesCookieSession(): boolean;
|
|
167
172
|
setSessionToken(token: string | null): void;
|
|
168
173
|
/**
|
|
169
174
|
* Clear session on logout
|
package/dist/client.js
CHANGED
|
@@ -314,6 +314,7 @@ var ScaleMuleClient = class {
|
|
|
314
314
|
// The shared helper also single-flights at the storage-adapter level.
|
|
315
315
|
this.anonymousIdPromise = null;
|
|
316
316
|
this.refreshPromise = null;
|
|
317
|
+
this.cookieSession = config.cookieSession === true;
|
|
317
318
|
this.apiKey = config.apiKey;
|
|
318
319
|
this.applicationId = config.applicationId || null;
|
|
319
320
|
this.gatewayUrl = resolveGatewayUrl(config);
|
|
@@ -443,8 +444,13 @@ var ScaleMuleClient = class {
|
|
|
443
444
|
* Initialize client by loading persisted session
|
|
444
445
|
*/
|
|
445
446
|
async initialize() {
|
|
446
|
-
|
|
447
|
-
|
|
447
|
+
if (this.cookieSession) {
|
|
448
|
+
await this.storage.removeItem(SESSION_STORAGE_KEY);
|
|
449
|
+
await this.storage.removeItem(sdk.STORAGE_KEYS.SESSION_POOL);
|
|
450
|
+
await this.storage.removeItem(sdk.STORAGE_KEYS.ACTIVE_ACCOUNT);
|
|
451
|
+
}
|
|
452
|
+
const token = this.cookieSession ? null : await this.storage.getItem(SESSION_STORAGE_KEY);
|
|
453
|
+
const userId = this.cookieSession ? null : await this.storage.getItem(USER_ID_STORAGE_KEY);
|
|
448
454
|
if (token) this.sessionToken = token;
|
|
449
455
|
if (userId) this.userId = userId;
|
|
450
456
|
const wsId = await this.storage.getItem(WORKSPACE_STORAGE_KEY);
|
|
@@ -490,6 +496,11 @@ var ScaleMuleClient = class {
|
|
|
490
496
|
* Set session after login
|
|
491
497
|
*/
|
|
492
498
|
async setSession(token, userId) {
|
|
499
|
+
if (this.cookieSession) {
|
|
500
|
+
this.setCookieSession(userId);
|
|
501
|
+
await this.storage.removeItem(SESSION_STORAGE_KEY);
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
493
504
|
this.sessionToken = token;
|
|
494
505
|
this.userId = userId;
|
|
495
506
|
await this.storage.setItem(SESSION_STORAGE_KEY, token);
|
|
@@ -510,8 +521,17 @@ var ScaleMuleClient = class {
|
|
|
510
521
|
*
|
|
511
522
|
* Pass `null` to clear without touching userId/storage.
|
|
512
523
|
*/
|
|
524
|
+
setCookieSession(userId) {
|
|
525
|
+
if (!this.cookieSession) return;
|
|
526
|
+
this.sessionToken = null;
|
|
527
|
+
this.userId = userId;
|
|
528
|
+
this.resolveSessionPending();
|
|
529
|
+
}
|
|
530
|
+
usesCookieSession() {
|
|
531
|
+
return this.cookieSession;
|
|
532
|
+
}
|
|
513
533
|
setSessionToken(token) {
|
|
514
|
-
this.sessionToken = token;
|
|
534
|
+
this.sessionToken = this.cookieSession ? null : token;
|
|
515
535
|
if (this.debug) {
|
|
516
536
|
console.log("[ScaleMule] Session token", token ? "set (token-only)" : "cleared (token-only)");
|
|
517
537
|
}
|
|
@@ -546,7 +566,7 @@ var ScaleMuleClient = class {
|
|
|
546
566
|
* Check if client has an active session
|
|
547
567
|
*/
|
|
548
568
|
isAuthenticated() {
|
|
549
|
-
return this.sessionToken !== null && this.userId !== null;
|
|
569
|
+
return (this.cookieSession || this.sessionToken !== null) && this.userId !== null;
|
|
550
570
|
}
|
|
551
571
|
/**
|
|
552
572
|
* Build headers for a request
|
package/dist/client.mjs
CHANGED
|
@@ -312,6 +312,7 @@ var ScaleMuleClient = class {
|
|
|
312
312
|
// The shared helper also single-flights at the storage-adapter level.
|
|
313
313
|
this.anonymousIdPromise = null;
|
|
314
314
|
this.refreshPromise = null;
|
|
315
|
+
this.cookieSession = config.cookieSession === true;
|
|
315
316
|
this.apiKey = config.apiKey;
|
|
316
317
|
this.applicationId = config.applicationId || null;
|
|
317
318
|
this.gatewayUrl = resolveGatewayUrl(config);
|
|
@@ -441,8 +442,13 @@ var ScaleMuleClient = class {
|
|
|
441
442
|
* Initialize client by loading persisted session
|
|
442
443
|
*/
|
|
443
444
|
async initialize() {
|
|
444
|
-
|
|
445
|
-
|
|
445
|
+
if (this.cookieSession) {
|
|
446
|
+
await this.storage.removeItem(SESSION_STORAGE_KEY);
|
|
447
|
+
await this.storage.removeItem(STORAGE_KEYS.SESSION_POOL);
|
|
448
|
+
await this.storage.removeItem(STORAGE_KEYS.ACTIVE_ACCOUNT);
|
|
449
|
+
}
|
|
450
|
+
const token = this.cookieSession ? null : await this.storage.getItem(SESSION_STORAGE_KEY);
|
|
451
|
+
const userId = this.cookieSession ? null : await this.storage.getItem(USER_ID_STORAGE_KEY);
|
|
446
452
|
if (token) this.sessionToken = token;
|
|
447
453
|
if (userId) this.userId = userId;
|
|
448
454
|
const wsId = await this.storage.getItem(WORKSPACE_STORAGE_KEY);
|
|
@@ -488,6 +494,11 @@ var ScaleMuleClient = class {
|
|
|
488
494
|
* Set session after login
|
|
489
495
|
*/
|
|
490
496
|
async setSession(token, userId) {
|
|
497
|
+
if (this.cookieSession) {
|
|
498
|
+
this.setCookieSession(userId);
|
|
499
|
+
await this.storage.removeItem(SESSION_STORAGE_KEY);
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
491
502
|
this.sessionToken = token;
|
|
492
503
|
this.userId = userId;
|
|
493
504
|
await this.storage.setItem(SESSION_STORAGE_KEY, token);
|
|
@@ -508,8 +519,17 @@ var ScaleMuleClient = class {
|
|
|
508
519
|
*
|
|
509
520
|
* Pass `null` to clear without touching userId/storage.
|
|
510
521
|
*/
|
|
522
|
+
setCookieSession(userId) {
|
|
523
|
+
if (!this.cookieSession) return;
|
|
524
|
+
this.sessionToken = null;
|
|
525
|
+
this.userId = userId;
|
|
526
|
+
this.resolveSessionPending();
|
|
527
|
+
}
|
|
528
|
+
usesCookieSession() {
|
|
529
|
+
return this.cookieSession;
|
|
530
|
+
}
|
|
511
531
|
setSessionToken(token) {
|
|
512
|
-
this.sessionToken = token;
|
|
532
|
+
this.sessionToken = this.cookieSession ? null : token;
|
|
513
533
|
if (this.debug) {
|
|
514
534
|
console.log("[ScaleMule] Session token", token ? "set (token-only)" : "cleared (token-only)");
|
|
515
535
|
}
|
|
@@ -544,7 +564,7 @@ var ScaleMuleClient = class {
|
|
|
544
564
|
* Check if client has an active session
|
|
545
565
|
*/
|
|
546
566
|
isAuthenticated() {
|
|
547
|
-
return this.sessionToken !== null && this.userId !== null;
|
|
567
|
+
return (this.cookieSession || this.sessionToken !== null) && this.userId !== null;
|
|
548
568
|
}
|
|
549
569
|
/**
|
|
550
570
|
* Build headers for a request
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
type ScaleMuleEnvironment = 'dev' | 'prod';
|
|
7
7
|
interface ScaleMuleConfig {
|
|
8
|
+
/** Explicit legacy bearer transport; auth proxies default to HTTP-only cookie transport. */
|
|
9
|
+
sessionMode?: 'cookie' | 'bearer';
|
|
8
10
|
/** Your ScaleMule API key */
|
|
9
11
|
apiKey: string;
|
|
10
12
|
/** Your ScaleMule Application ID (required for realtime features) */
|
|
@@ -199,6 +201,18 @@ interface LoginResponse {
|
|
|
199
201
|
device?: LoginDeviceInfo;
|
|
200
202
|
risk?: LoginRiskInfo;
|
|
201
203
|
}
|
|
204
|
+
/** Browser auth succeeds through an HTTP-only cookie; no token is returned. */
|
|
205
|
+
interface CookieLoginResponse {
|
|
206
|
+
authenticated: true;
|
|
207
|
+
user: User;
|
|
208
|
+
userId: string;
|
|
209
|
+
}
|
|
210
|
+
/** Legacy custom proxies may omit the backend's session expiry metadata. */
|
|
211
|
+
type ProxyBearerLoginResponse = Pick<LoginResponse, 'session_token' | 'user'> & Partial<Omit<LoginResponse, 'session_token' | 'user'>>;
|
|
212
|
+
type AuthLoginResponse = LoginResponse | CookieLoginResponse | ProxyBearerLoginResponse;
|
|
213
|
+
type CookieOAuthCallbackResponse = Omit<OAuthCallbackResponse, 'session_token'> & {
|
|
214
|
+
authenticated: true;
|
|
215
|
+
};
|
|
202
216
|
interface LoginDeviceInfo {
|
|
203
217
|
id: string;
|
|
204
218
|
name: string;
|
|
@@ -481,7 +495,7 @@ interface UseAuthReturn {
|
|
|
481
495
|
/** Register a new user */
|
|
482
496
|
register: (data: RegisterRequest) => Promise<User>;
|
|
483
497
|
/** Login with email/password (may return MFA challenge) */
|
|
484
|
-
login: (data: LoginRequest) => Promise<
|
|
498
|
+
login: (data: LoginRequest) => Promise<AuthLoginResponse | LoginResponseWithMFA>;
|
|
485
499
|
/** Logout current user */
|
|
486
500
|
logout: () => Promise<void>;
|
|
487
501
|
/** Request password reset email */
|
|
@@ -497,7 +511,7 @@ interface UseAuthReturn {
|
|
|
497
511
|
/** Start OAuth flow for a provider */
|
|
498
512
|
startOAuth: (config: OAuthConfig) => Promise<OAuthStartResponse>;
|
|
499
513
|
/** Complete OAuth flow after redirect */
|
|
500
|
-
completeOAuth: (request: OAuthCallbackRequest) => Promise<OAuthCallbackResponse>;
|
|
514
|
+
completeOAuth: (request: OAuthCallbackRequest) => Promise<OAuthCallbackResponse | CookieOAuthCallbackResponse>;
|
|
501
515
|
/** Get list of linked OAuth accounts */
|
|
502
516
|
getLinkedAccounts: () => Promise<LinkedAccount[]>;
|
|
503
517
|
/** Link a new OAuth account */
|
|
@@ -511,7 +525,7 @@ interface UseAuthReturn {
|
|
|
511
525
|
/** Verify and enable MFA */
|
|
512
526
|
verifyMFA: (request: MFAVerifyRequest) => Promise<void>;
|
|
513
527
|
/** Complete MFA challenge during login */
|
|
514
|
-
completeMFAChallenge: (challengeToken: string, code: string, method: MFAMethod) => Promise<
|
|
528
|
+
completeMFAChallenge: (challengeToken: string, code: string, method: MFAMethod) => Promise<AuthLoginResponse>;
|
|
515
529
|
/** Disable MFA */
|
|
516
530
|
disableMFA: (password: string) => Promise<void>;
|
|
517
531
|
/** Regenerate backup codes */
|
|
@@ -521,7 +535,7 @@ interface UseAuthReturn {
|
|
|
521
535
|
/** Verify phone number */
|
|
522
536
|
verifyPhone: (request: PhoneVerifyRequest) => Promise<void>;
|
|
523
537
|
/** Login with phone number */
|
|
524
|
-
loginWithPhone: (request: PhoneLoginRequest) => Promise<
|
|
538
|
+
loginWithPhone: (request: PhoneLoginRequest) => Promise<AuthLoginResponse>;
|
|
525
539
|
/**
|
|
526
540
|
* All accounts that have previously logged in on this device.
|
|
527
541
|
* Contains display metadata only — no tokens.
|
|
@@ -958,4 +972,4 @@ interface UseBillingReturn {
|
|
|
958
972
|
}) => Promise<string | null>;
|
|
959
973
|
}
|
|
960
974
|
|
|
961
|
-
export { type
|
|
975
|
+
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 };
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
type ScaleMuleEnvironment = 'dev' | 'prod';
|
|
7
7
|
interface ScaleMuleConfig {
|
|
8
|
+
/** Explicit legacy bearer transport; auth proxies default to HTTP-only cookie transport. */
|
|
9
|
+
sessionMode?: 'cookie' | 'bearer';
|
|
8
10
|
/** Your ScaleMule API key */
|
|
9
11
|
apiKey: string;
|
|
10
12
|
/** Your ScaleMule Application ID (required for realtime features) */
|
|
@@ -199,6 +201,18 @@ interface LoginResponse {
|
|
|
199
201
|
device?: LoginDeviceInfo;
|
|
200
202
|
risk?: LoginRiskInfo;
|
|
201
203
|
}
|
|
204
|
+
/** Browser auth succeeds through an HTTP-only cookie; no token is returned. */
|
|
205
|
+
interface CookieLoginResponse {
|
|
206
|
+
authenticated: true;
|
|
207
|
+
user: User;
|
|
208
|
+
userId: string;
|
|
209
|
+
}
|
|
210
|
+
/** Legacy custom proxies may omit the backend's session expiry metadata. */
|
|
211
|
+
type ProxyBearerLoginResponse = Pick<LoginResponse, 'session_token' | 'user'> & Partial<Omit<LoginResponse, 'session_token' | 'user'>>;
|
|
212
|
+
type AuthLoginResponse = LoginResponse | CookieLoginResponse | ProxyBearerLoginResponse;
|
|
213
|
+
type CookieOAuthCallbackResponse = Omit<OAuthCallbackResponse, 'session_token'> & {
|
|
214
|
+
authenticated: true;
|
|
215
|
+
};
|
|
202
216
|
interface LoginDeviceInfo {
|
|
203
217
|
id: string;
|
|
204
218
|
name: string;
|
|
@@ -481,7 +495,7 @@ interface UseAuthReturn {
|
|
|
481
495
|
/** Register a new user */
|
|
482
496
|
register: (data: RegisterRequest) => Promise<User>;
|
|
483
497
|
/** Login with email/password (may return MFA challenge) */
|
|
484
|
-
login: (data: LoginRequest) => Promise<
|
|
498
|
+
login: (data: LoginRequest) => Promise<AuthLoginResponse | LoginResponseWithMFA>;
|
|
485
499
|
/** Logout current user */
|
|
486
500
|
logout: () => Promise<void>;
|
|
487
501
|
/** Request password reset email */
|
|
@@ -497,7 +511,7 @@ interface UseAuthReturn {
|
|
|
497
511
|
/** Start OAuth flow for a provider */
|
|
498
512
|
startOAuth: (config: OAuthConfig) => Promise<OAuthStartResponse>;
|
|
499
513
|
/** Complete OAuth flow after redirect */
|
|
500
|
-
completeOAuth: (request: OAuthCallbackRequest) => Promise<OAuthCallbackResponse>;
|
|
514
|
+
completeOAuth: (request: OAuthCallbackRequest) => Promise<OAuthCallbackResponse | CookieOAuthCallbackResponse>;
|
|
501
515
|
/** Get list of linked OAuth accounts */
|
|
502
516
|
getLinkedAccounts: () => Promise<LinkedAccount[]>;
|
|
503
517
|
/** Link a new OAuth account */
|
|
@@ -511,7 +525,7 @@ interface UseAuthReturn {
|
|
|
511
525
|
/** Verify and enable MFA */
|
|
512
526
|
verifyMFA: (request: MFAVerifyRequest) => Promise<void>;
|
|
513
527
|
/** Complete MFA challenge during login */
|
|
514
|
-
completeMFAChallenge: (challengeToken: string, code: string, method: MFAMethod) => Promise<
|
|
528
|
+
completeMFAChallenge: (challengeToken: string, code: string, method: MFAMethod) => Promise<AuthLoginResponse>;
|
|
515
529
|
/** Disable MFA */
|
|
516
530
|
disableMFA: (password: string) => Promise<void>;
|
|
517
531
|
/** Regenerate backup codes */
|
|
@@ -521,7 +535,7 @@ interface UseAuthReturn {
|
|
|
521
535
|
/** Verify phone number */
|
|
522
536
|
verifyPhone: (request: PhoneVerifyRequest) => Promise<void>;
|
|
523
537
|
/** Login with phone number */
|
|
524
|
-
loginWithPhone: (request: PhoneLoginRequest) => Promise<
|
|
538
|
+
loginWithPhone: (request: PhoneLoginRequest) => Promise<AuthLoginResponse>;
|
|
525
539
|
/**
|
|
526
540
|
* All accounts that have previously logged in on this device.
|
|
527
541
|
* Contains display metadata only — no tokens.
|
|
@@ -958,4 +972,4 @@ interface UseBillingReturn {
|
|
|
958
972
|
}) => Promise<string | null>;
|
|
959
973
|
}
|
|
960
974
|
|
|
961
|
-
export { type
|
|
975
|
+
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 };
|
package/dist/index.d.mts
CHANGED
|
@@ -6,8 +6,8 @@ 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-
|
|
10
|
-
export { h as AccountBalance, i as AnalyticsEvent, j as ApiResponse, B as BatchTrackRequest,
|
|
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';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Tri-state file visibility — `'private' | 'app_public' | 'anonymous_visible'`.
|
|
@@ -340,7 +340,7 @@ interface ScaleMuleProviderProps extends ScaleMuleConfig {
|
|
|
340
340
|
*/
|
|
341
341
|
memberTokenPollMs?: number | null;
|
|
342
342
|
}
|
|
343
|
-
declare function ScaleMuleProvider({ apiKey, applicationId, environment, gatewayUrl, debug, storage, analyticsProxyUrl, authProxyUrl, telemetryEndpoint, publishableKey, enableAccountSwitcher, accountSwitcherPrivacy, children, onLogin, onLogout, onAuthError, bootstrapFlags, mediaPolicy, getToken, userResolver, memberTokenPollMs, passwordRecoveryUrl, onSecurityChallenge, }: ScaleMuleProviderProps): react_jsx_runtime.JSX.Element;
|
|
343
|
+
declare function ScaleMuleProvider({ apiKey, applicationId, environment, gatewayUrl, debug, storage, analyticsProxyUrl, authProxyUrl, sessionMode, telemetryEndpoint, publishableKey, enableAccountSwitcher, accountSwitcherPrivacy, children, onLogin, onLogout, onAuthError, bootstrapFlags, mediaPolicy, getToken, userResolver, memberTokenPollMs, passwordRecoveryUrl, onSecurityChallenge, }: ScaleMuleProviderProps): react_jsx_runtime.JSX.Element;
|
|
344
344
|
declare function useScaleMule(): ScaleMuleContextValue;
|
|
345
345
|
declare function useScaleMuleClient(): ScaleMuleClient;
|
|
346
346
|
declare function useMoneyClient(): MoneyClient;
|
package/dist/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ 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-
|
|
10
|
-
export { h as AccountBalance, i as AnalyticsEvent, j as ApiResponse, B as BatchTrackRequest,
|
|
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';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Tri-state file visibility — `'private' | 'app_public' | 'anonymous_visible'`.
|
|
@@ -340,7 +340,7 @@ interface ScaleMuleProviderProps extends ScaleMuleConfig {
|
|
|
340
340
|
*/
|
|
341
341
|
memberTokenPollMs?: number | null;
|
|
342
342
|
}
|
|
343
|
-
declare function ScaleMuleProvider({ apiKey, applicationId, environment, gatewayUrl, debug, storage, analyticsProxyUrl, authProxyUrl, telemetryEndpoint, publishableKey, enableAccountSwitcher, accountSwitcherPrivacy, children, onLogin, onLogout, onAuthError, bootstrapFlags, mediaPolicy, getToken, userResolver, memberTokenPollMs, passwordRecoveryUrl, onSecurityChallenge, }: ScaleMuleProviderProps): react_jsx_runtime.JSX.Element;
|
|
343
|
+
declare function ScaleMuleProvider({ apiKey, applicationId, environment, gatewayUrl, debug, storage, analyticsProxyUrl, authProxyUrl, sessionMode, telemetryEndpoint, publishableKey, enableAccountSwitcher, accountSwitcherPrivacy, children, onLogin, onLogout, onAuthError, bootstrapFlags, mediaPolicy, getToken, userResolver, memberTokenPollMs, passwordRecoveryUrl, onSecurityChallenge, }: ScaleMuleProviderProps): react_jsx_runtime.JSX.Element;
|
|
344
344
|
declare function useScaleMule(): ScaleMuleContextValue;
|
|
345
345
|
declare function useScaleMuleClient(): ScaleMuleClient;
|
|
346
346
|
declare function useMoneyClient(): MoneyClient;
|