import { DecodedAppCheckToken } from 'firebase-admin/app-check'; import { DecodedIdToken } from 'firebase-admin/auth'; import { CloudFunctionsBody, HttpRequestOptions } from '../../http/http-types.js'; import { AuthKey } from '../../types.js'; import { CloudFunctionRequestBase } from '../https-types.js'; export interface FunctionMetaDataOptions { onCallMode: boolean; appCheck?: DecodedAppCheckToken; id?: DecodedIdToken; } /** * Populate/normalize HTTP request metadata for a Cloud Function invocation. * * @param request - High-level function request descriptor (identity key, region, project, emulator flag, etc.). * @param httpOptions - Low-level HTTP request options object to **mutate** (URL, method, headers, etc.). * @param onCallMode - If `true`, enforce callable (`onCall`) defaults (e.g., `POST`, JSON body, synthesized URL). * * @remarks * This helper shapes an Express-like `HttpRequestOptions` for both `onRequest` and `onCall` flows: * * - **URL / path shaping** * - If `onCallMode === true` **or** `options.url` is missing, sets a synthetic path based on * `{project}/{region}/{functionName}` when targeting the **emulator**, or `/{functionName}` for hosted. * - Defaults: * - `region` → {@link DEFAULT_REGION} * - `project` → {@link DEFAULT_PROJECT_ID} * - `functionName` → `"defaultFunction"` * - Also mirrors the path to `originalUrl`, `path`, and clears `baseUrl`. * * - **Headers** * - Ensures a `host` header: * - Emulator: `"127.0.0.1:5001"` * - Hosted: `"-.cloudfunctions.net"` * - Ensures `x-forwarded-proto` (`"http"` for emulator, otherwise `"https"`). * - Ensures `content-type: application/json` for callable mode, or if not already set. * * - **HTTP method** * - Sets `method: "POST"` in callable mode, or if `options.method` is not provided. * * - **Mutation/Safety** * - This function **modifies** the provided `options` object in place. * - Existing `headers`, `url`, and `method` are respected unless callable-mode requires an override, * or they are undefined/empty. */ export declare function applyFunctionMeta(request: CloudFunctionRequestBase, httpOptions: HttpRequestOptions, fnOptions: FunctionMetaDataOptions): void; //# sourceMappingURL=apply-function-meta.d.ts.map