import { AuthData } from 'firebase-functions/tasks'; import { MockHttpResponse } from 'src/lib/http/http-types.js'; import { AuthenticatedRequestContext, UnauthenticatedRequestContext } from '../../types.js'; /** * Http header keys (standard and custom) replicating the Firebase environment. */ export declare enum HeaderKey { Host = "host", ContentType = "content-type", Authorization = "authorization", ForwardedProto = "x-forwarded-proto", AppCheck = "x-firebase-appcheck" } /** * Format an ID token issuer (`iss`) string for a given project. * * @param projectNumber - Firebase project number. * @returns Issuer URL like `https://firebaseappcheck.googleapis.com/`. */ export declare function formatIss(projectNumber: string): string; /** * Build {@link AuthData} for callable handlers from a generic auth context. * * @param context - The version-agnostic auth context produced by the provider. * @returns An `AuthData` object containing `uid`, a decoded token, and the raw encoded token. * * @remarks * - The returned `uid` mirrors the identity’s `uid` (i.e., the `sub` claim). * - The returned token is a **decoded** shape that merges standard JWT claims * with fields from {@link AuthenticatedRequestContext} identity. */ export declare function buildAuthData(context: UnauthenticatedRequestContext | AuthenticatedRequestContext): AuthData | undefined; /** * Build the App Check object surfaced on callable requests (v1/v2). * * @param app - Optional App Check payload with `appId` and a token. * @returns `{ appId, token }` if `app` is provided; otherwise `undefined`. * * @remarks * This is a shaping helper; it does not validate the token. */ export declare function buildAppData(app?: { appId: string; token?: unknown; }): { appId: string; token: unknown; } | undefined; /** * Resolve when the HTTP response lifecycle completes. * * @typeParam T - The result value type to resolve with after completion. * * @param res - The mocked HTTP response (e.g., from `node-mocks-http`). * @param result - Value to resolve once the response finishes. * @returns A promise that resolves to `result` after the response ends, or rejects on error. * * @remarks * - Works with both Express and `node-mocks-http`: * - Express emits `'finish'`. * - `node-mocks-http` emits `'end'` (and sometimes `'close'`). * - If the response is already ended, resolves immediately. */ export declare function awaitResponse(res: MockHttpResponse, result: T): Promise; /** * Execute an operation and then wait for the HTTP response to complete. * * @typeParam T - The result value type of the operation. * * @param executor - Function to invoke (may be sync or async). * @param response - The mocked HTTP response to await. * @returns A promise resolving with the executor’s result once the response finishes. * * @remarks * - Wraps {@link execPromise} to normalize sync/async execution paths. * - Chains to {@link awaitResponse} to ensure response completion before resolving. */ export declare function execAndAwaitResponse(executor: () => T | Promise, response: MockHttpResponse): Promise; /** * Encode a UTF-8 string to base64url (RFC 7515) form. * * - Uses standard base64 * - Strips `=` * - Replaces `+` with `-` * - Replaces `/` with `_` * * @param value - The string to encode. * @returns The base64url-encoded string. */ export declare function base64UrlEncode(value: string): string; /** * Decode a base64url string back to a UTF-8 string. * * - Restores padding * - Reverts `-` → `+` and `_` → `/` * * @param value - The base64url string to decode. * @returns The decoded UTF-8 string. * @throws If the input cannot be padded to valid base64. */ export declare function base64UrlDecode(value: string): string; //# sourceMappingURL=util.d.ts.map