firebase 9.4.1 → 9.5.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/app/dist/index.cjs.js +1 -1
  3. package/app/dist/index.esm.js +1 -1
  4. package/app/dist/index.mjs +1 -1
  5. package/compat/app/dist/index.cjs.js +1 -1
  6. package/compat/app/dist/index.esm.js +1 -1
  7. package/compat/app/dist/index.mjs +1 -1
  8. package/compat/dist/index.esm.js +2 -2
  9. package/compat/dist/index.node.cjs +2 -2
  10. package/compat/dist/index.rn.cjs.js +2 -2
  11. package/firebase-analytics.js +3 -3
  12. package/firebase-app-check-compat.js +2 -2
  13. package/firebase-app-check-compat.js.map +1 -1
  14. package/firebase-app-check.js +285 -50
  15. package/firebase-app-check.js.map +1 -1
  16. package/firebase-app-compat.js +2 -2
  17. package/firebase-app-compat.js.map +1 -1
  18. package/firebase-app.js +9 -9
  19. package/firebase-auth.js +2 -2
  20. package/firebase-compat.js +4 -4
  21. package/firebase-compat.js.map +1 -1
  22. package/firebase-database.js +4 -4
  23. package/firebase-firestore-compat.js +1 -1
  24. package/firebase-firestore-compat.js.map +1 -1
  25. package/firebase-firestore-lite.js +7 -7
  26. package/firebase-firestore-lite.js.map +1 -1
  27. package/firebase-firestore.js +12 -12
  28. package/firebase-firestore.js.map +1 -1
  29. package/firebase-functions.js +2 -2
  30. package/firebase-messaging-sw.js +1 -1
  31. package/firebase-messaging.js +1 -1
  32. package/firebase-performance-standalone-compat.es2017.js +5 -5
  33. package/firebase-performance-standalone-compat.es2017.js.map +1 -1
  34. package/firebase-performance-standalone-compat.js +1 -1
  35. package/firebase-performance-standalone-compat.js.map +1 -1
  36. package/firebase-performance.js +3 -3
  37. package/firebase-remote-config.js +2 -2
  38. package/firebase-storage-compat.js +1 -1
  39. package/firebase-storage-compat.js.map +1 -1
  40. package/firebase-storage.js +177 -24
  41. package/firebase-storage.js.map +1 -1
  42. package/package.json +9 -9
@@ -1,4 +1,4 @@
1
- import { getApp, _getProvider, _registerComponent, registerVersion, SDK_VERSION } from 'https://www.gstatic.com/firebasejs/9.4.1/firebase-app.js';
1
+ import { getApp, _getProvider, _registerComponent, registerVersion, SDK_VERSION } from 'https://www.gstatic.com/firebasejs/9.5.0/firebase-app.js';
2
2
 
3
3
  /**
4
4
  * @license
@@ -1073,6 +1073,14 @@ var ErrorCode;
1073
1073
  * See the License for the specific language governing permissions and
1074
1074
  * limitations under the License.
1075
1075
  */
