//#region src/oauth/token-endpoint.d.ts /** * Low-level token-endpoint client. The Authorization Code, Device, * and Refresh flows all funnel into a single POST to the token * endpoint with `application/x-www-form-urlencoded` body per * RFC 6749 § 3.2 + OAuth 2.1. * * @packageDocumentation */ /** Strategy hook used by tests to inject synthetic token responses. */ type TokenEndpointFetcher = (url: string, init: { body: string; signal?: AbortSignal; basicAuth?: string; }) => Promise; /** Internal HTTP-style response shape consumed by the higher-level flows. */ interface TokenEndpointResponse { readonly ok: boolean; readonly status: number; readonly statusText?: string; readonly body: TokenEndpointBody; } /** * Parsed body returned by the token endpoint. Mirrors the shape * defined by RFC 6749 § 5.1 + the device-flow extension. * * @stable */ interface TokenEndpointBody { readonly access_token?: string; readonly refresh_token?: string; readonly id_token?: string; readonly token_type?: string; readonly expires_in?: number; readonly scope?: string; readonly error?: string; readonly error_description?: string; readonly error_uri?: string; readonly interval?: number; readonly [extra: string]: unknown; } /** * Override the token-endpoint fetcher. Used by the test suite to * inject canned responses without hitting the network. * * @experimental */ declare function _setTokenEndpointFetcherForTesting(fetcher: TokenEndpointFetcher | null): void; /** * POST `params` to the token endpoint and return the parsed JSON * body. The helper does not throw on non-2xx responses - the caller * is responsible for branching on `.ok` so error responses can * surface the spec-defined `error` / `error_description` fields. * * @stable */ declare function postToTokenEndpoint(endpoint: string, params: Readonly>, options?: { signal?: AbortSignal; basicAuth?: string; }): Promise; /** * Encode HTTP Basic credentials. * * @internal */ declare function encodeBasicAuth(clientId: string, clientSecret: string): string; //#endregion export { TokenEndpointBody, TokenEndpointFetcher, TokenEndpointResponse, _setTokenEndpointFetcherForTesting, encodeBasicAuth, postToTokenEndpoint }; //# sourceMappingURL=token-endpoint.d.ts.map