/** * @license * Copyright Google LLC * SPDX-License-Identifier: Apache-2.0 */ /** * @fileoverview * Functions which allow fetch() on resourceUrls to be * interpreted as SafeHtml or SafeScript. */ import { SafeHtml } from '../../internals/html_impl.js'; import { TrustedResourceUrl } from '../../internals/resource_url_impl.js'; import { SafeScript } from '../../internals/script_impl.js'; import { SafeStyleSheet } from '../../internals/style_sheet_impl.js'; /** * IncorrectTypeError represents an error that can occur with {@link * fetchResourceUrl} when the server responds with a content type that would be * unsafe for the type of content requested. */ export declare class IncorrectContentTypeError extends Error { readonly url: string; readonly typeName: string; readonly contentType: string; constructor(url: string, typeName: string, contentType: string); } /** * A SafeResponse is the response value of a {@link fetchResourceUrl} call. */ export interface SafeResponse { /** * html returns this {@link Response} as a SafeHtml, or throws an error. */ html(): Promise; /** * script returns the fetch response as a {@link SafeScript}, or returns an * error. */ script(): Promise; /** * styleSheet returns the fetch response as a {@link SafeStyleSheet}, or * returns an error. */ styleSheet(): Promise; } /** * fetches a given {@link TrustedResourceUrl}, * and returns a value which can be turned into a given safe type. */ export declare function fetchResourceUrl(u: TrustedResourceUrl, init?: RequestInit): Promise;