/** * Browser auth utilities for @sentry/api. * * Provides a fetch wrapper that handles cookie-based session auth and * CSRF token injection, allowing the SDK to be used inside the Sentry * frontend without a Bearer token. */ /** Matches the standard fetch signature without Bun/Node runtime extensions. */ export type FetchFn = (input: RequestInfo | URL, init?: RequestInit) => Promise; export type BrowserClientOptions = { /** Cookie name to read the CSRF token from. Defaults to 'sc' (Sentry's Django default). */ csrfCookieName?: string; /** Override the CSRF token getter — useful for testing. */ getCsrfToken?: () => string; /** Base URL for all requests. Defaults to '' (same-origin relative URLs). */ baseUrl?: string; /** * Origin of the page that sends the requests, which decides where the CSRF * token may go. Defaults to `location.origin`. With neither, only relative * URLs get the token. */ origin?: string; }; /** * Returns a fetch wrapper that injects X-CSRFToken on state-changing requests * to the page's origin or a similar one (the same host, a parent or subdomain * of it, or a sibling subdomain), only over https from an https page, and * sends session cookies via * credentials: 'include'. Requests to other origins never get the token. * * Sentry's Django backend reads the CSRF token from the 'sc' cookie by default * (configurable via window.csrfCookieName in the frontend). * * Note: always sets credentials: 'include'; any credentials value in init is overridden. */ export declare function createBrowserFetch(opts?: BrowserClientOptions): FetchFn; /** * Returns configuration for a browser SDK instance with cookie-based session * auth and CSRF token injection. The base URL defaults to same-origin relative URLs. * * @example * import {createSentryClient} from '@sentry/api'; * import {createBrowserSdkConfig} from '@sentry/api/browser'; * const sentry = createSentryClient( * createBrowserSdkConfig({baseUrl: 'https://sentry.example.com'}), * ); * const {data, error} = await sentry.listOrganizations(); */ export declare function createBrowserSdkConfig(opts?: BrowserClientOptions): { readonly baseUrl: string; readonly fetch: FetchFn; };