@progressive-development/pd-spa-helper 0.4.0 → 0.5.0

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.
Files changed (194) hide show
  1. package/dist/PdSpaHelper.d.ts.map +1 -1
  2. package/dist/{src/PdSpaHelper.js → PdSpaHelper.js} +16 -17
  3. package/dist/defaultpage/default-confirm-popup.d.ts.map +1 -1
  4. package/dist/{src/defaultpage → defaultpage}/default-confirm-popup.js +4 -5
  5. package/dist/defaultpage/default-dialog-popup.d.ts.map +1 -1
  6. package/dist/{src/defaultpage → defaultpage}/default-dialog-popup.js +4 -5
  7. package/dist/{src/defaultpage → defaultpage}/default-login.js +2 -3
  8. package/dist/defaultpage/default-popup.d.ts.map +1 -1
  9. package/dist/{src/defaultpage → defaultpage}/default-popup.js +1 -1
  10. package/dist/{src/defaultpage → defaultpage}/default-step-address.js +5 -6
  11. package/dist/{src/defaultpage → defaultpage}/default-step-summary.js +6 -7
  12. package/dist/{src/defaultpage → defaultpage}/default-view-page.js +2 -3
  13. package/dist/{src/defaultpage → defaultpage}/default-wizard-step.js +4 -5
  14. package/dist/defaultpage/default-wizard.d.ts.map +1 -1
  15. package/dist/{src/defaultpage → defaultpage}/default-wizard.js +7 -8
  16. package/dist/generated/locale-wrapper/be-wrapper.d.ts +15 -1
  17. package/dist/generated/locale-wrapper/be-wrapper.d.ts.map +1 -1
  18. package/dist/generated/locale-wrapper/be-wrapper.js +17 -0
  19. package/dist/generated/locale-wrapper/de-wrapper.d.ts.map +1 -1
  20. package/dist/generated/locale-wrapper/de-wrapper.js +17 -0
  21. package/dist/generated/locale-wrapper/en-wrapper.d.ts +15 -1
  22. package/dist/generated/locale-wrapper/en-wrapper.d.ts.map +1 -1
  23. package/dist/generated/locale-wrapper/en-wrapper.js +17 -0
  24. package/dist/index.js +21 -21
  25. package/dist/pd-panel-viewer.js +10 -12
  26. package/dist/pd-panel.js +2 -3
  27. package/dist/{src/popup → popup}/wizard-close-popup.js +3 -5
  28. package/dist/{src/popup → popup}/wizard-reload-popup.js +3 -5
  29. package/dist/{src/router → router}/AppMain.js +4 -5
  30. package/dist/{src/service-provider → service-provider}/firebase/auth.js +1 -4
  31. package/dist/{src/service-provider → service-provider}/firebase/firestorage-client.js +1 -1
  32. package/dist/{src/service-provider → service-provider}/firebase/firestore-client.js +1 -1
  33. package/dist/{src/service-provider → service-provider}/firebase/functions-client.js +1 -1
  34. package/dist/{src/service-provider → service-provider}/firebase/messagingFirebaseClient.js +2 -2
  35. package/dist/{src/service-provider → service-provider}/service-provider-impl.js +1 -2
  36. package/dist/{src/store → store}/mini-rx.store.js +1 -1
  37. package/dist/{src/store → store}/spa-app-effects.js +2 -2
  38. package/dist/{src/store → store}/spa-app-selector.js +1 -1
  39. package/dist/stories/pd-loading-state.stories.d.ts +3 -3
  40. package/dist/stories/pd-toast.stories.d.ts +3 -3
  41. package/dist/tmpown/pd-loading-state.d.ts.map +1 -1
  42. package/dist/{src/tmpown → tmpown}/pd-loading-state.js +6 -8
  43. package/dist/tmpown/pd-login.d.ts.map +1 -1
  44. package/dist/{src/tmpown → tmpown}/pd-login.js +6 -7
  45. package/dist/tmpown/pd-panel-viewer.d.ts.map +1 -1
  46. package/dist/{src/tmpown → tmpown}/pd-toast.js +5 -7
  47. package/package.json +24 -21
  48. package/dist/node_modules/@firebase/app/dist/esm/index.esm2017.js +0 -749
  49. package/dist/node_modules/@firebase/auth/dist/esm2017/index-68602d24.js +0 -6265
  50. package/dist/node_modules/@firebase/component/dist/esm/index.esm2017.js +0 -341
  51. package/dist/node_modules/@firebase/firestore/dist/index.esm2017.js +0 -10250
  52. package/dist/node_modules/@firebase/functions/dist/index.esm2017.js +0 -513
  53. package/dist/node_modules/@firebase/installations/dist/esm/index.esm2017.js +0 -863
  54. package/dist/node_modules/@firebase/logger/dist/esm/index.esm2017.js +0 -122
  55. package/dist/node_modules/@firebase/messaging/dist/esm/index.esm2017.js +0 -1019
  56. package/dist/node_modules/@firebase/storage/dist/index.esm2017.js +0 -2042
  57. package/dist/node_modules/@firebase/util/dist/index.esm2017.js +0 -931
  58. package/dist/node_modules/@firebase/webchannel-wrapper/dist/bloom-blob/esm/bloom_blob_es2018.js +0 -417
  59. package/dist/node_modules/@firebase/webchannel-wrapper/dist/webchannel-blob/esm/webchannel_blob_es2018.js +0 -2155
  60. package/dist/node_modules/@lit/reactive-element/decorators/custom-element.js +0 -14
  61. package/dist/node_modules/@lit/reactive-element/decorators/property.js +0 -20
  62. package/dist/node_modules/@lit/reactive-element/decorators/query-assigned-elements.js +0 -7
  63. package/dist/node_modules/@progressive-development/pd-dialog/pd-popup-dialog.js +0 -5
  64. package/dist/node_modules/@progressive-development/pd-dialog/pd-popup.js +0 -2
  65. package/dist/node_modules/@progressive-development/pd-dialog/src/PdPopup.js +0 -113
  66. package/dist/node_modules/@progressive-development/pd-dialog/src/PdPopupDialog.js +0 -189
  67. package/dist/node_modules/@progressive-development/pd-forms/pd-button.js +0 -2
  68. package/dist/node_modules/@progressive-development/pd-forms/pd-form-container.js +0 -2
  69. package/dist/node_modules/@progressive-development/pd-forms/pd-form-row.js +0 -2
  70. package/dist/node_modules/@progressive-development/pd-forms/pd-hover-box.js +0 -2
  71. package/dist/node_modules/@progressive-development/pd-forms/pd-input.js +0 -2
  72. package/dist/node_modules/@progressive-development/pd-forms/src/PdBaseInputElement.js +0 -86
  73. package/dist/node_modules/@progressive-development/pd-forms/src/PdBaseUi.js +0 -34
  74. package/dist/node_modules/@progressive-development/pd-forms/src/PdBaseUiInput.js +0 -227
  75. package/dist/node_modules/@progressive-development/pd-forms/src/PdButton.js +0 -194
  76. package/dist/node_modules/@progressive-development/pd-forms/src/PdFormContainer.js +0 -167
  77. package/dist/node_modules/@progressive-development/pd-forms/src/PdFormRow.js +0 -92
  78. package/dist/node_modules/@progressive-development/pd-forms/src/PdHoverBox.js +0 -108
  79. package/dist/node_modules/@progressive-development/pd-forms/src/PdInput.js +0 -79
  80. package/dist/node_modules/@progressive-development/pd-forms/src/generated/locale/be.js +0 -11
  81. package/dist/node_modules/@progressive-development/pd-forms/src/generated/locale/en.js +0 -11
  82. package/dist/node_modules/@progressive-development/pd-forms/src/shared-input-field-styles.js +0 -152
  83. package/dist/node_modules/@progressive-development/pd-forms/src/shared-input-styles.js +0 -64
  84. package/dist/node_modules/@progressive-development/pd-icon/pd-icon.js +0 -4
  85. package/dist/node_modules/@progressive-development/pd-icon/src/PdIcon.js +0 -596
  86. package/dist/node_modules/@progressive-development/pd-order/dist/locales/be.js +0 -15
  87. package/dist/node_modules/@progressive-development/pd-order/dist/locales/de.js +0 -15
  88. package/dist/node_modules/@progressive-development/pd-order/dist/locales/en.js +0 -15
  89. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-contact/pd-contact.js +0 -2
  90. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-contact/src/PdContact.js +0 -567
  91. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-content/pd-collapse.js +0 -2
  92. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-content/pd-edit-content.js +0 -2
  93. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-content/src/PdCollapse.js +0 -136
  94. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-content/src/PdEditContent.js +0 -224
  95. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-dialog/pd-popup.js +0 -2
  96. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-dialog/src/PdPopup.js +0 -113
  97. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/pd-checkbox.js +0 -2
  98. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/pd-form-container.js +0 -2
  99. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/pd-form-row.js +0 -2
  100. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/pd-hover-box.js +0 -2
  101. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/pd-input.js +0 -2
  102. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/pd-radio-group.js +0 -2
  103. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdBaseInputElement.js +0 -86
  104. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdBaseUi.js +0 -34
  105. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdBaseUiInput.js +0 -229
  106. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdCheckbox.js +0 -230
  107. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdFormContainer.js +0 -167
  108. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdFormRow.js +0 -92
  109. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdHoverBox.js +0 -108
  110. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdInput.js +0 -79
  111. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/PdRadioGroup.js +0 -72
  112. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/shared-input-field-styles.js +0 -152
  113. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-forms/src/shared-input-styles.js +0 -64
  114. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-icon/pd-icon.js +0 -4
  115. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-icon/src/PdIcon.js +0 -596
  116. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-price/pd-pricetable.js +0 -2
  117. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/@progressive-development/pd-price/src/PdPricetable.js +0 -149
  118. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/fecha/lib/fecha.js +0 -200
  119. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/lit/node_modules/lit-html/directive.js +0 -27
  120. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/lit/node_modules/lit-html/directives/class-map.js +0 -36
  121. package/dist/node_modules/@progressive-development/pd-order/dist/node_modules/lit/node_modules/lit-html/lit-html.js +0 -242
  122. package/dist/node_modules/@progressive-development/pd-order/dist/pd-order-contacts.js +0 -2
  123. package/dist/node_modules/@progressive-development/pd-order/dist/pd-order-summary.js +0 -2
  124. package/dist/node_modules/@progressive-development/pd-order/dist/src/PdOrderContacts.js +0 -192
  125. package/dist/node_modules/@progressive-development/pd-order/dist/src/PdOrderSummary.js +0 -243
  126. package/dist/node_modules/@progressive-development/pd-page/pd-footer.js +0 -2
  127. package/dist/node_modules/@progressive-development/pd-page/pd-menu.js +0 -2
  128. package/dist/node_modules/@progressive-development/pd-page/src/PdFooter.js +0 -141
  129. package/dist/node_modules/@progressive-development/pd-page/src/PdMenu.js +0 -450
  130. package/dist/node_modules/@progressive-development/pd-shared-styles/src/shared-color-styles.js +0 -30
  131. package/dist/node_modules/@progressive-development/pd-shared-styles/src/shared-font-styles.js +0 -32
  132. package/dist/node_modules/@progressive-development/pd-wizard/pd-wizard.js +0 -2
  133. package/dist/node_modules/@progressive-development/pd-wizard/src/PdSteps.js +0 -191
  134. package/dist/node_modules/@progressive-development/pd-wizard/src/PdWizard.js +0 -280
  135. package/dist/node_modules/firebase/app/dist/esm/index.esm.js +0 -35
  136. package/dist/node_modules/idb/build/index.js +0 -81
  137. package/dist/node_modules/idb/build/wrap-idb-value.js +0 -148
  138. package/dist/node_modules/lit/node_modules/lit-html/directive.js +0 -27
  139. package/dist/node_modules/lit/node_modules/lit-html/directives/class-map.js +0 -36
  140. package/dist/node_modules/lit/node_modules/lit-html/lit-html.js +0 -242
  141. package/dist/node_modules/lit-element-router/lit-element-router.js +0 -131
  142. package/dist/node_modules/lit-element-router/utility/router-utility.js +0 -36
  143. package/dist/node_modules/mini-rx-store/index.esm.js +0 -458
  144. package/dist/node_modules/pwa-helpers/media-query.js +0 -17
  145. package/dist/node_modules/rxjs/dist/esm5/internal/Observable.js +0 -100
  146. package/dist/node_modules/rxjs/dist/esm5/internal/Subscriber.js +0 -147
  147. package/dist/node_modules/rxjs/dist/esm5/internal/Subscription.js +0 -139
  148. package/dist/node_modules/rxjs/dist/esm5/internal/config.js +0 -10
  149. package/dist/node_modules/rxjs/dist/esm5/internal/observable/innerFrom.js +0 -159
  150. package/dist/node_modules/rxjs/dist/esm5/internal/operators/OperatorSubscriber.js +0 -52
  151. package/dist/node_modules/rxjs/dist/esm5/internal/operators/catchError.js +0 -28
  152. package/dist/node_modules/rxjs/dist/esm5/internal/operators/distinctUntilChanged.js +0 -27
  153. package/dist/node_modules/rxjs/dist/esm5/internal/operators/filter.js +0 -13
  154. package/dist/node_modules/rxjs/dist/esm5/internal/operators/map.js +0 -13
  155. package/dist/node_modules/rxjs/dist/esm5/internal/operators/observeOn.js +0 -26
  156. package/dist/node_modules/rxjs/dist/esm5/internal/operators/tap.js +0 -36
  157. package/dist/node_modules/rxjs/dist/esm5/internal/operators/withLatestFrom.js +0 -43
  158. package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js +0 -18
  159. package/dist/node_modules/rxjs/dist/esm5/internal/symbol/iterator.js +0 -11
  160. package/dist/node_modules/rxjs/dist/esm5/internal/symbol/observable.js +0 -6
  161. package/dist/node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js +0 -14
  162. package/dist/node_modules/rxjs/dist/esm5/internal/util/args.js +0 -10
  163. package/dist/node_modules/rxjs/dist/esm5/internal/util/arrRemove.js +0 -9
  164. package/dist/node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js +0 -13
  165. package/dist/node_modules/rxjs/dist/esm5/internal/util/errorContext.js +0 -8
  166. package/dist/node_modules/rxjs/dist/esm5/internal/util/executeSchedule.js +0 -23
  167. package/dist/node_modules/rxjs/dist/esm5/internal/util/identity.js +0 -6
  168. package/dist/node_modules/rxjs/dist/esm5/internal/util/isArrayLike.js +0 -6
  169. package/dist/node_modules/rxjs/dist/esm5/internal/util/isAsyncIterable.js +0 -7
  170. package/dist/node_modules/rxjs/dist/esm5/internal/util/isFunction.js +0 -6
  171. package/dist/node_modules/rxjs/dist/esm5/internal/util/isInteropObservable.js +0 -8
  172. package/dist/node_modules/rxjs/dist/esm5/internal/util/isIterable.js +0 -8
  173. package/dist/node_modules/rxjs/dist/esm5/internal/util/isPromise.js +0 -7
  174. package/dist/node_modules/rxjs/dist/esm5/internal/util/isReadableStreamLike.js +0 -46
  175. package/dist/node_modules/rxjs/dist/esm5/internal/util/lift.js +0 -22
  176. package/dist/node_modules/rxjs/dist/esm5/internal/util/noop.js +0 -5
  177. package/dist/node_modules/rxjs/dist/esm5/internal/util/pipe.js +0 -17
  178. package/dist/node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js +0 -11
  179. package/dist/node_modules/rxjs/dist/esm5/internal/util/throwUnobservableError.js +0 -6
  180. package/dist/src/generated/locale-wrapper/be-wrapper.js +0 -15
  181. package/dist/src/generated/locale-wrapper/de-wrapper.js +0 -13
  182. package/dist/src/generated/locale-wrapper/en-wrapper.js +0 -15
  183. /package/dist/{src/generated → generated}/locales/be.js +0 -0
  184. /package/dist/{src/generated → generated}/locales/de.js +0 -0
  185. /package/dist/{src/generated → generated}/locales/en.js +0 -0
  186. /package/dist/{src/helper → helper}/helper-utils.js +0 -0
  187. /package/dist/{src/model → model}/spa-model.js +0 -0
  188. /package/dist/{src/service-provider → service-provider}/mock/auth.js +0 -0
  189. /package/dist/{src/service-provider → service-provider}/mock/function-client.js +0 -0
  190. /package/dist/{src/service-provider → service-provider}/mock/storage-client.js +0 -0
  191. /package/dist/{src/service-provider → service-provider}/service-provider-model.js +0 -0
  192. /package/dist/{src/store → store}/indexDB.js +0 -0
  193. /package/dist/{src/store → store}/spa-app-actions.js +0 -0
  194. /package/dist/{src/store → store}/spa-app-reducer.js +0 -0
