@datadome/module-nextjs
Version:
DataDome module for Next.js applications
38 lines • 1.89 kB
TypeScript
import { RequestCookies } from 'next/dist/compiled/@edge-runtime/cookies';
import { NextRequest } from 'next/server';
import { RequestData } from './middleware';
/**
* This function is used to attach the list of headers from the DataDome's protection API response to the incoming request.
* This function is mainly used to attach the DataDome's enriched headers.
* @see {@link https://docs.datadome.co/docs/logs-integration} for the available enriched headers.
* @param reqHeaders - The headers of the incoming request.
* @param dataDomeResHeaders - The headers of the DataDome's protection API response.
* @param listKey - The header key we want to retrieve.
* @returns A map of string.
*/
export declare function convertHeadersToMap(reqHeaders: Headers, dataDomeResHeaders: Headers, listKey: string): Map<string, string>;
/**
* This functions is used to return all the headers from the request in a string separated by commas.
* @param req - The incoming request.
* @returns A comma separated list of headers.
*/
export declare function getHeadersList(req: NextRequest): string;
/**
* This function is used to return the length of the Authorization header.
* @param req - The incoming request.
* @returns The length of the Authorization header.
*/
export declare function getAuthorizationLength(req: NextRequest): number | undefined;
/**
* This function is used to create an URL-encoded string of the payload of the Protection API.
* @param obj - The truncated payload for the Protection API.
* @returns An URL-encoded string of the truncated payload.
*/
export declare function stringify(obj: RequestData): string;
/**
* Returns the value of the `datadome` cookie.
* @param cookies - the cookies of the request.
* @returns The Client ID of the request.
*/
export declare function getCookieData(cookies: RequestCookies): string;
//# sourceMappingURL=utils.d.ts.map