@firebase/storage 0.13.7-canary.058afa280 → 0.13.7-canary.0e1276649
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.
- package/dist/index.browser.cjs.js +16 -9
- package/dist/index.browser.cjs.js.map +1 -1
- package/dist/index.cjs.js +16 -9
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +17 -10
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.node.cjs.js +27 -20
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/node-esm/index.node.esm.js +28 -21
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/implementation/connection.d.ts +1 -1
- package/dist/node-esm/src/implementation/request.d.ts +1 -1
- package/dist/node-esm/src/platform/browser/connection.d.ts +1 -1
- package/dist/node-esm/src/platform/node/connection.d.ts +2 -2
- package/dist/node-esm/src/service.d.ts +2 -1
- package/dist/node-esm/test/unit/connection.d.ts +1 -1
- package/dist/src/implementation/connection.d.ts +1 -1
- package/dist/src/implementation/request.d.ts +1 -1
- package/dist/src/platform/browser/connection.d.ts +1 -1
- package/dist/src/platform/node/connection.d.ts +2 -2
- package/dist/src/service.d.ts +2 -1
- package/dist/storage.d.ts +3 -2
- package/dist/test/unit/connection.d.ts +1 -1
- package/package.json +6 -6
package/dist/index.node.cjs.js
CHANGED
|
@@ -658,7 +658,7 @@ function isRetryStatusCode(status, additionalRetryCodes) {
|
|
|
658
658
|
* happens in the specified `callback_`.
|
|
659
659
|
*/
|
|
660
660
|
class NetworkRequest {
|
|
661
|
-
constructor(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, connectionFactory_, retry = true) {
|
|
661
|
+
constructor(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, connectionFactory_, retry = true, isUsingEmulator = false) {
|
|
662
662
|
this.url_ = url_;
|
|
663
663
|
this.method_ = method_;
|
|
664
664
|
this.headers_ = headers_;
|
|
@@ -671,6 +671,7 @@ class NetworkRequest {
|
|
|
671
671
|
this.progressCallback_ = progressCallback_;
|
|
672
672
|
this.connectionFactory_ = connectionFactory_;
|
|
673
673
|
this.retry = retry;
|
|
674
|
+
this.isUsingEmulator = isUsingEmulator;
|
|
674
675
|
this.pendingConnection_ = null;
|
|
675
676
|
this.backoffId_ = null;
|
|
676
677
|
this.canceled_ = false;
|
|
@@ -705,7 +706,7 @@ class NetworkRequest {
|
|
|
705
706
|
// connection.send() never rejects, so we don't need to have a error handler or use catch on the returned promise.
|
|
706
707
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
707
708
|
connection
|
|
708
|
-
.send(this.url_, this.method_, this.body_, this.headers_)
|
|
709
|
+
.send(this.url_, this.method_, this.isUsingEmulator, this.body_, this.headers_)
|
|
709
710
|
.then(() => {
|
|
710
711
|
if (this.progressCallback_ !== null) {
|
|
711
712
|
connection.removeUploadProgressListener(progressListener);
|
|
@@ -822,7 +823,7 @@ function addAppCheckHeader_(headers, appCheckToken) {
|
|
|
822
823
|
headers['X-Firebase-AppCheck'] = appCheckToken;
|
|
823
824
|
}
|
|
824
825
|
}
|
|
825
|
-
function makeRequest(requestInfo, appId, authToken, appCheckToken, requestFactory, firebaseVersion, retry = true) {
|
|
826
|
+
function makeRequest(requestInfo, appId, authToken, appCheckToken, requestFactory, firebaseVersion, retry = true, isUsingEmulator = false) {
|
|
826
827
|
const queryPart = makeQueryString(requestInfo.urlParams);
|
|
827
828
|
const url = requestInfo.url + queryPart;
|
|
828
829
|
const headers = Object.assign({}, requestInfo.headers);
|
|
@@ -830,7 +831,7 @@ function makeRequest(requestInfo, appId, authToken, appCheckToken, requestFactor
|
|
|
830
831
|
addAuthHeader_(headers, authToken);
|
|
831
832
|
addVersionHeader_(headers, firebaseVersion);
|
|
832
833
|
addAppCheckHeader_(headers, appCheckToken);
|
|
833
|
-
return new NetworkRequest(url, requestInfo.method, headers, requestInfo.body, requestInfo.successCodes, requestInfo.additionalRetryCodes, requestInfo.handler, requestInfo.errorHandler, requestInfo.timeout, requestInfo.progressCallback, requestFactory, retry);
|
|
834
|
+
return new NetworkRequest(url, requestInfo.method, headers, requestInfo.body, requestInfo.successCodes, requestInfo.additionalRetryCodes, requestInfo.handler, requestInfo.errorHandler, requestInfo.timeout, requestInfo.progressCallback, requestFactory, retry, isUsingEmulator);
|
|
834
835
|
}
|
|
835
836
|
|
|
836
837
|
/**
|
|
@@ -2149,17 +2150,13 @@ class FetchConnection {
|
|
|
2149
2150
|
this.sent_ = false;
|
|
2150
2151
|
this.errorCode_ = ErrorCode.NO_ERROR;
|
|
2151
2152
|
}
|
|
2152
|
-
async send(url, method, body, headers) {
|
|
2153
|
+
async send(url, method, isUsingEmulator, body, headers) {
|
|
2153
2154
|
if (this.sent_) {
|
|
2154
2155
|
throw internalError('cannot .send() more than once');
|
|
2155
2156
|
}
|
|
2156
2157
|
this.sent_ = true;
|
|
2157
2158
|
try {
|
|
2158
|
-
const response = await
|
|
2159
|
-
method,
|
|
2160
|
-
headers: headers || {},
|
|
2161
|
-
body: body
|
|
2162
|
-
});
|
|
2159
|
+
const response = await newFetch(url, method, isUsingEmulator, headers, body);
|
|
2163
2160
|
this.headers_ = response.headers;
|
|
2164
2161
|
this.statusCode_ = response.status;
|
|
2165
2162
|
this.errorCode_ = ErrorCode.NO_ERROR;
|
|
@@ -2232,17 +2229,13 @@ class FetchStreamConnection extends FetchConnection {
|
|
|
2232
2229
|
super(...arguments);
|
|
2233
2230
|
this.stream_ = null;
|
|
2234
2231
|
}
|
|
2235
|
-
async send(url, method, body, headers) {
|
|
2232
|
+
async send(url, method, isUsingEmulator, body, headers) {
|
|
2236
2233
|
if (this.sent_) {
|
|
2237
2234
|
throw internalError('cannot .send() more than once');
|
|
2238
2235
|
}
|
|
2239
2236
|
this.sent_ = true;
|
|
2240
2237
|
try {
|
|
2241
|
-
const response = await
|
|
2242
|
-
method,
|
|
2243
|
-
headers: headers || {},
|
|
2244
|
-
body: body
|
|
2245
|
-
});
|
|
2238
|
+
const response = await newFetch(url, method, isUsingEmulator, headers, body);
|
|
2246
2239
|
this.headers_ = response.headers;
|
|
2247
2240
|
this.statusCode_ = response.status;
|
|
2248
2241
|
this.errorCode_ = ErrorCode.NO_ERROR;
|
|
@@ -2262,6 +2255,17 @@ class FetchStreamConnection extends FetchConnection {
|
|
|
2262
2255
|
return this.stream_;
|
|
2263
2256
|
}
|
|
2264
2257
|
}
|
|
2258
|
+
function newFetch(url, method, isUsingEmulator, headers, body) {
|
|
2259
|
+
const fetchArgs = {
|
|
2260
|
+
method,
|
|
2261
|
+
headers: headers || {},
|
|
2262
|
+
body: body
|
|
2263
|
+
};
|
|
2264
|
+
if (util.isCloudWorkstation(url) && isUsingEmulator) {
|
|
2265
|
+
fetchArgs.credentials = 'include';
|
|
2266
|
+
}
|
|
2267
|
+
return fetch(url, fetchArgs);
|
|
2268
|
+
}
|
|
2265
2269
|
function newStreamConnection() {
|
|
2266
2270
|
return new FetchStreamConnection();
|
|
2267
2271
|
}
|
|
@@ -3197,7 +3201,9 @@ function extractBucket(host, config) {
|
|
|
3197
3201
|
}
|
|
3198
3202
|
function connectStorageEmulator$1(storage, host, port, options = {}) {
|
|
3199
3203
|
storage.host = `${host}:${port}`;
|
|
3200
|
-
|
|
3204
|
+
const useSsl = util.isCloudWorkstation(host);
|
|
3205
|
+
storage._isUsingEmulator = true;
|
|
3206
|
+
storage._protocol = useSsl ? 'https' : 'http';
|
|
3201
3207
|
const { mockUserToken } = options;
|
|
3202
3208
|
if (mockUserToken) {
|
|
3203
3209
|
storage._overrideAuthToken =
|
|
@@ -3225,12 +3231,13 @@ class FirebaseStorageImpl {
|
|
|
3225
3231
|
/**
|
|
3226
3232
|
* @internal
|
|
3227
3233
|
*/
|
|
3228
|
-
_url, _firebaseVersion) {
|
|
3234
|
+
_url, _firebaseVersion, _isUsingEmulator = false) {
|
|
3229
3235
|
this.app = app;
|
|
3230
3236
|
this._authProvider = _authProvider;
|
|
3231
3237
|
this._appCheckProvider = _appCheckProvider;
|
|
3232
3238
|
this._url = _url;
|
|
3233
3239
|
this._firebaseVersion = _firebaseVersion;
|
|
3240
|
+
this._isUsingEmulator = _isUsingEmulator;
|
|
3234
3241
|
this._bucket = null;
|
|
3235
3242
|
/**
|
|
3236
3243
|
* This string can be in the formats:
|
|
@@ -3344,7 +3351,7 @@ class FirebaseStorageImpl {
|
|
|
3344
3351
|
*/
|
|
3345
3352
|
_makeRequest(requestInfo, requestFactory, authToken, appCheckToken, retry = true) {
|
|
3346
3353
|
if (!this._deleted) {
|
|
3347
|
-
const request = makeRequest(requestInfo, this._appId, authToken, appCheckToken, requestFactory, this._firebaseVersion, retry);
|
|
3354
|
+
const request = makeRequest(requestInfo, this._appId, authToken, appCheckToken, requestFactory, this._firebaseVersion, retry, this._isUsingEmulator);
|
|
3348
3355
|
this._requests.add(request);
|
|
3349
3356
|
// Request removes itself from set when complete.
|
|
3350
3357
|
request.getPromise().then(() => this._requests.delete(request), () => this._requests.delete(request));
|
|
@@ -3364,7 +3371,7 @@ class FirebaseStorageImpl {
|
|
|
3364
3371
|
}
|
|
3365
3372
|
|
|
3366
3373
|
const name = "@firebase/storage";
|
|
3367
|
-
const version = "0.13.7-canary.
|
|
3374
|
+
const version = "0.13.7-canary.0e1276649";
|
|
3368
3375
|
|
|
3369
3376
|
/**
|
|
3370
3377
|
* @license
|