@firebase/storage 0.13.7 → 0.13.8-20250505162014

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.isUsingEmulator, this.body_, this.headers_)
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, isUsingEmulator, body, headers) {
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) {
@@ -3170,7 +3174,13 @@ function extractBucket(host, config) {
3170
3174
  }
3171
3175
  function connectStorageEmulator$1(storage, host, port, options = {}) {
3172
3176
  storage.host = `${host}:${port}`;
3173
- storage._protocol = 'http';
3177
+ const useSsl = util.isCloudWorkstation(host);
3178
+ // Workaround to get cookies in Firebase Studio
3179
+ if (useSsl) {
3180
+ void util.pingServer(`https://${storage.host}`);
3181
+ }
3182
+ storage._isUsingEmulator = true;
3183
+ storage._protocol = useSsl ? 'https' : 'http';
3174
3184
  const { mockUserToken } = options;
3175
3185
  if (mockUserToken) {
3176
3186
  storage._overrideAuthToken =
@@ -3198,12 +3208,13 @@ class FirebaseStorageImpl {
3198
3208
  /**
3199
3209
  * @internal
3200
3210
  */
3201
- _url, _firebaseVersion) {
3211
+ _url, _firebaseVersion, _isUsingEmulator = false) {
3202
3212
  this.app = app;
3203
3213
  this._authProvider = _authProvider;
3204
3214
  this._appCheckProvider = _appCheckProvider;
3205
3215
  this._url = _url;
3206
3216
  this._firebaseVersion = _firebaseVersion;
3217
+ this._isUsingEmulator = _isUsingEmulator;
3207
3218
  this._bucket = null;
3208
3219
  /**
3209
3220
  * This string can be in the formats:
@@ -3317,7 +3328,7 @@ class FirebaseStorageImpl {
3317
3328
  */
3318
3329
  _makeRequest(requestInfo, requestFactory, authToken, appCheckToken, retry = true) {
3319
3330
  if (!this._deleted) {
3320
- const request = makeRequest(requestInfo, this._appId, authToken, appCheckToken, requestFactory, this._firebaseVersion, retry);
3331
+ const request = makeRequest(requestInfo, this._appId, authToken, appCheckToken, requestFactory, this._firebaseVersion, retry, this._isUsingEmulator);
3321
3332
  this._requests.add(request);
3322
3333
  // Request removes itself from set when complete.
3323
3334
  request.getPromise().then(() => this._requests.delete(request), () => this._requests.delete(request));
@@ -3337,7 +3348,7 @@ class FirebaseStorageImpl {
3337
3348
  }
3338
3349
 
3339
3350
  const name = "@firebase/storage";
3340
- const version = "0.13.7";
3351
+ const version = "0.13.8-20250505162014";
3341
3352
 
3342
3353
  /**
3343
3354
  * @license