@firebase/storage 0.13.6 → 0.13.7-auth-redirect-credentials.82faa0828

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.
@@ -1,5 +1,5 @@
1
1
  import { _isFirebaseServerApp, _getProvider, getApp, _registerComponent, registerVersion, SDK_VERSION } from '@firebase/app';
2
- import { FirebaseError, createMockUserToken, getModularInstance, getDefaultEmulatorHostnameAndPort } from '@firebase/util';
2
+ import { FirebaseError, isCloudWorkstation, createMockUserToken, getModularInstance, getDefaultEmulatorHostnameAndPort } from '@firebase/util';
3
3
  import { Component } from '@firebase/component';
4
4
 
5
5
  /**
@@ -657,7 +657,7 @@ function isRetryStatusCode(status, additionalRetryCodes) {
657
657
  * happens in the specified `callback_`.
658
658
  */
659
659
  class NetworkRequest {
660
- constructor(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, connectionFactory_, retry = true) {
660
+ constructor(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, connectionFactory_, retry = true, isUsingEmulator = false) {
661
661
  this.url_ = url_;
662
662
  this.method_ = method_;
663
663
  this.headers_ = headers_;
@@ -670,6 +670,7 @@ class NetworkRequest {
670
670
  this.progressCallback_ = progressCallback_;
671
671
  this.connectionFactory_ = connectionFactory_;
672
672
  this.retry = retry;
673
+ this.isUsingEmulator = isUsingEmulator;
673
674
  this.pendingConnection_ = null;
674
675
  this.backoffId_ = null;
675
676
  this.canceled_ = false;
@@ -704,7 +705,7 @@ class NetworkRequest {
704
705
  // connection.send() never rejects, so we don't need to have a error handler or use catch on the returned promise.
705
706
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
706
707
  connection
707
- .send(this.url_, this.method_, this.body_, this.headers_)
708
+ .send(this.url_, this.method_, this.body_, this.headers_, this.isUsingEmulator)
708
709
  .then(() => {
709
710
  if (this.progressCallback_ !== null) {
710
711
  connection.removeUploadProgressListener(progressListener);
@@ -821,7 +822,7 @@ function addAppCheckHeader_(headers, appCheckToken) {
821
822
  headers['X-Firebase-AppCheck'] = appCheckToken;
822
823
  }
823
824
  }
824
- function makeRequest(requestInfo, appId, authToken, appCheckToken, requestFactory, firebaseVersion, retry = true) {
825
+ function makeRequest(requestInfo, appId, authToken, appCheckToken, requestFactory, firebaseVersion, retry = true, isUsingEmulator = false) {
825
826
  const queryPart = makeQueryString(requestInfo.urlParams);
826
827
  const url = requestInfo.url + queryPart;
827
828
  const headers = Object.assign({}, requestInfo.headers);
@@ -829,7 +830,7 @@ function makeRequest(requestInfo, appId, authToken, appCheckToken, requestFactor
829
830
  addAuthHeader_(headers, authToken);
830
831
  addVersionHeader_(headers, firebaseVersion);
831
832
  addAppCheckHeader_(headers, appCheckToken);
832
- return new NetworkRequest(url, requestInfo.method, headers, requestInfo.body, requestInfo.successCodes, requestInfo.additionalRetryCodes, requestInfo.handler, requestInfo.errorHandler, requestInfo.timeout, requestInfo.progressCallback, requestFactory, retry);
833
+ return new NetworkRequest(url, requestInfo.method, headers, requestInfo.body, requestInfo.successCodes, requestInfo.additionalRetryCodes, requestInfo.handler, requestInfo.errorHandler, requestInfo.timeout, requestInfo.progressCallback, requestFactory, retry, isUsingEmulator);
833
834
  }
834
835
 
835
836
  /**
@@ -2158,10 +2159,13 @@ class XhrConnection {
2158
2159
  });
2159
2160
  });
2160
2161
  }
2161
- send(url, method, body, headers) {
2162
+ send(url, method, body, headers, isUsingEmulator) {
2162
2163
  if (this.sent_) {
2163
2164
  throw internalError('cannot .send() more than once');
2164
2165
  }
2166
+ if (isCloudWorkstation(url) && isUsingEmulator) {
2167
+ this.xhr_.withCredentials = true;
2168
+ }
2165
2169
  this.sent_ = true;
2166
2170
  this.xhr_.open(method, url, true);
2167
2171
  if (headers !== undefined) {
@@ -3194,12 +3198,13 @@ class FirebaseStorageImpl {
3194
3198
  /**
3195
3199
  * @internal
3196
3200
  */
3197
- _url, _firebaseVersion) {
3201
+ _url, _firebaseVersion, _isUsingEmulator = false) {
3198
3202
  this.app = app;
3199
3203
  this._authProvider = _authProvider;
3200
3204
  this._appCheckProvider = _appCheckProvider;
3201
3205
  this._url = _url;
3202
3206
  this._firebaseVersion = _firebaseVersion;
3207
+ this._isUsingEmulator = _isUsingEmulator;
3203
3208
  this._bucket = null;
3204
3209
  /**
3205
3210
  * This string can be in the formats:
@@ -3313,7 +3318,7 @@ class FirebaseStorageImpl {
3313
3318
  */
3314
3319
  _makeRequest(requestInfo, requestFactory, authToken, appCheckToken, retry = true) {
3315
3320
  if (!this._deleted) {
3316
- const request = makeRequest(requestInfo, this._appId, authToken, appCheckToken, requestFactory, this._firebaseVersion, retry);
3321
+ const request = makeRequest(requestInfo, this._appId, authToken, appCheckToken, requestFactory, this._firebaseVersion, retry, this._isUsingEmulator);
3317
3322
  this._requests.add(request);
3318
3323
  // Request removes itself from set when complete.
3319
3324
  request.getPromise().then(() => this._requests.delete(request), () => this._requests.delete(request));
@@ -3333,7 +3338,7 @@ class FirebaseStorageImpl {
3333
3338
  }
3334
3339
 
3335
3340
  const name = "@firebase/storage";
3336
- const version = "0.13.6";
3341
+ const version = "0.13.7-auth-redirect-credentials.82faa0828";
3337
3342
 
3338
3343
  /**
3339
3344
  * @license