@progressive-development/pd-spa-helper 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PdSpaHelper.d.ts.map +1 -1
- package/dist/{src/PdSpaHelper.js → PdSpaHelper.js} +16 -17
- package/dist/defaultpage/default-confirm-popup.d.ts.map +1 -1
- package/dist/{src/defaultpage → defaultpage}/default-confirm-popup.js +4 -5
- package/dist/defaultpage/default-dialog-popup.d.ts.map +1 -1
- package/dist/{src/defaultpage → defaultpage}/default-dialog-popup.js +4 -5
- package/dist/{src/defaultpage → defaultpage}/default-login.js +2 -3
- package/dist/defaultpage/default-popup.d.ts.map +1 -1
- package/dist/{src/defaultpage → defaultpage}/default-popup.js +1 -1
- package/dist/{src/defaultpage → defaultpage}/default-step-address.js +5 -6
- package/dist/{src/defaultpage → defaultpage}/default-step-summary.js +6 -7
- package/dist/{src/defaultpage → defaultpage}/default-view-page.js +2 -3
- package/dist/{src/defaultpage → defaultpage}/default-wizard-step.js +4 -5
- package/dist/defaultpage/default-wizard.d.ts.map +1 -1
- package/dist/{src/defaultpage → defaultpage}/default-wizard.js +7 -8
- package/dist/generated/locale-wrapper/be-wrapper.d.ts +15 -1
- package/dist/generated/locale-wrapper/be-wrapper.d.ts.map +1 -1
- package/dist/generated/locale-wrapper/be-wrapper.js +17 -0
- package/dist/generated/locale-wrapper/de-wrapper.d.ts.map +1 -1
- package/dist/generated/locale-wrapper/de-wrapper.js +17 -0
- package/dist/generated/locale-wrapper/en-wrapper.d.ts +15 -1
- package/dist/generated/locale-wrapper/en-wrapper.d.ts.map +1 -1
- package/dist/generated/locale-wrapper/en-wrapper.js +17 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -21
- package/dist/pd-panel-viewer.js +10 -12
- package/dist/pd-panel.js +2 -3
- package/dist/{src/popup → popup}/wizard-close-popup.js +3 -5
- package/dist/{src/popup → popup}/wizard-reload-popup.js +3 -5
- package/dist/{src/router → router}/AppMain.js +4 -5
- package/dist/{src/service-provider → service-provider}/firebase/auth.js +1 -4
- package/dist/{src/service-provider → service-provider}/firebase/firestorage-client.js +1 -1
- package/dist/{src/service-provider → service-provider}/firebase/firestore-client.js +1 -1
- package/dist/{src/service-provider → service-provider}/firebase/functions-client.js +1 -1
- package/dist/{src/service-provider → service-provider}/firebase/messagingFirebaseClient.js +2 -2
- package/dist/{src/service-provider → service-provider}/service-provider-impl.js +1 -2
- package/dist/{src/store → store}/mini-rx.store.js +1 -1
- package/dist/{src/store → store}/spa-app-effects.js +2 -2
- package/dist/{src/store → store}/spa-app-selector.js +1 -1
- package/dist/stories/pd-loading-state.stories.d.ts +3 -3
- package/dist/stories/pd-toast.stories.d.ts +3 -3
- package/dist/tmpown/pd-loading-state.d.ts.map +1 -1
- package/dist/{src/tmpown → tmpown}/pd-loading-state.js +6 -8
- package/dist/tmpown/pd-login.d.ts.map +1 -1
- package/dist/{src/tmpown → tmpown}/pd-login.js +6 -7
- package/dist/tmpown/pd-panel-viewer.d.ts.map +1 -1
- package/dist/{src/tmpown → tmpown}/pd-toast.js +5 -7
- package/package.json +29 -23
- package/dist/node_modules/@firebase/app/dist/esm/index.esm2017.js +0 -749
- package/dist/node_modules/@firebase/auth/dist/esm2017/index-68602d24.js +0 -6265
- package/dist/node_modules/@firebase/component/dist/esm/index.esm2017.js +0 -341
- package/dist/node_modules/@firebase/firestore/dist/index.esm2017.js +0 -10250
- package/dist/node_modules/@firebase/functions/dist/index.esm2017.js +0 -513
- package/dist/node_modules/@firebase/installations/dist/esm/index.esm2017.js +0 -863
- package/dist/node_modules/@firebase/logger/dist/esm/index.esm2017.js +0 -122
- package/dist/node_modules/@firebase/messaging/dist/esm/index.esm2017.js +0 -1019
- package/dist/node_modules/@firebase/storage/dist/index.esm2017.js +0 -2042
- package/dist/node_modules/@firebase/util/dist/index.esm2017.js +0 -931
- package/dist/node_modules/@firebase/webchannel-wrapper/dist/bloom-blob/esm/bloom_blob_es2018.js +0 -417
- package/dist/node_modules/@firebase/webchannel-wrapper/dist/webchannel-blob/esm/webchannel_blob_es2018.js +0 -2155
- package/dist/node_modules/@lit/reactive-element/decorators/custom-element.js +0 -14
- package/dist/node_modules/@lit/reactive-element/decorators/property.js +0 -20
- package/dist/node_modules/@lit/reactive-element/decorators/query-assigned-elements.js +0 -7
- package/dist/node_modules/@progressive-development/pd-dialog/pd-popup-dialog.js +0 -5
- package/dist/node_modules/@progressive-development/pd-dialog/pd-popup.js +0 -2
- package/dist/node_modules/@progressive-development/pd-dialog/src/PdPopup.js +0 -113
- package/dist/node_modules/@progressive-development/pd-dialog/src/PdPopupDialog.js +0 -189
- package/dist/node_modules/@progressive-development/pd-forms/pd-button.js +0 -2
- package/dist/node_modules/@progressive-development/pd-forms/pd-form-container.js +0 -2
- package/dist/node_modules/@progressive-development/pd-forms/pd-form-row.js +0 -2
- package/dist/node_modules/@progressive-development/pd-forms/pd-hover-box.js +0 -2
- package/dist/node_modules/@progressive-development/pd-forms/pd-input.js +0 -2
- package/dist/node_modules/@progressive-development/pd-forms/src/PdBaseInputElement.js +0 -86
- package/dist/node_modules/@progressive-development/pd-forms/src/PdBaseUi.js +0 -34
- package/dist/node_modules/@progressive-development/pd-forms/src/PdBaseUiInput.js +0 -227
- package/dist/node_modules/@progressive-development/pd-forms/src/PdButton.js +0 -194
- package/dist/node_modules/@progressive-development/pd-forms/src/PdFormContainer.js +0 -167
- package/dist/node_modules/@progressive-development/pd-forms/src/PdFormRow.js +0 -92
- package/dist/node_modules/@progressive-development/pd-forms/src/PdHoverBox.js +0 -108
- package/dist/node_modules/@progressive-development/pd-forms/src/PdInput.js +0 -79
- package/dist/node_modules/@progressive-development/pd-forms/src/generated/locale/be.js +0 -11
- package/dist/node_modules/@progressive-development/pd-forms/src/generated/locale/en.js +0 -11
- package/dist/node_modules/@progressive-development/pd-forms/src/shared-input-field-styles.js +0 -152
- package/dist/node_modules/@progressive-development/pd-forms/src/shared-input-styles.js +0 -64
- package/dist/node_modules/@progressive-development/pd-icon/pd-icon.js +0 -4
- package/dist/node_modules/@progressive-development/pd-icon/src/PdIcon.js +0 -596
- package/dist/node_modules/@progressive-development/pd-order/dist/locales/be.js +0 -15
- package/dist/node_modules/@progressive-development/pd-order/dist/locales/de.js +0 -15
- package/dist/node_modules/@progressive-development/pd-order/dist/locales/en.js +0 -15
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-contact/pd-contact.js +0 -2
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-contact/src/PdContact.js +0 -567
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-content/pd-collapse.js +0 -2
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-content/pd-edit-content.js +0 -2
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-content/src/PdCollapse.js +0 -136
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-content/src/PdEditContent.js +0 -224
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-dialog/pd-popup.js +0 -2
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-dialog/src/PdPopup.js +0 -113
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/pd-checkbox.js +0 -2
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/pd-form-container.js +0 -2
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/pd-form-row.js +0 -2
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/pd-hover-box.js +0 -2
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/pd-input.js +0 -2
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/pd-radio-group.js +0 -2
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdBaseInputElement.js +0 -86
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdBaseUi.js +0 -34
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdBaseUiInput.js +0 -229
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdCheckbox.js +0 -230
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdFormContainer.js +0 -167
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdFormRow.js +0 -92
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdHoverBox.js +0 -108
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdInput.js +0 -79
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdRadioGroup.js +0 -72
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/shared-input-field-styles.js +0 -152
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/shared-input-styles.js +0 -64
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-icon/pd-icon.js +0 -4
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-icon/src/PdIcon.js +0 -596
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-price/pd-pricetable.js +0 -2
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-price/src/PdPricetable.js +0 -149
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/fecha/lib/fecha.js +0 -200
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/lit/node_modules/lit-html/directive.js +0 -27
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/lit/node_modules/lit-html/directives/class-map.js +0 -36
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/lit/node_modules/lit-html/lit-html.js +0 -242
- package/dist/node_modules/@progressive-development/pd-order/dist/pd-order-contacts.js +0 -2
- package/dist/node_modules/@progressive-development/pd-order/dist/pd-order-summary.js +0 -2
- package/dist/node_modules/@progressive-development/pd-order/dist/src/PdOrderContacts.js +0 -192
- package/dist/node_modules/@progressive-development/pd-order/dist/src/PdOrderSummary.js +0 -243
- package/dist/node_modules/@progressive-development/pd-page/pd-footer.js +0 -2
- package/dist/node_modules/@progressive-development/pd-page/pd-menu.js +0 -2
- package/dist/node_modules/@progressive-development/pd-page/src/PdFooter.js +0 -141
- package/dist/node_modules/@progressive-development/pd-page/src/PdMenu.js +0 -450
- package/dist/node_modules/@progressive-development/pd-shared-styles/src/shared-color-styles.js +0 -30
- package/dist/node_modules/@progressive-development/pd-shared-styles/src/shared-font-styles.js +0 -32
- package/dist/node_modules/@progressive-development/pd-wizard/pd-wizard.js +0 -2
- package/dist/node_modules/@progressive-development/pd-wizard/src/PdSteps.js +0 -191
- package/dist/node_modules/@progressive-development/pd-wizard/src/PdWizard.js +0 -280
- package/dist/node_modules/firebase/app/dist/esm/index.esm.js +0 -35
- package/dist/node_modules/idb/build/index.js +0 -81
- package/dist/node_modules/idb/build/wrap-idb-value.js +0 -148
- package/dist/node_modules/lit/node_modules/lit-html/directive.js +0 -27
- package/dist/node_modules/lit/node_modules/lit-html/directives/class-map.js +0 -36
- package/dist/node_modules/lit/node_modules/lit-html/lit-html.js +0 -242
- package/dist/node_modules/lit-element-router/lit-element-router.js +0 -131
- package/dist/node_modules/lit-element-router/utility/router-utility.js +0 -36
- package/dist/node_modules/mini-rx-store/index.esm.js +0 -458
- package/dist/node_modules/pwa-helpers/media-query.js +0 -17
- package/dist/node_modules/rxjs/dist/esm5/internal/Observable.js +0 -100
- package/dist/node_modules/rxjs/dist/esm5/internal/Subscriber.js +0 -147
- package/dist/node_modules/rxjs/dist/esm5/internal/Subscription.js +0 -139
- package/dist/node_modules/rxjs/dist/esm5/internal/config.js +0 -10
- package/dist/node_modules/rxjs/dist/esm5/internal/observable/innerFrom.js +0 -159
- package/dist/node_modules/rxjs/dist/esm5/internal/operators/OperatorSubscriber.js +0 -52
- package/dist/node_modules/rxjs/dist/esm5/internal/operators/catchError.js +0 -28
- package/dist/node_modules/rxjs/dist/esm5/internal/operators/distinctUntilChanged.js +0 -27
- package/dist/node_modules/rxjs/dist/esm5/internal/operators/filter.js +0 -13
- package/dist/node_modules/rxjs/dist/esm5/internal/operators/map.js +0 -13
- package/dist/node_modules/rxjs/dist/esm5/internal/operators/observeOn.js +0 -26
- package/dist/node_modules/rxjs/dist/esm5/internal/operators/tap.js +0 -36
- package/dist/node_modules/rxjs/dist/esm5/internal/operators/withLatestFrom.js +0 -43
- package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js +0 -18
- package/dist/node_modules/rxjs/dist/esm5/internal/symbol/iterator.js +0 -11
- package/dist/node_modules/rxjs/dist/esm5/internal/symbol/observable.js +0 -6
- package/dist/node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js +0 -14
- package/dist/node_modules/rxjs/dist/esm5/internal/util/args.js +0 -10
- package/dist/node_modules/rxjs/dist/esm5/internal/util/arrRemove.js +0 -9
- package/dist/node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js +0 -13
- package/dist/node_modules/rxjs/dist/esm5/internal/util/errorContext.js +0 -8
- package/dist/node_modules/rxjs/dist/esm5/internal/util/executeSchedule.js +0 -23
- package/dist/node_modules/rxjs/dist/esm5/internal/util/identity.js +0 -6
- package/dist/node_modules/rxjs/dist/esm5/internal/util/isArrayLike.js +0 -6
- package/dist/node_modules/rxjs/dist/esm5/internal/util/isAsyncIterable.js +0 -7
- package/dist/node_modules/rxjs/dist/esm5/internal/util/isFunction.js +0 -6
- package/dist/node_modules/rxjs/dist/esm5/internal/util/isInteropObservable.js +0 -8
- package/dist/node_modules/rxjs/dist/esm5/internal/util/isIterable.js +0 -8
- package/dist/node_modules/rxjs/dist/esm5/internal/util/isPromise.js +0 -7
- package/dist/node_modules/rxjs/dist/esm5/internal/util/isReadableStreamLike.js +0 -46
- package/dist/node_modules/rxjs/dist/esm5/internal/util/lift.js +0 -22
- package/dist/node_modules/rxjs/dist/esm5/internal/util/noop.js +0 -5
- package/dist/node_modules/rxjs/dist/esm5/internal/util/pipe.js +0 -17
- package/dist/node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js +0 -11
- package/dist/node_modules/rxjs/dist/esm5/internal/util/throwUnobservableError.js +0 -6
- package/dist/pd-spa-helper.d.ts +0 -1
- package/dist/pd-spa-helper.d.ts.map +0 -1
- package/dist/src/generated/locale-wrapper/be-wrapper.js +0 -15
- package/dist/src/generated/locale-wrapper/de-wrapper.js +0 -13
- package/dist/src/generated/locale-wrapper/en-wrapper.js +0 -15
- /package/dist/{src/generated → generated}/locales/be.js +0 -0
- /package/dist/{src/generated → generated}/locales/de.js +0 -0
- /package/dist/{src/generated → generated}/locales/en.js +0 -0
- /package/dist/{src/helper → helper}/helper-utils.js +0 -0
- /package/dist/{src/model → model}/spa-model.js +0 -0
- /package/dist/{src/service-provider → service-provider}/mock/auth.js +0 -0
- /package/dist/{src/service-provider → service-provider}/mock/function-client.js +0 -0
- /package/dist/{src/service-provider → service-provider}/mock/storage-client.js +0 -0
- /package/dist/{src/service-provider → service-provider}/service-provider-model.js +0 -0
- /package/dist/{src/store → store}/indexDB.js +0 -0
- /package/dist/{src/store → store}/spa-app-actions.js +0 -0
- /package/dist/{src/store → store}/spa-app-reducer.js +0 -0
|
@@ -1,2042 +0,0 @@
|
|
|
1
|
-
import { _registerComponent, registerVersion, SDK_VERSION, _getProvider, getApp } from "../../app/dist/esm/index.esm2017.js";
|
|
2
|
-
import { getModularInstance, FirebaseError, getDefaultEmulatorHostnameAndPort, createMockUserToken } from "../../util/dist/index.esm2017.js";
|
|
3
|
-
import { Component } from "../../component/dist/esm/index.esm2017.js";
|
|
4
|
-
/**
|
|
5
|
-
* @license
|
|
6
|
-
* Copyright 2017 Google LLC
|
|
7
|
-
*
|
|
8
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
-
* you may not use this file except in compliance with the License.
|
|
10
|
-
* You may obtain a copy of the License at
|
|
11
|
-
*
|
|
12
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
*
|
|
14
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
-
* See the License for the specific language governing permissions and
|
|
18
|
-
* limitations under the License.
|
|
19
|
-
*/
|
|
20
|
-
const DEFAULT_HOST = "firebasestorage.googleapis.com";
|
|
21
|
-
const CONFIG_STORAGE_BUCKET_KEY = "storageBucket";
|
|
22
|
-
const DEFAULT_MAX_OPERATION_RETRY_TIME = 2 * 60 * 1e3;
|
|
23
|
-
const DEFAULT_MAX_UPLOAD_RETRY_TIME = 10 * 60 * 1e3;
|
|
24
|
-
/**
|
|
25
|
-
* @license
|
|
26
|
-
* Copyright 2017 Google LLC
|
|
27
|
-
*
|
|
28
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
29
|
-
* you may not use this file except in compliance with the License.
|
|
30
|
-
* You may obtain a copy of the License at
|
|
31
|
-
*
|
|
32
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
33
|
-
*
|
|
34
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
35
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
36
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
37
|
-
* See the License for the specific language governing permissions and
|
|
38
|
-
* limitations under the License.
|
|
39
|
-
*/
|
|
40
|
-
class StorageError extends FirebaseError {
|
|
41
|
-
/**
|
|
42
|
-
* @param code - A `StorageErrorCode` string to be prefixed with 'storage/' and
|
|
43
|
-
* added to the end of the message.
|
|
44
|
-
* @param message - Error message.
|
|
45
|
-
* @param status_ - Corresponding HTTP Status Code
|
|
46
|
-
*/
|
|
47
|
-
constructor(code, message, status_ = 0) {
|
|
48
|
-
super(prependCode(code), `Firebase Storage: ${message} (${prependCode(code)})`);
|
|
49
|
-
this.status_ = status_;
|
|
50
|
-
this.customData = { serverResponse: null };
|
|
51
|
-
this._baseMessage = this.message;
|
|
52
|
-
Object.setPrototypeOf(this, StorageError.prototype);
|
|
53
|
-
}
|
|
54
|
-
get status() {
|
|
55
|
-
return this.status_;
|
|
56
|
-
}
|
|
57
|
-
set status(status) {
|
|
58
|
-
this.status_ = status;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Compares a `StorageErrorCode` against this error's code, filtering out the prefix.
|
|
62
|
-
*/
|
|
63
|
-
_codeEquals(code) {
|
|
64
|
-
return prependCode(code) === this.code;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Optional response message that was added by the server.
|
|
68
|
-
*/
|
|
69
|
-
get serverResponse() {
|
|
70
|
-
return this.customData.serverResponse;
|
|
71
|
-
}
|
|
72
|
-
set serverResponse(serverResponse) {
|
|
73
|
-
this.customData.serverResponse = serverResponse;
|
|
74
|
-
if (this.customData.serverResponse) {
|
|
75
|
-
this.message = `${this._baseMessage}
|
|
76
|
-
${this.customData.serverResponse}`;
|
|
77
|
-
} else {
|
|
78
|
-
this.message = this._baseMessage;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
var StorageErrorCode;
|
|
83
|
-
(function(StorageErrorCode2) {
|
|
84
|
-
StorageErrorCode2["UNKNOWN"] = "unknown";
|
|
85
|
-
StorageErrorCode2["OBJECT_NOT_FOUND"] = "object-not-found";
|
|
86
|
-
StorageErrorCode2["BUCKET_NOT_FOUND"] = "bucket-not-found";
|
|
87
|
-
StorageErrorCode2["PROJECT_NOT_FOUND"] = "project-not-found";
|
|
88
|
-
StorageErrorCode2["QUOTA_EXCEEDED"] = "quota-exceeded";
|
|
89
|
-
StorageErrorCode2["UNAUTHENTICATED"] = "unauthenticated";
|
|
90
|
-
StorageErrorCode2["UNAUTHORIZED"] = "unauthorized";
|
|
91
|
-
StorageErrorCode2["UNAUTHORIZED_APP"] = "unauthorized-app";
|
|
92
|
-
StorageErrorCode2["RETRY_LIMIT_EXCEEDED"] = "retry-limit-exceeded";
|
|
93
|
-
StorageErrorCode2["INVALID_CHECKSUM"] = "invalid-checksum";
|
|
94
|
-
StorageErrorCode2["CANCELED"] = "canceled";
|
|
95
|
-
StorageErrorCode2["INVALID_EVENT_NAME"] = "invalid-event-name";
|
|
96
|
-
StorageErrorCode2["INVALID_URL"] = "invalid-url";
|
|
97
|
-
StorageErrorCode2["INVALID_DEFAULT_BUCKET"] = "invalid-default-bucket";
|
|
98
|
-
StorageErrorCode2["NO_DEFAULT_BUCKET"] = "no-default-bucket";
|
|
99
|
-
StorageErrorCode2["CANNOT_SLICE_BLOB"] = "cannot-slice-blob";
|
|
100
|
-
StorageErrorCode2["SERVER_FILE_WRONG_SIZE"] = "server-file-wrong-size";
|
|
101
|
-
StorageErrorCode2["NO_DOWNLOAD_URL"] = "no-download-url";
|
|
102
|
-
StorageErrorCode2["INVALID_ARGUMENT"] = "invalid-argument";
|
|
103
|
-
StorageErrorCode2["INVALID_ARGUMENT_COUNT"] = "invalid-argument-count";
|
|
104
|
-
StorageErrorCode2["APP_DELETED"] = "app-deleted";
|
|
105
|
-
StorageErrorCode2["INVALID_ROOT_OPERATION"] = "invalid-root-operation";
|
|
106
|
-
StorageErrorCode2["INVALID_FORMAT"] = "invalid-format";
|
|
107
|
-
StorageErrorCode2["INTERNAL_ERROR"] = "internal-error";
|
|
108
|
-
StorageErrorCode2["UNSUPPORTED_ENVIRONMENT"] = "unsupported-environment";
|
|
109
|
-
})(StorageErrorCode || (StorageErrorCode = {}));
|
|
110
|
-
function prependCode(code) {
|
|
111
|
-
return "storage/" + code;
|
|
112
|
-
}
|
|
113
|
-
function unknown() {
|
|
114
|
-
const message = "An unknown error occurred, please check the error payload for server response.";
|
|
115
|
-
return new StorageError(StorageErrorCode.UNKNOWN, message);
|
|
116
|
-
}
|
|
117
|
-
function objectNotFound(path) {
|
|
118
|
-
return new StorageError(StorageErrorCode.OBJECT_NOT_FOUND, "Object '" + path + "' does not exist.");
|
|
119
|
-
}
|
|
120
|
-
function quotaExceeded(bucket) {
|
|
121
|
-
return new StorageError(StorageErrorCode.QUOTA_EXCEEDED, "Quota for bucket '" + bucket + "' exceeded, please view quota on https://firebase.google.com/pricing/.");
|
|
122
|
-
}
|
|
123
|
-
function unauthenticated() {
|
|
124
|
-
const message = "User is not authenticated, please authenticate using Firebase Authentication and try again.";
|
|
125
|
-
return new StorageError(StorageErrorCode.UNAUTHENTICATED, message);
|
|
126
|
-
}
|
|
127
|
-
function unauthorizedApp() {
|
|
128
|
-
return new StorageError(StorageErrorCode.UNAUTHORIZED_APP, "This app does not have permission to access Firebase Storage on this project.");
|
|
129
|
-
}
|
|
130
|
-
function unauthorized(path) {
|
|
131
|
-
return new StorageError(StorageErrorCode.UNAUTHORIZED, "User does not have permission to access '" + path + "'.");
|
|
132
|
-
}
|
|
133
|
-
function retryLimitExceeded() {
|
|
134
|
-
return new StorageError(StorageErrorCode.RETRY_LIMIT_EXCEEDED, "Max retry time for operation exceeded, please try again.");
|
|
135
|
-
}
|
|
136
|
-
function canceled() {
|
|
137
|
-
return new StorageError(StorageErrorCode.CANCELED, "User canceled the upload/download.");
|
|
138
|
-
}
|
|
139
|
-
function invalidUrl(url) {
|
|
140
|
-
return new StorageError(StorageErrorCode.INVALID_URL, "Invalid URL '" + url + "'.");
|
|
141
|
-
}
|
|
142
|
-
function invalidDefaultBucket(bucket) {
|
|
143
|
-
return new StorageError(StorageErrorCode.INVALID_DEFAULT_BUCKET, "Invalid default bucket '" + bucket + "'.");
|
|
144
|
-
}
|
|
145
|
-
function noDefaultBucket() {
|
|
146
|
-
return new StorageError(StorageErrorCode.NO_DEFAULT_BUCKET, "No default bucket found. Did you set the '" + CONFIG_STORAGE_BUCKET_KEY + "' property when initializing the app?");
|
|
147
|
-
}
|
|
148
|
-
function cannotSliceBlob() {
|
|
149
|
-
return new StorageError(StorageErrorCode.CANNOT_SLICE_BLOB, "Cannot slice blob for upload. Please retry the upload.");
|
|
150
|
-
}
|
|
151
|
-
function noDownloadURL() {
|
|
152
|
-
return new StorageError(StorageErrorCode.NO_DOWNLOAD_URL, "The given file does not have any download URLs.");
|
|
153
|
-
}
|
|
154
|
-
function missingPolyFill(polyFill) {
|
|
155
|
-
return new StorageError(StorageErrorCode.UNSUPPORTED_ENVIRONMENT, `${polyFill} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`);
|
|
156
|
-
}
|
|
157
|
-
function invalidArgument(message) {
|
|
158
|
-
return new StorageError(StorageErrorCode.INVALID_ARGUMENT, message);
|
|
159
|
-
}
|
|
160
|
-
function appDeleted() {
|
|
161
|
-
return new StorageError(StorageErrorCode.APP_DELETED, "The Firebase app was deleted.");
|
|
162
|
-
}
|
|
163
|
-
function invalidRootOperation(name2) {
|
|
164
|
-
return new StorageError(StorageErrorCode.INVALID_ROOT_OPERATION, "The operation '" + name2 + "' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').");
|
|
165
|
-
}
|
|
166
|
-
function invalidFormat(format, message) {
|
|
167
|
-
return new StorageError(StorageErrorCode.INVALID_FORMAT, "String does not match format '" + format + "': " + message);
|
|
168
|
-
}
|
|
169
|
-
function internalError(message) {
|
|
170
|
-
throw new StorageError(StorageErrorCode.INTERNAL_ERROR, "Internal error: " + message);
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* @license
|
|
174
|
-
* Copyright 2017 Google LLC
|
|
175
|
-
*
|
|
176
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
177
|
-
* you may not use this file except in compliance with the License.
|
|
178
|
-
* You may obtain a copy of the License at
|
|
179
|
-
*
|
|
180
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
181
|
-
*
|
|
182
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
183
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
184
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
185
|
-
* See the License for the specific language governing permissions and
|
|
186
|
-
* limitations under the License.
|
|
187
|
-
*/
|
|
188
|
-
class Location {
|
|
189
|
-
constructor(bucket, path) {
|
|
190
|
-
this.bucket = bucket;
|
|
191
|
-
this.path_ = path;
|
|
192
|
-
}
|
|
193
|
-
get path() {
|
|
194
|
-
return this.path_;
|
|
195
|
-
}
|
|
196
|
-
get isRoot() {
|
|
197
|
-
return this.path.length === 0;
|
|
198
|
-
}
|
|
199
|
-
fullServerUrl() {
|
|
200
|
-
const encode = encodeURIComponent;
|
|
201
|
-
return "/b/" + encode(this.bucket) + "/o/" + encode(this.path);
|
|
202
|
-
}
|
|
203
|
-
bucketOnlyServerUrl() {
|
|
204
|
-
const encode = encodeURIComponent;
|
|
205
|
-
return "/b/" + encode(this.bucket) + "/o";
|
|
206
|
-
}
|
|
207
|
-
static makeFromBucketSpec(bucketString, host) {
|
|
208
|
-
let bucketLocation;
|
|
209
|
-
try {
|
|
210
|
-
bucketLocation = Location.makeFromUrl(bucketString, host);
|
|
211
|
-
} catch (e) {
|
|
212
|
-
return new Location(bucketString, "");
|
|
213
|
-
}
|
|
214
|
-
if (bucketLocation.path === "") {
|
|
215
|
-
return bucketLocation;
|
|
216
|
-
} else {
|
|
217
|
-
throw invalidDefaultBucket(bucketString);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
static makeFromUrl(url, host) {
|
|
221
|
-
let location = null;
|
|
222
|
-
const bucketDomain = "([A-Za-z0-9.\\-_]+)";
|
|
223
|
-
function gsModify(loc) {
|
|
224
|
-
if (loc.path.charAt(loc.path.length - 1) === "/") {
|
|
225
|
-
loc.path_ = loc.path_.slice(0, -1);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
const gsPath = "(/(.*))?$";
|
|
229
|
-
const gsRegex = new RegExp("^gs://" + bucketDomain + gsPath, "i");
|
|
230
|
-
const gsIndices = { bucket: 1, path: 3 };
|
|
231
|
-
function httpModify(loc) {
|
|
232
|
-
loc.path_ = decodeURIComponent(loc.path);
|
|
233
|
-
}
|
|
234
|
-
const version2 = "v[A-Za-z0-9_]+";
|
|
235
|
-
const firebaseStorageHost = host.replace(/[.]/g, "\\.");
|
|
236
|
-
const firebaseStoragePath = "(/([^?#]*).*)?$";
|
|
237
|
-
const firebaseStorageRegExp = new RegExp(`^https?://${firebaseStorageHost}/${version2}/b/${bucketDomain}/o${firebaseStoragePath}`, "i");
|
|
238
|
-
const firebaseStorageIndices = { bucket: 1, path: 3 };
|
|
239
|
-
const cloudStorageHost = host === DEFAULT_HOST ? "(?:storage.googleapis.com|storage.cloud.google.com)" : host;
|
|
240
|
-
const cloudStoragePath = "([^?#]*)";
|
|
241
|
-
const cloudStorageRegExp = new RegExp(`^https?://${cloudStorageHost}/${bucketDomain}/${cloudStoragePath}`, "i");
|
|
242
|
-
const cloudStorageIndices = { bucket: 1, path: 2 };
|
|
243
|
-
const groups = [
|
|
244
|
-
{ regex: gsRegex, indices: gsIndices, postModify: gsModify },
|
|
245
|
-
{
|
|
246
|
-
regex: firebaseStorageRegExp,
|
|
247
|
-
indices: firebaseStorageIndices,
|
|
248
|
-
postModify: httpModify
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
regex: cloudStorageRegExp,
|
|
252
|
-
indices: cloudStorageIndices,
|
|
253
|
-
postModify: httpModify
|
|
254
|
-
}
|
|
255
|
-
];
|
|
256
|
-
for (let i = 0; i < groups.length; i++) {
|
|
257
|
-
const group = groups[i];
|
|
258
|
-
const captures = group.regex.exec(url);
|
|
259
|
-
if (captures) {
|
|
260
|
-
const bucketValue = captures[group.indices.bucket];
|
|
261
|
-
let pathValue = captures[group.indices.path];
|
|
262
|
-
if (!pathValue) {
|
|
263
|
-
pathValue = "";
|
|
264
|
-
}
|
|
265
|
-
location = new Location(bucketValue, pathValue);
|
|
266
|
-
group.postModify(location);
|
|
267
|
-
break;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
if (location == null) {
|
|
271
|
-
throw invalidUrl(url);
|
|
272
|
-
}
|
|
273
|
-
return location;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
class FailRequest {
|
|
277
|
-
constructor(error) {
|
|
278
|
-
this.promise_ = Promise.reject(error);
|
|
279
|
-
}
|
|
280
|
-
/** @inheritDoc */
|
|
281
|
-
getPromise() {
|
|
282
|
-
return this.promise_;
|
|
283
|
-
}
|
|
284
|
-
/** @inheritDoc */
|
|
285
|
-
cancel(_appDelete = false) {
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* @license
|
|
290
|
-
* Copyright 2017 Google LLC
|
|
291
|
-
*
|
|
292
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
293
|
-
* you may not use this file except in compliance with the License.
|
|
294
|
-
* You may obtain a copy of the License at
|
|
295
|
-
*
|
|
296
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
297
|
-
*
|
|
298
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
299
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
300
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
301
|
-
* See the License for the specific language governing permissions and
|
|
302
|
-
* limitations under the License.
|
|
303
|
-
*/
|
|
304
|
-
function start(doRequest, backoffCompleteCb, timeout) {
|
|
305
|
-
let waitSeconds = 1;
|
|
306
|
-
let retryTimeoutId = null;
|
|
307
|
-
let globalTimeoutId = null;
|
|
308
|
-
let hitTimeout = false;
|
|
309
|
-
let cancelState = 0;
|
|
310
|
-
function canceled2() {
|
|
311
|
-
return cancelState === 2;
|
|
312
|
-
}
|
|
313
|
-
let triggeredCallback = false;
|
|
314
|
-
function triggerCallback(...args) {
|
|
315
|
-
if (!triggeredCallback) {
|
|
316
|
-
triggeredCallback = true;
|
|
317
|
-
backoffCompleteCb.apply(null, args);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
function callWithDelay(millis) {
|
|
321
|
-
retryTimeoutId = setTimeout(() => {
|
|
322
|
-
retryTimeoutId = null;
|
|
323
|
-
doRequest(responseHandler, canceled2());
|
|
324
|
-
}, millis);
|
|
325
|
-
}
|
|
326
|
-
function clearGlobalTimeout() {
|
|
327
|
-
if (globalTimeoutId) {
|
|
328
|
-
clearTimeout(globalTimeoutId);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
function responseHandler(success, ...args) {
|
|
332
|
-
if (triggeredCallback) {
|
|
333
|
-
clearGlobalTimeout();
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
if (success) {
|
|
337
|
-
clearGlobalTimeout();
|
|
338
|
-
triggerCallback.call(null, success, ...args);
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
const mustStop = canceled2() || hitTimeout;
|
|
342
|
-
if (mustStop) {
|
|
343
|
-
clearGlobalTimeout();
|
|
344
|
-
triggerCallback.call(null, success, ...args);
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
if (waitSeconds < 64) {
|
|
348
|
-
waitSeconds *= 2;
|
|
349
|
-
}
|
|
350
|
-
let waitMillis;
|
|
351
|
-
if (cancelState === 1) {
|
|
352
|
-
cancelState = 2;
|
|
353
|
-
waitMillis = 0;
|
|
354
|
-
} else {
|
|
355
|
-
waitMillis = (waitSeconds + Math.random()) * 1e3;
|
|
356
|
-
}
|
|
357
|
-
callWithDelay(waitMillis);
|
|
358
|
-
}
|
|
359
|
-
let stopped = false;
|
|
360
|
-
function stop2(wasTimeout) {
|
|
361
|
-
if (stopped) {
|
|
362
|
-
return;
|
|
363
|
-
}
|
|
364
|
-
stopped = true;
|
|
365
|
-
clearGlobalTimeout();
|
|
366
|
-
if (triggeredCallback) {
|
|
367
|
-
return;
|
|
368
|
-
}
|
|
369
|
-
if (retryTimeoutId !== null) {
|
|
370
|
-
if (!wasTimeout) {
|
|
371
|
-
cancelState = 2;
|
|
372
|
-
}
|
|
373
|
-
clearTimeout(retryTimeoutId);
|
|
374
|
-
callWithDelay(0);
|
|
375
|
-
} else {
|
|
376
|
-
if (!wasTimeout) {
|
|
377
|
-
cancelState = 1;
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
callWithDelay(0);
|
|
382
|
-
globalTimeoutId = setTimeout(() => {
|
|
383
|
-
hitTimeout = true;
|
|
384
|
-
stop2(true);
|
|
385
|
-
}, timeout);
|
|
386
|
-
return stop2;
|
|
387
|
-
}
|
|
388
|
-
function stop(id) {
|
|
389
|
-
id(false);
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* @license
|
|
393
|
-
* Copyright 2017 Google LLC
|
|
394
|
-
*
|
|
395
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
396
|
-
* you may not use this file except in compliance with the License.
|
|
397
|
-
* You may obtain a copy of the License at
|
|
398
|
-
*
|
|
399
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
400
|
-
*
|
|
401
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
402
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
403
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
404
|
-
* See the License for the specific language governing permissions and
|
|
405
|
-
* limitations under the License.
|
|
406
|
-
*/
|
|
407
|
-
function isJustDef(p) {
|
|
408
|
-
return p !== void 0;
|
|
409
|
-
}
|
|
410
|
-
function isNonArrayObject(p) {
|
|
411
|
-
return typeof p === "object" && !Array.isArray(p);
|
|
412
|
-
}
|
|
413
|
-
function isString(p) {
|
|
414
|
-
return typeof p === "string" || p instanceof String;
|
|
415
|
-
}
|
|
416
|
-
function isNativeBlob(p) {
|
|
417
|
-
return isNativeBlobDefined() && p instanceof Blob;
|
|
418
|
-
}
|
|
419
|
-
function isNativeBlobDefined() {
|
|
420
|
-
return typeof Blob !== "undefined";
|
|
421
|
-
}
|
|
422
|
-
function validateNumber(argument, minValue, maxValue, value) {
|
|
423
|
-
if (value < minValue) {
|
|
424
|
-
throw invalidArgument(`Invalid value for '${argument}'. Expected ${minValue} or greater.`);
|
|
425
|
-
}
|
|
426
|
-
if (value > maxValue) {
|
|
427
|
-
throw invalidArgument(`Invalid value for '${argument}'. Expected ${maxValue} or less.`);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* @license
|
|
432
|
-
* Copyright 2017 Google LLC
|
|
433
|
-
*
|
|
434
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
435
|
-
* you may not use this file except in compliance with the License.
|
|
436
|
-
* You may obtain a copy of the License at
|
|
437
|
-
*
|
|
438
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
439
|
-
*
|
|
440
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
441
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
442
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
443
|
-
* See the License for the specific language governing permissions and
|
|
444
|
-
* limitations under the License.
|
|
445
|
-
*/
|
|
446
|
-
function makeUrl(urlPart, host, protocol) {
|
|
447
|
-
let origin = host;
|
|
448
|
-
if (protocol == null) {
|
|
449
|
-
origin = `https://${host}`;
|
|
450
|
-
}
|
|
451
|
-
return `${protocol}://${origin}/v0${urlPart}`;
|
|
452
|
-
}
|
|
453
|
-
function makeQueryString(params) {
|
|
454
|
-
const encode = encodeURIComponent;
|
|
455
|
-
let queryPart = "?";
|
|
456
|
-
for (const key in params) {
|
|
457
|
-
if (params.hasOwnProperty(key)) {
|
|
458
|
-
const nextPart = encode(key) + "=" + encode(params[key]);
|
|
459
|
-
queryPart = queryPart + nextPart + "&";
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
queryPart = queryPart.slice(0, -1);
|
|
463
|
-
return queryPart;
|
|
464
|
-
}
|
|
465
|
-
var ErrorCode;
|
|
466
|
-
(function(ErrorCode2) {
|
|
467
|
-
ErrorCode2[ErrorCode2["NO_ERROR"] = 0] = "NO_ERROR";
|
|
468
|
-
ErrorCode2[ErrorCode2["NETWORK_ERROR"] = 1] = "NETWORK_ERROR";
|
|
469
|
-
ErrorCode2[ErrorCode2["ABORT"] = 2] = "ABORT";
|
|
470
|
-
})(ErrorCode || (ErrorCode = {}));
|
|
471
|
-
/**
|
|
472
|
-
* @license
|
|
473
|
-
* Copyright 2022 Google LLC
|
|
474
|
-
*
|
|
475
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
476
|
-
* you may not use this file except in compliance with the License.
|
|
477
|
-
* You may obtain a copy of the License at
|
|
478
|
-
*
|
|
479
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
480
|
-
*
|
|
481
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
482
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
483
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
484
|
-
* See the License for the specific language governing permissions and
|
|
485
|
-
* limitations under the License.
|
|
486
|
-
*/
|
|
487
|
-
function isRetryStatusCode(status, additionalRetryCodes) {
|
|
488
|
-
const isFiveHundredCode = status >= 500 && status < 600;
|
|
489
|
-
const extraRetryCodes = [
|
|
490
|
-
// Request Timeout: web server didn't receive full request in time.
|
|
491
|
-
408,
|
|
492
|
-
// Too Many Requests: you're getting rate-limited, basically.
|
|
493
|
-
429
|
|
494
|
-
];
|
|
495
|
-
const isExtraRetryCode = extraRetryCodes.indexOf(status) !== -1;
|
|
496
|
-
const isAdditionalRetryCode = additionalRetryCodes.indexOf(status) !== -1;
|
|
497
|
-
return isFiveHundredCode || isExtraRetryCode || isAdditionalRetryCode;
|
|
498
|
-
}
|
|
499
|
-
/**
|
|
500
|
-
* @license
|
|
501
|
-
* Copyright 2017 Google LLC
|
|
502
|
-
*
|
|
503
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
504
|
-
* you may not use this file except in compliance with the License.
|
|
505
|
-
* You may obtain a copy of the License at
|
|
506
|
-
*
|
|
507
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
508
|
-
*
|
|
509
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
510
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
511
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
512
|
-
* See the License for the specific language governing permissions and
|
|
513
|
-
* limitations under the License.
|
|
514
|
-
*/
|
|
515
|
-
class NetworkRequest {
|
|
516
|
-
constructor(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, connectionFactory_, retry = true) {
|
|
517
|
-
this.url_ = url_;
|
|
518
|
-
this.method_ = method_;
|
|
519
|
-
this.headers_ = headers_;
|
|
520
|
-
this.body_ = body_;
|
|
521
|
-
this.successCodes_ = successCodes_;
|
|
522
|
-
this.additionalRetryCodes_ = additionalRetryCodes_;
|
|
523
|
-
this.callback_ = callback_;
|
|
524
|
-
this.errorCallback_ = errorCallback_;
|
|
525
|
-
this.timeout_ = timeout_;
|
|
526
|
-
this.progressCallback_ = progressCallback_;
|
|
527
|
-
this.connectionFactory_ = connectionFactory_;
|
|
528
|
-
this.retry = retry;
|
|
529
|
-
this.pendingConnection_ = null;
|
|
530
|
-
this.backoffId_ = null;
|
|
531
|
-
this.canceled_ = false;
|
|
532
|
-
this.appDelete_ = false;
|
|
533
|
-
this.promise_ = new Promise((resolve, reject) => {
|
|
534
|
-
this.resolve_ = resolve;
|
|
535
|
-
this.reject_ = reject;
|
|
536
|
-
this.start_();
|
|
537
|
-
});
|
|
538
|
-
}
|
|
539
|
-
/**
|
|
540
|
-
* Actually starts the retry loop.
|
|
541
|
-
*/
|
|
542
|
-
start_() {
|
|
543
|
-
const doTheRequest = (backoffCallback, canceled2) => {
|
|
544
|
-
if (canceled2) {
|
|
545
|
-
backoffCallback(false, new RequestEndStatus(false, null, true));
|
|
546
|
-
return;
|
|
547
|
-
}
|
|
548
|
-
const connection = this.connectionFactory_();
|
|
549
|
-
this.pendingConnection_ = connection;
|
|
550
|
-
const progressListener = (progressEvent) => {
|
|
551
|
-
const loaded = progressEvent.loaded;
|
|
552
|
-
const total = progressEvent.lengthComputable ? progressEvent.total : -1;
|
|
553
|
-
if (this.progressCallback_ !== null) {
|
|
554
|
-
this.progressCallback_(loaded, total);
|
|
555
|
-
}
|
|
556
|
-
};
|
|
557
|
-
if (this.progressCallback_ !== null) {
|
|
558
|
-
connection.addUploadProgressListener(progressListener);
|
|
559
|
-
}
|
|
560
|
-
connection.send(this.url_, this.method_, this.body_, this.headers_).then(() => {
|
|
561
|
-
if (this.progressCallback_ !== null) {
|
|
562
|
-
connection.removeUploadProgressListener(progressListener);
|
|
563
|
-
}
|
|
564
|
-
this.pendingConnection_ = null;
|
|
565
|
-
const hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR;
|
|
566
|
-
const status = connection.getStatus();
|
|
567
|
-
if (!hitServer || isRetryStatusCode(status, this.additionalRetryCodes_) && this.retry) {
|
|
568
|
-
const wasCanceled = connection.getErrorCode() === ErrorCode.ABORT;
|
|
569
|
-
backoffCallback(false, new RequestEndStatus(false, null, wasCanceled));
|
|
570
|
-
return;
|
|
571
|
-
}
|
|
572
|
-
const successCode = this.successCodes_.indexOf(status) !== -1;
|
|
573
|
-
backoffCallback(true, new RequestEndStatus(successCode, connection));
|
|
574
|
-
});
|
|
575
|
-
};
|
|
576
|
-
const backoffDone = (requestWentThrough, status) => {
|
|
577
|
-
const resolve = this.resolve_;
|
|
578
|
-
const reject = this.reject_;
|
|
579
|
-
const connection = status.connection;
|
|
580
|
-
if (status.wasSuccessCode) {
|
|
581
|
-
try {
|
|
582
|
-
const result = this.callback_(connection, connection.getResponse());
|
|
583
|
-
if (isJustDef(result)) {
|
|
584
|
-
resolve(result);
|
|
585
|
-
} else {
|
|
586
|
-
resolve();
|
|
587
|
-
}
|
|
588
|
-
} catch (e) {
|
|
589
|
-
reject(e);
|
|
590
|
-
}
|
|
591
|
-
} else {
|
|
592
|
-
if (connection !== null) {
|
|
593
|
-
const err = unknown();
|
|
594
|
-
err.serverResponse = connection.getErrorText();
|
|
595
|
-
if (this.errorCallback_) {
|
|
596
|
-
reject(this.errorCallback_(connection, err));
|
|
597
|
-
} else {
|
|
598
|
-
reject(err);
|
|
599
|
-
}
|
|
600
|
-
} else {
|
|
601
|
-
if (status.canceled) {
|
|
602
|
-
const err = this.appDelete_ ? appDeleted() : canceled();
|
|
603
|
-
reject(err);
|
|
604
|
-
} else {
|
|
605
|
-
const err = retryLimitExceeded();
|
|
606
|
-
reject(err);
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
};
|
|
611
|
-
if (this.canceled_) {
|
|
612
|
-
backoffDone(false, new RequestEndStatus(false, null, true));
|
|
613
|
-
} else {
|
|
614
|
-
this.backoffId_ = start(doTheRequest, backoffDone, this.timeout_);
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
/** @inheritDoc */
|
|
618
|
-
getPromise() {
|
|
619
|
-
return this.promise_;
|
|
620
|
-
}
|
|
621
|
-
/** @inheritDoc */
|
|
622
|
-
cancel(appDelete) {
|
|
623
|
-
this.canceled_ = true;
|
|
624
|
-
this.appDelete_ = appDelete || false;
|
|
625
|
-
if (this.backoffId_ !== null) {
|
|
626
|
-
stop(this.backoffId_);
|
|
627
|
-
}
|
|
628
|
-
if (this.pendingConnection_ !== null) {
|
|
629
|
-
this.pendingConnection_.abort();
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
class RequestEndStatus {
|
|
634
|
-
constructor(wasSuccessCode, connection, canceled2) {
|
|
635
|
-
this.wasSuccessCode = wasSuccessCode;
|
|
636
|
-
this.connection = connection;
|
|
637
|
-
this.canceled = !!canceled2;
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
function addAuthHeader_(headers, authToken) {
|
|
641
|
-
if (authToken !== null && authToken.length > 0) {
|
|
642
|
-
headers["Authorization"] = "Firebase " + authToken;
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
function addVersionHeader_(headers, firebaseVersion) {
|
|
646
|
-
headers["X-Firebase-Storage-Version"] = "webjs/" + (firebaseVersion !== null && firebaseVersion !== void 0 ? firebaseVersion : "AppManager");
|
|
647
|
-
}
|
|
648
|
-
function addGmpidHeader_(headers, appId) {
|
|
649
|
-
if (appId) {
|
|
650
|
-
headers["X-Firebase-GMPID"] = appId;
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
function addAppCheckHeader_(headers, appCheckToken) {
|
|
654
|
-
if (appCheckToken !== null) {
|
|
655
|
-
headers["X-Firebase-AppCheck"] = appCheckToken;
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
function makeRequest(requestInfo, appId, authToken, appCheckToken, requestFactory, firebaseVersion, retry = true) {
|
|
659
|
-
const queryPart = makeQueryString(requestInfo.urlParams);
|
|
660
|
-
const url = requestInfo.url + queryPart;
|
|
661
|
-
const headers = Object.assign({}, requestInfo.headers);
|
|
662
|
-
addGmpidHeader_(headers, appId);
|
|
663
|
-
addAuthHeader_(headers, authToken);
|
|
664
|
-
addVersionHeader_(headers, firebaseVersion);
|
|
665
|
-
addAppCheckHeader_(headers, appCheckToken);
|
|
666
|
-
return new NetworkRequest(url, requestInfo.method, headers, requestInfo.body, requestInfo.successCodes, requestInfo.additionalRetryCodes, requestInfo.handler, requestInfo.errorHandler, requestInfo.timeout, requestInfo.progressCallback, requestFactory, retry);
|
|
667
|
-
}
|
|
668
|
-
/**
|
|
669
|
-
* @license
|
|
670
|
-
* Copyright 2017 Google LLC
|
|
671
|
-
*
|
|
672
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
673
|
-
* you may not use this file except in compliance with the License.
|
|
674
|
-
* You may obtain a copy of the License at
|
|
675
|
-
*
|
|
676
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
677
|
-
*
|
|
678
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
679
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
680
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
681
|
-
* See the License for the specific language governing permissions and
|
|
682
|
-
* limitations under the License.
|
|
683
|
-
*/
|
|
684
|
-
function getBlobBuilder() {
|
|
685
|
-
if (typeof BlobBuilder !== "undefined") {
|
|
686
|
-
return BlobBuilder;
|
|
687
|
-
} else if (typeof WebKitBlobBuilder !== "undefined") {
|
|
688
|
-
return WebKitBlobBuilder;
|
|
689
|
-
} else {
|
|
690
|
-
return void 0;
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
function getBlob$1(...args) {
|
|
694
|
-
const BlobBuilder2 = getBlobBuilder();
|
|
695
|
-
if (BlobBuilder2 !== void 0) {
|
|
696
|
-
const bb = new BlobBuilder2();
|
|
697
|
-
for (let i = 0; i < args.length; i++) {
|
|
698
|
-
bb.append(args[i]);
|
|
699
|
-
}
|
|
700
|
-
return bb.getBlob();
|
|
701
|
-
} else {
|
|
702
|
-
if (isNativeBlobDefined()) {
|
|
703
|
-
return new Blob(args);
|
|
704
|
-
} else {
|
|
705
|
-
throw new StorageError(StorageErrorCode.UNSUPPORTED_ENVIRONMENT, "This browser doesn't seem to support creating Blobs");
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
function sliceBlob(blob, start2, end) {
|
|
710
|
-
if (blob.webkitSlice) {
|
|
711
|
-
return blob.webkitSlice(start2, end);
|
|
712
|
-
} else if (blob.mozSlice) {
|
|
713
|
-
return blob.mozSlice(start2, end);
|
|
714
|
-
} else if (blob.slice) {
|
|
715
|
-
return blob.slice(start2, end);
|
|
716
|
-
}
|
|
717
|
-
return null;
|
|
718
|
-
}
|
|
719
|
-
/**
|
|
720
|
-
* @license
|
|
721
|
-
* Copyright 2021 Google LLC
|
|
722
|
-
*
|
|
723
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
724
|
-
* you may not use this file except in compliance with the License.
|
|
725
|
-
* You may obtain a copy of the License at
|
|
726
|
-
*
|
|
727
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
728
|
-
*
|
|
729
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
730
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
731
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
732
|
-
* See the License for the specific language governing permissions and
|
|
733
|
-
* limitations under the License.
|
|
734
|
-
*/
|
|
735
|
-
function decodeBase64(encoded) {
|
|
736
|
-
if (typeof atob === "undefined") {
|
|
737
|
-
throw missingPolyFill("base-64");
|
|
738
|
-
}
|
|
739
|
-
return atob(encoded);
|
|
740
|
-
}
|
|
741
|
-
/**
|
|
742
|
-
* @license
|
|
743
|
-
* Copyright 2017 Google LLC
|
|
744
|
-
*
|
|
745
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
746
|
-
* you may not use this file except in compliance with the License.
|
|
747
|
-
* You may obtain a copy of the License at
|
|
748
|
-
*
|
|
749
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
750
|
-
*
|
|
751
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
752
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
753
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
754
|
-
* See the License for the specific language governing permissions and
|
|
755
|
-
* limitations under the License.
|
|
756
|
-
*/
|
|
757
|
-
const StringFormat = {
|
|
758
|
-
/**
|
|
759
|
-
* Indicates the string should be interpreted "raw", that is, as normal text.
|
|
760
|
-
* The string will be interpreted as UTF-16, then uploaded as a UTF-8 byte
|
|
761
|
-
* sequence.
|
|
762
|
-
* Example: The string 'Hello! \\ud83d\\ude0a' becomes the byte sequence
|
|
763
|
-
* 48 65 6c 6c 6f 21 20 f0 9f 98 8a
|
|
764
|
-
*/
|
|
765
|
-
RAW: "raw",
|
|
766
|
-
/**
|
|
767
|
-
* Indicates the string should be interpreted as base64-encoded data.
|
|
768
|
-
* Padding characters (trailing '='s) are optional.
|
|
769
|
-
* Example: The string 'rWmO++E6t7/rlw==' becomes the byte sequence
|
|
770
|
-
* ad 69 8e fb e1 3a b7 bf eb 97
|
|
771
|
-
*/
|
|
772
|
-
BASE64: "base64",
|
|
773
|
-
/**
|
|
774
|
-
* Indicates the string should be interpreted as base64url-encoded data.
|
|
775
|
-
* Padding characters (trailing '='s) are optional.
|
|
776
|
-
* Example: The string 'rWmO--E6t7_rlw==' becomes the byte sequence
|
|
777
|
-
* ad 69 8e fb e1 3a b7 bf eb 97
|
|
778
|
-
*/
|
|
779
|
-
BASE64URL: "base64url",
|
|
780
|
-
/**
|
|
781
|
-
* Indicates the string is a data URL, such as one obtained from
|
|
782
|
-
* canvas.toDataURL().
|
|
783
|
-
* Example: the string 'data:application/octet-stream;base64,aaaa'
|
|
784
|
-
* becomes the byte sequence
|
|
785
|
-
* 69 a6 9a
|
|
786
|
-
* (the content-type "application/octet-stream" is also applied, but can
|
|
787
|
-
* be overridden in the metadata object).
|
|
788
|
-
*/
|
|
789
|
-
DATA_URL: "data_url"
|
|
790
|
-
};
|
|
791
|
-
class StringData {
|
|
792
|
-
constructor(data, contentType) {
|
|
793
|
-
this.data = data;
|
|
794
|
-
this.contentType = contentType || null;
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
function dataFromString(format, stringData) {
|
|
798
|
-
switch (format) {
|
|
799
|
-
case StringFormat.RAW:
|
|
800
|
-
return new StringData(utf8Bytes_(stringData));
|
|
801
|
-
case StringFormat.BASE64:
|
|
802
|
-
case StringFormat.BASE64URL:
|
|
803
|
-
return new StringData(base64Bytes_(format, stringData));
|
|
804
|
-
case StringFormat.DATA_URL:
|
|
805
|
-
return new StringData(dataURLBytes_(stringData), dataURLContentType_(stringData));
|
|
806
|
-
}
|
|
807
|
-
throw unknown();
|
|
808
|
-
}
|
|
809
|
-
function utf8Bytes_(value) {
|
|
810
|
-
const b = [];
|
|
811
|
-
for (let i = 0; i < value.length; i++) {
|
|
812
|
-
let c = value.charCodeAt(i);
|
|
813
|
-
if (c <= 127) {
|
|
814
|
-
b.push(c);
|
|
815
|
-
} else {
|
|
816
|
-
if (c <= 2047) {
|
|
817
|
-
b.push(192 | c >> 6, 128 | c & 63);
|
|
818
|
-
} else {
|
|
819
|
-
if ((c & 64512) === 55296) {
|
|
820
|
-
const valid = i < value.length - 1 && (value.charCodeAt(i + 1) & 64512) === 56320;
|
|
821
|
-
if (!valid) {
|
|
822
|
-
b.push(239, 191, 189);
|
|
823
|
-
} else {
|
|
824
|
-
const hi = c;
|
|
825
|
-
const lo = value.charCodeAt(++i);
|
|
826
|
-
c = 65536 | (hi & 1023) << 10 | lo & 1023;
|
|
827
|
-
b.push(240 | c >> 18, 128 | c >> 12 & 63, 128 | c >> 6 & 63, 128 | c & 63);
|
|
828
|
-
}
|
|
829
|
-
} else {
|
|
830
|
-
if ((c & 64512) === 56320) {
|
|
831
|
-
b.push(239, 191, 189);
|
|
832
|
-
} else {
|
|
833
|
-
b.push(224 | c >> 12, 128 | c >> 6 & 63, 128 | c & 63);
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
return new Uint8Array(b);
|
|
840
|
-
}
|
|
841
|
-
function percentEncodedBytes_(value) {
|
|
842
|
-
let decoded;
|
|
843
|
-
try {
|
|
844
|
-
decoded = decodeURIComponent(value);
|
|
845
|
-
} catch (e) {
|
|
846
|
-
throw invalidFormat(StringFormat.DATA_URL, "Malformed data URL.");
|
|
847
|
-
}
|
|
848
|
-
return utf8Bytes_(decoded);
|
|
849
|
-
}
|
|
850
|
-
function base64Bytes_(format, value) {
|
|
851
|
-
switch (format) {
|
|
852
|
-
case StringFormat.BASE64: {
|
|
853
|
-
const hasMinus = value.indexOf("-") !== -1;
|
|
854
|
-
const hasUnder = value.indexOf("_") !== -1;
|
|
855
|
-
if (hasMinus || hasUnder) {
|
|
856
|
-
const invalidChar = hasMinus ? "-" : "_";
|
|
857
|
-
throw invalidFormat(format, "Invalid character '" + invalidChar + "' found: is it base64url encoded?");
|
|
858
|
-
}
|
|
859
|
-
break;
|
|
860
|
-
}
|
|
861
|
-
case StringFormat.BASE64URL: {
|
|
862
|
-
const hasPlus = value.indexOf("+") !== -1;
|
|
863
|
-
const hasSlash = value.indexOf("/") !== -1;
|
|
864
|
-
if (hasPlus || hasSlash) {
|
|
865
|
-
const invalidChar = hasPlus ? "+" : "/";
|
|
866
|
-
throw invalidFormat(format, "Invalid character '" + invalidChar + "' found: is it base64 encoded?");
|
|
867
|
-
}
|
|
868
|
-
value = value.replace(/-/g, "+").replace(/_/g, "/");
|
|
869
|
-
break;
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
let bytes;
|
|
873
|
-
try {
|
|
874
|
-
bytes = decodeBase64(value);
|
|
875
|
-
} catch (e) {
|
|
876
|
-
if (e.message.includes("polyfill")) {
|
|
877
|
-
throw e;
|
|
878
|
-
}
|
|
879
|
-
throw invalidFormat(format, "Invalid character found");
|
|
880
|
-
}
|
|
881
|
-
const array = new Uint8Array(bytes.length);
|
|
882
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
883
|
-
array[i] = bytes.charCodeAt(i);
|
|
884
|
-
}
|
|
885
|
-
return array;
|
|
886
|
-
}
|
|
887
|
-
class DataURLParts {
|
|
888
|
-
constructor(dataURL) {
|
|
889
|
-
this.base64 = false;
|
|
890
|
-
this.contentType = null;
|
|
891
|
-
const matches = dataURL.match(/^data:([^,]+)?,/);
|
|
892
|
-
if (matches === null) {
|
|
893
|
-
throw invalidFormat(StringFormat.DATA_URL, "Must be formatted 'data:[<mediatype>][;base64],<data>");
|
|
894
|
-
}
|
|
895
|
-
const middle = matches[1] || null;
|
|
896
|
-
if (middle != null) {
|
|
897
|
-
this.base64 = endsWith(middle, ";base64");
|
|
898
|
-
this.contentType = this.base64 ? middle.substring(0, middle.length - ";base64".length) : middle;
|
|
899
|
-
}
|
|
900
|
-
this.rest = dataURL.substring(dataURL.indexOf(",") + 1);
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
function dataURLBytes_(dataUrl) {
|
|
904
|
-
const parts = new DataURLParts(dataUrl);
|
|
905
|
-
if (parts.base64) {
|
|
906
|
-
return base64Bytes_(StringFormat.BASE64, parts.rest);
|
|
907
|
-
} else {
|
|
908
|
-
return percentEncodedBytes_(parts.rest);
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
function dataURLContentType_(dataUrl) {
|
|
912
|
-
const parts = new DataURLParts(dataUrl);
|
|
913
|
-
return parts.contentType;
|
|
914
|
-
}
|
|
915
|
-
function endsWith(s, end) {
|
|
916
|
-
const longEnough = s.length >= end.length;
|
|
917
|
-
if (!longEnough) {
|
|
918
|
-
return false;
|
|
919
|
-
}
|
|
920
|
-
return s.substring(s.length - end.length) === end;
|
|
921
|
-
}
|
|
922
|
-
/**
|
|
923
|
-
* @license
|
|
924
|
-
* Copyright 2017 Google LLC
|
|
925
|
-
*
|
|
926
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
927
|
-
* you may not use this file except in compliance with the License.
|
|
928
|
-
* You may obtain a copy of the License at
|
|
929
|
-
*
|
|
930
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
931
|
-
*
|
|
932
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
933
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
934
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
935
|
-
* See the License for the specific language governing permissions and
|
|
936
|
-
* limitations under the License.
|
|
937
|
-
*/
|
|
938
|
-
class FbsBlob {
|
|
939
|
-
constructor(data, elideCopy) {
|
|
940
|
-
let size = 0;
|
|
941
|
-
let blobType = "";
|
|
942
|
-
if (isNativeBlob(data)) {
|
|
943
|
-
this.data_ = data;
|
|
944
|
-
size = data.size;
|
|
945
|
-
blobType = data.type;
|
|
946
|
-
} else if (data instanceof ArrayBuffer) {
|
|
947
|
-
if (elideCopy) {
|
|
948
|
-
this.data_ = new Uint8Array(data);
|
|
949
|
-
} else {
|
|
950
|
-
this.data_ = new Uint8Array(data.byteLength);
|
|
951
|
-
this.data_.set(new Uint8Array(data));
|
|
952
|
-
}
|
|
953
|
-
size = this.data_.length;
|
|
954
|
-
} else if (data instanceof Uint8Array) {
|
|
955
|
-
if (elideCopy) {
|
|
956
|
-
this.data_ = data;
|
|
957
|
-
} else {
|
|
958
|
-
this.data_ = new Uint8Array(data.length);
|
|
959
|
-
this.data_.set(data);
|
|
960
|
-
}
|
|
961
|
-
size = data.length;
|
|
962
|
-
}
|
|
963
|
-
this.size_ = size;
|
|
964
|
-
this.type_ = blobType;
|
|
965
|
-
}
|
|
966
|
-
size() {
|
|
967
|
-
return this.size_;
|
|
968
|
-
}
|
|
969
|
-
type() {
|
|
970
|
-
return this.type_;
|
|
971
|
-
}
|
|
972
|
-
slice(startByte, endByte) {
|
|
973
|
-
if (isNativeBlob(this.data_)) {
|
|
974
|
-
const realBlob = this.data_;
|
|
975
|
-
const sliced = sliceBlob(realBlob, startByte, endByte);
|
|
976
|
-
if (sliced === null) {
|
|
977
|
-
return null;
|
|
978
|
-
}
|
|
979
|
-
return new FbsBlob(sliced);
|
|
980
|
-
} else {
|
|
981
|
-
const slice = new Uint8Array(this.data_.buffer, startByte, endByte - startByte);
|
|
982
|
-
return new FbsBlob(slice, true);
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
static getBlob(...args) {
|
|
986
|
-
if (isNativeBlobDefined()) {
|
|
987
|
-
const blobby = args.map((val) => {
|
|
988
|
-
if (val instanceof FbsBlob) {
|
|
989
|
-
return val.data_;
|
|
990
|
-
} else {
|
|
991
|
-
return val;
|
|
992
|
-
}
|
|
993
|
-
});
|
|
994
|
-
return new FbsBlob(getBlob$1.apply(null, blobby));
|
|
995
|
-
} else {
|
|
996
|
-
const uint8Arrays = args.map((val) => {
|
|
997
|
-
if (isString(val)) {
|
|
998
|
-
return dataFromString(StringFormat.RAW, val).data;
|
|
999
|
-
} else {
|
|
1000
|
-
return val.data_;
|
|
1001
|
-
}
|
|
1002
|
-
});
|
|
1003
|
-
let finalLength = 0;
|
|
1004
|
-
uint8Arrays.forEach((array) => {
|
|
1005
|
-
finalLength += array.byteLength;
|
|
1006
|
-
});
|
|
1007
|
-
const merged = new Uint8Array(finalLength);
|
|
1008
|
-
let index = 0;
|
|
1009
|
-
uint8Arrays.forEach((array) => {
|
|
1010
|
-
for (let i = 0; i < array.length; i++) {
|
|
1011
|
-
merged[index++] = array[i];
|
|
1012
|
-
}
|
|
1013
|
-
});
|
|
1014
|
-
return new FbsBlob(merged, true);
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
uploadData() {
|
|
1018
|
-
return this.data_;
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
/**
|
|
1022
|
-
* @license
|
|
1023
|
-
* Copyright 2017 Google LLC
|
|
1024
|
-
*
|
|
1025
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1026
|
-
* you may not use this file except in compliance with the License.
|
|
1027
|
-
* You may obtain a copy of the License at
|
|
1028
|
-
*
|
|
1029
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1030
|
-
*
|
|
1031
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1032
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1033
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1034
|
-
* See the License for the specific language governing permissions and
|
|
1035
|
-
* limitations under the License.
|
|
1036
|
-
*/
|
|
1037
|
-
function jsonObjectOrNull(s) {
|
|
1038
|
-
let obj;
|
|
1039
|
-
try {
|
|
1040
|
-
obj = JSON.parse(s);
|
|
1041
|
-
} catch (e) {
|
|
1042
|
-
return null;
|
|
1043
|
-
}
|
|
1044
|
-
if (isNonArrayObject(obj)) {
|
|
1045
|
-
return obj;
|
|
1046
|
-
} else {
|
|
1047
|
-
return null;
|
|
1048
|
-
}
|
|
1049
|
-
}
|
|
1050
|
-
/**
|
|
1051
|
-
* @license
|
|
1052
|
-
* Copyright 2017 Google LLC
|
|
1053
|
-
*
|
|
1054
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1055
|
-
* you may not use this file except in compliance with the License.
|
|
1056
|
-
* You may obtain a copy of the License at
|
|
1057
|
-
*
|
|
1058
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1059
|
-
*
|
|
1060
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1061
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1062
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1063
|
-
* See the License for the specific language governing permissions and
|
|
1064
|
-
* limitations under the License.
|
|
1065
|
-
*/
|
|
1066
|
-
function parent(path) {
|
|
1067
|
-
if (path.length === 0) {
|
|
1068
|
-
return null;
|
|
1069
|
-
}
|
|
1070
|
-
const index = path.lastIndexOf("/");
|
|
1071
|
-
if (index === -1) {
|
|
1072
|
-
return "";
|
|
1073
|
-
}
|
|
1074
|
-
const newPath = path.slice(0, index);
|
|
1075
|
-
return newPath;
|
|
1076
|
-
}
|
|
1077
|
-
function child(path, childPath) {
|
|
1078
|
-
const canonicalChildPath = childPath.split("/").filter((component) => component.length > 0).join("/");
|
|
1079
|
-
if (path.length === 0) {
|
|
1080
|
-
return canonicalChildPath;
|
|
1081
|
-
} else {
|
|
1082
|
-
return path + "/" + canonicalChildPath;
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
function lastComponent(path) {
|
|
1086
|
-
const index = path.lastIndexOf("/", path.length - 2);
|
|
1087
|
-
if (index === -1) {
|
|
1088
|
-
return path;
|
|
1089
|
-
} else {
|
|
1090
|
-
return path.slice(index + 1);
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
/**
|
|
1094
|
-
* @license
|
|
1095
|
-
* Copyright 2017 Google LLC
|
|
1096
|
-
*
|
|
1097
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1098
|
-
* you may not use this file except in compliance with the License.
|
|
1099
|
-
* You may obtain a copy of the License at
|
|
1100
|
-
*
|
|
1101
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1102
|
-
*
|
|
1103
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1104
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1105
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1106
|
-
* See the License for the specific language governing permissions and
|
|
1107
|
-
* limitations under the License.
|
|
1108
|
-
*/
|
|
1109
|
-
function noXform_(metadata, value) {
|
|
1110
|
-
return value;
|
|
1111
|
-
}
|
|
1112
|
-
class Mapping {
|
|
1113
|
-
constructor(server, local, writable, xform) {
|
|
1114
|
-
this.server = server;
|
|
1115
|
-
this.local = local || server;
|
|
1116
|
-
this.writable = !!writable;
|
|
1117
|
-
this.xform = xform || noXform_;
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
let mappings_ = null;
|
|
1121
|
-
function xformPath(fullPath) {
|
|
1122
|
-
if (!isString(fullPath) || fullPath.length < 2) {
|
|
1123
|
-
return fullPath;
|
|
1124
|
-
} else {
|
|
1125
|
-
return lastComponent(fullPath);
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
function getMappings() {
|
|
1129
|
-
if (mappings_) {
|
|
1130
|
-
return mappings_;
|
|
1131
|
-
}
|
|
1132
|
-
const mappings = [];
|
|
1133
|
-
mappings.push(new Mapping("bucket"));
|
|
1134
|
-
mappings.push(new Mapping("generation"));
|
|
1135
|
-
mappings.push(new Mapping("metageneration"));
|
|
1136
|
-
mappings.push(new Mapping("name", "fullPath", true));
|
|
1137
|
-
function mappingsXformPath(_metadata, fullPath) {
|
|
1138
|
-
return xformPath(fullPath);
|
|
1139
|
-
}
|
|
1140
|
-
const nameMapping = new Mapping("name");
|
|
1141
|
-
nameMapping.xform = mappingsXformPath;
|
|
1142
|
-
mappings.push(nameMapping);
|
|
1143
|
-
function xformSize(_metadata, size) {
|
|
1144
|
-
if (size !== void 0) {
|
|
1145
|
-
return Number(size);
|
|
1146
|
-
} else {
|
|
1147
|
-
return size;
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
const sizeMapping = new Mapping("size");
|
|
1151
|
-
sizeMapping.xform = xformSize;
|
|
1152
|
-
mappings.push(sizeMapping);
|
|
1153
|
-
mappings.push(new Mapping("timeCreated"));
|
|
1154
|
-
mappings.push(new Mapping("updated"));
|
|
1155
|
-
mappings.push(new Mapping("md5Hash", null, true));
|
|
1156
|
-
mappings.push(new Mapping("cacheControl", null, true));
|
|
1157
|
-
mappings.push(new Mapping("contentDisposition", null, true));
|
|
1158
|
-
mappings.push(new Mapping("contentEncoding", null, true));
|
|
1159
|
-
mappings.push(new Mapping("contentLanguage", null, true));
|
|
1160
|
-
mappings.push(new Mapping("contentType", null, true));
|
|
1161
|
-
mappings.push(new Mapping("metadata", "customMetadata", true));
|
|
1162
|
-
mappings_ = mappings;
|
|
1163
|
-
return mappings_;
|
|
1164
|
-
}
|
|
1165
|
-
function addRef(metadata, service) {
|
|
1166
|
-
function generateRef() {
|
|
1167
|
-
const bucket = metadata["bucket"];
|
|
1168
|
-
const path = metadata["fullPath"];
|
|
1169
|
-
const loc = new Location(bucket, path);
|
|
1170
|
-
return service._makeStorageReference(loc);
|
|
1171
|
-
}
|
|
1172
|
-
Object.defineProperty(metadata, "ref", { get: generateRef });
|
|
1173
|
-
}
|
|
1174
|
-
function fromResource(service, resource, mappings) {
|
|
1175
|
-
const metadata = {};
|
|
1176
|
-
metadata["type"] = "file";
|
|
1177
|
-
const len = mappings.length;
|
|
1178
|
-
for (let i = 0; i < len; i++) {
|
|
1179
|
-
const mapping = mappings[i];
|
|
1180
|
-
metadata[mapping.local] = mapping.xform(metadata, resource[mapping.server]);
|
|
1181
|
-
}
|
|
1182
|
-
addRef(metadata, service);
|
|
1183
|
-
return metadata;
|
|
1184
|
-
}
|
|
1185
|
-
function fromResourceString(service, resourceString, mappings) {
|
|
1186
|
-
const obj = jsonObjectOrNull(resourceString);
|
|
1187
|
-
if (obj === null) {
|
|
1188
|
-
return null;
|
|
1189
|
-
}
|
|
1190
|
-
const resource = obj;
|
|
1191
|
-
return fromResource(service, resource, mappings);
|
|
1192
|
-
}
|
|
1193
|
-
function downloadUrlFromResourceString(metadata, resourceString, host, protocol) {
|
|
1194
|
-
const obj = jsonObjectOrNull(resourceString);
|
|
1195
|
-
if (obj === null) {
|
|
1196
|
-
return null;
|
|
1197
|
-
}
|
|
1198
|
-
if (!isString(obj["downloadTokens"])) {
|
|
1199
|
-
return null;
|
|
1200
|
-
}
|
|
1201
|
-
const tokens = obj["downloadTokens"];
|
|
1202
|
-
if (tokens.length === 0) {
|
|
1203
|
-
return null;
|
|
1204
|
-
}
|
|
1205
|
-
const encode = encodeURIComponent;
|
|
1206
|
-
const tokensList = tokens.split(",");
|
|
1207
|
-
const urls = tokensList.map((token) => {
|
|
1208
|
-
const bucket = metadata["bucket"];
|
|
1209
|
-
const path = metadata["fullPath"];
|
|
1210
|
-
const urlPart = "/b/" + encode(bucket) + "/o/" + encode(path);
|
|
1211
|
-
const base = makeUrl(urlPart, host, protocol);
|
|
1212
|
-
const queryString = makeQueryString({
|
|
1213
|
-
alt: "media",
|
|
1214
|
-
token
|
|
1215
|
-
});
|
|
1216
|
-
return base + queryString;
|
|
1217
|
-
});
|
|
1218
|
-
return urls[0];
|
|
1219
|
-
}
|
|
1220
|
-
function toResourceString(metadata, mappings) {
|
|
1221
|
-
const resource = {};
|
|
1222
|
-
const len = mappings.length;
|
|
1223
|
-
for (let i = 0; i < len; i++) {
|
|
1224
|
-
const mapping = mappings[i];
|
|
1225
|
-
if (mapping.writable) {
|
|
1226
|
-
resource[mapping.server] = metadata[mapping.local];
|
|
1227
|
-
}
|
|
1228
|
-
}
|
|
1229
|
-
return JSON.stringify(resource);
|
|
1230
|
-
}
|
|
1231
|
-
/**
|
|
1232
|
-
* @license
|
|
1233
|
-
* Copyright 2019 Google LLC
|
|
1234
|
-
*
|
|
1235
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1236
|
-
* you may not use this file except in compliance with the License.
|
|
1237
|
-
* You may obtain a copy of the License at
|
|
1238
|
-
*
|
|
1239
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1240
|
-
*
|
|
1241
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1242
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1243
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1244
|
-
* See the License for the specific language governing permissions and
|
|
1245
|
-
* limitations under the License.
|
|
1246
|
-
*/
|
|
1247
|
-
const PREFIXES_KEY = "prefixes";
|
|
1248
|
-
const ITEMS_KEY = "items";
|
|
1249
|
-
function fromBackendResponse(service, bucket, resource) {
|
|
1250
|
-
const listResult = {
|
|
1251
|
-
prefixes: [],
|
|
1252
|
-
items: [],
|
|
1253
|
-
nextPageToken: resource["nextPageToken"]
|
|
1254
|
-
};
|
|
1255
|
-
if (resource[PREFIXES_KEY]) {
|
|
1256
|
-
for (const path of resource[PREFIXES_KEY]) {
|
|
1257
|
-
const pathWithoutTrailingSlash = path.replace(/\/$/, "");
|
|
1258
|
-
const reference = service._makeStorageReference(new Location(bucket, pathWithoutTrailingSlash));
|
|
1259
|
-
listResult.prefixes.push(reference);
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
if (resource[ITEMS_KEY]) {
|
|
1263
|
-
for (const item of resource[ITEMS_KEY]) {
|
|
1264
|
-
const reference = service._makeStorageReference(new Location(bucket, item["name"]));
|
|
1265
|
-
listResult.items.push(reference);
|
|
1266
|
-
}
|
|
1267
|
-
}
|
|
1268
|
-
return listResult;
|
|
1269
|
-
}
|
|
1270
|
-
function fromResponseString(service, bucket, resourceString) {
|
|
1271
|
-
const obj = jsonObjectOrNull(resourceString);
|
|
1272
|
-
if (obj === null) {
|
|
1273
|
-
return null;
|
|
1274
|
-
}
|
|
1275
|
-
const resource = obj;
|
|
1276
|
-
return fromBackendResponse(service, bucket, resource);
|
|
1277
|
-
}
|
|
1278
|
-
class RequestInfo {
|
|
1279
|
-
constructor(url, method, handler, timeout) {
|
|
1280
|
-
this.url = url;
|
|
1281
|
-
this.method = method;
|
|
1282
|
-
this.handler = handler;
|
|
1283
|
-
this.timeout = timeout;
|
|
1284
|
-
this.urlParams = {};
|
|
1285
|
-
this.headers = {};
|
|
1286
|
-
this.body = null;
|
|
1287
|
-
this.errorHandler = null;
|
|
1288
|
-
this.progressCallback = null;
|
|
1289
|
-
this.successCodes = [200];
|
|
1290
|
-
this.additionalRetryCodes = [];
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
/**
|
|
1294
|
-
* @license
|
|
1295
|
-
* Copyright 2017 Google LLC
|
|
1296
|
-
*
|
|
1297
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1298
|
-
* you may not use this file except in compliance with the License.
|
|
1299
|
-
* You may obtain a copy of the License at
|
|
1300
|
-
*
|
|
1301
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1302
|
-
*
|
|
1303
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1304
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1305
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1306
|
-
* See the License for the specific language governing permissions and
|
|
1307
|
-
* limitations under the License.
|
|
1308
|
-
*/
|
|
1309
|
-
function handlerCheck(cndn) {
|
|
1310
|
-
if (!cndn) {
|
|
1311
|
-
throw unknown();
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
function metadataHandler(service, mappings) {
|
|
1315
|
-
function handler(xhr, text) {
|
|
1316
|
-
const metadata = fromResourceString(service, text, mappings);
|
|
1317
|
-
handlerCheck(metadata !== null);
|
|
1318
|
-
return metadata;
|
|
1319
|
-
}
|
|
1320
|
-
return handler;
|
|
1321
|
-
}
|
|
1322
|
-
function listHandler(service, bucket) {
|
|
1323
|
-
function handler(xhr, text) {
|
|
1324
|
-
const listResult = fromResponseString(service, bucket, text);
|
|
1325
|
-
handlerCheck(listResult !== null);
|
|
1326
|
-
return listResult;
|
|
1327
|
-
}
|
|
1328
|
-
return handler;
|
|
1329
|
-
}
|
|
1330
|
-
function downloadUrlHandler(service, mappings) {
|
|
1331
|
-
function handler(xhr, text) {
|
|
1332
|
-
const metadata = fromResourceString(service, text, mappings);
|
|
1333
|
-
handlerCheck(metadata !== null);
|
|
1334
|
-
return downloadUrlFromResourceString(metadata, text, service.host, service._protocol);
|
|
1335
|
-
}
|
|
1336
|
-
return handler;
|
|
1337
|
-
}
|
|
1338
|
-
function sharedErrorHandler(location) {
|
|
1339
|
-
function errorHandler(xhr, err) {
|
|
1340
|
-
let newErr;
|
|
1341
|
-
if (xhr.getStatus() === 401) {
|
|
1342
|
-
if (
|
|
1343
|
-
// This exact message string is the only consistent part of the
|
|
1344
|
-
// server's error response that identifies it as an App Check error.
|
|
1345
|
-
xhr.getErrorText().includes("Firebase App Check token is invalid")
|
|
1346
|
-
) {
|
|
1347
|
-
newErr = unauthorizedApp();
|
|
1348
|
-
} else {
|
|
1349
|
-
newErr = unauthenticated();
|
|
1350
|
-
}
|
|
1351
|
-
} else {
|
|
1352
|
-
if (xhr.getStatus() === 402) {
|
|
1353
|
-
newErr = quotaExceeded(location.bucket);
|
|
1354
|
-
} else {
|
|
1355
|
-
if (xhr.getStatus() === 403) {
|
|
1356
|
-
newErr = unauthorized(location.path);
|
|
1357
|
-
} else {
|
|
1358
|
-
newErr = err;
|
|
1359
|
-
}
|
|
1360
|
-
}
|
|
1361
|
-
}
|
|
1362
|
-
newErr.status = xhr.getStatus();
|
|
1363
|
-
newErr.serverResponse = err.serverResponse;
|
|
1364
|
-
return newErr;
|
|
1365
|
-
}
|
|
1366
|
-
return errorHandler;
|
|
1367
|
-
}
|
|
1368
|
-
function objectErrorHandler(location) {
|
|
1369
|
-
const shared = sharedErrorHandler(location);
|
|
1370
|
-
function errorHandler(xhr, err) {
|
|
1371
|
-
let newErr = shared(xhr, err);
|
|
1372
|
-
if (xhr.getStatus() === 404) {
|
|
1373
|
-
newErr = objectNotFound(location.path);
|
|
1374
|
-
}
|
|
1375
|
-
newErr.serverResponse = err.serverResponse;
|
|
1376
|
-
return newErr;
|
|
1377
|
-
}
|
|
1378
|
-
return errorHandler;
|
|
1379
|
-
}
|
|
1380
|
-
function getMetadata$2(service, location, mappings) {
|
|
1381
|
-
const urlPart = location.fullServerUrl();
|
|
1382
|
-
const url = makeUrl(urlPart, service.host, service._protocol);
|
|
1383
|
-
const method = "GET";
|
|
1384
|
-
const timeout = service.maxOperationRetryTime;
|
|
1385
|
-
const requestInfo = new RequestInfo(url, method, metadataHandler(service, mappings), timeout);
|
|
1386
|
-
requestInfo.errorHandler = objectErrorHandler(location);
|
|
1387
|
-
return requestInfo;
|
|
1388
|
-
}
|
|
1389
|
-
function list$2(service, location, delimiter, pageToken, maxResults) {
|
|
1390
|
-
const urlParams = {};
|
|
1391
|
-
if (location.isRoot) {
|
|
1392
|
-
urlParams["prefix"] = "";
|
|
1393
|
-
} else {
|
|
1394
|
-
urlParams["prefix"] = location.path + "/";
|
|
1395
|
-
}
|
|
1396
|
-
if (delimiter.length > 0) {
|
|
1397
|
-
urlParams["delimiter"] = delimiter;
|
|
1398
|
-
}
|
|
1399
|
-
if (pageToken) {
|
|
1400
|
-
urlParams["pageToken"] = pageToken;
|
|
1401
|
-
}
|
|
1402
|
-
if (maxResults) {
|
|
1403
|
-
urlParams["maxResults"] = maxResults;
|
|
1404
|
-
}
|
|
1405
|
-
const urlPart = location.bucketOnlyServerUrl();
|
|
1406
|
-
const url = makeUrl(urlPart, service.host, service._protocol);
|
|
1407
|
-
const method = "GET";
|
|
1408
|
-
const timeout = service.maxOperationRetryTime;
|
|
1409
|
-
const requestInfo = new RequestInfo(url, method, listHandler(service, location.bucket), timeout);
|
|
1410
|
-
requestInfo.urlParams = urlParams;
|
|
1411
|
-
requestInfo.errorHandler = sharedErrorHandler(location);
|
|
1412
|
-
return requestInfo;
|
|
1413
|
-
}
|
|
1414
|
-
function getDownloadUrl(service, location, mappings) {
|
|
1415
|
-
const urlPart = location.fullServerUrl();
|
|
1416
|
-
const url = makeUrl(urlPart, service.host, service._protocol);
|
|
1417
|
-
const method = "GET";
|
|
1418
|
-
const timeout = service.maxOperationRetryTime;
|
|
1419
|
-
const requestInfo = new RequestInfo(url, method, downloadUrlHandler(service, mappings), timeout);
|
|
1420
|
-
requestInfo.errorHandler = objectErrorHandler(location);
|
|
1421
|
-
return requestInfo;
|
|
1422
|
-
}
|
|
1423
|
-
function deleteObject$2(service, location) {
|
|
1424
|
-
const urlPart = location.fullServerUrl();
|
|
1425
|
-
const url = makeUrl(urlPart, service.host, service._protocol);
|
|
1426
|
-
const method = "DELETE";
|
|
1427
|
-
const timeout = service.maxOperationRetryTime;
|
|
1428
|
-
function handler(_xhr, _text) {
|
|
1429
|
-
}
|
|
1430
|
-
const requestInfo = new RequestInfo(url, method, handler, timeout);
|
|
1431
|
-
requestInfo.successCodes = [200, 204];
|
|
1432
|
-
requestInfo.errorHandler = objectErrorHandler(location);
|
|
1433
|
-
return requestInfo;
|
|
1434
|
-
}
|
|
1435
|
-
function determineContentType_(metadata, blob) {
|
|
1436
|
-
return metadata && metadata["contentType"] || blob && blob.type() || "application/octet-stream";
|
|
1437
|
-
}
|
|
1438
|
-
function metadataForUpload_(location, blob, metadata) {
|
|
1439
|
-
const metadataClone = Object.assign({}, metadata);
|
|
1440
|
-
metadataClone["fullPath"] = location.path;
|
|
1441
|
-
metadataClone["size"] = blob.size();
|
|
1442
|
-
if (!metadataClone["contentType"]) {
|
|
1443
|
-
metadataClone["contentType"] = determineContentType_(null, blob);
|
|
1444
|
-
}
|
|
1445
|
-
return metadataClone;
|
|
1446
|
-
}
|
|
1447
|
-
function multipartUpload(service, location, mappings, blob, metadata) {
|
|
1448
|
-
const urlPart = location.bucketOnlyServerUrl();
|
|
1449
|
-
const headers = {
|
|
1450
|
-
"X-Goog-Upload-Protocol": "multipart"
|
|
1451
|
-
};
|
|
1452
|
-
function genBoundary() {
|
|
1453
|
-
let str = "";
|
|
1454
|
-
for (let i = 0; i < 2; i++) {
|
|
1455
|
-
str = str + Math.random().toString().slice(2);
|
|
1456
|
-
}
|
|
1457
|
-
return str;
|
|
1458
|
-
}
|
|
1459
|
-
const boundary = genBoundary();
|
|
1460
|
-
headers["Content-Type"] = "multipart/related; boundary=" + boundary;
|
|
1461
|
-
const metadata_ = metadataForUpload_(location, blob, metadata);
|
|
1462
|
-
const metadataString = toResourceString(metadata_, mappings);
|
|
1463
|
-
const preBlobPart = "--" + boundary + "\r\nContent-Type: application/json; charset=utf-8\r\n\r\n" + metadataString + "\r\n--" + boundary + "\r\nContent-Type: " + metadata_["contentType"] + "\r\n\r\n";
|
|
1464
|
-
const postBlobPart = "\r\n--" + boundary + "--";
|
|
1465
|
-
const body = FbsBlob.getBlob(preBlobPart, blob, postBlobPart);
|
|
1466
|
-
if (body === null) {
|
|
1467
|
-
throw cannotSliceBlob();
|
|
1468
|
-
}
|
|
1469
|
-
const urlParams = { name: metadata_["fullPath"] };
|
|
1470
|
-
const url = makeUrl(urlPart, service.host, service._protocol);
|
|
1471
|
-
const method = "POST";
|
|
1472
|
-
const timeout = service.maxUploadRetryTime;
|
|
1473
|
-
const requestInfo = new RequestInfo(url, method, metadataHandler(service, mappings), timeout);
|
|
1474
|
-
requestInfo.urlParams = urlParams;
|
|
1475
|
-
requestInfo.headers = headers;
|
|
1476
|
-
requestInfo.body = body.uploadData();
|
|
1477
|
-
requestInfo.errorHandler = sharedErrorHandler(location);
|
|
1478
|
-
return requestInfo;
|
|
1479
|
-
}
|
|
1480
|
-
class XhrConnection {
|
|
1481
|
-
constructor() {
|
|
1482
|
-
this.sent_ = false;
|
|
1483
|
-
this.xhr_ = new XMLHttpRequest();
|
|
1484
|
-
this.initXhr();
|
|
1485
|
-
this.errorCode_ = ErrorCode.NO_ERROR;
|
|
1486
|
-
this.sendPromise_ = new Promise((resolve) => {
|
|
1487
|
-
this.xhr_.addEventListener("abort", () => {
|
|
1488
|
-
this.errorCode_ = ErrorCode.ABORT;
|
|
1489
|
-
resolve();
|
|
1490
|
-
});
|
|
1491
|
-
this.xhr_.addEventListener("error", () => {
|
|
1492
|
-
this.errorCode_ = ErrorCode.NETWORK_ERROR;
|
|
1493
|
-
resolve();
|
|
1494
|
-
});
|
|
1495
|
-
this.xhr_.addEventListener("load", () => {
|
|
1496
|
-
resolve();
|
|
1497
|
-
});
|
|
1498
|
-
});
|
|
1499
|
-
}
|
|
1500
|
-
send(url, method, body, headers) {
|
|
1501
|
-
if (this.sent_) {
|
|
1502
|
-
throw internalError("cannot .send() more than once");
|
|
1503
|
-
}
|
|
1504
|
-
this.sent_ = true;
|
|
1505
|
-
this.xhr_.open(method, url, true);
|
|
1506
|
-
if (headers !== void 0) {
|
|
1507
|
-
for (const key in headers) {
|
|
1508
|
-
if (headers.hasOwnProperty(key)) {
|
|
1509
|
-
this.xhr_.setRequestHeader(key, headers[key].toString());
|
|
1510
|
-
}
|
|
1511
|
-
}
|
|
1512
|
-
}
|
|
1513
|
-
if (body !== void 0) {
|
|
1514
|
-
this.xhr_.send(body);
|
|
1515
|
-
} else {
|
|
1516
|
-
this.xhr_.send();
|
|
1517
|
-
}
|
|
1518
|
-
return this.sendPromise_;
|
|
1519
|
-
}
|
|
1520
|
-
getErrorCode() {
|
|
1521
|
-
if (!this.sent_) {
|
|
1522
|
-
throw internalError("cannot .getErrorCode() before sending");
|
|
1523
|
-
}
|
|
1524
|
-
return this.errorCode_;
|
|
1525
|
-
}
|
|
1526
|
-
getStatus() {
|
|
1527
|
-
if (!this.sent_) {
|
|
1528
|
-
throw internalError("cannot .getStatus() before sending");
|
|
1529
|
-
}
|
|
1530
|
-
try {
|
|
1531
|
-
return this.xhr_.status;
|
|
1532
|
-
} catch (e) {
|
|
1533
|
-
return -1;
|
|
1534
|
-
}
|
|
1535
|
-
}
|
|
1536
|
-
getResponse() {
|
|
1537
|
-
if (!this.sent_) {
|
|
1538
|
-
throw internalError("cannot .getResponse() before sending");
|
|
1539
|
-
}
|
|
1540
|
-
return this.xhr_.response;
|
|
1541
|
-
}
|
|
1542
|
-
getErrorText() {
|
|
1543
|
-
if (!this.sent_) {
|
|
1544
|
-
throw internalError("cannot .getErrorText() before sending");
|
|
1545
|
-
}
|
|
1546
|
-
return this.xhr_.statusText;
|
|
1547
|
-
}
|
|
1548
|
-
/** Aborts the request. */
|
|
1549
|
-
abort() {
|
|
1550
|
-
this.xhr_.abort();
|
|
1551
|
-
}
|
|
1552
|
-
getResponseHeader(header) {
|
|
1553
|
-
return this.xhr_.getResponseHeader(header);
|
|
1554
|
-
}
|
|
1555
|
-
addUploadProgressListener(listener) {
|
|
1556
|
-
if (this.xhr_.upload != null) {
|
|
1557
|
-
this.xhr_.upload.addEventListener("progress", listener);
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
|
-
removeUploadProgressListener(listener) {
|
|
1561
|
-
if (this.xhr_.upload != null) {
|
|
1562
|
-
this.xhr_.upload.removeEventListener("progress", listener);
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1565
|
-
}
|
|
1566
|
-
class XhrTextConnection extends XhrConnection {
|
|
1567
|
-
initXhr() {
|
|
1568
|
-
this.xhr_.responseType = "text";
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
|
-
function newTextConnection() {
|
|
1572
|
-
return new XhrTextConnection();
|
|
1573
|
-
}
|
|
1574
|
-
/**
|
|
1575
|
-
* @license
|
|
1576
|
-
* Copyright 2019 Google LLC
|
|
1577
|
-
*
|
|
1578
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1579
|
-
* you may not use this file except in compliance with the License.
|
|
1580
|
-
* You may obtain a copy of the License at
|
|
1581
|
-
*
|
|
1582
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1583
|
-
*
|
|
1584
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1585
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1586
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1587
|
-
* See the License for the specific language governing permissions and
|
|
1588
|
-
* limitations under the License.
|
|
1589
|
-
*/
|
|
1590
|
-
class Reference {
|
|
1591
|
-
constructor(_service, location) {
|
|
1592
|
-
this._service = _service;
|
|
1593
|
-
if (location instanceof Location) {
|
|
1594
|
-
this._location = location;
|
|
1595
|
-
} else {
|
|
1596
|
-
this._location = Location.makeFromUrl(location, _service.host);
|
|
1597
|
-
}
|
|
1598
|
-
}
|
|
1599
|
-
/**
|
|
1600
|
-
* Returns the URL for the bucket and path this object references,
|
|
1601
|
-
* in the form gs://<bucket>/<object-path>
|
|
1602
|
-
* @override
|
|
1603
|
-
*/
|
|
1604
|
-
toString() {
|
|
1605
|
-
return "gs://" + this._location.bucket + "/" + this._location.path;
|
|
1606
|
-
}
|
|
1607
|
-
_newRef(service, location) {
|
|
1608
|
-
return new Reference(service, location);
|
|
1609
|
-
}
|
|
1610
|
-
/**
|
|
1611
|
-
* A reference to the root of this object's bucket.
|
|
1612
|
-
*/
|
|
1613
|
-
get root() {
|
|
1614
|
-
const location = new Location(this._location.bucket, "");
|
|
1615
|
-
return this._newRef(this._service, location);
|
|
1616
|
-
}
|
|
1617
|
-
/**
|
|
1618
|
-
* The name of the bucket containing this reference's object.
|
|
1619
|
-
*/
|
|
1620
|
-
get bucket() {
|
|
1621
|
-
return this._location.bucket;
|
|
1622
|
-
}
|
|
1623
|
-
/**
|
|
1624
|
-
* The full path of this object.
|
|
1625
|
-
*/
|
|
1626
|
-
get fullPath() {
|
|
1627
|
-
return this._location.path;
|
|
1628
|
-
}
|
|
1629
|
-
/**
|
|
1630
|
-
* The short name of this object, which is the last component of the full path.
|
|
1631
|
-
* For example, if fullPath is 'full/path/image.png', name is 'image.png'.
|
|
1632
|
-
*/
|
|
1633
|
-
get name() {
|
|
1634
|
-
return lastComponent(this._location.path);
|
|
1635
|
-
}
|
|
1636
|
-
/**
|
|
1637
|
-
* The `StorageService` instance this `StorageReference` is associated with.
|
|
1638
|
-
*/
|
|
1639
|
-
get storage() {
|
|
1640
|
-
return this._service;
|
|
1641
|
-
}
|
|
1642
|
-
/**
|
|
1643
|
-
* A `StorageReference` pointing to the parent location of this `StorageReference`, or null if
|
|
1644
|
-
* this reference is the root.
|
|
1645
|
-
*/
|
|
1646
|
-
get parent() {
|
|
1647
|
-
const newPath = parent(this._location.path);
|
|
1648
|
-
if (newPath === null) {
|
|
1649
|
-
return null;
|
|
1650
|
-
}
|
|
1651
|
-
const location = new Location(this._location.bucket, newPath);
|
|
1652
|
-
return new Reference(this._service, location);
|
|
1653
|
-
}
|
|
1654
|
-
/**
|
|
1655
|
-
* Utility function to throw an error in methods that do not accept a root reference.
|
|
1656
|
-
*/
|
|
1657
|
-
_throwIfRoot(name2) {
|
|
1658
|
-
if (this._location.path === "") {
|
|
1659
|
-
throw invalidRootOperation(name2);
|
|
1660
|
-
}
|
|
1661
|
-
}
|
|
1662
|
-
}
|
|
1663
|
-
function uploadBytes$1(ref2, data, metadata) {
|
|
1664
|
-
ref2._throwIfRoot("uploadBytes");
|
|
1665
|
-
const requestInfo = multipartUpload(ref2.storage, ref2._location, getMappings(), new FbsBlob(data, true), metadata);
|
|
1666
|
-
return ref2.storage.makeRequestWithTokens(requestInfo, newTextConnection).then((finalMetadata) => {
|
|
1667
|
-
return {
|
|
1668
|
-
metadata: finalMetadata,
|
|
1669
|
-
ref: ref2
|
|
1670
|
-
};
|
|
1671
|
-
});
|
|
1672
|
-
}
|
|
1673
|
-
function uploadString$1(ref2, value, format = StringFormat.RAW, metadata) {
|
|
1674
|
-
ref2._throwIfRoot("uploadString");
|
|
1675
|
-
const data = dataFromString(format, value);
|
|
1676
|
-
const metadataClone = Object.assign({}, metadata);
|
|
1677
|
-
if (metadataClone["contentType"] == null && data.contentType != null) {
|
|
1678
|
-
metadataClone["contentType"] = data.contentType;
|
|
1679
|
-
}
|
|
1680
|
-
return uploadBytes$1(ref2, data.data, metadataClone);
|
|
1681
|
-
}
|
|
1682
|
-
function listAll$1(ref2) {
|
|
1683
|
-
const accumulator = {
|
|
1684
|
-
prefixes: [],
|
|
1685
|
-
items: []
|
|
1686
|
-
};
|
|
1687
|
-
return listAllHelper(ref2, accumulator).then(() => accumulator);
|
|
1688
|
-
}
|
|
1689
|
-
async function listAllHelper(ref2, accumulator, pageToken) {
|
|
1690
|
-
const opt = {
|
|
1691
|
-
// maxResults is 1000 by default.
|
|
1692
|
-
pageToken
|
|
1693
|
-
};
|
|
1694
|
-
const nextPage = await list$1(ref2, opt);
|
|
1695
|
-
accumulator.prefixes.push(...nextPage.prefixes);
|
|
1696
|
-
accumulator.items.push(...nextPage.items);
|
|
1697
|
-
if (nextPage.nextPageToken != null) {
|
|
1698
|
-
await listAllHelper(ref2, accumulator, nextPage.nextPageToken);
|
|
1699
|
-
}
|
|
1700
|
-
}
|
|
1701
|
-
function list$1(ref2, options) {
|
|
1702
|
-
if (options != null) {
|
|
1703
|
-
if (typeof options.maxResults === "number") {
|
|
1704
|
-
validateNumber(
|
|
1705
|
-
"options.maxResults",
|
|
1706
|
-
/* minValue= */
|
|
1707
|
-
1,
|
|
1708
|
-
/* maxValue= */
|
|
1709
|
-
1e3,
|
|
1710
|
-
options.maxResults
|
|
1711
|
-
);
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
|
-
const op = options;
|
|
1715
|
-
const requestInfo = list$2(
|
|
1716
|
-
ref2.storage,
|
|
1717
|
-
ref2._location,
|
|
1718
|
-
/*delimiter= */
|
|
1719
|
-
"/",
|
|
1720
|
-
op.pageToken,
|
|
1721
|
-
op.maxResults
|
|
1722
|
-
);
|
|
1723
|
-
return ref2.storage.makeRequestWithTokens(requestInfo, newTextConnection);
|
|
1724
|
-
}
|
|
1725
|
-
function getMetadata$1(ref2) {
|
|
1726
|
-
ref2._throwIfRoot("getMetadata");
|
|
1727
|
-
const requestInfo = getMetadata$2(ref2.storage, ref2._location, getMappings());
|
|
1728
|
-
return ref2.storage.makeRequestWithTokens(requestInfo, newTextConnection);
|
|
1729
|
-
}
|
|
1730
|
-
function getDownloadURL$1(ref2) {
|
|
1731
|
-
ref2._throwIfRoot("getDownloadURL");
|
|
1732
|
-
const requestInfo = getDownloadUrl(ref2.storage, ref2._location, getMappings());
|
|
1733
|
-
return ref2.storage.makeRequestWithTokens(requestInfo, newTextConnection).then((url) => {
|
|
1734
|
-
if (url === null) {
|
|
1735
|
-
throw noDownloadURL();
|
|
1736
|
-
}
|
|
1737
|
-
return url;
|
|
1738
|
-
});
|
|
1739
|
-
}
|
|
1740
|
-
function deleteObject$1(ref2) {
|
|
1741
|
-
ref2._throwIfRoot("deleteObject");
|
|
1742
|
-
const requestInfo = deleteObject$2(ref2.storage, ref2._location);
|
|
1743
|
-
return ref2.storage.makeRequestWithTokens(requestInfo, newTextConnection);
|
|
1744
|
-
}
|
|
1745
|
-
function _getChild$1(ref2, childPath) {
|
|
1746
|
-
const newPath = child(ref2._location.path, childPath);
|
|
1747
|
-
const location = new Location(ref2._location.bucket, newPath);
|
|
1748
|
-
return new Reference(ref2.storage, location);
|
|
1749
|
-
}
|
|
1750
|
-
/**
|
|
1751
|
-
* @license
|
|
1752
|
-
* Copyright 2017 Google LLC
|
|
1753
|
-
*
|
|
1754
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1755
|
-
* you may not use this file except in compliance with the License.
|
|
1756
|
-
* You may obtain a copy of the License at
|
|
1757
|
-
*
|
|
1758
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1759
|
-
*
|
|
1760
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1761
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1762
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1763
|
-
* See the License for the specific language governing permissions and
|
|
1764
|
-
* limitations under the License.
|
|
1765
|
-
*/
|
|
1766
|
-
function isUrl(path) {
|
|
1767
|
-
return /^[A-Za-z]+:\/\//.test(path);
|
|
1768
|
-
}
|
|
1769
|
-
function refFromURL(service, url) {
|
|
1770
|
-
return new Reference(service, url);
|
|
1771
|
-
}
|
|
1772
|
-
function refFromPath(ref2, path) {
|
|
1773
|
-
if (ref2 instanceof FirebaseStorageImpl) {
|
|
1774
|
-
const service = ref2;
|
|
1775
|
-
if (service._bucket == null) {
|
|
1776
|
-
throw noDefaultBucket();
|
|
1777
|
-
}
|
|
1778
|
-
const reference = new Reference(service, service._bucket);
|
|
1779
|
-
if (path != null) {
|
|
1780
|
-
return refFromPath(reference, path);
|
|
1781
|
-
} else {
|
|
1782
|
-
return reference;
|
|
1783
|
-
}
|
|
1784
|
-
} else {
|
|
1785
|
-
if (path !== void 0) {
|
|
1786
|
-
return _getChild$1(ref2, path);
|
|
1787
|
-
} else {
|
|
1788
|
-
return ref2;
|
|
1789
|
-
}
|
|
1790
|
-
}
|
|
1791
|
-
}
|
|
1792
|
-
function ref$1(serviceOrRef, pathOrUrl) {
|
|
1793
|
-
if (pathOrUrl && isUrl(pathOrUrl)) {
|
|
1794
|
-
if (serviceOrRef instanceof FirebaseStorageImpl) {
|
|
1795
|
-
return refFromURL(serviceOrRef, pathOrUrl);
|
|
1796
|
-
} else {
|
|
1797
|
-
throw invalidArgument("To use ref(service, url), the first argument must be a Storage instance.");
|
|
1798
|
-
}
|
|
1799
|
-
} else {
|
|
1800
|
-
return refFromPath(serviceOrRef, pathOrUrl);
|
|
1801
|
-
}
|
|
1802
|
-
}
|
|
1803
|
-
function extractBucket(host, config) {
|
|
1804
|
-
const bucketString = config === null || config === void 0 ? void 0 : config[CONFIG_STORAGE_BUCKET_KEY];
|
|
1805
|
-
if (bucketString == null) {
|
|
1806
|
-
return null;
|
|
1807
|
-
}
|
|
1808
|
-
return Location.makeFromBucketSpec(bucketString, host);
|
|
1809
|
-
}
|
|
1810
|
-
function connectStorageEmulator$1(storage, host, port, options = {}) {
|
|
1811
|
-
storage.host = `${host}:${port}`;
|
|
1812
|
-
storage._protocol = "http";
|
|
1813
|
-
const { mockUserToken } = options;
|
|
1814
|
-
if (mockUserToken) {
|
|
1815
|
-
storage._overrideAuthToken = typeof mockUserToken === "string" ? mockUserToken : createMockUserToken(mockUserToken, storage.app.options.projectId);
|
|
1816
|
-
}
|
|
1817
|
-
}
|
|
1818
|
-
class FirebaseStorageImpl {
|
|
1819
|
-
constructor(app, _authProvider, _appCheckProvider, _url, _firebaseVersion) {
|
|
1820
|
-
this.app = app;
|
|
1821
|
-
this._authProvider = _authProvider;
|
|
1822
|
-
this._appCheckProvider = _appCheckProvider;
|
|
1823
|
-
this._url = _url;
|
|
1824
|
-
this._firebaseVersion = _firebaseVersion;
|
|
1825
|
-
this._bucket = null;
|
|
1826
|
-
this._host = DEFAULT_HOST;
|
|
1827
|
-
this._protocol = "https";
|
|
1828
|
-
this._appId = null;
|
|
1829
|
-
this._deleted = false;
|
|
1830
|
-
this._maxOperationRetryTime = DEFAULT_MAX_OPERATION_RETRY_TIME;
|
|
1831
|
-
this._maxUploadRetryTime = DEFAULT_MAX_UPLOAD_RETRY_TIME;
|
|
1832
|
-
this._requests = /* @__PURE__ */ new Set();
|
|
1833
|
-
if (_url != null) {
|
|
1834
|
-
this._bucket = Location.makeFromBucketSpec(_url, this._host);
|
|
1835
|
-
} else {
|
|
1836
|
-
this._bucket = extractBucket(this._host, this.app.options);
|
|
1837
|
-
}
|
|
1838
|
-
}
|
|
1839
|
-
/**
|
|
1840
|
-
* The host string for this service, in the form of `host` or
|
|
1841
|
-
* `host:port`.
|
|
1842
|
-
*/
|
|
1843
|
-
get host() {
|
|
1844
|
-
return this._host;
|
|
1845
|
-
}
|
|
1846
|
-
set host(host) {
|
|
1847
|
-
this._host = host;
|
|
1848
|
-
if (this._url != null) {
|
|
1849
|
-
this._bucket = Location.makeFromBucketSpec(this._url, host);
|
|
1850
|
-
} else {
|
|
1851
|
-
this._bucket = extractBucket(host, this.app.options);
|
|
1852
|
-
}
|
|
1853
|
-
}
|
|
1854
|
-
/**
|
|
1855
|
-
* The maximum time to retry uploads in milliseconds.
|
|
1856
|
-
*/
|
|
1857
|
-
get maxUploadRetryTime() {
|
|
1858
|
-
return this._maxUploadRetryTime;
|
|
1859
|
-
}
|
|
1860
|
-
set maxUploadRetryTime(time) {
|
|
1861
|
-
validateNumber(
|
|
1862
|
-
"time",
|
|
1863
|
-
/* minValue=*/
|
|
1864
|
-
0,
|
|
1865
|
-
/* maxValue= */
|
|
1866
|
-
Number.POSITIVE_INFINITY,
|
|
1867
|
-
time
|
|
1868
|
-
);
|
|
1869
|
-
this._maxUploadRetryTime = time;
|
|
1870
|
-
}
|
|
1871
|
-
/**
|
|
1872
|
-
* The maximum time to retry operations other than uploads or downloads in
|
|
1873
|
-
* milliseconds.
|
|
1874
|
-
*/
|
|
1875
|
-
get maxOperationRetryTime() {
|
|
1876
|
-
return this._maxOperationRetryTime;
|
|
1877
|
-
}
|
|
1878
|
-
set maxOperationRetryTime(time) {
|
|
1879
|
-
validateNumber(
|
|
1880
|
-
"time",
|
|
1881
|
-
/* minValue=*/
|
|
1882
|
-
0,
|
|
1883
|
-
/* maxValue= */
|
|
1884
|
-
Number.POSITIVE_INFINITY,
|
|
1885
|
-
time
|
|
1886
|
-
);
|
|
1887
|
-
this._maxOperationRetryTime = time;
|
|
1888
|
-
}
|
|
1889
|
-
async _getAuthToken() {
|
|
1890
|
-
if (this._overrideAuthToken) {
|
|
1891
|
-
return this._overrideAuthToken;
|
|
1892
|
-
}
|
|
1893
|
-
const auth = this._authProvider.getImmediate({ optional: true });
|
|
1894
|
-
if (auth) {
|
|
1895
|
-
const tokenData = await auth.getToken();
|
|
1896
|
-
if (tokenData !== null) {
|
|
1897
|
-
return tokenData.accessToken;
|
|
1898
|
-
}
|
|
1899
|
-
}
|
|
1900
|
-
return null;
|
|
1901
|
-
}
|
|
1902
|
-
async _getAppCheckToken() {
|
|
1903
|
-
const appCheck = this._appCheckProvider.getImmediate({ optional: true });
|
|
1904
|
-
if (appCheck) {
|
|
1905
|
-
const result = await appCheck.getToken();
|
|
1906
|
-
return result.token;
|
|
1907
|
-
}
|
|
1908
|
-
return null;
|
|
1909
|
-
}
|
|
1910
|
-
/**
|
|
1911
|
-
* Stop running requests and prevent more from being created.
|
|
1912
|
-
*/
|
|
1913
|
-
_delete() {
|
|
1914
|
-
if (!this._deleted) {
|
|
1915
|
-
this._deleted = true;
|
|
1916
|
-
this._requests.forEach((request) => request.cancel());
|
|
1917
|
-
this._requests.clear();
|
|
1918
|
-
}
|
|
1919
|
-
return Promise.resolve();
|
|
1920
|
-
}
|
|
1921
|
-
/**
|
|
1922
|
-
* Returns a new firebaseStorage.Reference object referencing this StorageService
|
|
1923
|
-
* at the given Location.
|
|
1924
|
-
*/
|
|
1925
|
-
_makeStorageReference(loc) {
|
|
1926
|
-
return new Reference(this, loc);
|
|
1927
|
-
}
|
|
1928
|
-
/**
|
|
1929
|
-
* @param requestInfo - HTTP RequestInfo object
|
|
1930
|
-
* @param authToken - Firebase auth token
|
|
1931
|
-
*/
|
|
1932
|
-
_makeRequest(requestInfo, requestFactory, authToken, appCheckToken, retry = true) {
|
|
1933
|
-
if (!this._deleted) {
|
|
1934
|
-
const request = makeRequest(requestInfo, this._appId, authToken, appCheckToken, requestFactory, this._firebaseVersion, retry);
|
|
1935
|
-
this._requests.add(request);
|
|
1936
|
-
request.getPromise().then(() => this._requests.delete(request), () => this._requests.delete(request));
|
|
1937
|
-
return request;
|
|
1938
|
-
} else {
|
|
1939
|
-
return new FailRequest(appDeleted());
|
|
1940
|
-
}
|
|
1941
|
-
}
|
|
1942
|
-
async makeRequestWithTokens(requestInfo, requestFactory) {
|
|
1943
|
-
const [authToken, appCheckToken] = await Promise.all([
|
|
1944
|
-
this._getAuthToken(),
|
|
1945
|
-
this._getAppCheckToken()
|
|
1946
|
-
]);
|
|
1947
|
-
return this._makeRequest(requestInfo, requestFactory, authToken, appCheckToken).getPromise();
|
|
1948
|
-
}
|
|
1949
|
-
}
|
|
1950
|
-
const name = "@firebase/storage";
|
|
1951
|
-
const version = "0.13.2";
|
|
1952
|
-
/**
|
|
1953
|
-
* @license
|
|
1954
|
-
* Copyright 2020 Google LLC
|
|
1955
|
-
*
|
|
1956
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1957
|
-
* you may not use this file except in compliance with the License.
|
|
1958
|
-
* You may obtain a copy of the License at
|
|
1959
|
-
*
|
|
1960
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1961
|
-
*
|
|
1962
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1963
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1964
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1965
|
-
* See the License for the specific language governing permissions and
|
|
1966
|
-
* limitations under the License.
|
|
1967
|
-
*/
|
|
1968
|
-
const STORAGE_TYPE = "storage";
|
|
1969
|
-
function uploadString(ref2, value, format, metadata) {
|
|
1970
|
-
ref2 = getModularInstance(ref2);
|
|
1971
|
-
return uploadString$1(ref2, value, format, metadata);
|
|
1972
|
-
}
|
|
1973
|
-
function getMetadata(ref2) {
|
|
1974
|
-
ref2 = getModularInstance(ref2);
|
|
1975
|
-
return getMetadata$1(ref2);
|
|
1976
|
-
}
|
|
1977
|
-
function listAll(ref2) {
|
|
1978
|
-
ref2 = getModularInstance(ref2);
|
|
1979
|
-
return listAll$1(ref2);
|
|
1980
|
-
}
|
|
1981
|
-
function getDownloadURL(ref2) {
|
|
1982
|
-
ref2 = getModularInstance(ref2);
|
|
1983
|
-
return getDownloadURL$1(ref2);
|
|
1984
|
-
}
|
|
1985
|
-
function deleteObject(ref2) {
|
|
1986
|
-
ref2 = getModularInstance(ref2);
|
|
1987
|
-
return deleteObject$1(ref2);
|
|
1988
|
-
}
|
|
1989
|
-
function ref(serviceOrRef, pathOrUrl) {
|
|
1990
|
-
serviceOrRef = getModularInstance(serviceOrRef);
|
|
1991
|
-
return ref$1(serviceOrRef, pathOrUrl);
|
|
1992
|
-
}
|
|
1993
|
-
function getStorage(app = getApp(), bucketUrl) {
|
|
1994
|
-
app = getModularInstance(app);
|
|
1995
|
-
const storageProvider = _getProvider(app, STORAGE_TYPE);
|
|
1996
|
-
const storageInstance = storageProvider.getImmediate({
|
|
1997
|
-
identifier: bucketUrl
|
|
1998
|
-
});
|
|
1999
|
-
const emulator = getDefaultEmulatorHostnameAndPort("storage");
|
|
2000
|
-
if (emulator) {
|
|
2001
|
-
connectStorageEmulator(storageInstance, ...emulator);
|
|
2002
|
-
}
|
|
2003
|
-
return storageInstance;
|
|
2004
|
-
}
|
|
2005
|
-
function connectStorageEmulator(storage, host, port, options = {}) {
|
|
2006
|
-
connectStorageEmulator$1(storage, host, port, options);
|
|
2007
|
-
}
|
|
2008
|
-
function factory(container, { instanceIdentifier: url }) {
|
|
2009
|
-
const app = container.getProvider("app").getImmediate();
|
|
2010
|
-
const authProvider = container.getProvider("auth-internal");
|
|
2011
|
-
const appCheckProvider = container.getProvider("app-check-internal");
|
|
2012
|
-
return new FirebaseStorageImpl(app, authProvider, appCheckProvider, url, SDK_VERSION);
|
|
2013
|
-
}
|
|
2014
|
-
function registerStorage() {
|
|
2015
|
-
_registerComponent(new Component(
|
|
2016
|
-
STORAGE_TYPE,
|
|
2017
|
-
factory,
|
|
2018
|
-
"PUBLIC"
|
|
2019
|
-
/* ComponentType.PUBLIC */
|
|
2020
|
-
).setMultipleInstances(true));
|
|
2021
|
-
registerVersion(name, version, "");
|
|
2022
|
-
registerVersion(name, version, "esm2017");
|
|
2023
|
-
}
|
|
2024
|
-
registerStorage();
|
|
2025
|
-
export {
|
|
2026
|
-
StorageError,
|
|
2027
|
-
StorageErrorCode,
|
|
2028
|
-
StringFormat,
|
|
2029
|
-
FbsBlob as _FbsBlob,
|
|
2030
|
-
Location as _Location,
|
|
2031
|
-
dataFromString as _dataFromString,
|
|
2032
|
-
invalidArgument as _invalidArgument,
|
|
2033
|
-
invalidRootOperation as _invalidRootOperation,
|
|
2034
|
-
connectStorageEmulator,
|
|
2035
|
-
deleteObject,
|
|
2036
|
-
getDownloadURL,
|
|
2037
|
-
getMetadata,
|
|
2038
|
-
getStorage,
|
|
2039
|
-
listAll,
|
|
2040
|
-
ref,
|
|
2041
|
-
uploadString
|
|
2042
|
-
};
|