@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
|
@@ -7,32 +7,6 @@ var tslib = require('tslib');
|
|
|
7
7
|
var util = require('@firebase/util');
|
|
8
8
|
var component = require('@firebase/component');
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* @license
|
|
12
|
-
* Copyright 2017 Google LLC
|
|
13
|
-
*
|
|
14
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
15
|
-
* you may not use this file except in compliance with the License.
|
|
16
|
-
* You may obtain a copy of the License at
|
|
17
|
-
*
|
|
18
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
-
*
|
|
20
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
21
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
22
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
23
|
-
* See the License for the specific language governing permissions and
|
|
24
|
-
* limitations under the License.
|
|
25
|
-
*/
|
|
26
|
-
/**
|
|
27
|
-
* Error codes for requests made by the the XhrIo wrapper.
|
|
28
|
-
*/
|
|
29
|
-
var ErrorCode;
|
|
30
|
-
(function (ErrorCode) {
|
|
31
|
-
ErrorCode[ErrorCode["NO_ERROR"] = 0] = "NO_ERROR";
|
|
32
|
-
ErrorCode[ErrorCode["NETWORK_ERROR"] = 1] = "NETWORK_ERROR";
|
|
33
|
-
ErrorCode[ErrorCode["ABORT"] = 2] = "ABORT";
|
|
34
|
-
})(ErrorCode || (ErrorCode = {}));
|
|
35
|
-
|
|
36
10
|
/**
|
|
37
11
|
* @license
|
|
38
12
|
* Copyright 2017 Google LLC
|
|
@@ -212,165 +186,6 @@ function internalError(message) {
|
|
|
212
186
|
throw new StorageError("internal-error" /* INTERNAL_ERROR */, 'Internal error: ' + message);
|
|
213
187
|
}
|
|
214
188
|
|
|
215
|
-
/**
|
|
216
|
-
* @license
|
|
217
|
-
* Copyright 2017 Google LLC
|
|
218
|
-
*
|
|
219
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
220
|
-
* you may not use this file except in compliance with the License.
|
|
221
|
-
* You may obtain a copy of the License at
|
|
222
|
-
*
|
|
223
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
224
|
-
*
|
|
225
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
226
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
227
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
228
|
-
* See the License for the specific language governing permissions and
|
|
229
|
-
* limitations under the License.
|
|
230
|
-
*/
|
|
231
|
-
/**
|
|
232
|
-
* Network layer for browsers. We use this instead of goog.net.XhrIo because
|
|
233
|
-
* goog.net.XhrIo is hyuuuuge and doesn't work in React Native on Android.
|
|
234
|
-
*/
|
|
235
|
-
var XhrConnection = /** @class */ (function () {
|
|
236
|
-
function XhrConnection() {
|
|
237
|
-
var _this = this;
|
|
238
|
-
this.sent_ = false;
|
|
239
|
-
this.xhr_ = new XMLHttpRequest();
|
|
240
|
-
this.errorCode_ = ErrorCode.NO_ERROR;
|
|
241
|
-
this.sendPromise_ = new Promise(function (resolve) {
|
|
242
|
-
_this.xhr_.addEventListener('abort', function () {
|
|
243
|
-
_this.errorCode_ = ErrorCode.ABORT;
|
|
244
|
-
resolve();
|
|
245
|
-
});
|
|
246
|
-
_this.xhr_.addEventListener('error', function () {
|
|
247
|
-
_this.errorCode_ = ErrorCode.NETWORK_ERROR;
|
|
248
|
-
resolve();
|
|
249
|
-
});
|
|
250
|
-
_this.xhr_.addEventListener('load', function () {
|
|
251
|
-
resolve();
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* @override
|
|
257
|
-
*/
|
|
258
|
-
XhrConnection.prototype.send = function (url, method, body, headers) {
|
|
259
|
-
if (this.sent_) {
|
|
260
|
-
throw internalError('cannot .send() more than once');
|
|
261
|
-
}
|
|
262
|
-
this.sent_ = true;
|
|
263
|
-
this.xhr_.open(method, url, true);
|
|
264
|
-
if (headers !== undefined) {
|
|
265
|
-
for (var key in headers) {
|
|
266
|
-
if (headers.hasOwnProperty(key)) {
|
|
267
|
-
this.xhr_.setRequestHeader(key, headers[key].toString());
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
if (body !== undefined) {
|
|
272
|
-
this.xhr_.send(body);
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
this.xhr_.send();
|
|
276
|
-
}
|
|
277
|
-
return this.sendPromise_;
|
|
278
|
-
};
|
|
279
|
-
/**
|
|
280
|
-
* @override
|
|
281
|
-
*/
|
|
282
|
-
XhrConnection.prototype.getErrorCode = function () {
|
|
283
|
-
if (!this.sent_) {
|
|
284
|
-
throw internalError('cannot .getErrorCode() before sending');
|
|
285
|
-
}
|
|
286
|
-
return this.errorCode_;
|
|
287
|
-
};
|
|
288
|
-
/**
|
|
289
|
-
* @override
|
|
290
|
-
*/
|
|
291
|
-
XhrConnection.prototype.getStatus = function () {
|
|
292
|
-
if (!this.sent_) {
|
|
293
|
-
throw internalError('cannot .getStatus() before sending');
|
|
294
|
-
}
|
|
295
|
-
try {
|
|
296
|
-
return this.xhr_.status;
|
|
297
|
-
}
|
|
298
|
-
catch (e) {
|
|
299
|
-
return -1;
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
/**
|
|
303
|
-
* @override
|
|
304
|
-
*/
|
|
305
|
-
XhrConnection.prototype.getResponseText = function () {
|
|
306
|
-
if (!this.sent_) {
|
|
307
|
-
throw internalError('cannot .getResponseText() before sending');
|
|
308
|
-
}
|
|
309
|
-
return this.xhr_.responseText;
|
|
310
|
-
};
|
|
311
|
-
/**
|
|
312
|
-
* Aborts the request.
|
|
313
|
-
* @override
|
|
314
|
-
*/
|
|
315
|
-
XhrConnection.prototype.abort = function () {
|
|
316
|
-
this.xhr_.abort();
|
|
317
|
-
};
|
|
318
|
-
/**
|
|
319
|
-
* @override
|
|
320
|
-
*/
|
|
321
|
-
XhrConnection.prototype.getResponseHeader = function (header) {
|
|
322
|
-
return this.xhr_.getResponseHeader(header);
|
|
323
|
-
};
|
|
324
|
-
/**
|
|
325
|
-
* @override
|
|
326
|
-
*/
|
|
327
|
-
XhrConnection.prototype.addUploadProgressListener = function (listener) {
|
|
328
|
-
if (this.xhr_.upload != null) {
|
|
329
|
-
this.xhr_.upload.addEventListener('progress', listener);
|
|
330
|
-
}
|
|
331
|
-
};
|
|
332
|
-
/**
|
|
333
|
-
* @override
|
|
334
|
-
*/
|
|
335
|
-
XhrConnection.prototype.removeUploadProgressListener = function (listener) {
|
|
336
|
-
if (this.xhr_.upload != null) {
|
|
337
|
-
this.xhr_.upload.removeEventListener('progress', listener);
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
return XhrConnection;
|
|
341
|
-
}());
|
|
342
|
-
function newConnection() {
|
|
343
|
-
return new XhrConnection();
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* @license
|
|
348
|
-
* Copyright 2017 Google LLC
|
|
349
|
-
*
|
|
350
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
351
|
-
* you may not use this file except in compliance with the License.
|
|
352
|
-
* You may obtain a copy of the License at
|
|
353
|
-
*
|
|
354
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
355
|
-
*
|
|
356
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
357
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
358
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
359
|
-
* See the License for the specific language governing permissions and
|
|
360
|
-
* limitations under the License.
|
|
361
|
-
*/
|
|
362
|
-
/**
|
|
363
|
-
* Factory-like class for creating XhrIo instances.
|
|
364
|
-
*/
|
|
365
|
-
var ConnectionPool = /** @class */ (function () {
|
|
366
|
-
function ConnectionPool() {
|
|
367
|
-
}
|
|
368
|
-
ConnectionPool.prototype.createConnection = function () {
|
|
369
|
-
return newConnection();
|
|
370
|
-
};
|
|
371
|
-
return ConnectionPool;
|
|
372
|
-
}());
|
|
373
|
-
|
|
374
189
|
/**
|
|
375
190
|
* @license
|
|
376
191
|
* Copyright 2017 Google LLC
|
|
@@ -719,6 +534,32 @@ function makeQueryString(params) {
|
|
|
719
534
|
return queryPart;
|
|
720
535
|
}
|
|
721
536
|
|
|
537
|
+
/**
|
|
538
|
+
* @license
|
|
539
|
+
* Copyright 2017 Google LLC
|
|
540
|
+
*
|
|
541
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
542
|
+
* you may not use this file except in compliance with the License.
|
|
543
|
+
* You may obtain a copy of the License at
|
|
544
|
+
*
|
|
545
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
546
|
+
*
|
|
547
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
548
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
549
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
550
|
+
* See the License for the specific language governing permissions and
|
|
551
|
+
* limitations under the License.
|
|
552
|
+
*/
|
|
553
|
+
/**
|
|
554
|
+
* Error codes for requests made by the the XhrIo wrapper.
|
|
555
|
+
*/
|
|
556
|
+
var ErrorCode;
|
|
557
|
+
(function (ErrorCode) {
|
|
558
|
+
ErrorCode[ErrorCode["NO_ERROR"] = 0] = "NO_ERROR";
|
|
559
|
+
ErrorCode[ErrorCode["NETWORK_ERROR"] = 1] = "NETWORK_ERROR";
|
|
560
|
+
ErrorCode[ErrorCode["ABORT"] = 2] = "ABORT";
|
|
561
|
+
})(ErrorCode || (ErrorCode = {}));
|
|
562
|
+
|
|
722
563
|
/**
|
|
723
564
|
* @license
|
|
724
565
|
* Copyright 2017 Google LLC
|
|
@@ -736,23 +577,23 @@ function makeQueryString(params) {
|
|
|
736
577
|
* limitations under the License.
|
|
737
578
|
*/
|
|
738
579
|
var NetworkRequest = /** @class */ (function () {
|
|
739
|
-
function NetworkRequest(
|
|
580
|
+
function NetworkRequest(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, connectionFactory_) {
|
|
740
581
|
var _this = this;
|
|
582
|
+
this.url_ = url_;
|
|
583
|
+
this.method_ = method_;
|
|
584
|
+
this.headers_ = headers_;
|
|
585
|
+
this.body_ = body_;
|
|
586
|
+
this.successCodes_ = successCodes_;
|
|
587
|
+
this.additionalRetryCodes_ = additionalRetryCodes_;
|
|
588
|
+
this.callback_ = callback_;
|
|
589
|
+
this.errorCallback_ = errorCallback_;
|
|
590
|
+
this.timeout_ = timeout_;
|
|
591
|
+
this.progressCallback_ = progressCallback_;
|
|
592
|
+
this.connectionFactory_ = connectionFactory_;
|
|
741
593
|
this.pendingConnection_ = null;
|
|
742
594
|
this.backoffId_ = null;
|
|
743
595
|
this.canceled_ = false;
|
|
744
596
|
this.appDelete_ = false;
|
|
745
|
-
this.url_ = url;
|
|
746
|
-
this.method_ = method;
|
|
747
|
-
this.headers_ = headers;
|
|
748
|
-
this.body_ = body;
|
|
749
|
-
this.successCodes_ = successCodes.slice();
|
|
750
|
-
this.additionalRetryCodes_ = additionalRetryCodes.slice();
|
|
751
|
-
this.callback_ = callback;
|
|
752
|
-
this.errorCallback_ = errorCallback;
|
|
753
|
-
this.progressCallback_ = progressCallback;
|
|
754
|
-
this.timeout_ = timeout;
|
|
755
|
-
this.pool_ = pool;
|
|
756
597
|
this.promise_ = new Promise(function (resolve, reject) {
|
|
757
598
|
_this.resolve_ = resolve;
|
|
758
599
|
_this.reject_ = reject;
|
|
@@ -763,54 +604,57 @@ var NetworkRequest = /** @class */ (function () {
|
|
|
763
604
|
* Actually starts the retry loop.
|
|
764
605
|
*/
|
|
765
606
|
NetworkRequest.prototype.start_ = function () {
|
|
766
|
-
var
|
|
767
|
-
function
|
|
607
|
+
var _this = this;
|
|
608
|
+
var doTheRequest = function (backoffCallback, canceled) {
|
|
768
609
|
if (canceled) {
|
|
769
610
|
backoffCallback(false, new RequestEndStatus(false, null, true));
|
|
770
611
|
return;
|
|
771
612
|
}
|
|
772
|
-
var connection =
|
|
773
|
-
|
|
774
|
-
function
|
|
613
|
+
var connection = _this.connectionFactory_();
|
|
614
|
+
_this.pendingConnection_ = connection;
|
|
615
|
+
var progressListener = function (progressEvent) {
|
|
775
616
|
var loaded = progressEvent.loaded;
|
|
776
|
-
var total = progressEvent.lengthComputable
|
|
777
|
-
|
|
778
|
-
|
|
617
|
+
var total = progressEvent.lengthComputable
|
|
618
|
+
? progressEvent.total
|
|
619
|
+
: -1;
|
|
620
|
+
if (_this.progressCallback_ !== null) {
|
|
621
|
+
_this.progressCallback_(loaded, total);
|
|
779
622
|
}
|
|
780
|
-
}
|
|
781
|
-
if (
|
|
623
|
+
};
|
|
624
|
+
if (_this.progressCallback_ !== null) {
|
|
782
625
|
connection.addUploadProgressListener(progressListener);
|
|
783
626
|
}
|
|
627
|
+
// connection.send() never rejects, so we don't need to have a error handler or use catch on the returned promise.
|
|
784
628
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
785
629
|
connection
|
|
786
|
-
.send(
|
|
630
|
+
.send(_this.url_, _this.method_, _this.body_, _this.headers_)
|
|
787
631
|
.then(function () {
|
|
788
|
-
if (
|
|
632
|
+
if (_this.progressCallback_ !== null) {
|
|
789
633
|
connection.removeUploadProgressListener(progressListener);
|
|
790
634
|
}
|
|
791
|
-
|
|
635
|
+
_this.pendingConnection_ = null;
|
|
792
636
|
var hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR;
|
|
793
637
|
var status = connection.getStatus();
|
|
794
|
-
if (!hitServer ||
|
|
638
|
+
if (!hitServer || _this.isRetryStatusCode_(status)) {
|
|
795
639
|
var wasCanceled = connection.getErrorCode() === ErrorCode.ABORT;
|
|
796
640
|
backoffCallback(false, new RequestEndStatus(false, null, wasCanceled));
|
|
797
641
|
return;
|
|
798
642
|
}
|
|
799
|
-
var successCode =
|
|
643
|
+
var successCode = _this.successCodes_.indexOf(status) !== -1;
|
|
800
644
|
backoffCallback(true, new RequestEndStatus(successCode, connection));
|
|
801
645
|
});
|
|
802
|
-
}
|
|
646
|
+
};
|
|
803
647
|
/**
|
|
804
648
|
* @param requestWentThrough - True if the request eventually went
|
|
805
649
|
* through, false if it hit the retry limit or was canceled.
|
|
806
650
|
*/
|
|
807
|
-
function
|
|
808
|
-
var resolve =
|
|
809
|
-
var reject =
|
|
651
|
+
var backoffDone = function (requestWentThrough, status) {
|
|
652
|
+
var resolve = _this.resolve_;
|
|
653
|
+
var reject = _this.reject_;
|
|
810
654
|
var connection = status.connection;
|
|
811
655
|
if (status.wasSuccessCode) {
|
|
812
656
|
try {
|
|
813
|
-
var result =
|
|
657
|
+
var result = _this.callback_(connection, connection.getResponseText());
|
|
814
658
|
if (isJustDef(result)) {
|
|
815
659
|
resolve(result);
|
|
816
660
|
}
|
|
@@ -826,8 +670,8 @@ var NetworkRequest = /** @class */ (function () {
|
|
|
826
670
|
if (connection !== null) {
|
|
827
671
|
var err = unknown();
|
|
828
672
|
err.serverResponse = connection.getResponseText();
|
|
829
|
-
if (
|
|
830
|
-
reject(
|
|
673
|
+
if (_this.errorCallback_) {
|
|
674
|
+
reject(_this.errorCallback_(connection, err));
|
|
831
675
|
}
|
|
832
676
|
else {
|
|
833
677
|
reject(err);
|
|
@@ -835,7 +679,7 @@ var NetworkRequest = /** @class */ (function () {
|
|
|
835
679
|
}
|
|
836
680
|
else {
|
|
837
681
|
if (status.canceled) {
|
|
838
|
-
var err =
|
|
682
|
+
var err = _this.appDelete_ ? appDeleted() : canceled();
|
|
839
683
|
reject(err);
|
|
840
684
|
}
|
|
841
685
|
else {
|
|
@@ -844,7 +688,7 @@ var NetworkRequest = /** @class */ (function () {
|
|
|
844
688
|
}
|
|
845
689
|
}
|
|
846
690
|
}
|
|
847
|
-
}
|
|
691
|
+
};
|
|
848
692
|
if (this.canceled_) {
|
|
849
693
|
backoffDone(false, new RequestEndStatus(false, null, true));
|
|
850
694
|
}
|
|
@@ -914,7 +758,7 @@ function addAppCheckHeader_(headers, appCheckToken) {
|
|
|
914
758
|
headers['X-Firebase-AppCheck'] = appCheckToken;
|
|
915
759
|
}
|
|
916
760
|
}
|
|
917
|
-
function makeRequest(requestInfo, appId, authToken, appCheckToken,
|
|
761
|
+
function makeRequest(requestInfo, appId, authToken, appCheckToken, requestFactory, firebaseVersion) {
|
|
918
762
|
var queryPart = makeQueryString(requestInfo.urlParams);
|
|
919
763
|
var url = requestInfo.url + queryPart;
|
|
920
764
|
var headers = Object.assign({}, requestInfo.headers);
|
|
@@ -922,7 +766,7 @@ function makeRequest(requestInfo, appId, authToken, appCheckToken, pool, firebas
|
|
|
922
766
|
addAuthHeader_(headers, authToken);
|
|
923
767
|
addVersionHeader_(headers, firebaseVersion);
|
|
924
768
|
addAppCheckHeader_(headers, appCheckToken);
|
|
925
|
-
return new NetworkRequest(url, requestInfo.method, headers, requestInfo.body, requestInfo.successCodes, requestInfo.additionalRetryCodes, requestInfo.handler, requestInfo.errorHandler, requestInfo.timeout, requestInfo.progressCallback,
|
|
769
|
+
return new NetworkRequest(url, requestInfo.method, headers, requestInfo.body, requestInfo.successCodes, requestInfo.additionalRetryCodes, requestInfo.handler, requestInfo.errorHandler, requestInfo.timeout, requestInfo.progressCallback, requestFactory);
|
|
926
770
|
}
|
|
927
771
|
|
|
928
772
|
/**
|
|
@@ -2195,6 +2039,117 @@ function async(f) {
|
|
|
2195
2039
|
};
|
|
2196
2040
|
}
|
|
2197
2041
|
|
|
2042
|
+
/**
|
|
2043
|
+
* @license
|
|
2044
|
+
* Copyright 2017 Google LLC
|
|
2045
|
+
*
|
|
2046
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2047
|
+
* you may not use this file except in compliance with the License.
|
|
2048
|
+
* You may obtain a copy of the License at
|
|
2049
|
+
*
|
|
2050
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2051
|
+
*
|
|
2052
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2053
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2054
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2055
|
+
* See the License for the specific language governing permissions and
|
|
2056
|
+
* limitations under the License.
|
|
2057
|
+
*/
|
|
2058
|
+
/** An override for the text-based Connection. Used in tests. */
|
|
2059
|
+
var connectionFactoryOverride = null;
|
|
2060
|
+
/**
|
|
2061
|
+
* Network layer for browsers. We use this instead of goog.net.XhrIo because
|
|
2062
|
+
* goog.net.XhrIo is hyuuuuge and doesn't work in React Native on Android.
|
|
2063
|
+
*/
|
|
2064
|
+
var XhrConnection = /** @class */ (function () {
|
|
2065
|
+
function XhrConnection() {
|
|
2066
|
+
var _this = this;
|
|
2067
|
+
this.sent_ = false;
|
|
2068
|
+
this.xhr_ = new XMLHttpRequest();
|
|
2069
|
+
this.errorCode_ = ErrorCode.NO_ERROR;
|
|
2070
|
+
this.sendPromise_ = new Promise(function (resolve) {
|
|
2071
|
+
_this.xhr_.addEventListener('abort', function () {
|
|
2072
|
+
_this.errorCode_ = ErrorCode.ABORT;
|
|
2073
|
+
resolve();
|
|
2074
|
+
});
|
|
2075
|
+
_this.xhr_.addEventListener('error', function () {
|
|
2076
|
+
_this.errorCode_ = ErrorCode.NETWORK_ERROR;
|
|
2077
|
+
resolve();
|
|
2078
|
+
});
|
|
2079
|
+
_this.xhr_.addEventListener('load', function () {
|
|
2080
|
+
resolve();
|
|
2081
|
+
});
|
|
2082
|
+
});
|
|
2083
|
+
}
|
|
2084
|
+
XhrConnection.prototype.send = function (url, method, body, headers) {
|
|
2085
|
+
if (this.sent_) {
|
|
2086
|
+
throw internalError('cannot .send() more than once');
|
|
2087
|
+
}
|
|
2088
|
+
this.sent_ = true;
|
|
2089
|
+
this.xhr_.open(method, url, true);
|
|
2090
|
+
if (headers !== undefined) {
|
|
2091
|
+
for (var key in headers) {
|
|
2092
|
+
if (headers.hasOwnProperty(key)) {
|
|
2093
|
+
this.xhr_.setRequestHeader(key, headers[key].toString());
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
if (body !== undefined) {
|
|
2098
|
+
this.xhr_.send(body);
|
|
2099
|
+
}
|
|
2100
|
+
else {
|
|
2101
|
+
this.xhr_.send();
|
|
2102
|
+
}
|
|
2103
|
+
return this.sendPromise_;
|
|
2104
|
+
};
|
|
2105
|
+
XhrConnection.prototype.getErrorCode = function () {
|
|
2106
|
+
if (!this.sent_) {
|
|
2107
|
+
throw internalError('cannot .getErrorCode() before sending');
|
|
2108
|
+
}
|
|
2109
|
+
return this.errorCode_;
|
|
2110
|
+
};
|
|
2111
|
+
XhrConnection.prototype.getStatus = function () {
|
|
2112
|
+
if (!this.sent_) {
|
|
2113
|
+
throw internalError('cannot .getStatus() before sending');
|
|
2114
|
+
}
|
|
2115
|
+
try {
|
|
2116
|
+
return this.xhr_.status;
|
|
2117
|
+
}
|
|
2118
|
+
catch (e) {
|
|
2119
|
+
return -1;
|
|
2120
|
+
}
|
|
2121
|
+
};
|
|
2122
|
+
XhrConnection.prototype.getResponseText = function () {
|
|
2123
|
+
if (!this.sent_) {
|
|
2124
|
+
throw internalError('cannot .getResponseText() before sending');
|
|
2125
|
+
}
|
|
2126
|
+
return this.xhr_.responseText;
|
|
2127
|
+
};
|
|
2128
|
+
/** Aborts the request. */
|
|
2129
|
+
XhrConnection.prototype.abort = function () {
|
|
2130
|
+
this.xhr_.abort();
|
|
2131
|
+
};
|
|
2132
|
+
XhrConnection.prototype.getResponseHeader = function (header) {
|
|
2133
|
+
return this.xhr_.getResponseHeader(header);
|
|
2134
|
+
};
|
|
2135
|
+
XhrConnection.prototype.addUploadProgressListener = function (listener) {
|
|
2136
|
+
if (this.xhr_.upload != null) {
|
|
2137
|
+
this.xhr_.upload.addEventListener('progress', listener);
|
|
2138
|
+
}
|
|
2139
|
+
};
|
|
2140
|
+
XhrConnection.prototype.removeUploadProgressListener = function (listener) {
|
|
2141
|
+
if (this.xhr_.upload != null) {
|
|
2142
|
+
this.xhr_.upload.removeEventListener('progress', listener);
|
|
2143
|
+
}
|
|
2144
|
+
};
|
|
2145
|
+
return XhrConnection;
|
|
2146
|
+
}());
|
|
2147
|
+
function newConnection() {
|
|
2148
|
+
return connectionFactoryOverride
|
|
2149
|
+
? connectionFactoryOverride()
|
|
2150
|
+
: new XhrConnection();
|
|
2151
|
+
}
|
|
2152
|
+
|
|
2198
2153
|
/**
|
|
2199
2154
|
* @license
|
|
2200
2155
|
* Copyright 2017 Google LLC
|
|
@@ -2340,7 +2295,7 @@ var UploadTask = /** @class */ (function () {
|
|
|
2340
2295
|
var _this = this;
|
|
2341
2296
|
this._resolveToken(function (authToken, appCheckToken) {
|
|
2342
2297
|
var requestInfo = createResumableUpload(_this._ref.storage, _this._ref._location, _this._mappings, _this._blob, _this._metadata);
|
|
2343
|
-
var createRequest = _this._ref.storage._makeRequest(requestInfo, authToken, appCheckToken);
|
|
2298
|
+
var createRequest = _this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
|
|
2344
2299
|
_this._request = createRequest;
|
|
2345
2300
|
createRequest.getPromise().then(function (url) {
|
|
2346
2301
|
_this._request = undefined;
|
|
@@ -2356,7 +2311,7 @@ var UploadTask = /** @class */ (function () {
|
|
|
2356
2311
|
var url = this._uploadUrl;
|
|
2357
2312
|
this._resolveToken(function (authToken, appCheckToken) {
|
|
2358
2313
|
var requestInfo = getResumableUploadStatus(_this._ref.storage, _this._ref._location, url, _this._blob);
|
|
2359
|
-
var statusRequest = _this._ref.storage._makeRequest(requestInfo, authToken, appCheckToken);
|
|
2314
|
+
var statusRequest = _this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
|
|
2360
2315
|
_this._request = statusRequest;
|
|
2361
2316
|
statusRequest.getPromise().then(function (status) {
|
|
2362
2317
|
status = status;
|
|
@@ -2386,7 +2341,7 @@ var UploadTask = /** @class */ (function () {
|
|
|
2386
2341
|
_this._transition("error" /* ERROR */);
|
|
2387
2342
|
return;
|
|
2388
2343
|
}
|
|
2389
|
-
var uploadRequest = _this._ref.storage._makeRequest(requestInfo, authToken, appCheckToken);
|
|
2344
|
+
var uploadRequest = _this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
|
|
2390
2345
|
_this._request = uploadRequest;
|
|
2391
2346
|
uploadRequest.getPromise().then(function (newStatus) {
|
|
2392
2347
|
_this._increaseMultiplier();
|
|
@@ -2413,7 +2368,7 @@ var UploadTask = /** @class */ (function () {
|
|
|
2413
2368
|
var _this = this;
|
|
2414
2369
|
this._resolveToken(function (authToken, appCheckToken) {
|
|
2415
2370
|
var requestInfo = getMetadata$2(_this._ref.storage, _this._ref._location, _this._mappings);
|
|
2416
|
-
var metadataRequest = _this._ref.storage._makeRequest(requestInfo, authToken, appCheckToken);
|
|
2371
|
+
var metadataRequest = _this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
|
|
2417
2372
|
_this._request = metadataRequest;
|
|
2418
2373
|
metadataRequest.getPromise().then(function (metadata) {
|
|
2419
2374
|
_this._request = undefined;
|
|
@@ -2426,7 +2381,7 @@ var UploadTask = /** @class */ (function () {
|
|
|
2426
2381
|
var _this = this;
|
|
2427
2382
|
this._resolveToken(function (authToken, appCheckToken) {
|
|
2428
2383
|
var requestInfo = multipartUpload(_this._ref.storage, _this._ref._location, _this._mappings, _this._blob, _this._metadata);
|
|
2429
|
-
var multipartRequest = _this._ref.storage._makeRequest(requestInfo, authToken, appCheckToken);
|
|
2384
|
+
var multipartRequest = _this._ref.storage._makeRequest(requestInfo, newConnection, authToken, appCheckToken);
|
|
2430
2385
|
_this._request = multipartRequest;
|
|
2431
2386
|
multipartRequest.getPromise().then(function (metadata) {
|
|
2432
2387
|
_this._request = undefined;
|
|
@@ -2836,8 +2791,7 @@ function uploadBytes$1(ref, data, metadata) {
|
|
|
2836
2791
|
ref._throwIfRoot('uploadBytes');
|
|
2837
2792
|
var requestInfo = multipartUpload(ref.storage, ref._location, getMappings(), new FbsBlob(data, true), metadata);
|
|
2838
2793
|
return ref.storage
|
|
2839
|
-
.makeRequestWithTokens(requestInfo)
|
|
2840
|
-
.then(function (request) { return request.getPromise(); })
|
|
2794
|
+
.makeRequestWithTokens(requestInfo, newConnection)
|
|
2841
2795
|
.then(function (finalMetadata) {
|
|
2842
2796
|
return {
|
|
2843
2797
|
metadata: finalMetadata,
|
|
@@ -2959,26 +2913,17 @@ function listAllHelper(ref, accumulator, pageToken) {
|
|
|
2959
2913
|
* can be used to get the rest of the results.
|
|
2960
2914
|
*/
|
|
2961
2915
|
function list$1(ref, options) {
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
}
|
|
2974
|
-
op = options || {};
|
|
2975
|
-
requestInfo = list$2(ref.storage, ref._location,
|
|
2976
|
-
/*delimiter= */ '/', op.pageToken, op.maxResults);
|
|
2977
|
-
return [4 /*yield*/, ref.storage.makeRequestWithTokens(requestInfo)];
|
|
2978
|
-
case 1: return [2 /*return*/, (_a.sent()).getPromise()];
|
|
2979
|
-
}
|
|
2980
|
-
});
|
|
2981
|
-
});
|
|
2916
|
+
if (options != null) {
|
|
2917
|
+
if (typeof options.maxResults === 'number') {
|
|
2918
|
+
validateNumber('options.maxResults',
|
|
2919
|
+
/* minValue= */ 1,
|
|
2920
|
+
/* maxValue= */ 1000, options.maxResults);
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
2923
|
+
var op = options || {};
|
|
2924
|
+
var requestInfo = list$2(ref.storage, ref._location,
|
|
2925
|
+
/*delimiter= */ '/', op.pageToken, op.maxResults);
|
|
2926
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
|
|
2982
2927
|
}
|
|
2983
2928
|
/**
|
|
2984
2929
|
* A `Promise` that resolves with the metadata for this object. If this
|
|
@@ -2988,18 +2933,9 @@ function list$1(ref, options) {
|
|
|
2988
2933
|
* @param ref - StorageReference to get metadata from.
|
|
2989
2934
|
*/
|
|
2990
2935
|
function getMetadata$1(ref) {
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
switch (_a.label) {
|
|
2995
|
-
case 0:
|
|
2996
|
-
ref._throwIfRoot('getMetadata');
|
|
2997
|
-
requestInfo = getMetadata$2(ref.storage, ref._location, getMappings());
|
|
2998
|
-
return [4 /*yield*/, ref.storage.makeRequestWithTokens(requestInfo)];
|
|
2999
|
-
case 1: return [2 /*return*/, (_a.sent()).getPromise()];
|
|
3000
|
-
}
|
|
3001
|
-
});
|
|
3002
|
-
});
|
|
2936
|
+
ref._throwIfRoot('getMetadata');
|
|
2937
|
+
var requestInfo = getMetadata$2(ref.storage, ref._location, getMappings());
|
|
2938
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
|
|
3003
2939
|
}
|
|
3004
2940
|
/**
|
|
3005
2941
|
* Updates the metadata for this object.
|
|
@@ -3013,18 +2949,9 @@ function getMetadata$1(ref) {
|
|
|
3013
2949
|
* See `firebaseStorage.Reference.prototype.getMetadata`
|
|
3014
2950
|
*/
|
|
3015
2951
|
function updateMetadata$1(ref, metadata) {
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
switch (_a.label) {
|
|
3020
|
-
case 0:
|
|
3021
|
-
ref._throwIfRoot('updateMetadata');
|
|
3022
|
-
requestInfo = updateMetadata$2(ref.storage, ref._location, metadata, getMappings());
|
|
3023
|
-
return [4 /*yield*/, ref.storage.makeRequestWithTokens(requestInfo)];
|
|
3024
|
-
case 1: return [2 /*return*/, (_a.sent()).getPromise()];
|
|
3025
|
-
}
|
|
3026
|
-
});
|
|
3027
|
-
});
|
|
2952
|
+
ref._throwIfRoot('updateMetadata');
|
|
2953
|
+
var requestInfo = updateMetadata$2(ref.storage, ref._location, metadata, getMappings());
|
|
2954
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
|
|
3028
2955
|
}
|
|
3029
2956
|
/**
|
|
3030
2957
|
* Returns the download URL for the given Reference.
|
|
@@ -3033,24 +2960,15 @@ function updateMetadata$1(ref, metadata) {
|
|
|
3033
2960
|
* URL for this object.
|
|
3034
2961
|
*/
|
|
3035
2962
|
function getDownloadURL$1(ref) {
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
.getPromise()
|
|
3046
|
-
.then(function (url) {
|
|
3047
|
-
if (url === null) {
|
|
3048
|
-
throw noDownloadURL();
|
|
3049
|
-
}
|
|
3050
|
-
return url;
|
|
3051
|
-
})];
|
|
3052
|
-
}
|
|
3053
|
-
});
|
|
2963
|
+
ref._throwIfRoot('getDownloadURL');
|
|
2964
|
+
var requestInfo = getDownloadUrl(ref.storage, ref._location, getMappings());
|
|
2965
|
+
return ref.storage
|
|
2966
|
+
.makeRequestWithTokens(requestInfo, newConnection)
|
|
2967
|
+
.then(function (url) {
|
|
2968
|
+
if (url === null) {
|
|
2969
|
+
throw noDownloadURL();
|
|
2970
|
+
}
|
|
2971
|
+
return url;
|
|
3054
2972
|
});
|
|
3055
2973
|
}
|
|
3056
2974
|
/**
|
|
@@ -3060,18 +2978,9 @@ function getDownloadURL$1(ref) {
|
|
|
3060
2978
|
* @returns A `Promise` that resolves if the deletion succeeds.
|
|
3061
2979
|
*/
|
|
3062
2980
|
function deleteObject$1(ref) {
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
switch (_a.label) {
|
|
3067
|
-
case 0:
|
|
3068
|
-
ref._throwIfRoot('deleteObject');
|
|
3069
|
-
requestInfo = deleteObject$2(ref.storage, ref._location);
|
|
3070
|
-
return [4 /*yield*/, ref.storage.makeRequestWithTokens(requestInfo)];
|
|
3071
|
-
case 1: return [2 /*return*/, (_a.sent()).getPromise()];
|
|
3072
|
-
}
|
|
3073
|
-
});
|
|
3074
|
-
});
|
|
2981
|
+
ref._throwIfRoot('deleteObject');
|
|
2982
|
+
var requestInfo = deleteObject$2(ref.storage, ref._location);
|
|
2983
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newConnection);
|
|
3075
2984
|
}
|
|
3076
2985
|
/**
|
|
3077
2986
|
* Returns reference for object obtained by appending `childPath` to `ref`.
|
|
@@ -3193,11 +3102,10 @@ var FirebaseStorageImpl = /** @class */ (function () {
|
|
|
3193
3102
|
/**
|
|
3194
3103
|
* @internal
|
|
3195
3104
|
*/
|
|
3196
|
-
|
|
3105
|
+
_url, _firebaseVersion) {
|
|
3197
3106
|
this.app = app;
|
|
3198
3107
|
this._authProvider = _authProvider;
|
|
3199
3108
|
this._appCheckProvider = _appCheckProvider;
|
|
3200
|
-
this._pool = _pool;
|
|
3201
3109
|
this._url = _url;
|
|
3202
3110
|
this._firebaseVersion = _firebaseVersion;
|
|
3203
3111
|
this._bucket = null;
|
|
@@ -3339,10 +3247,10 @@ var FirebaseStorageImpl = /** @class */ (function () {
|
|
|
3339
3247
|
* @param requestInfo - HTTP RequestInfo object
|
|
3340
3248
|
* @param authToken - Firebase auth token
|
|
3341
3249
|
*/
|
|
3342
|
-
FirebaseStorageImpl.prototype._makeRequest = function (requestInfo, authToken, appCheckToken) {
|
|
3250
|
+
FirebaseStorageImpl.prototype._makeRequest = function (requestInfo, requestFactory, authToken, appCheckToken) {
|
|
3343
3251
|
var _this = this;
|
|
3344
3252
|
if (!this._deleted) {
|
|
3345
|
-
var request_1 = makeRequest(requestInfo, this._appId, authToken, appCheckToken,
|
|
3253
|
+
var request_1 = makeRequest(requestInfo, this._appId, authToken, appCheckToken, requestFactory, this._firebaseVersion);
|
|
3346
3254
|
this._requests.add(request_1);
|
|
3347
3255
|
// Request removes itself from set when complete.
|
|
3348
3256
|
request_1.getPromise().then(function () { return _this._requests.delete(request_1); }, function () { return _this._requests.delete(request_1); });
|
|
@@ -3352,7 +3260,7 @@ var FirebaseStorageImpl = /** @class */ (function () {
|
|
|
3352
3260
|
return new FailRequest(appDeleted());
|
|
3353
3261
|
}
|
|
3354
3262
|
};
|
|
3355
|
-
FirebaseStorageImpl.prototype.makeRequestWithTokens = function (requestInfo) {
|
|
3263
|
+
FirebaseStorageImpl.prototype.makeRequestWithTokens = function (requestInfo, requestFactory) {
|
|
3356
3264
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
3357
3265
|
var _a, authToken, appCheckToken;
|
|
3358
3266
|
return tslib.__generator(this, function (_b) {
|
|
@@ -3363,7 +3271,7 @@ var FirebaseStorageImpl = /** @class */ (function () {
|
|
|
3363
3271
|
])];
|
|
3364
3272
|
case 1:
|
|
3365
3273
|
_a = _b.sent(), authToken = _a[0], appCheckToken = _a[1];
|
|
3366
|
-
return [2 /*return*/, this._makeRequest(requestInfo, authToken, appCheckToken)];
|
|
3274
|
+
return [2 /*return*/, this._makeRequest(requestInfo, requestFactory, authToken, appCheckToken).getPromise()];
|
|
3367
3275
|
}
|
|
3368
3276
|
});
|
|
3369
3277
|
});
|
|
@@ -3372,7 +3280,7 @@ var FirebaseStorageImpl = /** @class */ (function () {
|
|
|
3372
3280
|
}());
|
|
3373
3281
|
|
|
3374
3282
|
var name = "@firebase/storage";
|
|
3375
|
-
var version = "0.8.
|
|
3283
|
+
var version = "0.8.4-2021927221742";
|
|
3376
3284
|
|
|
3377
3285
|
/**
|
|
3378
3286
|
* @license
|
|
@@ -3597,11 +3505,14 @@ function factory(container, _a) {
|
|
|
3597
3505
|
var app$1 = container.getProvider('app').getImmediate();
|
|
3598
3506
|
var authProvider = container.getProvider('auth-internal');
|
|
3599
3507
|
var appCheckProvider = container.getProvider('app-check-internal');
|
|
3600
|
-
return new FirebaseStorageImpl(app$1, authProvider, appCheckProvider,
|
|
3508
|
+
return new FirebaseStorageImpl(app$1, authProvider, appCheckProvider, url, app.SDK_VERSION);
|
|
3601
3509
|
}
|
|
3602
3510
|
function registerStorage() {
|
|
3603
3511
|
app._registerComponent(new component.Component(STORAGE_TYPE, factory, "PUBLIC" /* PUBLIC */).setMultipleInstances(true));
|
|
3604
|
-
|
|
3512
|
+
//RUNTIME_ENV will be replaced during the compilation to "node" for nodejs and an empty string for browser
|
|
3513
|
+
app.registerVersion(name, version, '');
|
|
3514
|
+
// BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
|
|
3515
|
+
app.registerVersion(name, version, 'cjs5');
|
|
3605
3516
|
}
|
|
3606
3517
|
registerStorage();
|
|
3607
3518
|
|