@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.esm2017.js
CHANGED
|
@@ -2,32 +2,6 @@ import { getApp, _getProvider, _registerComponent, registerVersion, SDK_VERSION
|
|
|
2
2
|
import { FirebaseError, createMockUserToken, getModularInstance } from '@firebase/util';
|
|
3
3
|
import { Component } from '@firebase/component';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* @license
|
|
7
|
-
* Copyright 2017 Google LLC
|
|
8
|
-
*
|
|
9
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
-
* you may not use this file except in compliance with the License.
|
|
11
|
-
* You may obtain a copy of the License at
|
|
12
|
-
*
|
|
13
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
-
*
|
|
15
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
-
* See the License for the specific language governing permissions and
|
|
19
|
-
* limitations under the License.
|
|
20
|
-
*/
|
|
21
|
-
/**
|
|
22
|
-
* Error codes for requests made by the the XhrIo wrapper.
|
|
23
|
-
*/
|
|
24
|
-
var ErrorCode;
|
|
25
|
-
(function (ErrorCode) {
|
|
26
|
-
ErrorCode[ErrorCode["NO_ERROR"] = 0] = "NO_ERROR";
|
|
27
|
-
ErrorCode[ErrorCode["NETWORK_ERROR"] = 1] = "NETWORK_ERROR";
|
|
28
|
-
ErrorCode[ErrorCode["ABORT"] = 2] = "ABORT";
|
|
29
|
-
})(ErrorCode || (ErrorCode = {}));
|
|
30
|
-
|
|
31
5
|
/**
|
|
32
6
|
* @license
|
|
33
7
|
* Copyright 2017 Google LLC
|
|
@@ -200,160 +174,6 @@ function internalError(message) {
|
|
|
200
174
|
throw new StorageError("internal-error" /* INTERNAL_ERROR */, 'Internal error: ' + message);
|
|
201
175
|
}
|
|
202
176
|
|
|
203
|
-
/**
|
|
204
|
-
* @license
|
|
205
|
-
* Copyright 2017 Google LLC
|
|
206
|
-
*
|
|
207
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
208
|
-
* you may not use this file except in compliance with the License.
|
|
209
|
-
* You may obtain a copy of the License at
|
|
210
|
-
*
|
|
211
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
212
|
-
*
|
|
213
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
214
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
215
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
216
|
-
* See the License for the specific language governing permissions and
|
|
217
|
-
* limitations under the License.
|
|
218
|
-
*/
|
|
219
|
-
/**
|
|
220
|
-
* Network layer for browsers. We use this instead of goog.net.XhrIo because
|
|
221
|
-
* goog.net.XhrIo is hyuuuuge and doesn't work in React Native on Android.
|
|
222
|
-
*/
|
|
223
|
-
class XhrConnection {
|
|
224
|
-
constructor() {
|
|
225
|
-
this.sent_ = false;
|
|
226
|
-
this.xhr_ = new XMLHttpRequest();
|
|
227
|
-
this.errorCode_ = ErrorCode.NO_ERROR;
|
|
228
|
-
this.sendPromise_ = new Promise(resolve => {
|
|
229
|
-
this.xhr_.addEventListener('abort', () => {
|
|
230
|
-
this.errorCode_ = ErrorCode.ABORT;
|
|
231
|
-
resolve();
|
|
232
|
-
});
|
|
233
|
-
this.xhr_.addEventListener('error', () => {
|
|
234
|
-
this.errorCode_ = ErrorCode.NETWORK_ERROR;
|
|
235
|
-
resolve();
|
|
236
|
-
});
|
|
237
|
-
this.xhr_.addEventListener('load', () => {
|
|
238
|
-
resolve();
|
|
239
|
-
});
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* @override
|
|
244
|
-
*/
|
|
245
|
-
send(url, method, body, headers) {
|
|
246
|
-
if (this.sent_) {
|
|
247
|
-
throw internalError('cannot .send() more than once');
|
|
248
|
-
}
|
|
249
|
-
this.sent_ = true;
|
|
250
|
-
this.xhr_.open(method, url, true);
|
|
251
|
-
if (headers !== undefined) {
|
|
252
|
-
for (const key in headers) {
|
|
253
|
-
if (headers.hasOwnProperty(key)) {
|
|
254
|
-
this.xhr_.setRequestHeader(key, headers[key].toString());
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
if (body !== undefined) {
|
|
259
|
-
this.xhr_.send(body);
|
|
260
|
-
}
|
|
261
|
-
else {
|
|
262
|
-
this.xhr_.send();
|
|
263
|
-
}
|
|
264
|
-
return this.sendPromise_;
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* @override
|
|
268
|
-
*/
|
|
269
|
-
getErrorCode() {
|
|
270
|
-
if (!this.sent_) {
|
|
271
|
-
throw internalError('cannot .getErrorCode() before sending');
|
|
272
|
-
}
|
|
273
|
-
return this.errorCode_;
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* @override
|
|
277
|
-
*/
|
|
278
|
-
getStatus() {
|
|
279
|
-
if (!this.sent_) {
|
|
280
|
-
throw internalError('cannot .getStatus() before sending');
|
|
281
|
-
}
|
|
282
|
-
try {
|
|
283
|
-
return this.xhr_.status;
|
|
284
|
-
}
|
|
285
|
-
catch (e) {
|
|
286
|
-
return -1;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* @override
|
|
291
|
-
*/
|
|
292
|
-
getResponseText() {
|
|
293
|
-
if (!this.sent_) {
|
|
294
|
-
throw internalError('cannot .getResponseText() before sending');
|
|
295
|
-
}
|
|
296
|
-
return this.xhr_.responseText;
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* Aborts the request.
|
|
300
|
-
* @override
|
|
301
|
-
*/
|
|
302
|
-
abort() {
|
|
303
|
-
this.xhr_.abort();
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* @override
|
|
307
|
-
*/
|
|
308
|
-
getResponseHeader(header) {
|
|
309
|
-
return this.xhr_.getResponseHeader(header);
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* @override
|
|
313
|
-
*/
|
|
314
|
-
addUploadProgressListener(listener) {
|
|
315
|
-
if (this.xhr_.upload != null) {
|
|
316
|
-
this.xhr_.upload.addEventListener('progress', listener);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* @override
|
|
321
|
-
*/
|
|
322
|
-
removeUploadProgressListener(listener) {
|
|
323
|
-
if (this.xhr_.upload != null) {
|
|
324
|
-
this.xhr_.upload.removeEventListener('progress', listener);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
function newConnection() {
|
|
329
|
-
return new XhrConnection();
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* @license
|
|
334
|
-
* Copyright 2017 Google LLC
|
|
335
|
-
*
|
|
336
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
337
|
-
* you may not use this file except in compliance with the License.
|
|
338
|
-
* You may obtain a copy of the License at
|
|
339
|
-
*
|
|
340
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
341
|
-
*
|
|
342
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
343
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
344
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
345
|
-
* See the License for the specific language governing permissions and
|
|
346
|
-
* limitations under the License.
|
|
347
|
-
*/
|
|
348
|
-
/**
|
|
349
|
-
* Factory-like class for creating XhrIo instances.
|
|
350
|
-
*/
|
|
351
|
-
class ConnectionPool {
|
|
352
|
-
createConnection() {
|
|
353
|
-
return newConnection();
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
177
|
/**
|
|
358
178
|
* @license
|
|
359
179
|
* Copyright 2017 Google LLC
|
|
@@ -683,6 +503,32 @@ function makeQueryString(params) {
|
|
|
683
503
|
return queryPart;
|
|
684
504
|
}
|
|
685
505
|
|
|
506
|
+
/**
|
|
507
|
+
* @license
|
|
508
|
+
* Copyright 2017 Google LLC
|
|
509
|
+
*
|
|
510
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
511
|
+
* you may not use this file except in compliance with the License.
|
|
512
|
+
* You may obtain a copy of the License at
|
|
513
|
+
*
|
|
514
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
515
|
+
*
|
|
516
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
517
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
518
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
519
|
+
* See the License for the specific language governing permissions and
|
|
520
|
+
* limitations under the License.
|
|
521
|
+
*/
|
|
522
|
+
/**
|
|
523
|
+
* Error codes for requests made by the the XhrIo wrapper.
|
|
524
|
+
*/
|
|
525
|
+
var ErrorCode;
|
|
526
|
+
(function (ErrorCode) {
|
|
527
|
+
ErrorCode[ErrorCode["NO_ERROR"] = 0] = "NO_ERROR";
|
|
528
|
+
ErrorCode[ErrorCode["NETWORK_ERROR"] = 1] = "NETWORK_ERROR";
|
|
529
|
+
ErrorCode[ErrorCode["ABORT"] = 2] = "ABORT";
|
|
530
|
+
})(ErrorCode || (ErrorCode = {}));
|
|
531
|
+
|
|
686
532
|
/**
|
|
687
533
|
* @license
|
|
688
534
|
* Copyright 2017 Google LLC
|
|
@@ -700,22 +546,22 @@ function makeQueryString(params) {
|
|
|
700
546
|
* limitations under the License.
|
|
701
547
|
*/
|
|
702
548
|
class NetworkRequest {
|
|
703
|
-
constructor(
|
|
549
|
+
constructor(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, connectionFactory_) {
|
|
550
|
+
this.url_ = url_;
|
|
551
|
+
this.method_ = method_;
|
|
552
|
+
this.headers_ = headers_;
|
|
553
|
+
this.body_ = body_;
|
|
554
|
+
this.successCodes_ = successCodes_;
|
|
555
|
+
this.additionalRetryCodes_ = additionalRetryCodes_;
|
|
556
|
+
this.callback_ = callback_;
|
|
557
|
+
this.errorCallback_ = errorCallback_;
|
|
558
|
+
this.timeout_ = timeout_;
|
|
559
|
+
this.progressCallback_ = progressCallback_;
|
|
560
|
+
this.connectionFactory_ = connectionFactory_;
|
|
704
561
|
this.pendingConnection_ = null;
|
|
705
562
|
this.backoffId_ = null;
|
|
706
563
|
this.canceled_ = false;
|
|
707
564
|
this.appDelete_ = false;
|
|
708
|
-
this.url_ = url;
|
|
709
|
-
this.method_ = method;
|
|
710
|
-
this.headers_ = headers;
|
|
711
|
-
this.body_ = body;
|
|
712
|
-
this.successCodes_ = successCodes.slice();
|
|
713
|
-
this.additionalRetryCodes_ = additionalRetryCodes.slice();
|
|
714
|
-
this.callback_ = callback;
|
|
715
|
-
this.errorCallback_ = errorCallback;
|
|
716
|
-
this.progressCallback_ = progressCallback;
|
|
717
|
-
this.timeout_ = timeout;
|
|
718
|
-
this.pool_ = pool;
|
|
719
565
|
this.promise_ = new Promise((resolve, reject) => {
|
|
720
566
|
this.resolve_ = resolve;
|
|
721
567
|
this.reject_ = reject;
|
|
@@ -726,54 +572,56 @@ class NetworkRequest {
|
|
|
726
572
|
* Actually starts the retry loop.
|
|
727
573
|
*/
|
|
728
574
|
start_() {
|
|
729
|
-
const
|
|
730
|
-
function doTheRequest(backoffCallback, canceled) {
|
|
575
|
+
const doTheRequest = (backoffCallback, canceled) => {
|
|
731
576
|
if (canceled) {
|
|
732
577
|
backoffCallback(false, new RequestEndStatus(false, null, true));
|
|
733
578
|
return;
|
|
734
579
|
}
|
|
735
|
-
const connection =
|
|
736
|
-
|
|
737
|
-
|
|
580
|
+
const connection = this.connectionFactory_();
|
|
581
|
+
this.pendingConnection_ = connection;
|
|
582
|
+
const progressListener = progressEvent => {
|
|
738
583
|
const loaded = progressEvent.loaded;
|
|
739
|
-
const total = progressEvent.lengthComputable
|
|
740
|
-
|
|
741
|
-
|
|
584
|
+
const total = progressEvent.lengthComputable
|
|
585
|
+
? progressEvent.total
|
|
586
|
+
: -1;
|
|
587
|
+
if (this.progressCallback_ !== null) {
|
|
588
|
+
this.progressCallback_(loaded, total);
|
|
742
589
|
}
|
|
743
|
-
}
|
|
744
|
-
if (
|
|
590
|
+
};
|
|
591
|
+
if (this.progressCallback_ !== null) {
|
|
745
592
|
connection.addUploadProgressListener(progressListener);
|
|
746
593
|
}
|
|
594
|
+
// connection.send() never rejects, so we don't need to have a error handler or use catch on the returned promise.
|
|
747
595
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
748
596
|
connection
|
|
749
|
-
.send(
|
|
597
|
+
.send(this.url_, this.method_, this.body_, this.headers_)
|
|
750
598
|
.then(() => {
|
|
751
|
-
if (
|
|
599
|
+
if (this.progressCallback_ !== null) {
|
|
752
600
|
connection.removeUploadProgressListener(progressListener);
|
|
753
601
|
}
|
|
754
|
-
|
|
602
|
+
this.pendingConnection_ = null;
|
|
755
603
|
const hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR;
|
|
756
604
|
const status = connection.getStatus();
|
|
757
|
-
if (!hitServer ||
|
|
605
|
+
if (!hitServer || this.isRetryStatusCode_(status)) {
|
|
758
606
|
const wasCanceled = connection.getErrorCode() === ErrorCode.ABORT;
|
|
759
607
|
backoffCallback(false, new RequestEndStatus(false, null, wasCanceled));
|
|
760
608
|
return;
|
|
761
609
|
}
|
|
762
|
-
const successCode =
|
|
610
|
+
const successCode = this.successCodes_.indexOf(status) !== -1;
|
|
763
611
|
backoffCallback(true, new RequestEndStatus(successCode, connection));
|
|
764
612
|
});
|
|
765
|
-
}
|
|
613
|
+
};
|
|
766
614
|
/**
|
|
767
615
|
* @param requestWentThrough - True if the request eventually went
|
|
768
616
|
* through, false if it hit the retry limit or was canceled.
|
|
769
617
|
*/
|
|
770
|
-
|
|
771
|
-
const resolve =
|
|
772
|
-
const reject =
|
|
618
|
+
const backoffDone = (requestWentThrough, status) => {
|
|
619
|
+
const resolve = this.resolve_;
|
|
620
|
+
const reject = this.reject_;
|
|
773
621
|
const connection = status.connection;
|
|
774
622
|
if (status.wasSuccessCode) {
|
|
775
623
|
try {
|
|
776
|
-
const result =
|
|
624
|
+
const result = this.callback_(connection, connection.getResponseText());
|
|
777
625
|
if (isJustDef(result)) {
|
|
778
626
|
resolve(result);
|
|
779
627
|
}
|
|
@@ -789,8 +637,8 @@ class NetworkRequest {
|
|
|
789
637
|
if (connection !== null) {
|
|
790
638
|
const err = unknown();
|
|
791
639
|
err.serverResponse = connection.getResponseText();
|
|
792
|
-
if (
|
|
793
|
-
reject(
|
|
640
|
+
if (this.errorCallback_) {
|
|
641
|
+
reject(this.errorCallback_(connection, err));
|
|
794
642
|
}
|
|
795
643
|
else {
|
|
796
644
|
reject(err);
|
|
@@ -798,7 +646,7 @@ class NetworkRequest {
|
|
|
798
646
|
}
|
|
799
647
|
else {
|
|
800
648
|
if (status.canceled) {
|
|
801
|
-
const err =
|
|
649
|
+
const err = this.appDelete_ ? appDeleted() : canceled();
|
|
802
650
|
reject(err);
|
|
803
651
|
}
|
|
804
652
|
else {
|
|
@@ -807,7 +655,7 @@ class NetworkRequest {
|
|
|
807
655
|
}
|
|
808
656
|
}
|
|
809
657
|
}
|
|
810
|
-
}
|
|
658
|
+
};
|
|
811
659
|
if (this.canceled_) {
|
|
812
660
|
backoffDone(false, new RequestEndStatus(false, null, true));
|
|
813
661
|
}
|
|
@@ -875,7 +723,7 @@ function addAppCheckHeader_(headers, appCheckToken) {
|
|
|
875
723
|
headers['X-Firebase-AppCheck'] = appCheckToken;
|
|
876
724
|
}
|
|
877
725
|
}
|
|
878
|
-
function makeRequest(requestInfo, appId, authToken, appCheckToken,
|
|
726
|
+
function makeRequest(requestInfo, appId, authToken, appCheckToken, requestFactory, firebaseVersion) {
|
|
879
727
|
const queryPart = makeQueryString(requestInfo.urlParams);
|
|
880
728
|
const url = requestInfo.url + queryPart;
|
|
881
729
|
const headers = Object.assign({}, requestInfo.headers);
|
|
@@ -883,7 +731,7 @@ function makeRequest(requestInfo, appId, authToken, appCheckToken, pool, firebas
|
|
|
883
731
|
addAuthHeader_(headers, authToken);
|
|
884
732
|
addVersionHeader_(headers, firebaseVersion);
|
|
885
733
|
addAppCheckHeader_(headers, appCheckToken);
|
|
886
|
-
return new NetworkRequest(url, requestInfo.method, headers, requestInfo.body, requestInfo.successCodes, requestInfo.additionalRetryCodes, requestInfo.handler, requestInfo.errorHandler, requestInfo.timeout, requestInfo.progressCallback,
|
|
734
|
+
return new NetworkRequest(url, requestInfo.method, headers, requestInfo.body, requestInfo.successCodes, requestInfo.additionalRetryCodes, requestInfo.handler, requestInfo.errorHandler, requestInfo.timeout, requestInfo.progressCallback, requestFactory);
|
|
887
735
|
}
|
|
888
736
|
|
|
889
737
|
/**
|
|
@@ -2135,6 +1983,115 @@ function async(f) {
|
|
|
2135
1983
|
};
|
|
2136
1984
|
}
|
|
2137
1985
|
|
|
1986
|
+
/**
|
|
1987
|
+
* @license
|
|
1988
|
+
* Copyright 2017 Google LLC
|
|
1989
|
+
*
|
|
1990
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1991
|
+
* you may not use this file except in compliance with the License.
|
|
1992
|
+
* You may obtain a copy of the License at
|
|
1993
|
+
*
|
|
1994
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1995
|
+
*
|
|
1996
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1997
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1998
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1999
|
+
* See the License for the specific language governing permissions and
|
|
2000
|
+
* limitations under the License.
|
|
2001
|
+
*/
|
|
2002
|
+
/** An override for the text-based Connection. Used in tests. */
|
|
2003
|
+
let connectionFactoryOverride = null;
|
|
2004
|
+
/**
|
|
2005
|
+
* Network layer for browsers. We use this instead of goog.net.XhrIo because
|
|
2006
|
+
* goog.net.XhrIo is hyuuuuge and doesn't work in React Native on Android.
|
|
2007
|
+
*/
|
|
2008
|
+
class XhrConnection {
|
|
2009
|
+
constructor() {
|
|
2010
|
+
this.sent_ = false;
|
|
2011
|
+
this.xhr_ = new XMLHttpRequest();
|
|
2012
|
+
this.errorCode_ = ErrorCode.NO_ERROR;
|
|
2013
|
+
this.sendPromise_ = new Promise(resolve => {
|
|
2014
|
+
this.xhr_.addEventListener('abort', () => {
|
|
2015
|
+
this.errorCode_ = ErrorCode.ABORT;
|
|
2016
|
+
resolve();
|
|
2017
|
+
});
|
|
2018
|
+
this.xhr_.addEventListener('error', () => {
|
|
2019
|
+
this.errorCode_ = ErrorCode.NETWORK_ERROR;
|
|
2020
|
+
resolve();
|
|
2021
|
+
});
|
|
2022
|
+
this.xhr_.addEventListener('load', () => {
|
|
2023
|
+
resolve();
|
|
2024
|
+
});
|
|
2025
|
+
});
|
|
2026
|
+
}
|
|
2027
|
+
send(url, method, body, headers) {
|
|
2028
|
+
if (this.sent_) {
|
|
2029
|
+
throw internalError('cannot .send() more than once');
|
|
2030
|
+
}
|
|
2031
|
+
this.sent_ = true;
|
|
2032
|
+
this.xhr_.open(method, url, true);
|
|
2033
|
+
if (headers !== undefined) {
|
|
2034
|
+
for (const key in headers) {
|
|
2035
|
+
if (headers.hasOwnProperty(key)) {
|
|
2036
|
+
this.xhr_.setRequestHeader(key, headers[key].toString());
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
if (body !== undefined) {
|
|
2041
|
+
this.xhr_.send(body);
|
|
2042
|
+
}
|
|
2043
|
+
else {
|
|
2044
|
+
this.xhr_.send();
|
|
2045
|
+
}
|
|
2046
|
+
return this.sendPromise_;
|
|
2047
|
+
}
|
|
2048
|
+
getErrorCode() {
|
|
2049
|
+
if (!this.sent_) {
|
|
2050
|
+
throw internalError('cannot .getErrorCode() before sending');
|
|
2051
|
+
}
|
|
2052
|
+
return this.errorCode_;
|
|
2053
|
+
}
|
|
2054
|
+
getStatus() {
|
|
2055
|
+
if (!this.sent_) {
|
|
2056
|
+
throw internalError('cannot .getStatus() before sending');
|
|
2057
|
+
}
|
|
2058
|
+
try {
|
|
2059
|
+
return this.xhr_.status;
|
|
2060
|
+
}
|
|
2061
|
+
catch (e) {
|
|
2062
|
+
return -1;
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
getResponseText() {
|
|
2066
|
+
if (!this.sent_) {
|
|
2067
|
+
throw internalError('cannot .getResponseText() before sending');
|
|
2068
|
+
}
|
|
2069
|
+
return this.xhr_.responseText;
|
|
2070
|
+
}
|
|
2071
|
+
/** Aborts the request. */
|
|
2072
|
+
abort() {
|
|
2073
|
+
this.xhr_.abort();
|
|
2074
|
+
}
|
|
2075
|
+
getResponseHeader(header) {
|
|
2076
|
+
return this.xhr_.getResponseHeader(header);
|
|
2077
|
+
}
|
|
2078
|
+
addUploadProgressListener(listener) {
|
|
2079
|
+
if (this.xhr_.upload != null) {
|
|
2080
|
+
this.xhr_.upload.addEventListener('progress', listener);
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
removeUploadProgressListener(listener) {
|
|
2084
|
+
if (this.xhr_.upload != null) {
|
|
2085
|
+
this.xhr_.upload.removeEventListener('progress', listener);
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
function newConnection() {
|
|
2090
|
+
return connectionFactoryOverride
|
|
2091
|
+
? connectionFactoryOverride()
|
|
2092
|
+
: new XhrConnection();
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2138
2095
|
/**
|
|
2139
2096
|
* @license
|
|
2140
2097
|
* Copyright 2017 Google LLC
|
|
@@ -2274,7 +2231,7 @@ class UploadTask {
|
|
|
2274
2231
|
_createResumable() {
|
|
2275
2232
|
this._resolveToken((authToken, appCheckToken) => {
|
|
2276
2233
|
const requestInfo = createResumableUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata);
|
|
2277
|
-
const createRequest = this._ref.storage._makeRequest(requestInfo, authToken, appCheckToken);
|
|
2234
|
+
const createRequest = this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
|
|
2278
2235
|
this._request = createRequest;
|
|
2279
2236
|
createRequest.getPromise().then((url) => {
|
|
2280
2237
|
this._request = undefined;
|
|
@@ -2289,7 +2246,7 @@ class UploadTask {
|
|
|
2289
2246
|
const url = this._uploadUrl;
|
|
2290
2247
|
this._resolveToken((authToken, appCheckToken) => {
|
|
2291
2248
|
const requestInfo = getResumableUploadStatus(this._ref.storage, this._ref._location, url, this._blob);
|
|
2292
|
-
const statusRequest = this._ref.storage._makeRequest(requestInfo, authToken, appCheckToken);
|
|
2249
|
+
const statusRequest = this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
|
|
2293
2250
|
this._request = statusRequest;
|
|
2294
2251
|
statusRequest.getPromise().then(status => {
|
|
2295
2252
|
status = status;
|
|
@@ -2318,7 +2275,7 @@ class UploadTask {
|
|
|
2318
2275
|
this._transition("error" /* ERROR */);
|
|
2319
2276
|
return;
|
|
2320
2277
|
}
|
|
2321
|
-
const uploadRequest = this._ref.storage._makeRequest(requestInfo, authToken, appCheckToken);
|
|
2278
|
+
const uploadRequest = this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
|
|
2322
2279
|
this._request = uploadRequest;
|
|
2323
2280
|
uploadRequest.getPromise().then((newStatus) => {
|
|
2324
2281
|
this._increaseMultiplier();
|
|
@@ -2344,7 +2301,7 @@ class UploadTask {
|
|
|
2344
2301
|
_fetchMetadata() {
|
|
2345
2302
|
this._resolveToken((authToken, appCheckToken) => {
|
|
2346
2303
|
const requestInfo = getMetadata$2(this._ref.storage, this._ref._location, this._mappings);
|
|
2347
|
-
const metadataRequest = this._ref.storage._makeRequest(requestInfo, authToken, appCheckToken);
|
|
2304
|
+
const metadataRequest = this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
|
|
2348
2305
|
this._request = metadataRequest;
|
|
2349
2306
|
metadataRequest.getPromise().then(metadata => {
|
|
2350
2307
|
this._request = undefined;
|
|
@@ -2356,7 +2313,7 @@ class UploadTask {
|
|
|
2356
2313
|
_oneShotUpload() {
|
|
2357
2314
|
this._resolveToken((authToken, appCheckToken) => {
|
|
2358
2315
|
const requestInfo = multipartUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata);
|
|
2359
|
-
const multipartRequest = this._ref.storage._makeRequest(requestInfo, authToken, appCheckToken);
|
|
2316
|
+
const multipartRequest = this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
|
|
2360
2317
|
this._request = multipartRequest;
|
|
2361
2318
|
multipartRequest.getPromise().then(metadata => {
|
|
2362
2319
|
this._request = undefined;
|
|
@@ -2734,8 +2691,7 @@ function uploadBytes$1(ref, data, metadata) {
|
|
|
2734
2691
|
ref._throwIfRoot('uploadBytes');
|
|
2735
2692
|
const requestInfo = multipartUpload(ref.storage, ref._location, getMappings(), new FbsBlob(data, true), metadata);
|
|
2736
2693
|
return ref.storage
|
|
2737
|
-
.makeRequestWithTokens(requestInfo)
|
|
2738
|
-
.then(request => request.getPromise())
|
|
2694
|
+
.makeRequestWithTokens(requestInfo, newConnection)
|
|
2739
2695
|
.then(finalMetadata => {
|
|
2740
2696
|
return {
|
|
2741
2697
|
metadata: finalMetadata,
|
|
@@ -2841,7 +2797,7 @@ async function listAllHelper(ref, accumulator, pageToken) {
|
|
|
2841
2797
|
* contains references to objects in this folder. `nextPageToken`
|
|
2842
2798
|
* can be used to get the rest of the results.
|
|
2843
2799
|
*/
|
|
2844
|
-
|
|
2800
|
+
function list$1(ref, options) {
|
|
2845
2801
|
if (options != null) {
|
|
2846
2802
|
if (typeof options.maxResults === 'number') {
|
|
2847
2803
|
validateNumber('options.maxResults',
|
|
@@ -2852,7 +2808,7 @@ async function list$1(ref, options) {
|
|
|
2852
2808
|
const op = options || {};
|
|
2853
2809
|
const requestInfo = list$2(ref.storage, ref._location,
|
|
2854
2810
|
/*delimiter= */ '/', op.pageToken, op.maxResults);
|
|
2855
|
-
return
|
|
2811
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
|
|
2856
2812
|
}
|
|
2857
2813
|
/**
|
|
2858
2814
|
* A `Promise` that resolves with the metadata for this object. If this
|
|
@@ -2861,10 +2817,10 @@ async function list$1(ref, options) {
|
|
|
2861
2817
|
* @public
|
|
2862
2818
|
* @param ref - StorageReference to get metadata from.
|
|
2863
2819
|
*/
|
|
2864
|
-
|
|
2820
|
+
function getMetadata$1(ref) {
|
|
2865
2821
|
ref._throwIfRoot('getMetadata');
|
|
2866
2822
|
const requestInfo = getMetadata$2(ref.storage, ref._location, getMappings());
|
|
2867
|
-
return
|
|
2823
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
|
|
2868
2824
|
}
|
|
2869
2825
|
/**
|
|
2870
2826
|
* Updates the metadata for this object.
|
|
@@ -2877,10 +2833,10 @@ async function getMetadata$1(ref) {
|
|
|
2877
2833
|
* with the new metadata for this object.
|
|
2878
2834
|
* See `firebaseStorage.Reference.prototype.getMetadata`
|
|
2879
2835
|
*/
|
|
2880
|
-
|
|
2836
|
+
function updateMetadata$1(ref, metadata) {
|
|
2881
2837
|
ref._throwIfRoot('updateMetadata');
|
|
2882
2838
|
const requestInfo = updateMetadata$2(ref.storage, ref._location, metadata, getMappings());
|
|
2883
|
-
return
|
|
2839
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
|
|
2884
2840
|
}
|
|
2885
2841
|
/**
|
|
2886
2842
|
* Returns the download URL for the given Reference.
|
|
@@ -2888,11 +2844,11 @@ async function updateMetadata$1(ref, metadata) {
|
|
|
2888
2844
|
* @returns A `Promise` that resolves with the download
|
|
2889
2845
|
* URL for this object.
|
|
2890
2846
|
*/
|
|
2891
|
-
|
|
2847
|
+
function getDownloadURL$1(ref) {
|
|
2892
2848
|
ref._throwIfRoot('getDownloadURL');
|
|
2893
2849
|
const requestInfo = getDownloadUrl(ref.storage, ref._location, getMappings());
|
|
2894
|
-
return
|
|
2895
|
-
.
|
|
2850
|
+
return ref.storage
|
|
2851
|
+
.makeRequestWithTokens(requestInfo, newConnection)
|
|
2896
2852
|
.then(url => {
|
|
2897
2853
|
if (url === null) {
|
|
2898
2854
|
throw noDownloadURL();
|
|
@@ -2906,10 +2862,10 @@ async function getDownloadURL$1(ref) {
|
|
|
2906
2862
|
* @param ref - StorageReference for object to delete.
|
|
2907
2863
|
* @returns A `Promise` that resolves if the deletion succeeds.
|
|
2908
2864
|
*/
|
|
2909
|
-
|
|
2865
|
+
function deleteObject$1(ref) {
|
|
2910
2866
|
ref._throwIfRoot('deleteObject');
|
|
2911
2867
|
const requestInfo = deleteObject$2(ref.storage, ref._location);
|
|
2912
|
-
return
|
|
2868
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
|
|
2913
2869
|
}
|
|
2914
2870
|
/**
|
|
2915
2871
|
* Returns reference for object obtained by appending `childPath` to `ref`.
|
|
@@ -3030,11 +2986,10 @@ class FirebaseStorageImpl {
|
|
|
3030
2986
|
/**
|
|
3031
2987
|
* @internal
|
|
3032
2988
|
*/
|
|
3033
|
-
|
|
2989
|
+
_url, _firebaseVersion) {
|
|
3034
2990
|
this.app = app;
|
|
3035
2991
|
this._authProvider = _authProvider;
|
|
3036
2992
|
this._appCheckProvider = _appCheckProvider;
|
|
3037
|
-
this._pool = _pool;
|
|
3038
2993
|
this._url = _url;
|
|
3039
2994
|
this._firebaseVersion = _firebaseVersion;
|
|
3040
2995
|
this._bucket = null;
|
|
@@ -3145,9 +3100,9 @@ class FirebaseStorageImpl {
|
|
|
3145
3100
|
* @param requestInfo - HTTP RequestInfo object
|
|
3146
3101
|
* @param authToken - Firebase auth token
|
|
3147
3102
|
*/
|
|
3148
|
-
_makeRequest(requestInfo, authToken, appCheckToken) {
|
|
3103
|
+
_makeRequest(requestInfo, requestFactory, authToken, appCheckToken) {
|
|
3149
3104
|
if (!this._deleted) {
|
|
3150
|
-
const request = makeRequest(requestInfo, this._appId, authToken, appCheckToken,
|
|
3105
|
+
const request = makeRequest(requestInfo, this._appId, authToken, appCheckToken, requestFactory, this._firebaseVersion);
|
|
3151
3106
|
this._requests.add(request);
|
|
3152
3107
|
// Request removes itself from set when complete.
|
|
3153
3108
|
request.getPromise().then(() => this._requests.delete(request), () => this._requests.delete(request));
|
|
@@ -3157,17 +3112,17 @@ class FirebaseStorageImpl {
|
|
|
3157
3112
|
return new FailRequest(appDeleted());
|
|
3158
3113
|
}
|
|
3159
3114
|
}
|
|
3160
|
-
async makeRequestWithTokens(requestInfo) {
|
|
3115
|
+
async makeRequestWithTokens(requestInfo, requestFactory) {
|
|
3161
3116
|
const [authToken, appCheckToken] = await Promise.all([
|
|
3162
3117
|
this._getAuthToken(),
|
|
3163
3118
|
this._getAppCheckToken()
|
|
3164
3119
|
]);
|
|
3165
|
-
return this._makeRequest(requestInfo, authToken, appCheckToken);
|
|
3120
|
+
return this._makeRequest(requestInfo, requestFactory, authToken, appCheckToken).getPromise();
|
|
3166
3121
|
}
|
|
3167
3122
|
}
|
|
3168
3123
|
|
|
3169
3124
|
const name = "@firebase/storage";
|
|
3170
|
-
const version = "0.8.
|
|
3125
|
+
const version = "0.8.4-2021927221742";
|
|
3171
3126
|
|
|
3172
3127
|
/**
|
|
3173
3128
|
* @license
|
|
@@ -3389,11 +3344,14 @@ function factory(container, { instanceIdentifier: url }) {
|
|
|
3389
3344
|
const app = container.getProvider('app').getImmediate();
|
|
3390
3345
|
const authProvider = container.getProvider('auth-internal');
|
|
3391
3346
|
const appCheckProvider = container.getProvider('app-check-internal');
|
|
3392
|
-
return new FirebaseStorageImpl(app, authProvider, appCheckProvider,
|
|
3347
|
+
return new FirebaseStorageImpl(app, authProvider, appCheckProvider, url, SDK_VERSION);
|
|
3393
3348
|
}
|
|
3394
3349
|
function registerStorage() {
|
|
3395
3350
|
_registerComponent(new Component(STORAGE_TYPE, factory, "PUBLIC" /* PUBLIC */).setMultipleInstances(true));
|
|
3396
|
-
|
|
3351
|
+
//RUNTIME_ENV will be replaced during the compilation to "node" for nodejs and an empty string for browser
|
|
3352
|
+
registerVersion(name, version, '');
|
|
3353
|
+
// BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
|
|
3354
|
+
registerVersion(name, version, 'esm2017');
|
|
3397
3355
|
}
|
|
3398
3356
|
registerStorage();
|
|
3399
3357
|
|