1076
+ /**
1077
+ * Handles network logic for all Storage Requests, including error reporting and
1078
+ * retries with backoff.
1079
+ *
1080
+ * @param I - the type of the backend's network response.
1081
+ * @param - O the output type used by the rest of the SDK. The conversion
1082
+ * happens in the specified `callback_`.
1083
+ */
1076
1084
  class NetworkRequest {
1077
1085
  constructor(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, connectionFactory_) {
1078
1086
  this.url_ = url_;
@@ -1149,7 +1157,7 @@ class NetworkRequest {
1149
1157
  const connection = status.connection;
1150
1158
  if (status.wasSuccessCode) {
1151
1159
  try {
1152
- const result = this.callback_(connection, connection.getResponseText());
1160
+ const result = this.callback_(connection, connection.getResponse());
1153
1161
  if (isJustDef(result)) {
1154
1162
  resolve(result);
1155
1163
  }
@@ -1164,7 +1172,7 @@ class NetworkRequest {
1164
1172
  else {
1165
1173
  if (connection !== null) {
1166
1174
  const err = unknown();
1167
- err.serverResponse = connection.getResponseText();
1175
+ err.serverResponse = connection.getErrorText();
1168
1176
  if (this.errorCallback_) {
1169
1177
  reject(this.errorCallback_(connection, err));
1170
1178
  }
@@ -1295,7 +1303,7 @@ function getBlobBuilder() {
1295
1303
  * @param args The values that will make up the resulting blob.
1296
1304
  * @return The blob.
1297
1305
  */
1298
- function getBlob(...args) {
1306
+ function getBlob$1(...args) {
1299
1307
  const BlobBuilder = getBlobBuilder();
1300
1308
  if (BlobBuilder !== undefined) {
1301
1309
  const bb = new BlobBuilder();
@@ -1645,7 +1653,7 @@ class FbsBlob {
1645
1653
  return val;
1646
1654
  }
1647
1655
  });
1648
- return new FbsBlob(getBlob.apply(null, blobby));
1656
+ return new FbsBlob(getBlob$1.apply(null, blobby));
1649
1657
  }
1650
1658
  else {
1651
1659
  const uint8Arrays = args.map((val) => {
@@ -1967,6 +1975,12 @@ function fromResponseString(service, bucket, resourceString) {
1967
1975
  return fromBackendResponse(service, bucket, resource);
1968
1976
  }
1969
1977
 
1978
+ /**
1979
+ * Contains a fully specified request.
1980
+ *
1981
+ * @param I - the type of the backend's network response.
1982
+ * @param O - the output response type used by the rest of the SDK.
1983
+ */
1970
1984
  class RequestInfo {
1971
1985
  constructor(url, method,
1972
1986
  /**
@@ -2050,7 +2064,7 @@ function sharedErrorHandler(location) {
2050
2064
  if (
2051
2065
  // This exact message string is the only consistent part of the
2052
2066
  // server's error response that identifies it as an App Check error.
2053
- xhr.getResponseText().includes('Firebase App Check token is invalid')) {
2067
+ xhr.getErrorText().includes('Firebase App Check token is invalid')) {
2054
2068
  newErr = unauthorizedApp();
2055
2069
  }
2056
2070
  else {
@@ -2122,6 +2136,19 @@ function list$2(service, location, delimiter, pageToken, maxResults) {
2122
2136
  requestInfo.errorHandler = sharedErrorHandler(location);
2123
2137
  return requestInfo;
2124
2138
  }
2139
+ function getBytes$1(service, location, maxDownloadSizeBytes) {
2140
+ const urlPart = location.fullServerUrl();
2141
+ const url = makeUrl(urlPart, service.host, service._protocol) + '?alt=media';
2142
+ const method = 'GET';
2143
+ const timeout = service.maxOperationRetryTime;
2144
+ const requestInfo = new RequestInfo(url, method, (_, data) => data, timeout);
2145
+ requestInfo.errorHandler = objectErrorHandler(location);
2146
+ if (maxDownloadSizeBytes !== undefined) {
2147
+ requestInfo.headers['Range'] = `bytes=0-${maxDownloadSizeBytes}`;
2148
+ requestInfo.successCodes = [200 /* OK */, 206 /* Partial Content */];
2149
+ }
2150
+ return requestInfo;
2151
+ }
2125
2152
  function getDownloadUrl(service, location, mappings) {
2126
2153
  const urlPart = location.fullServerUrl();
2127
2154
  const url = makeUrl(urlPart, service.host, service._protocol);
@@ -2518,6 +2545,7 @@ class XhrConnection {
2518
2545
  constructor() {
2519
2546
  this.sent_ = false;
2520
2547
  this.xhr_ = new XMLHttpRequest();
2548
+ this.initXhr();
2521
2549
  this.errorCode_ = ErrorCode.NO_ERROR;
2522
2550
  this.sendPromise_ = new Promise(resolve => {
2523
2551
  this.xhr_.addEventListener('abort', () => {
@@ -2571,11 +2599,17 @@ class XhrConnection {
2571
2599
  return -1;
2572
2600
  }
2573
2601
  }
2574
- getResponseText() {
2602
+ getResponse() {
2575
2603
  if (!this.sent_) {
2576
- throw internalError('cannot .getResponseText() before sending');
2604
+ throw internalError('cannot .getResponse() before sending');
2577
2605
  }
2578
- return this.xhr_.responseText;
2606
+ return this.xhr_.response;
2607
+ }
2608
+ getErrorText() {
2609
+ if (!this.sent_) {
2610
+ throw internalError('cannot .getErrorText() before sending');
2611
+ }
2612
+ return this.xhr_.statusText;
2579
2613
  }
2580
2614
  /** Aborts the request. */
2581
2615
  abort() {
@@ -2595,8 +2629,29 @@ class XhrConnection {
2595
2629
  }
2596
2630
  }
2597
2631
  }
2598
- function newConnection() {
2599
- return new XhrConnection();
2632
+ class XhrTextConnection extends XhrConnection {
2633
+ initXhr() {
2634
+ this.xhr_.responseType = 'text';
2635
+ }
2636
+ }
2637
+ function newTextConnection() {
2638
+ return new XhrTextConnection();
2639
+ }
2640
+ class XhrBytesConnection extends XhrConnection {
2641
+ initXhr() {
2642
+ this.xhr_.responseType = 'arraybuffer';
2643
+ }
2644
+ }
2645
+ function newBytesConnection() {
2646
+ return new XhrBytesConnection();
2647
+ }
2648
+ class XhrBlobConnection extends XhrConnection {
2649
+ initXhr() {
2650
+ this.xhr_.responseType = 'blob';
2651
+ }
2652
+ }
2653
+ function newBlobConnection() {
2654
+ return new XhrBlobConnection();
2600
2655
  }
2601
2656
 
2602
2657
  /**
@@ -2738,7 +2793,7 @@ class UploadTask {
2738
2793
  _createResumable() {
2739
2794
  this._resolveToken((authToken, appCheckToken) => {
2740
2795
  const requestInfo = createResumableUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata);
2741
- const createRequest = this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
2796
+ const createRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
2742
2797
  this._request = createRequest;
2743
2798
  createRequest.getPromise().then((url) => {
2744
2799
  this._request = undefined;
@@ -2753,7 +2808,7 @@ class UploadTask {
2753
2808
  const url = this._uploadUrl;
2754
2809
  this._resolveToken((authToken, appCheckToken) => {
2755
2810
  const requestInfo = getResumableUploadStatus(this._ref.storage, this._ref._location, url, this._blob);
2756
- const statusRequest = this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
2811
+ const statusRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
2757
2812
  this._request = statusRequest;
2758
2813
  statusRequest.getPromise().then(status => {
2759
2814
  status = status;
@@ -2782,7 +2837,7 @@ class UploadTask {
2782
2837
  this._transition("error" /* ERROR */);
2783
2838
  return;
2784
2839
  }
2785
- const uploadRequest = this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
2840
+ const uploadRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
2786
2841
  this._request = uploadRequest;
2787
2842
  uploadRequest.getPromise().then((newStatus) => {
2788
2843
  this._increaseMultiplier();
@@ -2808,7 +2863,7 @@ class UploadTask {
2808
2863
  _fetchMetadata() {
2809
2864
  this._resolveToken((authToken, appCheckToken) => {
2810
2865
  const requestInfo = getMetadata$2(this._ref.storage, this._ref._location, this._mappings);
2811
- const metadataRequest = this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
2866
+ const metadataRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
2812
2867
  this._request = metadataRequest;
2813
2868
  metadataRequest.getPromise().then(metadata => {
2814
2869
  this._request = undefined;
@@ -2820,7 +2875,7 @@ class UploadTask {
2820
2875
  _oneShotUpload() {
2821
2876
  this._resolveToken((authToken, appCheckToken) => {
2822
2877
  const requestInfo = multipartUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata);
2823
- const multipartRequest = this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
2878
+ const multipartRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
2824
2879
  this._request = multipartRequest;
2825
2880
  multipartRequest.getPromise().then(metadata => {
2826
2881
  this._request = undefined;
@@ -3185,6 +3240,34 @@ class Reference {
3185
3240
  }
3186
3241
  }
3187
3242
  }
3243
+ /**
3244
+ * Download the bytes at the object's location.
3245
+ * @returns A Promise containing the downloaded bytes.
3246
+ */
3247
+ function getBytesInternal(ref, maxDownloadSizeBytes) {
3248
+ ref._throwIfRoot('getBytes');
3249
+ const requestInfo = getBytes$1(ref.storage, ref._location, maxDownloadSizeBytes);
3250
+ return ref.storage
3251
+ .makeRequestWithTokens(requestInfo, newBytesConnection)
3252
+ .then(bytes => maxDownloadSizeBytes !== undefined
3253
+ ? // GCS may not honor the Range header for small files
3254
+ bytes.slice(0, maxDownloadSizeBytes)
3255
+ : bytes);
3256
+ }
3257
+ /**
3258
+ * Download the bytes at the object's location.
3259
+ * @returns A Promise containing the downloaded blob.
3260
+ */
3261
+ function getBlobInternal(ref, maxDownloadSizeBytes) {
3262
+ ref._throwIfRoot('getBlob');
3263
+ const requestInfo = getBytes$1(ref.storage, ref._location, maxDownloadSizeBytes);
3264
+ return ref.storage
3265
+ .makeRequestWithTokens(requestInfo, newBlobConnection)
3266
+ .then(blob => maxDownloadSizeBytes !== undefined
3267
+ ? // GCS may not honor the Range header for small files
3268
+ blob.slice(0, maxDownloadSizeBytes)
3269
+ : blob);
3270
+ }
3188
3271
  /**
3189
3272
  * Uploads data to this object's location.
3190
3273
  * The upload is not resumable.
@@ -3198,7 +3281,7 @@ function uploadBytes$1(ref, data, metadata) {
3198
3281
  ref._throwIfRoot('uploadBytes');
3199
3282
  const requestInfo = multipartUpload(ref.storage, ref._location, getMappings(), new FbsBlob(data, true), metadata);
3200
3283
  return ref.storage
3201
- .makeRequestWithTokens(requestInfo, newConnection)
3284
+ .makeRequestWithTokens(requestInfo, newTextConnection)
3202
3285
  .then(finalMetadata => {
3203
3286
  return {
3204
3287
  metadata: finalMetadata,
@@ -3315,7 +3398,7 @@ function list$1(ref, options) {
3315
3398
  const op = options || {};
3316
3399
  const requestInfo = list$2(ref.storage, ref._location,
3317
3400
  /*delimiter= */ '/', op.pageToken, op.maxResults);
3318
- return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
3401
+ return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);
3319
3402
  }
3320
3403
  /**
3321
3404
  * A `Promise` that resolves with the metadata for this object. If this
@@ -3327,7 +3410,7 @@ function list$1(ref, options) {
3327
3410
  function getMetadata$1(ref) {
3328
3411
  ref._throwIfRoot('getMetadata');
3329
3412
  const requestInfo = getMetadata$2(ref.storage, ref._location, getMappings());
3330
- return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
3413
+ return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);
3331
3414
  }
3332
3415
  /**
3333
3416
  * Updates the metadata for this object.
@@ -3343,7 +3426,7 @@ function getMetadata$1(ref) {
3343
3426
  function updateMetadata$1(ref, metadata) {
3344
3427
  ref._throwIfRoot('updateMetadata');
3345
3428
  const requestInfo = updateMetadata$2(ref.storage, ref._location, metadata, getMappings());
3346
- return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
3429
+ return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);
3347
3430
  }
3348
3431
  /**
3349
3432
  * Returns the download URL for the given Reference.
@@ -3355,7 +3438,7 @@ function getDownloadURL$1(ref) {
3355
3438
  ref._throwIfRoot('getDownloadURL');
3356
3439
  const requestInfo = getDownloadUrl(ref.storage, ref._location, getMappings());
3357
3440
  return ref.storage
3358
- .makeRequestWithTokens(requestInfo, newConnection)
3441
+ .makeRequestWithTokens(requestInfo, newTextConnection)
3359
3442
  .then(url => {
3360
3443
  if (url === null) {
3361
3444
  throw noDownloadURL();
@@ -3372,7 +3455,7 @@ function getDownloadURL$1(ref) {
3372
3455
  function deleteObject$1(ref) {
3373
3456
  ref._throwIfRoot('deleteObject');
3374
3457
  const requestInfo = deleteObject$2(ref.storage, ref._location);
3375
- return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
3458
+ return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);
3376
3459
  }
3377
3460
  /**
3378
3461
  * Returns reference for object obtained by appending `childPath` to `ref`.
@@ -3629,7 +3712,7 @@ class FirebaseStorageImpl {
3629
3712
  }
3630
3713
 
3631
3714
  const name = "@firebase/storage";
3632
- const version = "0.8.7";
3715
+ const version = "0.9.0";
3633
3716
 
3634
3717
  /**
3635
3718
  * @license
@@ -3668,6 +3751,24 @@ const STORAGE_TYPE = 'storage';
3668
3751
  * See the License for the specific language governing permissions and
3669
3752
  * limitations under the License.
3670
3753
  */
3754
+ /**
3755
+ * Downloads the data at the object's location. Returns an error if the object
3756
+ * is not found.
3757
+ *
3758
+ * To use this functionality, you have to whitelist your app's origin in your
3759
+ * Cloud Storage bucket. See also
3760
+ * https://cloud.google.com/storage/docs/configuring-cors
3761
+ *
3762
+ * @public
3763
+ * @param ref - StorageReference where data should be downloaded.
3764
+ * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
3765
+ * retrieve.
3766
+ * @returns A Promise containing the object's bytes
3767
+ */
3768
+ function getBytes(ref, maxDownloadSizeBytes) {
3769
+ ref = getModularInstance(ref);
3770
+ return getBytesInternal(ref, maxDownloadSizeBytes);
3771
+ }
3671
3772
  /**
3672
3773
  * Uploads data to this object's location.
3673
3774
  * The upload is not resumable.
@@ -3842,6 +3943,58 @@ function connectStorageEmulator(storage, host, port, options = {}) {
3842
3943
  connectStorageEmulator$1(storage, host, port, options);
3843
3944
  }
3844
3945
 
3946
+ /**
3947
+ * @license
3948
+ * Copyright 2021 Google LLC
3949
+ *
3950
+ * Licensed under the Apache License, Version 2.0 (the "License");
3951
+ * you may not use this file except in compliance with the License.
3952
+ * You may obtain a copy of the License at
3953
+ *
3954
+ * http://www.apache.org/licenses/LICENSE-2.0
3955
+ *
3956
+ * Unless required by applicable law or agreed to in writing, software
3957
+ * distributed under the License is distributed on an "AS IS" BASIS,
3958
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3959
+ * See the License for the specific language governing permissions and
3960
+ * limitations under the License.
3961
+ */
3962
+ /**
3963
+ * Downloads the data at the object's location. Returns an error if the object
3964
+ * is not found.
3965
+ *
3966
+ * To use this functionality, you have to whitelist your app's origin in your
3967
+ * Cloud Storage bucket. See also
3968
+ * https://cloud.google.com/storage/docs/configuring-cors
3969
+ *
3970
+ * This API is not available in Node.
3971
+ *
3972
+ * @public
3973
+ * @param ref - StorageReference where data should be downloaded.
3974
+ * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
3975
+ * retrieve.
3976
+ * @returns A Promise that resolves with a Blob containing the object's bytes
3977
+ */
3978
+ function getBlob(ref, maxDownloadSizeBytes) {
3979
+ ref = getModularInstance(ref);
3980
+ return getBlobInternal(ref, maxDownloadSizeBytes);
3981
+ }
3982
+ /**
3983
+ * Downloads the data at the object's location. Raises an error event if the
3984
+ * object is not found.
3985
+ *
3986
+ * This API is only available in Node.
3987
+ *
3988
+ * @public
3989
+ * @param ref - StorageReference where data should be downloaded.
3990
+ * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
3991
+ * retrieve.
3992
+ * @returns A stream with the object's data as bytes
3993
+ */
3994
+ function getStream(ref, maxDownloadSizeBytes) {
3995
+ throw new Error('getStream() is only supported by NodeJS builds');
3996
+ }
3997
+
3845
3998
  /**
3846
3999
  * Cloud Storage for Firebase
3847
4000
  *
@@ -3862,6 +4015,6 @@ function registerStorage() {
3862
4015
  }
3863
4016
  registerStorage();
3864
4017
 
3865
- export { StringFormat, FbsBlob as _FbsBlob, Location as _Location, TaskEvent as _TaskEvent, TaskState as _TaskState, UploadTask as _UploadTask, dataFromString as _dataFromString, _getChild, invalidArgument as _invalidArgument, invalidRootOperation as _invalidRootOperation, connectStorageEmulator, deleteObject, getDownloadURL, getMetadata, getStorage, list, listAll, ref, updateMetadata, uploadBytes, uploadBytesResumable, uploadString };
4018
+ export { StringFormat, FbsBlob as _FbsBlob, Location as _Location, TaskEvent as _TaskEvent, TaskState as _TaskState, UploadTask as _UploadTask, dataFromString as _dataFromString, _getChild, invalidArgument as _invalidArgument, invalidRootOperation as _invalidRootOperation, connectStorageEmulator, deleteObject, getBlob, getBytes, getDownloadURL, getMetadata, getStorage, getStream, list, listAll, ref, updateMetadata, uploadBytes, uploadBytesResumable, uploadString };
3866
4019
 
3867
4020
  //# sourceMappingURL=firebase-storage.js.map