@microsoft/kiota-http-fetchlibrary
Version:
Kiota request adapter implementation with fetch
83 lines • 3.12 kB
TypeScript
/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
/**
* @module RedirectHandlerOptions
*/
import type { RequestOption } from "@microsoft/kiota-abstractions";
/**
*
* A type declaration for shouldRetry callback
*/
export type ShouldRedirect = (response: Response) => boolean;
/**
* A type declaration for scrubbing sensitive headers during redirects.
* @param headers - The headers object to modify
* @param originalUrl - The original request URL
* @param newUrl - The new redirect URL
*/
export type ScrubSensitiveHeaders = (headers: Record<string, string>, originalUrl: string, newUrl: string) => void;
export declare const RedirectHandlerOptionKey = "RedirectHandlerOption";
export interface RedirectHandlerOptionsParams {
maxRedirects?: number;
shouldRedirect?: ShouldRedirect;
scrubSensitiveHeaders?: ScrubSensitiveHeaders;
}
/**
* MiddlewareOptions
* A class representing RedirectHandlerOptions
*/
export declare class RedirectHandlerOptions implements RequestOption {
/**
* A member holding default max redirects value
*/
private static readonly DEFAULT_MAX_REDIRECTS;
/**
* A member holding maximum max redirects value
*/
private static readonly MAX_MAX_REDIRECTS;
/**
*
* A member holding default shouldRedirect callback
* @returns true
*/
private static readonly defaultShouldRetry;
/**
* The default implementation for scrubbing sensitive headers during redirects.
* This method removes Authorization and Cookie headers when the host or scheme changes.
* Note: Proxy-Authorization handling is not applicable in Fetch API as proxy configuration
* is handled at a lower level by the browser/runtime and is not accessible to JavaScript.
* @param headers - The headers object to modify
* @param originalUrl - The original request URL
* @param newUrl - The new redirect URL
*/
private static readonly defaultScrubSensitiveHeaders;
/**
*
* A member holding the max redirects value
*/
maxRedirects: number;
/**
*
* A member holding the should redirect callback
*/
shouldRedirect: ShouldRedirect;
/**
* A member holding the callback for scrubbing sensitive headers during redirects
*/
scrubSensitiveHeaders: ScrubSensitiveHeaders;
/**
*
* To create an instance of RedirectHandlerOptions
* @param [options] - The redirect handler options instance
* @returns An instance of RedirectHandlerOptions
* @throws Error if maxRedirects is more than 20 or less than 0
* @example const options = new RedirectHandlerOptions({ maxRedirects: 5 });
*/
constructor(options?: Partial<RedirectHandlerOptionsParams>);
getKey(): string;
}
//# sourceMappingURL=redirectHandlerOptions.d.ts.map