@firebase/storage 0.8.3 → 0.8.4-2021927221742
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/CHANGELOG.md +8 -0
- package/dist/index.browser.cjs.js +224 -313
- package/dist/index.browser.cjs.js.map +1 -1
- package/dist/index.cjs.js +185 -204
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +203 -245
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +224 -313
- package/dist/index.esm5.js.map +1 -1
- package/dist/src/{implementation/connectionPool.d.ts → api.browser.d.ts} +2 -11
- package/dist/src/api.d.ts +1 -1
- package/dist/src/{implementation/requestmaker.d.ts → api.node.d.ts} +2 -6
- package/dist/src/implementation/connection.d.ts +6 -6
- package/dist/src/implementation/request.d.ts +1 -2
- package/dist/src/implementation/requestinfo.d.ts +11 -3
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.node.d.ts +7 -0
- package/dist/src/platform/browser/connection.d.ts +2 -25
- package/dist/src/platform/connection.d.ts +1 -0
- package/dist/src/platform/node/connection.d.ts +2 -0
- package/dist/src/service.d.ts +4 -5
- package/dist/storage.d.ts +21 -20
- package/dist/test/browser/connection.test.d.ts +17 -0
- package/dist/test/unit/connection.d.ts +1 -0
- package/dist/test/unit/connection.test.d.ts +17 -0
- package/dist/test/unit/testshared.d.ts +0 -3
- package/package.json +6 -6
package/dist/index.cjs.js
CHANGED
|
@@ -11,32 +11,6 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
11
11
|
|
|
12
12
|
var nodeFetch__default = /*#__PURE__*/_interopDefaultLegacy(nodeFetch);
|
|
13
13
|
|
|
14
|
-
/**
|
|
15
|
-
* @license
|
|
16
|
-
* Copyright 2017 Google LLC
|
|
17
|
-
*
|
|
18
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
19
|
-
* you may not use this file except in compliance with the License.
|
|
20
|
-
* You may obtain a copy of the License at
|
|
21
|
-
*
|
|
22
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
23
|
-
*
|
|
24
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
25
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
26
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
27
|
-
* See the License for the specific language governing permissions and
|
|
28
|
-
* limitations under the License.
|
|
29
|
-
*/
|
|
30
|
-
/**
|
|
31
|
-
* Error codes for requests made by the the XhrIo wrapper.
|
|
32
|
-
*/
|
|
33
|
-
var ErrorCode;
|
|
34
|
-
(function (ErrorCode) {
|
|
35
|
-
ErrorCode[ErrorCode["NO_ERROR"] = 0] = "NO_ERROR";
|
|
36
|
-
ErrorCode[ErrorCode["NETWORK_ERROR"] = 1] = "NETWORK_ERROR";
|
|
37
|
-
ErrorCode[ErrorCode["ABORT"] = 2] = "ABORT";
|
|
38
|
-
})(ErrorCode || (ErrorCode = {}));
|
|
39
|
-
|
|
40
14
|
/**
|
|
41
15
|
* @license
|
|
42
16
|
* Copyright 2017 Google LLC
|
|
@@ -209,120 +183,6 @@ function internalError(message) {
|
|
|
209
183
|
throw new StorageError("internal-error" /* INTERNAL_ERROR */, 'Internal error: ' + message);
|
|
210
184
|
}
|
|
211
185
|
|
|
212
|
-
/**
|
|
213
|
-
* @license
|
|
214
|
-
* Copyright 2021 Google LLC
|
|
215
|
-
*
|
|
216
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
217
|
-
* you may not use this file except in compliance with the License.
|
|
218
|
-
* You may obtain a copy of the License at
|
|
219
|
-
*
|
|
220
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
221
|
-
*
|
|
222
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
223
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
224
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
225
|
-
* See the License for the specific language governing permissions and
|
|
226
|
-
* limitations under the License.
|
|
227
|
-
*/
|
|
228
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
229
|
-
const fetch = nodeFetch__default['default'];
|
|
230
|
-
/**
|
|
231
|
-
* Network layer that works in Node.
|
|
232
|
-
*
|
|
233
|
-
* This network implementation should not be used in browsers as it does not
|
|
234
|
-
* support progress updates.
|
|
235
|
-
*/
|
|
236
|
-
class FetchConnection {
|
|
237
|
-
constructor() {
|
|
238
|
-
this.sent_ = false;
|
|
239
|
-
this.errorCode_ = ErrorCode.NO_ERROR;
|
|
240
|
-
}
|
|
241
|
-
send(url, method, body, headers) {
|
|
242
|
-
if (this.sent_) {
|
|
243
|
-
throw internalError('cannot .send() more than once');
|
|
244
|
-
}
|
|
245
|
-
this.sent_ = true;
|
|
246
|
-
return fetch(url, {
|
|
247
|
-
method,
|
|
248
|
-
headers: headers || {},
|
|
249
|
-
body
|
|
250
|
-
})
|
|
251
|
-
.then(resp => {
|
|
252
|
-
this.headers_ = resp.headers;
|
|
253
|
-
this.statusCode_ = resp.status;
|
|
254
|
-
return resp.text();
|
|
255
|
-
})
|
|
256
|
-
.then(body => {
|
|
257
|
-
this.body_ = body;
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
getErrorCode() {
|
|
261
|
-
if (this.errorCode_ === undefined) {
|
|
262
|
-
throw internalError('cannot .getErrorCode() before receiving response');
|
|
263
|
-
}
|
|
264
|
-
return this.errorCode_;
|
|
265
|
-
}
|
|
266
|
-
getStatus() {
|
|
267
|
-
if (this.statusCode_ === undefined) {
|
|
268
|
-
throw internalError('cannot .getStatus() before receiving response');
|
|
269
|
-
}
|
|
270
|
-
return this.statusCode_;
|
|
271
|
-
}
|
|
272
|
-
getResponseText() {
|
|
273
|
-
if (this.body_ === undefined) {
|
|
274
|
-
throw internalError('cannot .getResponseText() before receiving response');
|
|
275
|
-
}
|
|
276
|
-
return this.body_;
|
|
277
|
-
}
|
|
278
|
-
abort() {
|
|
279
|
-
// Not supported
|
|
280
|
-
}
|
|
281
|
-
getResponseHeader(header) {
|
|
282
|
-
if (!this.headers_) {
|
|
283
|
-
throw internalError('cannot .getResponseText() before receiving response');
|
|
284
|
-
}
|
|
285
|
-
return this.headers_.get(header);
|
|
286
|
-
}
|
|
287
|
-
addUploadProgressListener(listener) {
|
|
288
|
-
// Not supported
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* @override
|
|
292
|
-
*/
|
|
293
|
-
removeUploadProgressListener(listener) {
|
|
294
|
-
// Not supported
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
function newConnection() {
|
|
298
|
-
return new FetchConnection();
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* @license
|
|
303
|
-
* Copyright 2017 Google LLC
|
|
304
|
-
*
|
|
305
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
306
|
-
* you may not use this file except in compliance with the License.
|
|
307
|
-
* You may obtain a copy of the License at
|
|
308
|
-
*
|
|
309
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
310
|
-
*
|
|
311
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
312
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
313
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
314
|
-
* See the License for the specific language governing permissions and
|
|
315
|
-
* limitations under the License.
|
|
316
|
-
*/
|
|
317
|
-
/**
|
|
318
|
-
* Factory-like class for creating XhrIo instances.
|
|
319
|
-
*/
|
|
320
|
-
class ConnectionPool {
|
|
321
|
-
createConnection() {
|
|
322
|
-
return newConnection();
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
186
|
/**
|
|
327
187
|
* @license
|
|
328
188
|
* Copyright 2017 Google LLC
|
|
@@ -652,6 +512,32 @@ function makeQueryString(params) {
|
|
|
652
512
|
return queryPart;
|
|
653
513
|
}
|
|
654
514
|
|
|
515
|
+
/**
|
|
516
|
+
* @license
|
|
517
|
+
* Copyright 2017 Google LLC
|
|
518
|
+
*
|
|
519
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
520
|
+
* you may not use this file except in compliance with the License.
|
|
521
|
+
* You may obtain a copy of the License at
|
|
522
|
+
*
|
|
523
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
524
|
+
*
|
|
525
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
526
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
527
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
528
|
+
* See the License for the specific language governing permissions and
|
|
529
|
+
* limitations under the License.
|
|
530
|
+
*/
|
|
531
|
+
/**
|
|
532
|
+
* Error codes for requests made by the the XhrIo wrapper.
|
|
533
|
+
*/
|
|
534
|
+
var ErrorCode;
|
|
535
|
+
(function (ErrorCode) {
|
|
536
|
+
ErrorCode[ErrorCode["NO_ERROR"] = 0] = "NO_ERROR";
|
|
537
|
+
ErrorCode[ErrorCode["NETWORK_ERROR"] = 1] = "NETWORK_ERROR";
|
|
538
|
+
ErrorCode[ErrorCode["ABORT"] = 2] = "ABORT";
|
|
539
|
+
})(ErrorCode || (ErrorCode = {}));
|
|
540
|
+
|
|
655
541
|
/**
|
|
656
542
|
* @license
|
|
657
543
|
* Copyright 2017 Google LLC
|
|
@@ -669,22 +555,22 @@ function makeQueryString(params) {
|
|
|
669
555
|
* limitations under the License.
|
|
670
556
|
*/
|
|
671
557
|
class NetworkRequest {
|
|
672
|
-
constructor(
|
|
558
|
+
constructor(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, connectionFactory_) {
|
|
559
|
+
this.url_ = url_;
|
|
560
|
+
this.method_ = method_;
|
|
561
|
+
this.headers_ = headers_;
|
|
562
|
+
this.body_ = body_;
|
|
563
|
+
this.successCodes_ = successCodes_;
|
|
564
|
+
this.additionalRetryCodes_ = additionalRetryCodes_;
|
|
565
|
+
this.callback_ = callback_;
|
|
566
|
+
this.errorCallback_ = errorCallback_;
|
|
567
|
+
this.timeout_ = timeout_;
|
|
568
|
+
this.progressCallback_ = progressCallback_;
|
|
569
|
+
this.connectionFactory_ = connectionFactory_;
|
|
673
570
|
this.pendingConnection_ = null;
|
|
674
571
|
this.backoffId_ = null;
|
|
675
572
|
this.canceled_ = false;
|
|
676
573
|
this.appDelete_ = false;
|
|
677
|
-
this.url_ = url;
|
|
678
|
-
this.method_ = method;
|
|
679
|
-
this.headers_ = headers;
|
|
680
|
-
this.body_ = body;
|
|
681
|
-
this.successCodes_ = successCodes.slice();
|
|
682
|
-
this.additionalRetryCodes_ = additionalRetryCodes.slice();
|
|
683
|
-
this.callback_ = callback;
|
|
684
|
-
this.errorCallback_ = errorCallback;
|
|
685
|
-
this.progressCallback_ = progressCallback;
|
|
686
|
-
this.timeout_ = timeout;
|
|
687
|
-
this.pool_ = pool;
|
|
688
574
|
this.promise_ = new Promise((resolve, reject) => {
|
|
689
575
|
this.resolve_ = resolve;
|
|
690
576
|
this.reject_ = reject;
|
|
@@ -695,54 +581,56 @@ class NetworkRequest {
|
|
|
695
581
|
* Actually starts the retry loop.
|
|
696
582
|
*/
|
|
697
583
|
start_() {
|
|
698
|
-
const
|
|
699
|
-
function doTheRequest(backoffCallback, canceled) {
|
|
584
|
+
const doTheRequest = (backoffCallback, canceled) => {
|
|
700
585
|
if (canceled) {
|
|
701
586
|
backoffCallback(false, new RequestEndStatus(false, null, true));
|
|
702
587
|
return;
|
|
703
588
|
}
|
|
704
|
-
const connection =
|
|
705
|
-
|
|
706
|
-
|
|
589
|
+
const connection = this.connectionFactory_();
|
|
590
|
+
this.pendingConnection_ = connection;
|
|
591
|
+
const progressListener = progressEvent => {
|
|
707
592
|
const loaded = progressEvent.loaded;
|
|
708
|
-
const total = progressEvent.lengthComputable
|
|
709
|
-
|
|
710
|
-
|
|
593
|
+
const total = progressEvent.lengthComputable
|
|
594
|
+
? progressEvent.total
|
|
595
|
+
: -1;
|
|
596
|
+
if (this.progressCallback_ !== null) {
|
|
597
|
+
this.progressCallback_(loaded, total);
|
|
711
598
|
}
|
|
712
|
-
}
|
|
713
|
-
if (
|
|
599
|
+
};
|
|
600
|
+
if (this.progressCallback_ !== null) {
|
|
714
601
|
connection.addUploadProgressListener(progressListener);
|
|
715
602
|
}
|
|
603
|
+
// connection.send() never rejects, so we don't need to have a error handler or use catch on the returned promise.
|
|
716
604
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
717
605
|
connection
|
|
718
|
-
.send(
|
|
606
|
+
.send(this.url_, this.method_, this.body_, this.headers_)
|
|
719
607
|
.then(() => {
|
|
720
|
-
if (
|
|
608
|
+
if (this.progressCallback_ !== null) {
|
|
721
609
|
connection.removeUploadProgressListener(progressListener);
|
|
722
610
|
}
|
|
723
|
-
|
|
611
|
+
this.pendingConnection_ = null;
|
|
724
612
|
const hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR;
|
|
725
613
|
const status = connection.getStatus();
|
|
726
|
-
if (!hitServer ||
|
|
614
|
+
if (!hitServer || this.isRetryStatusCode_(status)) {
|
|
727
615
|
const wasCanceled = connection.getErrorCode() === ErrorCode.ABORT;
|
|
728
616
|
backoffCallback(false, new RequestEndStatus(false, null, wasCanceled));
|
|
729
617
|
return;
|
|
730
618
|
}
|
|
731
|
-
const successCode =
|
|
619
|
+
const successCode = this.successCodes_.indexOf(status) !== -1;
|
|
732
620
|
backoffCallback(true, new RequestEndStatus(successCode, connection));
|
|
733
621
|
});
|
|
734
|
-
}
|
|
622
|
+
};
|
|
735
623
|
/**
|
|
736
624
|
* @param requestWentThrough - True if the request eventually went
|
|
737
625
|
* through, false if it hit the retry limit or was canceled.
|
|
738
626
|
*/
|
|
739
|
-
|
|
740
|
-
const resolve =
|
|
741
|
-
const reject =
|
|
627
|
+
const backoffDone = (requestWentThrough, status) => {
|
|
628
|
+
const resolve = this.resolve_;
|
|
629
|
+
const reject = this.reject_;
|
|
742
630
|
const connection = status.connection;
|
|
743
631
|
if (status.wasSuccessCode) {
|
|
744
632
|
try {
|
|
745
|
-
const result =
|
|
633
|
+
const result = this.callback_(connection, connection.getResponseText());
|
|
746
634
|
if (isJustDef(result)) {
|
|
747
635
|
resolve(result);
|
|
748
636
|
}
|
|
@@ -758,8 +646,8 @@ class NetworkRequest {
|
|
|
758
646
|
if (connection !== null) {
|
|
759
647
|
const err = unknown();
|
|
760
648
|
err.serverResponse = connection.getResponseText();
|
|
761
|
-
if (
|
|
762
|
-
reject(
|
|
649
|
+
if (this.errorCallback_) {
|
|
650
|
+
reject(this.errorCallback_(connection, err));
|
|
763
651
|
}
|
|
764
652
|
else {
|
|
765
653
|
reject(err);
|
|
@@ -767,7 +655,7 @@ class NetworkRequest {
|
|
|
767
655
|
}
|
|
768
656
|
else {
|
|
769
657
|
if (status.canceled) {
|
|
770
|
-
const err =
|
|
658
|
+
const err = this.appDelete_ ? appDeleted() : canceled();
|
|
771
659
|
reject(err);
|
|
772
660
|
}
|
|
773
661
|
else {
|
|
@@ -776,7 +664,7 @@ class NetworkRequest {
|
|
|
776
664
|
}
|
|
777
665
|
}
|
|
778
666
|
}
|
|
779
|
-
}
|
|
667
|
+
};
|
|
780
668
|
if (this.canceled_) {
|
|
781
669
|
backoffDone(false, new RequestEndStatus(false, null, true));
|
|
782
670
|
}
|
|
@@ -844,7 +732,7 @@ function addAppCheckHeader_(headers, appCheckToken) {
|
|
|
844
732
|
headers['X-Firebase-AppCheck'] = appCheckToken;
|
|
845
733
|
}
|
|
846
734
|
}
|
|
847
|
-
function makeRequest(requestInfo, appId, authToken, appCheckToken,
|
|
735
|
+
function makeRequest(requestInfo, appId, authToken, appCheckToken, requestFactory, firebaseVersion) {
|
|
848
736
|
const queryPart = makeQueryString(requestInfo.urlParams);
|
|
849
737
|
const url = requestInfo.url + queryPart;
|
|
850
738
|
const headers = Object.assign({}, requestInfo.headers);
|
|
@@ -852,7 +740,7 @@ function makeRequest(requestInfo, appId, authToken, appCheckToken, pool, firebas
|
|
|
852
740
|
addAuthHeader_(headers, authToken);
|
|
853
741
|
addVersionHeader_(headers, firebaseVersion);
|
|
854
742
|
addAppCheckHeader_(headers, appCheckToken);
|
|
855
|
-
return new NetworkRequest(url, requestInfo.method, headers, requestInfo.body, requestInfo.successCodes, requestInfo.additionalRetryCodes, requestInfo.handler, requestInfo.errorHandler, requestInfo.timeout, requestInfo.progressCallback,
|
|
743
|
+
return new NetworkRequest(url, requestInfo.method, headers, requestInfo.body, requestInfo.successCodes, requestInfo.additionalRetryCodes, requestInfo.handler, requestInfo.errorHandler, requestInfo.timeout, requestInfo.progressCallback, requestFactory);
|
|
856
744
|
}
|
|
857
745
|
|
|
858
746
|
/**
|
|
@@ -2109,6 +1997,101 @@ function async(f) {
|
|
|
2109
1997
|
};
|
|
2110
1998
|
}
|
|
2111
1999
|
|
|
2000
|
+
/**
|
|
2001
|
+
* @license
|
|
2002
|
+
* Copyright 2021 Google LLC
|
|
2003
|
+
*
|
|
2004
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2005
|
+
* you may not use this file except in compliance with the License.
|
|
2006
|
+
* You may obtain a copy of the License at
|
|
2007
|
+
*
|
|
2008
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2009
|
+
*
|
|
2010
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2011
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2012
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2013
|
+
* See the License for the specific language governing permissions and
|
|
2014
|
+
* limitations under the License.
|
|
2015
|
+
*/
|
|
2016
|
+
/** An override for the text-based Connection. Used in tests. */
|
|
2017
|
+
let connectionFactoryOverride = null;
|
|
2018
|
+
/**
|
|
2019
|
+
* Network layer that works in Node.
|
|
2020
|
+
*
|
|
2021
|
+
* This network implementation should not be used in browsers as it does not
|
|
2022
|
+
* support progress updates.
|
|
2023
|
+
*/
|
|
2024
|
+
class FetchConnection {
|
|
2025
|
+
constructor() {
|
|
2026
|
+
this.sent_ = false;
|
|
2027
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2028
|
+
this.fetch_ = nodeFetch__default["default"];
|
|
2029
|
+
this.errorCode_ = ErrorCode.NO_ERROR;
|
|
2030
|
+
}
|
|
2031
|
+
send(url, method, body, headers) {
|
|
2032
|
+
if (this.sent_) {
|
|
2033
|
+
throw internalError('cannot .send() more than once');
|
|
2034
|
+
}
|
|
2035
|
+
this.sent_ = true;
|
|
2036
|
+
return this.fetch_(url, {
|
|
2037
|
+
method,
|
|
2038
|
+
headers: headers || {},
|
|
2039
|
+
body
|
|
2040
|
+
}).then(resp => {
|
|
2041
|
+
this.headers_ = resp.headers;
|
|
2042
|
+
this.statusCode_ = resp.status;
|
|
2043
|
+
return resp.text().then(body => {
|
|
2044
|
+
this.body_ = body;
|
|
2045
|
+
});
|
|
2046
|
+
}, (_err) => {
|
|
2047
|
+
this.errorCode_ = ErrorCode.NETWORK_ERROR;
|
|
2048
|
+
// emulate XHR which sets status to 0 when encountering a network error
|
|
2049
|
+
this.statusCode_ = 0;
|
|
2050
|
+
});
|
|
2051
|
+
}
|
|
2052
|
+
getErrorCode() {
|
|
2053
|
+
if (this.errorCode_ === undefined) {
|
|
2054
|
+
throw internalError('cannot .getErrorCode() before receiving response');
|
|
2055
|
+
}
|
|
2056
|
+
return this.errorCode_;
|
|
2057
|
+
}
|
|
2058
|
+
getStatus() {
|
|
2059
|
+
if (this.statusCode_ === undefined) {
|
|
2060
|
+
throw internalError('cannot .getStatus() before receiving response');
|
|
2061
|
+
}
|
|
2062
|
+
return this.statusCode_;
|
|
2063
|
+
}
|
|
2064
|
+
getResponseText() {
|
|
2065
|
+
if (this.body_ === undefined) {
|
|
2066
|
+
throw internalError('cannot .getResponseText() before receiving response');
|
|
2067
|
+
}
|
|
2068
|
+
return this.body_;
|
|
2069
|
+
}
|
|
2070
|
+
abort() {
|
|
2071
|
+
// Not supported
|
|
2072
|
+
}
|
|
2073
|
+
getResponseHeader(header) {
|
|
2074
|
+
if (!this.headers_) {
|
|
2075
|
+
throw internalError('cannot .getResponseText() before receiving response');
|
|
2076
|
+
}
|
|
2077
|
+
return this.headers_.get(header);
|
|
2078
|
+
}
|
|
2079
|
+
addUploadProgressListener(listener) {
|
|
2080
|
+
// Not supported
|
|
2081
|
+
}
|
|
2082
|
+
/**
|
|
2083
|
+
* @override
|
|
2084
|
+
*/
|
|
2085
|
+
removeUploadProgressListener(listener) {
|
|
2086
|
+
// Not supported
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
function newConnection() {
|
|
2090
|
+
return connectionFactoryOverride
|
|
2091
|
+
? connectionFactoryOverride()
|
|
2092
|
+
: new FetchConnection();
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2112
2095
|
/**
|
|
2113
2096
|
* @license
|
|
2114
2097
|
* Copyright 2017 Google LLC
|
|
@@ -2248,7 +2231,7 @@ class UploadTask {
|
|
|
2248
2231
|
_createResumable() {
|
|
2249
2232
|
this._resolveToken((authToken, appCheckToken) => {
|
|
2250
2233
|
const requestInfo = createResumableUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata);
|
|
2251
|
-
const createRequest = this._ref.storage._makeRequest(requestInfo, authToken, appCheckToken);
|
|
2234
|
+
const createRequest = this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
|
|
2252
2235
|
this._request = createRequest;
|
|
2253
2236
|
createRequest.getPromise().then((url) => {
|
|
2254
2237
|
this._request = undefined;
|
|
@@ -2263,7 +2246,7 @@ class UploadTask {
|
|
|
2263
2246
|
const url = this._uploadUrl;
|
|
2264
2247
|
this._resolveToken((authToken, appCheckToken) => {
|
|
2265
2248
|
const requestInfo = getResumableUploadStatus(this._ref.storage, this._ref._location, url, this._blob);
|
|
2266
|
-
const statusRequest = this._ref.storage._makeRequest(requestInfo, authToken, appCheckToken);
|
|
2249
|
+
const statusRequest = this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
|
|
2267
2250
|
this._request = statusRequest;
|
|
2268
2251
|
statusRequest.getPromise().then(status => {
|
|
2269
2252
|
status = status;
|
|
@@ -2292,7 +2275,7 @@ class UploadTask {
|
|
|
2292
2275
|
this._transition("error" /* ERROR */);
|
|
2293
2276
|
return;
|
|
2294
2277
|
}
|
|
2295
|
-
const uploadRequest = this._ref.storage._makeRequest(requestInfo, authToken, appCheckToken);
|
|
2278
|
+
const uploadRequest = this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
|
|
2296
2279
|
this._request = uploadRequest;
|
|
2297
2280
|
uploadRequest.getPromise().then((newStatus) => {
|
|
2298
2281
|
this._increaseMultiplier();
|
|
@@ -2318,7 +2301,7 @@ class UploadTask {
|
|
|
2318
2301
|
_fetchMetadata() {
|
|
2319
2302
|
this._resolveToken((authToken, appCheckToken) => {
|
|
2320
2303
|
const requestInfo = getMetadata$2(this._ref.storage, this._ref._location, this._mappings);
|
|
2321
|
-
const metadataRequest = this._ref.storage._makeRequest(requestInfo, authToken, appCheckToken);
|
|
2304
|
+
const metadataRequest = this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
|
|
2322
2305
|
this._request = metadataRequest;
|
|
2323
2306
|
metadataRequest.getPromise().then(metadata => {
|
|
2324
2307
|
this._request = undefined;
|
|
@@ -2330,7 +2313,7 @@ class UploadTask {
|
|
|
2330
2313
|
_oneShotUpload() {
|
|
2331
2314
|
this._resolveToken((authToken, appCheckToken) => {
|
|
2332
2315
|
const requestInfo = multipartUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata);
|
|
2333
|
-
const multipartRequest = this._ref.storage._makeRequest(requestInfo, authToken, appCheckToken);
|
|
2316
|
+
const multipartRequest = this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
|
|
2334
2317
|
this._request = multipartRequest;
|
|
2335
2318
|
multipartRequest.getPromise().then(metadata => {
|
|
2336
2319
|
this._request = undefined;
|
|
@@ -2708,8 +2691,7 @@ function uploadBytes$1(ref, data, metadata) {
|
|
|
2708
2691
|
ref._throwIfRoot('uploadBytes');
|
|
2709
2692
|
const requestInfo = multipartUpload(ref.storage, ref._location, getMappings(), new FbsBlob(data, true), metadata);
|
|
2710
2693
|
return ref.storage
|
|
2711
|
-
.makeRequestWithTokens(requestInfo)
|
|
2712
|
-
.then(request => request.getPromise())
|
|
2694
|
+
.makeRequestWithTokens(requestInfo, newConnection)
|
|
2713
2695
|
.then(finalMetadata => {
|
|
2714
2696
|
return {
|
|
2715
2697
|
metadata: finalMetadata,
|
|
@@ -2815,7 +2797,7 @@ async function listAllHelper(ref, accumulator, pageToken) {
|
|
|
2815
2797
|
* contains references to objects in this folder. `nextPageToken`
|
|
2816
2798
|
* can be used to get the rest of the results.
|
|
2817
2799
|
*/
|
|
2818
|
-
|
|
2800
|
+
function list$1(ref, options) {
|
|
2819
2801
|
if (options != null) {
|
|
2820
2802
|
if (typeof options.maxResults === 'number') {
|
|
2821
2803
|
validateNumber('options.maxResults',
|
|
@@ -2826,7 +2808,7 @@ async function list$1(ref, options) {
|
|
|
2826
2808
|
const op = options || {};
|
|
2827
2809
|
const requestInfo = list$2(ref.storage, ref._location,
|
|
2828
2810
|
/*delimiter= */ '/', op.pageToken, op.maxResults);
|
|
2829
|
-
return
|
|
2811
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
|
|
2830
2812
|
}
|
|
2831
2813
|
/**
|
|
2832
2814
|
* A `Promise` that resolves with the metadata for this object. If this
|
|
@@ -2835,10 +2817,10 @@ async function list$1(ref, options) {
|
|
|
2835
2817
|
* @public
|
|
2836
2818
|
* @param ref - StorageReference to get metadata from.
|
|
2837
2819
|
*/
|
|
2838
|
-
|
|
2820
|
+
function getMetadata$1(ref) {
|
|
2839
2821
|
ref._throwIfRoot('getMetadata');
|
|
2840
2822
|
const requestInfo = getMetadata$2(ref.storage, ref._location, getMappings());
|
|
2841
|
-
return
|
|
2823
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
|
|
2842
2824
|
}
|
|
2843
2825
|
/**
|
|
2844
2826
|
* Updates the metadata for this object.
|
|
@@ -2851,10 +2833,10 @@ async function getMetadata$1(ref) {
|
|
|
2851
2833
|
* with the new metadata for this object.
|
|
2852
2834
|
* See `firebaseStorage.Reference.prototype.getMetadata`
|
|
2853
2835
|
*/
|
|
2854
|
-
|
|
2836
|
+
function updateMetadata$1(ref, metadata) {
|
|
2855
2837
|
ref._throwIfRoot('updateMetadata');
|
|
2856
2838
|
const requestInfo = updateMetadata$2(ref.storage, ref._location, metadata, getMappings());
|
|
2857
|
-
return
|
|
2839
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
|
|
2858
2840
|
}
|
|
2859
2841
|
/**
|
|
2860
2842
|
* Returns the download URL for the given Reference.
|
|
@@ -2862,11 +2844,11 @@ async function updateMetadata$1(ref, metadata) {
|
|
|
2862
2844
|
* @returns A `Promise` that resolves with the download
|
|
2863
2845
|
* URL for this object.
|
|
2864
2846
|
*/
|
|
2865
|
-
|
|
2847
|
+
function getDownloadURL$1(ref) {
|
|
2866
2848
|
ref._throwIfRoot('getDownloadURL');
|
|
2867
2849
|
const requestInfo = getDownloadUrl(ref.storage, ref._location, getMappings());
|
|
2868
|
-
return
|
|
2869
|
-
.
|
|
2850
|
+
return ref.storage
|
|
2851
|
+
.makeRequestWithTokens(requestInfo, newConnection)
|
|
2870
2852
|
.then(url => {
|
|
2871
2853
|
if (url === null) {
|
|
2872
2854
|
throw noDownloadURL();
|
|
@@ -2880,10 +2862,10 @@ async function getDownloadURL$1(ref) {
|
|
|
2880
2862
|
* @param ref - StorageReference for object to delete.
|
|
2881
2863
|
* @returns A `Promise` that resolves if the deletion succeeds.
|
|
2882
2864
|
*/
|
|
2883
|
-
|
|
2865
|
+
function deleteObject$1(ref) {
|
|
2884
2866
|
ref._throwIfRoot('deleteObject');
|
|
2885
2867
|
const requestInfo = deleteObject$2(ref.storage, ref._location);
|
|
2886
|
-
return
|
|
2868
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
|
|
2887
2869
|
}
|
|
2888
2870
|
/**
|
|
2889
2871
|
* Returns reference for object obtained by appending `childPath` to `ref`.
|
|
@@ -3004,11 +2986,10 @@ class FirebaseStorageImpl {
|
|
|
3004
2986
|
/**
|
|
3005
2987
|
* @internal
|
|
3006
2988
|
*/
|
|
3007
|
-
|
|
2989
|
+
_url, _firebaseVersion) {
|
|
3008
2990
|
this.app = app;
|
|
3009
2991
|
this._authProvider = _authProvider;
|
|
3010
2992
|
this._appCheckProvider = _appCheckProvider;
|
|
3011
|
-
this._pool = _pool;
|
|
3012
2993
|
this._url = _url;
|
|
3013
2994
|
this._firebaseVersion = _firebaseVersion;
|
|
3014
2995
|
this._bucket = null;
|
|
@@ -3119,9 +3100,9 @@ class FirebaseStorageImpl {
|
|
|
3119
3100
|
* @param requestInfo - HTTP RequestInfo object
|
|
3120
3101
|
* @param authToken - Firebase auth token
|
|
3121
3102
|
*/
|
|
3122
|
-
_makeRequest(requestInfo, authToken, appCheckToken) {
|
|
3103
|
+
_makeRequest(requestInfo, requestFactory, authToken, appCheckToken) {
|
|
3123
3104
|
if (!this._deleted) {
|
|
3124
|
-
const request = makeRequest(requestInfo, this._appId, authToken, appCheckToken,
|
|
3105
|
+
const request = makeRequest(requestInfo, this._appId, authToken, appCheckToken, requestFactory, this._firebaseVersion);
|
|
3125
3106
|
this._requests.add(request);
|
|
3126
3107
|
// Request removes itself from set when complete.
|
|
3127
3108
|
request.getPromise().then(() => this._requests.delete(request), () => this._requests.delete(request));
|
|
@@ -3131,17 +3112,17 @@ class FirebaseStorageImpl {
|
|
|
3131
3112
|
return new FailRequest(appDeleted());
|
|
3132
3113
|
}
|
|
3133
3114
|
}
|
|
3134
|
-
async makeRequestWithTokens(requestInfo) {
|
|
3115
|
+
async makeRequestWithTokens(requestInfo, requestFactory) {
|
|
3135
3116
|
const [authToken, appCheckToken] = await Promise.all([
|
|
3136
3117
|
this._getAuthToken(),
|
|
3137
3118
|
this._getAppCheckToken()
|
|
3138
3119
|
]);
|
|
3139
|
-
return this._makeRequest(requestInfo, authToken, appCheckToken);
|
|
3120
|
+
return this._makeRequest(requestInfo, requestFactory, authToken, appCheckToken).getPromise();
|
|
3140
3121
|
}
|
|
3141
3122
|
}
|
|
3142
3123
|
|
|
3143
3124
|
const name = "@firebase/storage";
|
|
3144
|
-
const version = "0.8.
|
|
3125
|
+
const version = "0.8.4-2021927221742";
|
|
3145
3126
|
|
|
3146
3127
|
/**
|
|
3147
3128
|
* @license
|
|
@@ -3363,7 +3344,7 @@ function factory(container, { instanceIdentifier: url }) {
|
|
|
3363
3344
|
const app$1 = container.getProvider('app').getImmediate();
|
|
3364
3345
|
const authProvider = container.getProvider('auth-internal');
|
|
3365
3346
|
const appCheckProvider = container.getProvider('app-check-internal');
|
|
3366
|
-
return new FirebaseStorageImpl(app$1, authProvider, appCheckProvider,
|
|
3347
|
+
return new FirebaseStorageImpl(app$1, authProvider, appCheckProvider, url, app.SDK_VERSION);
|
|
3367
3348
|
}
|
|
3368
3349
|
function registerStorage() {
|
|
3369
3350
|
app._registerComponent(new component.Component(STORAGE_TYPE, factory, "PUBLIC" /* PUBLIC */).setMultipleInstances(true));
|