@elliemae/pui-cli 8.40.2 → 8.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,65 @@
1
+ /** Module for enabling a hash-based strict Content Security Policy. */
2
+ declare class CSP {
3
+ private static readonly HASH_FUNCTION;
4
+ private static readonly INLINE_SCRIPT_SELECTOR;
5
+ private static readonly SOURCED_SCRIPT_SELECTOR;
6
+ private $;
7
+ constructor(html: string);
8
+ serializeDom(): string;
9
+ /**
10
+ * Returns a strict Content Security Policy for mittigating XSS.
11
+ * For more details read csp.withgoogle.com.
12
+ * If you modify this CSP, make sure it has not become trivially bypassable by
13
+ * checking the policy using csp-evaluator.withgoogle.com.
14
+ * @param hashes A list of sha-256 hashes of trusted inline scripts.
15
+ * @param cspOptions
16
+ * @param enableTrustedTypes If Trusted Types should be enabled for scripts.
17
+ * @param enableBrowserFallbacks If fallbacks for older browsers should be
18
+ * added. This is will not weaken the policy as modern browsers will ignore
19
+ * the fallbacks.
20
+ * @param enableUnsafeEval If you cannot remove all uses of eval(), you can
21
+ * still set a strict CSP, but you will have to use the 'unsafe-eval'
22
+ * keyword which will make your policy slightly less secure.
23
+ * @param cspOptions.enableBrowserFallbacks
24
+ * @param cspOptions.enableTrustedTypes
25
+ * @param cspOptions.enableUnsafeEval
26
+ * @returns A strict Content Security Policy string.
27
+ */
28
+ static getStrictCsp(hashes?: string[], cspOptions?: {
29
+ enableUnsafeEval?: boolean;
30
+ }): string;
31
+ /**
32
+ * Enables a CSP via a meta tag at the beginning of the document.
33
+ * Warning: It's recommended to set CSP as HTTP response header instead of
34
+ * using a meta tag. Injections before the meta tag will not be covered by CSP
35
+ * and meta tags don't support CSP in report-only mode.
36
+ * @param csp A Content Security Policy string.
37
+ */
38
+ addMetaTag(csp: string): void;
39
+ /**
40
+ * Replaces all sourced scripts with a single inline script that can be hashed
41
+ */
42
+ refactorSourcedScriptsForHashBasedCsp(): void;
43
+ /**
44
+ * Returns a list of hashes of all inline scripts found in the HTML document.
45
+ * @returns A list of sha-256 hashes of inline scripts.
46
+ */
47
+ hashAllInlineScripts(): string[];
48
+ /**
49
+ * Returns JS code for dynamically loading sourced (external) scripts.
50
+ * @param scriptInfoList A list of objects containing src and type for scripts that should be loaded
51
+ * @returns JS code for loading scripts.
52
+ */
53
+ static createLoaderScript(scriptInfoList: {
54
+ src: string;
55
+ type?: string;
56
+ }[]): string | undefined;
57
+ /**
58
+ * Calculates a CSP compatible hash of an inline script.
59
+ * @param scriptText Text between opening and closing script tag. Has to
60
+ * include whitespaces and newlines!
61
+ * @returns A sha-256 hash of the script.
62
+ */
63
+ static hashInlineScript(scriptText: string): string;
64
+ }
65
+ export { CSP };