@dintero/sri-to-dist
Version:
HTML tool for adding subresource integrity hashes
32 lines (31 loc) • 1.72 kB
TypeScript
declare const extractLinkRel: (scriptOrLinkTag: string) => string | undefined;
declare const isSriTag: (scriptOrLinkTag: string) => boolean;
export declare const isImportMapTag: (scriptOrLinkTag: string) => boolean;
type ImportMapJson = {
imports: {
[key: string]: string;
};
integrity?: {
[src: string]: string;
};
scopes?: {
[scope: string]: {
[key: string]: string;
};
};
};
export declare const parseImportMap: (scriptOrLinkTag: string) => ImportMapJson;
export declare const extractImports: (importMapJson: ImportMapJson) => {
src: string;
oldHash: string | undefined;
}[];
export declare const toSriImportMap: (tag: string, importMapJson: ImportMapJson, newIntegrityMap: ImportMapJson["integrity"]) => string;
declare const toHtmlWithSri: (htmlContent: string, baseDir: string, baseUrl?: string, noRemote?: boolean, verify?: boolean) => Promise<string>;
declare const getContent: (src: string, baseDir: string, baseUrl?: string, noRemote?: boolean) => Promise<Buffer>;
declare const fetchRemoteContent: (src: string) => Promise<Buffer>;
declare const readLocalContent: (src: string, baseDir: string, baseUrl: string) => Buffer;
declare const calculateSha384: (content: Buffer) => string;
declare const handleUpdatedHtml: (stdout: NodeJS.WriteStream, outputPath?: string, updatedHtml?: string) => void;
declare const toSriScriptTag: (tag: string, integrity: string) => string;
declare const alterTag: (tag: string, param: "crossorigin" | "integrity", value: string) => string;
export { extractLinkRel, isSriTag, toHtmlWithSri, getContent, readLocalContent, fetchRemoteContent, calculateSha384, toSriScriptTag, handleUpdatedHtml, alterTag };