@firebase/storage 0.8.6 → 0.8.7-canary.ce39a1a07

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 (48) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/index.browser.cjs.js +215 -31
  3. package/dist/index.browser.cjs.js.map +1 -1
  4. package/dist/index.esm2017.js +194 -32
  5. package/dist/index.esm2017.js.map +1 -1
  6. package/dist/index.esm5.js +213 -32
  7. package/dist/index.esm5.js.map +1 -1
  8. package/dist/index.node.cjs.js +262 -51
  9. package/dist/index.node.cjs.js.map +1 -1
  10. package/dist/node-esm/index.node.esm.js +206 -52
  11. package/dist/node-esm/index.node.esm.js.map +1 -1
  12. package/dist/node-esm/src/api.browser.d.ts +32 -1
  13. package/dist/node-esm/src/api.d.ts +15 -0
  14. package/dist/node-esm/src/api.node.d.ts +32 -1
  15. package/dist/node-esm/src/implementation/connection.d.ts +14 -4
  16. package/dist/node-esm/src/implementation/request.d.ts +5 -5
  17. package/dist/node-esm/src/implementation/requestinfo.d.ts +14 -6
  18. package/dist/node-esm/src/implementation/requests.d.ts +17 -16
  19. package/dist/node-esm/src/platform/browser/connection.d.ts +24 -7
  20. package/dist/node-esm/src/platform/connection.d.ts +6 -2
  21. package/dist/node-esm/src/platform/node/connection.d.ts +30 -14
  22. package/dist/node-esm/src/reference.d.ts +13 -0
  23. package/dist/node-esm/src/service.d.ts +3 -3
  24. package/dist/node-esm/test/integration/integration.test.d.ts +4 -0
  25. package/dist/node-esm/test/{unit → node}/connection.test.d.ts +0 -0
  26. package/dist/{test/unit/connection.test.d.ts → node-esm/test/node/stream.test.d.ts} +0 -0
  27. package/dist/node-esm/test/unit/connection.d.ts +4 -3
  28. package/dist/node-esm/test/unit/testshared.d.ts +2 -2
  29. package/dist/src/api.browser.d.ts +32 -1
  30. package/dist/src/api.d.ts +15 -0
  31. package/dist/src/api.node.d.ts +32 -1
  32. package/dist/src/implementation/connection.d.ts +14 -4
  33. package/dist/src/implementation/request.d.ts +5 -5
  34. package/dist/src/implementation/requestinfo.d.ts +14 -6
  35. package/dist/src/implementation/requests.d.ts +17 -16
  36. package/dist/src/platform/browser/connection.d.ts +24 -7
  37. package/dist/src/platform/connection.d.ts +6 -2
  38. package/dist/src/platform/node/connection.d.ts +30 -14
  39. package/dist/src/reference.d.ts +13 -0
  40. package/dist/src/service.d.ts +3 -3
  41. package/dist/storage-public.d.ts +46 -0
  42. package/dist/storage.d.ts +80 -11
  43. package/dist/test/integration/integration.test.d.ts +4 -0
  44. package/dist/test/node/connection.test.d.ts +17 -0
  45. package/dist/test/node/stream.test.d.ts +17 -0
  46. package/dist/test/unit/connection.d.ts +4 -3
  47. package/dist/test/unit/testshared.d.ts +2 -2
  48. package/package.json +6 -6
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var app = require('@firebase/app');
6
6
  var util = require('@firebase/util');
7
+ var stream = require('stream');
7
8
  var nodeFetch = require('node-fetch');
8
9
  var component = require('@firebase/component');
9
10
 
@@ -345,7 +346,9 @@ callback, timeout) {
345
346
  // Would type this as "number" but that doesn't work for Node so ¯\_(ツ)_/¯
346
347
  // TODO: find a way to exclude Node type definition for storage because storage only works in browser
347
348
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
348
- let timeoutId = null;
349
+ let retryTimeoutId = null;
350
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
351
+ let globalTimeoutId = null;
349
352
  let hitTimeout = false;
350
353
  let cancelState = 0;
351
354
  function canceled() {
@@ -359,21 +362,29 @@ callback, timeout) {
359
362
  }
360
363
  }