@@ -1,1019 +0,0 @@
1
- import "../../../installations/dist/esm/index.esm2017.js";
2
- import { Component } from "../../../component/dist/esm/index.esm2017.js";
3
- import { openDB, deleteDB } from "../../../../idb/build/index.js";
4
- import { ErrorFactory, getModularInstance, validateIndexedDBOpenable, isIndexedDBAvailable, areCookiesEnabled } from "../../../util/dist/index.esm2017.js";
5
- import { _registerComponent, registerVersion, _getProvider, getApp } from "../../../app/dist/esm/index.esm2017.js";
6
- /**
7
- * @license
8
- * Copyright 2019 Google LLC
9
- *
10
- * Licensed under the Apache License, Version 2.0 (the "License");
11
- * you may not use this file except in compliance with the License.
12
- * You may obtain a copy of the License at
13
- *
14
- * http://www.apache.org/licenses/LICENSE-2.0
15
- *
16
- * Unless required by applicable law or agreed to in writing, software
17
- * distributed under the License is distributed on an "AS IS" BASIS,
18
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
- * See the License for the specific language governing permissions and
20
- * limitations under the License.
21
- */
22
- const DEFAULT_SW_PATH = "/firebase-messaging-sw.js";
23
- const DEFAULT_SW_SCOPE = "/firebase-cloud-messaging-push-scope";
24
- const DEFAULT_VAPID_KEY = "BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4";
25
- const ENDPOINT = "https://fcmregistrations.googleapis.com/v1";
26
- const CONSOLE_CAMPAIGN_ID = "google.c.a.c_id";
27
- const CONSOLE_CAMPAIGN_NAME = "google.c.a.c_l";
28
- const CONSOLE_CAMPAIGN_TIME = "google.c.a.ts";
29
- const CONSOLE_CAMPAIGN_ANALYTICS_ENABLED = "google.c.a.e";
30
- var MessageType$1;
31
- (function(MessageType2) {
32
- MessageType2[MessageType2["DATA_MESSAGE"] = 1] = "DATA_MESSAGE";
33
- MessageType2[MessageType2["DISPLAY_NOTIFICATION"] = 3] = "DISPLAY_NOTIFICATION";
34
- })(MessageType$1 || (MessageType$1 = {}));
35
- /**
36
- * @license
37
- * Copyright 2018 Google LLC
38
- *
39
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
40
- * in compliance with the License. You may obtain a copy of the License at
41
- *
42
- * http://www.apache.org/licenses/LICENSE-2.0
43
- *
44
- * Unless required by applicable law or agreed to in writing, software distributed under the License
45
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
46
- * or implied. See the License for the specific language governing permissions and limitations under
47
- * the License.
48
- */
49
- var MessageType;
50
- (function(MessageType2) {
51
- MessageType2["PUSH_RECEIVED"] = "push-received";
52
- MessageType2["NOTIFICATION_CLICKED"] = "notification-clicked";
53
- })(MessageType || (MessageType = {}));
54
- /**
55
- * @license
56
- * Copyright 2017 Google LLC
57
- *
58
- * Licensed under the Apache License, Version 2.0 (the "License");
59
- * you may not use this file except in compliance with the License.
60
- * You may obtain a copy of the License at
61
- *
62
- * http://www.apache.org/licenses/LICENSE-2.0
63
- *
64
- * Unless required by applicable law or agreed to in writing, software
65
- * distributed under the License is distributed on an "AS IS" BASIS,
66
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
67
- * See the License for the specific language governing permissions and
68
- * limitations under the License.
69
- */
70
- function arrayToBase64(array) {
71
- const uint8Array = new Uint8Array(array);
72
- const base64String = btoa(String.fromCharCode(...uint8Array));
73
- return base64String.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
74
- }
75
- function base64ToArray(base64String) {
76
- const padding = "=".repeat((4 - base64String.length % 4) % 4);
77
- const base64 = (base64String + padding).replace(/\-/g, "+").replace(/_/g, "/");
78
- const rawData = atob(base64);
79
- const outputArray = new Uint8Array(rawData.length);
80
- for (let i = 0; i < rawData.length; ++i) {
81
- outputArray[i] = rawData.charCodeAt(i);
82
- }
83
- return outputArray;
84
- }
85
- /**
86
- * @license
87
- * Copyright 2019 Google LLC
88
- *
89
- * Licensed under the Apache License, Version 2.0 (the "License");
90
- * you may not use this file except in compliance with the License.
91
- * You may obtain a copy of the License at
92
- *
93
- * http://www.apache.org/licenses/LICENSE-2.0
94
- *
95
- * Unless required by applicable law or agreed to in writing, software
96
- * distributed under the License is distributed on an "AS IS" BASIS,
97
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
98
- * See the License for the specific language governing permissions and
99
- * limitations under the License.
100
- */
101
- const OLD_DB_NAME = "fcm_token_details_db";
102
- const OLD_DB_VERSION = 5;
103
- const OLD_OBJECT_STORE_NAME = "fcm_token_object_Store";
104
- async function migrateOldDatabase(senderId) {
105
- if ("databases" in indexedDB) {
106
- const databases = await indexedDB.databases();
107
- const dbNames = databases.map((db2) => db2.name);
108
- if (!dbNames.includes(OLD_DB_NAME)) {
109
- return null;
110
- }
111
- }
112
- let tokenDetails = null;
113
- const db = await openDB(OLD_DB_NAME, OLD_DB_VERSION, {
114
- upgrade: async (db2, oldVersion, newVersion, upgradeTransaction) => {
115
- var _a;
116
- if (oldVersion < 2) {
117
- return;
118
- }
119
- if (!db2.objectStoreNames.contains(OLD_OBJECT_STORE_NAME)) {
120
- return;
121
- }
122
- const objectStore = upgradeTransaction.objectStore(OLD_OBJECT_STORE_NAME);
123
- const value = await objectStore.index("fcmSenderId").get(senderId);
124
- await objectStore.clear();
125
- if (!value) {
126
- return;
127
- }
128
- if (oldVersion === 2) {
129
- const oldDetails = value;
130
- if (!oldDetails.auth || !oldDetails.p256dh || !oldDetails.endpoint) {
131
- return;
132
- }
133
- tokenDetails = {
134
- token: oldDetails.fcmToken,
135
- createTime: (_a = oldDetails.createTime) !== null && _a !== void 0 ? _a : Date.now(),
136
- subscriptionOptions: {
137
- auth: oldDetails.auth,
138
- p256dh: oldDetails.p256dh,
139
- endpoint: oldDetails.endpoint,
140
- swScope: oldDetails.swScope,
141
- vapidKey: typeof oldDetails.vapidKey === "string" ? oldDetails.vapidKey : arrayToBase64(oldDetails.vapidKey)
142
- }
143
- };
144
- } else if (oldVersion === 3) {
145
- const oldDetails = value;
146
- tokenDetails = {
147
- token: oldDetails.fcmToken,
148
- createTime: oldDetails.createTime,
149
- subscriptionOptions: {
150
- auth: arrayToBase64(oldDetails.auth),
151
- p256dh: arrayToBase64(oldDetails.p256dh),
152
- endpoint: oldDetails.endpoint,
153
- swScope: oldDetails.swScope,
154
- vapidKey: arrayToBase64(oldDetails.vapidKey)
155
- }
156
- };
157
- } else if (oldVersion === 4) {
158
- const oldDetails = value;
159
- tokenDetails = {
160
- token: oldDetails.fcmToken,
161
- createTime: oldDetails.createTime,
162
- subscriptionOptions: {
163
- auth: arrayToBase64(oldDetails.auth),
164
- p256dh: arrayToBase64(oldDetails.p256dh),
165
- endpoint: oldDetails.endpoint,
166
- swScope: oldDetails.swScope,
167
- vapidKey: arrayToBase64(oldDetails.vapidKey)
168
- }
169
- };
170
- }
171
- }
172
- });
173
- db.close();
174
- await deleteDB(OLD_DB_NAME);
175
- await deleteDB("fcm_vapid_details_db");
176
- await deleteDB("undefined");
177
- return checkTokenDetails(tokenDetails) ? tokenDetails : null;
178
- }
179
- function checkTokenDetails(tokenDetails) {
180
- if (!tokenDetails || !tokenDetails.subscriptionOptions) {
181
- return false;
182
- }
183
- const { subscriptionOptions } = tokenDetails;
184
- return typeof tokenDetails.createTime === "number" && tokenDetails.createTime > 0 && typeof tokenDetails.token === "string" && tokenDetails.token.length > 0 && typeof subscriptionOptions.auth === "string" && subscriptionOptions.auth.length > 0 && typeof subscriptionOptions.p256dh === "string" && subscriptionOptions.p256dh.length > 0 && typeof subscriptionOptions.endpoint === "string" && subscriptionOptions.endpoint.length > 0 && typeof subscriptionOptions.swScope === "string" && subscriptionOptions.swScope.length > 0 && typeof subscriptionOptions.vapidKey === "string" && subscriptionOptions.vapidKey.length > 0;
185
- }
186
- /**
187
- * @license
188
- * Copyright 2019 Google LLC
189
- *
190
- * Licensed under the Apache License, Version 2.0 (the "License");
191
- * you may not use this file except in compliance with the License.
192
- * You may obtain a copy of the License at
193
- *
194
- * http://www.apache.org/licenses/LICENSE-2.0
195
- *
196
- * Unless required by applicable law or agreed to in writing, software
197
- * distributed under the License is distributed on an "AS IS" BASIS,
198
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
199
- * See the License for the specific language governing permissions and
200
- * limitations under the License.
201
- */
202
- const DATABASE_NAME = "firebase-messaging-database";
203
- const DATABASE_VERSION = 1;
204
- const OBJECT_STORE_NAME = "firebase-messaging-store";
205
- let dbPromise = null;
206
- function getDbPromise() {
207
- if (!dbPromise) {
208
- dbPromise = openDB(DATABASE_NAME, DATABASE_VERSION, {
209
- upgrade: (upgradeDb, oldVersion) => {
210
- switch (oldVersion) {
211
- case 0:
212
- upgradeDb.createObjectStore(OBJECT_STORE_NAME);
213
- }
214
- }
215
- });
216
- }
217
- return dbPromise;
218
- }
219
- async function dbGet(firebaseDependencies) {
220
- const key = getKey(firebaseDependencies);
221
- const db = await getDbPromise();
222
- const tokenDetails = await db.transaction(OBJECT_STORE_NAME).objectStore(OBJECT_STORE_NAME).get(key);
223
- if (tokenDetails) {
224
- return tokenDetails;
225
- } else {
226
- const oldTokenDetails = await migrateOldDatabase(firebaseDependencies.appConfig.senderId);
227
- if (oldTokenDetails) {
228
- await dbSet(firebaseDependencies, oldTokenDetails);
229
- return oldTokenDetails;
230
- }
231
- }
232
- }
233
- async function dbSet(firebaseDependencies, tokenDetails) {
234
- const key = getKey(firebaseDependencies);
235
- const db = await getDbPromise();
236
- const tx = db.transaction(OBJECT_STORE_NAME, "readwrite");
237
- await tx.objectStore(OBJECT_STORE_NAME).put(tokenDetails, key);
238
- await tx.done;
239
- return tokenDetails;
240
- }
241
- function getKey({ appConfig }) {
242
- return appConfig.appId;
243
- }
244
- /**
245
- * @license
246
- * Copyright 2017 Google LLC
247
- *
248
- * Licensed under the Apache License, Version 2.0 (the "License");
249
- * you may not use this file except in compliance with the License.
250
- * You may obtain a copy of the License at
251
- *
252
- * http://www.apache.org/licenses/LICENSE-2.0
253
- *
254
- * Unless required by applicable law or agreed to in writing, software
255
- * distributed under the License is distributed on an "AS IS" BASIS,
256
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
257
- * See the License for the specific language governing permissions and
258
- * limitations under the License.
259
- */
260
- const ERROR_MAP = {
261
- [
262
- "missing-app-config-values"
263
- /* ErrorCode.MISSING_APP_CONFIG_VALUES */
264
- ]: 'Missing App configuration value: "{$valueName}"',
265
- [
266
- "only-available-in-window"
267
- /* ErrorCode.AVAILABLE_IN_WINDOW */
268
- ]: "This method is available in a Window context.",
269
- [
270
- "only-available-in-sw"
271
- /* ErrorCode.AVAILABLE_IN_SW */
272
- ]: "This method is available in a service worker context.",
273
- [
274
- "permission-default"
275
- /* ErrorCode.PERMISSION_DEFAULT */
276
- ]: "The notification permission was not granted and dismissed instead.",
277
- [
278
- "permission-blocked"
279
- /* ErrorCode.PERMISSION_BLOCKED */
280
- ]: "The notification permission was not granted and blocked instead.",
281
- [
282
- "unsupported-browser"
283
- /* ErrorCode.UNSUPPORTED_BROWSER */
284
- ]: "This browser doesn't support the API's required to use the Firebase SDK.",
285
- [
286
- "indexed-db-unsupported"
287
- /* ErrorCode.INDEXED_DB_UNSUPPORTED */
288
- ]: "This browser doesn't support indexedDb.open() (ex. Safari iFrame, Firefox Private Browsing, etc)",
289
- [
290
- "failed-service-worker-registration"
291
- /* ErrorCode.FAILED_DEFAULT_REGISTRATION */
292
- ]: "We are unable to register the default service worker. {$browserErrorMessage}",
293
- [
294
- "token-subscribe-failed"
295
- /* ErrorCode.TOKEN_SUBSCRIBE_FAILED */
296
- ]: "A problem occurred while subscribing the user to FCM: {$errorInfo}",
297
- [
298
- "token-subscribe-no-token"
299
- /* ErrorCode.TOKEN_SUBSCRIBE_NO_TOKEN */
300
- ]: "FCM returned no token when subscribing the user to push.",
301
- [
302
- "token-unsubscribe-failed"
303
- /* ErrorCode.TOKEN_UNSUBSCRIBE_FAILED */
304
- ]: "A problem occurred while unsubscribing the user from FCM: {$errorInfo}",
305
- [
306
- "token-update-failed"
307
- /* ErrorCode.TOKEN_UPDATE_FAILED */
308
- ]: "A problem occurred while updating the user from FCM: {$errorInfo}",
309
- [
310
- "token-update-no-token"
311
- /* ErrorCode.TOKEN_UPDATE_NO_TOKEN */
312
- ]: "FCM returned no token when updating the user to push.",
313
- [
314
- "use-sw-after-get-token"
315
- /* ErrorCode.USE_SW_AFTER_GET_TOKEN */
316
- ]: "The useServiceWorker() method may only be called once and must be called before calling getToken() to ensure your service worker is used.",
317
- [
318
- "invalid-sw-registration"
319
- /* ErrorCode.INVALID_SW_REGISTRATION */
320
- ]: "The input to useServiceWorker() must be a ServiceWorkerRegistration.",
321
- [
322
- "invalid-bg-handler"
323
- /* ErrorCode.INVALID_BG_HANDLER */
324
- ]: "The input to setBackgroundMessageHandler() must be a function.",
325
- [
326
- "invalid-vapid-key"
327
- /* ErrorCode.INVALID_VAPID_KEY */
328
- ]: "The public VAPID key must be a string.",
329
- [
330
- "use-vapid-key-after-get-token"
331
- /* ErrorCode.USE_VAPID_KEY_AFTER_GET_TOKEN */
332
- ]: "The usePublicVapidKey() method may only be called once and must be called before calling getToken() to ensure your VAPID key is used."
333
- };
334
- const ERROR_FACTORY = new ErrorFactory("messaging", "Messaging", ERROR_MAP);
335
- /**
336
- * @license
337
- * Copyright 2019 Google LLC
338
- *
339
- * Licensed under the Apache License, Version 2.0 (the "License");
340
- * you may not use this file except in compliance with the License.
341
- * You may obtain a copy of the License at
342
- *
343
- * http://www.apache.org/licenses/LICENSE-2.0
344
- *
345
- * Unless required by applicable law or agreed to in writing, software
346
- * distributed under the License is distributed on an "AS IS" BASIS,
347
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
348
- * See the License for the specific language governing permissions and
349
- * limitations under the License.
350
- */
351
- async function requestGetToken(firebaseDependencies, subscriptionOptions) {
352
- const headers = await getHeaders(firebaseDependencies);
353
- const body = getBody(subscriptionOptions);
354
- const subscribeOptions = {
355
- method: "POST",
356
- headers,
357
- body: JSON.stringify(body)
358
- };
359
- let responseData;
360
- try {
361
- const response = await fetch(getEndpoint(firebaseDependencies.appConfig), subscribeOptions);
362
- responseData = await response.json();
363
- } catch (err) {
364
- throw ERROR_FACTORY.create("token-subscribe-failed", {
365
- errorInfo: err === null || err === void 0 ? void 0 : err.toString()
366
- });
367
- }
368
- if (responseData.error) {
369
- const message = responseData.error.message;
370
- throw ERROR_FACTORY.create("token-subscribe-failed", {
371
- errorInfo: message
372
- });
373
- }
374
- if (!responseData.token) {
375
- throw ERROR_FACTORY.create(
376
- "token-subscribe-no-token"
377
- /* ErrorCode.TOKEN_SUBSCRIBE_NO_TOKEN */
378
- );
379
- }
380
- return responseData.token;
381
- }
382
- async function requestUpdateToken(firebaseDependencies, tokenDetails) {
383
- const headers = await getHeaders(firebaseDependencies);
384
- const body = getBody(tokenDetails.subscriptionOptions);
385
- const updateOptions = {
386
- method: "PATCH",
387
- headers,
388
- body: JSON.stringify(body)
389
- };
390
- let responseData;
391
- try {
392
- const response = await fetch(`${getEndpoint(firebaseDependencies.appConfig)}/${tokenDetails.token}`, updateOptions);
393
- responseData = await response.json();
394
- } catch (err) {
395
- throw ERROR_FACTORY.create("token-update-failed", {
396
- errorInfo: err === null || err === void 0 ? void 0 : err.toString()
397
- });
398
- }
399
- if (responseData.error) {
400
- const message = responseData.error.message;
401
- throw ERROR_FACTORY.create("token-update-failed", {
402
- errorInfo: message
403
- });
404
- }
405
- if (!responseData.token) {
406
- throw ERROR_FACTORY.create(
407
- "token-update-no-token"
408
- /* ErrorCode.TOKEN_UPDATE_NO_TOKEN */
409
- );
410
- }
411
- return responseData.token;
412
- }
413
- async function requestDeleteToken(firebaseDependencies, token) {
414
- const headers = await getHeaders(firebaseDependencies);
415
- const unsubscribeOptions = {
416
- method: "DELETE",
417
- headers
418
- };
419
- try {
420
- const response = await fetch(`${getEndpoint(firebaseDependencies.appConfig)}/${token}`, unsubscribeOptions);
421
- const responseData = await response.json();
422
- if (responseData.error) {
423
- const message = responseData.error.message;
424
- throw ERROR_FACTORY.create("token-unsubscribe-failed", {
425
- errorInfo: message
426
- });
427
- }
428
- } catch (err) {
429
- throw ERROR_FACTORY.create("token-unsubscribe-failed", {
430
- errorInfo: err === null || err === void 0 ? void 0 : err.toString()
431
- });
432
- }
433
- }
434
- function getEndpoint({ projectId }) {
435
- return `${ENDPOINT}/projects/${projectId}/registrations`;
436
- }
437
- async function getHeaders({ appConfig, installations }) {
438
- const authToken = await installations.getToken();
439
- return new Headers({
440
- "Content-Type": "application/json",
441
- Accept: "application/json",
442
- "x-goog-api-key": appConfig.apiKey,
443
- "x-goog-firebase-installations-auth": `FIS ${authToken}`
444
- });
445
- }
446
- function getBody({ p256dh, auth, endpoint, vapidKey }) {
447
- const body = {
448
- web: {
449
- endpoint,
450
- auth,
451
- p256dh
452
- }
453
- };
454
- if (vapidKey !== DEFAULT_VAPID_KEY) {
455
- body.web.applicationPubKey = vapidKey;
456
- }
457
- return body;
458
- }
459
- /**
460
- * @license
461
- * Copyright 2019 Google LLC
462
- *
463
- * Licensed under the Apache License, Version 2.0 (the "License");
464
- * you may not use this file except in compliance with the License.
465
- * You may obtain a copy of the License at
466
- *
467
- * http://www.apache.org/licenses/LICENSE-2.0
468
- *
469
- * Unless required by applicable law or agreed to in writing, software
470
- * distributed under the License is distributed on an "AS IS" BASIS,
471
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
472
- * See the License for the specific language governing permissions and
473
- * limitations under the License.
474
- */
475
- const TOKEN_EXPIRATION_MS = 7 * 24 * 60 * 60 * 1e3;
476
- async function getTokenInternal(messaging) {
477
- const pushSubscription = await getPushSubscription(messaging.swRegistration, messaging.vapidKey);
478
- const subscriptionOptions = {
479
- vapidKey: messaging.vapidKey,
480
- swScope: messaging.swRegistration.scope,
481
- endpoint: pushSubscription.endpoint,
482
- auth: arrayToBase64(pushSubscription.getKey("auth")),
483
- p256dh: arrayToBase64(pushSubscription.getKey("p256dh"))
484
- };
485
- const tokenDetails = await dbGet(messaging.firebaseDependencies);
486
- if (!tokenDetails) {
487
- return getNewToken(messaging.firebaseDependencies, subscriptionOptions);
488
- } else if (!isTokenValid(tokenDetails.subscriptionOptions, subscriptionOptions)) {
489
- try {
490
- await requestDeleteToken(messaging.firebaseDependencies, tokenDetails.token);
491
- } catch (e) {
492
- console.warn(e);
493
- }
494
- return getNewToken(messaging.firebaseDependencies, subscriptionOptions);
495
- } else if (Date.now() >= tokenDetails.createTime + TOKEN_EXPIRATION_MS) {
496
- return updateToken(messaging, {
497
- token: tokenDetails.token,
498
- createTime: Date.now(),
499
- subscriptionOptions
500
- });
501
- } else {
502
- return tokenDetails.token;
503
- }
504
- }
505
- async function updateToken(messaging, tokenDetails) {
506
- try {
507
- const updatedToken = await requestUpdateToken(messaging.firebaseDependencies, tokenDetails);
508
- const updatedTokenDetails = Object.assign(Object.assign({}, tokenDetails), { token: updatedToken, createTime: Date.now() });
509
- await dbSet(messaging.firebaseDependencies, updatedTokenDetails);
510
- return updatedToken;
511
- } catch (e) {
512
- throw e;
513
- }
514
- }
515
- async function getNewToken(firebaseDependencies, subscriptionOptions) {
516
- const token = await requestGetToken(firebaseDependencies, subscriptionOptions);
517
- const tokenDetails = {
518
- token,
519
- createTime: Date.now(),
520
- subscriptionOptions
521
- };
522
- await dbSet(firebaseDependencies, tokenDetails);
523
- return tokenDetails.token;
524
- }
525
- async function getPushSubscription(swRegistration, vapidKey) {
526
- const subscription = await swRegistration.pushManager.getSubscription();
527
- if (subscription) {
528
- return subscription;
529
- }
530
- return swRegistration.pushManager.subscribe({
531
- userVisibleOnly: true,
532
- // Chrome <= 75 doesn't support base64-encoded VAPID key. For backward compatibility, VAPID key
533
- // submitted to pushManager#subscribe must be of type Uint8Array.
534
- applicationServerKey: base64ToArray(vapidKey)
535
- });
536
- }
537
- function isTokenValid(dbOptions, currentOptions) {
538
- const isVapidKeyEqual = currentOptions.vapidKey === dbOptions.vapidKey;
539
- const isEndpointEqual = currentOptions.endpoint === dbOptions.endpoint;
540
- const isAuthEqual = currentOptions.auth === dbOptions.auth;
541
- const isP256dhEqual = currentOptions.p256dh === dbOptions.p256dh;
542
- return isVapidKeyEqual && isEndpointEqual && isAuthEqual && isP256dhEqual;
543
- }
544
- /**
545
- * @license
546
- * Copyright 2020 Google LLC
547
- *
548
- * Licensed under the Apache License, Version 2.0 (the "License");
549
- * you may not use this file except in compliance with the License.
550
- * You may obtain a copy of the License at
551
- *
552
- * http://www.apache.org/licenses/LICENSE-2.0
553
- *
554
- * Unless required by applicable law or agreed to in writing, software
555
- * distributed under the License is distributed on an "AS IS" BASIS,
556
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
557
- * See the License for the specific language governing permissions and
558
- * limitations under the License.
559
- */
560
- function externalizePayload(internalPayload) {
561
- const payload = {
562
- from: internalPayload.from,
563
- // eslint-disable-next-line camelcase
564
- collapseKey: internalPayload.collapse_key,
565
- // eslint-disable-next-line camelcase
566
- messageId: internalPayload.fcmMessageId
567
- };
568
- propagateNotificationPayload(payload, internalPayload);
569
- propagateDataPayload(payload, internalPayload);
570
- propagateFcmOptions(payload, internalPayload);
571
- return payload;
572
- }
573
- function propagateNotificationPayload(payload, messagePayloadInternal) {
574
- if (!messagePayloadInternal.notification) {
575
- return;
576
- }
577
- payload.notification = {};
578
- const title = messagePayloadInternal.notification.title;
579
- if (!!title) {
580
- payload.notification.title = title;
581
- }
582
- const body = messagePayloadInternal.notification.body;
583
- if (!!body) {
584
- payload.notification.body = body;
585
- }
586
- const image = messagePayloadInternal.notification.image;
587
- if (!!image) {
588
- payload.notification.image = image;
589
- }
590
- const icon = messagePayloadInternal.notification.icon;
591
- if (!!icon) {
592
- payload.notification.icon = icon;
593
- }
594
- }
595
- function propagateDataPayload(payload, messagePayloadInternal) {
596
- if (!messagePayloadInternal.data) {
597
- return;
598
- }
599
- payload.data = messagePayloadInternal.data;
600
- }
601
- function propagateFcmOptions(payload, messagePayloadInternal) {
602
- var _a, _b, _c, _d, _e;
603
- if (!messagePayloadInternal.fcmOptions && !((_a = messagePayloadInternal.notification) === null || _a === void 0 ? void 0 : _a.click_action)) {
604
- return;
605
- }
606
- payload.fcmOptions = {};
607
- const link = (_c = (_b = messagePayloadInternal.fcmOptions) === null || _b === void 0 ? void 0 : _b.link) !== null && _c !== void 0 ? _c : (_d = messagePayloadInternal.notification) === null || _d === void 0 ? void 0 : _d.click_action;
608
- if (!!link) {
609
- payload.fcmOptions.link = link;
610
- }
611
- const analyticsLabel = (_e = messagePayloadInternal.fcmOptions) === null || _e === void 0 ? void 0 : _e.analytics_label;
612
- if (!!analyticsLabel) {
613
- payload.fcmOptions.analyticsLabel = analyticsLabel;
614
- }
615
- }
616
- /**
617
- * @license
618
- * Copyright 2019 Google LLC
619
- *
620
- * Licensed under the Apache License, Version 2.0 (the "License");
621
- * you may not use this file except in compliance with the License.
622
- * You may obtain a copy of the License at
623
- *
624
- * http://www.apache.org/licenses/LICENSE-2.0
625
- *
626
- * Unless required by applicable law or agreed to in writing, software
627
- * distributed under the License is distributed on an "AS IS" BASIS,
628
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
629
- * See the License for the specific language governing permissions and
630
- * limitations under the License.
631
- */
632
- function isConsoleMessage(data) {
633
- return typeof data === "object" && !!data && CONSOLE_CAMPAIGN_ID in data;
634
- }
635
- /**
636
- * @license
637
- * Copyright 2019 Google LLC
638
- *
639
- * Licensed under the Apache License, Version 2.0 (the "License");
640
- * you may not use this file except in compliance with the License.
641
- * You may obtain a copy of the License at
642
- *
643
- * http://www.apache.org/licenses/LICENSE-2.0
644
- *
645
- * Unless required by applicable law or agreed to in writing, software
646
- * distributed under the License is distributed on an "AS IS" BASIS,
647
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
648
- * See the License for the specific language governing permissions and
649
- * limitations under the License.
650
- */
651
- function extractAppConfig(app) {
652
- if (!app || !app.options) {
653
- throw getMissingValueError("App Configuration Object");
654
- }
655
- if (!app.name) {
656
- throw getMissingValueError("App Name");
657
- }
658
- const configKeys = [
659
- "projectId",
660
- "apiKey",
661
- "appId",
662
- "messagingSenderId"
663
- ];
664
- const { options } = app;
665
- for (const keyName of configKeys) {
666
- if (!options[keyName]) {
667
- throw getMissingValueError(keyName);
668
- }
669
- }
670
- return {
671
- appName: app.name,
672
- projectId: options.projectId,
673
- apiKey: options.apiKey,
674
- appId: options.appId,
675
- senderId: options.messagingSenderId
676
- };
677
- }
678
- function getMissingValueError(valueName) {
679
- return ERROR_FACTORY.create("missing-app-config-values", {
680
- valueName
681
- });
682
- }
683
- /**
684
- * @license
685
- * Copyright 2020 Google LLC
686
- *
687
- * Licensed under the Apache License, Version 2.0 (the "License");
688
- * you may not use this file except in compliance with the License.
689
- * You may obtain a copy of the License at
690
- *
691
- * http://www.apache.org/licenses/LICENSE-2.0
692
- *
693
- * Unless required by applicable law or agreed to in writing, software
694
- * distributed under the License is distributed on an "AS IS" BASIS,
695
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
696
- * See the License for the specific language governing permissions and
697
- * limitations under the License.
698
- */
699
- class MessagingService {
700
- constructor(app, installations, analyticsProvider) {
701
- this.deliveryMetricsExportedToBigQueryEnabled = false;
702
- this.onBackgroundMessageHandler = null;
703
- this.onMessageHandler = null;
704
- this.logEvents = [];
705
- this.isLogServiceStarted = false;
706
- const appConfig = extractAppConfig(app);
707
- this.firebaseDependencies = {
708
- app,
709
- appConfig,
710
- installations,
711
- analyticsProvider
712
- };
713
- }
714
- _delete() {
715
- return Promise.resolve();
716
- }
717
- }
718
- /**
719
- * @license
720
- * Copyright 2020 Google LLC
721
- *
722
- * Licensed under the Apache License, Version 2.0 (the "License");
723
- * you may not use this file except in compliance with the License.
724
- * You may obtain a copy of the License at
725
- *
726
- * http://www.apache.org/licenses/LICENSE-2.0
727
- *
728
- * Unless required by applicable law or agreed to in writing, software
729
- * distributed under the License is distributed on an "AS IS" BASIS,
730
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
731
- * See the License for the specific language governing permissions and
732
- * limitations under the License.
733
- */
734
- async function registerDefaultSw(messaging) {
735
- try {
736
- messaging.swRegistration = await navigator.serviceWorker.register(DEFAULT_SW_PATH, {
737
- scope: DEFAULT_SW_SCOPE
738
- });
739
- messaging.swRegistration.update().catch(() => {
740
- });
741
- } catch (e) {
742
- throw ERROR_FACTORY.create("failed-service-worker-registration", {
743
- browserErrorMessage: e === null || e === void 0 ? void 0 : e.message
744
- });
745
- }
746
- }
747
- /**
748
- * @license
749
- * Copyright 2020 Google LLC
750
- *
751
- * Licensed under the Apache License, Version 2.0 (the "License");
752
- * you may not use this file except in compliance with the License.
753
- * You may obtain a copy of the License at
754
- *
755
- * http://www.apache.org/licenses/LICENSE-2.0
756
- *
757
- * Unless required by applicable law or agreed to in writing, software
758
- * distributed under the License is distributed on an "AS IS" BASIS,
759
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
760
- * See the License for the specific language governing permissions and
761
- * limitations under the License.
762
- */
763
- async function updateSwReg(messaging, swRegistration) {
764
- if (!swRegistration && !messaging.swRegistration) {
765
- await registerDefaultSw(messaging);
766
- }
767
- if (!swRegistration && !!messaging.swRegistration) {
768
- return;
769
- }
770
- if (!(swRegistration instanceof ServiceWorkerRegistration)) {
771
- throw ERROR_FACTORY.create(
772
- "invalid-sw-registration"
773
- /* ErrorCode.INVALID_SW_REGISTRATION */
774
- );
775
- }
776
- messaging.swRegistration = swRegistration;
777
- }
778
- /**
779
- * @license
780
- * Copyright 2020 Google LLC
781
- *
782
- * Licensed under the Apache License, Version 2.0 (the "License");
783
- * you may not use this file except in compliance with the License.
784
- * You may obtain a copy of the License at
785
- *
786
- * http://www.apache.org/licenses/LICENSE-2.0
787
- *
788
- * Unless required by applicable law or agreed to in writing, software
789
- * distributed under the License is distributed on an "AS IS" BASIS,
790
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
791
- * See the License for the specific language governing permissions and
792
- * limitations under the License.
793
- */
794
- async function updateVapidKey(messaging, vapidKey) {
795
- if (!!vapidKey) {
796
- messaging.vapidKey = vapidKey;
797
- } else if (!messaging.vapidKey) {
798
- messaging.vapidKey = DEFAULT_VAPID_KEY;
799
- }
800
- }
801
- /**
802
- * @license
803
- * Copyright 2020 Google LLC
804
- *
805
- * Licensed under the Apache License, Version 2.0 (the "License");
806
- * you may not use this file except in compliance with the License.
807
- * You may obtain a copy of the License at
808
- *
809
- * http://www.apache.org/licenses/LICENSE-2.0
810
- *
811
- * Unless required by applicable law or agreed to in writing, software
812
- * distributed under the License is distributed on an "AS IS" BASIS,
813
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
814
- * See the License for the specific language governing permissions and
815
- * limitations under the License.
816
- */
817
- async function getToken$1(messaging, options) {
818
- if (!navigator) {
819
- throw ERROR_FACTORY.create(
820
- "only-available-in-window"
821
- /* ErrorCode.AVAILABLE_IN_WINDOW */
822
- );
823
- }
824
- if (Notification.permission === "default") {
825
- await Notification.requestPermission();
826
- }
827
- if (Notification.permission !== "granted") {
828
- throw ERROR_FACTORY.create(
829
- "permission-blocked"
830
- /* ErrorCode.PERMISSION_BLOCKED */
831
- );
832
- }
833
- await updateVapidKey(messaging, options === null || options === void 0 ? void 0 : options.vapidKey);
834
- await updateSwReg(messaging, options === null || options === void 0 ? void 0 : options.serviceWorkerRegistration);
835
- return getTokenInternal(messaging);
836
- }
837
- /**
838
- * @license
839
- * Copyright 2019 Google LLC
840
- *
841
- * Licensed under the Apache License, Version 2.0 (the "License");
842
- * you may not use this file except in compliance with the License.
843
- * You may obtain a copy of the License at
844
- *
845
- * http://www.apache.org/licenses/LICENSE-2.0
846
- *
847
- * Unless required by applicable law or agreed to in writing, software
848
- * distributed under the License is distributed on an "AS IS" BASIS,
849
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
850
- * See the License for the specific language governing permissions and
851
- * limitations under the License.
852
- */
853
- async function logToScion(messaging, messageType, data) {
854
- const eventType = getEventType(messageType);
855
- const analytics = await messaging.firebaseDependencies.analyticsProvider.get();
856
- analytics.logEvent(eventType, {
857
- /* eslint-disable camelcase */
858
- message_id: data[CONSOLE_CAMPAIGN_ID],
859
- message_name: data[CONSOLE_CAMPAIGN_NAME],
860
- message_time: data[CONSOLE_CAMPAIGN_TIME],
861
- message_device_time: Math.floor(Date.now() / 1e3)
862
- /* eslint-enable camelcase */
863
- });
864
- }
865
- function getEventType(messageType) {
866
- switch (messageType) {
867
- case MessageType.NOTIFICATION_CLICKED:
868
- return "notification_open";
869
- case MessageType.PUSH_RECEIVED:
870
- return "notification_foreground";
871
- default:
872
- throw new Error();
873
- }
874
- }
875
- /**
876
- * @license
877
- * Copyright 2017 Google LLC
878
- *
879
- * Licensed under the Apache License, Version 2.0 (the "License");
880
- * you may not use this file except in compliance with the License.
881
- * You may obtain a copy of the License at
882
- *
883
- * http://www.apache.org/licenses/LICENSE-2.0
884
- *
885
- * Unless required by applicable law or agreed to in writing, software
886
- * distributed under the License is distributed on an "AS IS" BASIS,
887
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
888
- * See the License for the specific language governing permissions and
889
- * limitations under the License.
890
- */
891
- async function messageEventListener(messaging, event) {
892
- const internalPayload = event.data;
893
- if (!internalPayload.isFirebaseMessaging) {
894
- return;
895
- }
896
- if (messaging.onMessageHandler && internalPayload.messageType === MessageType.PUSH_RECEIVED) {
897
- if (typeof messaging.onMessageHandler === "function") {
898
- messaging.onMessageHandler(externalizePayload(internalPayload));
899
- } else {
900
- messaging.onMessageHandler.next(externalizePayload(internalPayload));
901
- }
902
- }
903
- const dataPayload = internalPayload.data;
904
- if (isConsoleMessage(dataPayload) && dataPayload[CONSOLE_CAMPAIGN_ANALYTICS_ENABLED] === "1") {
905
- await logToScion(messaging, internalPayload.messageType, dataPayload);
906
- }
907
- }
908
- const name = "@firebase/messaging";
909
- const version = "0.12.12";
910
- /**
911
- * @license
912
- * Copyright 2020 Google LLC
913
- *
914
- * Licensed under the Apache License, Version 2.0 (the "License");
915
- * you may not use this file except in compliance with the License.
916
- * You may obtain a copy of the License at
917
- *
918
- * http://www.apache.org/licenses/LICENSE-2.0
919
- *
920
- * Unless required by applicable law or agreed to in writing, software
921
- * distributed under the License is distributed on an "AS IS" BASIS,
922
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
923
- * See the License for the specific language governing permissions and
924
- * limitations under the License.
925
- */
926
- const WindowMessagingFactory = (container) => {
927
- const messaging = new MessagingService(container.getProvider("app").getImmediate(), container.getProvider("installations-internal").getImmediate(), container.getProvider("analytics-internal"));
928
- navigator.serviceWorker.addEventListener("message", (e) => messageEventListener(messaging, e));
929
- return messaging;
930
- };
931
- const WindowMessagingInternalFactory = (container) => {
932
- const messaging = container.getProvider("messaging").getImmediate();
933
- const messagingInternal = {
934
- getToken: (options) => getToken$1(messaging, options)
935
- };
936
- return messagingInternal;
937
- };
938
- function registerMessagingInWindow() {
939
- _registerComponent(new Component(
940
- "messaging",
941
- WindowMessagingFactory,
942
- "PUBLIC"
943
- /* ComponentType.PUBLIC */
944
- ));
945
- _registerComponent(new Component(
946
- "messaging-internal",
947
- WindowMessagingInternalFactory,
948
- "PRIVATE"
949
- /* ComponentType.PRIVATE */
950
- ));
951
- registerVersion(name, version);
952
- registerVersion(name, version, "esm2017");
953
- }
954
- /**
955
- * @license
956
- * Copyright 2020 Google LLC
957
- *
958
- * Licensed under the Apache License, Version 2.0 (the "License");
959
- * you may not use this file except in compliance with the License.
960
- * You may obtain a copy of the License at
961
- *
962
- * http://www.apache.org/licenses/LICENSE-2.0
963
- *
964
- * Unless required by applicable law or agreed to in writing, software
965
- * distributed under the License is distributed on an "AS IS" BASIS,
966
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
967
- * See the License for the specific language governing permissions and
968
- * limitations under the License.
969
- */
970
- async function isWindowSupported() {
971
- try {
972
- await validateIndexedDBOpenable();
973
- } catch (e) {
974
- return false;
975
- }
976
- return typeof window !== "undefined" && isIndexedDBAvailable() && areCookiesEnabled() && "serviceWorker" in navigator && "PushManager" in window && "Notification" in window && "fetch" in window && ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification") && PushSubscription.prototype.hasOwnProperty("getKey");
977
- }
978
- /**
979
- * @license
980
- * Copyright 2017 Google LLC
981
- *
982
- * Licensed under the Apache License, Version 2.0 (the "License");
983
- * you may not use this file except in compliance with the License.
984
- * You may obtain a copy of the License at
985
- *
986
- * http://www.apache.org/licenses/LICENSE-2.0
987
- *
988
- * Unless required by applicable law or agreed to in writing, software
989
- * distributed under the License is distributed on an "AS IS" BASIS,
990
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
991
- * See the License for the specific language governing permissions and
992
- * limitations under the License.
993
- */
994
- function getMessagingInWindow(app = getApp()) {
995
- isWindowSupported().then((isSupported) => {
996
- if (!isSupported) {
997
- throw ERROR_FACTORY.create(
998
- "unsupported-browser"
999
- /* ErrorCode.UNSUPPORTED_BROWSER */
1000
- );
1001
- }
1002
- }, (_) => {
1003
- throw ERROR_FACTORY.create(
1004
- "indexed-db-unsupported"
1005
- /* ErrorCode.INDEXED_DB_UNSUPPORTED */
1006
- );
1007
- });
1008
- return _getProvider(getModularInstance(app), "messaging").getImmediate();
1009
- }
1010
- async function getToken(messaging, options) {
1011
- messaging = getModularInstance(messaging);
1012
- return getToken$1(messaging, options);
1013
- }
1014
- registerMessagingInWindow();
1015
- export {
1016
- getMessagingInWindow as getMessaging,
1017
- getToken,
1018
- isWindowSupported as isSupported
1019
- };