source: trip-planner-front/node_modules/@angular/core/esm2015/src/util/security/trusted_types.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 16.4 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8/**
9 * @fileoverview
10 * A module to facilitate use of a Trusted Types policy internally within
11 * Angular. It lazily constructs the Trusted Types policy, providing helper
12 * utilities for promoting strings to Trusted Types. When Trusted Types are not
13 * available, strings are used as a fallback.
14 * @security All use of this module is security-sensitive and should go through
15 * security review.
16 */
17import { global } from '../global';
18/**
19 * The Trusted Types policy, or null if Trusted Types are not
20 * enabled/supported, or undefined if the policy has not been created yet.
21 */
22let policy;
23/**
24 * Returns the Trusted Types policy, or null if Trusted Types are not
25 * enabled/supported. The first call to this function will create the policy.
26 */
27function getPolicy() {
28 if (policy === undefined) {
29 policy = null;
30 if (global.trustedTypes) {
31 try {
32 policy = global.trustedTypes.createPolicy('angular', {
33 createHTML: (s) => s,
34 createScript: (s) => s,
35 createScriptURL: (s) => s,
36 });
37 }
38 catch (_a) {
39 // trustedTypes.createPolicy throws if called with a name that is
40 // already registered, even in report-only mode. Until the API changes,
41 // catch the error not to break the applications functionally. In such
42 // cases, the code will fall back to using strings.
43 }
44 }
45 }
46 return policy;
47}
48/**
49 * Unsafely promote a string to a TrustedHTML, falling back to strings when
50 * Trusted Types are not available.
51 * @security This is a security-sensitive function; any use of this function
52 * must go through security review. In particular, it must be assured that the
53 * provided string will never cause an XSS vulnerability if used in a context
54 * that will be interpreted as HTML by a browser, e.g. when assigning to
55 * element.innerHTML.
56 */
57export function trustedHTMLFromString(html) {
58 var _a;
59 return ((_a = getPolicy()) === null || _a === void 0 ? void 0 : _a.createHTML(html)) || html;
60}
61/**
62 * Unsafely promote a string to a TrustedScript, falling back to strings when
63 * Trusted Types are not available.
64 * @security In particular, it must be assured that the provided string will
65 * never cause an XSS vulnerability if used in a context that will be
66 * interpreted and executed as a script by a browser, e.g. when calling eval.
67 */
68export function trustedScriptFromString(script) {
69 var _a;
70 return ((_a = getPolicy()) === null || _a === void 0 ? void 0 : _a.createScript(script)) || script;
71}
72/**
73 * Unsafely promote a string to a TrustedScriptURL, falling back to strings
74 * when Trusted Types are not available.
75 * @security This is a security-sensitive function; any use of this function
76 * must go through security review. In particular, it must be assured that the
77 * provided string will never cause an XSS vulnerability if used in a context
78 * that will cause a browser to load and execute a resource, e.g. when
79 * assigning to script.src.
80 */
81export function trustedScriptURLFromString(url) {
82 var _a;
83 return ((_a = getPolicy()) === null || _a === void 0 ? void 0 : _a.createScriptURL(url)) || url;
84}
85/**
86 * Unsafely call the Function constructor with the given string arguments. It
87 * is only available in development mode, and should be stripped out of
88 * production code.
89 * @security This is a security-sensitive function; any use of this function
90 * must go through security review. In particular, it must be assured that it
91 * is only called from development code, as use in production code can lead to
92 * XSS vulnerabilities.
93 */
94export function newTrustedFunctionForDev(...args) {
95 if (typeof ngDevMode === 'undefined') {
96 throw new Error('newTrustedFunctionForDev should never be called in production');
97 }
98 if (!global.trustedTypes) {
99 // In environments that don't support Trusted Types, fall back to the most
100 // straightforward implementation:
101 return new Function(...args);
102 }
103 // Chrome currently does not support passing TrustedScript to the Function
104 // constructor. The following implements the workaround proposed on the page
105 // below, where the Chromium bug is also referenced:
106 // https://github.com/w3c/webappsec-trusted-types/wiki/Trusted-Types-for-function-constructor
107 const fnArgs = args.slice(0, -1).join(',');
108 const fnBody = args[args.length - 1];
109 const body = `(function anonymous(${fnArgs}
110) { ${fnBody}
111})`;
112 // Using eval directly confuses the compiler and prevents this module from
113 // being stripped out of JS binaries even if not used. The global['eval']
114 // indirection fixes that.
115 const fn = global['eval'](trustedScriptFromString(body));
116 if (fn.bind === undefined) {
117 // Workaround for a browser bug that only exists in Chrome 83, where passing
118 // a TrustedScript to eval just returns the TrustedScript back without
119 // evaluating it. In that case, fall back to the most straightforward
120 // implementation:
121 return new Function(...args);
122 }
123 // To completely mimic the behavior of calling "new Function", two more
124 // things need to happen:
125 // 1. Stringifying the resulting function should return its source code
126 fn.toString = () => body;
127 // 2. When calling the resulting function, `this` should refer to `global`
128 return fn.bind(global);
129 // When Trusted Types support in Function constructors is widely available,
130 // the implementation of this function can be simplified to:
131 // return new Function(...args.map(a => trustedScriptFromString(a)));
132}
133//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJ1c3RlZF90eXBlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvcmUvc3JjL3V0aWwvc2VjdXJpdHkvdHJ1c3RlZF90eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSDs7Ozs7Ozs7R0FRRztBQUVILE9BQU8sRUFBQyxNQUFNLEVBQUMsTUFBTSxXQUFXLENBQUM7QUFHakM7OztHQUdHO0FBQ0gsSUFBSSxNQUF3QyxDQUFDO0FBRTdDOzs7R0FHRztBQUNILFNBQVMsU0FBUztJQUNoQixJQUFJLE1BQU0sS0FBSyxTQUFTLEVBQUU7UUFDeEIsTUFBTSxHQUFHLElBQUksQ0FBQztRQUNkLElBQUksTUFBTSxDQUFDLFlBQVksRUFBRTtZQUN2QixJQUFJO2dCQUNGLE1BQU0sR0FBSSxNQUFNLENBQUMsWUFBeUMsQ0FBQyxZQUFZLENBQUMsU0FBUyxFQUFFO29CQUNqRixVQUFVLEVBQUUsQ0FBQyxDQUFTLEVBQUUsRUFBRSxDQUFDLENBQUM7b0JBQzVCLFlBQVksRUFBRSxDQUFDLENBQVMsRUFBRSxFQUFFLENBQUMsQ0FBQztvQkFDOUIsZUFBZSxFQUFFLENBQUMsQ0FBUyxFQUFFLEVBQUUsQ0FBQyxDQUFDO2lCQUNsQyxD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