@firebase/app 0.16.6 → 0.16.7

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.
@@ -936,4 +936,19 @@ declare function _isFirebaseServerApp(obj: FirebaseApp | FirebaseServerApp | nul
936
936
  */
937
937
  declare function _clearComponents(): void;
938
938
 
939
- export { FirebaseApp, FirebaseAppSettings, FirebaseError, FirebaseOptions, FirebaseServerApp, FirebaseServerAppSettings, SDK_VERSION, DEFAULT_ENTRY_NAME as _DEFAULT_ENTRY_NAME, _FirebaseAppInternal, _FirebaseService, _addComponent, _addOrOverwriteComponent, _apps, _clearComponents, _components, _getProvider, _isFirebaseApp, _isFirebaseServerApp, _isFirebaseServerAppSettings, _registerComponent, _removeServiceInstance, _serverApps, deleteApp, getApp, getApps, initializeApp, initializeServerApp, onLog, registerVersion, setLogLevel };
939
+ /**
940
+ * Sets the `src` of a script element through the Firebase Trusted Types policy
941
+ * when Trusted Types are supported, so that Firebase SDKs can load external
942
+ * scripts on pages that enforce Trusted Types.
943
+ *
944
+ * Throws if `url` is not an allowed Firebase script URL, or if the browser
945
+ * rejects the assignment.
946
+ *
947
+ * @param script - The script element to update.
948
+ * @param url - The script URL. Must be an allowed Firebase script URL.
949
+ *
950
+ * @internal
951
+ */
952
+ declare function _setTrustedScriptSrc(script: HTMLScriptElement, url: string): void;
953
+
954
+ export { FirebaseApp, FirebaseAppSettings, FirebaseError, FirebaseOptions, FirebaseServerApp, FirebaseServerAppSettings, SDK_VERSION, DEFAULT_ENTRY_NAME as _DEFAULT_ENTRY_NAME, _FirebaseAppInternal, _FirebaseService, _addComponent, _addOrOverwriteComponent, _apps, _clearComponents, _components, _getProvider, _isFirebaseApp, _isFirebaseServerApp, _isFirebaseServerAppSettings, _registerComponent, _removeServiceInstance, _serverApps, _setTrustedScriptSrc, deleteApp, getApp, getApps, initializeApp, initializeServerApp, onLog, registerVersion, setLogLevel };
@@ -7,3 +7,4 @@
7
7
  export * from './api';
8
8
  export * from './internal';
9
9
  export * from './public-types';
10
+ export { _setTrustedScriptSrc } from './trustedTypes';
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Name of the Trusted Types policy that Firebase SDKs use to load external
19
+ * scripts. Apps that restrict policy names with the `trusted-types` CSP
20
+ * directive must allow this name.
21
+ *
22
+ * @internal
23
+ */
24
+ export declare const _TRUSTED_TYPES_POLICY_NAME = "firebase-js-sdk-policy";
25
+ /**
26
+ * Returns `url` if it is one of the allowed external scripts, and throws
27
+ * otherwise. Used as the `createScriptURL` implementation of the Trusted Types
28
+ * policy.
29
+ *
30
+ * @internal
31
+ */
32
+ export declare function _createTrustedScriptURL(url: string): string;
33
+ /**
34
+ * Sets the `src` of a script element through the Firebase Trusted Types policy
35
+ * when Trusted Types are supported, so that Firebase SDKs can load external
36
+ * scripts on pages that enforce Trusted Types.
37
+ *
38
+ * Throws if `url` is not an allowed Firebase script URL, or if the browser
39
+ * rejects the assignment.
40
+ *
41
+ * @param script - The script element to update.
42
+ * @param url - The script URL. Must be an allowed Firebase script URL.
43
+ *
44
+ * @internal
45
+ */
46
+ export declare function _setTrustedScriptSrc(script: HTMLScriptElement, url: string): void;
47
+ /**
48
+ * Resets the cached Trusted Types policy. Only for use in tests.
49
+ *
50
+ * @internal
51
+ */
52
+ export declare function _resetTrustedTypesPolicyForTesting(): void;
@@ -475,4 +475,6 @@ export declare const SDK_VERSION: string;
475
475
  */
476
476
  export declare function setLogLevel(logLevel: LogLevelString): void;
477
477
 
478
+ /* Excluded from this release type: _setTrustedScriptSrc */
479
+
478
480
  export { }
package/dist/app.d.ts CHANGED
@@ -570,4 +570,19 @@ export declare const _serverApps: Map<string, FirebaseServerApp>;
570
570
  */
571
571
  export declare function setLogLevel(logLevel: LogLevelString): void;
572
572
 
573
+ /**
574
+ * Sets the `src` of a script element through the Firebase Trusted Types policy
575
+ * when Trusted Types are supported, so that Firebase SDKs can load external
576
+ * scripts on pages that enforce Trusted Types.
577
+ *
578
+ * Throws if `url` is not an allowed Firebase script URL, or if the browser
579
+ * rejects the assignment.
580
+ *
581
+ * @param script - The script element to update.
582
+ * @param url - The script URL. Must be an allowed Firebase script URL.
583
+ *
584
+ * @internal
585
+ */
586
+ export declare function _setTrustedScriptSrc(script: HTMLScriptElement, url: string): void;
587
+
573
588
  export { }
@@ -7,3 +7,4 @@
7
7
  export * from './api';
8
8
  export * from './internal';
9
9
  export * from './public-types';
10
+ export { _setTrustedScriptSrc } from './trustedTypes';
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Name of the Trusted Types policy that Firebase SDKs use to load external
19
+ * scripts. Apps that restrict policy names with the `trusted-types` CSP
20
+ * directive must allow this name.
21
+ *
22
+ * @internal
23
+ */
24
+ export declare const _TRUSTED_TYPES_POLICY_NAME = "firebase-js-sdk-policy";
25
+ /**
26
+ * Returns `url` if it is one of the allowed external scripts, and throws
27
+ * otherwise. Used as the `createScriptURL` implementation of the Trusted Types
28
+ * policy.
29
+ *
30
+ * @internal
31
+ */
32
+ export declare function _createTrustedScriptURL(url: string): string;
33
+ /**
34
+ * Sets the `src` of a script element through the Firebase Trusted Types policy
35
+ * when Trusted Types are supported, so that Firebase SDKs can load external
36
+ * scripts on pages that enforce Trusted Types.
37
+ *
38
+ * Throws if `url` is not an allowed Firebase script URL, or if the browser
39
+ * rejects the assignment.
40
+ *
41
+ * @param script - The script element to update.
42
+ * @param url - The script URL. Must be an allowed Firebase script URL.
43
+ *
44
+ * @internal
45
+ */
46
+ export declare function _setTrustedScriptSrc(script: HTMLScriptElement, url: string): void;
47
+ /**
48
+ * Resets the cached Trusted Types policy. Only for use in tests.
49
+ *
50
+ * @internal
51
+ */
52
+ export declare function _resetTrustedTypesPolicyForTesting(): void;
@@ -58,7 +58,7 @@ function isVersionServiceProvider(provider) {
58
58
  }
59
59
 
60
60
  const name$r = "@firebase/app";
61
- const version$1 = "0.16.6";
61
+ const version$1 = "0.16.7";
62
62
 
63
63
  /**
64
64
  * @license
@@ -131,7 +131,7 @@ const name$2 = "@firebase/ai";
131
131
  const name$1 = "@firebase/firestore-compat";
132
132
 
133
133
  const name = "firebase";
134
- const version = "13.3.0";
134
+ const version = "13.4.0";
135
135
 
136
136
  /**
137
137
  * @license
@@ -1244,6 +1244,135 @@ function registerCoreComponents(variant) {
1244
1244
  registerVersion('fire-js', '');
1245
1245
  }
1246
1246
 
1247
+ /**
1248
+ * @license
1249
+ * Copyright 2026 Google LLC
1250
+ *
1251
+ * Licensed under the Apache License, Version 2.0 (the "License");
1252
+ * you may not use this file except in compliance with the License.
1253
+ * You may obtain a copy of the License at
1254
+ *
1255
+ * http://www.apache.org/licenses/LICENSE-2.0
1256
+ *
1257
+ * Unless required by applicable law or agreed to in writing, software
1258
+ * distributed under the License is distributed on an "AS IS" BASIS,
1259
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1260
+ * See the License for the specific language governing permissions and
1261
+ * limitations under the License.
1262
+ */
1263
+ /**
1264
+ * Name of the Trusted Types policy that Firebase SDKs use to load external
1265
+ * scripts. Apps that restrict policy names with the `trusted-types` CSP
1266
+ * directive must allow this name.
1267
+ *
1268
+ * @internal
1269
+ */
1270
+ const _TRUSTED_TYPES_POLICY_NAME = 'firebase-js-sdk-policy';
1271
+ /**
1272
+ * External scripts that Firebase SDKs are allowed to load. A script URL is
1273
+ * allowed if it is one of these URLs, optionally followed by a query string.
1274
+ *
1275
+ * - Analytics: Google tag (gtag.js)
1276
+ * - Auth: Google API loader (gapi), reCAPTCHA v2 and reCAPTCHA Enterprise
1277
+ * - App Check: reCAPTCHA v3 and reCAPTCHA Enterprise
1278
+ */
1279
+ const ALLOWED_SCRIPT_URLS = [
1280
+ 'https://www.googletagmanager.com/gtag/js',
1281
+ 'https://apis.google.com/js/api.js',
1282
+ 'https://www.google.com/recaptcha/api.js',
1283
+ 'https://www.google.com/recaptcha/enterprise.js'
1284
+ ];
1285
+ // `undefined` means the policy has not been created yet. `null` means Trusted
1286
+ // Types are unavailable or the policy could not be created.
1287
+ let trustedTypesPolicy;
1288
+ // True if the browser supports Trusted Types but the policy could not be
1289
+ // created, usually because the page's CSP does not allow the policy name.
1290
+ let trustedTypesPolicyBlocked = false;
1291
+ /**
1292
+ * Returns `url` if it is one of the allowed external scripts, and throws
1293
+ * otherwise. Used as the `createScriptURL` implementation of the Trusted Types
1294
+ * policy.
1295
+ *
1296
+ * @internal
1297
+ */
1298
+ function _createTrustedScriptURL(url) {
1299
+ const allowed = ALLOWED_SCRIPT_URLS.some(allowedUrl => url.startsWith(allowedUrl) &&
1300
+ // Only allow a query string after the allowed URL, so that e.g.
1301
+ // "https://apis.google.com/js/api.js.evil.com" is rejected.
1302
+ (url.length === allowedUrl.length ||
1303
+ url.charAt(allowedUrl.length) === '?'));
1304
+ if (!allowed) {
1305
+ throw new TypeError(`Firebase: Refusing to load untrusted script URL: ${url}`);
1306
+ }
1307
+ return url;
1308
+ }
1309
+ /**
1310
+ * Lazily creates the Trusted Types policy. The policy is only created the first
1311
+ * time a script is loaded, so that pages that load more than one copy of
1312
+ * `@firebase/app` (for example the compat and modular CDN builds) only run
1313
+ * into a policy name collision if more than one copy loads a script.
1314
+ */
1315
+ function getTrustedTypesPolicy() {
1316
+ if (trustedTypesPolicy === undefined) {
1317
+ trustedTypesPolicy = null;
1318
+ const trustedTypes = typeof window !== 'undefined' ? window.trustedTypes : undefined;
1319
+ if (trustedTypes?.createPolicy) {
1320
+ try {
1321
+ trustedTypesPolicy = trustedTypes.createPolicy(_TRUSTED_TYPES_POLICY_NAME, { createScriptURL: _createTrustedScriptURL });
1322
+ }
1323
+ catch {
1324
+ // The page's CSP does not allow this policy name, or a policy with
1325
+ // this name already exists. Fall back to assigning a plain string,
1326
+ // which still works unless the page also requires Trusted Types for
1327
+ // scripts. If it does, _setTrustedScriptSrc logs an error explaining
1328
+ // how to allow the policy.
1329
+ trustedTypesPolicyBlocked = true;
1330
+ }
1331
+ }
1332
+ }
1333
+ return trustedTypesPolicy;
1334
+ }
1335
+ /**
1336
+ * Sets the `src` of a script element through the Firebase Trusted Types policy
1337
+ * when Trusted Types are supported, so that Firebase SDKs can load external
1338
+ * scripts on pages that enforce Trusted Types.
1339
+ *
1340
+ * Throws if `url` is not an allowed Firebase script URL, or if the browser
1341
+ * rejects the assignment.
1342
+ *
1343
+ * @param script - The script element to update.
1344
+ * @param url - The script URL. Must be an allowed Firebase script URL.
1345
+ *
1346
+ * @internal
1347
+ */
1348
+ function _setTrustedScriptSrc(script, url) {
1349
+ // Validate the URL even when Trusted Types are unavailable, so that the
1350
+ // allowlist is enforced the same way in every browser.
1351
+ _createTrustedScriptURL(url);
1352
+ const policy = getTrustedTypesPolicy();
1353
+ if (policy) {
1354
+ // HTMLScriptElement.src is typed as a string, but accepts a
1355
+ // TrustedScriptURL.
1356
+ script.src = policy.createScriptURL(url);
1357
+ return;
1358
+ }
1359
+ try {
1360
+ script.src = url;
1361
+ }
1362
+ catch (e) {
1363
+ if (trustedTypesPolicyBlocked) {
1364
+ // The browser rejected the plain string because the page requires
1365
+ // Trusted Types, and the page's CSP did not allow our policy.
1366
+ logger.error(`Unable to load ${url} because this page requires Trusted Types ` +
1367
+ `for scripts but does not allow the "${_TRUSTED_TYPES_POLICY_NAME}" ` +
1368
+ `Trusted Types policy. To fix this, add ` +
1369
+ `"${_TRUSTED_TYPES_POLICY_NAME}" to the trusted-types directive ` +
1370
+ `of the page's Content-Security-Policy.`);
1371
+ }
1372
+ throw e;
1373
+ }
1374
+ }
1375
+
1247
1376
  /**
1248
1377
  * Firebase App
1249
1378
  *
@@ -1268,5 +1397,5 @@ function registerCoreComponents(variant) {
1268
1397
  */
1269
1398
  registerCoreComponents('');
1270
1399
 
1271
- export { SDK_VERSION, DEFAULT_ENTRY_NAME as _DEFAULT_ENTRY_NAME, _addComponent, _addOrOverwriteComponent, _apps, _clearComponents, _components, _getProvider, _isFirebaseApp, _isFirebaseServerApp, _isFirebaseServerAppSettings, _registerComponent, _removeServiceInstance, _serverApps, deleteApp, getApp, getApps, initializeApp, initializeServerApp, onLog, registerVersion, setLogLevel };
1400
+ export { SDK_VERSION, DEFAULT_ENTRY_NAME as _DEFAULT_ENTRY_NAME, _addComponent, _addOrOverwriteComponent, _apps, _clearComponents, _components, _getProvider, _isFirebaseApp, _isFirebaseServerApp, _isFirebaseServerAppSettings, _registerComponent, _removeServiceInstance, _serverApps, _setTrustedScriptSrc, deleteApp, getApp, getApps, initializeApp, initializeServerApp, onLog, registerVersion, setLogLevel };
1272
1401
  //# sourceMappingURL=index.esm.js.map