361
364
  function callWithDelay(millis) {
362
- timeoutId = setTimeout(() => {
363
- timeoutId = null;
365
+ retryTimeoutId = setTimeout(() => {
366
+ retryTimeoutId = null;
364
367
  f(handler, canceled());
365
368
  }, millis);
366
369
  }
370
+ function clearGlobalTimeout() {
371
+ if (globalTimeoutId) {
372
+ clearTimeout(globalTimeoutId);
373
+ }
374
+ }
367
375
  function handler(success, ...args) {
368
376
  if (triggeredCallback) {
377
+ clearGlobalTimeout();
369
378
  return;
370
379
  }
371
380
  if (success) {
381
+ clearGlobalTimeout();
372
382
  triggerCallback.call(null, success, ...args);
373
383
  return;
374
384
  }
375
385
  const mustStop = canceled() || hitTimeout;
376
386
  if (mustStop) {
387
+ clearGlobalTimeout();
377
388
  triggerCallback.call(null, success, ...args);
378
389
  return;
379
390
  }
@@ -397,14 +408,15 @@ callback, timeout) {
397
408
  return;
398
409
  }
399
410
  stopped = true;
411
+ clearGlobalTimeout();
400
412
  if (triggeredCallback) {
401
413
  return;
402
414
  }
403
- if (timeoutId !== null) {
415
+ if (retryTimeoutId !== null) {
404
416
  if (!wasTimeout) {
405
417
  cancelState = 2;
406
418
  }
407
- clearTimeout(timeoutId);
419
+ clearTimeout(retryTimeoutId);
408
420
  callWithDelay(0);
409
421
  }
410
422
  else {
@@ -414,7 +426,7 @@ callback, timeout) {
414
426
  }
415
427
  }
416
428
  callWithDelay(0);
417
- setTimeout(() => {
429
+ globalTimeoutId = setTimeout(() => {
418
430
  hitTimeout = true;
419
431
  stop(true);
420
432
  }, timeout);
@@ -554,6 +566,14 @@ var ErrorCode;
554
566
  * See the License for the specific language governing permissions and
555
567
  * limitations under the License.
556
568
  */
569
+ /**
570
+ * Handles network logic for all Storage Requests, including error reporting and
571
+ * retries with backoff.
572
+ *
573
+ * @param I - the type of the backend's network response.
574
+ * @param - O the output type used by the rest of the SDK. The conversion
575
+ * happens in the specified `callback_`.
576
+ */
557
577
  class NetworkRequest {
558
578
  constructor(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, connectionFactory_) {
559
579
  this.url_ = url_;
@@ -630,7 +650,7 @@ class NetworkRequest {
630
650
  const connection = status.connection;
631
651
  if (status.wasSuccessCode) {
632
652
  try {
633
- const result = this.callback_(connection, connection.getResponseText());
653
+ const result = this.callback_(connection, connection.getResponse());
634
654
  if (isJustDef(result)) {
635
655
  resolve(result);
636
656
  }
@@ -645,7 +665,7 @@ class NetworkRequest {
645
665
  else {
646
666
  if (connection !== null) {
647
667
  const err = unknown();
648
- err.serverResponse = connection.getResponseText();
668
+ err.serverResponse = connection.getErrorText();
649
669
  if (this.errorCallback_) {
650
670
  reject(this.errorCallback_(connection, err));
651
671
  }
@@ -776,7 +796,7 @@ function getBlobBuilder() {
776
796
  * @param args The values that will make up the resulting blob.
777
797
  * @return The blob.
778
798
  */
779
- function getBlob(...args) {
799
+ function getBlob$1(...args) {
780
800
  const BlobBuilder = getBlobBuilder();
781
801
  if (BlobBuilder !== undefined) {
782
802
  const bb = new BlobBuilder();
@@ -1131,7 +1151,7 @@ class FbsBlob {
1131
1151
  return val;
1132
1152
  }
1133
1153
  });
1134
- return new FbsBlob(getBlob.apply(null, blobby));
1154
+ return new FbsBlob(getBlob$1.apply(null, blobby));
1135
1155
  }
1136
1156
  else {
1137
1157
  const uint8Arrays = args.map((val) => {
@@ -1453,6 +1473,12 @@ function fromResponseString(service, bucket, resourceString) {
1453
1473
  return fromBackendResponse(service, bucket, resource);
1454
1474
  }
1455
1475
 
1476
+ /**
1477
+ * Contains a fully specified request.
1478
+ *
1479
+ * @param I - the type of the backend's network response.
1480
+ * @param O - the output response type used by the rest of the SDK.
1481
+ */
1456
1482
  class RequestInfo {
1457
1483
  constructor(url, method,
1458
1484
  /**
@@ -1536,7 +1562,7 @@ function sharedErrorHandler(location) {
1536
1562
  if (
1537
1563
  // This exact message string is the only consistent part of the
1538
1564
  // server's error response that identifies it as an App Check error.
1539
- xhr.getResponseText().includes('Firebase App Check token is invalid')) {
1565
+ xhr.getErrorText().includes('Firebase App Check token is invalid')) {
1540
1566
  newErr = unauthorizedApp();
1541
1567
  }
1542
1568
  else {
@@ -1608,6 +1634,19 @@ function list$2(service, location, delimiter, pageToken, maxResults) {
1608
1634
  requestInfo.errorHandler = sharedErrorHandler(location);
1609
1635
  return requestInfo;
1610
1636
  }
1637
+ function getBytes$1(service, location, maxDownloadSizeBytes) {
1638
+ const urlPart = location.fullServerUrl();
1639
+ const url = makeUrl(urlPart, service.host, service._protocol) + '?alt=media';
1640
+ const method = 'GET';
1641
+ const timeout = service.maxOperationRetryTime;
1642
+ const requestInfo = new RequestInfo(url, method, (_, data) => data, timeout);
1643
+ requestInfo.errorHandler = objectErrorHandler(location);
1644
+ if (maxDownloadSizeBytes !== undefined) {
1645
+ requestInfo.headers['Range'] = `bytes=0-${maxDownloadSizeBytes}`;
1646
+ requestInfo.successCodes = [200 /* OK */, 206 /* Partial Content */];
1647
+ }
1648
+ return requestInfo;
1649
+ }
1611
1650
  function getDownloadUrl(service, location, mappings) {
1612
1651
  const urlPart = location.fullServerUrl();
1613
1652
  const url = makeUrl(urlPart, service.host, service._protocol);
@@ -2014,7 +2053,7 @@ function async(f) {
2014
2053
  * limitations under the License.
2015
2054
  */
2016
2055
  /** An override for the text-based Connection. Used in tests. */
2017
- let connectionFactoryOverride = null;
2056
+ let textFactoryOverride = null;
2018
2057
  /**
2019
2058
  * Network layer that works in Node.
2020
2059
  *
@@ -2023,31 +2062,33 @@ let connectionFactoryOverride = null;
2023
2062
  */
2024
2063
  class FetchConnection {
2025
2064
  constructor() {
2065
+ this.errorText_ = '';
2026
2066
  this.sent_ = false;
2027
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2028
2067
  this.fetch_ = nodeFetch__default["default"];
2029
2068
  this.errorCode_ = ErrorCode.NO_ERROR;
2030
2069
  }
2031
- send(url, method, body, headers) {
2070
+ async send(url, method, body, headers) {
2032
2071
  if (this.sent_) {
2033
2072
  throw internalError('cannot .send() more than once');
2034
2073
  }
2035
2074
  this.sent_ = true;
2036
- return this.fetch_(url, {
2037
- method,
2038
- headers: headers || {},
2039
- body
2040
- }).then(resp => {
2041
- this.headers_ = resp.headers;
2042
- this.statusCode_ = resp.status;
2043
- return resp.text().then(body => {
2044
- this.body_ = body;
2075
+ try {
2076
+ const response = await this.fetch_(url, {
2077
+ method,
2078
+ headers: headers || {},
2079
+ body: body
2045
2080
  });
2046
- }, (_err) => {
2047
- this.errorCode_ = ErrorCode.NETWORK_ERROR;
2081
+ this.headers_ = response.headers;
2082
+ this.statusCode_ = response.status;
2083
+ this.errorCode_ = ErrorCode.NO_ERROR;
2084
+ this.body_ = await response.arrayBuffer();
2085
+ }
2086
+ catch (e) {
2087
+ this.errorText_ = e.message;
2048
2088
  // emulate XHR which sets status to 0 when encountering a network error
2049
2089
  this.statusCode_ = 0;
2050
- });
2090
+ this.errorCode_ = ErrorCode.NETWORK_ERROR;
2091
+ }
2051
2092
  }
2052
2093
  getErrorCode() {
2053
2094
  if (this.errorCode_ === undefined) {
@@ -2061,35 +2102,86 @@ class FetchConnection {
2061
2102
  }
2062
2103
  return this.statusCode_;
2063
2104
  }
2064
- getResponseText() {
2065
- if (this.body_ === undefined) {
2066
- throw internalError('cannot .getResponseText() before receiving response');
2067
- }
2068
- return this.body_;
2105
+ getErrorText() {
2106
+ return this.errorText_;
2069
2107
  }
2070
2108
  abort() {
2071
2109
  // Not supported
2072
2110
  }
2073
2111
  getResponseHeader(header) {
2074
2112
  if (!this.headers_) {
2075
- throw internalError('cannot .getResponseText() before receiving response');
2113
+ throw internalError('cannot .getResponseHeader() before receiving response');
2076
2114
  }
2077
2115
  return this.headers_.get(header);
2078
2116
  }
2079
2117
  addUploadProgressListener(listener) {
2080
2118
  // Not supported
2081
2119
  }
2082
- /**
2083
- * @override
2084
- */
2085
2120
  removeUploadProgressListener(listener) {
2086
2121
  // Not supported
2087
2122
  }
2088
2123
  }
2089
- function newConnection() {
2090
- return connectionFactoryOverride
2091
- ? connectionFactoryOverride()
2092
- : new FetchConnection();
2124
+ class FetchTextConnection extends FetchConnection {
2125
+ getResponse() {
2126
+ if (!this.body_) {
2127
+ throw internalError('cannot .getResponse() before receiving response');
2128
+ }
2129
+ return Buffer.from(this.body_).toString('utf-8');
2130
+ }
2131
+ }
2132
+ function newTextConnection() {
2133
+ return textFactoryOverride
2134
+ ? textFactoryOverride()
2135
+ : new FetchTextConnection();
2136
+ }
2137
+ class FetchBytesConnection extends FetchConnection {
2138
+ getResponse() {
2139
+ if (!this.body_) {
2140
+ throw internalError('cannot .getResponse() before sending');
2141
+ }
2142
+ return this.body_;
2143
+ }
2144
+ }
2145
+ function newBytesConnection() {
2146
+ return new FetchBytesConnection();
2147
+ }
2148
+ class FetchStreamConnection extends FetchConnection {
2149
+ constructor() {
2150
+ super(...arguments);
2151
+ this.stream_ = null;
2152
+ }
2153
+ async send(url, method, body, headers) {
2154
+ if (this.sent_) {
2155
+ throw internalError('cannot .send() more than once');
2156
+ }
2157
+ this.sent_ = true;
2158
+ try {
2159
+ const response = await this.fetch_(url, {
2160
+ method,
2161
+ headers: headers || {},
2162
+ body: body
2163
+ });
2164
+ this.headers_ = response.headers;
2165
+ this.statusCode_ = response.status;
2166
+ this.errorCode_ = ErrorCode.NO_ERROR;
2167
+ this.stream_ = response.body;
2168
+ }
2169
+ catch (e) {
2170
+ this.errorText_ = e.message;
2171
+ // emulate XHR which sets status to 0 when encountering a network error
2172
+ this.statusCode_ = 0;
2173
+ this.errorCode_ = ErrorCode.NETWORK_ERROR;
2174
+ }
2175
+ }
2176
+ getResponse() {
2177
+ if (!this.stream_) {
2178
+ throw internalError('cannot .getResponse() before sending');
2179
+ }
2180
+ return this.stream_;
2181
+ }
2182
+ }
2183
+ function newStreamConnection() {
2184
+ return new FetchStreamConnection();
2093
2185
  }
2094
2186
 
2095
2187
  /**
@@ -2231,7 +2323,7 @@ class UploadTask {
2231
2323
  _createResumable() {
2232
2324
  this._resolveToken((authToken, appCheckToken) => {
2233
2325
  const requestInfo = createResumableUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata);
2234
- const createRequest = this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
2326
+ const createRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
2235
2327
  this._request = createRequest;
2236
2328
  createRequest.getPromise().then((url) => {
2237
2329
  this._request = undefined;
@@ -2246,7 +2338,7 @@ class UploadTask {
2246
2338
  const url = this._uploadUrl;
2247
2339
  this._resolveToken((authToken, appCheckToken) => {
2248
2340
  const requestInfo = getResumableUploadStatus(this._ref.storage, this._ref._location, url, this._blob);
2249
- const statusRequest = this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
2341
+ const statusRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
2250
2342
  this._request = statusRequest;
2251
2343
  statusRequest.getPromise().then(status => {
2252
2344
  status = status;
@@ -2275,7 +2367,7 @@ class UploadTask {
2275
2367
  this._transition("error" /* ERROR */);
2276
2368
  return;
2277
2369
  }
2278
- const uploadRequest = this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
2370
+ const uploadRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
2279
2371
  this._request = uploadRequest;
2280
2372
  uploadRequest.getPromise().then((newStatus) => {
2281
2373
  this._increaseMultiplier();
@@ -2301,7 +2393,7 @@ class UploadTask {
2301
2393
  _fetchMetadata() {
2302
2394
  this._resolveToken((authToken, appCheckToken) => {
2303
2395
  const requestInfo = getMetadata$2(this._ref.storage, this._ref._location, this._mappings);
2304
- const metadataRequest = this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
2396
+ const metadataRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
2305
2397
  this._request = metadataRequest;
2306
2398
  metadataRequest.getPromise().then(metadata => {
2307
2399
  this._request = undefined;
@@ -2313,7 +2405,7 @@ class UploadTask {
2313
2405
  _oneShotUpload() {
2314
2406
  this._resolveToken((authToken, appCheckToken) => {
2315
2407
  const requestInfo = multipartUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata);
2316
- const multipartRequest = this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
2408
+ const multipartRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
2317
2409
  this._request = multipartRequest;
2318
2410
  multipartRequest.getPromise().then(metadata => {
2319
2411
  this._request = undefined;
@@ -2678,6 +2770,51 @@ class Reference {
2678
2770
  }
2679
2771
  }
2680
2772
  }
2773
+ /**
2774
+ * Download the bytes at the object's location.
2775
+ * @returns A Promise containing the downloaded bytes.
2776
+ */
2777
+ function getBytesInternal(ref, maxDownloadSizeBytes) {
2778
+ ref._throwIfRoot('getBytes');
2779
+ const requestInfo = getBytes$1(ref.storage, ref._location, maxDownloadSizeBytes);
2780
+ return ref.storage
2781
+ .makeRequestWithTokens(requestInfo, newBytesConnection)
2782
+ .then(bytes => maxDownloadSizeBytes !== undefined
2783
+ ? // GCS may not honor the Range header for small files
2784
+ bytes.slice(0, maxDownloadSizeBytes)
2785
+ : bytes);
2786
+ }
2787
+ /** Stream the bytes at the object's location. */
2788
+ function getStreamInternal(ref, maxDownloadSizeBytes) {
2789
+ ref._throwIfRoot('getStream');
2790
+ const requestInfo = getBytes$1(ref.storage, ref._location, maxDownloadSizeBytes);
2791
+ /** A transformer that passes through the first n bytes. */
2792
+ const newMaxSizeTransform = n => {
2793
+ let missingBytes = n;
2794
+ return {
2795
+ transform(chunk, encoding, callback) {
2796
+ // GCS may not honor the Range header for small files
2797
+ if (chunk.length < missingBytes) {
2798
+ this.push(chunk);
2799
+ missingBytes -= chunk.length;
2800
+ }
2801
+ else {
2802
+ this.push(chunk.slice(0, missingBytes));
2803
+ this.emit('end');
2804
+ }
2805
+ callback();
2806
+ }
2807
+ };
2808
+ };
2809
+ const result = maxDownloadSizeBytes !== undefined
2810
+ ? new stream.Transform(newMaxSizeTransform(maxDownloadSizeBytes))
2811
+ : new stream.PassThrough();
2812
+ ref.storage
2813
+ .makeRequestWithTokens(requestInfo, newStreamConnection)
2814
+ .then(stream => stream.pipe(result))
2815
+ .catch(e => result.destroy(e));
2816
+ return result;
2817
+ }
2681
2818
  /**
2682
2819
  * Uploads data to this object's location.
2683
2820
  * The upload is not resumable.
@@ -2691,7 +2828,7 @@ function uploadBytes$1(ref, data, metadata) {
2691
2828
  ref._throwIfRoot('uploadBytes');
2692
2829
  const requestInfo = multipartUpload(ref.storage, ref._location, getMappings(), new FbsBlob(data, true), metadata);
2693
2830
  return ref.storage
2694
- .makeRequestWithTokens(requestInfo, newConnection)
2831
+ .makeRequestWithTokens(requestInfo, newTextConnection)
2695
2832
  .then(finalMetadata => {
2696
2833
  return {
2697
2834
  metadata: finalMetadata,
@@ -2808,7 +2945,7 @@ function list$1(ref, options) {
2808
2945
  const op = options || {};
2809
2946
  const requestInfo = list$2(ref.storage, ref._location,
2810
2947
  /*delimiter= */ '/', op.pageToken, op.maxResults);
2811
- return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
2948
+ return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);
2812
2949
  }
2813
2950
  /**
2814
2951
  * A `Promise` that resolves with the metadata for this object. If this
@@ -2820,7 +2957,7 @@ function list$1(ref, options) {
2820
2957
  function getMetadata$1(ref) {
2821
2958
  ref._throwIfRoot('getMetadata');
2822
2959
  const requestInfo = getMetadata$2(ref.storage, ref._location, getMappings());
2823
- return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
2960
+ return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);
2824
2961
  }
2825
2962
  /**
2826
2963
  * Updates the metadata for this object.
@@ -2836,7 +2973,7 @@ function getMetadata$1(ref) {
2836
2973
  function updateMetadata$1(ref, metadata) {
2837
2974
  ref._throwIfRoot('updateMetadata');
2838
2975
  const requestInfo = updateMetadata$2(ref.storage, ref._location, metadata, getMappings());
2839
- return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
2976
+ return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);
2840
2977
  }
2841
2978
  /**
2842
2979
  * Returns the download URL for the given Reference.
@@ -2848,7 +2985,7 @@ function getDownloadURL$1(ref) {
2848
2985
  ref._throwIfRoot('getDownloadURL');
2849
2986
  const requestInfo = getDownloadUrl(ref.storage, ref._location, getMappings());
2850
2987
  return ref.storage
2851
- .makeRequestWithTokens(requestInfo, newConnection)
2988
+ .makeRequestWithTokens(requestInfo, newTextConnection)
2852
2989
  .then(url => {
2853
2990
  if (url === null) {
2854
2991
  throw noDownloadURL();
@@ -2865,7 +3002,7 @@ function getDownloadURL$1(ref) {
2865
3002
  function deleteObject$1(ref) {
2866
3003
  ref._throwIfRoot('deleteObject');
2867
3004
  const requestInfo = deleteObject$2(ref.storage, ref._location);
2868
- return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
3005
+ return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);
2869
3006
  }
2870
3007
  /**
2871
3008
  * Returns reference for object obtained by appending `childPath` to `ref`.
@@ -3122,7 +3259,7 @@ class FirebaseStorageImpl {
3122
3259
  }
3123
3260
 
3124
3261
  const name = "@firebase/storage";
3125
- const version = "0.8.6";
3262
+ const version = "0.8.7-canary.ce39a1a07";
3126
3263
 
3127
3264
  /**
3128
3265
  * @license
@@ -3161,6 +3298,24 @@ const STORAGE_TYPE = 'storage';
3161
3298
  * See the License for the specific language governing permissions and
3162
3299
  * limitations under the License.
3163
3300
  */
3301
+ /**
3302
+ * Downloads the data at the object's location. Returns an error if the object
3303
+ * is not found.
3304
+ *
3305
+ * To use this functionality, you have to whitelist your app's origin in your
3306
+ * Cloud Storage bucket. See also
3307
+ * https://cloud.google.com/storage/docs/configuring-cors
3308
+ *
3309
+ * @public
3310
+ * @param ref - StorageReference where data should be downloaded.
3311
+ * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
3312
+ * retrieve.
3313
+ * @returns A Promise containing the object's bytes
3314
+ */
3315
+ function getBytes(ref, maxDownloadSizeBytes) {
3316
+ ref = util.getModularInstance(ref);
3317
+ return getBytesInternal(ref, maxDownloadSizeBytes);
3318
+ }
3164
3319
  /**
3165
3320
  * Uploads data to this object's location.
3166
3321
  * The upload is not resumable.
@@ -3335,6 +3490,59 @@ function connectStorageEmulator(storage, host, port, options = {}) {
3335
3490
  connectStorageEmulator$1(storage, host, port, options);
3336
3491
  }
3337
3492
 
3493
+ /**
3494
+ * @license
3495
+ * Copyright 2021 Google LLC
3496
+ *
3497
+ * Licensed under the Apache License, Version 2.0 (the "License");
3498
+ * you may not use this file except in compliance with the License.
3499
+ * You may obtain a copy of the License at
3500
+ *
3501
+ * http://www.apache.org/licenses/LICENSE-2.0
3502
+ *
3503
+ * Unless required by applicable law or agreed to in writing, software
3504
+ * distributed under the License is distributed on an "AS IS" BASIS,
3505
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3506
+ * See the License for the specific language governing permissions and
3507
+ * limitations under the License.
3508
+ */
3509
+ /**
3510
+ * Downloads the data at the object's location. Returns an error if the object
3511
+ * is not found.
3512
+ *
3513
+ * To use this functionality, you have to whitelist your app's origin in your
3514
+ * Cloud Storage bucket. See also
3515
+ * https://cloud.google.com/storage/docs/configuring-cors
3516
+ *
3517
+ * This API is not available in Node.
3518
+ *
3519
+ * @public
3520
+ * @param ref - StorageReference where data should be downloaded.
3521
+ * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
3522
+ * retrieve.
3523
+ * @returns A Promise that resolves with a Blob containing the object's bytes
3524
+ */
3525
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3526
+ function getBlob(ref, maxDownloadSizeBytes) {
3527
+ throw new Error('getBlob() is only available in Browser-like environments');
3528
+ }
3529
+ /**
3530
+ * Downloads the data at the object's location. Raises an error event if the
3531
+ * object is not found.
3532
+ *
3533
+ * This API is only available in Node.
3534
+ *
3535
+ * @public
3536
+ * @param ref - StorageReference where data should be downloaded.
3537
+ * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
3538
+ * retrieve.
3539
+ * @returns A stream with the object's data as bytes
3540
+ */
3541
+ function getStream(ref, maxDownloadSizeBytes) {
3542
+ ref = util.getModularInstance(ref);
3543
+ return getStreamInternal(ref, maxDownloadSizeBytes);
3544
+ }
3545
+
3338
3546
  /**
3339
3547
  * Cloud Storage for Firebase
3340
3548
  *
@@ -3364,9 +3572,12 @@ exports._invalidArgument = invalidArgument;
3364
3572
  exports._invalidRootOperation = invalidRootOperation;
3365
3573
  exports.connectStorageEmulator = connectStorageEmulator;
3366
3574
  exports.deleteObject = deleteObject;
3575
+ exports.getBlob = getBlob;
3576
+ exports.getBytes = getBytes;
3367
3577
  exports.getDownloadURL = getDownloadURL;
3368
3578
  exports.getMetadata = getMetadata;
3369
3579
  exports.getStorage = getStorage;
3580
+ exports.getStream = getStream;
3370
3581
  exports.list = list;
3371
3582
  exports.listAll = listAll;
3372
3583
  exports.ref = ref;