@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.esm5.js
CHANGED
|
@@ -3,32 +3,6 @@ import { __extends, __spreadArray, __awaiter, __generator, __assign } from 'tsli
|
|
|
3
3
|
import { FirebaseError, createMockUserToken, getModularInstance } from '@firebase/util';
|
|
4
4
|
import { Component } from '@firebase/component';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* @license
|
|
8
|
-
* Copyright 2017 Google LLC
|
|
9
|
-
*
|
|
10
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
-
* you may not use this file except in compliance with the License.
|
|
12
|
-
* You may obtain a copy of the License at
|
|
13
|
-
*
|
|
14
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
-
*
|
|
16
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
-
* See the License for the specific language governing permissions and
|
|
20
|
-
* limitations under the License.
|
|
21
|
-
*/
|
|
22
|
-
/**
|
|
23
|
-
* Error codes for requests made by the the XhrIo wrapper.
|
|
24
|
-
*/
|
|
25
|
-
var ErrorCode;
|
|
26
|
-
(function (ErrorCode) {
|
|
27
|
-
ErrorCode[ErrorCode["NO_ERROR"] = 0] = "NO_ERROR";
|
|
28
|
-
ErrorCode[ErrorCode["NETWORK_ERROR"] = 1] = "NETWORK_ERROR";
|
|
29
|
-
ErrorCode[ErrorCode["ABORT"] = 2] = "ABORT";
|
|
30
|
-
})(ErrorCode || (ErrorCode = {}));
|
|
31
|
-
|
|
32
6
|
/**
|
|
33
7
|
* @license
|
|
34
8
|
* Copyright 2017 Google LLC
|
|
@@ -208,165 +182,6 @@ function internalError(message) {
|
|
|
208
182
|
throw new StorageError("internal-error" /* INTERNAL_ERROR */, 'Internal error: ' + message);
|
|
209
183
|
}
|
|
210
184
|
|
|
211
|
-
/**
|
|
212
|
-
* @license
|
|
213
|
-
* Copyright 2017 Google LLC
|
|
214
|
-
*
|
|
215
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
216
|
-
* you may not use this file except in compliance with the License.
|
|
217
|
-
* You may obtain a copy of the License at
|
|
218
|
-
*
|
|
219
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
220
|
-
*
|
|
221
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
222
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
223
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
224
|
-
* See the License for the specific language governing permissions and
|
|
225
|
-
* limitations under the License.
|
|
226
|
-
*/
|
|
227
|
-
/**
|
|
228
|
-
* Network layer for browsers. We use this instead of goog.net.XhrIo because
|
|
229
|
-
* goog.net.XhrIo is hyuuuuge and doesn't work in React Native on Android.
|
|
230
|
-
*/
|
|
231
|
-
var XhrConnection = /** @class */ (function () {
|
|
232
|
-
function XhrConnection() {
|
|
233
|
-
var _this = this;
|
|
234
|
-
this.sent_ = false;
|
|
235
|
-
this.xhr_ = new XMLHttpRequest();
|
|
236
|
-
this.errorCode_ = ErrorCode.NO_ERROR;
|
|
237
|
-
this.sendPromise_ = new Promise(function (resolve) {
|
|
238
|
-
_this.xhr_.addEventListener('abort', function () {
|
|
239
|
-
_this.errorCode_ = ErrorCode.ABORT;
|
|
240
|
-
resolve();
|
|
241
|
-
});
|
|
242
|
-
_this.xhr_.addEventListener('error', function () {
|
|
243
|
-
_this.errorCode_ = ErrorCode.NETWORK_ERROR;
|
|
244
|
-
resolve();
|
|
245
|
-
});
|
|
246
|
-
_this.xhr_.addEventListener('load', function () {
|
|
247
|
-
resolve();
|
|
248
|
-
});
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* @override
|
|
253
|
-
*/
|
|
254
|
-
XhrConnection.prototype.send = function (url, method, body, headers) {
|
|
255
|
-
if (this.sent_) {
|
|
256
|
-
throw internalError('cannot .send() more than once');
|
|
257
|
-
}
|
|
258
|
-
this.sent_ = true;
|
|
259
|
-
this.xhr_.open(method, url, true);
|
|
260
|
-
if (headers !== undefined) {
|
|
261
|
-
for (var key in headers) {
|
|
262
|
-
if (headers.hasOwnProperty(key)) {
|
|
263
|
-
this.xhr_.setRequestHeader(key, headers[key].toString());
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
if (body !== undefined) {
|
|
268
|
-
this.xhr_.send(body);
|
|
269
|
-
}
|
|
270
|
-
else {
|
|
271
|
-
this.xhr_.send();
|
|
272
|
-
}
|
|
273
|
-
return this.sendPromise_;
|
|
274
|
-
};
|
|
275
|
-
/**
|
|
276
|
-
* @override
|
|
277
|
-
*/
|
|
278
|
-
XhrConnection.prototype.getErrorCode = function () {
|
|
279
|
-
if (!this.sent_) {
|
|
280
|
-
throw internalError('cannot .getErrorCode() before sending');
|
|
281
|
-
}
|
|
282
|
-
return this.errorCode_;
|
|
283
|
-
};
|
|
284
|
-
/**
|
|
285
|
-
* @override
|
|
286
|
-
*/
|
|
287
|
-
XhrConnection.prototype.getStatus = function () {
|
|
288
|
-
if (!this.sent_) {
|
|
289
|
-
throw internalError('cannot .getStatus() before sending');
|
|
290
|
-
}
|
|
291
|
-
try {
|
|
292
|
-
return this.xhr_.status;
|
|
293
|
-
}
|
|
294
|
-
catch (e) {
|
|
295
|
-
return -1;
|
|
296
|
-
}
|
|
297
|
-
};
|
|
298
|
-
/**
|
|
299
|
-
* @override
|
|
300
|
-
*/
|
|
301
|
-
XhrConnection.prototype.getResponseText = function () {
|
|
302
|
-
if (!this.sent_) {
|
|
303
|
-
throw internalError('cannot .getResponseText() before sending');
|
|
304
|
-
}
|
|
305
|
-
return this.xhr_.responseText;
|
|
306
|
-
};
|
|
307
|
-
/**
|
|
308
|
-
* Aborts the request.
|
|
309
|
-
* @override
|
|
310
|
-
*/
|
|
311
|
-
XhrConnection.prototype.abort = function () {
|
|
312
|
-
this.xhr_.abort();
|
|
313
|
-
};
|
|
314
|
-
/**
|
|
315
|
-
* @override
|
|
316
|
-
*/
|
|
317
|
-
XhrConnection.prototype.getResponseHeader = function (header) {
|
|
318
|
-
return this.xhr_.getResponseHeader(header);
|
|
319
|
-
};
|
|
320
|
-
/**
|
|
321
|
-
* @override
|
|
322
|
-
*/
|
|
323
|
-
XhrConnection.prototype.addUploadProgressListener = function (listener) {
|
|
324
|
-
if (this.xhr_.upload != null) {
|
|
325
|
-
this.xhr_.upload.addEventListener('progress', listener);
|
|
326
|
-
}
|
|
327
|
-
};
|
|
328
|
-
/**
|
|
329
|
-
* @override
|
|
330
|
-
*/
|
|
331
|
-
XhrConnection.prototype.removeUploadProgressListener = function (listener) {
|
|
332
|
-
if (this.xhr_.upload != null) {
|
|
333
|
-
this.xhr_.upload.removeEventListener('progress', listener);
|
|
334
|
-
}
|
|
335
|
-
};
|
|
336
|
-
return XhrConnection;
|
|
337
|
-
}());
|
|
338
|
-
function newConnection() {
|
|
339
|
-
return new XhrConnection();
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* @license
|
|
344
|
-
* Copyright 2017 Google LLC
|
|
345
|
-
*
|
|
346
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
347
|
-
* you may not use this file except in compliance with the License.
|
|
348
|
-
* You may obtain a copy of the License at
|
|
349
|
-
*
|
|
350
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
351
|
-
*
|
|
352
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
353
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
354
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
355
|
-
* See the License for the specific language governing permissions and
|
|
356
|
-
* limitations under the License.
|
|
357
|
-
*/
|
|
358
|
-
/**
|
|
359
|
-
* Factory-like class for creating XhrIo instances.
|
|
360
|
-
*/
|
|
361
|
-
var ConnectionPool = /** @class */ (function () {
|
|
362
|
-
function ConnectionPool() {
|
|
363
|
-
}
|
|
364
|
-
ConnectionPool.prototype.createConnection = function () {
|
|
365
|
-
return newConnection();
|
|
366
|
-
};
|
|
367
|
-
return ConnectionPool;
|
|
368
|
-
}());
|
|
369
|
-
|
|
370
185
|
/**
|
|
371
186
|
* @license
|
|
372
187
|
* Copyright 2017 Google LLC
|
|
@@ -715,6 +530,32 @@ function makeQueryString(params) {
|
|
|
715
530
|
return queryPart;
|
|
716
531
|
}
|
|
717
532
|
|
|
533
|
+
/**
|
|
534
|
+
* @license
|
|
535
|
+
* Copyright 2017 Google LLC
|
|
536
|
+
*
|
|
537
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
538
|
+
* you may not use this file except in compliance with the License.
|
|
539
|
+
* You may obtain a copy of the License at
|
|
540
|
+
*
|
|
541
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
542
|
+
*
|
|
543
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
544
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
545
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
546
|
+
* See the License for the specific language governing permissions and
|
|
547
|
+
* limitations under the License.
|
|
548
|
+
*/
|
|
549
|
+
/**
|
|
550
|
+
* Error codes for requests made by the the XhrIo wrapper.
|
|
551
|
+
*/
|
|
552
|
+
var ErrorCode;
|
|
553
|
+
(function (ErrorCode) {
|
|
554
|
+
ErrorCode[ErrorCode["NO_ERROR"] = 0] = "NO_ERROR";
|
|
555
|
+
ErrorCode[ErrorCode["NETWORK_ERROR"] = 1] = "NETWORK_ERROR";
|
|
556
|
+
ErrorCode[ErrorCode["ABORT"] = 2] = "ABORT";
|
|
557
|
+
})(ErrorCode || (ErrorCode = {}));
|
|
558
|
+
|
|
718
559
|
/**
|
|
719
560
|
* @license
|
|
720
561
|
* Copyright 2017 Google LLC
|
|
@@ -732,23 +573,23 @@ function makeQueryString(params) {
|
|
|
732
573
|
* limitations under the License.
|
|
733
574
|
*/
|
|
734
575
|
var NetworkRequest = /** @class */ (function () {
|
|
735
|
-
function NetworkRequest(
|
|
576
|
+
function NetworkRequest(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, connectionFactory_) {
|
|
736
577
|
var _this = this;
|
|
578
|
+
this.url_ = url_;
|
|
579
|
+
this.method_ = method_;
|
|
580
|
+
this.headers_ = headers_;
|
|
581
|
+
this.body_ = body_;
|
|
582
|
+
this.successCodes_ = successCodes_;
|
|
583
|
+
this.additionalRetryCodes_ = additionalRetryCodes_;
|
|
584
|
+
this.callback_ = callback_;
|
|
585
|
+
this.errorCallback_ = errorCallback_;
|
|
586
|
+
this.timeout_ = timeout_;
|
|
587
|
+
this.progressCallback_ = progressCallback_;
|
|
588
|
+
this.connectionFactory_ = connectionFactory_;
|
|
737
589
|
this.pendingConnection_ = null;
|
|
738
590
|
this.backoffId_ = null;
|
|
739
591
|
this.canceled_ = false;
|
|
740
592
|
this.appDelete_ = false;
|
|
741
|
-
this.url_ = url;
|
|
742
|
-
this.method_ = method;
|
|
743
|
-
this.headers_ = headers;
|
|
744
|
-
this.body_ = body;
|
|
745
|
-
this.successCodes_ = successCodes.slice();
|
|
746
|
-
this.additionalRetryCodes_ = additionalRetryCodes.slice();
|
|
747
|
-
this.callback_ = callback;
|
|
748
|
-
this.errorCallback_ = errorCallback;
|
|
749
|
-
this.progressCallback_ = progressCallback;
|
|
750
|
-
this.timeout_ = timeout;
|
|
751
|
-
this.pool_ = pool;
|
|
752
593
|
this.promise_ = new Promise(function (resolve, reject) {
|
|
753
594
|
_this.resolve_ = resolve;
|
|
754
595
|
_this.reject_ = reject;
|
|
@@ -759,54 +600,57 @@ var NetworkRequest = /** @class */ (function () {
|
|
|
759
600
|
* Actually starts the retry loop.
|
|
760
601
|
*/
|
|
761
602
|
NetworkRequest.prototype.start_ = function () {
|
|
762
|
-
var
|
|
763
|
-
function
|
|
603
|
+
var _this = this;
|
|
604
|
+
var doTheRequest = function (backoffCallback, canceled) {
|
|
764
605
|
if (canceled) {
|
|
765
606
|
backoffCallback(false, new RequestEndStatus(false, null, true));
|
|
766
607
|
return;
|
|
767
608
|
}
|
|
768
|
-
var connection =
|
|
769
|
-
|
|
770
|
-
function
|
|
609
|
+
var connection = _this.connectionFactory_();
|
|
610
|
+
_this.pendingConnection_ = connection;
|
|
611
|
+
var progressListener = function (progressEvent) {
|
|
771
612
|
var loaded = progressEvent.loaded;
|
|
772
|
-
var total = progressEvent.lengthComputable
|
|
773
|
-
|
|
774
|
-
|
|
613
|
+
var total = progressEvent.lengthComputable
|
|
614
|
+
? progressEvent.total
|
|
615
|
+
: -1;
|
|
616
|
+
if (_this.progressCallback_ !== null) {
|
|
617
|
+
_this.progressCallback_(loaded, total);
|
|
775
618
|
}
|
|
776
|
-
}
|
|
777
|
-
if (
|
|
619
|
+
};
|
|
620
|
+
if (_this.progressCallback_ !== null) {
|
|
778
621
|
connection.addUploadProgressListener(progressListener);
|
|
779
622
|
}
|
|
623
|
+
// connection.send() never rejects, so we don't need to have a error handler or use catch on the returned promise.
|
|
780
624
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
781
625
|
connection
|
|
782
|
-
.send(
|
|
626
|
+
.send(_this.url_, _this.method_, _this.body_, _this.headers_)
|
|
783
627
|
.then(function () {
|
|
784
|
-
if (
|
|
628
|
+
if (_this.progressCallback_ !== null) {
|
|
785
629
|
connection.removeUploadProgressListener(progressListener);
|
|
786
630
|
}
|
|
787
|
-
|
|
631
|
+
_this.pendingConnection_ = null;
|
|
788
632
|
var hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR;
|
|
789
633
|
var status = connection.getStatus();
|
|
790
|
-
if (!hitServer ||
|
|
634
|
+
if (!hitServer || _this.isRetryStatusCode_(status)) {
|
|
791
635
|
var wasCanceled = connection.getErrorCode() === ErrorCode.ABORT;
|
|
792
636
|
backoffCallback(false, new RequestEndStatus(false, null, wasCanceled));
|
|
793
637
|
return;
|
|
794
638
|
}
|
|
795
|
-
var successCode =
|
|
639
|
+
var successCode = _this.successCodes_.indexOf(status) !== -1;
|
|
796
640
|
backoffCallback(true, new RequestEndStatus(successCode, connection));
|
|
797
641
|
});
|
|
798
|
-
}
|
|
642
|
+
};
|
|
799
643
|
/**
|
|
800
644
|
* @param requestWentThrough - True if the request eventually went
|
|
801
645
|
* through, false if it hit the retry limit or was canceled.
|
|
802
646
|
*/
|
|
803
|
-
function
|
|
804
|
-
var resolve =
|
|
805
|
-
var reject =
|
|
647
|
+
var backoffDone = function (requestWentThrough, status) {
|
|
648
|
+
var resolve = _this.resolve_;
|
|
649
|
+
var reject = _this.reject_;
|
|
806
650
|
var connection = status.connection;
|
|
807
651
|
if (status.wasSuccessCode) {
|
|
808
652
|
try {
|
|
809
|
-
var result =
|
|
653
|
+
var result = _this.callback_(connection, connection.getResponseText());
|
|
810
654
|
if (isJustDef(result)) {
|
|
811
655
|
resolve(result);
|
|
812
656
|
}
|
|
@@ -822,8 +666,8 @@ var NetworkRequest = /** @class */ (function () {
|
|
|
822
666
|
if (connection !== null) {
|
|
823
667
|
var err = unknown();
|
|
824
668
|
err.serverResponse = connection.getResponseText();
|
|
825
|
-
if (
|
|
826
|
-
reject(
|
|
669
|
+
if (_this.errorCallback_) {
|
|
670
|
+
reject(_this.errorCallback_(connection, err));
|
|
827
671
|
}
|
|
828
672
|
else {
|
|
829
673
|
reject(err);
|
|
@@ -831,7 +675,7 @@ var NetworkRequest = /** @class */ (function () {
|
|
|
831
675
|
}
|
|
832
676
|
else {
|
|
833
677
|
if (status.canceled) {
|
|
834
|
-
var err =
|
|
678
|
+
var err = _this.appDelete_ ? appDeleted() : canceled();
|
|
835
679
|
reject(err);
|
|
836
680
|
}
|
|
837
681
|
else {
|
|
@@ -840,7 +684,7 @@ var NetworkRequest = /** @class */ (function () {
|
|
|
840
684
|
}
|
|
841
685
|
}
|
|
842
686
|
}
|
|
843
|
-
}
|
|
687
|
+
};
|
|
844
688
|
if (this.canceled_) {
|
|
845
689
|
backoffDone(false, new RequestEndStatus(false, null, true));
|
|
846
690
|
}
|
|
@@ -910,7 +754,7 @@ function addAppCheckHeader_(headers, appCheckToken) {
|
|
|
910
754
|
headers['X-Firebase-AppCheck'] = appCheckToken;
|
|
911
755
|
}
|
|
912
756
|
}
|
|
913
|
-
function makeRequest(requestInfo, appId, authToken, appCheckToken,
|
|
757
|
+
function makeRequest(requestInfo, appId, authToken, appCheckToken, requestFactory, firebaseVersion) {
|
|
914
758
|
var queryPart = makeQueryString(requestInfo.urlParams);
|
|
915
759
|
var url = requestInfo.url + queryPart;
|
|
916
760
|
var headers = Object.assign({}, requestInfo.headers);
|
|
@@ -918,7 +762,7 @@ function makeRequest(requestInfo, appId, authToken, appCheckToken, pool, firebas
|
|
|
918
762
|
addAuthHeader_(headers, authToken);
|
|
919
763
|
addVersionHeader_(headers, firebaseVersion);
|
|
920
764
|
addAppCheckHeader_(headers, appCheckToken);
|
|
921
|
-
return new NetworkRequest(url, requestInfo.method, headers, requestInfo.body, requestInfo.successCodes, requestInfo.additionalRetryCodes, requestInfo.handler, requestInfo.errorHandler, requestInfo.timeout, requestInfo.progressCallback,
|
|
765
|
+
return new NetworkRequest(url, requestInfo.method, headers, requestInfo.body, requestInfo.successCodes, requestInfo.additionalRetryCodes, requestInfo.handler, requestInfo.errorHandler, requestInfo.timeout, requestInfo.progressCallback, requestFactory);
|
|
922
766
|
}
|
|
923
767
|
|
|
924
768
|
/**
|
|
@@ -2191,6 +2035,117 @@ function async(f) {
|
|
|
2191
2035
|
};
|
|
2192
2036
|
}
|
|
2193
2037
|
|
|
2038
|
+
/**
|
|
2039
|
+
* @license
|
|
2040
|
+
* Copyright 2017 Google LLC
|
|
2041
|
+
*
|
|
2042
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2043
|
+
* you may not use this file except in compliance with the License.
|
|
2044
|
+
* You may obtain a copy of the License at
|
|
2045
|
+
*
|
|
2046
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2047
|
+
*
|
|
2048
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2049
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2050
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2051
|
+
* See the License for the specific language governing permissions and
|
|
2052
|
+
* limitations under the License.
|
|
2053
|
+
*/
|
|
2054
|
+
/** An override for the text-based Connection. Used in tests. */
|
|
2055
|
+
var connectionFactoryOverride = null;
|
|
2056
|
+
/**
|
|
2057
|
+
* Network layer for browsers. We use this instead of goog.net.XhrIo because
|
|
2058
|
+
* goog.net.XhrIo is hyuuuuge and doesn't work in React Native on Android.
|
|
2059
|
+
*/
|
|
2060
|
+
var XhrConnection = /** @class */ (function () {
|
|
2061
|
+
function XhrConnection() {
|
|
2062
|
+
var _this = this;
|
|
2063
|
+
this.sent_ = false;
|
|
2064
|
+
this.xhr_ = new XMLHttpRequest();
|
|
2065
|
+
this.errorCode_ = ErrorCode.NO_ERROR;
|
|
2066
|
+
this.sendPromise_ = new Promise(function (resolve) {
|
|
2067
|
+
_this.xhr_.addEventListener('abort', function () {
|
|
2068
|
+
_this.errorCode_ = ErrorCode.ABORT;
|
|
2069
|
+
resolve();
|
|
2070
|
+
});
|
|
2071
|
+
_this.xhr_.addEventListener('error', function () {
|
|
2072
|
+
_this.errorCode_ = ErrorCode.NETWORK_ERROR;
|
|
2073
|
+
resolve();
|
|
2074
|
+
});
|
|
2075
|
+
_this.xhr_.addEventListener('load', function () {
|
|
2076
|
+
resolve();
|
|
2077
|
+
});
|
|
2078
|
+
});
|
|
2079
|
+
}
|
|
2080
|
+
XhrConnection.prototype.send = function (url, method, body, headers) {
|
|
2081
|
+
if (this.sent_) {
|
|
2082
|
+
throw internalError('cannot .send() more than once');
|
|
2083
|
+
}
|
|
2084
|
+
this.sent_ = true;
|
|
2085
|
+
this.xhr_.open(method, url, true);
|
|
2086
|
+
if (headers !== undefined) {
|
|
2087
|
+
for (var key in headers) {
|
|
2088
|
+
if (headers.hasOwnProperty(key)) {
|
|
2089
|
+
this.xhr_.setRequestHeader(key, headers[key].toString());
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
if (body !== undefined) {
|
|
2094
|
+
this.xhr_.send(body);
|
|
2095
|
+
}
|
|
2096
|
+
else {
|
|
2097
|
+
this.xhr_.send();
|
|
2098
|
+
}
|
|
2099
|
+
return this.sendPromise_;
|
|
2100
|
+
};
|
|
2101
|
+
XhrConnection.prototype.getErrorCode = function () {
|
|
2102
|
+
if (!this.sent_) {
|
|
2103
|
+
throw internalError('cannot .getErrorCode() before sending');
|
|
2104
|
+
}
|
|
2105
|
+
return this.errorCode_;
|
|
2106
|
+
};
|
|
2107
|
+
XhrConnection.prototype.getStatus = function () {
|
|
2108
|
+
if (!this.sent_) {
|
|
2109
|
+
throw internalError('cannot .getStatus() before sending');
|
|
2110
|
+
}
|
|
2111
|
+
try {
|
|
2112
|
+
return this.xhr_.status;
|
|
2113
|
+
}
|
|
2114
|
+
catch (e) {
|
|
2115
|
+
return -1;
|
|
2116
|
+
}
|
|
2117
|
+
};
|
|
2118
|
+
XhrConnection.prototype.getResponseText = function () {
|
|
2119
|
+
if (!this.sent_) {
|
|
2120
|
+
throw internalError('cannot .getResponseText() before sending');
|
|
2121
|
+
}
|
|
2122
|
+
return this.xhr_.responseText;
|
|
2123
|
+
};
|
|
2124
|
+
/** Aborts the request. */
|
|
2125
|
+
XhrConnection.prototype.abort = function () {
|
|
2126
|
+
this.xhr_.abort();
|
|
2127
|
+
};
|
|
2128
|
+
XhrConnection.prototype.getResponseHeader = function (header) {
|
|
2129
|
+
return this.xhr_.getResponseHeader(header);
|
|
2130
|
+
};
|
|
2131
|
+
XhrConnection.prototype.addUploadProgressListener = function (listener) {
|
|
2132
|
+
if (this.xhr_.upload != null) {
|
|
2133
|
+
this.xhr_.upload.addEventListener('progress', listener);
|
|
2134
|
+
}
|
|
2135
|
+
};
|
|
2136
|
+
XhrConnection.prototype.removeUploadProgressListener = function (listener) {
|
|
2137
|
+
if (this.xhr_.upload != null) {
|
|
2138
|
+
this.xhr_.upload.removeEventListener('progress', listener);
|
|
2139
|
+
}
|
|
2140
|
+
};
|
|
2141
|
+
return XhrConnection;
|
|
2142
|
+
}());
|
|
2143
|
+
function newConnection() {
|
|
2144
|
+
return connectionFactoryOverride
|
|
2145
|
+
? connectionFactoryOverride()
|
|
2146
|
+
: new XhrConnection();
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2194
2149
|
/**
|
|
2195
2150
|
* @license
|
|
2196
2151
|
* Copyright 2017 Google LLC
|
|
@@ -2336,7 +2291,7 @@ var UploadTask = /** @class */ (function () {
|
|
|
2336
2291
|
var _this = this;
|
|
2337
2292
|
this._resolveToken(function (authToken, appCheckToken) {
|
|
2338
2293
|
var requestInfo = createResumableUpload(_this._ref.storage, _this._ref._location, _this._mappings, _this._blob, _this._metadata);
|
|
2339
|
-
var createRequest = _this._ref.storage._makeRequest(requestInfo, authToken, appCheckToken);
|
|
2294
|
+
var createRequest = _this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
|
|
2340
2295
|
_this._request = createRequest;
|
|
2341
2296
|
createRequest.getPromise().then(function (url) {
|
|
2342
2297
|
_this._request = undefined;
|
|
@@ -2352,7 +2307,7 @@ var UploadTask = /** @class */ (function () {
|
|
|
2352
2307
|
var url = this._uploadUrl;
|
|
2353
2308
|
this._resolveToken(function (authToken, appCheckToken) {
|
|
2354
2309
|
var requestInfo = getResumableUploadStatus(_this._ref.storage, _this._ref._location, url, _this._blob);
|
|
2355
|
-
var statusRequest = _this._ref.storage._makeRequest(requestInfo, authToken, appCheckToken);
|
|
2310
|
+
var statusRequest = _this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
|
|
2356
2311
|
_this._request = statusRequest;
|
|
2357
2312
|
statusRequest.getPromise().then(function (status) {
|
|
2358
2313
|
status = status;
|
|
@@ -2382,7 +2337,7 @@ var UploadTask = /** @class */ (function () {
|
|
|
2382
2337
|
_this._transition("error" /* ERROR */);
|
|
2383
2338
|
return;
|
|
2384
2339
|
}
|
|
2385
|
-
var uploadRequest = _this._ref.storage._makeRequest(requestInfo, authToken, appCheckToken);
|
|
2340
|
+
var uploadRequest = _this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
|
|
2386
2341
|
_this._request = uploadRequest;
|
|
2387
2342
|
uploadRequest.getPromise().then(function (newStatus) {
|
|
2388
2343
|
_this._increaseMultiplier();
|
|
@@ -2409,7 +2364,7 @@ var UploadTask = /** @class */ (function () {
|
|
|
2409
2364
|
var _this = this;
|
|
2410
2365
|
this._resolveToken(function (authToken, appCheckToken) {
|
|
2411
2366
|
var requestInfo = getMetadata$2(_this._ref.storage, _this._ref._location, _this._mappings);
|
|
2412
|
-
var metadataRequest = _this._ref.storage._makeRequest(requestInfo, authToken, appCheckToken);
|
|
2367
|
+
var metadataRequest = _this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
|
|
2413
2368
|
_this._request = metadataRequest;
|
|
2414
2369
|
metadataRequest.getPromise().then(function (metadata) {
|
|
2415
2370
|
_this._request = undefined;
|
|
@@ -2422,7 +2377,7 @@ var UploadTask = /** @class */ (function () {
|
|
|
2422
2377
|
var _this = this;
|
|
2423
2378
|
this._resolveToken(function (authToken, appCheckToken) {
|
|
2424
2379
|
var requestInfo = multipartUpload(_this._ref.storage, _this._ref._location, _this._mappings, _this._blob, _this._metadata);
|
|
2425
|
-
var multipartRequest = _this._ref.storage._makeRequest(requestInfo, authToken, appCheckToken);
|
|
2380
|
+
var multipartRequest = _this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
|
|
2426
2381
|
_this._request = multipartRequest;
|
|
2427
2382
|
multipartRequest.getPromise().then(function (metadata) {
|
|
2428
2383
|
_this._request = undefined;
|
|
@@ -2832,8 +2787,7 @@ function uploadBytes$1(ref, data, metadata) {
|
|
|
2832
2787
|
ref._throwIfRoot('uploadBytes');
|
|
2833
2788
|
var requestInfo = multipartUpload(ref.storage, ref._location, getMappings(), new FbsBlob(data, true), metadata);
|
|
2834
2789
|
return ref.storage
|
|
2835
|
-
.makeRequestWithTokens(requestInfo)
|
|
2836
|
-
.then(function (request) { return request.getPromise(); })
|
|
2790
|
+
.makeRequestWithTokens(requestInfo, newConnection)
|
|
2837
2791
|
.then(function (finalMetadata) {
|
|
2838
2792
|
return {
|
|
2839
2793
|
metadata: finalMetadata,
|
|
@@ -2955,26 +2909,17 @@ function listAllHelper(ref, accumulator, pageToken) {
|
|
|
2955
2909
|
* can be used to get the rest of the results.
|
|
2956
2910
|
*/
|
|
2957
2911
|
function list$1(ref, options) {
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
}
|
|
2970
|
-
op = options || {};
|
|
2971
|
-
requestInfo = list$2(ref.storage, ref._location,
|
|
2972
|
-
/*delimiter= */ '/', op.pageToken, op.maxResults);
|
|
2973
|
-
return [4 /*yield*/, ref.storage.makeRequestWithTokens(requestInfo)];
|
|
2974
|
-
case 1: return [2 /*return*/, (_a.sent()).getPromise()];
|
|
2975
|
-
}
|
|
2976
|
-
});
|
|
2977
|
-
});
|
|
2912
|
+
if (options != null) {
|
|
2913
|
+
if (typeof options.maxResults === 'number') {
|
|
2914
|
+
validateNumber('options.maxResults',
|
|
2915
|
+
/* minValue= */ 1,
|
|
2916
|
+
/* maxValue= */ 1000, options.maxResults);
|
|
2917
|
+
}
|
|
2918
|
+
}
|
|
2919
|
+
var op = options || {};
|
|
2920
|
+
var requestInfo = list$2(ref.storage, ref._location,
|
|
2921
|
+
/*delimiter= */ '/', op.pageToken, op.maxResults);
|
|
2922
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
|
|
2978
2923
|
}
|
|
2979
2924
|
/**
|
|
2980
2925
|
* A `Promise` that resolves with the metadata for this object. If this
|
|
@@ -2984,18 +2929,9 @@ function list$1(ref, options) {
|
|
|
2984
2929
|
* @param ref - StorageReference to get metadata from.
|
|
2985
2930
|
*/
|
|
2986
2931
|
function getMetadata$1(ref) {
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
switch (_a.label) {
|
|
2991
|
-
case 0:
|
|
2992
|
-
ref._throwIfRoot('getMetadata');
|
|
2993
|
-
requestInfo = getMetadata$2(ref.storage, ref._location, getMappings());
|
|
2994
|
-
return [4 /*yield*/, ref.storage.makeRequestWithTokens(requestInfo)];
|
|
2995
|
-
case 1: return [2 /*return*/, (_a.sent()).getPromise()];
|
|
2996
|
-
}
|
|
2997
|
-
});
|
|
2998
|
-
});
|
|
2932
|
+
ref._throwIfRoot('getMetadata');
|
|
2933
|
+
var requestInfo = getMetadata$2(ref.storage, ref._location, getMappings());
|
|
2934
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
|
|
2999
2935
|
}
|
|
3000
2936
|
/**
|
|
3001
2937
|
* Updates the metadata for this object.
|
|
@@ -3009,18 +2945,9 @@ function getMetadata$1(ref) {
|
|
|
3009
2945
|
* See `firebaseStorage.Reference.prototype.getMetadata`
|
|
3010
2946
|
*/
|
|
3011
2947
|
function updateMetadata$1(ref, metadata) {
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
switch (_a.label) {
|
|
3016
|
-
case 0:
|
|
3017
|
-
ref._throwIfRoot('updateMetadata');
|
|
3018
|
-
requestInfo = updateMetadata$2(ref.storage, ref._location, metadata, getMappings());
|
|
3019
|
-
return [4 /*yield*/, ref.storage.makeRequestWithTokens(requestInfo)];
|
|
3020
|
-
case 1: return [2 /*return*/, (_a.sent()).getPromise()];
|
|
3021
|
-
}
|
|
3022
|
-
});
|
|
3023
|
-
});
|
|
2948
|
+
ref._throwIfRoot('updateMetadata');
|
|
2949
|
+
var requestInfo = updateMetadata$2(ref.storage, ref._location, metadata, getMappings());
|
|
2950
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
|
|
3024
2951
|
}
|
|
3025
2952
|
/**
|
|
3026
2953
|
* Returns the download URL for the given Reference.
|
|
@@ -3029,24 +2956,15 @@ function updateMetadata$1(ref, metadata) {
|
|
|
3029
2956
|
* URL for this object.
|
|
3030
2957
|
*/
|
|
3031
2958
|
function getDownloadURL$1(ref) {
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
.getPromise()
|
|
3042
|
-
.then(function (url) {
|
|
3043
|
-
if (url === null) {
|
|
3044
|
-
throw noDownloadURL();
|
|
3045
|
-
}
|
|
3046
|
-
return url;
|
|
3047
|
-
})];
|
|
3048
|
-
}
|
|
3049
|
-
});
|
|
2959
|
+
ref._throwIfRoot('getDownloadURL');
|
|
2960
|
+
var requestInfo = getDownloadUrl(ref.storage, ref._location, getMappings());
|
|
2961
|
+
return ref.storage
|
|
2962
|
+
.makeRequestWithTokens(requestInfo, newConnection)
|
|
2963
|
+
.then(function (url) {
|
|
2964
|
+
if (url === null) {
|
|
2965
|
+
throw noDownloadURL();
|
|
2966
|
+
}
|
|
2967
|
+
return url;
|
|
3050
2968
|
});
|
|
3051
2969
|
}
|
|
3052
2970
|
/**
|
|
@@ -3056,18 +2974,9 @@ function getDownloadURL$1(ref) {
|
|
|
3056
2974
|
* @returns A `Promise` that resolves if the deletion succeeds.
|
|
3057
2975
|
*/
|
|
3058
2976
|
function deleteObject$1(ref) {
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
switch (_a.label) {
|
|
3063
|
-
case 0:
|
|
3064
|
-
ref._throwIfRoot('deleteObject');
|
|
3065
|
-
requestInfo = deleteObject$2(ref.storage, ref._location);
|
|
3066
|
-
return [4 /*yield*/, ref.storage.makeRequestWithTokens(requestInfo)];
|
|
3067
|
-
case 1: return [2 /*return*/, (_a.sent()).getPromise()];
|
|
3068
|
-
}
|
|
3069
|
-
});
|
|
3070
|
-
});
|
|
2977
|
+
ref._throwIfRoot('deleteObject');
|
|
2978
|
+
var requestInfo = deleteObject$2(ref.storage, ref._location);
|
|
2979
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
|
|
3071
2980
|
}
|
|
3072
2981
|
/**
|
|
3073
2982
|
* Returns reference for object obtained by appending `childPath` to `ref`.
|
|
@@ -3189,11 +3098,10 @@ var FirebaseStorageImpl = /** @class */ (function () {
|
|
|
3189
3098
|
/**
|
|
3190
3099
|
* @internal
|
|
3191
3100
|
*/
|
|
3192
|
-
|
|
3101
|
+
_url, _firebaseVersion) {
|
|
3193
3102
|
this.app = app;
|
|
3194
3103
|
this._authProvider = _authProvider;
|
|
3195
3104
|
this._appCheckProvider = _appCheckProvider;
|
|
3196
|
-
this._pool = _pool;
|
|
3197
3105
|
this._url = _url;
|
|
3198
3106
|
this._firebaseVersion = _firebaseVersion;
|
|
3199
3107
|
this._bucket = null;
|
|
@@ -3335,10 +3243,10 @@ var FirebaseStorageImpl = /** @class */ (function () {
|
|
|
3335
3243
|
* @param requestInfo - HTTP RequestInfo object
|
|
3336
3244
|
* @param authToken - Firebase auth token
|
|
3337
3245
|
*/
|
|
3338
|
-
FirebaseStorageImpl.prototype._makeRequest = function (requestInfo, authToken, appCheckToken) {
|
|
3246
|
+
FirebaseStorageImpl.prototype._makeRequest = function (requestInfo, requestFactory, authToken, appCheckToken) {
|
|
3339
3247
|
var _this = this;
|
|
3340
3248
|
if (!this._deleted) {
|
|
3341
|
-
var request_1 = makeRequest(requestInfo, this._appId, authToken, appCheckToken,
|
|
3249
|
+
var request_1 = makeRequest(requestInfo, this._appId, authToken, appCheckToken, requestFactory, this._firebaseVersion);
|
|
3342
3250
|
this._requests.add(request_1);
|
|
3343
3251
|
// Request removes itself from set when complete.
|
|
3344
3252
|
request_1.getPromise().then(function () { return _this._requests.delete(request_1); }, function () { return _this._requests.delete(request_1); });
|
|
@@ -3348,7 +3256,7 @@ var FirebaseStorageImpl = /** @class */ (function () {
|
|
|
3348
3256
|
return new FailRequest(appDeleted());
|
|
3349
3257
|
}
|
|
3350
3258
|
};
|
|
3351
|
-
FirebaseStorageImpl.prototype.makeRequestWithTokens = function (requestInfo) {
|
|
3259
|
+
FirebaseStorageImpl.prototype.makeRequestWithTokens = function (requestInfo, requestFactory) {
|
|
3352
3260
|
return __awaiter(this, void 0, void 0, function () {
|
|
3353
3261
|
var _a, authToken, appCheckToken;
|
|
3354
3262
|
return __generator(this, function (_b) {
|
|
@@ -3359,7 +3267,7 @@ var FirebaseStorageImpl = /** @class */ (function () {
|
|
|
3359
3267
|
])];
|
|
3360
3268
|
case 1:
|
|
3361
3269
|
_a = _b.sent(), authToken = _a[0], appCheckToken = _a[1];
|
|
3362
|
-
return [2 /*return*/, this._makeRequest(requestInfo, authToken, appCheckToken)];
|
|
3270
|
+
return [2 /*return*/, this._makeRequest(requestInfo, requestFactory, authToken, appCheckToken).getPromise()];
|
|
3363
3271
|
}
|
|
3364
3272
|
});
|
|
3365
3273
|
});
|
|
@@ -3368,7 +3276,7 @@ var FirebaseStorageImpl = /** @class */ (function () {
|
|
|
3368
3276
|
}());
|
|
3369
3277
|
|
|
3370
3278
|
var name = "@firebase/storage";
|
|
3371
|
-
var version = "0.8.
|
|
3279
|
+
var version = "0.8.4-2021927221742";
|
|
3372
3280
|
|
|
3373
3281
|
/**
|
|
3374
3282
|
* @license
|
|
@@ -3593,11 +3501,14 @@ function factory(container, _a) {
|
|
|
3593
3501
|
var app = container.getProvider('app').getImmediate();
|
|
3594
3502
|
var authProvider = container.getProvider('auth-internal');
|
|
3595
3503
|
var appCheckProvider = container.getProvider('app-check-internal');
|
|
3596
|
-
return new FirebaseStorageImpl(app, authProvider, appCheckProvider,
|
|
3504
|
+
return new FirebaseStorageImpl(app, authProvider, appCheckProvider, url, SDK_VERSION);
|
|
3597
3505
|
}
|
|
3598
3506
|
function registerStorage() {
|
|
3599
3507
|
_registerComponent(new Component(STORAGE_TYPE, factory, "PUBLIC" /* PUBLIC */).setMultipleInstances(true));
|
|
3600
|
-
|
|
3508
|
+
//RUNTIME_ENV will be replaced during the compilation to "node" for nodejs and an empty string for browser
|
|
3509
|
+
registerVersion(name, version, '');
|
|
3510
|
+
// BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
|
|
3511
|
+
registerVersion(name, version, 'esm5');
|
|
3601
3512
|
}
|
|
3602
3513
|
registerStorage();
|
|
3603
3514
|
|