@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.
@@ -661,7 +661,7 @@ function isRetryStatusCode(status, additionalRetryCodes) {
661
661
  * happens in the specified `callback_`.
662
662
  */
663
663
  class NetworkRequest {
664
- constructor(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, connectionFactory_, retry = true) {
664
+ constructor(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, connectionFactory_, retry = true, isUsingEmulator = false) {
665
665
  this.url_ = url_;
666
666
  this.method_ = method_;
667
667
  this.headers_ = headers_;
@@ -674,6 +674,7 @@ class NetworkRequest {
674
674
  this.progressCallback_ = progressCallback_;
675
675
  this.connectionFactory_ = connectionFactory_;
676
676
  this.retry = retry;
677
+ this.isUsingEmulator = isUsingEmulator;
677
678
  this.pendingConnection_ = null;
678
679
  this.backoffId_ = null;
679
680
  this.canceled_ = false;
@@ -708,7 +709,7 @@ class NetworkRequest {
708
709
  // connection.send() never rejects, so we don't need to have a error handler or use catch on the returned promise.
709
710
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
710
711
  connection
711
- .send(this.url_, this.method_, this.body_, this.headers_)
712
+ .send(this.url_, this.method_, this.body_, this.headers_, this.isUsingEmulator)
712
713
  .then(() => {
713
714
  if (this.progressCallback_ !== null) {
714
715
  connection.removeUploadProgressListener(progressListener);
@@ -825,7 +826,7 @@ function addAppCheckHeader_(headers, appCheckToken) {
825
826
  headers['X-Firebase-AppCheck'] = appCheckToken;
826
827
  }
827
828
  }
828
- function makeRequest(requestInfo, appId, authToken, appCheckToken, requestFactory, firebaseVersion, retry = true) {
829
+ function makeRequest(requestInfo, appId, authToken, appCheckToken, requestFactory, firebaseVersion, retry = true, isUsingEmulator = false) {
829
830
  const queryPart = makeQueryString(requestInfo.urlParams);
830
831
  const url = requestInfo.url + queryPart;
831
832
  const headers = Object.assign({}, requestInfo.headers);
@@ -833,7 +834,7 @@ function makeRequest(requestInfo, appId, authToken, appCheckToken, requestFactor
833
834
  addAuthHeader_(headers, authToken);
834
835
  addVersionHeader_(headers, firebaseVersion);
835
836
  addAppCheckHeader_(headers, appCheckToken);
836
- return new NetworkRequest(url, requestInfo.method, headers, requestInfo.body, requestInfo.successCodes, requestInfo.additionalRetryCodes, requestInfo.handler, requestInfo.errorHandler, requestInfo.timeout, requestInfo.progressCallback, requestFactory, retry);
837
+ return new NetworkRequest(url, requestInfo.method, headers, requestInfo.body, requestInfo.successCodes, requestInfo.additionalRetryCodes, requestInfo.handler, requestInfo.errorHandler, requestInfo.timeout, requestInfo.progressCallback, requestFactory, retry, isUsingEmulator);
837
838
  }
838
839
 
839
840
  /**
@@ -2162,10 +2163,13 @@ class XhrConnection {
2162
2163
  });
2163
2164
  });
2164
2165
  }
2165
- send(url, method, body, headers) {
2166
+ send(url, method, body, headers, isUsingEmulator) {
2166
2167
  if (this.sent_) {
2167
2168
  throw internalError('cannot .send() more than once');
2168
2169
  }
2170
+ if (util.isCloudWorkstation(url) && isUsingEmulator) {
2171
+ this.xhr_.withCredentials = true;
2172
+ }
2169
2173
  this.sent_ = true;
2170
2174
  this.xhr_.open(method, url, true);
2171
2175
  if (headers !== undefined) {
@@ -3198,12 +3202,13 @@ class FirebaseStorageImpl {
3198
3202
  /**
3199
3203
  * @internal
3200
3204
  */
3201
- _url, _firebaseVersion) {
3205
+ _url, _firebaseVersion, _isUsingEmulator = false) {
3202
3206
  this.app = app;
3203
3207
  this._authProvider = _authProvider;
3204
3208
  this._appCheckProvider = _appCheckProvider;
3205
3209
  this._url = _url;
3206
3210
  this._firebaseVersion = _firebaseVersion;
3211
+ this._isUsingEmulator = _isUsingEmulator;
3207
3212
  this._bucket = null;
3208
3213
  /**
3209
3214
  * This string can be in the formats:
@@ -3317,7 +3322,7 @@ class FirebaseStorageImpl {
3317
3322
  */
3318
3323
  _makeRequest(requestInfo, requestFactory, authToken, appCheckToken, retry = true) {
3319
3324
  if (!this._deleted) {
3320
- const request = makeRequest(requestInfo, this._appId, authToken, appCheckToken, requestFactory, this._firebaseVersion, retry);
3325
+ const request = makeRequest(requestInfo, this._appId, authToken, appCheckToken, requestFactory, this._firebaseVersion, retry, this._isUsingEmulator);
3321
3326
  this._requests.add(request);
3322
3327
  // Request removes itself from set when complete.
3323
3328
  request.getPromise().then(() => this._requests.delete(request), () => this._requests.delete(request));
@@ -3337,7 +3342,7 @@ class FirebaseStorageImpl {
3337
3342
  }
3338
3343
 
3339
3344
  const name = "@firebase/storage";
3340
- const version = "0.13.6";
3345
+ const version = "0.13.7-auth-redirect-credentials.82faa0828";
3341
3346
 
3342
3347
  /**
3343
3348
  * @license