@progressive-development/pd-spa-helper 0.3.102 → 0.3.103
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/index.js +72 -0
- package/dist/node_modules/@firebase/app/dist/esm/index.esm2017.js +749 -0
- package/dist/node_modules/@firebase/auth/dist/esm2017/index-68602d24.js +6265 -0
- package/dist/node_modules/@firebase/component/dist/esm/index.esm2017.js +341 -0
- package/dist/node_modules/@firebase/firestore/dist/index.esm2017.js +10250 -0
- package/dist/node_modules/@firebase/functions/dist/index.esm2017.js +513 -0
- package/dist/node_modules/@firebase/installations/dist/esm/index.esm2017.js +863 -0
- package/dist/node_modules/@firebase/logger/dist/esm/index.esm2017.js +122 -0
- package/dist/node_modules/@firebase/messaging/dist/esm/index.esm2017.js +1019 -0
- package/dist/node_modules/@firebase/storage/dist/index.esm2017.js +2042 -0
- package/dist/node_modules/@firebase/util/dist/index.esm2017.js +931 -0
- package/dist/node_modules/@firebase/webchannel-wrapper/dist/bloom-blob/esm/bloom_blob_es2018.js +417 -0
- package/dist/node_modules/@firebase/webchannel-wrapper/dist/webchannel-blob/esm/webchannel_blob_es2018.js +2155 -0
- package/dist/node_modules/@lit/reactive-element/decorators/custom-element.js +14 -0
- package/dist/node_modules/@lit/reactive-element/decorators/property.js +20 -0
- package/dist/node_modules/@lit/reactive-element/decorators/query-assigned-elements.js +7 -0
- package/dist/node_modules/@progressive-development/pd-dialog/pd-popup-dialog.js +5 -0
- package/dist/node_modules/@progressive-development/pd-dialog/pd-popup.js +2 -0
- package/dist/node_modules/@progressive-development/pd-dialog/src/PdPopup.js +113 -0
- package/dist/node_modules/@progressive-development/pd-dialog/src/PdPopupDialog.js +189 -0
- package/dist/node_modules/@progressive-development/pd-forms/pd-button.js +2 -0
- package/dist/node_modules/@progressive-development/pd-forms/pd-form-container.js +2 -0
- package/dist/node_modules/@progressive-development/pd-forms/pd-form-row.js +2 -0
- package/dist/node_modules/@progressive-development/pd-forms/pd-hover-box.js +2 -0
- package/dist/node_modules/@progressive-development/pd-forms/pd-input.js +2 -0
- package/dist/node_modules/@progressive-development/pd-forms/src/PdBaseInputElement.js +86 -0
- package/dist/node_modules/@progressive-development/pd-forms/src/PdBaseUi.js +34 -0
- package/dist/node_modules/@progressive-development/pd-forms/src/PdBaseUiInput.js +227 -0
- package/dist/node_modules/@progressive-development/pd-forms/src/PdButton.js +194 -0
- package/dist/node_modules/@progressive-development/pd-forms/src/PdFormContainer.js +167 -0
- package/dist/node_modules/@progressive-development/pd-forms/src/PdFormRow.js +92 -0
- package/dist/node_modules/@progressive-development/pd-forms/src/PdHoverBox.js +108 -0
- package/dist/node_modules/@progressive-development/pd-forms/src/PdInput.js +79 -0
- package/dist/node_modules/@progressive-development/pd-forms/src/generated/locale/be.js +11 -0
- package/dist/node_modules/@progressive-development/pd-forms/src/generated/locale/en.js +11 -0
- package/dist/node_modules/@progressive-development/pd-forms/src/shared-input-field-styles.js +152 -0
- package/dist/node_modules/@progressive-development/pd-forms/src/shared-input-styles.js +64 -0
- package/dist/node_modules/@progressive-development/pd-icon/pd-icon.js +4 -0
- package/dist/node_modules/@progressive-development/pd-icon/src/PdIcon.js +596 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/locales/be.js +15 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/locales/de.js +15 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/locales/en.js +15 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-contact/pd-contact.js +2 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-contact/src/PdContact.js +567 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-content/pd-collapse.js +2 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-content/pd-edit-content.js +2 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-content/src/PdCollapse.js +136 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-content/src/PdEditContent.js +224 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-dialog/pd-popup.js +2 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-dialog/src/PdPopup.js +113 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/pd-checkbox.js +2 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/pd-form-container.js +2 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/pd-form-row.js +2 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/pd-hover-box.js +2 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/pd-input.js +2 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/pd-radio-group.js +2 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdBaseInputElement.js +86 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdBaseUi.js +34 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdBaseUiInput.js +229 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdCheckbox.js +230 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdFormContainer.js +167 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdFormRow.js +92 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdHoverBox.js +108 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdInput.js +79 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdRadioGroup.js +72 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/shared-input-field-styles.js +152 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/shared-input-styles.js +64 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-icon/pd-icon.js +4 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-icon/src/PdIcon.js +596 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-price/pd-pricetable.js +2 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-price/src/PdPricetable.js +149 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/fecha/lib/fecha.js +200 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/lit/node_modules/lit-html/directive.js +27 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/lit/node_modules/lit-html/directives/class-map.js +36 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/lit/node_modules/lit-html/lit-html.js +242 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/pd-order-contacts.js +2 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/pd-order-summary.js +2 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/src/PdOrderContacts.js +192 -0
- package/dist/node_modules/@progressive-development/pd-order/dist/src/PdOrderSummary.js +243 -0
- package/dist/node_modules/@progressive-development/pd-page/pd-footer.js +2 -0
- package/dist/node_modules/@progressive-development/pd-page/pd-menu.js +2 -0
- package/dist/node_modules/@progressive-development/pd-page/src/PdFooter.js +141 -0
- package/dist/node_modules/@progressive-development/pd-page/src/PdMenu.js +450 -0
- package/dist/node_modules/@progressive-development/pd-shared-styles/src/shared-color-styles.js +30 -0
- package/dist/node_modules/@progressive-development/pd-shared-styles/src/shared-font-styles.js +32 -0
- package/dist/node_modules/@progressive-development/pd-wizard/pd-wizard.js +2 -0
- package/dist/node_modules/@progressive-development/pd-wizard/src/PdSteps.js +191 -0
- package/dist/node_modules/@progressive-development/pd-wizard/src/PdWizard.js +280 -0
- package/dist/node_modules/firebase/app/dist/esm/index.esm.js +35 -0
- package/dist/node_modules/idb/build/index.js +81 -0
- package/dist/node_modules/idb/build/wrap-idb-value.js +148 -0
- package/dist/node_modules/lit/node_modules/lit-html/directive.js +27 -0
- package/dist/node_modules/lit/node_modules/lit-html/directives/class-map.js +36 -0
- package/dist/node_modules/lit/node_modules/lit-html/lit-html.js +242 -0
- package/dist/node_modules/lit-element-router/lit-element-router.js +131 -0
- package/dist/node_modules/lit-element-router/utility/router-utility.js +36 -0
- package/dist/node_modules/mini-rx-store/index.esm.js +458 -0
- package/dist/node_modules/pwa-helpers/media-query.js +17 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/Observable.js +100 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/Subscriber.js +147 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/Subscription.js +139 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/config.js +10 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/observable/innerFrom.js +159 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/operators/OperatorSubscriber.js +52 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/operators/catchError.js +28 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/operators/distinctUntilChanged.js +27 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/operators/filter.js +13 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/operators/map.js +13 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/operators/observeOn.js +26 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/operators/tap.js +36 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/operators/withLatestFrom.js +43 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js +18 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/symbol/iterator.js +11 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/symbol/observable.js +6 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js +14 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/util/args.js +10 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/util/arrRemove.js +9 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js +13 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/util/errorContext.js +8 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/util/executeSchedule.js +23 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/util/identity.js +6 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/util/isArrayLike.js +6 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/util/isAsyncIterable.js +7 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/util/isFunction.js +6 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/util/isInteropObservable.js +8 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/util/isIterable.js +8 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/util/isPromise.js +7 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/util/isReadableStreamLike.js +46 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/util/lift.js +22 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/util/noop.js +5 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/util/pipe.js +17 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js +11 -0
- package/dist/node_modules/rxjs/dist/esm5/internal/util/throwUnobservableError.js +6 -0
- package/dist/node_modules/tslib/tslib.es6.js +240 -0
- package/dist/pd-panel-viewer.js +189 -0
- package/dist/pd-panel.js +51 -0
- package/dist/src/PdSpaHelper.js +319 -402
- package/dist/src/defaultpage/default-confirm-popup.js +61 -41
- package/dist/src/defaultpage/default-dialog-popup.js +74 -60
- package/dist/src/defaultpage/default-login.js +31 -20
- package/dist/src/defaultpage/default-popup.js +13 -10
- package/dist/src/defaultpage/default-step-address.js +52 -42
- package/dist/src/defaultpage/default-step-summary.js +58 -49
- package/dist/src/defaultpage/default-view-page.js +31 -23
- package/dist/src/defaultpage/default-wizard-step.js +119 -111
- package/dist/src/defaultpage/default-wizard.js +199 -195
- package/dist/src/generated/locale-wrapper/be-wrapper.js +14 -11
- package/dist/src/generated/locale-wrapper/de-wrapper.js +12 -9
- package/dist/src/generated/locale-wrapper/en-wrapper.js +14 -11
- package/dist/src/generated/locales/be.js +17 -19
- package/dist/src/generated/locales/de.js +17 -19
- package/dist/src/generated/locales/en.js +17 -19
- package/dist/src/helper/helper-utils.js +29 -24
- package/dist/src/model/spa-model.js +6 -3
- package/dist/src/popup/wizard-close-popup.js +37 -27
- package/dist/src/popup/wizard-reload-popup.js +35 -23
- package/dist/src/router/AppMain.js +23 -12
- package/dist/src/service-provider/firebase/auth.js +50 -73
- package/dist/src/service-provider/firebase/firestorage-client.js +194 -243
- package/dist/src/service-provider/firebase/firestore-client.js +19 -25
- package/dist/src/service-provider/firebase/functions-client.js +27 -59
- package/dist/src/service-provider/firebase/messagingFirebaseClient.js +60 -59
- package/dist/src/service-provider/mock/auth.js +54 -54
- package/dist/src/service-provider/mock/function-client.js +28 -27
- package/dist/src/service-provider/mock/storage-client.js +86 -92
- package/dist/src/service-provider/service-provider-impl.js +206 -211
- package/dist/src/service-provider/service-provider-model.js +1 -2
- package/dist/src/store/indexDB.js +133 -180
- package/dist/src/store/mini-rx.store.js +36 -38
- package/dist/src/store/spa-app-actions.js +27 -14
- package/dist/src/store/spa-app-effects.js +60 -40
- package/dist/src/store/spa-app-reducer.js +42 -33
- package/dist/src/store/spa-app-selector.js +31 -15
- package/dist/src/tmpown/pd-loading-state.js +49 -39
- package/dist/src/tmpown/pd-login.js +76 -67
- package/dist/src/tmpown/pd-toast.js +74 -65
- package/package.json +16 -13
- package/.editorconfig +0 -29
- package/.storybook/main.ts +0 -14
- package/.storybook/preview.ts +0 -15
- package/demo/index.html +0 -29
- package/dist/src/InitApplicationData.d.ts +0 -3
- package/dist/src/InitApplicationData.js +0 -8
- package/dist/src/InitApplicationData.js.map +0 -1
- package/dist/src/PdSpaHelper.d.ts +0 -93
- package/dist/src/PdSpaHelper.js.map +0 -1
- package/dist/src/defaultpage/default-confirm-popup.d.ts +0 -19
- package/dist/src/defaultpage/default-confirm-popup.js.map +0 -1
- package/dist/src/defaultpage/default-dialog-popup.d.ts +0 -16
- package/dist/src/defaultpage/default-dialog-popup.js.map +0 -1
- package/dist/src/defaultpage/default-login.d.ts +0 -8
- package/dist/src/defaultpage/default-login.js.map +0 -1
- package/dist/src/defaultpage/default-popup.d.ts +0 -7
- package/dist/src/defaultpage/default-popup.js.map +0 -1
- package/dist/src/defaultpage/default-step-address.d.ts +0 -19
- package/dist/src/defaultpage/default-step-address.js.map +0 -1
- package/dist/src/defaultpage/default-step-summary.d.ts +0 -30
- package/dist/src/defaultpage/default-step-summary.js.map +0 -1
- package/dist/src/defaultpage/default-view-page.d.ts +0 -9
- package/dist/src/defaultpage/default-view-page.js.map +0 -1
- package/dist/src/defaultpage/default-wizard-step.d.ts +0 -34
- package/dist/src/defaultpage/default-wizard-step.js.map +0 -1
- package/dist/src/defaultpage/default-wizard.d.ts +0 -33
- package/dist/src/defaultpage/default-wizard.js.map +0 -1
- package/dist/src/firebase/auth.d.ts +0 -4
- package/dist/src/firebase/auth.js +0 -28
- package/dist/src/firebase/auth.js.map +0 -1
- package/dist/src/firebase/firestore-client.d.ts +0 -9
- package/dist/src/firebase/firestore-client.js +0 -19
- package/dist/src/firebase/firestore-client.js.map +0 -1
- package/dist/src/firebase/functions-client.d.ts +0 -34
- package/dist/src/firebase/functions-client.js +0 -70
- package/dist/src/firebase/functions-client.js.map +0 -1
- package/dist/src/generated/locale-codes.d.ts +0 -13
- package/dist/src/generated/locale-codes.js +0 -25
- package/dist/src/generated/locale-codes.js.map +0 -1
- package/dist/src/generated/locale-wrapper/be-wrapper.d.ts +0 -1
- package/dist/src/generated/locale-wrapper/be-wrapper.js.map +0 -1
- package/dist/src/generated/locale-wrapper/de-wrapper.d.ts +0 -15
- package/dist/src/generated/locale-wrapper/de-wrapper.js.map +0 -1
- package/dist/src/generated/locale-wrapper/en-wrapper.d.ts +0 -1
- package/dist/src/generated/locale-wrapper/en-wrapper.js.map +0 -1
- package/dist/src/generated/locales/be.d.ts +0 -15
- package/dist/src/generated/locales/be.js.map +0 -1
- package/dist/src/generated/locales/de.d.ts +0 -15
- package/dist/src/generated/locales/de.js.map +0 -1
- package/dist/src/generated/locales/en.d.ts +0 -15
- package/dist/src/generated/locales/en.js.map +0 -1
- package/dist/src/helper/helper-utils.d.ts +0 -5
- package/dist/src/helper/helper-utils.js.map +0 -1
- package/dist/src/index.d.ts +0 -22
- package/dist/src/index.js +0 -33
- package/dist/src/index.js.map +0 -1
- package/dist/src/model/spa-model.d.ts +0 -16
- package/dist/src/model/spa-model.js.map +0 -1
- package/dist/src/pd-spa-helper.d.ts +0 -0
- package/dist/src/pd-spa-helper.js +0 -5
- package/dist/src/pd-spa-helper.js.map +0 -1
- package/dist/src/popup/wizard-close-popup.d.ts +0 -10
- package/dist/src/popup/wizard-close-popup.js.map +0 -1
- package/dist/src/popup/wizard-reload-popup.d.ts +0 -13
- package/dist/src/popup/wizard-reload-popup.js.map +0 -1
- package/dist/src/router/AppMain.d.ts +0 -6
- package/dist/src/router/AppMain.js.map +0 -1
- package/dist/src/service-call-controller2.d.ts +0 -16
- package/dist/src/service-call-controller2.js +0 -43
- package/dist/src/service-call-controller2.js.map +0 -1
- package/dist/src/service-provider/firebase/auth.d.ts +0 -14
- package/dist/src/service-provider/firebase/auth.js.map +0 -1
- package/dist/src/service-provider/firebase/firestorage-client.d.ts +0 -20
- package/dist/src/service-provider/firebase/firestorage-client.js.map +0 -1
- package/dist/src/service-provider/firebase/firestore-client.d.ts +0 -11
- package/dist/src/service-provider/firebase/firestore-client.js.map +0 -1
- package/dist/src/service-provider/firebase/functions-client.d.ts +0 -9
- package/dist/src/service-provider/firebase/functions-client.js.map +0 -1
- package/dist/src/service-provider/firebase/messagingFirebaseClient.d.ts +0 -8
- package/dist/src/service-provider/firebase/messagingFirebaseClient.js.map +0 -1
- package/dist/src/service-provider/mock/auth.d.ts +0 -5
- package/dist/src/service-provider/mock/auth.js.map +0 -1
- package/dist/src/service-provider/mock/function-client.d.ts +0 -8
- package/dist/src/service-provider/mock/function-client.js.map +0 -1
- package/dist/src/service-provider/mock/storage-client.d.ts +0 -10
- package/dist/src/service-provider/mock/storage-client.js.map +0 -1
- package/dist/src/service-provider/service-provider-impl.d.ts +0 -21
- package/dist/src/service-provider/service-provider-impl.js.map +0 -1
- package/dist/src/service-provider/service-provider-model.d.ts +0 -136
- package/dist/src/service-provider/service-provider-model.js.map +0 -1
- package/dist/src/store/indexDB.d.ts +0 -27
- package/dist/src/store/indexDB.js.map +0 -1
- package/dist/src/store/mini-rx.store.d.ts +0 -4
- package/dist/src/store/mini-rx.store.js.map +0 -1
- package/dist/src/store/spa-app-actions.d.ts +0 -104
- package/dist/src/store/spa-app-actions.js.map +0 -1
- package/dist/src/store/spa-app-effects.d.ts +0 -23
- package/dist/src/store/spa-app-effects.js.map +0 -1
- package/dist/src/store/spa-app-reducer.d.ts +0 -9
- package/dist/src/store/spa-app-reducer.js.map +0 -1
- package/dist/src/store/spa-app-selector.d.ts +0 -6
- package/dist/src/store/spa-app-selector.js.map +0 -1
- package/dist/src/stories/Button.d.ts +0 -27
- package/dist/src/stories/Button.js +0 -20
- package/dist/src/stories/Button.js.map +0 -1
- package/dist/src/stories/Button.stories.d.ts +0 -9
- package/dist/src/stories/Button.stories.js +0 -41
- package/dist/src/stories/Button.stories.js.map +0 -1
- package/dist/src/stories/Header.d.ts +0 -12
- package/dist/src/stories/Header.js +0 -44
- package/dist/src/stories/Header.js.map +0 -1
- package/dist/src/stories/Header.stories.d.ts +0 -7
- package/dist/src/stories/Header.stories.js +0 -17
- package/dist/src/stories/Header.stories.js.map +0 -1
- package/dist/src/stories/Page.d.ts +0 -12
- package/dist/src/stories/Page.js +0 -61
- package/dist/src/stories/Page.js.map +0 -1
- package/dist/src/stories/Page.stories.d.ts +0 -7
- package/dist/src/stories/Page.stories.js +0 -19
- package/dist/src/stories/Page.stories.js.map +0 -1
- package/dist/src/stories/pd-loading-state.stories.d.ts +0 -30
- package/dist/src/stories/pd-loading-state.stories.js +0 -153
- package/dist/src/stories/pd-loading-state.stories.js.map +0 -1
- package/dist/src/stories/pd-toast.stories.d.ts +0 -23
- package/dist/src/stories/pd-toast.stories.js +0 -34
- package/dist/src/stories/pd-toast.stories.js.map +0 -1
- package/dist/src/tmpown/pd-loading-state.d.ts +0 -9
- package/dist/src/tmpown/pd-loading-state.js.map +0 -1
- package/dist/src/tmpown/pd-login.d.ts +0 -14
- package/dist/src/tmpown/pd-login.js.map +0 -1
- package/dist/src/tmpown/pd-panel-viewer.d.ts +0 -18
- package/dist/src/tmpown/pd-panel-viewer.js +0 -188
- package/dist/src/tmpown/pd-panel-viewer.js.map +0 -1
- package/dist/src/tmpown/pd-panel.d.ts +0 -5
- package/dist/src/tmpown/pd-panel.js +0 -41
- package/dist/src/tmpown/pd-panel.js.map +0 -1
- package/dist/src/tmpown/pd-toast.d.ts +0 -12
- package/dist/src/tmpown/pd-toast.js.map +0 -1
- package/dist/stories/index.stories.d.ts +0 -33
- package/dist/stories/index.stories.js +0 -37
- package/dist/stories/index.stories.js.map +0 -1
- package/dist/test/pd-spa-helper.test.d.ts +0 -1
- package/dist/test/pd-spa-helper.test.js +0 -22
- package/dist/test/pd-spa-helper.test.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/index.d.ts +0 -15
- package/lit-localize.json +0 -15
- package/pd-spa-helper.iml +0 -9
- package/src/PdSpaHelper.ts +0 -619
- package/src/defaultpage/default-confirm-popup.ts +0 -78
- package/src/defaultpage/default-dialog-popup.ts +0 -105
- package/src/defaultpage/default-login.ts +0 -41
- package/src/defaultpage/default-popup.ts +0 -26
- package/src/defaultpage/default-step-address.ts +0 -57
- package/src/defaultpage/default-step-summary.ts +0 -88
- package/src/defaultpage/default-view-page.ts +0 -58
- package/src/defaultpage/default-wizard-step.ts +0 -142
- package/src/defaultpage/default-wizard.ts +0 -273
- package/src/generated/locale-codes.ts +0 -27
- package/src/generated/locale-wrapper/be-wrapper.ts +0 -13
- package/src/generated/locale-wrapper/de-wrapper.ts +0 -11
- package/src/generated/locale-wrapper/en-wrapper.ts +0 -13
- package/src/generated/locales/be.ts +0 -26
- package/src/generated/locales/de.ts +0 -26
- package/src/generated/locales/en.ts +0 -26
- package/src/helper/helper-utils.ts +0 -35
- package/src/index.ts +0 -66
- package/src/model/spa-model.ts +0 -20
- package/src/pd-spa-helper.ts +0 -3
- package/src/popup/wizard-close-popup.ts +0 -52
- package/src/popup/wizard-reload-popup.ts +0 -69
- package/src/router/AppMain.ts +0 -10
- package/src/service-call-controller2.ts +0 -68
- package/src/service-provider/firebase/auth.ts +0 -89
- package/src/service-provider/firebase/firestorage-client.ts +0 -327
- package/src/service-provider/firebase/firestore-client.ts +0 -40
- package/src/service-provider/firebase/functions-client.ts +0 -73
- package/src/service-provider/firebase/messagingFirebaseClient.ts +0 -102
- package/src/service-provider/mock/auth.ts +0 -86
- package/src/service-provider/mock/function-client.ts +0 -42
- package/src/service-provider/mock/storage-client.ts +0 -149
- package/src/service-provider/service-provider-impl.ts +0 -286
- package/src/service-provider/service-provider-model.ts +0 -163
- package/src/store/indexDB.ts +0 -244
- package/src/store/mini-rx.store.ts +0 -48
- package/src/store/spa-app-actions.ts +0 -36
- package/src/store/spa-app-effects.ts +0 -73
- package/src/store/spa-app-reducer.ts +0 -86
- package/src/store/spa-app-selector.ts +0 -41
- package/src/stories/pd-loading-state.stories.ts +0 -168
- package/src/stories/pd-toast.stories.ts +0 -43
- package/src/tmpown/pd-loading-state.ts +0 -177
- package/src/tmpown/pd-login.ts +0 -131
- package/src/tmpown/pd-panel-viewer.ts +0 -193
- package/src/tmpown/pd-panel.ts +0 -43
- package/src/tmpown/pd-toast.ts +0 -118
- package/test/pd-spa-helper.test.ts +0 -26
- package/tsconfig.json +0 -22
- package/web-dev-server.config.mjs +0 -27
- package/web-test-runner.config.mjs +0 -41
- package/xliff/be.xlf +0 -60
- package/xliff/de.xlf +0 -46
- package/xliff/en.xlf +0 -58
|
@@ -0,0 +1,863 @@
|
|
|
1
|
+
import { registerVersion, _registerComponent, _getProvider } from "../../../app/dist/esm/index.esm2017.js";
|
|
2
|
+
import { Component } from "../../../component/dist/esm/index.esm2017.js";
|
|
3
|
+
import { ErrorFactory, FirebaseError } from "../../../util/dist/index.esm2017.js";
|
|
4
|
+
import { openDB } from "../../../../idb/build/index.js";
|
|
5
|
+
const name = "@firebase/installations";
|
|
6
|
+
const version = "0.6.9";
|
|
7
|
+
/**
|
|
8
|
+
* @license
|
|
9
|
+
* Copyright 2019 Google LLC
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*/
|
|
23
|
+
const PENDING_TIMEOUT_MS = 1e4;
|
|
24
|
+
const PACKAGE_VERSION = `w:${version}`;
|
|
25
|
+
const INTERNAL_AUTH_VERSION = "FIS_v2";
|
|
26
|
+
const INSTALLATIONS_API_URL = "https://firebaseinstallations.googleapis.com/v1";
|
|
27
|
+
const TOKEN_EXPIRATION_BUFFER = 60 * 60 * 1e3;
|
|
28
|
+
const SERVICE = "installations";
|
|
29
|
+
const SERVICE_NAME = "Installations";
|
|
30
|
+
/**
|
|
31
|
+
* @license
|
|
32
|
+
* Copyright 2019 Google LLC
|
|
33
|
+
*
|
|
34
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
35
|
+
* you may not use this file except in compliance with the License.
|
|
36
|
+
* You may obtain a copy of the License at
|
|
37
|
+
*
|
|
38
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
39
|
+
*
|
|
40
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
41
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
42
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
43
|
+
* See the License for the specific language governing permissions and
|
|
44
|
+
* limitations under the License.
|
|
45
|
+
*/
|
|
46
|
+
const ERROR_DESCRIPTION_MAP = {
|
|
47
|
+
[
|
|
48
|
+
"missing-app-config-values"
|
|
49
|
+
/* ErrorCode.MISSING_APP_CONFIG_VALUES */
|
|
50
|
+
]: 'Missing App configuration value: "{$valueName}"',
|
|
51
|
+
[
|
|
52
|
+
"not-registered"
|
|
53
|
+
/* ErrorCode.NOT_REGISTERED */
|
|
54
|
+
]: "Firebase Installation is not registered.",
|
|
55
|
+
[
|
|
56
|
+
"installation-not-found"
|
|
57
|
+
/* ErrorCode.INSTALLATION_NOT_FOUND */
|
|
58
|
+
]: "Firebase Installation not found.",
|
|
59
|
+
[
|
|
60
|
+
"request-failed"
|
|
61
|
+
/* ErrorCode.REQUEST_FAILED */
|
|
62
|
+
]: '{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',
|
|
63
|
+
[
|
|
64
|
+
"app-offline"
|
|
65
|
+
/* ErrorCode.APP_OFFLINE */
|
|
66
|
+
]: "Could not process request. Application offline.",
|
|
67
|
+
[
|
|
68
|
+
"delete-pending-registration"
|
|
69
|
+
/* ErrorCode.DELETE_PENDING_REGISTRATION */
|
|
70
|
+
]: "Can't delete installation while there is a pending registration request."
|
|
71
|
+
};
|
|
72
|
+
const ERROR_FACTORY = new ErrorFactory(SERVICE, SERVICE_NAME, ERROR_DESCRIPTION_MAP);
|
|
73
|
+
function isServerError(error) {
|
|
74
|
+
return error instanceof FirebaseError && error.code.includes(
|
|
75
|
+
"request-failed"
|
|
76
|
+
/* ErrorCode.REQUEST_FAILED */
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* @license
|
|
81
|
+
* Copyright 2019 Google LLC
|
|
82
|
+
*
|
|
83
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
84
|
+
* you may not use this file except in compliance with the License.
|
|
85
|
+
* You may obtain a copy of the License at
|
|
86
|
+
*
|
|
87
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
88
|
+
*
|
|
89
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
90
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
91
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
92
|
+
* See the License for the specific language governing permissions and
|
|
93
|
+
* limitations under the License.
|
|
94
|
+
*/
|
|
95
|
+
function getInstallationsEndpoint({ projectId }) {
|
|
96
|
+
return `${INSTALLATIONS_API_URL}/projects/${projectId}/installations`;
|
|
97
|
+
}
|
|
98
|
+
function extractAuthTokenInfoFromResponse(response) {
|
|
99
|
+
return {
|
|
100
|
+
token: response.token,
|
|
101
|
+
requestStatus: 2,
|
|
102
|
+
expiresIn: getExpiresInFromResponseExpiresIn(response.expiresIn),
|
|
103
|
+
creationTime: Date.now()
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
async function getErrorFromResponse(requestName, response) {
|
|
107
|
+
const responseJson = await response.json();
|
|
108
|
+
const errorData = responseJson.error;
|
|
109
|
+
return ERROR_FACTORY.create("request-failed", {
|
|
110
|
+
requestName,
|
|
111
|
+
serverCode: errorData.code,
|
|
112
|
+
serverMessage: errorData.message,
|
|
113
|
+
serverStatus: errorData.status
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function getHeaders({ apiKey }) {
|
|
117
|
+
return new Headers({
|
|
118
|
+
"Content-Type": "application/json",
|
|
119
|
+
Accept: "application/json",
|
|
120
|
+
"x-goog-api-key": apiKey
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function getHeadersWithAuth(appConfig, { refreshToken }) {
|
|
124
|
+
const headers = getHeaders(appConfig);
|
|
125
|
+
headers.append("Authorization", getAuthorizationHeader(refreshToken));
|
|
126
|
+
return headers;
|
|
127
|
+
}
|
|
128
|
+
async function retryIfServerError(fn) {
|
|
129
|
+
const result = await fn();
|
|
130
|
+
if (result.status >= 500 && result.status < 600) {
|
|
131
|
+
return fn();
|
|
132
|
+
}
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
function getExpiresInFromResponseExpiresIn(responseExpiresIn) {
|
|
136
|
+
return Number(responseExpiresIn.replace("s", "000"));
|
|
137
|
+
}
|
|
138
|
+
function getAuthorizationHeader(refreshToken) {
|
|
139
|
+
return `${INTERNAL_AUTH_VERSION} ${refreshToken}`;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* @license
|
|
143
|
+
* Copyright 2019 Google LLC
|
|
144
|
+
*
|
|
145
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
146
|
+
* you may not use this file except in compliance with the License.
|
|
147
|
+
* You may obtain a copy of the License at
|
|
148
|
+
*
|
|
149
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
150
|
+
*
|
|
151
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
152
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
153
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
154
|
+
* See the License for the specific language governing permissions and
|
|
155
|
+
* limitations under the License.
|
|
156
|
+
*/
|
|
157
|
+
async function createInstallationRequest({ appConfig, heartbeatServiceProvider }, { fid }) {
|
|
158
|
+
const endpoint = getInstallationsEndpoint(appConfig);
|
|
159
|
+
const headers = getHeaders(appConfig);
|
|
160
|
+
const heartbeatService = heartbeatServiceProvider.getImmediate({
|
|
161
|
+
optional: true
|
|
162
|
+
});
|
|
163
|
+
if (heartbeatService) {
|
|
164
|
+
const heartbeatsHeader = await heartbeatService.getHeartbeatsHeader();
|
|
165
|
+
if (heartbeatsHeader) {
|
|
166
|
+
headers.append("x-firebase-client", heartbeatsHeader);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const body = {
|
|
170
|
+
fid,
|
|
171
|
+
authVersion: INTERNAL_AUTH_VERSION,
|
|
172
|
+
appId: appConfig.appId,
|
|
173
|
+
sdkVersion: PACKAGE_VERSION
|
|
174
|
+
};
|
|
175
|
+
const request = {
|
|
176
|
+
method: "POST",
|
|
177
|
+
headers,
|
|
178
|
+
body: JSON.stringify(body)
|
|
179
|
+
};
|
|
180
|
+
const response = await retryIfServerError(() => fetch(endpoint, request));
|
|
181
|
+
if (response.ok) {
|
|
182
|
+
const responseValue = await response.json();
|
|
183
|
+
const registeredInstallationEntry = {
|
|
184
|
+
fid: responseValue.fid || fid,
|
|
185
|
+
registrationStatus: 2,
|
|
186
|
+
refreshToken: responseValue.refreshToken,
|
|
187
|
+
authToken: extractAuthTokenInfoFromResponse(responseValue.authToken)
|
|
188
|
+
};
|
|
189
|
+
return registeredInstallationEntry;
|
|
190
|
+
} else {
|
|
191
|
+
throw await getErrorFromResponse("Create Installation", response);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* @license
|
|
196
|
+
* Copyright 2019 Google LLC
|
|
197
|
+
*
|
|
198
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
199
|
+
* you may not use this file except in compliance with the License.
|
|
200
|
+
* You may obtain a copy of the License at
|
|
201
|
+
*
|
|
202
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
203
|
+
*
|
|
204
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
205
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
206
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
207
|
+
* See the License for the specific language governing permissions and
|
|
208
|
+
* limitations under the License.
|
|
209
|
+
*/
|
|
210
|
+
function sleep(ms) {
|
|
211
|
+
return new Promise((resolve) => {
|
|
212
|
+
setTimeout(resolve, ms);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* @license
|
|
217
|
+
* Copyright 2019 Google LLC
|
|
218
|
+
*
|
|
219
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
220
|
+
* you may not use this file except in compliance with the License.
|
|
221
|
+
* You may obtain a copy of the License at
|
|
222
|
+
*
|
|
223
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
224
|
+
*
|
|
225
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
226
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
227
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
228
|
+
* See the License for the specific language governing permissions and
|
|
229
|
+
* limitations under the License.
|
|
230
|
+
*/
|
|
231
|
+
function bufferToBase64UrlSafe(array) {
|
|
232
|
+
const b64 = btoa(String.fromCharCode(...array));
|
|
233
|
+
return b64.replace(/\+/g, "-").replace(/\//g, "_");
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* @license
|
|
237
|
+
* Copyright 2019 Google LLC
|
|
238
|
+
*
|
|
239
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
240
|
+
* you may not use this file except in compliance with the License.
|
|
241
|
+
* You may obtain a copy of the License at
|
|
242
|
+
*
|
|
243
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
244
|
+
*
|
|
245
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
246
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
247
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
248
|
+
* See the License for the specific language governing permissions and
|
|
249
|
+
* limitations under the License.
|
|
250
|
+
*/
|
|
251
|
+
const VALID_FID_PATTERN = /^[cdef][\w-]{21}$/;
|
|
252
|
+
const INVALID_FID = "";
|
|
253
|
+
function generateFid() {
|
|
254
|
+
try {
|
|
255
|
+
const fidByteArray = new Uint8Array(17);
|
|
256
|
+
const crypto = self.crypto || self.msCrypto;
|
|
257
|
+
crypto.getRandomValues(fidByteArray);
|
|
258
|
+
fidByteArray[0] = 112 + fidByteArray[0] % 16;
|
|
259
|
+
const fid = encode(fidByteArray);
|
|
260
|
+
return VALID_FID_PATTERN.test(fid) ? fid : INVALID_FID;
|
|
261
|
+
} catch (_a) {
|
|
262
|
+
return INVALID_FID;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function encode(fidByteArray) {
|
|
266
|
+
const b64String = bufferToBase64UrlSafe(fidByteArray);
|
|
267
|
+
return b64String.substr(0, 22);
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* @license
|
|
271
|
+
* Copyright 2019 Google LLC
|
|
272
|
+
*
|
|
273
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
274
|
+
* you may not use this file except in compliance with the License.
|
|
275
|
+
* You may obtain a copy of the License at
|
|
276
|
+
*
|
|
277
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
278
|
+
*
|
|
279
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
280
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
281
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
282
|
+
* See the License for the specific language governing permissions and
|
|
283
|
+
* limitations under the License.
|
|
284
|
+
*/
|
|
285
|
+
function getKey(appConfig) {
|
|
286
|
+
return `${appConfig.appName}!${appConfig.appId}`;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* @license
|
|
290
|
+
* Copyright 2019 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
|
+
const fidChangeCallbacks = /* @__PURE__ */ new Map();
|
|
305
|
+
function fidChanged(appConfig, fid) {
|
|
306
|
+
const key = getKey(appConfig);
|
|
307
|
+
callFidChangeCallbacks(key, fid);
|
|
308
|
+
broadcastFidChange(key, fid);
|
|
309
|
+
}
|
|
310
|
+
function callFidChangeCallbacks(key, fid) {
|
|
311
|
+
const callbacks = fidChangeCallbacks.get(key);
|
|
312
|
+
if (!callbacks) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
for (const callback of callbacks) {
|
|
316
|
+
callback(fid);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
function broadcastFidChange(key, fid) {
|
|
320
|
+
const channel = getBroadcastChannel();
|
|
321
|
+
if (channel) {
|
|
322
|
+
channel.postMessage({ key, fid });
|
|
323
|
+
}
|
|
324
|
+
closeBroadcastChannel();
|
|
325
|
+
}
|
|
326
|
+
let broadcastChannel = null;
|
|
327
|
+
function getBroadcastChannel() {
|
|
328
|
+
if (!broadcastChannel && "BroadcastChannel" in self) {
|
|
329
|
+
broadcastChannel = new BroadcastChannel("[Firebase] FID Change");
|
|
330
|
+
broadcastChannel.onmessage = (e) => {
|
|
331
|
+
callFidChangeCallbacks(e.data.key, e.data.fid);
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
return broadcastChannel;
|
|
335
|
+
}
|
|
336
|
+
function closeBroadcastChannel() {
|
|
337
|
+
if (fidChangeCallbacks.size === 0 && broadcastChannel) {
|
|
338
|
+
broadcastChannel.close();
|
|
339
|
+
broadcastChannel = null;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* @license
|
|
344
|
+
* Copyright 2019 Google LLC
|
|
345
|
+
*
|
|
346
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
347
|
+
* you may not use this file except in compliance with the License.
|
|
348
|
+
* You may obtain a copy of the License at
|
|
349
|
+
*
|
|
350
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
351
|
+
*
|
|
352
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
353
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
354
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
355
|
+
* See the License for the specific language governing permissions and
|
|
356
|
+
* limitations under the License.
|
|
357
|
+
*/
|
|
358
|
+
const DATABASE_NAME = "firebase-installations-database";
|
|
359
|
+
const DATABASE_VERSION = 1;
|
|
360
|
+
const OBJECT_STORE_NAME = "firebase-installations-store";
|
|
361
|
+
let dbPromise = null;
|
|
362
|
+
function getDbPromise() {
|
|
363
|
+
if (!dbPromise) {
|
|
364
|
+
dbPromise = openDB(DATABASE_NAME, DATABASE_VERSION, {
|
|
365
|
+
upgrade: (db, oldVersion) => {
|
|
366
|
+
switch (oldVersion) {
|
|
367
|
+
case 0:
|
|
368
|
+
db.createObjectStore(OBJECT_STORE_NAME);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
return dbPromise;
|
|
374
|
+
}
|
|
375
|
+
async function set(appConfig, value) {
|
|
376
|
+
const key = getKey(appConfig);
|
|
377
|
+
const db = await getDbPromise();
|
|
378
|
+
const tx = db.transaction(OBJECT_STORE_NAME, "readwrite");
|
|
379
|
+
const objectStore = tx.objectStore(OBJECT_STORE_NAME);
|
|
380
|
+
const oldValue = await objectStore.get(key);
|
|
381
|
+
await objectStore.put(value, key);
|
|
382
|
+
await tx.done;
|
|
383
|
+
if (!oldValue || oldValue.fid !== value.fid) {
|
|
384
|
+
fidChanged(appConfig, value.fid);
|
|
385
|
+
}
|
|
386
|
+
return value;
|
|
387
|
+
}
|
|
388
|
+
async function remove(appConfig) {
|
|
389
|
+
const key = getKey(appConfig);
|
|
390
|
+
const db = await getDbPromise();
|
|
391
|
+
const tx = db.transaction(OBJECT_STORE_NAME, "readwrite");
|
|
392
|
+
await tx.objectStore(OBJECT_STORE_NAME).delete(key);
|
|
393
|
+
await tx.done;
|
|
394
|
+
}
|
|
395
|
+
async function update(appConfig, updateFn) {
|
|
396
|
+
const key = getKey(appConfig);
|
|
397
|
+
const db = await getDbPromise();
|
|
398
|
+
const tx = db.transaction(OBJECT_STORE_NAME, "readwrite");
|
|
399
|
+
const store = tx.objectStore(OBJECT_STORE_NAME);
|
|
400
|
+
const oldValue = await store.get(key);
|
|
401
|
+
const newValue = updateFn(oldValue);
|
|
402
|
+
if (newValue === void 0) {
|
|
403
|
+
await store.delete(key);
|
|
404
|
+
} else {
|
|
405
|
+
await store.put(newValue, key);
|
|
406
|
+
}
|
|
407
|
+
await tx.done;
|
|
408
|
+
if (newValue && (!oldValue || oldValue.fid !== newValue.fid)) {
|
|
409
|
+
fidChanged(appConfig, newValue.fid);
|
|
410
|
+
}
|
|
411
|
+
return newValue;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* @license
|
|
415
|
+
* Copyright 2019 Google LLC
|
|
416
|
+
*
|
|
417
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
418
|
+
* you may not use this file except in compliance with the License.
|
|
419
|
+
* You may obtain a copy of the License at
|
|
420
|
+
*
|
|
421
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
422
|
+
*
|
|
423
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
424
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
425
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
426
|
+
* See the License for the specific language governing permissions and
|
|
427
|
+
* limitations under the License.
|
|
428
|
+
*/
|
|
429
|
+
async function getInstallationEntry(installations) {
|
|
430
|
+
let registrationPromise;
|
|
431
|
+
const installationEntry = await update(installations.appConfig, (oldEntry) => {
|
|
432
|
+
const installationEntry2 = updateOrCreateInstallationEntry(oldEntry);
|
|
433
|
+
const entryWithPromise = triggerRegistrationIfNecessary(installations, installationEntry2);
|
|
434
|
+
registrationPromise = entryWithPromise.registrationPromise;
|
|
435
|
+
return entryWithPromise.installationEntry;
|
|
436
|
+
});
|
|
437
|
+
if (installationEntry.fid === INVALID_FID) {
|
|
438
|
+
return { installationEntry: await registrationPromise };
|
|
439
|
+
}
|
|
440
|
+
return {
|
|
441
|
+
installationEntry,
|
|
442
|
+
registrationPromise
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
function updateOrCreateInstallationEntry(oldEntry) {
|
|
446
|
+
const entry = oldEntry || {
|
|
447
|
+
fid: generateFid(),
|
|
448
|
+
registrationStatus: 0
|
|
449
|
+
/* RequestStatus.NOT_STARTED */
|
|
450
|
+
};
|
|
451
|
+
return clearTimedOutRequest(entry);
|
|
452
|
+
}
|
|
453
|
+
function triggerRegistrationIfNecessary(installations, installationEntry) {
|
|
454
|
+
if (installationEntry.registrationStatus === 0) {
|
|
455
|
+
if (!navigator.onLine) {
|
|
456
|
+
const registrationPromiseWithError = Promise.reject(ERROR_FACTORY.create(
|
|
457
|
+
"app-offline"
|
|
458
|
+
/* ErrorCode.APP_OFFLINE */
|
|
459
|
+
));
|
|
460
|
+
return {
|
|
461
|
+
installationEntry,
|
|
462
|
+
registrationPromise: registrationPromiseWithError
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
const inProgressEntry = {
|
|
466
|
+
fid: installationEntry.fid,
|
|
467
|
+
registrationStatus: 1,
|
|
468
|
+
registrationTime: Date.now()
|
|
469
|
+
};
|
|
470
|
+
const registrationPromise = registerInstallation(installations, inProgressEntry);
|
|
471
|
+
return { installationEntry: inProgressEntry, registrationPromise };
|
|
472
|
+
} else if (installationEntry.registrationStatus === 1) {
|
|
473
|
+
return {
|
|
474
|
+
installationEntry,
|
|
475
|
+
registrationPromise: waitUntilFidRegistration(installations)
|
|
476
|
+
};
|
|
477
|
+
} else {
|
|
478
|
+
return { installationEntry };
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
async function registerInstallation(installations, installationEntry) {
|
|
482
|
+
try {
|
|
483
|
+
const registeredInstallationEntry = await createInstallationRequest(installations, installationEntry);
|
|
484
|
+
return set(installations.appConfig, registeredInstallationEntry);
|
|
485
|
+
} catch (e) {
|
|
486
|
+
if (isServerError(e) && e.customData.serverCode === 409) {
|
|
487
|
+
await remove(installations.appConfig);
|
|
488
|
+
} else {
|
|
489
|
+
await set(installations.appConfig, {
|
|
490
|
+
fid: installationEntry.fid,
|
|
491
|
+
registrationStatus: 0
|
|
492
|
+
/* RequestStatus.NOT_STARTED */
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
throw e;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
async function waitUntilFidRegistration(installations) {
|
|
499
|
+
let entry = await updateInstallationRequest(installations.appConfig);
|
|
500
|
+
while (entry.registrationStatus === 1) {
|
|
501
|
+
await sleep(100);
|
|
502
|
+
entry = await updateInstallationRequest(installations.appConfig);
|
|
503
|
+
}
|
|
504
|
+
if (entry.registrationStatus === 0) {
|
|
505
|
+
const { installationEntry, registrationPromise } = await getInstallationEntry(installations);
|
|
506
|
+
if (registrationPromise) {
|
|
507
|
+
return registrationPromise;
|
|
508
|
+
} else {
|
|
509
|
+
return installationEntry;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
return entry;
|
|
513
|
+
}
|
|
514
|
+
function updateInstallationRequest(appConfig) {
|
|
515
|
+
return update(appConfig, (oldEntry) => {
|
|
516
|
+
if (!oldEntry) {
|
|
517
|
+
throw ERROR_FACTORY.create(
|
|
518
|
+
"installation-not-found"
|
|
519
|
+
/* ErrorCode.INSTALLATION_NOT_FOUND */
|
|
520
|
+
);
|
|
521
|
+
}
|
|
522
|
+
return clearTimedOutRequest(oldEntry);
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
function clearTimedOutRequest(entry) {
|
|
526
|
+
if (hasInstallationRequestTimedOut(entry)) {
|
|
527
|
+
return {
|
|
528
|
+
fid: entry.fid,
|
|
529
|
+
registrationStatus: 0
|
|
530
|
+
/* RequestStatus.NOT_STARTED */
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
return entry;
|
|
534
|
+
}
|
|
535
|
+
function hasInstallationRequestTimedOut(installationEntry) {
|
|
536
|
+
return installationEntry.registrationStatus === 1 && installationEntry.registrationTime + PENDING_TIMEOUT_MS < Date.now();
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* @license
|
|
540
|
+
* Copyright 2019 Google LLC
|
|
541
|
+
*
|
|
542
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
543
|
+
* you may not use this file except in compliance with the License.
|
|
544
|
+
* You may obtain a copy of the License at
|
|
545
|
+
*
|
|
546
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
547
|
+
*
|
|
548
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
549
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
550
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
551
|
+
* See the License for the specific language governing permissions and
|
|
552
|
+
* limitations under the License.
|
|
553
|
+
*/
|
|
554
|
+
async function generateAuthTokenRequest({ appConfig, heartbeatServiceProvider }, installationEntry) {
|
|
555
|
+
const endpoint = getGenerateAuthTokenEndpoint(appConfig, installationEntry);
|
|
556
|
+
const headers = getHeadersWithAuth(appConfig, installationEntry);
|
|
557
|
+
const heartbeatService = heartbeatServiceProvider.getImmediate({
|
|
558
|
+
optional: true
|
|
559
|
+
});
|
|
560
|
+
if (heartbeatService) {
|
|
561
|
+
const heartbeatsHeader = await heartbeatService.getHeartbeatsHeader();
|
|
562
|
+
if (heartbeatsHeader) {
|
|
563
|
+
headers.append("x-firebase-client", heartbeatsHeader);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
const body = {
|
|
567
|
+
installation: {
|
|
568
|
+
sdkVersion: PACKAGE_VERSION,
|
|
569
|
+
appId: appConfig.appId
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
const request = {
|
|
573
|
+
method: "POST",
|
|
574
|
+
headers,
|
|
575
|
+
body: JSON.stringify(body)
|
|
576
|
+
};
|
|
577
|
+
const response = await retryIfServerError(() => fetch(endpoint, request));
|
|
578
|
+
if (response.ok) {
|
|
579
|
+
const responseValue = await response.json();
|
|
580
|
+
const completedAuthToken = extractAuthTokenInfoFromResponse(responseValue);
|
|
581
|
+
return completedAuthToken;
|
|
582
|
+
} else {
|
|
583
|
+
throw await getErrorFromResponse("Generate Auth Token", response);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
function getGenerateAuthTokenEndpoint(appConfig, { fid }) {
|
|
587
|
+
return `${getInstallationsEndpoint(appConfig)}/${fid}/authTokens:generate`;
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* @license
|
|
591
|
+
* Copyright 2019 Google LLC
|
|
592
|
+
*
|
|
593
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
594
|
+
* you may not use this file except in compliance with the License.
|
|
595
|
+
* You may obtain a copy of the License at
|
|
596
|
+
*
|
|
597
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
598
|
+
*
|
|
599
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
600
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
601
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
602
|
+
* See the License for the specific language governing permissions and
|
|
603
|
+
* limitations under the License.
|
|
604
|
+
*/
|
|
605
|
+
async function refreshAuthToken(installations, forceRefresh = false) {
|
|
606
|
+
let tokenPromise;
|
|
607
|
+
const entry = await update(installations.appConfig, (oldEntry) => {
|
|
608
|
+
if (!isEntryRegistered(oldEntry)) {
|
|
609
|
+
throw ERROR_FACTORY.create(
|
|
610
|
+
"not-registered"
|
|
611
|
+
/* ErrorCode.NOT_REGISTERED */
|
|
612
|
+
);
|
|
613
|
+
}
|
|
614
|
+
const oldAuthToken = oldEntry.authToken;
|
|
615
|
+
if (!forceRefresh && isAuthTokenValid(oldAuthToken)) {
|
|
616
|
+
return oldEntry;
|
|
617
|
+
} else if (oldAuthToken.requestStatus === 1) {
|
|
618
|
+
tokenPromise = waitUntilAuthTokenRequest(installations, forceRefresh);
|
|
619
|
+
return oldEntry;
|
|
620
|
+
} else {
|
|
621
|
+
if (!navigator.onLine) {
|
|
622
|
+
throw ERROR_FACTORY.create(
|
|
623
|
+
"app-offline"
|
|
624
|
+
/* ErrorCode.APP_OFFLINE */
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
const inProgressEntry = makeAuthTokenRequestInProgressEntry(oldEntry);
|
|
628
|
+
tokenPromise = fetchAuthTokenFromServer(installations, inProgressEntry);
|
|
629
|
+
return inProgressEntry;
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
const authToken = tokenPromise ? await tokenPromise : entry.authToken;
|
|
633
|
+
return authToken;
|
|
634
|
+
}
|
|
635
|
+
async function waitUntilAuthTokenRequest(installations, forceRefresh) {
|
|
636
|
+
let entry = await updateAuthTokenRequest(installations.appConfig);
|
|
637
|
+
while (entry.authToken.requestStatus === 1) {
|
|
638
|
+
await sleep(100);
|
|
639
|
+
entry = await updateAuthTokenRequest(installations.appConfig);
|
|
640
|
+
}
|
|
641
|
+
const authToken = entry.authToken;
|
|
642
|
+
if (authToken.requestStatus === 0) {
|
|
643
|
+
return refreshAuthToken(installations, forceRefresh);
|
|
644
|
+
} else {
|
|
645
|
+
return authToken;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
function updateAuthTokenRequest(appConfig) {
|
|
649
|
+
return update(appConfig, (oldEntry) => {
|
|
650
|
+
if (!isEntryRegistered(oldEntry)) {
|
|
651
|
+
throw ERROR_FACTORY.create(
|
|
652
|
+
"not-registered"
|
|
653
|
+
/* ErrorCode.NOT_REGISTERED */
|
|
654
|
+
);
|
|
655
|
+
}
|
|
656
|
+
const oldAuthToken = oldEntry.authToken;
|
|
657
|
+
if (hasAuthTokenRequestTimedOut(oldAuthToken)) {
|
|
658
|
+
return Object.assign(Object.assign({}, oldEntry), { authToken: {
|
|
659
|
+
requestStatus: 0
|
|
660
|
+
/* RequestStatus.NOT_STARTED */
|
|
661
|
+
} });
|
|
662
|
+
}
|
|
663
|
+
return oldEntry;
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
async function fetchAuthTokenFromServer(installations, installationEntry) {
|
|
667
|
+
try {
|
|
668
|
+
const authToken = await generateAuthTokenRequest(installations, installationEntry);
|
|
669
|
+
const updatedInstallationEntry = Object.assign(Object.assign({}, installationEntry), { authToken });
|
|
670
|
+
await set(installations.appConfig, updatedInstallationEntry);
|
|
671
|
+
return authToken;
|
|
672
|
+
} catch (e) {
|
|
673
|
+
if (isServerError(e) && (e.customData.serverCode === 401 || e.customData.serverCode === 404)) {
|
|
674
|
+
await remove(installations.appConfig);
|
|
675
|
+
} else {
|
|
676
|
+
const updatedInstallationEntry = Object.assign(Object.assign({}, installationEntry), { authToken: {
|
|
677
|
+
requestStatus: 0
|
|
678
|
+
/* RequestStatus.NOT_STARTED */
|
|
679
|
+
} });
|
|
680
|
+
await set(installations.appConfig, updatedInstallationEntry);
|
|
681
|
+
}
|
|
682
|
+
throw e;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
function isEntryRegistered(installationEntry) {
|
|
686
|
+
return installationEntry !== void 0 && installationEntry.registrationStatus === 2;
|
|
687
|
+
}
|
|
688
|
+
function isAuthTokenValid(authToken) {
|
|
689
|
+
return authToken.requestStatus === 2 && !isAuthTokenExpired(authToken);
|
|
690
|
+
}
|
|
691
|
+
function isAuthTokenExpired(authToken) {
|
|
692
|
+
const now = Date.now();
|
|
693
|
+
return now < authToken.creationTime || authToken.creationTime + authToken.expiresIn < now + TOKEN_EXPIRATION_BUFFER;
|
|
694
|
+
}
|
|
695
|
+
function makeAuthTokenRequestInProgressEntry(oldEntry) {
|
|
696
|
+
const inProgressAuthToken = {
|
|
697
|
+
requestStatus: 1,
|
|
698
|
+
requestTime: Date.now()
|
|
699
|
+
};
|
|
700
|
+
return Object.assign(Object.assign({}, oldEntry), { authToken: inProgressAuthToken });
|
|
701
|
+
}
|
|
702
|
+
function hasAuthTokenRequestTimedOut(authToken) {
|
|
703
|
+
return authToken.requestStatus === 1 && authToken.requestTime + PENDING_TIMEOUT_MS < Date.now();
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* @license
|
|
707
|
+
* Copyright 2019 Google LLC
|
|
708
|
+
*
|
|
709
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
710
|
+
* you may not use this file except in compliance with the License.
|
|
711
|
+
* You may obtain a copy of the License at
|
|
712
|
+
*
|
|
713
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
714
|
+
*
|
|
715
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
716
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
717
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
718
|
+
* See the License for the specific language governing permissions and
|
|
719
|
+
* limitations under the License.
|
|
720
|
+
*/
|
|
721
|
+
async function getId(installations) {
|
|
722
|
+
const installationsImpl = installations;
|
|
723
|
+
const { installationEntry, registrationPromise } = await getInstallationEntry(installationsImpl);
|
|
724
|
+
if (registrationPromise) {
|
|
725
|
+
registrationPromise.catch(console.error);
|
|
726
|
+
} else {
|
|
727
|
+
refreshAuthToken(installationsImpl).catch(console.error);
|
|
728
|
+
}
|
|
729
|
+
return installationEntry.fid;
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* @license
|
|
733
|
+
* Copyright 2019 Google LLC
|
|
734
|
+
*
|
|
735
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
736
|
+
* you may not use this file except in compliance with the License.
|
|
737
|
+
* You may obtain a copy of the License at
|
|
738
|
+
*
|
|
739
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
740
|
+
*
|
|
741
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
742
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
743
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
744
|
+
* See the License for the specific language governing permissions and
|
|
745
|
+
* limitations under the License.
|
|
746
|
+
*/
|
|
747
|
+
async function getToken(installations, forceRefresh = false) {
|
|
748
|
+
const installationsImpl = installations;
|
|
749
|
+
await completeInstallationRegistration(installationsImpl);
|
|
750
|
+
const authToken = await refreshAuthToken(installationsImpl, forceRefresh);
|
|
751
|
+
return authToken.token;
|
|
752
|
+
}
|
|
753
|
+
async function completeInstallationRegistration(installations) {
|
|
754
|
+
const { registrationPromise } = await getInstallationEntry(installations);
|
|
755
|
+
if (registrationPromise) {
|
|
756
|
+
await registrationPromise;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* @license
|
|
761
|
+
* Copyright 2019 Google LLC
|
|
762
|
+
*
|
|
763
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
764
|
+
* you may not use this file except in compliance with the License.
|
|
765
|
+
* You may obtain a copy of the License at
|
|
766
|
+
*
|
|
767
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
768
|
+
*
|
|
769
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
770
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
771
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
772
|
+
* See the License for the specific language governing permissions and
|
|
773
|
+
* limitations under the License.
|
|
774
|
+
*/
|
|
775
|
+
function extractAppConfig(app) {
|
|
776
|
+
if (!app || !app.options) {
|
|
777
|
+
throw getMissingValueError("App Configuration");
|
|
778
|
+
}
|
|
779
|
+
if (!app.name) {
|
|
780
|
+
throw getMissingValueError("App Name");
|
|
781
|
+
}
|
|
782
|
+
const configKeys = [
|
|
783
|
+
"projectId",
|
|
784
|
+
"apiKey",
|
|
785
|
+
"appId"
|
|
786
|
+
];
|
|
787
|
+
for (const keyName of configKeys) {
|
|
788
|
+
if (!app.options[keyName]) {
|
|
789
|
+
throw getMissingValueError(keyName);
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
return {
|
|
793
|
+
appName: app.name,
|
|
794
|
+
projectId: app.options.projectId,
|
|
795
|
+
apiKey: app.options.apiKey,
|
|
796
|
+
appId: app.options.appId
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
function getMissingValueError(valueName) {
|
|
800
|
+
return ERROR_FACTORY.create("missing-app-config-values", {
|
|
801
|
+
valueName
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
/**
|
|
805
|
+
* @license
|
|
806
|
+
* Copyright 2020 Google LLC
|
|
807
|
+
*
|
|
808
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
809
|
+
* you may not use this file except in compliance with the License.
|
|
810
|
+
* You may obtain a copy of the License at
|
|
811
|
+
*
|
|
812
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
813
|
+
*
|
|
814
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
815
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
816
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
817
|
+
* See the License for the specific language governing permissions and
|
|
818
|
+
* limitations under the License.
|
|
819
|
+
*/
|
|
820
|
+
const INSTALLATIONS_NAME = "installations";
|
|
821
|
+
const INSTALLATIONS_NAME_INTERNAL = "installations-internal";
|
|
822
|
+
const publicFactory = (container) => {
|
|
823
|
+
const app = container.getProvider("app").getImmediate();
|
|
824
|
+
const appConfig = extractAppConfig(app);
|
|
825
|
+
const heartbeatServiceProvider = _getProvider(app, "heartbeat");
|
|
826
|
+
const installationsImpl = {
|
|
827
|
+
app,
|
|
828
|
+
appConfig,
|
|
829
|
+
heartbeatServiceProvider,
|
|
830
|
+
_delete: () => Promise.resolve()
|
|
831
|
+
};
|
|
832
|
+
return installationsImpl;
|
|
833
|
+
};
|
|
834
|
+
const internalFactory = (container) => {
|
|
835
|
+
const app = container.getProvider("app").getImmediate();
|
|
836
|
+
const installations = _getProvider(app, INSTALLATIONS_NAME).getImmediate();
|
|
837
|
+
const installationsInternal = {
|
|
838
|
+
getId: () => getId(installations),
|
|
839
|
+
getToken: (forceRefresh) => getToken(installations, forceRefresh)
|
|
840
|
+
};
|
|
841
|
+
return installationsInternal;
|
|
842
|
+
};
|
|
843
|
+
function registerInstallations() {
|
|
844
|
+
_registerComponent(new Component(
|
|
845
|
+
INSTALLATIONS_NAME,
|
|
846
|
+
publicFactory,
|
|
847
|
+
"PUBLIC"
|
|
848
|
+
/* ComponentType.PUBLIC */
|
|
849
|
+
));
|
|
850
|
+
_registerComponent(new Component(
|
|
851
|
+
INSTALLATIONS_NAME_INTERNAL,
|
|
852
|
+
internalFactory,
|
|
853
|
+
"PRIVATE"
|
|
854
|
+
/* ComponentType.PRIVATE */
|
|
855
|
+
));
|
|
856
|
+
}
|
|
857
|
+
registerInstallations();
|
|
858
|
+
registerVersion(name, version);
|
|
859
|
+
registerVersion(name, version, "esm2017");
|
|
860
|
+
export {
|
|
861
|
+
getId,
|
|
862
|
+
getToken
|
|
863
|
+
};
|