@firebase/storage 0.13.7-canary.058afa280 → 0.13.7-canary.080a90dcc
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 +20 -9
- package/dist/index.browser.cjs.js.map +1 -1
- package/dist/index.cjs.js +20 -9
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +21 -10
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.node.cjs.js +31 -20
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/node-esm/index.node.esm.js +32 -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,13 @@ 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
|
+
// Workaround to get cookies in Firebase Studio
|
|
3206
|
+
if (useSsl) {
|
|
3207
|
+
void util.pingServer(`https://${storage.host}`);
|
|
3208
|
+
}
|
|
3209
|
+
storage._isUsingEmulator = true;
|
|
3210
|
+
storage._protocol = useSsl ? 'https' : 'http';
|
|
3201
3211
|
const { mockUserToken } = options;
|
|
3202
3212
|
if (mockUserToken) {
|
|
3203
3213
|
storage._overrideAuthToken =
|
|
@@ -3225,12 +3235,13 @@ class FirebaseStorageImpl {
|
|
|
3225
3235
|
/**
|
|
3226
3236
|
* @internal
|
|
3227
3237
|
*/
|
|
3228
|
-
_url, _firebaseVersion) {
|
|
3238
|
+
_url, _firebaseVersion, _isUsingEmulator = false) {
|
|
3229
3239
|
this.app = app;
|
|
3230
3240
|
this._authProvider = _authProvider;
|
|
3231
3241
|
this._appCheckProvider = _appCheckProvider;
|
|
3232
3242
|
this._url = _url;
|
|
3233
3243
|
this._firebaseVersion = _firebaseVersion;
|
|
3244
|
+
this._isUsingEmulator = _isUsingEmulator;
|
|
3234
3245
|
this._bucket = null;
|
|
3235
3246
|
/**
|
|
3236
3247
|
* This string can be in the formats:
|
|
@@ -3344,7 +3355,7 @@ class FirebaseStorageImpl {
|
|
|
3344
3355
|
*/
|
|
3345
3356
|
_makeRequest(requestInfo, requestFactory, authToken, appCheckToken, retry = true) {
|
|
3346
3357
|
if (!this._deleted) {
|
|
3347
|
-
const request = makeRequest(requestInfo, this._appId, authToken, appCheckToken, requestFactory, this._firebaseVersion, retry);
|
|
3358
|
+
const request = makeRequest(requestInfo, this._appId, authToken, appCheckToken, requestFactory, this._firebaseVersion, retry, this._isUsingEmulator);
|
|
3348
3359
|
this._requests.add(request);
|
|
3349
3360
|
// Request removes itself from set when complete.
|
|
3350
3361
|
request.getPromise().then(() => this._requests.delete(request), () => this._requests.delete(request));
|
|
@@ -3364,7 +3375,7 @@ class FirebaseStorageImpl {
|
|
|
3364
3375
|
}
|
|
3365
3376
|
|
|
3366
3377
|
const name = "@firebase/storage";
|
|
3367
|
-
const version = "0.13.7-canary.
|
|
3378
|
+
const version = "0.13.7-canary.080a90dcc";
|
|
3368
3379
|
|
|
3369
3380
|
/**
|
|
3370
3381
|
* @license
|