@scalemule/nextjs 0.0.39 → 0.0.40
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 +5 -1
- package/dist/client.d.ts +5 -1
- package/dist/{index-BoENfro3.d.mts → index-BIIUrnPr.d.mts} +54 -1
- package/dist/{index-BoENfro3.d.ts → index-BIIUrnPr.d.ts} +54 -1
- package/dist/index.d.mts +15 -4
- package/dist/index.d.ts +15 -4
- package/dist/index.js +176 -89
- package/dist/index.mjs +168 -90
- package/dist/server/auth.js +275 -6
- package/dist/server/auth.mjs +275 -6
- package/dist/server/index.d.mts +135 -4
- package/dist/server/index.d.ts +135 -4
- package/dist/server/index.js +333 -6
- package/dist/server/index.mjs +325 -7
- package/dist/server/webhook-handler.d.mts +3 -2
- package/dist/server/webhook-handler.d.ts +3 -2
- package/dist/server/webhook-handler.js +3 -0
- package/dist/server/webhook-handler.mjs +3 -0
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/{webhook-handler-CjSSCdvI.d.ts → webhook-handler-BjFbqZuq.d.ts} +4 -1
- package/dist/{webhook-handler-Cz9jtet2.d.mts → webhook-handler-BqzCYRNJ.d.mts} +4 -1
- package/package.json +3 -2
package/dist/server/index.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { S as ServerConfig } from '../webhook-handler-
|
|
2
|
-
export { a as ScaleMuleServer, V as VideoFailedEvent, b as VideoReadyEvent, c as VideoTranscodedEvent, d as VideoUploadedEvent, W as WebhookEvent, e as WebhookRoutesConfig, f as createServerClient, g as createWebhookHandler, h as createWebhookRoutes, p as parseWebhookEvent, r as registerVideoWebhook, i as resolveGatewayUrl, v as verifyWebhookSignature } from '../webhook-handler-
|
|
3
|
-
import { p as ClientContext, A as ApiError } from '../index-
|
|
1
|
+
import { S as ServerConfig } from '../webhook-handler-BqzCYRNJ.mjs';
|
|
2
|
+
export { a as ScaleMuleServer, V as VideoFailedEvent, b as VideoReadyEvent, c as VideoTranscodedEvent, d as VideoUploadedEvent, W as WebhookEvent, e as WebhookRoutesConfig, f as createServerClient, g as createWebhookHandler, h as createWebhookRoutes, p as parseWebhookEvent, r as registerVideoWebhook, i as resolveGatewayUrl, v as verifyWebhookSignature } from '../webhook-handler-BqzCYRNJ.mjs';
|
|
3
|
+
import { p as ClientContext, A as ApiError } from '../index-BIIUrnPr.mjs';
|
|
4
4
|
import { NextRequest, NextResponse } from 'next/server';
|
|
5
|
+
import '@scalemule/money';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Client Context Extraction Utilities (Next.js)
|
|
@@ -110,6 +111,12 @@ declare function buildFlagContext(clientContext: Pick<ClientContext, 'ip'> | und
|
|
|
110
111
|
*/
|
|
111
112
|
declare const SESSION_COOKIE_NAME = "sm_session";
|
|
112
113
|
declare const USER_ID_COOKIE_NAME = "sm_user_id";
|
|
114
|
+
/**
|
|
115
|
+
* Known accounts cookie — stores display metadata (email, name, avatar) for
|
|
116
|
+
* accounts that have logged in on this device. NOT httpOnly so client JS can
|
|
117
|
+
* read it to render the account switcher UI. Contains NO tokens or secrets.
|
|
118
|
+
*/
|
|
119
|
+
declare const KNOWN_ACCOUNTS_COOKIE_NAME = "sm_known_accounts";
|
|
113
120
|
interface SessionCookieOptions {
|
|
114
121
|
/** Cookie max age in seconds (default: 7 days) */
|
|
115
122
|
maxAge?: number;
|
|
@@ -181,6 +188,51 @@ declare function getSession(): Promise<SessionData | null>;
|
|
|
181
188
|
* Use this when you need to read cookies from a Request directly.
|
|
182
189
|
*/
|
|
183
190
|
declare function getSessionFromRequest(request: Request): SessionData | null;
|
|
191
|
+
/**
|
|
192
|
+
* Known account entry stored in cookie.
|
|
193
|
+
* Contains display metadata ONLY — no tokens, no secrets.
|
|
194
|
+
*/
|
|
195
|
+
interface KnownAccountEntry {
|
|
196
|
+
userId: string;
|
|
197
|
+
email?: string;
|
|
198
|
+
fullName?: string;
|
|
199
|
+
avatarUrl?: string;
|
|
200
|
+
provider?: string;
|
|
201
|
+
lastActiveAt: string;
|
|
202
|
+
displayLabel?: string;
|
|
203
|
+
colorIndex?: number;
|
|
204
|
+
}
|
|
205
|
+
type AccountSwitcherPrivacy = 'full' | 'masked' | 'minimal';
|
|
206
|
+
/**
|
|
207
|
+
* Add an account to the known accounts cookie.
|
|
208
|
+
* Called after successful login. The cookie is NOT httpOnly so client JS
|
|
209
|
+
* can read it to render the account switcher UI.
|
|
210
|
+
*
|
|
211
|
+
* Appends Set-Cookie headers to an existing Headers object.
|
|
212
|
+
*/
|
|
213
|
+
declare function appendKnownAccountCookie(headers: Headers, account: KnownAccountEntry, existingCookie: string | null, options?: SessionCookieOptions, privacy?: AccountSwitcherPrivacy): void;
|
|
214
|
+
/**
|
|
215
|
+
* Remove a specific account from the known accounts cookie.
|
|
216
|
+
*/
|
|
217
|
+
declare function removeKnownAccountFromCookie(headers: Headers, userId: string, existingCookie: string | null, options?: SessionCookieOptions): void;
|
|
218
|
+
/**
|
|
219
|
+
* Clear the known accounts cookie entirely.
|
|
220
|
+
*/
|
|
221
|
+
declare function clearKnownAccountsCookie(headers: Headers, options?: SessionCookieOptions): void;
|
|
222
|
+
/**
|
|
223
|
+
* Read known accounts from a Request's cookies.
|
|
224
|
+
*/
|
|
225
|
+
declare function getKnownAccountsFromRequest(request: Request): KnownAccountEntry[];
|
|
226
|
+
/**
|
|
227
|
+
* Read the raw known accounts cookie value from a Request.
|
|
228
|
+
*/
|
|
229
|
+
declare function getKnownAccountsCookieRaw(request: Request): string | null;
|
|
230
|
+
/**
|
|
231
|
+
* Normalize all entries in the known accounts cookie to the given privacy level.
|
|
232
|
+
* Returns a Set-Cookie header string if any entries changed, or null if nothing changed.
|
|
233
|
+
* Used on /me requests to migrate legacy full-PII cookies to the configured privacy level.
|
|
234
|
+
*/
|
|
235
|
+
declare function normalizeKnownAccountsCookie(request: Request, privacy: AccountSwitcherPrivacy | undefined, options?: SessionCookieOptions): string | null;
|
|
184
236
|
/**
|
|
185
237
|
* Require authentication - throws Response if not authenticated
|
|
186
238
|
*
|
|
@@ -220,6 +272,19 @@ interface AuthRoutesConfig {
|
|
|
220
272
|
cookies?: SessionCookieOptions;
|
|
221
273
|
/** Enable CSRF validation on state-changing requests (POST/DELETE/PATCH) */
|
|
222
274
|
csrf?: boolean;
|
|
275
|
+
/**
|
|
276
|
+
* Enable the account switcher — remembers which accounts have logged in on
|
|
277
|
+
* this device (metadata only, no tokens). Switching requires re-authentication.
|
|
278
|
+
* Adds routes: switch-account, forget-account, forget-all-accounts, known-accounts.
|
|
279
|
+
*/
|
|
280
|
+
enableAccountSwitcher?: boolean;
|
|
281
|
+
/**
|
|
282
|
+
* Privacy level for account switcher display metadata.
|
|
283
|
+
* - 'full': Store email, name, avatar as-is (default)
|
|
284
|
+
* - 'masked': Mask email, truncate name to initial
|
|
285
|
+
* - 'minimal': No PII — just a colored "Account" label
|
|
286
|
+
*/
|
|
287
|
+
accountSwitcherPrivacy?: 'full' | 'masked' | 'minimal';
|
|
223
288
|
/** Callbacks */
|
|
224
289
|
onLogin?: (user: {
|
|
225
290
|
id: string;
|
|
@@ -1011,4 +1076,70 @@ declare function invalidateBundleCache(key?: string): void;
|
|
|
1011
1076
|
*/
|
|
1012
1077
|
declare function prefetchBundles(keys: string[]): Promise<void>;
|
|
1013
1078
|
|
|
1014
|
-
|
|
1079
|
+
/**
|
|
1080
|
+
* Safe-redirect validation for authentication callback URLs.
|
|
1081
|
+
*
|
|
1082
|
+
* Prevents open-redirect attacks on `returnTo` / `callbackUrl` / `next`
|
|
1083
|
+
* params after login / registration / password-reset flows. An attacker
|
|
1084
|
+
* who can inject a `?returnTo=https://evil.example` into your login
|
|
1085
|
+
* form would otherwise redirect the freshly-authenticated user away
|
|
1086
|
+
* from your origin — a classic phishing + credential-harvesting setup.
|
|
1087
|
+
*
|
|
1088
|
+
* Safe by default — unknown input returns the configured default
|
|
1089
|
+
* path. Hosts opt in to external origins explicitly via
|
|
1090
|
+
* `allowedOrigins`.
|
|
1091
|
+
*
|
|
1092
|
+
* Framework-agnostic: no imports from `next/*`. Safe in any
|
|
1093
|
+
* Edge / Node / middleware runtime.
|
|
1094
|
+
*/
|
|
1095
|
+
interface SafeRedirectOptions {
|
|
1096
|
+
/**
|
|
1097
|
+
* Origins (schema + host + optional port) the redirect is allowed
|
|
1098
|
+
* to land on. Default `[]` — only same-origin relative paths are
|
|
1099
|
+
* allowed. Items are compared case-insensitively after normalizing
|
|
1100
|
+
* the scheme and host.
|
|
1101
|
+
*
|
|
1102
|
+
* Good practice: list only origins that your organization controls
|
|
1103
|
+
* and that are reachable over HTTPS.
|
|
1104
|
+
*
|
|
1105
|
+
* @example
|
|
1106
|
+
* ['https://app.example.com', 'https://admin.example.com']
|
|
1107
|
+
*/
|
|
1108
|
+
allowedOrigins?: string[];
|
|
1109
|
+
/**
|
|
1110
|
+
* Value returned when the input is missing, invalid, or points
|
|
1111
|
+
* outside the allowlist. Default `'/'`.
|
|
1112
|
+
*/
|
|
1113
|
+
defaultPath?: string;
|
|
1114
|
+
/**
|
|
1115
|
+
* Strip the scheme + host from same-origin absolute URLs and
|
|
1116
|
+
* return only the path + query + fragment. Default `true` — keeps
|
|
1117
|
+
* redirect targets as short relative URLs that route through
|
|
1118
|
+
* client-side routing cleanly.
|
|
1119
|
+
*/
|
|
1120
|
+
stripSameOriginHost?: boolean;
|
|
1121
|
+
}
|
|
1122
|
+
/**
|
|
1123
|
+
* Returns a safe-to-use redirect path, falling back to
|
|
1124
|
+
* `opts.defaultPath` (default `'/'`) when the input fails validation.
|
|
1125
|
+
*
|
|
1126
|
+
* Accepts:
|
|
1127
|
+
* - empty / nullish → default
|
|
1128
|
+
* - relative paths like `/foo/bar?x=1#frag` (leading `/` required)
|
|
1129
|
+
* - absolute URLs whose origin is in `allowedOrigins`
|
|
1130
|
+
*
|
|
1131
|
+
* Rejects everything else, including:
|
|
1132
|
+
* - schema-relative URLs (`//evil.example`)
|
|
1133
|
+
* - backslash-prefixed paths
|
|
1134
|
+
* - `javascript:`, `data:`, `mailto:`, `vbscript:` etc.
|
|
1135
|
+
* - bare hostnames (`example.com/path`)
|
|
1136
|
+
* - malformed URLs
|
|
1137
|
+
*/
|
|
1138
|
+
declare function validateSafeRedirect(input: string | null | undefined, opts?: SafeRedirectOptions): string;
|
|
1139
|
+
/**
|
|
1140
|
+
* Boolean predicate form. Returns `true` when `input` would pass
|
|
1141
|
+
* `validateSafeRedirect` with the same options.
|
|
1142
|
+
*/
|
|
1143
|
+
declare function isSafeRedirect(input: string | null | undefined, opts?: SafeRedirectOptions): boolean;
|
|
1144
|
+
|
|
1145
|
+
export { type AnalyticsRoutesConfig, type AnalyticsTrackingGateConfig, type AuthMiddlewareConfig, type AuthRoutesConfig, CSRF_COOKIE_NAME, CSRF_HEADER_NAME, type HandlerContext, type HandlerOptions, KNOWN_ACCOUNTS_COOKIE_NAME, type KnownAccountEntry, type MySqlBundle, type NotificationRoutesConfig, OAUTH_STATE_COOKIE_NAME, type OAuthBundle, type PostgresBundle, type PushRoutesConfig, type RedisBundle, type S3Bundle, SESSION_COOKIE_NAME, type SafeRedirectOptions, ScaleMuleError, ServerConfig, type SessionCookieOptions, type SessionData, type SmtpBundle, USER_ID_COOKIE_NAME, apiHandler, appendKnownAccountCookie, buildClientContextHeaders, buildFlagContext, clearKnownAccountsCookie, clearOAuthState, clearSession, configureBundles, configureSecrets, createAnalyticsRoutes, createAuthMiddleware, createAuthRoutes, createNotificationRoutes, createPushRoutes, errorCodeToStatus, extractClientContext, extractClientContextFromReq, generateCSRFToken, getAppSecret, getAppSecretOrDefault, getBootstrapFlags, getBundle, getCSRFToken, getKnownAccountsCookieRaw, getKnownAccountsFromRequest, getMySqlBundle, getOAuthBundle, getPostgresBundle, getRedisBundle, getS3Bundle, getSession, getSessionFromRequest, getSmtpBundle, invalidateBundleCache, invalidateSecretCache, isSafeRedirect, normalizeKnownAccountsCookie, prefetchBundles, prefetchSecrets, removeKnownAccountFromCookie, requireAppSecret, requireBundle, requireSession, setOAuthState, unwrap, validateCSRFToken, validateCSRFTokenAsync, validateOAuthState, validateOAuthStateAsync, validateSafeRedirect, withAuth, withCSRFProtection, withCSRFToken, withSession };
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { S as ServerConfig } from '../webhook-handler-
|
|
2
|
-
export { a as ScaleMuleServer, V as VideoFailedEvent, b as VideoReadyEvent, c as VideoTranscodedEvent, d as VideoUploadedEvent, W as WebhookEvent, e as WebhookRoutesConfig, f as createServerClient, g as createWebhookHandler, h as createWebhookRoutes, p as parseWebhookEvent, r as registerVideoWebhook, i as resolveGatewayUrl, v as verifyWebhookSignature } from '../webhook-handler-
|
|
3
|
-
import { p as ClientContext, A as ApiError } from '../index-
|
|
1
|
+
import { S as ServerConfig } from '../webhook-handler-BjFbqZuq.js';
|
|
2
|
+
export { a as ScaleMuleServer, V as VideoFailedEvent, b as VideoReadyEvent, c as VideoTranscodedEvent, d as VideoUploadedEvent, W as WebhookEvent, e as WebhookRoutesConfig, f as createServerClient, g as createWebhookHandler, h as createWebhookRoutes, p as parseWebhookEvent, r as registerVideoWebhook, i as resolveGatewayUrl, v as verifyWebhookSignature } from '../webhook-handler-BjFbqZuq.js';
|
|
3
|
+
import { p as ClientContext, A as ApiError } from '../index-BIIUrnPr.js';
|
|
4
4
|
import { NextRequest, NextResponse } from 'next/server';
|
|
5
|
+
import '@scalemule/money';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Client Context Extraction Utilities (Next.js)
|
|
@@ -110,6 +111,12 @@ declare function buildFlagContext(clientContext: Pick<ClientContext, 'ip'> | und
|
|
|
110
111
|
*/
|
|
111
112
|
declare const SESSION_COOKIE_NAME = "sm_session";
|
|
112
113
|
declare const USER_ID_COOKIE_NAME = "sm_user_id";
|
|
114
|
+
/**
|
|
115
|
+
* Known accounts cookie — stores display metadata (email, name, avatar) for
|
|
116
|
+
* accounts that have logged in on this device. NOT httpOnly so client JS can
|
|
117
|
+
* read it to render the account switcher UI. Contains NO tokens or secrets.
|
|
118
|
+
*/
|
|
119
|
+
declare const KNOWN_ACCOUNTS_COOKIE_NAME = "sm_known_accounts";
|
|
113
120
|
interface SessionCookieOptions {
|
|
114
121
|
/** Cookie max age in seconds (default: 7 days) */
|
|
115
122
|
maxAge?: number;
|
|
@@ -181,6 +188,51 @@ declare function getSession(): Promise<SessionData | null>;
|
|
|
181
188
|
* Use this when you need to read cookies from a Request directly.
|
|
182
189
|
*/
|
|
183
190
|
declare function getSessionFromRequest(request: Request): SessionData | null;
|
|
191
|
+
/**
|
|
192
|
+
* Known account entry stored in cookie.
|
|
193
|
+
* Contains display metadata ONLY — no tokens, no secrets.
|
|
194
|
+
*/
|
|
195
|
+
interface KnownAccountEntry {
|
|
196
|
+
userId: string;
|
|
197
|
+
email?: string;
|
|
198
|
+
fullName?: string;
|
|
199
|
+
avatarUrl?: string;
|
|
200
|
+
provider?: string;
|
|
201
|
+
lastActiveAt: string;
|
|
202
|
+
displayLabel?: string;
|
|
203
|
+
colorIndex?: number;
|
|
204
|
+
}
|
|
205
|
+
type AccountSwitcherPrivacy = 'full' | 'masked' | 'minimal';
|
|
206
|
+
/**
|
|
207
|
+
* Add an account to the known accounts cookie.
|
|
208
|
+
* Called after successful login. The cookie is NOT httpOnly so client JS
|
|
209
|
+
* can read it to render the account switcher UI.
|
|
210
|
+
*
|
|
211
|
+
* Appends Set-Cookie headers to an existing Headers object.
|
|
212
|
+
*/
|
|
213
|
+
declare function appendKnownAccountCookie(headers: Headers, account: KnownAccountEntry, existingCookie: string | null, options?: SessionCookieOptions, privacy?: AccountSwitcherPrivacy): void;
|
|
214
|
+
/**
|
|
215
|
+
* Remove a specific account from the known accounts cookie.
|
|
216
|
+
*/
|
|
217
|
+
declare function removeKnownAccountFromCookie(headers: Headers, userId: string, existingCookie: string | null, options?: SessionCookieOptions): void;
|
|
218
|
+
/**
|
|
219
|
+
* Clear the known accounts cookie entirely.
|
|
220
|
+
*/
|
|
221
|
+
declare function clearKnownAccountsCookie(headers: Headers, options?: SessionCookieOptions): void;
|
|
222
|
+
/**
|
|
223
|
+
* Read known accounts from a Request's cookies.
|
|
224
|
+
*/
|
|
225
|
+
declare function getKnownAccountsFromRequest(request: Request): KnownAccountEntry[];
|
|
226
|
+
/**
|
|
227
|
+
* Read the raw known accounts cookie value from a Request.
|
|
228
|
+
*/
|
|
229
|
+
declare function getKnownAccountsCookieRaw(request: Request): string | null;
|
|
230
|
+
/**
|
|
231
|
+
* Normalize all entries in the known accounts cookie to the given privacy level.
|
|
232
|
+
* Returns a Set-Cookie header string if any entries changed, or null if nothing changed.
|
|
233
|
+
* Used on /me requests to migrate legacy full-PII cookies to the configured privacy level.
|
|
234
|
+
*/
|
|
235
|
+
declare function normalizeKnownAccountsCookie(request: Request, privacy: AccountSwitcherPrivacy | undefined, options?: SessionCookieOptions): string | null;
|
|
184
236
|
/**
|
|
185
237
|
* Require authentication - throws Response if not authenticated
|
|
186
238
|
*
|
|
@@ -220,6 +272,19 @@ interface AuthRoutesConfig {
|
|
|
220
272
|
cookies?: SessionCookieOptions;
|
|
221
273
|
/** Enable CSRF validation on state-changing requests (POST/DELETE/PATCH) */
|
|
222
274
|
csrf?: boolean;
|
|
275
|
+
/**
|
|
276
|
+
* Enable the account switcher — remembers which accounts have logged in on
|
|
277
|
+
* this device (metadata only, no tokens). Switching requires re-authentication.
|
|
278
|
+
* Adds routes: switch-account, forget-account, forget-all-accounts, known-accounts.
|
|
279
|
+
*/
|
|
280
|
+
enableAccountSwitcher?: boolean;
|
|
281
|
+
/**
|
|
282
|
+
* Privacy level for account switcher display metadata.
|
|
283
|
+
* - 'full': Store email, name, avatar as-is (default)
|
|
284
|
+
* - 'masked': Mask email, truncate name to initial
|
|
285
|
+
* - 'minimal': No PII — just a colored "Account" label
|
|
286
|
+
*/
|
|
287
|
+
accountSwitcherPrivacy?: 'full' | 'masked' | 'minimal';
|
|
223
288
|
/** Callbacks */
|
|
224
289
|
onLogin?: (user: {
|
|
225
290
|
id: string;
|
|
@@ -1011,4 +1076,70 @@ declare function invalidateBundleCache(key?: string): void;
|
|
|
1011
1076
|
*/
|
|
1012
1077
|
declare function prefetchBundles(keys: string[]): Promise<void>;
|
|
1013
1078
|
|
|
1014
|
-
|
|
1079
|
+
/**
|
|
1080
|
+
* Safe-redirect validation for authentication callback URLs.
|
|
1081
|
+
*
|
|
1082
|
+
* Prevents open-redirect attacks on `returnTo` / `callbackUrl` / `next`
|
|
1083
|
+
* params after login / registration / password-reset flows. An attacker
|
|
1084
|
+
* who can inject a `?returnTo=https://evil.example` into your login
|
|
1085
|
+
* form would otherwise redirect the freshly-authenticated user away
|
|
1086
|
+
* from your origin — a classic phishing + credential-harvesting setup.
|
|
1087
|
+
*
|
|
1088
|
+
* Safe by default — unknown input returns the configured default
|
|
1089
|
+
* path. Hosts opt in to external origins explicitly via
|
|
1090
|
+
* `allowedOrigins`.
|
|
1091
|
+
*
|
|
1092
|
+
* Framework-agnostic: no imports from `next/*`. Safe in any
|
|
1093
|
+
* Edge / Node / middleware runtime.
|
|
1094
|
+
*/
|
|
1095
|
+
interface SafeRedirectOptions {
|
|
1096
|
+
/**
|
|
1097
|
+
* Origins (schema + host + optional port) the redirect is allowed
|
|
1098
|
+
* to land on. Default `[]` — only same-origin relative paths are
|
|
1099
|
+
* allowed. Items are compared case-insensitively after normalizing
|
|
1100
|
+
* the scheme and host.
|
|
1101
|
+
*
|
|
1102
|
+
* Good practice: list only origins that your organization controls
|
|
1103
|
+
* and that are reachable over HTTPS.
|
|
1104
|
+
*
|
|
1105
|
+
* @example
|
|
1106
|
+
* ['https://app.example.com', 'https://admin.example.com']
|
|
1107
|
+
*/
|
|
1108
|
+
allowedOrigins?: string[];
|
|
1109
|
+
/**
|
|
1110
|
+
* Value returned when the input is missing, invalid, or points
|
|
1111
|
+
* outside the allowlist. Default `'/'`.
|
|
1112
|
+
*/
|
|
1113
|
+
defaultPath?: string;
|
|
1114
|
+
/**
|
|
1115
|
+
* Strip the scheme + host from same-origin absolute URLs and
|
|
1116
|
+
* return only the path + query + fragment. Default `true` — keeps
|
|
1117
|
+
* redirect targets as short relative URLs that route through
|
|
1118
|
+
* client-side routing cleanly.
|
|
1119
|
+
*/
|
|
1120
|
+
stripSameOriginHost?: boolean;
|
|
1121
|
+
}
|
|
1122
|
+
/**
|
|
1123
|
+
* Returns a safe-to-use redirect path, falling back to
|
|
1124
|
+
* `opts.defaultPath` (default `'/'`) when the input fails validation.
|
|
1125
|
+
*
|
|
1126
|
+
* Accepts:
|
|
1127
|
+
* - empty / nullish → default
|
|
1128
|
+
* - relative paths like `/foo/bar?x=1#frag` (leading `/` required)
|
|
1129
|
+
* - absolute URLs whose origin is in `allowedOrigins`
|
|
1130
|
+
*
|
|
1131
|
+
* Rejects everything else, including:
|
|
1132
|
+
* - schema-relative URLs (`//evil.example`)
|
|
1133
|
+
* - backslash-prefixed paths
|
|
1134
|
+
* - `javascript:`, `data:`, `mailto:`, `vbscript:` etc.
|
|
1135
|
+
* - bare hostnames (`example.com/path`)
|
|
1136
|
+
* - malformed URLs
|
|
1137
|
+
*/
|
|
1138
|
+
declare function validateSafeRedirect(input: string | null | undefined, opts?: SafeRedirectOptions): string;
|
|
1139
|
+
/**
|
|
1140
|
+
* Boolean predicate form. Returns `true` when `input` would pass
|
|
1141
|
+
* `validateSafeRedirect` with the same options.
|
|
1142
|
+
*/
|
|
1143
|
+
declare function isSafeRedirect(input: string | null | undefined, opts?: SafeRedirectOptions): boolean;
|
|
1144
|
+
|
|
1145
|
+
export { type AnalyticsRoutesConfig, type AnalyticsTrackingGateConfig, type AuthMiddlewareConfig, type AuthRoutesConfig, CSRF_COOKIE_NAME, CSRF_HEADER_NAME, type HandlerContext, type HandlerOptions, KNOWN_ACCOUNTS_COOKIE_NAME, type KnownAccountEntry, type MySqlBundle, type NotificationRoutesConfig, OAUTH_STATE_COOKIE_NAME, type OAuthBundle, type PostgresBundle, type PushRoutesConfig, type RedisBundle, type S3Bundle, SESSION_COOKIE_NAME, type SafeRedirectOptions, ScaleMuleError, ServerConfig, type SessionCookieOptions, type SessionData, type SmtpBundle, USER_ID_COOKIE_NAME, apiHandler, appendKnownAccountCookie, buildClientContextHeaders, buildFlagContext, clearKnownAccountsCookie, clearOAuthState, clearSession, configureBundles, configureSecrets, createAnalyticsRoutes, createAuthMiddleware, createAuthRoutes, createNotificationRoutes, createPushRoutes, errorCodeToStatus, extractClientContext, extractClientContextFromReq, generateCSRFToken, getAppSecret, getAppSecretOrDefault, getBootstrapFlags, getBundle, getCSRFToken, getKnownAccountsCookieRaw, getKnownAccountsFromRequest, getMySqlBundle, getOAuthBundle, getPostgresBundle, getRedisBundle, getS3Bundle, getSession, getSessionFromRequest, getSmtpBundle, invalidateBundleCache, invalidateSecretCache, isSafeRedirect, normalizeKnownAccountsCookie, prefetchBundles, prefetchSecrets, removeKnownAccountFromCookie, requireAppSecret, requireBundle, requireSession, setOAuthState, unwrap, validateCSRFToken, validateCSRFTokenAsync, validateOAuthState, validateOAuthStateAsync, validateSafeRedirect, withAuth, withCSRFProtection, withCSRFToken, withSession };
|