summaryrefslogtreecommitdiff
path: root/frontend-old/node_modules/@firebase/messaging/dist/esm
diff options
context:
space:
mode:
authoraltaf-creator <dev@altafcreator.com>2025-11-09 11:15:19 +0800
committeraltaf-creator <dev@altafcreator.com>2025-11-09 11:15:19 +0800
commit8eff962cab608341a6f2fedc640a0e32d96f26e2 (patch)
tree05534d1a720ddc3691d346c69b4972555820a061 /frontend-old/node_modules/@firebase/messaging/dist/esm
pain
Diffstat (limited to 'frontend-old/node_modules/@firebase/messaging/dist/esm')
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/index.esm.js1270
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/index.esm.js.map1
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/index.sw.esm.js1278
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/index.sw.esm.js.map1
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/package.json1
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/api.d.ts101
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/deleteToken.d.ts18
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/getToken.d.ts19
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/isSupported.d.ts30
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/onBackgroundMessage.d.ts19
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/onMessage.d.ts19
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/setDeliveryMetricsExportedToBigQueryEnabled.d.ts18
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/array-base64-translator.d.ts18
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/externalizePayload.d.ts19
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/extract-app-config.d.ts19
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/is-console-message.d.ts18
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/logToFirelog.d.ts30
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/logToScion.d.ts19
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/migrate-old-database.d.ts51
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/register.d.ts23
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/registerDefaultSw.d.ts18
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/sleep.d.ts18
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/updateSwReg.d.ts18
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/updateVapidKey.d.ts18
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/index.d.ts32
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/index.sw.d.ts26
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/app-config.d.ts24
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/internal-dependencies.d.ts27
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/internal-message-payload.d.ts65
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/logging-types.d.ts60
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/public-types.d.ts144
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/token-details.d.ts32
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/internals/idb-manager.d.ts27
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/internals/requests.d.ts35
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/internals/token-manager.d.ts23
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/listeners/sw-listeners.d.ts21
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/listeners/window-listener.d.ts18
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/messaging-service.d.ts36
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/compare-headers.d.ts22
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/fakes/firebase-dependencies.d.ts25
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/fakes/logging-object.d.ts18
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/fakes/messaging-service.d.ts18
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/fakes/service-worker.d.ts83
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/fakes/token-details.d.ts18
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/setup.d.ts17
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/sinon-types.d.ts19
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/util/constants.d.ts40
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/util/errors.d.ts57
-rw-r--r--frontend-old/node_modules/@firebase/messaging/dist/esm/src/util/sw-types.d.ts90
49 files changed, 4021 insertions, 0 deletions
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/index.esm.js b/frontend-old/node_modules/@firebase/messaging/dist/esm/index.esm.js
new file mode 100644
index 0000000..b75f494
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/index.esm.js
@@ -0,0 +1,1270 @@
+import '@firebase/installations';
+import { Component } from '@firebase/component';
+import { openDB, deleteDB } from 'idb';
+import { ErrorFactory, validateIndexedDBOpenable, isIndexedDBAvailable, areCookiesEnabled, getModularInstance } from '@firebase/util';
+import { _registerComponent, registerVersion, _getProvider, getApp } from '@firebase/app';
+
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+const DEFAULT_SW_PATH = '/firebase-messaging-sw.js';
+const DEFAULT_SW_SCOPE = '/firebase-cloud-messaging-push-scope';
+const DEFAULT_VAPID_KEY = 'BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4';
+const ENDPOINT = 'https://fcmregistrations.googleapis.com/v1';
+const CONSOLE_CAMPAIGN_ID = 'google.c.a.c_id';
+const CONSOLE_CAMPAIGN_NAME = 'google.c.a.c_l';
+const CONSOLE_CAMPAIGN_TIME = 'google.c.a.ts';
+/** Set to '1' if Analytics is enabled for the campaign */
+const CONSOLE_CAMPAIGN_ANALYTICS_ENABLED = 'google.c.a.e';
+const DEFAULT_REGISTRATION_TIMEOUT = 10000;
+var MessageType$1;
+(function (MessageType) {
+ MessageType[MessageType["DATA_MESSAGE"] = 1] = "DATA_MESSAGE";
+ MessageType[MessageType["DISPLAY_NOTIFICATION"] = 3] = "DISPLAY_NOTIFICATION";
+})(MessageType$1 || (MessageType$1 = {}));
+
+/**
+ * @license
+ * Copyright 2018 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+var MessageType;
+(function (MessageType) {
+ MessageType["PUSH_RECEIVED"] = "push-received";
+ MessageType["NOTIFICATION_CLICKED"] = "notification-clicked";
+})(MessageType || (MessageType = {}));
+
+/**
+ * @license
+ * Copyright 2017 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+function arrayToBase64(array) {
+ const uint8Array = new Uint8Array(array);
+ const base64String = btoa(String.fromCharCode(...uint8Array));
+ return base64String.replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
+}
+function base64ToArray(base64String) {
+ const padding = '='.repeat((4 - (base64String.length % 4)) % 4);
+ const base64 = (base64String + padding)
+ .replace(/\-/g, '+')
+ .replace(/_/g, '/');
+ const rawData = atob(base64);
+ const outputArray = new Uint8Array(rawData.length);
+ for (let i = 0; i < rawData.length; ++i) {
+ outputArray[i] = rawData.charCodeAt(i);
+ }
+ return outputArray;
+}
+
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+const OLD_DB_NAME = 'fcm_token_details_db';
+/**
+ * The last DB version of 'fcm_token_details_db' was 4. This is one higher, so that the upgrade
+ * callback is called for all versions of the old DB.
+ */
+const OLD_DB_VERSION = 5;
+const OLD_OBJECT_STORE_NAME = 'fcm_token_object_Store';
+async function migrateOldDatabase(senderId) {
+ if ('databases' in indexedDB) {
+ // indexedDb.databases() is an IndexedDB v3 API and does not exist in all browsers. TODO: Remove
+ // typecast when it lands in TS types.
+ const databases = await indexedDB.databases();
+ const dbNames = databases.map(db => db.name);
+ if (!dbNames.includes(OLD_DB_NAME)) {
+ // old DB didn't exist, no need to open.
+ return null;
+ }
+ }
+ let tokenDetails = null;
+ const db = await openDB(OLD_DB_NAME, OLD_DB_VERSION, {
+ upgrade: async (db, oldVersion, newVersion, upgradeTransaction) => {
+ if (oldVersion < 2) {
+ // Database too old, skip migration.
+ return;
+ }
+ if (!db.objectStoreNames.contains(OLD_OBJECT_STORE_NAME)) {
+ // Database did not exist. Nothing to do.
+ return;
+ }
+ const objectStore = upgradeTransaction.objectStore(OLD_OBJECT_STORE_NAME);
+ const value = await objectStore.index('fcmSenderId').get(senderId);
+ await objectStore.clear();
+ if (!value) {
+ // No entry in the database, nothing to migrate.
+ return;
+ }
+ if (oldVersion === 2) {
+ const oldDetails = value;
+ if (!oldDetails.auth || !oldDetails.p256dh || !oldDetails.endpoint) {
+ return;
+ }
+ tokenDetails = {
+ token: oldDetails.fcmToken,
+ createTime: oldDetails.createTime ?? Date.now(),
+ subscriptionOptions: {
+ auth: oldDetails.auth,
+ p256dh: oldDetails.p256dh,
+ endpoint: oldDetails.endpoint,
+ swScope: oldDetails.swScope,
+ vapidKey: typeof oldDetails.vapidKey === 'string'
+ ? oldDetails.vapidKey
+ : arrayToBase64(oldDetails.vapidKey)
+ }
+ };
+ }
+ else if (oldVersion === 3) {
+ const oldDetails = value;
+ tokenDetails = {
+ token: oldDetails.fcmToken,
+ createTime: oldDetails.createTime,
+ subscriptionOptions: {
+ auth: arrayToBase64(oldDetails.auth),
+ p256dh: arrayToBase64(oldDetails.p256dh),
+ endpoint: oldDetails.endpoint,
+ swScope: oldDetails.swScope,
+ vapidKey: arrayToBase64(oldDetails.vapidKey)
+ }
+ };
+ }
+ else if (oldVersion === 4) {
+ const oldDetails = value;
+ tokenDetails = {
+ token: oldDetails.fcmToken,
+ createTime: oldDetails.createTime,
+ subscriptionOptions: {
+ auth: arrayToBase64(oldDetails.auth),
+ p256dh: arrayToBase64(oldDetails.p256dh),
+ endpoint: oldDetails.endpoint,
+ swScope: oldDetails.swScope,
+ vapidKey: arrayToBase64(oldDetails.vapidKey)
+ }
+ };
+ }
+ }
+ });
+ db.close();
+ // Delete all old databases.
+ await deleteDB(OLD_DB_NAME);
+ await deleteDB('fcm_vapid_details_db');
+ await deleteDB('undefined');
+ return checkTokenDetails(tokenDetails) ? tokenDetails : null;
+}
+function checkTokenDetails(tokenDetails) {
+ if (!tokenDetails || !tokenDetails.subscriptionOptions) {
+ return false;
+ }
+ const { subscriptionOptions } = tokenDetails;
+ 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);
+}
+
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// Exported for tests.
+const DATABASE_NAME = 'firebase-messaging-database';
+const DATABASE_VERSION = 1;
+const OBJECT_STORE_NAME = 'firebase-messaging-store';
+let dbPromise = null;
+function getDbPromise() {
+ if (!dbPromise) {
+ dbPromise = openDB(DATABASE_NAME, DATABASE_VERSION, {
+ upgrade: (upgradeDb, oldVersion) => {
+ // We don't use 'break' in this switch statement, the fall-through behavior is what we want,
+ // because if there are multiple versions between the old version and the current version, we
+ // want ALL the migrations that correspond to those versions to run, not only the last one.
+ // eslint-disable-next-line default-case
+ switch (oldVersion) {
+ case 0:
+ upgradeDb.createObjectStore(OBJECT_STORE_NAME);
+ }
+ }
+ });
+ }
+ return dbPromise;
+}
+/** Gets record(s) from the objectStore that match the given key. */
+async function dbGet(firebaseDependencies) {
+ const key = getKey(firebaseDependencies);
+ const db = await getDbPromise();
+ const tokenDetails = (await db
+ .transaction(OBJECT_STORE_NAME)
+ .objectStore(OBJECT_STORE_NAME)
+ .get(key));
+ if (tokenDetails) {
+ return tokenDetails;
+ }
+ else {
+ // Check if there is a tokenDetails object in the old DB.
+ const oldTokenDetails = await migrateOldDatabase(firebaseDependencies.appConfig.senderId);
+ if (oldTokenDetails) {
+ await dbSet(firebaseDependencies, oldTokenDetails);
+ return oldTokenDetails;
+ }
+ }
+}
+/** Assigns or overwrites the record for the given key with the given value. */
+async function dbSet(firebaseDependencies, tokenDetails) {
+ const key = getKey(firebaseDependencies);
+ const db = await getDbPromise();
+ const tx = db.transaction(OBJECT_STORE_NAME, 'readwrite');
+ await tx.objectStore(OBJECT_STORE_NAME).put(tokenDetails, key);
+ await tx.done;
+ return tokenDetails;
+}
+/** Removes record(s) from the objectStore that match the given key. */
+async function dbRemove(firebaseDependencies) {
+ const key = getKey(firebaseDependencies);
+ const db = await getDbPromise();
+ const tx = db.transaction(OBJECT_STORE_NAME, 'readwrite');
+ await tx.objectStore(OBJECT_STORE_NAME).delete(key);
+ await tx.done;
+}
+function getKey({ appConfig }) {
+ return appConfig.appId;
+}
+
+/**
+ * @license
+ * Copyright 2017 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+const ERROR_MAP = {
+ ["missing-app-config-values" /* ErrorCode.MISSING_APP_CONFIG_VALUES */]: 'Missing App configuration value: "{$valueName}"',
+ ["only-available-in-window" /* ErrorCode.AVAILABLE_IN_WINDOW */]: 'This method is available in a Window context.',
+ ["only-available-in-sw" /* ErrorCode.AVAILABLE_IN_SW */]: 'This method is available in a service worker context.',
+ ["permission-default" /* ErrorCode.PERMISSION_DEFAULT */]: 'The notification permission was not granted and dismissed instead.',
+ ["permission-blocked" /* ErrorCode.PERMISSION_BLOCKED */]: 'The notification permission was not granted and blocked instead.',
+ ["unsupported-browser" /* ErrorCode.UNSUPPORTED_BROWSER */]: "This browser doesn't support the API's required to use the Firebase SDK.",
+ ["indexed-db-unsupported" /* ErrorCode.INDEXED_DB_UNSUPPORTED */]: "This browser doesn't support indexedDb.open() (ex. Safari iFrame, Firefox Private Browsing, etc)",
+ ["failed-service-worker-registration" /* ErrorCode.FAILED_DEFAULT_REGISTRATION */]: 'We are unable to register the default service worker. {$browserErrorMessage}',
+ ["token-subscribe-failed" /* ErrorCode.TOKEN_SUBSCRIBE_FAILED */]: 'A problem occurred while subscribing the user to FCM: {$errorInfo}',
+ ["token-subscribe-no-token" /* ErrorCode.TOKEN_SUBSCRIBE_NO_TOKEN */]: 'FCM returned no token when subscribing the user to push.',
+ ["token-unsubscribe-failed" /* ErrorCode.TOKEN_UNSUBSCRIBE_FAILED */]: 'A problem occurred while unsubscribing the ' +
+ 'user from FCM: {$errorInfo}',
+ ["token-update-failed" /* ErrorCode.TOKEN_UPDATE_FAILED */]: 'A problem occurred while updating the user from FCM: {$errorInfo}',
+ ["token-update-no-token" /* ErrorCode.TOKEN_UPDATE_NO_TOKEN */]: 'FCM returned no token when updating the user to push.',
+ ["use-sw-after-get-token" /* ErrorCode.USE_SW_AFTER_GET_TOKEN */]: 'The useServiceWorker() method may only be called once and must be ' +
+ 'called before calling getToken() to ensure your service worker is used.',
+ ["invalid-sw-registration" /* ErrorCode.INVALID_SW_REGISTRATION */]: 'The input to useServiceWorker() must be a ServiceWorkerRegistration.',
+ ["invalid-bg-handler" /* ErrorCode.INVALID_BG_HANDLER */]: 'The input to setBackgroundMessageHandler() must be a function.',
+ ["invalid-vapid-key" /* ErrorCode.INVALID_VAPID_KEY */]: 'The public VAPID key must be a string.',
+ ["use-vapid-key-after-get-token" /* ErrorCode.USE_VAPID_KEY_AFTER_GET_TOKEN */]: 'The usePublicVapidKey() method may only be called once and must be ' +
+ 'called before calling getToken() to ensure your VAPID key is used.'
+};
+const ERROR_FACTORY = new ErrorFactory('messaging', 'Messaging', ERROR_MAP);
+
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+async function requestGetToken(firebaseDependencies, subscriptionOptions) {
+ const headers = await getHeaders(firebaseDependencies);
+ const body = getBody(subscriptionOptions);
+ const subscribeOptions = {
+ method: 'POST',
+ headers,
+ body: JSON.stringify(body)
+ };
+ let responseData;
+ try {
+ const response = await fetch(getEndpoint(firebaseDependencies.appConfig), subscribeOptions);
+ responseData = await response.json();
+ }
+ catch (err) {
+ throw ERROR_FACTORY.create("token-subscribe-failed" /* ErrorCode.TOKEN_SUBSCRIBE_FAILED */, {
+ errorInfo: err?.toString()
+ });
+ }
+ if (responseData.error) {
+ const message = responseData.error.message;
+ throw ERROR_FACTORY.create("token-subscribe-failed" /* ErrorCode.TOKEN_SUBSCRIBE_FAILED */, {
+ errorInfo: message
+ });
+ }
+ if (!responseData.token) {
+ throw ERROR_FACTORY.create("token-subscribe-no-token" /* ErrorCode.TOKEN_SUBSCRIBE_NO_TOKEN */);
+ }
+ return responseData.token;
+}
+async function requestUpdateToken(firebaseDependencies, tokenDetails) {
+ const headers = await getHeaders(firebaseDependencies);
+ const body = getBody(tokenDetails.subscriptionOptions);
+ const updateOptions = {
+ method: 'PATCH',
+ headers,
+ body: JSON.stringify(body)
+ };
+ let responseData;
+ try {
+ const response = await fetch(`${getEndpoint(firebaseDependencies.appConfig)}/${tokenDetails.token}`, updateOptions);
+ responseData = await response.json();
+ }
+ catch (err) {
+ throw ERROR_FACTORY.create("token-update-failed" /* ErrorCode.TOKEN_UPDATE_FAILED */, {
+ errorInfo: err?.toString()
+ });
+ }
+ if (responseData.error) {
+ const message = responseData.error.message;
+ throw ERROR_FACTORY.create("token-update-failed" /* ErrorCode.TOKEN_UPDATE_FAILED */, {
+ errorInfo: message
+ });
+ }
+ if (!responseData.token) {
+ throw ERROR_FACTORY.create("token-update-no-token" /* ErrorCode.TOKEN_UPDATE_NO_TOKEN */);
+ }
+ return responseData.token;
+}
+async function requestDeleteToken(firebaseDependencies, token) {
+ const headers = await getHeaders(firebaseDependencies);
+ const unsubscribeOptions = {
+ method: 'DELETE',
+ headers
+ };
+ try {
+ const response = await fetch(`${getEndpoint(firebaseDependencies.appConfig)}/${token}`, unsubscribeOptions);
+ const responseData = await response.json();
+ if (responseData.error) {
+ const message = responseData.error.message;
+ throw ERROR_FACTORY.create("token-unsubscribe-failed" /* ErrorCode.TOKEN_UNSUBSCRIBE_FAILED */, {
+ errorInfo: message
+ });
+ }
+ }
+ catch (err) {
+ throw ERROR_FACTORY.create("token-unsubscribe-failed" /* ErrorCode.TOKEN_UNSUBSCRIBE_FAILED */, {
+ errorInfo: err?.toString()
+ });
+ }
+}
+function getEndpoint({ projectId }) {
+ return `${ENDPOINT}/projects/${projectId}/registrations`;
+}
+async function getHeaders({ appConfig, installations }) {
+ const authToken = await installations.getToken();
+ return new Headers({
+ 'Content-Type': 'application/json',
+ Accept: 'application/json',
+ 'x-goog-api-key': appConfig.apiKey,
+ 'x-goog-firebase-installations-auth': `FIS ${authToken}`
+ });
+}
+function getBody({ p256dh, auth, endpoint, vapidKey }) {
+ const body = {
+ web: {
+ endpoint,
+ auth,
+ p256dh
+ }
+ };
+ if (vapidKey !== DEFAULT_VAPID_KEY) {
+ body.web.applicationPubKey = vapidKey;
+ }
+ return body;
+}
+
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// UpdateRegistration will be called once every week.
+const TOKEN_EXPIRATION_MS = 7 * 24 * 60 * 60 * 1000; // 7 days
+async function getTokenInternal(messaging) {
+ const pushSubscription = await getPushSubscription(messaging.swRegistration, messaging.vapidKey);
+ const subscriptionOptions = {
+ vapidKey: messaging.vapidKey,
+ swScope: messaging.swRegistration.scope,
+ endpoint: pushSubscription.endpoint,
+ auth: arrayToBase64(pushSubscription.getKey('auth')),
+ p256dh: arrayToBase64(pushSubscription.getKey('p256dh'))
+ };
+ const tokenDetails = await dbGet(messaging.firebaseDependencies);
+ if (!tokenDetails) {
+ // No token, get a new one.
+ return getNewToken(messaging.firebaseDependencies, subscriptionOptions);
+ }
+ else if (!isTokenValid(tokenDetails.subscriptionOptions, subscriptionOptions)) {
+ // Invalid token, get a new one.
+ try {
+ await requestDeleteToken(messaging.firebaseDependencies, tokenDetails.token);
+ }
+ catch (e) {
+ // Suppress errors because of #2364
+ console.warn(e);
+ }
+ return getNewToken(messaging.firebaseDependencies, subscriptionOptions);
+ }
+ else if (Date.now() >= tokenDetails.createTime + TOKEN_EXPIRATION_MS) {
+ // Weekly token refresh
+ return updateToken(messaging, {
+ token: tokenDetails.token,
+ createTime: Date.now(),
+ subscriptionOptions
+ });
+ }
+ else {
+ // Valid token, nothing to do.
+ return tokenDetails.token;
+ }
+}
+/**
+ * This method deletes the token from the database, unsubscribes the token from FCM, and unregisters
+ * the push subscription if it exists.
+ */
+async function deleteTokenInternal(messaging) {
+ const tokenDetails = await dbGet(messaging.firebaseDependencies);
+ if (tokenDetails) {
+ await requestDeleteToken(messaging.firebaseDependencies, tokenDetails.token);
+ await dbRemove(messaging.firebaseDependencies);
+ }
+ // Unsubscribe from the push subscription.
+ const pushSubscription = await messaging.swRegistration.pushManager.getSubscription();
+ if (pushSubscription) {
+ return pushSubscription.unsubscribe();
+ }
+ // If there's no SW, consider it a success.
+ return true;
+}
+async function updateToken(messaging, tokenDetails) {
+ try {
+ const updatedToken = await requestUpdateToken(messaging.firebaseDependencies, tokenDetails);
+ const updatedTokenDetails = {
+ ...tokenDetails,
+ token: updatedToken,
+ createTime: Date.now()
+ };
+ await dbSet(messaging.firebaseDependencies, updatedTokenDetails);
+ return updatedToken;
+ }
+ catch (e) {
+ throw e;
+ }
+}
+async function getNewToken(firebaseDependencies, subscriptionOptions) {
+ const token = await requestGetToken(firebaseDependencies, subscriptionOptions);
+ const tokenDetails = {
+ token,
+ createTime: Date.now(),
+ subscriptionOptions
+ };
+ await dbSet(firebaseDependencies, tokenDetails);
+ return tokenDetails.token;
+}
+/**
+ * Gets a PushSubscription for the current user.
+ */
+async function getPushSubscription(swRegistration, vapidKey) {
+ const subscription = await swRegistration.pushManager.getSubscription();
+ if (subscription) {
+ return subscription;
+ }
+ return swRegistration.pushManager.subscribe({
+ userVisibleOnly: true,
+ // Chrome <= 75 doesn't support base64-encoded VAPID key. For backward compatibility, VAPID key
+ // submitted to pushManager#subscribe must be of type Uint8Array.
+ applicationServerKey: base64ToArray(vapidKey)
+ });
+}
+/**
+ * Checks if the saved tokenDetails object matches the configuration provided.
+ */
+function isTokenValid(dbOptions, currentOptions) {
+ const isVapidKeyEqual = currentOptions.vapidKey === dbOptions.vapidKey;
+ const isEndpointEqual = currentOptions.endpoint === dbOptions.endpoint;
+ const isAuthEqual = currentOptions.auth === dbOptions.auth;
+ const isP256dhEqual = currentOptions.p256dh === dbOptions.p256dh;
+ return isVapidKeyEqual && isEndpointEqual && isAuthEqual && isP256dhEqual;
+}
+
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+function externalizePayload(internalPayload) {
+ const payload = {
+ from: internalPayload.from,
+ // eslint-disable-next-line camelcase
+ collapseKey: internalPayload.collapse_key,
+ // eslint-disable-next-line camelcase
+ messageId: internalPayload.fcmMessageId
+ };
+ propagateNotificationPayload(payload, internalPayload);
+ propagateDataPayload(payload, internalPayload);
+ propagateFcmOptions(payload, internalPayload);
+ return payload;
+}
+function propagateNotificationPayload(payload, messagePayloadInternal) {
+ if (!messagePayloadInternal.notification) {
+ return;
+ }
+ payload.notification = {};
+ const title = messagePayloadInternal.notification.title;
+ if (!!title) {
+ payload.notification.title = title;
+ }
+ const body = messagePayloadInternal.notification.body;
+ if (!!body) {
+ payload.notification.body = body;
+ }
+ const image = messagePayloadInternal.notification.image;
+ if (!!image) {
+ payload.notification.image = image;
+ }
+ const icon = messagePayloadInternal.notification.icon;
+ if (!!icon) {
+ payload.notification.icon = icon;
+ }
+}
+function propagateDataPayload(payload, messagePayloadInternal) {
+ if (!messagePayloadInternal.data) {
+ return;
+ }
+ payload.data = messagePayloadInternal.data;
+}
+function propagateFcmOptions(payload, messagePayloadInternal) {
+ // fcmOptions.link value is written into notification.click_action. see more in b/232072111
+ if (!messagePayloadInternal.fcmOptions &&
+ !messagePayloadInternal.notification?.click_action) {
+ return;
+ }
+ payload.fcmOptions = {};
+ const link = messagePayloadInternal.fcmOptions?.link ??
+ messagePayloadInternal.notification?.click_action;
+ if (!!link) {
+ payload.fcmOptions.link = link;
+ }
+ // eslint-disable-next-line camelcase
+ const analyticsLabel = messagePayloadInternal.fcmOptions?.analytics_label;
+ if (!!analyticsLabel) {
+ payload.fcmOptions.analyticsLabel = analyticsLabel;
+ }
+}
+
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+function isConsoleMessage(data) {
+ // This message has a campaign ID, meaning it was sent using the Firebase Console.
+ return typeof data === 'object' && !!data && CONSOLE_CAMPAIGN_ID in data;
+}
+
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+_mergeStrings('AzSCbw63g1R0nCw85jG8', 'Iaya3yLKwmgvh7cF0q4');
+function _mergeStrings(s1, s2) {
+ const resultArray = [];
+ for (let i = 0; i < s1.length; i++) {
+ resultArray.push(s1.charAt(i));
+ if (i < s2.length) {
+ resultArray.push(s2.charAt(i));
+ }
+ }
+ return resultArray.join('');
+}
+
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+function extractAppConfig(app) {
+ if (!app || !app.options) {
+ throw getMissingValueError('App Configuration Object');
+ }
+ if (!app.name) {
+ throw getMissingValueError('App Name');
+ }
+ // Required app config keys
+ const configKeys = [
+ 'projectId',
+ 'apiKey',
+ 'appId',
+ 'messagingSenderId'
+ ];
+ const { options } = app;
+ for (const keyName of configKeys) {
+ if (!options[keyName]) {
+ throw getMissingValueError(keyName);
+ }
+ }
+ return {
+ appName: app.name,
+ projectId: options.projectId,
+ apiKey: options.apiKey,
+ appId: options.appId,
+ senderId: options.messagingSenderId
+ };
+}
+function getMissingValueError(valueName) {
+ return ERROR_FACTORY.create("missing-app-config-values" /* ErrorCode.MISSING_APP_CONFIG_VALUES */, {
+ valueName
+ });
+}
+
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+class MessagingService {
+ constructor(app, installations, analyticsProvider) {
+ // logging is only done with end user consent. Default to false.
+ this.deliveryMetricsExportedToBigQueryEnabled = false;
+ this.onBackgroundMessageHandler = null;
+ this.onMessageHandler = null;
+ this.logEvents = [];
+ this.isLogServiceStarted = false;
+ const appConfig = extractAppConfig(app);
+ this.firebaseDependencies = {
+ app,
+ appConfig,
+ installations,
+ analyticsProvider
+ };
+ }
+ _delete() {
+ return Promise.resolve();
+ }
+}
+
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+async function registerDefaultSw(messaging) {
+ try {
+ messaging.swRegistration = await navigator.serviceWorker.register(DEFAULT_SW_PATH, {
+ scope: DEFAULT_SW_SCOPE
+ });
+ // The timing when browser updates sw when sw has an update is unreliable from experiment. It
+ // leads to version conflict when the SDK upgrades to a newer version in the main page, but sw
+ // is stuck with the old version. For example,
+ // https://github.com/firebase/firebase-js-sdk/issues/2590 The following line reliably updates
+ // sw if there was an update.
+ messaging.swRegistration.update().catch(() => {
+ /* it is non blocking and we don't care if it failed */
+ });
+ await waitForRegistrationActive(messaging.swRegistration);
+ }
+ catch (e) {
+ throw ERROR_FACTORY.create("failed-service-worker-registration" /* ErrorCode.FAILED_DEFAULT_REGISTRATION */, {
+ browserErrorMessage: e?.message
+ });
+ }
+}
+/**
+ * Waits for registration to become active. MDN documentation claims that
+ * a service worker registration should be ready to use after awaiting
+ * navigator.serviceWorker.register() but that doesn't seem to be the case in
+ * practice, causing the SDK to throw errors when calling
+ * swRegistration.pushManager.subscribe() too soon after register(). The only
+ * solution seems to be waiting for the service worker registration `state`
+ * to become "active".
+ */
+async function waitForRegistrationActive(registration) {
+ return new Promise((resolve, reject) => {
+ const rejectTimeout = setTimeout(() => reject(new Error(`Service worker not registered after ${DEFAULT_REGISTRATION_TIMEOUT} ms`)), DEFAULT_REGISTRATION_TIMEOUT);
+ const incomingSw = registration.installing || registration.waiting;
+ if (registration.active) {
+ clearTimeout(rejectTimeout);
+ resolve();
+ }
+ else if (incomingSw) {
+ incomingSw.onstatechange = ev => {
+ if (ev.target?.state === 'activated') {
+ incomingSw.onstatechange = null;
+ clearTimeout(rejectTimeout);
+ resolve();
+ }
+ };
+ }
+ else {
+ clearTimeout(rejectTimeout);
+ reject(new Error('No incoming service worker found.'));
+ }
+ });
+}
+
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+async function updateSwReg(messaging, swRegistration) {
+ if (!swRegistration && !messaging.swRegistration) {
+ await registerDefaultSw(messaging);
+ }
+ if (!swRegistration && !!messaging.swRegistration) {
+ return;
+ }
+ if (!(swRegistration instanceof ServiceWorkerRegistration)) {
+ throw ERROR_FACTORY.create("invalid-sw-registration" /* ErrorCode.INVALID_SW_REGISTRATION */);
+ }
+ messaging.swRegistration = swRegistration;
+}
+
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+async function updateVapidKey(messaging, vapidKey) {
+ if (!!vapidKey) {
+ messaging.vapidKey = vapidKey;
+ }
+ else if (!messaging.vapidKey) {
+ messaging.vapidKey = DEFAULT_VAPID_KEY;
+ }
+}
+
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+async function getToken$1(messaging, options) {
+ if (!navigator) {
+ throw ERROR_FACTORY.create("only-available-in-window" /* ErrorCode.AVAILABLE_IN_WINDOW */);
+ }
+ if (Notification.permission === 'default') {
+ await Notification.requestPermission();
+ }
+ if (Notification.permission !== 'granted') {
+ throw ERROR_FACTORY.create("permission-blocked" /* ErrorCode.PERMISSION_BLOCKED */);
+ }
+ await updateVapidKey(messaging, options?.vapidKey);
+ await updateSwReg(messaging, options?.serviceWorkerRegistration);
+ return getTokenInternal(messaging);
+}
+
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+async function logToScion(messaging, messageType, data) {
+ const eventType = getEventType(messageType);
+ const analytics = await messaging.firebaseDependencies.analyticsProvider.get();
+ analytics.logEvent(eventType, {
+ /* eslint-disable camelcase */
+ message_id: data[CONSOLE_CAMPAIGN_ID],
+ message_name: data[CONSOLE_CAMPAIGN_NAME],
+ message_time: data[CONSOLE_CAMPAIGN_TIME],
+ message_device_time: Math.floor(Date.now() / 1000)
+ /* eslint-enable camelcase */
+ });
+}
+function getEventType(messageType) {
+ switch (messageType) {
+ case MessageType.NOTIFICATION_CLICKED:
+ return 'notification_open';
+ case MessageType.PUSH_RECEIVED:
+ return 'notification_foreground';
+ default:
+ throw new Error();
+ }
+}
+
+/**
+ * @license
+ * Copyright 2017 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+async function messageEventListener(messaging, event) {
+ const internalPayload = event.data;
+ if (!internalPayload.isFirebaseMessaging) {
+ return;
+ }
+ if (messaging.onMessageHandler &&
+ internalPayload.messageType === MessageType.PUSH_RECEIVED) {
+ if (typeof messaging.onMessageHandler === 'function') {
+ messaging.onMessageHandler(externalizePayload(internalPayload));
+ }
+ else {
+ messaging.onMessageHandler.next(externalizePayload(internalPayload));
+ }
+ }
+ // Log to Scion if applicable
+ const dataPayload = internalPayload.data;
+ if (isConsoleMessage(dataPayload) &&
+ dataPayload[CONSOLE_CAMPAIGN_ANALYTICS_ENABLED] === '1') {
+ await logToScion(messaging, internalPayload.messageType, dataPayload);
+ }
+}
+
+const name = "@firebase/messaging";
+const version = "0.12.23";
+
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+const WindowMessagingFactory = (container) => {
+ const messaging = new MessagingService(container.getProvider('app').getImmediate(), container.getProvider('installations-internal').getImmediate(), container.getProvider('analytics-internal'));
+ navigator.serviceWorker.addEventListener('message', e => messageEventListener(messaging, e));
+ return messaging;
+};
+const WindowMessagingInternalFactory = (container) => {
+ const messaging = container
+ .getProvider('messaging')
+ .getImmediate();
+ const messagingInternal = {
+ getToken: (options) => getToken$1(messaging, options)
+ };
+ return messagingInternal;
+};
+function registerMessagingInWindow() {
+ _registerComponent(new Component('messaging', WindowMessagingFactory, "PUBLIC" /* ComponentType.PUBLIC */));
+ _registerComponent(new Component('messaging-internal', WindowMessagingInternalFactory, "PRIVATE" /* ComponentType.PRIVATE */));
+ registerVersion(name, version);
+ // BUILD_TARGET will be replaced by values like esm, cjs, etc during the compilation
+ registerVersion(name, version, 'esm2020');
+}
+
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Checks if all required APIs exist in the browser.
+ * @returns a Promise that resolves to a boolean.
+ *
+ * @public
+ */
+async function isWindowSupported() {
+ try {
+ // This throws if open() is unsupported, so adding it to the conditional
+ // statement below can cause an uncaught error.
+ await validateIndexedDBOpenable();
+ }
+ catch (e) {
+ return false;
+ }
+ // firebase-js-sdk/issues/2393 reveals that idb#open in Safari iframe and Firefox private browsing
+ // might be prohibited to run. In these contexts, an error would be thrown during the messaging
+ // instantiating phase, informing the developers to import/call isSupported for special handling.
+ 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'));
+}
+
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+async function deleteToken$1(messaging) {
+ if (!navigator) {
+ throw ERROR_FACTORY.create("only-available-in-window" /* ErrorCode.AVAILABLE_IN_WINDOW */);
+ }
+ if (!messaging.swRegistration) {
+ await registerDefaultSw(messaging);
+ }
+ return deleteTokenInternal(messaging);
+}
+
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+function onMessage$1(messaging, nextOrObserver) {
+ if (!navigator) {
+ throw ERROR_FACTORY.create("only-available-in-window" /* ErrorCode.AVAILABLE_IN_WINDOW */);
+ }
+ messaging.onMessageHandler = nextOrObserver;
+ return () => {
+ messaging.onMessageHandler = null;
+ };
+}
+
+/**
+ * @license
+ * Copyright 2017 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Retrieves a Firebase Cloud Messaging instance.
+ *
+ * @returns The Firebase Cloud Messaging instance associated with the provided firebase app.
+ *
+ * @public
+ */
+function getMessagingInWindow(app = getApp()) {
+ // Conscious decision to make this async check non-blocking during the messaging instance
+ // initialization phase for performance consideration. An error would be thrown latter for
+ // developer's information. Developers can then choose to import and call `isSupported` for
+ // special handling.
+ isWindowSupported().then(isSupported => {
+ // If `isWindowSupported()` resolved, but returned false.
+ if (!isSupported) {
+ throw ERROR_FACTORY.create("unsupported-browser" /* ErrorCode.UNSUPPORTED_BROWSER */);
+ }
+ }, _ => {
+ // If `isWindowSupported()` rejected.
+ throw ERROR_FACTORY.create("indexed-db-unsupported" /* ErrorCode.INDEXED_DB_UNSUPPORTED */);
+ });
+ return _getProvider(getModularInstance(app), 'messaging').getImmediate();
+}
+/**
+ * Subscribes the {@link Messaging} instance to push notifications. Returns a Firebase Cloud
+ * Messaging registration token that can be used to send push messages to that {@link Messaging}
+ * instance.
+ *
+ * If notification permission isn't already granted, this method asks the user for permission. The
+ * returned promise rejects if the user does not allow the app to show notifications.
+ *
+ * @param messaging - The {@link Messaging} instance.
+ * @param options - Provides an optional vapid key and an optional service worker registration.
+ *
+ * @returns The promise resolves with an FCM registration token.
+ *
+ * @public
+ */
+async function getToken(messaging, options) {
+ messaging = getModularInstance(messaging);
+ return getToken$1(messaging, options);
+}
+/**
+ * Deletes the registration token associated with this {@link Messaging} instance and unsubscribes
+ * the {@link Messaging} instance from the push subscription.
+ *
+ * @param messaging - The {@link Messaging} instance.
+ *
+ * @returns The promise resolves when the token has been successfully deleted.
+ *
+ * @public
+ */
+function deleteToken(messaging) {
+ messaging = getModularInstance(messaging);
+ return deleteToken$1(messaging);
+}
+/**
+ * When a push message is received and the user is currently on a page for your origin, the
+ * message is passed to the page and an `onMessage()` event is dispatched with the payload of
+ * the push message.
+ *
+ *
+ * @param messaging - The {@link Messaging} instance.
+ * @param nextOrObserver - This function, or observer object with `next` defined,
+ * is called when a message is received and the user is currently viewing your page.
+ * @returns To stop listening for messages execute this returned function.
+ *
+ * @public
+ */
+function onMessage(messaging, nextOrObserver) {
+ messaging = getModularInstance(messaging);
+ return onMessage$1(messaging, nextOrObserver);
+}
+
+/**
+ * The Firebase Cloud Messaging Web SDK.
+ * This SDK does not work in a Node.js environment.
+ *
+ * @packageDocumentation
+ */
+registerMessagingInWindow();
+
+export { deleteToken, getMessagingInWindow as getMessaging, getToken, isWindowSupported as isSupported, onMessage };
+//# sourceMappingURL=index.esm.js.map
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/index.esm.js.map b/frontend-old/node_modules/@firebase/messaging/dist/esm/index.esm.js.map
new file mode 100644
index 0000000..9e1b1d2
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/index.esm.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"index.esm.js","sources":["../../src/util/constants.ts","../../src/interfaces/internal-message-payload.ts","../../src/helpers/array-base64-translator.ts","../../src/helpers/migrate-old-database.ts","../../src/internals/idb-manager.ts","../../src/util/errors.ts","../../src/internals/requests.ts","../../src/internals/token-manager.ts","../../src/helpers/externalizePayload.ts","../../src/helpers/is-console-message.ts","../../src/helpers/logToFirelog.ts","../../src/helpers/extract-app-config.ts","../../src/messaging-service.ts","../../src/helpers/registerDefaultSw.ts","../../src/helpers/updateSwReg.ts","../../src/helpers/updateVapidKey.ts","../../src/api/getToken.ts","../../src/helpers/logToScion.ts","../../src/listeners/window-listener.ts","../../src/helpers/register.ts","../../src/api/isSupported.ts","../../src/api/deleteToken.ts","../../src/api/onMessage.ts","../../src/api.ts","../../src/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const DEFAULT_SW_PATH = '/firebase-messaging-sw.js';\nexport const DEFAULT_SW_SCOPE = '/firebase-cloud-messaging-push-scope';\n\nexport const DEFAULT_VAPID_KEY =\n 'BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4';\n\nexport const ENDPOINT = 'https://fcmregistrations.googleapis.com/v1';\n\n/** Key of FCM Payload in Notification's data field. */\nexport const FCM_MSG = 'FCM_MSG';\n\nexport const CONSOLE_CAMPAIGN_ID = 'google.c.a.c_id';\nexport const CONSOLE_CAMPAIGN_NAME = 'google.c.a.c_l';\nexport const CONSOLE_CAMPAIGN_TIME = 'google.c.a.ts';\n/** Set to '1' if Analytics is enabled for the campaign */\nexport const CONSOLE_CAMPAIGN_ANALYTICS_ENABLED = 'google.c.a.e';\nexport const TAG = 'FirebaseMessaging: ';\nexport const MAX_NUMBER_OF_EVENTS_PER_LOG_REQUEST = 1000;\nexport const MAX_RETRIES = 3;\nexport const LOG_INTERVAL_IN_MS = 86400000; //24 hour\nexport const DEFAULT_BACKOFF_TIME_MS = 5000;\nexport const DEFAULT_REGISTRATION_TIMEOUT = 10000;\n\n// FCM log source name registered at Firelog: 'FCM_CLIENT_EVENT_LOGGING'. It uniquely identifies\n// FCM's logging configuration.\nexport const FCM_LOG_SOURCE = 1249;\n\n// Defined as in proto/messaging_event.proto. Neglecting fields that are supported.\nexport const SDK_PLATFORM_WEB = 3;\nexport const EVENT_MESSAGE_DELIVERED = 1;\n\nexport enum MessageType {\n DATA_MESSAGE = 1,\n DISPLAY_NOTIFICATION = 3\n}\n","/**\n * @license\n * Copyright 2018 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n * in compliance with the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under the License\n * is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\n * or implied. See the License for the specific language governing permissions and limitations under\n * the License.\n */\n\nimport {\n CONSOLE_CAMPAIGN_ANALYTICS_ENABLED,\n CONSOLE_CAMPAIGN_ID,\n CONSOLE_CAMPAIGN_NAME,\n CONSOLE_CAMPAIGN_TIME\n} from '../util/constants';\n\nexport interface MessagePayloadInternal {\n notification?: NotificationPayloadInternal;\n data?: unknown;\n fcmOptions?: FcmOptionsInternal;\n messageType?: MessageType;\n isFirebaseMessaging?: boolean;\n from: string;\n fcmMessageId: string;\n productId: number;\n // eslint-disable-next-line camelcase\n collapse_key: string;\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/API/Notification/actions\ninterface NotificationAction {\n action: string;\n icon?: string;\n title: string;\n}\n\n/**\n * This interface defines experimental properties of NotificationOptions, that are not part of\n * the interface in the generated DOM types at https://github.com/microsoft/TypeScript-DOM-lib-generator/blob/179bdd84a944933a3103f29c2274c9f5a857b693/baselines/dom.generated.d.ts#L1012\n * https://developer.mozilla.org/en-US/docs/Web/API/Notification\n */\ninterface NotificationOptionsExperimental extends NotificationOptions {\n readonly maxActions?: number;\n readonly actions?: NotificationAction[];\n readonly image?: string;\n readonly renotify?: boolean;\n readonly timestamp?: EpochTimeStamp;\n readonly vibrate?: VibratePattern;\n}\n\nexport interface NotificationPayloadInternal\n extends NotificationOptionsExperimental {\n title: string;\n // Supported in the Legacy Send API.\n // See:https://firebase.google.com/docs/cloud-messaging/xmpp-server-ref.\n // eslint-disable-next-line camelcase\n click_action?: string;\n icon?: string;\n}\n\n// Defined in\n// https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#webpushfcmoptions. Note\n// that the keys are sent to the clients in snake cases which we need to convert to camel so it can\n// be exposed as a type to match the Firebase API convention.\nexport interface FcmOptionsInternal {\n link?: string;\n\n // eslint-disable-next-line camelcase\n analytics_label?: string;\n}\n\nexport enum MessageType {\n PUSH_RECEIVED = 'push-received',\n NOTIFICATION_CLICKED = 'notification-clicked'\n}\n\n/** Additional data of a message sent from the FN Console. */\nexport interface ConsoleMessageData {\n [CONSOLE_CAMPAIGN_ID]: string;\n [CONSOLE_CAMPAIGN_TIME]: string;\n [CONSOLE_CAMPAIGN_NAME]?: string;\n [CONSOLE_CAMPAIGN_ANALYTICS_ENABLED]?: '1';\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function arrayToBase64(array: Uint8Array | ArrayBuffer): string {\n const uint8Array = new Uint8Array(array);\n const base64String = btoa(String.fromCharCode(...uint8Array));\n return base64String.replace(/=/g, '').replace(/\\+/g, '-').replace(/\\//g, '_');\n}\n\nexport function base64ToArray(base64String: string): Uint8Array {\n const padding = '='.repeat((4 - (base64String.length % 4)) % 4);\n const base64 = (base64String + padding)\n .replace(/\\-/g, '+')\n .replace(/_/g, '/');\n\n const rawData = atob(base64);\n const outputArray = new Uint8Array(rawData.length);\n\n for (let i = 0; i < rawData.length; ++i) {\n outputArray[i] = rawData.charCodeAt(i);\n }\n return outputArray;\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { deleteDB, openDB } from 'idb';\n\nimport { TokenDetails } from '../interfaces/token-details';\nimport { arrayToBase64 } from './array-base64-translator';\n\n// https://github.com/firebase/firebase-js-sdk/blob/7857c212f944a2a9eb421fd4cb7370181bc034b5/packages/messaging/src/interfaces/token-details.ts\nexport interface V2TokenDetails {\n fcmToken: string;\n swScope: string;\n vapidKey: string | Uint8Array;\n subscription: PushSubscription;\n fcmSenderId: string;\n fcmPushSet: string;\n createTime?: number;\n endpoint?: string;\n auth?: string;\n p256dh?: string;\n}\n\n// https://github.com/firebase/firebase-js-sdk/blob/6b5b15ce4ea3df5df5df8a8b33a4e41e249c7715/packages/messaging/src/interfaces/token-details.ts\nexport interface V3TokenDetails {\n fcmToken: string;\n swScope: string;\n vapidKey: Uint8Array;\n fcmSenderId: string;\n fcmPushSet: string;\n endpoint: string;\n auth: ArrayBuffer;\n p256dh: ArrayBuffer;\n createTime: number;\n}\n\n// https://github.com/firebase/firebase-js-sdk/blob/9567dba664732f681fa7fe60f5b7032bb1daf4c9/packages/messaging/src/interfaces/token-details.ts\nexport interface V4TokenDetails {\n fcmToken: string;\n swScope: string;\n vapidKey: Uint8Array;\n fcmSenderId: string;\n endpoint: string;\n auth: ArrayBufferLike;\n p256dh: ArrayBufferLike;\n createTime: number;\n}\n\nconst OLD_DB_NAME = 'fcm_token_details_db';\n/**\n * The last DB version of 'fcm_token_details_db' was 4. This is one higher, so that the upgrade\n * callback is called for all versions of the old DB.\n */\nconst OLD_DB_VERSION = 5;\nconst OLD_OBJECT_STORE_NAME = 'fcm_token_object_Store';\n\nexport async function migrateOldDatabase(\n senderId: string\n): Promise<TokenDetails | null> {\n if ('databases' in indexedDB) {\n // indexedDb.databases() is an IndexedDB v3 API and does not exist in all browsers. TODO: Remove\n // typecast when it lands in TS types.\n const databases = await (\n indexedDB as {\n databases(): Promise<Array<{ name: string; version: number }>>;\n }\n ).databases();\n const dbNames = databases.map(db => db.name);\n\n if (!dbNames.includes(OLD_DB_NAME)) {\n // old DB didn't exist, no need to open.\n return null;\n }\n }\n\n let tokenDetails: TokenDetails | null = null;\n\n const db = await openDB(OLD_DB_NAME, OLD_DB_VERSION, {\n upgrade: async (db, oldVersion, newVersion, upgradeTransaction) => {\n if (oldVersion < 2) {\n // Database too old, skip migration.\n return;\n }\n\n if (!db.objectStoreNames.contains(OLD_OBJECT_STORE_NAME)) {\n // Database did not exist. Nothing to do.\n return;\n }\n\n const objectStore = upgradeTransaction.objectStore(OLD_OBJECT_STORE_NAME);\n const value = await objectStore.index('fcmSenderId').get(senderId);\n await objectStore.clear();\n\n if (!value) {\n // No entry in the database, nothing to migrate.\n return;\n }\n\n if (oldVersion === 2) {\n const oldDetails = value as V2TokenDetails;\n\n if (!oldDetails.auth || !oldDetails.p256dh || !oldDetails.endpoint) {\n return;\n }\n\n tokenDetails = {\n token: oldDetails.fcmToken,\n createTime: oldDetails.createTime ?? Date.now(),\n subscriptionOptions: {\n auth: oldDetails.auth,\n p256dh: oldDetails.p256dh,\n endpoint: oldDetails.endpoint,\n swScope: oldDetails.swScope,\n vapidKey:\n typeof oldDetails.vapidKey === 'string'\n ? oldDetails.vapidKey\n : arrayToBase64(oldDetails.vapidKey)\n }\n };\n } else if (oldVersion === 3) {\n const oldDetails = value as V3TokenDetails;\n\n tokenDetails = {\n token: oldDetails.fcmToken,\n createTime: oldDetails.createTime,\n subscriptionOptions: {\n auth: arrayToBase64(oldDetails.auth),\n p256dh: arrayToBase64(oldDetails.p256dh),\n endpoint: oldDetails.endpoint,\n swScope: oldDetails.swScope,\n vapidKey: arrayToBase64(oldDetails.vapidKey)\n }\n };\n } else if (oldVersion === 4) {\n const oldDetails = value as V4TokenDetails;\n\n tokenDetails = {\n token: oldDetails.fcmToken,\n createTime: oldDetails.createTime,\n subscriptionOptions: {\n auth: arrayToBase64(oldDetails.auth),\n p256dh: arrayToBase64(oldDetails.p256dh),\n endpoint: oldDetails.endpoint,\n swScope: oldDetails.swScope,\n vapidKey: arrayToBase64(oldDetails.vapidKey)\n }\n };\n }\n }\n });\n db.close();\n\n // Delete all old databases.\n await deleteDB(OLD_DB_NAME);\n await deleteDB('fcm_vapid_details_db');\n await deleteDB('undefined');\n\n return checkTokenDetails(tokenDetails) ? tokenDetails : null;\n}\n\nfunction checkTokenDetails(\n tokenDetails: TokenDetails | null\n): tokenDetails is TokenDetails {\n if (!tokenDetails || !tokenDetails.subscriptionOptions) {\n return false;\n }\n const { subscriptionOptions } = tokenDetails;\n return (\n typeof tokenDetails.createTime === 'number' &&\n tokenDetails.createTime > 0 &&\n typeof tokenDetails.token === 'string' &&\n tokenDetails.token.length > 0 &&\n typeof subscriptionOptions.auth === 'string' &&\n subscriptionOptions.auth.length > 0 &&\n typeof subscriptionOptions.p256dh === 'string' &&\n subscriptionOptions.p256dh.length > 0 &&\n typeof subscriptionOptions.endpoint === 'string' &&\n subscriptionOptions.endpoint.length > 0 &&\n typeof subscriptionOptions.swScope === 'string' &&\n subscriptionOptions.swScope.length > 0 &&\n typeof subscriptionOptions.vapidKey === 'string' &&\n subscriptionOptions.vapidKey.length > 0\n );\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DBSchema, IDBPDatabase, deleteDB, openDB } from 'idb';\n\nimport { FirebaseInternalDependencies } from '../interfaces/internal-dependencies';\nimport { TokenDetails } from '../interfaces/token-details';\nimport { migrateOldDatabase } from '../helpers/migrate-old-database';\n\n// Exported for tests.\nexport const DATABASE_NAME = 'firebase-messaging-database';\nconst DATABASE_VERSION = 1;\nconst OBJECT_STORE_NAME = 'firebase-messaging-store';\n\ninterface MessagingDB extends DBSchema {\n 'firebase-messaging-store': {\n key: string;\n value: TokenDetails;\n };\n}\n\nlet dbPromise: Promise<IDBPDatabase<MessagingDB>> | null = null;\nfunction getDbPromise(): Promise<IDBPDatabase<MessagingDB>> {\n if (!dbPromise) {\n dbPromise = openDB(DATABASE_NAME, DATABASE_VERSION, {\n upgrade: (upgradeDb, oldVersion) => {\n // We don't use 'break' in this switch statement, the fall-through behavior is what we want,\n // because if there are multiple versions between the old version and the current version, we\n // want ALL the migrations that correspond to those versions to run, not only the last one.\n // eslint-disable-next-line default-case\n switch (oldVersion) {\n case 0:\n upgradeDb.createObjectStore(OBJECT_STORE_NAME);\n }\n }\n });\n }\n return dbPromise;\n}\n\n/** Gets record(s) from the objectStore that match the given key. */\nexport async function dbGet(\n firebaseDependencies: FirebaseInternalDependencies\n): Promise<TokenDetails | undefined> {\n const key = getKey(firebaseDependencies);\n const db = await getDbPromise();\n const tokenDetails = (await db\n .transaction(OBJECT_STORE_NAME)\n .objectStore(OBJECT_STORE_NAME)\n .get(key)) as TokenDetails;\n\n if (tokenDetails) {\n return tokenDetails;\n } else {\n // Check if there is a tokenDetails object in the old DB.\n const oldTokenDetails = await migrateOldDatabase(\n firebaseDependencies.appConfig.senderId\n );\n if (oldTokenDetails) {\n await dbSet(firebaseDependencies, oldTokenDetails);\n return oldTokenDetails;\n }\n }\n}\n\n/** Assigns or overwrites the record for the given key with the given value. */\nexport async function dbSet(\n firebaseDependencies: FirebaseInternalDependencies,\n tokenDetails: TokenDetails\n): Promise<TokenDetails> {\n const key = getKey(firebaseDependencies);\n const db = await getDbPromise();\n const tx = db.transaction(OBJECT_STORE_NAME, 'readwrite');\n await tx.objectStore(OBJECT_STORE_NAME).put(tokenDetails, key);\n await tx.done;\n return tokenDetails;\n}\n\n/** Removes record(s) from the objectStore that match the given key. */\nexport async function dbRemove(\n firebaseDependencies: FirebaseInternalDependencies\n): Promise<void> {\n const key = getKey(firebaseDependencies);\n const db = await getDbPromise();\n const tx = db.transaction(OBJECT_STORE_NAME, 'readwrite');\n await tx.objectStore(OBJECT_STORE_NAME).delete(key);\n await tx.done;\n}\n\n/** Deletes the DB. Useful for tests. */\nexport async function dbDelete(): Promise<void> {\n if (dbPromise) {\n (await dbPromise).close();\n await deleteDB(DATABASE_NAME);\n dbPromise = null;\n }\n}\n\nfunction getKey({ appConfig }: FirebaseInternalDependencies): string {\n return appConfig.appId;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ErrorFactory, ErrorMap } from '@firebase/util';\n\nexport const enum ErrorCode {\n MISSING_APP_CONFIG_VALUES = 'missing-app-config-values',\n AVAILABLE_IN_WINDOW = 'only-available-in-window',\n AVAILABLE_IN_SW = 'only-available-in-sw',\n PERMISSION_DEFAULT = 'permission-default',\n PERMISSION_BLOCKED = 'permission-blocked',\n UNSUPPORTED_BROWSER = 'unsupported-browser',\n INDEXED_DB_UNSUPPORTED = 'indexed-db-unsupported',\n FAILED_DEFAULT_REGISTRATION = 'failed-service-worker-registration',\n TOKEN_SUBSCRIBE_FAILED = 'token-subscribe-failed',\n TOKEN_SUBSCRIBE_NO_TOKEN = 'token-subscribe-no-token',\n TOKEN_UNSUBSCRIBE_FAILED = 'token-unsubscribe-failed',\n TOKEN_UPDATE_FAILED = 'token-update-failed',\n TOKEN_UPDATE_NO_TOKEN = 'token-update-no-token',\n INVALID_BG_HANDLER = 'invalid-bg-handler',\n USE_SW_AFTER_GET_TOKEN = 'use-sw-after-get-token',\n INVALID_SW_REGISTRATION = 'invalid-sw-registration',\n USE_VAPID_KEY_AFTER_GET_TOKEN = 'use-vapid-key-after-get-token',\n INVALID_VAPID_KEY = 'invalid-vapid-key'\n}\n\nexport const ERROR_MAP: ErrorMap<ErrorCode> = {\n [ErrorCode.MISSING_APP_CONFIG_VALUES]:\n 'Missing App configuration value: \"{$valueName}\"',\n [ErrorCode.AVAILABLE_IN_WINDOW]:\n 'This method is available in a Window context.',\n [ErrorCode.AVAILABLE_IN_SW]:\n 'This method is available in a service worker context.',\n [ErrorCode.PERMISSION_DEFAULT]:\n 'The notification permission was not granted and dismissed instead.',\n [ErrorCode.PERMISSION_BLOCKED]:\n 'The notification permission was not granted and blocked instead.',\n [ErrorCode.UNSUPPORTED_BROWSER]:\n \"This browser doesn't support the API's required to use the Firebase SDK.\",\n [ErrorCode.INDEXED_DB_UNSUPPORTED]:\n \"This browser doesn't support indexedDb.open() (ex. Safari iFrame, Firefox Private Browsing, etc)\",\n [ErrorCode.FAILED_DEFAULT_REGISTRATION]:\n 'We are unable to register the default service worker. {$browserErrorMessage}',\n [ErrorCode.TOKEN_SUBSCRIBE_FAILED]:\n 'A problem occurred while subscribing the user to FCM: {$errorInfo}',\n [ErrorCode.TOKEN_SUBSCRIBE_NO_TOKEN]:\n 'FCM returned no token when subscribing the user to push.',\n [ErrorCode.TOKEN_UNSUBSCRIBE_FAILED]:\n 'A problem occurred while unsubscribing the ' +\n 'user from FCM: {$errorInfo}',\n [ErrorCode.TOKEN_UPDATE_FAILED]:\n 'A problem occurred while updating the user from FCM: {$errorInfo}',\n [ErrorCode.TOKEN_UPDATE_NO_TOKEN]:\n 'FCM returned no token when updating the user to push.',\n [ErrorCode.USE_SW_AFTER_GET_TOKEN]:\n 'The useServiceWorker() method may only be called once and must be ' +\n 'called before calling getToken() to ensure your service worker is used.',\n [ErrorCode.INVALID_SW_REGISTRATION]:\n 'The input to useServiceWorker() must be a ServiceWorkerRegistration.',\n [ErrorCode.INVALID_BG_HANDLER]:\n 'The input to setBackgroundMessageHandler() must be a function.',\n [ErrorCode.INVALID_VAPID_KEY]: 'The public VAPID key must be a string.',\n [ErrorCode.USE_VAPID_KEY_AFTER_GET_TOKEN]:\n 'The usePublicVapidKey() method may only be called once and must be ' +\n 'called before calling getToken() to ensure your VAPID key is used.'\n};\n\ninterface ErrorParams {\n [ErrorCode.MISSING_APP_CONFIG_VALUES]: {\n valueName: string;\n };\n [ErrorCode.FAILED_DEFAULT_REGISTRATION]: { browserErrorMessage: string };\n [ErrorCode.TOKEN_SUBSCRIBE_FAILED]: { errorInfo: string };\n [ErrorCode.TOKEN_UNSUBSCRIBE_FAILED]: { errorInfo: string };\n [ErrorCode.TOKEN_UPDATE_FAILED]: { errorInfo: string };\n}\n\nexport const ERROR_FACTORY = new ErrorFactory<ErrorCode, ErrorParams>(\n 'messaging',\n 'Messaging',\n ERROR_MAP\n);\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DEFAULT_VAPID_KEY, ENDPOINT } from '../util/constants';\nimport { ERROR_FACTORY, ErrorCode } from '../util/errors';\nimport { SubscriptionOptions, TokenDetails } from '../interfaces/token-details';\n\nimport { AppConfig } from '../interfaces/app-config';\nimport { FirebaseInternalDependencies } from '../interfaces/internal-dependencies';\n\nexport interface ApiResponse {\n token?: string;\n error?: { message: string };\n}\n\nexport interface ApiRequestBody {\n web: {\n endpoint: string;\n p256dh: string;\n auth: string;\n applicationPubKey?: string;\n };\n}\n\nexport async function requestGetToken(\n firebaseDependencies: FirebaseInternalDependencies,\n subscriptionOptions: SubscriptionOptions\n): Promise<string> {\n const headers = await getHeaders(firebaseDependencies);\n const body = getBody(subscriptionOptions);\n\n const subscribeOptions = {\n method: 'POST',\n headers,\n body: JSON.stringify(body)\n };\n\n let responseData: ApiResponse;\n try {\n const response = await fetch(\n getEndpoint(firebaseDependencies.appConfig),\n subscribeOptions\n );\n responseData = await response.json();\n } catch (err) {\n throw ERROR_FACTORY.create(ErrorCode.TOKEN_SUBSCRIBE_FAILED, {\n errorInfo: (err as Error)?.toString()\n });\n }\n\n if (responseData.error) {\n const message = responseData.error.message;\n throw ERROR_FACTORY.create(ErrorCode.TOKEN_SUBSCRIBE_FAILED, {\n errorInfo: message\n });\n }\n\n if (!responseData.token) {\n throw ERROR_FACTORY.create(ErrorCode.TOKEN_SUBSCRIBE_NO_TOKEN);\n }\n\n return responseData.token;\n}\n\nexport async function requestUpdateToken(\n firebaseDependencies: FirebaseInternalDependencies,\n tokenDetails: TokenDetails\n): Promise<string> {\n const headers = await getHeaders(firebaseDependencies);\n const body = getBody(tokenDetails.subscriptionOptions!);\n\n const updateOptions = {\n method: 'PATCH',\n headers,\n body: JSON.stringify(body)\n };\n\n let responseData: ApiResponse;\n try {\n const response = await fetch(\n `${getEndpoint(firebaseDependencies.appConfig)}/${tokenDetails.token}`,\n updateOptions\n );\n responseData = await response.json();\n } catch (err) {\n throw ERROR_FACTORY.create(ErrorCode.TOKEN_UPDATE_FAILED, {\n errorInfo: (err as Error)?.toString()\n });\n }\n\n if (responseData.error) {\n const message = responseData.error.message;\n throw ERROR_FACTORY.create(ErrorCode.TOKEN_UPDATE_FAILED, {\n errorInfo: message\n });\n }\n\n if (!responseData.token) {\n throw ERROR_FACTORY.create(ErrorCode.TOKEN_UPDATE_NO_TOKEN);\n }\n\n return responseData.token;\n}\n\nexport async function requestDeleteToken(\n firebaseDependencies: FirebaseInternalDependencies,\n token: string\n): Promise<void> {\n const headers = await getHeaders(firebaseDependencies);\n\n const unsubscribeOptions = {\n method: 'DELETE',\n headers\n };\n\n try {\n const response = await fetch(\n `${getEndpoint(firebaseDependencies.appConfig)}/${token}`,\n unsubscribeOptions\n );\n const responseData: ApiResponse = await response.json();\n if (responseData.error) {\n const message = responseData.error.message;\n throw ERROR_FACTORY.create(ErrorCode.TOKEN_UNSUBSCRIBE_FAILED, {\n errorInfo: message\n });\n }\n } catch (err) {\n throw ERROR_FACTORY.create(ErrorCode.TOKEN_UNSUBSCRIBE_FAILED, {\n errorInfo: (err as Error)?.toString()\n });\n }\n}\n\nfunction getEndpoint({ projectId }: AppConfig): string {\n return `${ENDPOINT}/projects/${projectId!}/registrations`;\n}\n\nasync function getHeaders({\n appConfig,\n installations\n}: FirebaseInternalDependencies): Promise<Headers> {\n const authToken = await installations.getToken();\n\n return new Headers({\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n 'x-goog-api-key': appConfig.apiKey!,\n 'x-goog-firebase-installations-auth': `FIS ${authToken}`\n });\n}\n\nfunction getBody({\n p256dh,\n auth,\n endpoint,\n vapidKey\n}: SubscriptionOptions): ApiRequestBody {\n const body: ApiRequestBody = {\n web: {\n endpoint,\n auth,\n p256dh\n }\n };\n\n if (vapidKey !== DEFAULT_VAPID_KEY) {\n body.web.applicationPubKey = vapidKey;\n }\n\n return body;\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SubscriptionOptions, TokenDetails } from '../interfaces/token-details';\nimport {\n arrayToBase64,\n base64ToArray\n} from '../helpers/array-base64-translator';\nimport { dbGet, dbRemove, dbSet } from './idb-manager';\nimport {\n requestDeleteToken,\n requestGetToken,\n requestUpdateToken\n} from './requests';\n\nimport { FirebaseInternalDependencies } from '../interfaces/internal-dependencies';\nimport { MessagingService } from '../messaging-service';\n\n// UpdateRegistration will be called once every week.\nconst TOKEN_EXPIRATION_MS = 7 * 24 * 60 * 60 * 1000; // 7 days\n\nexport async function getTokenInternal(\n messaging: MessagingService\n): Promise<string> {\n const pushSubscription = await getPushSubscription(\n messaging.swRegistration!,\n messaging.vapidKey!\n );\n\n const subscriptionOptions: SubscriptionOptions = {\n vapidKey: messaging.vapidKey!,\n swScope: messaging.swRegistration!.scope,\n endpoint: pushSubscription.endpoint,\n auth: arrayToBase64(pushSubscription.getKey('auth')!),\n p256dh: arrayToBase64(pushSubscription.getKey('p256dh')!)\n };\n\n const tokenDetails = await dbGet(messaging.firebaseDependencies);\n if (!tokenDetails) {\n // No token, get a new one.\n return getNewToken(messaging.firebaseDependencies, subscriptionOptions);\n } else if (\n !isTokenValid(tokenDetails.subscriptionOptions!, subscriptionOptions)\n ) {\n // Invalid token, get a new one.\n try {\n await requestDeleteToken(\n messaging.firebaseDependencies!,\n tokenDetails.token\n );\n } catch (e) {\n // Suppress errors because of #2364\n console.warn(e);\n }\n\n return getNewToken(messaging.firebaseDependencies!, subscriptionOptions);\n } else if (Date.now() >= tokenDetails.createTime + TOKEN_EXPIRATION_MS) {\n // Weekly token refresh\n return updateToken(messaging, {\n token: tokenDetails.token,\n createTime: Date.now(),\n subscriptionOptions\n });\n } else {\n // Valid token, nothing to do.\n return tokenDetails.token;\n }\n}\n\n/**\n * This method deletes the token from the database, unsubscribes the token from FCM, and unregisters\n * the push subscription if it exists.\n */\nexport async function deleteTokenInternal(\n messaging: MessagingService\n): Promise<boolean> {\n const tokenDetails = await dbGet(messaging.firebaseDependencies);\n if (tokenDetails) {\n await requestDeleteToken(\n messaging.firebaseDependencies,\n tokenDetails.token\n );\n await dbRemove(messaging.firebaseDependencies);\n }\n\n // Unsubscribe from the push subscription.\n const pushSubscription =\n await messaging.swRegistration!.pushManager.getSubscription();\n if (pushSubscription) {\n return pushSubscription.unsubscribe();\n }\n\n // If there's no SW, consider it a success.\n return true;\n}\n\nasync function updateToken(\n messaging: MessagingService,\n tokenDetails: TokenDetails\n): Promise<string> {\n try {\n const updatedToken = await requestUpdateToken(\n messaging.firebaseDependencies,\n tokenDetails\n );\n\n const updatedTokenDetails: TokenDetails = {\n ...tokenDetails,\n token: updatedToken,\n createTime: Date.now()\n };\n\n await dbSet(messaging.firebaseDependencies, updatedTokenDetails);\n return updatedToken;\n } catch (e) {\n throw e;\n }\n}\n\nasync function getNewToken(\n firebaseDependencies: FirebaseInternalDependencies,\n subscriptionOptions: SubscriptionOptions\n): Promise<string> {\n const token = await requestGetToken(\n firebaseDependencies,\n subscriptionOptions\n );\n const tokenDetails: TokenDetails = {\n token,\n createTime: Date.now(),\n subscriptionOptions\n };\n await dbSet(firebaseDependencies, tokenDetails);\n return tokenDetails.token;\n}\n\n/**\n * Gets a PushSubscription for the current user.\n */\nasync function getPushSubscription(\n swRegistration: ServiceWorkerRegistration,\n vapidKey: string\n): Promise<PushSubscription> {\n const subscription = await swRegistration.pushManager.getSubscription();\n if (subscription) {\n return subscription;\n }\n\n return swRegistration.pushManager.subscribe({\n userVisibleOnly: true,\n // Chrome <= 75 doesn't support base64-encoded VAPID key. For backward compatibility, VAPID key\n // submitted to pushManager#subscribe must be of type Uint8Array.\n applicationServerKey: base64ToArray(vapidKey)\n });\n}\n\n/**\n * Checks if the saved tokenDetails object matches the configuration provided.\n */\nfunction isTokenValid(\n dbOptions: SubscriptionOptions,\n currentOptions: SubscriptionOptions\n): boolean {\n const isVapidKeyEqual = currentOptions.vapidKey === dbOptions.vapidKey;\n const isEndpointEqual = currentOptions.endpoint === dbOptions.endpoint;\n const isAuthEqual = currentOptions.auth === dbOptions.auth;\n const isP256dhEqual = currentOptions.p256dh === dbOptions.p256dh;\n\n return isVapidKeyEqual && isEndpointEqual && isAuthEqual && isP256dhEqual;\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { MessagePayload } from '../interfaces/public-types';\nimport { MessagePayloadInternal } from '../interfaces/internal-message-payload';\n\nexport function externalizePayload(\n internalPayload: MessagePayloadInternal\n): MessagePayload {\n const payload: MessagePayload = {\n from: internalPayload.from,\n // eslint-disable-next-line camelcase\n collapseKey: internalPayload.collapse_key,\n // eslint-disable-next-line camelcase\n messageId: internalPayload.fcmMessageId\n } as MessagePayload;\n\n propagateNotificationPayload(payload, internalPayload);\n propagateDataPayload(payload, internalPayload);\n propagateFcmOptions(payload, internalPayload);\n\n return payload;\n}\n\nfunction propagateNotificationPayload(\n payload: MessagePayload,\n messagePayloadInternal: MessagePayloadInternal\n): void {\n if (!messagePayloadInternal.notification) {\n return;\n }\n\n payload.notification = {};\n\n const title = messagePayloadInternal.notification!.title;\n if (!!title) {\n payload.notification!.title = title;\n }\n\n const body = messagePayloadInternal.notification!.body;\n if (!!body) {\n payload.notification!.body = body;\n }\n\n const image = messagePayloadInternal.notification!.image;\n if (!!image) {\n payload.notification!.image = image;\n }\n\n const icon = messagePayloadInternal.notification!.icon;\n if (!!icon) {\n payload.notification!.icon = icon;\n }\n}\n\nfunction propagateDataPayload(\n payload: MessagePayload,\n messagePayloadInternal: MessagePayloadInternal\n): void {\n if (!messagePayloadInternal.data) {\n return;\n }\n\n payload.data = messagePayloadInternal.data as { [key: string]: string };\n}\n\nfunction propagateFcmOptions(\n payload: MessagePayload,\n messagePayloadInternal: MessagePayloadInternal\n): void {\n // fcmOptions.link value is written into notification.click_action. see more in b/232072111\n if (\n !messagePayloadInternal.fcmOptions &&\n !messagePayloadInternal.notification?.click_action\n ) {\n return;\n }\n\n payload.fcmOptions = {};\n\n const link =\n messagePayloadInternal.fcmOptions?.link ??\n messagePayloadInternal.notification?.click_action;\n\n if (!!link) {\n payload.fcmOptions!.link = link;\n }\n\n // eslint-disable-next-line camelcase\n const analyticsLabel = messagePayloadInternal.fcmOptions?.analytics_label;\n if (!!analyticsLabel) {\n payload.fcmOptions!.analyticsLabel = analyticsLabel;\n }\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CONSOLE_CAMPAIGN_ID } from '../util/constants';\nimport { ConsoleMessageData } from '../interfaces/internal-message-payload';\n\nexport function isConsoleMessage(data: unknown): data is ConsoleMessageData {\n // This message has a campaign ID, meaning it was sent using the Firebase Console.\n return typeof data === 'object' && !!data && CONSOLE_CAMPAIGN_ID in data;\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n DEFAULT_BACKOFF_TIME_MS,\n EVENT_MESSAGE_DELIVERED,\n FCM_LOG_SOURCE,\n LOG_INTERVAL_IN_MS,\n MAX_NUMBER_OF_EVENTS_PER_LOG_REQUEST,\n MAX_RETRIES,\n MessageType,\n SDK_PLATFORM_WEB\n} from '../util/constants';\nimport {\n FcmEvent,\n LogEvent,\n LogRequest,\n LogResponse,\n ComplianceData\n} from '../interfaces/logging-types';\n\nimport { MessagePayloadInternal } from '../interfaces/internal-message-payload';\nimport { MessagingService } from '../messaging-service';\n\nconst LOG_ENDPOINT = 'https://play.google.com/log?format=json_proto3';\n\nconst FCM_TRANSPORT_KEY = _mergeStrings(\n 'AzSCbw63g1R0nCw85jG8',\n 'Iaya3yLKwmgvh7cF0q4'\n);\n\nexport function startLoggingService(messaging: MessagingService): void {\n if (!messaging.isLogServiceStarted) {\n _processQueue(messaging, LOG_INTERVAL_IN_MS);\n messaging.isLogServiceStarted = true;\n }\n}\n\n/**\n *\n * @param messaging the messaging instance.\n * @param offsetInMs this method execute after `offsetInMs` elapsed .\n */\nexport function _processQueue(\n messaging: MessagingService,\n offsetInMs: number\n): void {\n setTimeout(async () => {\n if (!messaging.deliveryMetricsExportedToBigQueryEnabled) {\n // flush events and terminate logging service\n messaging.logEvents = [];\n messaging.isLogServiceStarted = false;\n\n return;\n }\n\n if (!messaging.logEvents.length) {\n return _processQueue(messaging, LOG_INTERVAL_IN_MS);\n }\n\n await _dispatchLogEvents(messaging);\n }, offsetInMs);\n}\n\nexport async function _dispatchLogEvents(\n messaging: MessagingService\n): Promise<void> {\n for (\n let i = 0, n = messaging.logEvents.length;\n i < n;\n i += MAX_NUMBER_OF_EVENTS_PER_LOG_REQUEST\n ) {\n const logRequest = _createLogRequest(\n messaging.logEvents.slice(i, i + MAX_NUMBER_OF_EVENTS_PER_LOG_REQUEST)\n );\n\n let retryCount = 0,\n response = {} as Response;\n\n do {\n try {\n response = await fetch(\n LOG_ENDPOINT.concat('&key=', FCM_TRANSPORT_KEY),\n {\n method: 'POST',\n body: JSON.stringify(logRequest)\n }\n );\n\n // don't retry on 200s or non retriable errors\n if (response.ok || (!response.ok && !isRetriableError(response))) {\n break;\n }\n\n if (!response.ok && isRetriableError(response)) {\n // rethrow to retry with quota\n throw new Error(\n 'a retriable Non-200 code is returned in fetch to Firelog endpoint. Retry'\n );\n }\n } catch (error) {\n const isLastAttempt = retryCount === MAX_RETRIES;\n if (isLastAttempt) {\n // existing the do-while interactive retry logic because retry quota has reached.\n break;\n }\n }\n\n let delayInMs: number;\n try {\n delayInMs = Number(\n ((await response.json()) as LogResponse).nextRequestWaitMillis\n );\n } catch (e) {\n delayInMs = DEFAULT_BACKOFF_TIME_MS;\n }\n\n await new Promise(resolve => setTimeout(resolve, delayInMs));\n\n retryCount++;\n } while (retryCount < MAX_RETRIES);\n }\n\n messaging.logEvents = [];\n // schedule for next logging\n _processQueue(messaging, LOG_INTERVAL_IN_MS);\n}\n\nfunction isRetriableError(response: Response): boolean {\n const httpStatus = response.status;\n\n return (\n httpStatus === 429 ||\n httpStatus === 500 ||\n httpStatus === 503 ||\n httpStatus === 504\n );\n}\n\nexport async function stageLog(\n messaging: MessagingService,\n internalPayload: MessagePayloadInternal\n): Promise<void> {\n const fcmEvent = createFcmEvent(\n internalPayload,\n await messaging.firebaseDependencies.installations.getId()\n );\n\n createAndEnqueueLogEvent(messaging, fcmEvent, internalPayload.productId);\n}\n\nfunction createFcmEvent(\n internalPayload: MessagePayloadInternal,\n fid: string\n): FcmEvent {\n const fcmEvent = {} as FcmEvent;\n\n /* eslint-disable camelcase */\n // some fields should always be non-null. Still check to ensure.\n if (!!internalPayload.from) {\n fcmEvent.project_number = internalPayload.from;\n }\n\n if (!!internalPayload.fcmMessageId) {\n fcmEvent.message_id = internalPayload.fcmMessageId;\n }\n\n fcmEvent.instance_id = fid;\n\n if (!!internalPayload.notification) {\n fcmEvent.message_type = MessageType.DISPLAY_NOTIFICATION.toString();\n } else {\n fcmEvent.message_type = MessageType.DATA_MESSAGE.toString();\n }\n\n fcmEvent.sdk_platform = SDK_PLATFORM_WEB.toString();\n fcmEvent.package_name = self.origin.replace(/(^\\w+:|^)\\/\\//, '');\n\n if (!!internalPayload.collapse_key) {\n fcmEvent.collapse_key = internalPayload.collapse_key;\n }\n\n fcmEvent.event = EVENT_MESSAGE_DELIVERED.toString();\n\n if (!!internalPayload.fcmOptions?.analytics_label) {\n fcmEvent.analytics_label = internalPayload.fcmOptions?.analytics_label;\n }\n\n /* eslint-enable camelcase */\n return fcmEvent;\n}\n\nfunction createAndEnqueueLogEvent(\n messaging: MessagingService,\n fcmEvent: FcmEvent,\n productId: number\n): void {\n const logEvent = {} as LogEvent;\n\n /* eslint-disable camelcase */\n logEvent.event_time_ms = Math.floor(Date.now()).toString();\n logEvent.source_extension_json_proto3 = JSON.stringify({\n messaging_client_event: fcmEvent\n });\n\n if (!!productId) {\n logEvent.compliance_data = buildComplianceData(productId);\n }\n // eslint-disable-next-line camelcase\n\n messaging.logEvents.push(logEvent);\n}\n\nfunction buildComplianceData(productId: number): ComplianceData {\n const complianceData: ComplianceData = {\n privacy_context: {\n prequest: {\n origin_associated_product_id: productId\n }\n }\n };\n\n return complianceData;\n}\n\nexport function _createLogRequest(logEventQueue: LogEvent[]): LogRequest {\n const logRequest = {} as LogRequest;\n\n /* eslint-disable camelcase */\n logRequest.log_source = FCM_LOG_SOURCE.toString();\n logRequest.log_event = logEventQueue;\n /* eslint-enable camelcase */\n\n return logRequest;\n}\n\nexport function _mergeStrings(s1: string, s2: string): string {\n const resultArray = [];\n for (let i = 0; i < s1.length; i++) {\n resultArray.push(s1.charAt(i));\n if (i < s2.length) {\n resultArray.push(s2.charAt(i));\n }\n }\n\n return resultArray.join('');\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ERROR_FACTORY, ErrorCode } from '../util/errors';\nimport { FirebaseApp, FirebaseOptions } from '@firebase/app';\n\nimport { AppConfig } from '../interfaces/app-config';\nimport { FirebaseError } from '@firebase/util';\n\nexport function extractAppConfig(app: FirebaseApp): AppConfig {\n if (!app || !app.options) {\n throw getMissingValueError('App Configuration Object');\n }\n\n if (!app.name) {\n throw getMissingValueError('App Name');\n }\n\n // Required app config keys\n const configKeys: ReadonlyArray<keyof FirebaseOptions> = [\n 'projectId',\n 'apiKey',\n 'appId',\n 'messagingSenderId'\n ];\n\n const { options } = app;\n for (const keyName of configKeys) {\n if (!options[keyName]) {\n throw getMissingValueError(keyName);\n }\n }\n\n return {\n appName: app.name,\n projectId: options.projectId!,\n apiKey: options.apiKey!,\n appId: options.appId!,\n senderId: options.messagingSenderId!\n };\n}\n\nfunction getMissingValueError(valueName: string): FirebaseError {\n return ERROR_FACTORY.create(ErrorCode.MISSING_APP_CONFIG_VALUES, {\n valueName\n });\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FirebaseApp, _FirebaseService } from '@firebase/app';\nimport { MessagePayload, NextFn, Observer } from './interfaces/public-types';\n\nimport { FirebaseAnalyticsInternalName } from '@firebase/analytics-interop-types';\nimport { FirebaseInternalDependencies } from './interfaces/internal-dependencies';\nimport { LogEvent } from './interfaces/logging-types';\nimport { Provider } from '@firebase/component';\nimport { _FirebaseInstallationsInternal } from '@firebase/installations';\nimport { extractAppConfig } from './helpers/extract-app-config';\n\nexport class MessagingService implements _FirebaseService {\n readonly app!: FirebaseApp;\n readonly firebaseDependencies!: FirebaseInternalDependencies;\n\n swRegistration?: ServiceWorkerRegistration;\n vapidKey?: string;\n // logging is only done with end user consent. Default to false.\n deliveryMetricsExportedToBigQueryEnabled: boolean = false;\n\n onBackgroundMessageHandler:\n | NextFn<MessagePayload>\n | Observer<MessagePayload>\n | null = null;\n\n onMessageHandler: NextFn<MessagePayload> | Observer<MessagePayload> | null =\n null;\n\n logEvents: LogEvent[] = [];\n isLogServiceStarted: boolean = false;\n\n constructor(\n app: FirebaseApp,\n installations: _FirebaseInstallationsInternal,\n analyticsProvider: Provider<FirebaseAnalyticsInternalName>\n ) {\n const appConfig = extractAppConfig(app);\n\n this.firebaseDependencies = {\n app,\n appConfig,\n installations,\n analyticsProvider\n };\n }\n\n _delete(): Promise<void> {\n return Promise.resolve();\n }\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n DEFAULT_REGISTRATION_TIMEOUT,\n DEFAULT_SW_PATH,\n DEFAULT_SW_SCOPE\n} from '../util/constants';\nimport { ERROR_FACTORY, ErrorCode } from '../util/errors';\n\nimport { MessagingService } from '../messaging-service';\n\nexport async function registerDefaultSw(\n messaging: MessagingService\n): Promise<void> {\n try {\n messaging.swRegistration = await navigator.serviceWorker.register(\n DEFAULT_SW_PATH,\n {\n scope: DEFAULT_SW_SCOPE\n }\n );\n\n // The timing when browser updates sw when sw has an update is unreliable from experiment. It\n // leads to version conflict when the SDK upgrades to a newer version in the main page, but sw\n // is stuck with the old version. For example,\n // https://github.com/firebase/firebase-js-sdk/issues/2590 The following line reliably updates\n // sw if there was an update.\n messaging.swRegistration.update().catch(() => {\n /* it is non blocking and we don't care if it failed */\n });\n await waitForRegistrationActive(messaging.swRegistration);\n } catch (e) {\n throw ERROR_FACTORY.create(ErrorCode.FAILED_DEFAULT_REGISTRATION, {\n browserErrorMessage: (e as Error)?.message\n });\n }\n}\n\n/**\n * Waits for registration to become active. MDN documentation claims that\n * a service worker registration should be ready to use after awaiting\n * navigator.serviceWorker.register() but that doesn't seem to be the case in\n * practice, causing the SDK to throw errors when calling\n * swRegistration.pushManager.subscribe() too soon after register(). The only\n * solution seems to be waiting for the service worker registration `state`\n * to become \"active\".\n */\nasync function waitForRegistrationActive(\n registration: ServiceWorkerRegistration\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n const rejectTimeout = setTimeout(\n () =>\n reject(\n new Error(\n `Service worker not registered after ${DEFAULT_REGISTRATION_TIMEOUT} ms`\n )\n ),\n DEFAULT_REGISTRATION_TIMEOUT\n );\n const incomingSw = registration.installing || registration.waiting;\n if (registration.active) {\n clearTimeout(rejectTimeout);\n resolve();\n } else if (incomingSw) {\n incomingSw.onstatechange = ev => {\n if ((ev.target as ServiceWorker)?.state === 'activated') {\n incomingSw.onstatechange = null;\n clearTimeout(rejectTimeout);\n resolve();\n }\n };\n } else {\n clearTimeout(rejectTimeout);\n reject(new Error('No incoming service worker found.'));\n }\n });\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ERROR_FACTORY, ErrorCode } from '../util/errors';\n\nimport { MessagingService } from '../messaging-service';\nimport { registerDefaultSw } from './registerDefaultSw';\n\nexport async function updateSwReg(\n messaging: MessagingService,\n swRegistration?: ServiceWorkerRegistration | undefined\n): Promise<void> {\n if (!swRegistration && !messaging.swRegistration) {\n await registerDefaultSw(messaging);\n }\n\n if (!swRegistration && !!messaging.swRegistration) {\n return;\n }\n\n if (!(swRegistration instanceof ServiceWorkerRegistration)) {\n throw ERROR_FACTORY.create(ErrorCode.INVALID_SW_REGISTRATION);\n }\n\n messaging.swRegistration = swRegistration;\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DEFAULT_VAPID_KEY } from '../util/constants';\nimport { MessagingService } from '../messaging-service';\n\nexport async function updateVapidKey(\n messaging: MessagingService,\n vapidKey?: string | undefined\n): Promise<void> {\n if (!!vapidKey) {\n messaging.vapidKey = vapidKey;\n } else if (!messaging.vapidKey) {\n messaging.vapidKey = DEFAULT_VAPID_KEY;\n }\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ERROR_FACTORY, ErrorCode } from '../util/errors';\n\nimport { MessagingService } from '../messaging-service';\nimport { getTokenInternal } from '../internals/token-manager';\nimport { updateSwReg } from '../helpers/updateSwReg';\nimport { updateVapidKey } from '../helpers/updateVapidKey';\nimport { GetTokenOptions } from '../interfaces/public-types';\n\nexport async function getToken(\n messaging: MessagingService,\n options?: GetTokenOptions\n): Promise<string> {\n if (!navigator) {\n throw ERROR_FACTORY.create(ErrorCode.AVAILABLE_IN_WINDOW);\n }\n\n if (Notification.permission === 'default') {\n await Notification.requestPermission();\n }\n\n if (Notification.permission !== 'granted') {\n throw ERROR_FACTORY.create(ErrorCode.PERMISSION_BLOCKED);\n }\n\n await updateVapidKey(messaging, options?.vapidKey);\n await updateSwReg(messaging, options?.serviceWorkerRegistration);\n\n return getTokenInternal(messaging);\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n CONSOLE_CAMPAIGN_ID,\n CONSOLE_CAMPAIGN_NAME,\n CONSOLE_CAMPAIGN_TIME\n} from '../util/constants';\nimport {\n ConsoleMessageData,\n MessageType\n} from '../interfaces/internal-message-payload';\n\nimport { MessagingService } from '../messaging-service';\n\nexport async function logToScion(\n messaging: MessagingService,\n messageType: MessageType,\n data: ConsoleMessageData\n): Promise<void> {\n const eventType = getEventType(messageType);\n const analytics =\n await messaging.firebaseDependencies.analyticsProvider.get();\n analytics.logEvent(eventType, {\n /* eslint-disable camelcase */\n message_id: data[CONSOLE_CAMPAIGN_ID],\n message_name: data[CONSOLE_CAMPAIGN_NAME],\n message_time: data[CONSOLE_CAMPAIGN_TIME],\n message_device_time: Math.floor(Date.now() / 1000)\n /* eslint-enable camelcase */\n });\n}\n\nfunction getEventType(messageType: MessageType): string {\n switch (messageType) {\n case MessageType.NOTIFICATION_CLICKED:\n return 'notification_open';\n case MessageType.PUSH_RECEIVED:\n return 'notification_foreground';\n default:\n throw new Error();\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n MessagePayloadInternal,\n MessageType\n} from '../interfaces/internal-message-payload';\n\nimport { CONSOLE_CAMPAIGN_ANALYTICS_ENABLED } from '../util/constants';\nimport { MessagingService } from '../messaging-service';\nimport { externalizePayload } from '../helpers/externalizePayload';\nimport { isConsoleMessage } from '../helpers/is-console-message';\nimport { logToScion } from '../helpers/logToScion';\n\nexport async function messageEventListener(\n messaging: MessagingService,\n event: MessageEvent\n): Promise<void> {\n const internalPayload = event.data as MessagePayloadInternal;\n\n if (!internalPayload.isFirebaseMessaging) {\n return;\n }\n\n if (\n messaging.onMessageHandler &&\n internalPayload.messageType === MessageType.PUSH_RECEIVED\n ) {\n if (typeof messaging.onMessageHandler === 'function') {\n messaging.onMessageHandler(externalizePayload(internalPayload));\n } else {\n messaging.onMessageHandler.next(externalizePayload(internalPayload));\n }\n }\n\n // Log to Scion if applicable\n const dataPayload = internalPayload.data;\n if (\n isConsoleMessage(dataPayload) &&\n dataPayload[CONSOLE_CAMPAIGN_ANALYTICS_ENABLED] === '1'\n ) {\n await logToScion(messaging, internalPayload.messageType!, dataPayload);\n }\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Component,\n ComponentContainer,\n ComponentType,\n InstanceFactory\n} from '@firebase/component';\nimport {\n onNotificationClick,\n onPush,\n onSubChange\n} from '../listeners/sw-listeners';\n\nimport { GetTokenOptions } from '../interfaces/public-types';\nimport { MessagingInternal } from '@firebase/messaging-interop-types';\nimport { MessagingService } from '../messaging-service';\nimport { ServiceWorkerGlobalScope } from '../util/sw-types';\nimport { _registerComponent, registerVersion } from '@firebase/app';\nimport { getToken } from '../api/getToken';\nimport { messageEventListener } from '../listeners/window-listener';\n\nimport { name, version } from '../../package.json';\n\nconst WindowMessagingFactory: InstanceFactory<'messaging'> = (\n container: ComponentContainer\n) => {\n const messaging = new MessagingService(\n container.getProvider('app').getImmediate(),\n container.getProvider('installations-internal').getImmediate(),\n container.getProvider('analytics-internal')\n );\n\n navigator.serviceWorker.addEventListener('message', e =>\n messageEventListener(messaging as MessagingService, e)\n );\n\n return messaging;\n};\n\nconst WindowMessagingInternalFactory: InstanceFactory<'messaging-internal'> = (\n container: ComponentContainer\n) => {\n const messaging = container\n .getProvider('messaging')\n .getImmediate() as MessagingService;\n\n const messagingInternal: MessagingInternal = {\n getToken: (options?: GetTokenOptions) => getToken(messaging, options)\n };\n\n return messagingInternal;\n};\n\ndeclare const self: ServiceWorkerGlobalScope;\nconst SwMessagingFactory: InstanceFactory<'messaging'> = (\n container: ComponentContainer\n) => {\n const messaging = new MessagingService(\n container.getProvider('app').getImmediate(),\n container.getProvider('installations-internal').getImmediate(),\n container.getProvider('analytics-internal')\n );\n\n self.addEventListener('push', e => {\n e.waitUntil(onPush(e, messaging as MessagingService));\n });\n self.addEventListener('pushsubscriptionchange', e => {\n e.waitUntil(onSubChange(e, messaging as MessagingService));\n });\n self.addEventListener('notificationclick', e => {\n e.waitUntil(onNotificationClick(e));\n });\n\n return messaging;\n};\n\nexport function registerMessagingInWindow(): void {\n _registerComponent(\n new Component('messaging', WindowMessagingFactory, ComponentType.PUBLIC)\n );\n\n _registerComponent(\n new Component(\n 'messaging-internal',\n WindowMessagingInternalFactory,\n ComponentType.PRIVATE\n )\n );\n\n registerVersion(name, version);\n // BUILD_TARGET will be replaced by values like esm, cjs, etc during the compilation\n registerVersion(name, version, '__BUILD_TARGET__');\n}\n\n/**\n * The messaging instance registered in sw is named differently than that of in client. This is\n * because both `registerMessagingInWindow` and `registerMessagingInSw` would be called in\n * `messaging-compat` and component with the same name can only be registered once.\n */\nexport function registerMessagingInSw(): void {\n _registerComponent(\n new Component('messaging-sw', SwMessagingFactory, ComponentType.PUBLIC)\n );\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n areCookiesEnabled,\n isIndexedDBAvailable,\n validateIndexedDBOpenable\n} from '@firebase/util';\n\n/**\n * Checks if all required APIs exist in the browser.\n * @returns a Promise that resolves to a boolean.\n *\n * @public\n */\nexport async function isWindowSupported(): Promise<boolean> {\n try {\n // This throws if open() is unsupported, so adding it to the conditional\n // statement below can cause an uncaught error.\n await validateIndexedDBOpenable();\n } catch (e) {\n return false;\n }\n // firebase-js-sdk/issues/2393 reveals that idb#open in Safari iframe and Firefox private browsing\n // might be prohibited to run. In these contexts, an error would be thrown during the messaging\n // instantiating phase, informing the developers to import/call isSupported for special handling.\n return (\n typeof window !== 'undefined' &&\n isIndexedDBAvailable() &&\n areCookiesEnabled() &&\n 'serviceWorker' in navigator &&\n 'PushManager' in window &&\n 'Notification' in window &&\n 'fetch' in window &&\n ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&\n PushSubscription.prototype.hasOwnProperty('getKey')\n );\n}\n\n/**\n * Checks whether all required APIs exist within SW Context\n * @returns a Promise that resolves to a boolean.\n *\n * @public\n */\nexport async function isSwSupported(): Promise<boolean> {\n // firebase-js-sdk/issues/2393 reveals that idb#open in Safari iframe and Firefox private browsing\n // might be prohibited to run. In these contexts, an error would be thrown during the messaging\n // instantiating phase, informing the developers to import/call isSupported for special handling.\n return (\n isIndexedDBAvailable() &&\n (await validateIndexedDBOpenable()) &&\n 'PushManager' in self &&\n 'Notification' in self &&\n ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&\n PushSubscription.prototype.hasOwnProperty('getKey')\n );\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ERROR_FACTORY, ErrorCode } from '../util/errors';\n\nimport { MessagingService } from '../messaging-service';\nimport { deleteTokenInternal } from '../internals/token-manager';\nimport { registerDefaultSw } from '../helpers/registerDefaultSw';\n\nexport async function deleteToken(\n messaging: MessagingService\n): Promise<boolean> {\n if (!navigator) {\n throw ERROR_FACTORY.create(ErrorCode.AVAILABLE_IN_WINDOW);\n }\n\n if (!messaging.swRegistration) {\n await registerDefaultSw(messaging);\n }\n\n return deleteTokenInternal(messaging);\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ERROR_FACTORY, ErrorCode } from '../util/errors';\n\nimport {\n MessagePayload,\n NextFn,\n Observer,\n Unsubscribe\n} from '../interfaces/public-types';\nimport { MessagingService } from '../messaging-service';\n\nexport function onMessage(\n messaging: MessagingService,\n nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>\n): Unsubscribe {\n if (!navigator) {\n throw ERROR_FACTORY.create(ErrorCode.AVAILABLE_IN_WINDOW);\n }\n\n messaging.onMessageHandler = nextOrObserver;\n\n return () => {\n messaging.onMessageHandler = null;\n };\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ERROR_FACTORY, ErrorCode } from './util/errors';\nimport { FirebaseApp, _getProvider, getApp } from '@firebase/app';\nimport {\n GetTokenOptions,\n MessagePayload,\n Messaging\n} from './interfaces/public-types';\nimport {\n NextFn,\n Observer,\n Unsubscribe,\n getModularInstance\n} from '@firebase/util';\nimport { isSwSupported, isWindowSupported } from './api/isSupported';\n\nimport { MessagingService } from './messaging-service';\nimport { deleteToken as _deleteToken } from './api/deleteToken';\nimport { getToken as _getToken } from './api/getToken';\nimport { onBackgroundMessage as _onBackgroundMessage } from './api/onBackgroundMessage';\nimport { onMessage as _onMessage } from './api/onMessage';\nimport { _setDeliveryMetricsExportedToBigQueryEnabled } from './api/setDeliveryMetricsExportedToBigQueryEnabled';\n\n/**\n * Retrieves a Firebase Cloud Messaging instance.\n *\n * @returns The Firebase Cloud Messaging instance associated with the provided firebase app.\n *\n * @public\n */\nexport function getMessagingInWindow(app: FirebaseApp = getApp()): Messaging {\n // Conscious decision to make this async check non-blocking during the messaging instance\n // initialization phase for performance consideration. An error would be thrown latter for\n // developer's information. Developers can then choose to import and call `isSupported` for\n // special handling.\n isWindowSupported().then(\n isSupported => {\n // If `isWindowSupported()` resolved, but returned false.\n if (!isSupported) {\n throw ERROR_FACTORY.create(ErrorCode.UNSUPPORTED_BROWSER);\n }\n },\n _ => {\n // If `isWindowSupported()` rejected.\n throw ERROR_FACTORY.create(ErrorCode.INDEXED_DB_UNSUPPORTED);\n }\n );\n return _getProvider(getModularInstance(app), 'messaging').getImmediate();\n}\n\n/**\n * Retrieves a Firebase Cloud Messaging instance.\n *\n * @returns The Firebase Cloud Messaging instance associated with the provided firebase app.\n *\n * @public\n */\nexport function getMessagingInSw(app: FirebaseApp = getApp()): Messaging {\n // Conscious decision to make this async check non-blocking during the messaging instance\n // initialization phase for performance consideration. An error would be thrown latter for\n // developer's information. Developers can then choose to import and call `isSupported` for\n // special handling.\n isSwSupported().then(\n isSupported => {\n // If `isSwSupported()` resolved, but returned false.\n if (!isSupported) {\n throw ERROR_FACTORY.create(ErrorCode.UNSUPPORTED_BROWSER);\n }\n },\n _ => {\n // If `isSwSupported()` rejected.\n throw ERROR_FACTORY.create(ErrorCode.INDEXED_DB_UNSUPPORTED);\n }\n );\n return _getProvider(getModularInstance(app), 'messaging-sw').getImmediate();\n}\n\n/**\n * Subscribes the {@link Messaging} instance to push notifications. Returns a Firebase Cloud\n * Messaging registration token that can be used to send push messages to that {@link Messaging}\n * instance.\n *\n * If notification permission isn't already granted, this method asks the user for permission. The\n * returned promise rejects if the user does not allow the app to show notifications.\n *\n * @param messaging - The {@link Messaging} instance.\n * @param options - Provides an optional vapid key and an optional service worker registration.\n *\n * @returns The promise resolves with an FCM registration token.\n *\n * @public\n */\nexport async function getToken(\n messaging: Messaging,\n options?: GetTokenOptions\n): Promise<string> {\n messaging = getModularInstance(messaging);\n return _getToken(messaging as MessagingService, options);\n}\n\n/**\n * Deletes the registration token associated with this {@link Messaging} instance and unsubscribes\n * the {@link Messaging} instance from the push subscription.\n *\n * @param messaging - The {@link Messaging} instance.\n *\n * @returns The promise resolves when the token has been successfully deleted.\n *\n * @public\n */\nexport function deleteToken(messaging: Messaging): Promise<boolean> {\n messaging = getModularInstance(messaging);\n return _deleteToken(messaging as MessagingService);\n}\n\n/**\n * When a push message is received and the user is currently on a page for your origin, the\n * message is passed to the page and an `onMessage()` event is dispatched with the payload of\n * the push message.\n *\n *\n * @param messaging - The {@link Messaging} instance.\n * @param nextOrObserver - This function, or observer object with `next` defined,\n * is called when a message is received and the user is currently viewing your page.\n * @returns To stop listening for messages execute this returned function.\n *\n * @public\n */\nexport function onMessage(\n messaging: Messaging,\n nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>\n): Unsubscribe {\n messaging = getModularInstance(messaging);\n return _onMessage(messaging as MessagingService, nextOrObserver);\n}\n\n/**\n * Called when a message is received while the app is in the background. An app is considered to be\n * in the background if no active window is displayed.\n *\n * @param messaging - The {@link Messaging} instance.\n * @param nextOrObserver - This function, or observer object with `next` defined, is called when a\n * message is received and the app is currently in the background.\n *\n * @returns To stop listening for messages execute this returned function\n *\n * @public\n */\nexport function onBackgroundMessage(\n messaging: Messaging,\n nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>\n): Unsubscribe {\n messaging = getModularInstance(messaging);\n return _onBackgroundMessage(messaging as MessagingService, nextOrObserver);\n}\n\n/**\n * Enables or disables Firebase Cloud Messaging message delivery metrics export to BigQuery. By\n * default, message delivery metrics are not exported to BigQuery. Use this method to enable or\n * disable the export at runtime.\n *\n * @param messaging - The `FirebaseMessaging` instance.\n * @param enable - Whether Firebase Cloud Messaging should export message delivery metrics to\n * BigQuery.\n *\n * @public\n */\nexport function experimentalSetDeliveryMetricsExportedToBigQueryEnabled(\n messaging: Messaging,\n enable: boolean\n): void {\n messaging = getModularInstance(messaging);\n return _setDeliveryMetricsExportedToBigQueryEnabled(messaging, enable);\n}\n","/**\n * The Firebase Cloud Messaging Web SDK.\n * This SDK does not work in a Node.js environment.\n *\n * @packageDocumentation\n */\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport '@firebase/installations';\n\nimport { Messaging } from './interfaces/public-types';\nimport { registerMessagingInWindow } from './helpers/register';\n\nexport {\n getToken,\n deleteToken,\n onMessage,\n getMessagingInWindow as getMessaging\n} from './api';\nexport { isWindowSupported as isSupported } from './api/isSupported';\nexport * from './interfaces/public-types';\n\ndeclare module '@firebase/component' {\n interface NameServiceMapping {\n 'messaging': Messaging;\n }\n}\n\nregisterMessagingInWindow();\n"],"names":["MessageType","getToken","deleteToken","onMessage","_getToken","_deleteToken","_onMessage"],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAEI,MAAM,eAAe,GAAG,2BAA2B,CAAC;AACpD,MAAM,gBAAgB,GAAG,sCAAsC,CAAC;AAEhE,MAAM,iBAAiB,GAC5B,yFAAyF,CAAC;A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CAAC,CAAC;AAC1C,IAAA,OAAOC,UAAS,CAAC,SAA6B,EAAE,OAAO,CAAC,CAAC;AAC3D,CAAC;AAED;;;;;;;;;AASG;AACG,SAAU,WAAW,CAAC,SAAoB,EAAA;AAC9C,IAAA,SAAS,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;AAC1C,IAAA,OAAOC,aAAY,CAAC,SAA6B,CAAC,CAAC;AACrD,CAAC;AAED;;;;;;;;;;;;AAYG;AACa,SAAA,SAAS,CACvB,SAAoB,EACpB,cAAiE,EAAA;AAEjE,IAAA,SAAS,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;AAC1C,IAAA,OAAOC,WAAU,CAAC,SAA6B,EAAE,cAAc,CAAC,CAAC;AACnE;;ACtJA;;;;;AAKG;AAuCH,yBAAyB,EAAE;;;;"} \ No newline at end of file
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/index.sw.esm.js b/frontend-old/node_modules/@firebase/messaging/dist/esm/index.sw.esm.js
new file mode 100644
index 0000000..3d358e6
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/index.sw.esm.js
@@ -0,0 +1,1278 @@
+import '@firebase/installations';
+import { Component } from '@firebase/component';
+import { openDB, deleteDB } from 'idb';
+import { ErrorFactory, isIndexedDBAvailable, validateIndexedDBOpenable, getModularInstance } from '@firebase/util';
+import { _registerComponent, _getProvider, getApp } from '@firebase/app';
+
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+const DEFAULT_VAPID_KEY = 'BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4';
+const ENDPOINT = 'https://fcmregistrations.googleapis.com/v1';
+/** Key of FCM Payload in Notification's data field. */
+const FCM_MSG = 'FCM_MSG';
+const CONSOLE_CAMPAIGN_ID = 'google.c.a.c_id';
+// Defined as in proto/messaging_event.proto. Neglecting fields that are supported.
+const SDK_PLATFORM_WEB = 3;
+const EVENT_MESSAGE_DELIVERED = 1;
+var MessageType$1;
+(function (MessageType) {
+ MessageType[MessageType["DATA_MESSAGE"] = 1] = "DATA_MESSAGE";
+ MessageType[MessageType["DISPLAY_NOTIFICATION"] = 3] = "DISPLAY_NOTIFICATION";
+})(MessageType$1 || (MessageType$1 = {}));
+
+/**
+ * @license
+ * Copyright 2018 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+var MessageType;
+(function (MessageType) {
+ MessageType["PUSH_RECEIVED"] = "push-received";
+ MessageType["NOTIFICATION_CLICKED"] = "notification-clicked";
+})(MessageType || (MessageType = {}));
+
+/**
+ * @license
+ * Copyright 2017 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+function arrayToBase64(array) {
+ const uint8Array = new Uint8Array(array);
+ const base64String = btoa(String.fromCharCode(...uint8Array));
+ return base64String.replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
+}
+function base64ToArray(base64String) {
+ const padding = '='.repeat((4 - (base64String.length % 4)) % 4);
+ const base64 = (base64String + padding)
+ .replace(/\-/g, '+')
+ .replace(/_/g, '/');
+ const rawData = atob(base64);
+ const outputArray = new Uint8Array(rawData.length);
+ for (let i = 0; i < rawData.length; ++i) {
+ outputArray[i] = rawData.charCodeAt(i);
+ }
+ return outputArray;
+}
+
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+const OLD_DB_NAME = 'fcm_token_details_db';
+/**
+ * The last DB version of 'fcm_token_details_db' was 4. This is one higher, so that the upgrade
+ * callback is called for all versions of the old DB.
+ */
+const OLD_DB_VERSION = 5;
+const OLD_OBJECT_STORE_NAME = 'fcm_token_object_Store';
+async function migrateOldDatabase(senderId) {
+ if ('databases' in indexedDB) {
+ // indexedDb.databases() is an IndexedDB v3 API and does not exist in all browsers. TODO: Remove
+ // typecast when it lands in TS types.
+ const databases = await indexedDB.databases();
+ const dbNames = databases.map(db => db.name);
+ if (!dbNames.includes(OLD_DB_NAME)) {
+ // old DB didn't exist, no need to open.
+ return null;
+ }
+ }
+ let tokenDetails = null;
+ const db = await openDB(OLD_DB_NAME, OLD_DB_VERSION, {
+ upgrade: async (db, oldVersion, newVersion, upgradeTransaction) => {
+ if (oldVersion < 2) {
+ // Database too old, skip migration.
+ return;
+ }
+ if (!db.objectStoreNames.contains(OLD_OBJECT_STORE_NAME)) {
+ // Database did not exist. Nothing to do.
+ return;
+ }
+ const objectStore = upgradeTransaction.objectStore(OLD_OBJECT_STORE_NAME);
+ const value = await objectStore.index('fcmSenderId').get(senderId);
+ await objectStore.clear();
+ if (!value) {
+ // No entry in the database, nothing to migrate.
+ return;
+ }
+ if (oldVersion === 2) {
+ const oldDetails = value;
+ if (!oldDetails.auth || !oldDetails.p256dh || !oldDetails.endpoint) {
+ return;
+ }
+ tokenDetails = {
+ token: oldDetails.fcmToken,
+ createTime: oldDetails.createTime ?? Date.now(),
+ subscriptionOptions: {
+ auth: oldDetails.auth,
+ p256dh: oldDetails.p256dh,
+ endpoint: oldDetails.endpoint,
+ swScope: oldDetails.swScope,
+ vapidKey: typeof oldDetails.vapidKey === 'string'
+ ? oldDetails.vapidKey
+ : arrayToBase64(oldDetails.vapidKey)
+ }
+ };
+ }
+ else if (oldVersion === 3) {
+ const oldDetails = value;
+ tokenDetails = {
+ token: oldDetails.fcmToken,
+ createTime: oldDetails.createTime,
+ subscriptionOptions: {
+ auth: arrayToBase64(oldDetails.auth),
+ p256dh: arrayToBase64(oldDetails.p256dh),
+ endpoint: oldDetails.endpoint,
+ swScope: oldDetails.swScope,
+ vapidKey: arrayToBase64(oldDetails.vapidKey)
+ }
+ };
+ }
+ else if (oldVersion === 4) {
+ const oldDetails = value;
+ tokenDetails = {
+ token: oldDetails.fcmToken,
+ createTime: oldDetails.createTime,
+ subscriptionOptions: {
+ auth: arrayToBase64(oldDetails.auth),
+ p256dh: arrayToBase64(oldDetails.p256dh),
+ endpoint: oldDetails.endpoint,
+ swScope: oldDetails.swScope,
+ vapidKey: arrayToBase64(oldDetails.vapidKey)
+ }
+ };
+ }
+ }
+ });
+ db.close();
+ // Delete all old databases.
+ await deleteDB(OLD_DB_NAME);
+ await deleteDB('fcm_vapid_details_db');
+ await deleteDB('undefined');
+ return checkTokenDetails(tokenDetails) ? tokenDetails : null;
+}
+function checkTokenDetails(tokenDetails) {
+ if (!tokenDetails || !tokenDetails.subscriptionOptions) {
+ return false;
+ }
+ const { subscriptionOptions } = tokenDetails;
+ 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);
+}
+
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// Exported for tests.
+const DATABASE_NAME = 'firebase-messaging-database';
+const DATABASE_VERSION = 1;
+const OBJECT_STORE_NAME = 'firebase-messaging-store';
+let dbPromise = null;
+function getDbPromise() {
+ if (!dbPromise) {
+ dbPromise = openDB(DATABASE_NAME, DATABASE_VERSION, {
+ upgrade: (upgradeDb, oldVersion) => {
+ // We don't use 'break' in this switch statement, the fall-through behavior is what we want,
+ // because if there are multiple versions between the old version and the current version, we
+ // want ALL the migrations that correspond to those versions to run, not only the last one.
+ // eslint-disable-next-line default-case
+ switch (oldVersion) {
+ case 0:
+ upgradeDb.createObjectStore(OBJECT_STORE_NAME);
+ }
+ }
+ });
+ }
+ return dbPromise;
+}
+/** Gets record(s) from the objectStore that match the given key. */
+async function dbGet(firebaseDependencies) {
+ const key = getKey(firebaseDependencies);
+ const db = await getDbPromise();
+ const tokenDetails = (await db
+ .transaction(OBJECT_STORE_NAME)
+ .objectStore(OBJECT_STORE_NAME)
+ .get(key));
+ if (tokenDetails) {
+ return tokenDetails;
+ }
+ else {
+ // Check if there is a tokenDetails object in the old DB.
+ const oldTokenDetails = await migrateOldDatabase(firebaseDependencies.appConfig.senderId);
+ if (oldTokenDetails) {
+ await dbSet(firebaseDependencies, oldTokenDetails);
+ return oldTokenDetails;
+ }
+ }
+}
+/** Assigns or overwrites the record for the given key with the given value. */
+async function dbSet(firebaseDependencies, tokenDetails) {
+ const key = getKey(firebaseDependencies);
+ const db = await getDbPromise();
+ const tx = db.transaction(OBJECT_STORE_NAME, 'readwrite');
+ await tx.objectStore(OBJECT_STORE_NAME).put(tokenDetails, key);
+ await tx.done;
+ return tokenDetails;
+}
+/** Removes record(s) from the objectStore that match the given key. */
+async function dbRemove(firebaseDependencies) {
+ const key = getKey(firebaseDependencies);
+ const db = await getDbPromise();
+ const tx = db.transaction(OBJECT_STORE_NAME, 'readwrite');
+ await tx.objectStore(OBJECT_STORE_NAME).delete(key);
+ await tx.done;
+}
+function getKey({ appConfig }) {
+ return appConfig.appId;
+}
+
+/**
+ * @license
+ * Copyright 2017 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+const ERROR_MAP = {
+ ["missing-app-config-values" /* ErrorCode.MISSING_APP_CONFIG_VALUES */]: 'Missing App configuration value: "{$valueName}"',
+ ["only-available-in-window" /* ErrorCode.AVAILABLE_IN_WINDOW */]: 'This method is available in a Window context.',
+ ["only-available-in-sw" /* ErrorCode.AVAILABLE_IN_SW */]: 'This method is available in a service worker context.',
+ ["permission-default" /* ErrorCode.PERMISSION_DEFAULT */]: 'The notification permission was not granted and dismissed instead.',
+ ["permission-blocked" /* ErrorCode.PERMISSION_BLOCKED */]: 'The notification permission was not granted and blocked instead.',
+ ["unsupported-browser" /* ErrorCode.UNSUPPORTED_BROWSER */]: "This browser doesn't support the API's required to use the Firebase SDK.",
+ ["indexed-db-unsupported" /* ErrorCode.INDEXED_DB_UNSUPPORTED */]: "This browser doesn't support indexedDb.open() (ex. Safari iFrame, Firefox Private Browsing, etc)",
+ ["failed-service-worker-registration" /* ErrorCode.FAILED_DEFAULT_REGISTRATION */]: 'We are unable to register the default service worker. {$browserErrorMessage}',
+ ["token-subscribe-failed" /* ErrorCode.TOKEN_SUBSCRIBE_FAILED */]: 'A problem occurred while subscribing the user to FCM: {$errorInfo}',
+ ["token-subscribe-no-token" /* ErrorCode.TOKEN_SUBSCRIBE_NO_TOKEN */]: 'FCM returned no token when subscribing the user to push.',
+ ["token-unsubscribe-failed" /* ErrorCode.TOKEN_UNSUBSCRIBE_FAILED */]: 'A problem occurred while unsubscribing the ' +
+ 'user from FCM: {$errorInfo}',
+ ["token-update-failed" /* ErrorCode.TOKEN_UPDATE_FAILED */]: 'A problem occurred while updating the user from FCM: {$errorInfo}',
+ ["token-update-no-token" /* ErrorCode.TOKEN_UPDATE_NO_TOKEN */]: 'FCM returned no token when updating the user to push.',
+ ["use-sw-after-get-token" /* ErrorCode.USE_SW_AFTER_GET_TOKEN */]: 'The useServiceWorker() method may only be called once and must be ' +
+ 'called before calling getToken() to ensure your service worker is used.',
+ ["invalid-sw-registration" /* ErrorCode.INVALID_SW_REGISTRATION */]: 'The input to useServiceWorker() must be a ServiceWorkerRegistration.',
+ ["invalid-bg-handler" /* ErrorCode.INVALID_BG_HANDLER */]: 'The input to setBackgroundMessageHandler() must be a function.',
+ ["invalid-vapid-key" /* ErrorCode.INVALID_VAPID_KEY */]: 'The public VAPID key must be a string.',
+ ["use-vapid-key-after-get-token" /* ErrorCode.USE_VAPID_KEY_AFTER_GET_TOKEN */]: 'The usePublicVapidKey() method may only be called once and must be ' +
+ 'called before calling getToken() to ensure your VAPID key is used.'
+};
+const ERROR_FACTORY = new ErrorFactory('messaging', 'Messaging', ERROR_MAP);
+
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+async function requestGetToken(firebaseDependencies, subscriptionOptions) {
+ const headers = await getHeaders(firebaseDependencies);
+ const body = getBody(subscriptionOptions);
+ const subscribeOptions = {
+ method: 'POST',
+ headers,
+ body: JSON.stringify(body)
+ };
+ let responseData;
+ try {
+ const response = await fetch(getEndpoint(firebaseDependencies.appConfig), subscribeOptions);
+ responseData = await response.json();
+ }
+ catch (err) {
+ throw ERROR_FACTORY.create("token-subscribe-failed" /* ErrorCode.TOKEN_SUBSCRIBE_FAILED */, {
+ errorInfo: err?.toString()
+ });
+ }
+ if (responseData.error) {
+ const message = responseData.error.message;
+ throw ERROR_FACTORY.create("token-subscribe-failed" /* ErrorCode.TOKEN_SUBSCRIBE_FAILED */, {
+ errorInfo: message
+ });
+ }
+ if (!responseData.token) {
+ throw ERROR_FACTORY.create("token-subscribe-no-token" /* ErrorCode.TOKEN_SUBSCRIBE_NO_TOKEN */);
+ }
+ return responseData.token;
+}
+async function requestUpdateToken(firebaseDependencies, tokenDetails) {
+ const headers = await getHeaders(firebaseDependencies);
+ const body = getBody(tokenDetails.subscriptionOptions);
+ const updateOptions = {
+ method: 'PATCH',
+ headers,
+ body: JSON.stringify(body)
+ };
+ let responseData;
+ try {
+ const response = await fetch(`${getEndpoint(firebaseDependencies.appConfig)}/${tokenDetails.token}`, updateOptions);
+ responseData = await response.json();
+ }
+ catch (err) {
+ throw ERROR_FACTORY.create("token-update-failed" /* ErrorCode.TOKEN_UPDATE_FAILED */, {
+ errorInfo: err?.toString()
+ });
+ }
+ if (responseData.error) {
+ const message = responseData.error.message;
+ throw ERROR_FACTORY.create("token-update-failed" /* ErrorCode.TOKEN_UPDATE_FAILED */, {
+ errorInfo: message
+ });
+ }
+ if (!responseData.token) {
+ throw ERROR_FACTORY.create("token-update-no-token" /* ErrorCode.TOKEN_UPDATE_NO_TOKEN */);
+ }
+ return responseData.token;
+}
+async function requestDeleteToken(firebaseDependencies, token) {
+ const headers = await getHeaders(firebaseDependencies);
+ const unsubscribeOptions = {
+ method: 'DELETE',
+ headers
+ };
+ try {
+ const response = await fetch(`${getEndpoint(firebaseDependencies.appConfig)}/${token}`, unsubscribeOptions);
+ const responseData = await response.json();
+ if (responseData.error) {
+ const message = responseData.error.message;
+ throw ERROR_FACTORY.create("token-unsubscribe-failed" /* ErrorCode.TOKEN_UNSUBSCRIBE_FAILED */, {
+ errorInfo: message
+ });
+ }
+ }
+ catch (err) {
+ throw ERROR_FACTORY.create("token-unsubscribe-failed" /* ErrorCode.TOKEN_UNSUBSCRIBE_FAILED */, {
+ errorInfo: err?.toString()
+ });
+ }
+}
+function getEndpoint({ projectId }) {
+ return `${ENDPOINT}/projects/${projectId}/registrations`;
+}
+async function getHeaders({ appConfig, installations }) {
+ const authToken = await installations.getToken();
+ return new Headers({
+ 'Content-Type': 'application/json',
+ Accept: 'application/json',
+ 'x-goog-api-key': appConfig.apiKey,
+ 'x-goog-firebase-installations-auth': `FIS ${authToken}`
+ });
+}
+function getBody({ p256dh, auth, endpoint, vapidKey }) {
+ const body = {
+ web: {
+ endpoint,
+ auth,
+ p256dh
+ }
+ };
+ if (vapidKey !== DEFAULT_VAPID_KEY) {
+ body.web.applicationPubKey = vapidKey;
+ }
+ return body;
+}
+
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// UpdateRegistration will be called once every week.
+const TOKEN_EXPIRATION_MS = 7 * 24 * 60 * 60 * 1000; // 7 days
+async function getTokenInternal(messaging) {
+ const pushSubscription = await getPushSubscription(messaging.swRegistration, messaging.vapidKey);
+ const subscriptionOptions = {
+ vapidKey: messaging.vapidKey,
+ swScope: messaging.swRegistration.scope,
+ endpoint: pushSubscription.endpoint,
+ auth: arrayToBase64(pushSubscription.getKey('auth')),
+ p256dh: arrayToBase64(pushSubscription.getKey('p256dh'))
+ };
+ const tokenDetails = await dbGet(messaging.firebaseDependencies);
+ if (!tokenDetails) {
+ // No token, get a new one.
+ return getNewToken(messaging.firebaseDependencies, subscriptionOptions);
+ }
+ else if (!isTokenValid(tokenDetails.subscriptionOptions, subscriptionOptions)) {
+ // Invalid token, get a new one.
+ try {
+ await requestDeleteToken(messaging.firebaseDependencies, tokenDetails.token);
+ }
+ catch (e) {
+ // Suppress errors because of #2364
+ console.warn(e);
+ }
+ return getNewToken(messaging.firebaseDependencies, subscriptionOptions);
+ }
+ else if (Date.now() >= tokenDetails.createTime + TOKEN_EXPIRATION_MS) {
+ // Weekly token refresh
+ return updateToken(messaging, {
+ token: tokenDetails.token,
+ createTime: Date.now(),
+ subscriptionOptions
+ });
+ }
+ else {
+ // Valid token, nothing to do.
+ return tokenDetails.token;
+ }
+}
+/**
+ * This method deletes the token from the database, unsubscribes the token from FCM, and unregisters
+ * the push subscription if it exists.
+ */
+async function deleteTokenInternal(messaging) {
+ const tokenDetails = await dbGet(messaging.firebaseDependencies);
+ if (tokenDetails) {
+ await requestDeleteToken(messaging.firebaseDependencies, tokenDetails.token);
+ await dbRemove(messaging.firebaseDependencies);
+ }
+ // Unsubscribe from the push subscription.
+ const pushSubscription = await messaging.swRegistration.pushManager.getSubscription();
+ if (pushSubscription) {
+ return pushSubscription.unsubscribe();
+ }
+ // If there's no SW, consider it a success.
+ return true;
+}
+async function updateToken(messaging, tokenDetails) {
+ try {
+ const updatedToken = await requestUpdateToken(messaging.firebaseDependencies, tokenDetails);
+ const updatedTokenDetails = {
+ ...tokenDetails,
+ token: updatedToken,
+ createTime: Date.now()
+ };
+ await dbSet(messaging.firebaseDependencies, updatedTokenDetails);
+ return updatedToken;
+ }
+ catch (e) {
+ throw e;
+ }
+}
+async function getNewToken(firebaseDependencies, subscriptionOptions) {
+ const token = await requestGetToken(firebaseDependencies, subscriptionOptions);
+ const tokenDetails = {
+ token,
+ createTime: Date.now(),
+ subscriptionOptions
+ };
+ await dbSet(firebaseDependencies, tokenDetails);
+ return tokenDetails.token;
+}
+/**
+ * Gets a PushSubscription for the current user.
+ */
+async function getPushSubscription(swRegistration, vapidKey) {
+ const subscription = await swRegistration.pushManager.getSubscription();
+ if (subscription) {
+ return subscription;
+ }
+ return swRegistration.pushManager.subscribe({
+ userVisibleOnly: true,
+ // Chrome <= 75 doesn't support base64-encoded VAPID key. For backward compatibility, VAPID key
+ // submitted to pushManager#subscribe must be of type Uint8Array.
+ applicationServerKey: base64ToArray(vapidKey)
+ });
+}
+/**
+ * Checks if the saved tokenDetails object matches the configuration provided.
+ */
+function isTokenValid(dbOptions, currentOptions) {
+ const isVapidKeyEqual = currentOptions.vapidKey === dbOptions.vapidKey;
+ const isEndpointEqual = currentOptions.endpoint === dbOptions.endpoint;
+ const isAuthEqual = currentOptions.auth === dbOptions.auth;
+ const isP256dhEqual = currentOptions.p256dh === dbOptions.p256dh;
+ return isVapidKeyEqual && isEndpointEqual && isAuthEqual && isP256dhEqual;
+}
+
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+function externalizePayload(internalPayload) {
+ const payload = {
+ from: internalPayload.from,
+ // eslint-disable-next-line camelcase
+ collapseKey: internalPayload.collapse_key,
+ // eslint-disable-next-line camelcase
+ messageId: internalPayload.fcmMessageId
+ };
+ propagateNotificationPayload(payload, internalPayload);
+ propagateDataPayload(payload, internalPayload);
+ propagateFcmOptions(payload, internalPayload);
+ return payload;
+}
+function propagateNotificationPayload(payload, messagePayloadInternal) {
+ if (!messagePayloadInternal.notification) {
+ return;
+ }
+ payload.notification = {};
+ const title = messagePayloadInternal.notification.title;
+ if (!!title) {
+ payload.notification.title = title;
+ }
+ const body = messagePayloadInternal.notification.body;
+ if (!!body) {
+ payload.notification.body = body;
+ }
+ const image = messagePayloadInternal.notification.image;
+ if (!!image) {
+ payload.notification.image = image;
+ }
+ const icon = messagePayloadInternal.notification.icon;
+ if (!!icon) {
+ payload.notification.icon = icon;
+ }
+}
+function propagateDataPayload(payload, messagePayloadInternal) {
+ if (!messagePayloadInternal.data) {
+ return;
+ }
+ payload.data = messagePayloadInternal.data;
+}
+function propagateFcmOptions(payload, messagePayloadInternal) {
+ // fcmOptions.link value is written into notification.click_action. see more in b/232072111
+ if (!messagePayloadInternal.fcmOptions &&
+ !messagePayloadInternal.notification?.click_action) {
+ return;
+ }
+ payload.fcmOptions = {};
+ const link = messagePayloadInternal.fcmOptions?.link ??
+ messagePayloadInternal.notification?.click_action;
+ if (!!link) {
+ payload.fcmOptions.link = link;
+ }
+ // eslint-disable-next-line camelcase
+ const analyticsLabel = messagePayloadInternal.fcmOptions?.analytics_label;
+ if (!!analyticsLabel) {
+ payload.fcmOptions.analyticsLabel = analyticsLabel;
+ }
+}
+
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+function isConsoleMessage(data) {
+ // This message has a campaign ID, meaning it was sent using the Firebase Console.
+ return typeof data === 'object' && !!data && CONSOLE_CAMPAIGN_ID in data;
+}
+
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/** Returns a promise that resolves after given time passes. */
+function sleep(ms) {
+ return new Promise(resolve => {
+ setTimeout(resolve, ms);
+ });
+}
+
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+_mergeStrings('AzSCbw63g1R0nCw85jG8', 'Iaya3yLKwmgvh7cF0q4');
+async function stageLog(messaging, internalPayload) {
+ const fcmEvent = createFcmEvent(internalPayload, await messaging.firebaseDependencies.installations.getId());
+ createAndEnqueueLogEvent(messaging, fcmEvent, internalPayload.productId);
+}
+function createFcmEvent(internalPayload, fid) {
+ const fcmEvent = {};
+ /* eslint-disable camelcase */
+ // some fields should always be non-null. Still check to ensure.
+ if (!!internalPayload.from) {
+ fcmEvent.project_number = internalPayload.from;
+ }
+ if (!!internalPayload.fcmMessageId) {
+ fcmEvent.message_id = internalPayload.fcmMessageId;
+ }
+ fcmEvent.instance_id = fid;
+ if (!!internalPayload.notification) {
+ fcmEvent.message_type = MessageType$1.DISPLAY_NOTIFICATION.toString();
+ }
+ else {
+ fcmEvent.message_type = MessageType$1.DATA_MESSAGE.toString();
+ }
+ fcmEvent.sdk_platform = SDK_PLATFORM_WEB.toString();
+ fcmEvent.package_name = self.origin.replace(/(^\w+:|^)\/\//, '');
+ if (!!internalPayload.collapse_key) {
+ fcmEvent.collapse_key = internalPayload.collapse_key;
+ }
+ fcmEvent.event = EVENT_MESSAGE_DELIVERED.toString();
+ if (!!internalPayload.fcmOptions?.analytics_label) {
+ fcmEvent.analytics_label = internalPayload.fcmOptions?.analytics_label;
+ }
+ /* eslint-enable camelcase */
+ return fcmEvent;
+}
+function createAndEnqueueLogEvent(messaging, fcmEvent, productId) {
+ const logEvent = {};
+ /* eslint-disable camelcase */
+ logEvent.event_time_ms = Math.floor(Date.now()).toString();
+ logEvent.source_extension_json_proto3 = JSON.stringify({
+ messaging_client_event: fcmEvent
+ });
+ if (!!productId) {
+ logEvent.compliance_data = buildComplianceData(productId);
+ }
+ // eslint-disable-next-line camelcase
+ messaging.logEvents.push(logEvent);
+}
+function buildComplianceData(productId) {
+ const complianceData = {
+ privacy_context: {
+ prequest: {
+ origin_associated_product_id: productId
+ }
+ }
+ };
+ return complianceData;
+}
+function _mergeStrings(s1, s2) {
+ const resultArray = [];
+ for (let i = 0; i < s1.length; i++) {
+ resultArray.push(s1.charAt(i));
+ if (i < s2.length) {
+ resultArray.push(s2.charAt(i));
+ }
+ }
+ return resultArray.join('');
+}
+
+/**
+ * @license
+ * Copyright 2017 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+async function onSubChange(event, messaging) {
+ const { newSubscription } = event;
+ if (!newSubscription) {
+ // Subscription revoked, delete token
+ await deleteTokenInternal(messaging);
+ return;
+ }
+ const tokenDetails = await dbGet(messaging.firebaseDependencies);
+ await deleteTokenInternal(messaging);
+ messaging.vapidKey =
+ tokenDetails?.subscriptionOptions?.vapidKey ?? DEFAULT_VAPID_KEY;
+ await getTokenInternal(messaging);
+}
+async function onPush(event, messaging) {
+ const internalPayload = getMessagePayloadInternal(event);
+ if (!internalPayload) {
+ // Failed to get parsed MessagePayload from the PushEvent. Skip handling the push.
+ return;
+ }
+ // log to Firelog with user consent
+ if (messaging.deliveryMetricsExportedToBigQueryEnabled) {
+ await stageLog(messaging, internalPayload);
+ }
+ // foreground handling: eventually passed to onMessage hook
+ const clientList = await getClientList();
+ if (hasVisibleClients(clientList)) {
+ return sendMessagePayloadInternalToWindows(clientList, internalPayload);
+ }
+ // background handling: display if possible and pass to onBackgroundMessage hook
+ if (!!internalPayload.notification) {
+ await showNotification(wrapInternalPayload(internalPayload));
+ }
+ if (!messaging) {
+ return;
+ }
+ if (!!messaging.onBackgroundMessageHandler) {
+ const payload = externalizePayload(internalPayload);
+ if (typeof messaging.onBackgroundMessageHandler === 'function') {
+ await messaging.onBackgroundMessageHandler(payload);
+ }
+ else {
+ messaging.onBackgroundMessageHandler.next(payload);
+ }
+ }
+}
+async function onNotificationClick(event) {
+ const internalPayload = event.notification?.data?.[FCM_MSG];
+ if (!internalPayload) {
+ return;
+ }
+ else if (event.action) {
+ // User clicked on an action button. This will allow developers to act on action button clicks
+ // by using a custom onNotificationClick listener that they define.
+ return;
+ }
+ // Prevent other listeners from receiving the event
+ event.stopImmediatePropagation();
+ event.notification.close();
+ // Note clicking on a notification with no link set will focus the Chrome's current tab.
+ const link = getLink(internalPayload);
+ if (!link) {
+ return;
+ }
+ // FM should only open/focus links from app's origin.
+ const url = new URL(link, self.location.href);
+ const originUrl = new URL(self.location.origin);
+ if (url.host !== originUrl.host) {
+ return;
+ }
+ let client = await getWindowClient(url);
+ if (!client) {
+ client = await self.clients.openWindow(link);
+ // Wait three seconds for the client to initialize and set up the message handler so that it
+ // can receive the message.
+ await sleep(3000);
+ }
+ else {
+ client = await client.focus();
+ }
+ if (!client) {
+ // Window Client will not be returned if it's for a third party origin.
+ return;
+ }
+ internalPayload.messageType = MessageType.NOTIFICATION_CLICKED;
+ internalPayload.isFirebaseMessaging = true;
+ return client.postMessage(internalPayload);
+}
+function wrapInternalPayload(internalPayload) {
+ const wrappedInternalPayload = {
+ ...internalPayload.notification
+ };
+ // Put the message payload under FCM_MSG name so we can identify the notification as being an FCM
+ // notification vs a notification from somewhere else (i.e. normal web push or developer generated
+ // notification).
+ wrappedInternalPayload.data = {
+ [FCM_MSG]: internalPayload
+ };
+ return wrappedInternalPayload;
+}
+function getMessagePayloadInternal({ data }) {
+ if (!data) {
+ return null;
+ }
+ try {
+ return data.json();
+ }
+ catch (err) {
+ // Not JSON so not an FCM message.
+ return null;
+ }
+}
+/**
+ * @param url The URL to look for when focusing a client.
+ * @return Returns an existing window client or a newly opened WindowClient.
+ */
+async function getWindowClient(url) {
+ const clientList = await getClientList();
+ for (const client of clientList) {
+ const clientUrl = new URL(client.url, self.location.href);
+ if (url.host === clientUrl.host) {
+ return client;
+ }
+ }
+ return null;
+}
+/**
+ * @returns If there is currently a visible WindowClient, this method will resolve to true,
+ * otherwise false.
+ */
+function hasVisibleClients(clientList) {
+ return clientList.some(client => client.visibilityState === 'visible' &&
+ // Ignore chrome-extension clients as that matches the background pages of extensions, which
+ // are always considered visible for some reason.
+ !client.url.startsWith('chrome-extension://'));
+}
+function sendMessagePayloadInternalToWindows(clientList, internalPayload) {
+ internalPayload.isFirebaseMessaging = true;
+ internalPayload.messageType = MessageType.PUSH_RECEIVED;
+ for (const client of clientList) {
+ client.postMessage(internalPayload);
+ }
+}
+function getClientList() {
+ return self.clients.matchAll({
+ type: 'window',
+ includeUncontrolled: true
+ // TS doesn't know that "type: 'window'" means it'll return WindowClient[]
+ });
+}
+function showNotification(notificationPayloadInternal) {
+ // Note: Firefox does not support the maxActions property.
+ // https://developer.mozilla.org/en-US/docs/Web/API/notification/maxActions
+ const { actions } = notificationPayloadInternal;
+ const { maxActions } = Notification;
+ if (actions && maxActions && actions.length > maxActions) {
+ console.warn(`This browser only supports ${maxActions} actions. The remaining actions will not be displayed.`);
+ }
+ return self.registration.showNotification(
+ /* title= */ notificationPayloadInternal.title ?? '', notificationPayloadInternal);
+}
+function getLink(payload) {
+ // eslint-disable-next-line camelcase
+ const link = payload.fcmOptions?.link ?? payload.notification?.click_action;
+ if (link) {
+ return link;
+ }
+ if (isConsoleMessage(payload.data)) {
+ // Notification created in the Firebase Console. Redirect to origin.
+ return self.location.origin;
+ }
+ else {
+ return null;
+ }
+}
+
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+function extractAppConfig(app) {
+ if (!app || !app.options) {
+ throw getMissingValueError('App Configuration Object');
+ }
+ if (!app.name) {
+ throw getMissingValueError('App Name');
+ }
+ // Required app config keys
+ const configKeys = [
+ 'projectId',
+ 'apiKey',
+ 'appId',
+ 'messagingSenderId'
+ ];
+ const { options } = app;
+ for (const keyName of configKeys) {
+ if (!options[keyName]) {
+ throw getMissingValueError(keyName);
+ }
+ }
+ return {
+ appName: app.name,
+ projectId: options.projectId,
+ apiKey: options.apiKey,
+ appId: options.appId,
+ senderId: options.messagingSenderId
+ };
+}
+function getMissingValueError(valueName) {
+ return ERROR_FACTORY.create("missing-app-config-values" /* ErrorCode.MISSING_APP_CONFIG_VALUES */, {
+ valueName
+ });
+}
+
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+class MessagingService {
+ constructor(app, installations, analyticsProvider) {
+ // logging is only done with end user consent. Default to false.
+ this.deliveryMetricsExportedToBigQueryEnabled = false;
+ this.onBackgroundMessageHandler = null;
+ this.onMessageHandler = null;
+ this.logEvents = [];
+ this.isLogServiceStarted = false;
+ const appConfig = extractAppConfig(app);
+ this.firebaseDependencies = {
+ app,
+ appConfig,
+ installations,
+ analyticsProvider
+ };
+ }
+ _delete() {
+ return Promise.resolve();
+ }
+}
+
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+const SwMessagingFactory = (container) => {
+ const messaging = new MessagingService(container.getProvider('app').getImmediate(), container.getProvider('installations-internal').getImmediate(), container.getProvider('analytics-internal'));
+ self.addEventListener('push', e => {
+ e.waitUntil(onPush(e, messaging));
+ });
+ self.addEventListener('pushsubscriptionchange', e => {
+ e.waitUntil(onSubChange(e, messaging));
+ });
+ self.addEventListener('notificationclick', e => {
+ e.waitUntil(onNotificationClick(e));
+ });
+ return messaging;
+};
+/**
+ * The messaging instance registered in sw is named differently than that of in client. This is
+ * because both `registerMessagingInWindow` and `registerMessagingInSw` would be called in
+ * `messaging-compat` and component with the same name can only be registered once.
+ */
+function registerMessagingInSw() {
+ _registerComponent(new Component('messaging-sw', SwMessagingFactory, "PUBLIC" /* ComponentType.PUBLIC */));
+}
+
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Checks whether all required APIs exist within SW Context
+ * @returns a Promise that resolves to a boolean.
+ *
+ * @public
+ */
+async function isSwSupported() {
+ // firebase-js-sdk/issues/2393 reveals that idb#open in Safari iframe and Firefox private browsing
+ // might be prohibited to run. In these contexts, an error would be thrown during the messaging
+ // instantiating phase, informing the developers to import/call isSupported for special handling.
+ return (isIndexedDBAvailable() &&
+ (await validateIndexedDBOpenable()) &&
+ 'PushManager' in self &&
+ 'Notification' in self &&
+ ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&
+ PushSubscription.prototype.hasOwnProperty('getKey'));
+}
+
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+function onBackgroundMessage$1(messaging, nextOrObserver) {
+ if (self.document !== undefined) {
+ throw ERROR_FACTORY.create("only-available-in-sw" /* ErrorCode.AVAILABLE_IN_SW */);
+ }
+ messaging.onBackgroundMessageHandler = nextOrObserver;
+ return () => {
+ messaging.onBackgroundMessageHandler = null;
+ };
+}
+
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+function _setDeliveryMetricsExportedToBigQueryEnabled(messaging, enable) {
+ messaging.deliveryMetricsExportedToBigQueryEnabled =
+ enable;
+}
+
+/**
+ * @license
+ * Copyright 2017 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Retrieves a Firebase Cloud Messaging instance.
+ *
+ * @returns The Firebase Cloud Messaging instance associated with the provided firebase app.
+ *
+ * @public
+ */
+function getMessagingInSw(app = getApp()) {
+ // Conscious decision to make this async check non-blocking during the messaging instance
+ // initialization phase for performance consideration. An error would be thrown latter for
+ // developer's information. Developers can then choose to import and call `isSupported` for
+ // special handling.
+ isSwSupported().then(isSupported => {
+ // If `isSwSupported()` resolved, but returned false.
+ if (!isSupported) {
+ throw ERROR_FACTORY.create("unsupported-browser" /* ErrorCode.UNSUPPORTED_BROWSER */);
+ }
+ }, _ => {
+ // If `isSwSupported()` rejected.
+ throw ERROR_FACTORY.create("indexed-db-unsupported" /* ErrorCode.INDEXED_DB_UNSUPPORTED */);
+ });
+ return _getProvider(getModularInstance(app), 'messaging-sw').getImmediate();
+}
+/**
+ * Called when a message is received while the app is in the background. An app is considered to be
+ * in the background if no active window is displayed.
+ *
+ * @param messaging - The {@link Messaging} instance.
+ * @param nextOrObserver - This function, or observer object with `next` defined, is called when a
+ * message is received and the app is currently in the background.
+ *
+ * @returns To stop listening for messages execute this returned function
+ *
+ * @public
+ */
+function onBackgroundMessage(messaging, nextOrObserver) {
+ messaging = getModularInstance(messaging);
+ return onBackgroundMessage$1(messaging, nextOrObserver);
+}
+/**
+ * Enables or disables Firebase Cloud Messaging message delivery metrics export to BigQuery. By
+ * default, message delivery metrics are not exported to BigQuery. Use this method to enable or
+ * disable the export at runtime.
+ *
+ * @param messaging - The `FirebaseMessaging` instance.
+ * @param enable - Whether Firebase Cloud Messaging should export message delivery metrics to
+ * BigQuery.
+ *
+ * @public
+ */
+function experimentalSetDeliveryMetricsExportedToBigQueryEnabled(messaging, enable) {
+ messaging = getModularInstance(messaging);
+ return _setDeliveryMetricsExportedToBigQueryEnabled(messaging, enable);
+}
+
+/**
+ * @license
+ * Copyright 2017 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+registerMessagingInSw();
+
+export { experimentalSetDeliveryMetricsExportedToBigQueryEnabled, getMessagingInSw as getMessaging, isSwSupported as isSupported, onBackgroundMessage };
+//# sourceMappingURL=index.sw.esm.js.map
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/index.sw.esm.js.map b/frontend-old/node_modules/@firebase/messaging/dist/esm/index.sw.esm.js.map
new file mode 100644
index 0000000..f46b3ef
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/index.sw.esm.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"index.sw.esm.js","sources":["../../src/util/constants.ts","../../src/interfaces/internal-message-payload.ts","../../src/helpers/array-base64-translator.ts","../../src/helpers/migrate-old-database.ts","../../src/internals/idb-manager.ts","../../src/util/errors.ts","../../src/internals/requests.ts","../../src/internals/token-manager.ts","../../src/helpers/externalizePayload.ts","../../src/helpers/is-console-message.ts","../../src/helpers/sleep.ts","../../src/helpers/logToFirelog.ts","../../src/listeners/sw-listeners.ts","../../src/helpers/extract-app-config.ts","../../src/messaging-service.ts","../../src/helpers/register.ts","../../src/api/isSupported.ts","../../src/api/onBackgroundMessage.ts","../../src/api/setDeliveryMetricsExportedToBigQueryEnabled.ts","../../src/api.ts","../../src/index.sw.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const DEFAULT_SW_PATH = '/firebase-messaging-sw.js';\nexport const DEFAULT_SW_SCOPE = '/firebase-cloud-messaging-push-scope';\n\nexport const DEFAULT_VAPID_KEY =\n 'BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4';\n\nexport const ENDPOINT = 'https://fcmregistrations.googleapis.com/v1';\n\n/** Key of FCM Payload in Notification's data field. */\nexport const FCM_MSG = 'FCM_MSG';\n\nexport const CONSOLE_CAMPAIGN_ID = 'google.c.a.c_id';\nexport const CONSOLE_CAMPAIGN_NAME = 'google.c.a.c_l';\nexport const CONSOLE_CAMPAIGN_TIME = 'google.c.a.ts';\n/** Set to '1' if Analytics is enabled for the campaign */\nexport const CONSOLE_CAMPAIGN_ANALYTICS_ENABLED = 'google.c.a.e';\nexport const TAG = 'FirebaseMessaging: ';\nexport const MAX_NUMBER_OF_EVENTS_PER_LOG_REQUEST = 1000;\nexport const MAX_RETRIES = 3;\nexport const LOG_INTERVAL_IN_MS = 86400000; //24 hour\nexport const DEFAULT_BACKOFF_TIME_MS = 5000;\nexport const DEFAULT_REGISTRATION_TIMEOUT = 10000;\n\n// FCM log source name registered at Firelog: 'FCM_CLIENT_EVENT_LOGGING'. It uniquely identifies\n// FCM's logging configuration.\nexport const FCM_LOG_SOURCE = 1249;\n\n// Defined as in proto/messaging_event.proto. Neglecting fields that are supported.\nexport const SDK_PLATFORM_WEB = 3;\nexport const EVENT_MESSAGE_DELIVERED = 1;\n\nexport enum MessageType {\n DATA_MESSAGE = 1,\n DISPLAY_NOTIFICATION = 3\n}\n","/**\n * @license\n * Copyright 2018 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n * in compliance with the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under the License\n * is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\n * or implied. See the License for the specific language governing permissions and limitations under\n * the License.\n */\n\nimport {\n CONSOLE_CAMPAIGN_ANALYTICS_ENABLED,\n CONSOLE_CAMPAIGN_ID,\n CONSOLE_CAMPAIGN_NAME,\n CONSOLE_CAMPAIGN_TIME\n} from '../util/constants';\n\nexport interface MessagePayloadInternal {\n notification?: NotificationPayloadInternal;\n data?: unknown;\n fcmOptions?: FcmOptionsInternal;\n messageType?: MessageType;\n isFirebaseMessaging?: boolean;\n from: string;\n fcmMessageId: string;\n productId: number;\n // eslint-disable-next-line camelcase\n collapse_key: string;\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/API/Notification/actions\ninterface NotificationAction {\n action: string;\n icon?: string;\n title: string;\n}\n\n/**\n * This interface defines experimental properties of NotificationOptions, that are not part of\n * the interface in the generated DOM types at https://github.com/microsoft/TypeScript-DOM-lib-generator/blob/179bdd84a944933a3103f29c2274c9f5a857b693/baselines/dom.generated.d.ts#L1012\n * https://developer.mozilla.org/en-US/docs/Web/API/Notification\n */\ninterface NotificationOptionsExperimental extends NotificationOptions {\n readonly maxActions?: number;\n readonly actions?: NotificationAction[];\n readonly image?: string;\n readonly renotify?: boolean;\n readonly timestamp?: EpochTimeStamp;\n readonly vibrate?: VibratePattern;\n}\n\nexport interface NotificationPayloadInternal\n extends NotificationOptionsExperimental {\n title: string;\n // Supported in the Legacy Send API.\n // See:https://firebase.google.com/docs/cloud-messaging/xmpp-server-ref.\n // eslint-disable-next-line camelcase\n click_action?: string;\n icon?: string;\n}\n\n// Defined in\n// https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#webpushfcmoptions. Note\n// that the keys are sent to the clients in snake cases which we need to convert to camel so it can\n// be exposed as a type to match the Firebase API convention.\nexport interface FcmOptionsInternal {\n link?: string;\n\n // eslint-disable-next-line camelcase\n analytics_label?: string;\n}\n\nexport enum MessageType {\n PUSH_RECEIVED = 'push-received',\n NOTIFICATION_CLICKED = 'notification-clicked'\n}\n\n/** Additional data of a message sent from the FN Console. */\nexport interface ConsoleMessageData {\n [CONSOLE_CAMPAIGN_ID]: string;\n [CONSOLE_CAMPAIGN_TIME]: string;\n [CONSOLE_CAMPAIGN_NAME]?: string;\n [CONSOLE_CAMPAIGN_ANALYTICS_ENABLED]?: '1';\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function arrayToBase64(array: Uint8Array | ArrayBuffer): string {\n const uint8Array = new Uint8Array(array);\n const base64String = btoa(String.fromCharCode(...uint8Array));\n return base64String.replace(/=/g, '').replace(/\\+/g, '-').replace(/\\//g, '_');\n}\n\nexport function base64ToArray(base64String: string): Uint8Array {\n const padding = '='.repeat((4 - (base64String.length % 4)) % 4);\n const base64 = (base64String + padding)\n .replace(/\\-/g, '+')\n .replace(/_/g, '/');\n\n const rawData = atob(base64);\n const outputArray = new Uint8Array(rawData.length);\n\n for (let i = 0; i < rawData.length; ++i) {\n outputArray[i] = rawData.charCodeAt(i);\n }\n return outputArray;\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { deleteDB, openDB } from 'idb';\n\nimport { TokenDetails } from '../interfaces/token-details';\nimport { arrayToBase64 } from './array-base64-translator';\n\n// https://github.com/firebase/firebase-js-sdk/blob/7857c212f944a2a9eb421fd4cb7370181bc034b5/packages/messaging/src/interfaces/token-details.ts\nexport interface V2TokenDetails {\n fcmToken: string;\n swScope: string;\n vapidKey: string | Uint8Array;\n subscription: PushSubscription;\n fcmSenderId: string;\n fcmPushSet: string;\n createTime?: number;\n endpoint?: string;\n auth?: string;\n p256dh?: string;\n}\n\n// https://github.com/firebase/firebase-js-sdk/blob/6b5b15ce4ea3df5df5df8a8b33a4e41e249c7715/packages/messaging/src/interfaces/token-details.ts\nexport interface V3TokenDetails {\n fcmToken: string;\n swScope: string;\n vapidKey: Uint8Array;\n fcmSenderId: string;\n fcmPushSet: string;\n endpoint: string;\n auth: ArrayBuffer;\n p256dh: ArrayBuffer;\n createTime: number;\n}\n\n// https://github.com/firebase/firebase-js-sdk/blob/9567dba664732f681fa7fe60f5b7032bb1daf4c9/packages/messaging/src/interfaces/token-details.ts\nexport interface V4TokenDetails {\n fcmToken: string;\n swScope: string;\n vapidKey: Uint8Array;\n fcmSenderId: string;\n endpoint: string;\n auth: ArrayBufferLike;\n p256dh: ArrayBufferLike;\n createTime: number;\n}\n\nconst OLD_DB_NAME = 'fcm_token_details_db';\n/**\n * The last DB version of 'fcm_token_details_db' was 4. This is one higher, so that the upgrade\n * callback is called for all versions of the old DB.\n */\nconst OLD_DB_VERSION = 5;\nconst OLD_OBJECT_STORE_NAME = 'fcm_token_object_Store';\n\nexport async function migrateOldDatabase(\n senderId: string\n): Promise<TokenDetails | null> {\n if ('databases' in indexedDB) {\n // indexedDb.databases() is an IndexedDB v3 API and does not exist in all browsers. TODO: Remove\n // typecast when it lands in TS types.\n const databases = await (\n indexedDB as {\n databases(): Promise<Array<{ name: string; version: number }>>;\n }\n ).databases();\n const dbNames = databases.map(db => db.name);\n\n if (!dbNames.includes(OLD_DB_NAME)) {\n // old DB didn't exist, no need to open.\n return null;\n }\n }\n\n let tokenDetails: TokenDetails | null = null;\n\n const db = await openDB(OLD_DB_NAME, OLD_DB_VERSION, {\n upgrade: async (db, oldVersion, newVersion, upgradeTransaction) => {\n if (oldVersion < 2) {\n // Database too old, skip migration.\n return;\n }\n\n if (!db.objectStoreNames.contains(OLD_OBJECT_STORE_NAME)) {\n // Database did not exist. Nothing to do.\n return;\n }\n\n const objectStore = upgradeTransaction.objectStore(OLD_OBJECT_STORE_NAME);\n const value = await objectStore.index('fcmSenderId').get(senderId);\n await objectStore.clear();\n\n if (!value) {\n // No entry in the database, nothing to migrate.\n return;\n }\n\n if (oldVersion === 2) {\n const oldDetails = value as V2TokenDetails;\n\n if (!oldDetails.auth || !oldDetails.p256dh || !oldDetails.endpoint) {\n return;\n }\n\n tokenDetails = {\n token: oldDetails.fcmToken,\n createTime: oldDetails.createTime ?? Date.now(),\n subscriptionOptions: {\n auth: oldDetails.auth,\n p256dh: oldDetails.p256dh,\n endpoint: oldDetails.endpoint,\n swScope: oldDetails.swScope,\n vapidKey:\n typeof oldDetails.vapidKey === 'string'\n ? oldDetails.vapidKey\n : arrayToBase64(oldDetails.vapidKey)\n }\n };\n } else if (oldVersion === 3) {\n const oldDetails = value as V3TokenDetails;\n\n tokenDetails = {\n token: oldDetails.fcmToken,\n createTime: oldDetails.createTime,\n subscriptionOptions: {\n auth: arrayToBase64(oldDetails.auth),\n p256dh: arrayToBase64(oldDetails.p256dh),\n endpoint: oldDetails.endpoint,\n swScope: oldDetails.swScope,\n vapidKey: arrayToBase64(oldDetails.vapidKey)\n }\n };\n } else if (oldVersion === 4) {\n const oldDetails = value as V4TokenDetails;\n\n tokenDetails = {\n token: oldDetails.fcmToken,\n createTime: oldDetails.createTime,\n subscriptionOptions: {\n auth: arrayToBase64(oldDetails.auth),\n p256dh: arrayToBase64(oldDetails.p256dh),\n endpoint: oldDetails.endpoint,\n swScope: oldDetails.swScope,\n vapidKey: arrayToBase64(oldDetails.vapidKey)\n }\n };\n }\n }\n });\n db.close();\n\n // Delete all old databases.\n await deleteDB(OLD_DB_NAME);\n await deleteDB('fcm_vapid_details_db');\n await deleteDB('undefined');\n\n return checkTokenDetails(tokenDetails) ? tokenDetails : null;\n}\n\nfunction checkTokenDetails(\n tokenDetails: TokenDetails | null\n): tokenDetails is TokenDetails {\n if (!tokenDetails || !tokenDetails.subscriptionOptions) {\n return false;\n }\n const { subscriptionOptions } = tokenDetails;\n return (\n typeof tokenDetails.createTime === 'number' &&\n tokenDetails.createTime > 0 &&\n typeof tokenDetails.token === 'string' &&\n tokenDetails.token.length > 0 &&\n typeof subscriptionOptions.auth === 'string' &&\n subscriptionOptions.auth.length > 0 &&\n typeof subscriptionOptions.p256dh === 'string' &&\n subscriptionOptions.p256dh.length > 0 &&\n typeof subscriptionOptions.endpoint === 'string' &&\n subscriptionOptions.endpoint.length > 0 &&\n typeof subscriptionOptions.swScope === 'string' &&\n subscriptionOptions.swScope.length > 0 &&\n typeof subscriptionOptions.vapidKey === 'string' &&\n subscriptionOptions.vapidKey.length > 0\n );\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DBSchema, IDBPDatabase, deleteDB, openDB } from 'idb';\n\nimport { FirebaseInternalDependencies } from '../interfaces/internal-dependencies';\nimport { TokenDetails } from '../interfaces/token-details';\nimport { migrateOldDatabase } from '../helpers/migrate-old-database';\n\n// Exported for tests.\nexport const DATABASE_NAME = 'firebase-messaging-database';\nconst DATABASE_VERSION = 1;\nconst OBJECT_STORE_NAME = 'firebase-messaging-store';\n\ninterface MessagingDB extends DBSchema {\n 'firebase-messaging-store': {\n key: string;\n value: TokenDetails;\n };\n}\n\nlet dbPromise: Promise<IDBPDatabase<MessagingDB>> | null = null;\nfunction getDbPromise(): Promise<IDBPDatabase<MessagingDB>> {\n if (!dbPromise) {\n dbPromise = openDB(DATABASE_NAME, DATABASE_VERSION, {\n upgrade: (upgradeDb, oldVersion) => {\n // We don't use 'break' in this switch statement, the fall-through behavior is what we want,\n // because if there are multiple versions between the old version and the current version, we\n // want ALL the migrations that correspond to those versions to run, not only the last one.\n // eslint-disable-next-line default-case\n switch (oldVersion) {\n case 0:\n upgradeDb.createObjectStore(OBJECT_STORE_NAME);\n }\n }\n });\n }\n return dbPromise;\n}\n\n/** Gets record(s) from the objectStore that match the given key. */\nexport async function dbGet(\n firebaseDependencies: FirebaseInternalDependencies\n): Promise<TokenDetails | undefined> {\n const key = getKey(firebaseDependencies);\n const db = await getDbPromise();\n const tokenDetails = (await db\n .transaction(OBJECT_STORE_NAME)\n .objectStore(OBJECT_STORE_NAME)\n .get(key)) as TokenDetails;\n\n if (tokenDetails) {\n return tokenDetails;\n } else {\n // Check if there is a tokenDetails object in the old DB.\n const oldTokenDetails = await migrateOldDatabase(\n firebaseDependencies.appConfig.senderId\n );\n if (oldTokenDetails) {\n await dbSet(firebaseDependencies, oldTokenDetails);\n return oldTokenDetails;\n }\n }\n}\n\n/** Assigns or overwrites the record for the given key with the given value. */\nexport async function dbSet(\n firebaseDependencies: FirebaseInternalDependencies,\n tokenDetails: TokenDetails\n): Promise<TokenDetails> {\n const key = getKey(firebaseDependencies);\n const db = await getDbPromise();\n const tx = db.transaction(OBJECT_STORE_NAME, 'readwrite');\n await tx.objectStore(OBJECT_STORE_NAME).put(tokenDetails, key);\n await tx.done;\n return tokenDetails;\n}\n\n/** Removes record(s) from the objectStore that match the given key. */\nexport async function dbRemove(\n firebaseDependencies: FirebaseInternalDependencies\n): Promise<void> {\n const key = getKey(firebaseDependencies);\n const db = await getDbPromise();\n const tx = db.transaction(OBJECT_STORE_NAME, 'readwrite');\n await tx.objectStore(OBJECT_STORE_NAME).delete(key);\n await tx.done;\n}\n\n/** Deletes the DB. Useful for tests. */\nexport async function dbDelete(): Promise<void> {\n if (dbPromise) {\n (await dbPromise).close();\n await deleteDB(DATABASE_NAME);\n dbPromise = null;\n }\n}\n\nfunction getKey({ appConfig }: FirebaseInternalDependencies): string {\n return appConfig.appId;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ErrorFactory, ErrorMap } from '@firebase/util';\n\nexport const enum ErrorCode {\n MISSING_APP_CONFIG_VALUES = 'missing-app-config-values',\n AVAILABLE_IN_WINDOW = 'only-available-in-window',\n AVAILABLE_IN_SW = 'only-available-in-sw',\n PERMISSION_DEFAULT = 'permission-default',\n PERMISSION_BLOCKED = 'permission-blocked',\n UNSUPPORTED_BROWSER = 'unsupported-browser',\n INDEXED_DB_UNSUPPORTED = 'indexed-db-unsupported',\n FAILED_DEFAULT_REGISTRATION = 'failed-service-worker-registration',\n TOKEN_SUBSCRIBE_FAILED = 'token-subscribe-failed',\n TOKEN_SUBSCRIBE_NO_TOKEN = 'token-subscribe-no-token',\n TOKEN_UNSUBSCRIBE_FAILED = 'token-unsubscribe-failed',\n TOKEN_UPDATE_FAILED = 'token-update-failed',\n TOKEN_UPDATE_NO_TOKEN = 'token-update-no-token',\n INVALID_BG_HANDLER = 'invalid-bg-handler',\n USE_SW_AFTER_GET_TOKEN = 'use-sw-after-get-token',\n INVALID_SW_REGISTRATION = 'invalid-sw-registration',\n USE_VAPID_KEY_AFTER_GET_TOKEN = 'use-vapid-key-after-get-token',\n INVALID_VAPID_KEY = 'invalid-vapid-key'\n}\n\nexport const ERROR_MAP: ErrorMap<ErrorCode> = {\n [ErrorCode.MISSING_APP_CONFIG_VALUES]:\n 'Missing App configuration value: \"{$valueName}\"',\n [ErrorCode.AVAILABLE_IN_WINDOW]:\n 'This method is available in a Window context.',\n [ErrorCode.AVAILABLE_IN_SW]:\n 'This method is available in a service worker context.',\n [ErrorCode.PERMISSION_DEFAULT]:\n 'The notification permission was not granted and dismissed instead.',\n [ErrorCode.PERMISSION_BLOCKED]:\n 'The notification permission was not granted and blocked instead.',\n [ErrorCode.UNSUPPORTED_BROWSER]:\n \"This browser doesn't support the API's required to use the Firebase SDK.\",\n [ErrorCode.INDEXED_DB_UNSUPPORTED]:\n \"This browser doesn't support indexedDb.open() (ex. Safari iFrame, Firefox Private Browsing, etc)\",\n [ErrorCode.FAILED_DEFAULT_REGISTRATION]:\n 'We are unable to register the default service worker. {$browserErrorMessage}',\n [ErrorCode.TOKEN_SUBSCRIBE_FAILED]:\n 'A problem occurred while subscribing the user to FCM: {$errorInfo}',\n [ErrorCode.TOKEN_SUBSCRIBE_NO_TOKEN]:\n 'FCM returned no token when subscribing the user to push.',\n [ErrorCode.TOKEN_UNSUBSCRIBE_FAILED]:\n 'A problem occurred while unsubscribing the ' +\n 'user from FCM: {$errorInfo}',\n [ErrorCode.TOKEN_UPDATE_FAILED]:\n 'A problem occurred while updating the user from FCM: {$errorInfo}',\n [ErrorCode.TOKEN_UPDATE_NO_TOKEN]:\n 'FCM returned no token when updating the user to push.',\n [ErrorCode.USE_SW_AFTER_GET_TOKEN]:\n 'The useServiceWorker() method may only be called once and must be ' +\n 'called before calling getToken() to ensure your service worker is used.',\n [ErrorCode.INVALID_SW_REGISTRATION]:\n 'The input to useServiceWorker() must be a ServiceWorkerRegistration.',\n [ErrorCode.INVALID_BG_HANDLER]:\n 'The input to setBackgroundMessageHandler() must be a function.',\n [ErrorCode.INVALID_VAPID_KEY]: 'The public VAPID key must be a string.',\n [ErrorCode.USE_VAPID_KEY_AFTER_GET_TOKEN]:\n 'The usePublicVapidKey() method may only be called once and must be ' +\n 'called before calling getToken() to ensure your VAPID key is used.'\n};\n\ninterface ErrorParams {\n [ErrorCode.MISSING_APP_CONFIG_VALUES]: {\n valueName: string;\n };\n [ErrorCode.FAILED_DEFAULT_REGISTRATION]: { browserErrorMessage: string };\n [ErrorCode.TOKEN_SUBSCRIBE_FAILED]: { errorInfo: string };\n [ErrorCode.TOKEN_UNSUBSCRIBE_FAILED]: { errorInfo: string };\n [ErrorCode.TOKEN_UPDATE_FAILED]: { errorInfo: string };\n}\n\nexport const ERROR_FACTORY = new ErrorFactory<ErrorCode, ErrorParams>(\n 'messaging',\n 'Messaging',\n ERROR_MAP\n);\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DEFAULT_VAPID_KEY, ENDPOINT } from '../util/constants';\nimport { ERROR_FACTORY, ErrorCode } from '../util/errors';\nimport { SubscriptionOptions, TokenDetails } from '../interfaces/token-details';\n\nimport { AppConfig } from '../interfaces/app-config';\nimport { FirebaseInternalDependencies } from '../interfaces/internal-dependencies';\n\nexport interface ApiResponse {\n token?: string;\n error?: { message: string };\n}\n\nexport interface ApiRequestBody {\n web: {\n endpoint: string;\n p256dh: string;\n auth: string;\n applicationPubKey?: string;\n };\n}\n\nexport async function requestGetToken(\n firebaseDependencies: FirebaseInternalDependencies,\n subscriptionOptions: SubscriptionOptions\n): Promise<string> {\n const headers = await getHeaders(firebaseDependencies);\n const body = getBody(subscriptionOptions);\n\n const subscribeOptions = {\n method: 'POST',\n headers,\n body: JSON.stringify(body)\n };\n\n let responseData: ApiResponse;\n try {\n const response = await fetch(\n getEndpoint(firebaseDependencies.appConfig),\n subscribeOptions\n );\n responseData = await response.json();\n } catch (err) {\n throw ERROR_FACTORY.create(ErrorCode.TOKEN_SUBSCRIBE_FAILED, {\n errorInfo: (err as Error)?.toString()\n });\n }\n\n if (responseData.error) {\n const message = responseData.error.message;\n throw ERROR_FACTORY.create(ErrorCode.TOKEN_SUBSCRIBE_FAILED, {\n errorInfo: message\n });\n }\n\n if (!responseData.token) {\n throw ERROR_FACTORY.create(ErrorCode.TOKEN_SUBSCRIBE_NO_TOKEN);\n }\n\n return responseData.token;\n}\n\nexport async function requestUpdateToken(\n firebaseDependencies: FirebaseInternalDependencies,\n tokenDetails: TokenDetails\n): Promise<string> {\n const headers = await getHeaders(firebaseDependencies);\n const body = getBody(tokenDetails.subscriptionOptions!);\n\n const updateOptions = {\n method: 'PATCH',\n headers,\n body: JSON.stringify(body)\n };\n\n let responseData: ApiResponse;\n try {\n const response = await fetch(\n `${getEndpoint(firebaseDependencies.appConfig)}/${tokenDetails.token}`,\n updateOptions\n );\n responseData = await response.json();\n } catch (err) {\n throw ERROR_FACTORY.create(ErrorCode.TOKEN_UPDATE_FAILED, {\n errorInfo: (err as Error)?.toString()\n });\n }\n\n if (responseData.error) {\n const message = responseData.error.message;\n throw ERROR_FACTORY.create(ErrorCode.TOKEN_UPDATE_FAILED, {\n errorInfo: message\n });\n }\n\n if (!responseData.token) {\n throw ERROR_FACTORY.create(ErrorCode.TOKEN_UPDATE_NO_TOKEN);\n }\n\n return responseData.token;\n}\n\nexport async function requestDeleteToken(\n firebaseDependencies: FirebaseInternalDependencies,\n token: string\n): Promise<void> {\n const headers = await getHeaders(firebaseDependencies);\n\n const unsubscribeOptions = {\n method: 'DELETE',\n headers\n };\n\n try {\n const response = await fetch(\n `${getEndpoint(firebaseDependencies.appConfig)}/${token}`,\n unsubscribeOptions\n );\n const responseData: ApiResponse = await response.json();\n if (responseData.error) {\n const message = responseData.error.message;\n throw ERROR_FACTORY.create(ErrorCode.TOKEN_UNSUBSCRIBE_FAILED, {\n errorInfo: message\n });\n }\n } catch (err) {\n throw ERROR_FACTORY.create(ErrorCode.TOKEN_UNSUBSCRIBE_FAILED, {\n errorInfo: (err as Error)?.toString()\n });\n }\n}\n\nfunction getEndpoint({ projectId }: AppConfig): string {\n return `${ENDPOINT}/projects/${projectId!}/registrations`;\n}\n\nasync function getHeaders({\n appConfig,\n installations\n}: FirebaseInternalDependencies): Promise<Headers> {\n const authToken = await installations.getToken();\n\n return new Headers({\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n 'x-goog-api-key': appConfig.apiKey!,\n 'x-goog-firebase-installations-auth': `FIS ${authToken}`\n });\n}\n\nfunction getBody({\n p256dh,\n auth,\n endpoint,\n vapidKey\n}: SubscriptionOptions): ApiRequestBody {\n const body: ApiRequestBody = {\n web: {\n endpoint,\n auth,\n p256dh\n }\n };\n\n if (vapidKey !== DEFAULT_VAPID_KEY) {\n body.web.applicationPubKey = vapidKey;\n }\n\n return body;\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SubscriptionOptions, TokenDetails } from '../interfaces/token-details';\nimport {\n arrayToBase64,\n base64ToArray\n} from '../helpers/array-base64-translator';\nimport { dbGet, dbRemove, dbSet } from './idb-manager';\nimport {\n requestDeleteToken,\n requestGetToken,\n requestUpdateToken\n} from './requests';\n\nimport { FirebaseInternalDependencies } from '../interfaces/internal-dependencies';\nimport { MessagingService } from '../messaging-service';\n\n// UpdateRegistration will be called once every week.\nconst TOKEN_EXPIRATION_MS = 7 * 24 * 60 * 60 * 1000; // 7 days\n\nexport async function getTokenInternal(\n messaging: MessagingService\n): Promise<string> {\n const pushSubscription = await getPushSubscription(\n messaging.swRegistration!,\n messaging.vapidKey!\n );\n\n const subscriptionOptions: SubscriptionOptions = {\n vapidKey: messaging.vapidKey!,\n swScope: messaging.swRegistration!.scope,\n endpoint: pushSubscription.endpoint,\n auth: arrayToBase64(pushSubscription.getKey('auth')!),\n p256dh: arrayToBase64(pushSubscription.getKey('p256dh')!)\n };\n\n const tokenDetails = await dbGet(messaging.firebaseDependencies);\n if (!tokenDetails) {\n // No token, get a new one.\n return getNewToken(messaging.firebaseDependencies, subscriptionOptions);\n } else if (\n !isTokenValid(tokenDetails.subscriptionOptions!, subscriptionOptions)\n ) {\n // Invalid token, get a new one.\n try {\n await requestDeleteToken(\n messaging.firebaseDependencies!,\n tokenDetails.token\n );\n } catch (e) {\n // Suppress errors because of #2364\n console.warn(e);\n }\n\n return getNewToken(messaging.firebaseDependencies!, subscriptionOptions);\n } else if (Date.now() >= tokenDetails.createTime + TOKEN_EXPIRATION_MS) {\n // Weekly token refresh\n return updateToken(messaging, {\n token: tokenDetails.token,\n createTime: Date.now(),\n subscriptionOptions\n });\n } else {\n // Valid token, nothing to do.\n return tokenDetails.token;\n }\n}\n\n/**\n * This method deletes the token from the database, unsubscribes the token from FCM, and unregisters\n * the push subscription if it exists.\n */\nexport async function deleteTokenInternal(\n messaging: MessagingService\n): Promise<boolean> {\n const tokenDetails = await dbGet(messaging.firebaseDependencies);\n if (tokenDetails) {\n await requestDeleteToken(\n messaging.firebaseDependencies,\n tokenDetails.token\n );\n await dbRemove(messaging.firebaseDependencies);\n }\n\n // Unsubscribe from the push subscription.\n const pushSubscription =\n await messaging.swRegistration!.pushManager.getSubscription();\n if (pushSubscription) {\n return pushSubscription.unsubscribe();\n }\n\n // If there's no SW, consider it a success.\n return true;\n}\n\nasync function updateToken(\n messaging: MessagingService,\n tokenDetails: TokenDetails\n): Promise<string> {\n try {\n const updatedToken = await requestUpdateToken(\n messaging.firebaseDependencies,\n tokenDetails\n );\n\n const updatedTokenDetails: TokenDetails = {\n ...tokenDetails,\n token: updatedToken,\n createTime: Date.now()\n };\n\n await dbSet(messaging.firebaseDependencies, updatedTokenDetails);\n return updatedToken;\n } catch (e) {\n throw e;\n }\n}\n\nasync function getNewToken(\n firebaseDependencies: FirebaseInternalDependencies,\n subscriptionOptions: SubscriptionOptions\n): Promise<string> {\n const token = await requestGetToken(\n firebaseDependencies,\n subscriptionOptions\n );\n const tokenDetails: TokenDetails = {\n token,\n createTime: Date.now(),\n subscriptionOptions\n };\n await dbSet(firebaseDependencies, tokenDetails);\n return tokenDetails.token;\n}\n\n/**\n * Gets a PushSubscription for the current user.\n */\nasync function getPushSubscription(\n swRegistration: ServiceWorkerRegistration,\n vapidKey: string\n): Promise<PushSubscription> {\n const subscription = await swRegistration.pushManager.getSubscription();\n if (subscription) {\n return subscription;\n }\n\n return swRegistration.pushManager.subscribe({\n userVisibleOnly: true,\n // Chrome <= 75 doesn't support base64-encoded VAPID key. For backward compatibility, VAPID key\n // submitted to pushManager#subscribe must be of type Uint8Array.\n applicationServerKey: base64ToArray(vapidKey)\n });\n}\n\n/**\n * Checks if the saved tokenDetails object matches the configuration provided.\n */\nfunction isTokenValid(\n dbOptions: SubscriptionOptions,\n currentOptions: SubscriptionOptions\n): boolean {\n const isVapidKeyEqual = currentOptions.vapidKey === dbOptions.vapidKey;\n const isEndpointEqual = currentOptions.endpoint === dbOptions.endpoint;\n const isAuthEqual = currentOptions.auth === dbOptions.auth;\n const isP256dhEqual = currentOptions.p256dh === dbOptions.p256dh;\n\n return isVapidKeyEqual && isEndpointEqual && isAuthEqual && isP256dhEqual;\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { MessagePayload } from '../interfaces/public-types';\nimport { MessagePayloadInternal } from '../interfaces/internal-message-payload';\n\nexport function externalizePayload(\n internalPayload: MessagePayloadInternal\n): MessagePayload {\n const payload: MessagePayload = {\n from: internalPayload.from,\n // eslint-disable-next-line camelcase\n collapseKey: internalPayload.collapse_key,\n // eslint-disable-next-line camelcase\n messageId: internalPayload.fcmMessageId\n } as MessagePayload;\n\n propagateNotificationPayload(payload, internalPayload);\n propagateDataPayload(payload, internalPayload);\n propagateFcmOptions(payload, internalPayload);\n\n return payload;\n}\n\nfunction propagateNotificationPayload(\n payload: MessagePayload,\n messagePayloadInternal: MessagePayloadInternal\n): void {\n if (!messagePayloadInternal.notification) {\n return;\n }\n\n payload.notification = {};\n\n const title = messagePayloadInternal.notification!.title;\n if (!!title) {\n payload.notification!.title = title;\n }\n\n const body = messagePayloadInternal.notification!.body;\n if (!!body) {\n payload.notification!.body = body;\n }\n\n const image = messagePayloadInternal.notification!.image;\n if (!!image) {\n payload.notification!.image = image;\n }\n\n const icon = messagePayloadInternal.notification!.icon;\n if (!!icon) {\n payload.notification!.icon = icon;\n }\n}\n\nfunction propagateDataPayload(\n payload: MessagePayload,\n messagePayloadInternal: MessagePayloadInternal\n): void {\n if (!messagePayloadInternal.data) {\n return;\n }\n\n payload.data = messagePayloadInternal.data as { [key: string]: string };\n}\n\nfunction propagateFcmOptions(\n payload: MessagePayload,\n messagePayloadInternal: MessagePayloadInternal\n): void {\n // fcmOptions.link value is written into notification.click_action. see more in b/232072111\n if (\n !messagePayloadInternal.fcmOptions &&\n !messagePayloadInternal.notification?.click_action\n ) {\n return;\n }\n\n payload.fcmOptions = {};\n\n const link =\n messagePayloadInternal.fcmOptions?.link ??\n messagePayloadInternal.notification?.click_action;\n\n if (!!link) {\n payload.fcmOptions!.link = link;\n }\n\n // eslint-disable-next-line camelcase\n const analyticsLabel = messagePayloadInternal.fcmOptions?.analytics_label;\n if (!!analyticsLabel) {\n payload.fcmOptions!.analyticsLabel = analyticsLabel;\n }\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CONSOLE_CAMPAIGN_ID } from '../util/constants';\nimport { ConsoleMessageData } from '../interfaces/internal-message-payload';\n\nexport function isConsoleMessage(data: unknown): data is ConsoleMessageData {\n // This message has a campaign ID, meaning it was sent using the Firebase Console.\n return typeof data === 'object' && !!data && CONSOLE_CAMPAIGN_ID in data;\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** Returns a promise that resolves after given time passes. */\nexport function sleep(ms: number): Promise<void> {\n return new Promise<void>(resolve => {\n setTimeout(resolve, ms);\n });\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n DEFAULT_BACKOFF_TIME_MS,\n EVENT_MESSAGE_DELIVERED,\n FCM_LOG_SOURCE,\n LOG_INTERVAL_IN_MS,\n MAX_NUMBER_OF_EVENTS_PER_LOG_REQUEST,\n MAX_RETRIES,\n MessageType,\n SDK_PLATFORM_WEB\n} from '../util/constants';\nimport {\n FcmEvent,\n LogEvent,\n LogRequest,\n LogResponse,\n ComplianceData\n} from '../interfaces/logging-types';\n\nimport { MessagePayloadInternal } from '../interfaces/internal-message-payload';\nimport { MessagingService } from '../messaging-service';\n\nconst LOG_ENDPOINT = 'https://play.google.com/log?format=json_proto3';\n\nconst FCM_TRANSPORT_KEY = _mergeStrings(\n 'AzSCbw63g1R0nCw85jG8',\n 'Iaya3yLKwmgvh7cF0q4'\n);\n\nexport function startLoggingService(messaging: MessagingService): void {\n if (!messaging.isLogServiceStarted) {\n _processQueue(messaging, LOG_INTERVAL_IN_MS);\n messaging.isLogServiceStarted = true;\n }\n}\n\n/**\n *\n * @param messaging the messaging instance.\n * @param offsetInMs this method execute after `offsetInMs` elapsed .\n */\nexport function _processQueue(\n messaging: MessagingService,\n offsetInMs: number\n): void {\n setTimeout(async () => {\n if (!messaging.deliveryMetricsExportedToBigQueryEnabled) {\n // flush events and terminate logging service\n messaging.logEvents = [];\n messaging.isLogServiceStarted = false;\n\n return;\n }\n\n if (!messaging.logEvents.length) {\n return _processQueue(messaging, LOG_INTERVAL_IN_MS);\n }\n\n await _dispatchLogEvents(messaging);\n }, offsetInMs);\n}\n\nexport async function _dispatchLogEvents(\n messaging: MessagingService\n): Promise<void> {\n for (\n let i = 0, n = messaging.logEvents.length;\n i < n;\n i += MAX_NUMBER_OF_EVENTS_PER_LOG_REQUEST\n ) {\n const logRequest = _createLogRequest(\n messaging.logEvents.slice(i, i + MAX_NUMBER_OF_EVENTS_PER_LOG_REQUEST)\n );\n\n let retryCount = 0,\n response = {} as Response;\n\n do {\n try {\n response = await fetch(\n LOG_ENDPOINT.concat('&key=', FCM_TRANSPORT_KEY),\n {\n method: 'POST',\n body: JSON.stringify(logRequest)\n }\n );\n\n // don't retry on 200s or non retriable errors\n if (response.ok || (!response.ok && !isRetriableError(response))) {\n break;\n }\n\n if (!response.ok && isRetriableError(response)) {\n // rethrow to retry with quota\n throw new Error(\n 'a retriable Non-200 code is returned in fetch to Firelog endpoint. Retry'\n );\n }\n } catch (error) {\n const isLastAttempt = retryCount === MAX_RETRIES;\n if (isLastAttempt) {\n // existing the do-while interactive retry logic because retry quota has reached.\n break;\n }\n }\n\n let delayInMs: number;\n try {\n delayInMs = Number(\n ((await response.json()) as LogResponse).nextRequestWaitMillis\n );\n } catch (e) {\n delayInMs = DEFAULT_BACKOFF_TIME_MS;\n }\n\n await new Promise(resolve => setTimeout(resolve, delayInMs));\n\n retryCount++;\n } while (retryCount < MAX_RETRIES);\n }\n\n messaging.logEvents = [];\n // schedule for next logging\n _processQueue(messaging, LOG_INTERVAL_IN_MS);\n}\n\nfunction isRetriableError(response: Response): boolean {\n const httpStatus = response.status;\n\n return (\n httpStatus === 429 ||\n httpStatus === 500 ||\n httpStatus === 503 ||\n httpStatus === 504\n );\n}\n\nexport async function stageLog(\n messaging: MessagingService,\n internalPayload: MessagePayloadInternal\n): Promise<void> {\n const fcmEvent = createFcmEvent(\n internalPayload,\n await messaging.firebaseDependencies.installations.getId()\n );\n\n createAndEnqueueLogEvent(messaging, fcmEvent, internalPayload.productId);\n}\n\nfunction createFcmEvent(\n internalPayload: MessagePayloadInternal,\n fid: string\n): FcmEvent {\n const fcmEvent = {} as FcmEvent;\n\n /* eslint-disable camelcase */\n // some fields should always be non-null. Still check to ensure.\n if (!!internalPayload.from) {\n fcmEvent.project_number = internalPayload.from;\n }\n\n if (!!internalPayload.fcmMessageId) {\n fcmEvent.message_id = internalPayload.fcmMessageId;\n }\n\n fcmEvent.instance_id = fid;\n\n if (!!internalPayload.notification) {\n fcmEvent.message_type = MessageType.DISPLAY_NOTIFICATION.toString();\n } else {\n fcmEvent.message_type = MessageType.DATA_MESSAGE.toString();\n }\n\n fcmEvent.sdk_platform = SDK_PLATFORM_WEB.toString();\n fcmEvent.package_name = self.origin.replace(/(^\\w+:|^)\\/\\//, '');\n\n if (!!internalPayload.collapse_key) {\n fcmEvent.collapse_key = internalPayload.collapse_key;\n }\n\n fcmEvent.event = EVENT_MESSAGE_DELIVERED.toString();\n\n if (!!internalPayload.fcmOptions?.analytics_label) {\n fcmEvent.analytics_label = internalPayload.fcmOptions?.analytics_label;\n }\n\n /* eslint-enable camelcase */\n return fcmEvent;\n}\n\nfunction createAndEnqueueLogEvent(\n messaging: MessagingService,\n fcmEvent: FcmEvent,\n productId: number\n): void {\n const logEvent = {} as LogEvent;\n\n /* eslint-disable camelcase */\n logEvent.event_time_ms = Math.floor(Date.now()).toString();\n logEvent.source_extension_json_proto3 = JSON.stringify({\n messaging_client_event: fcmEvent\n });\n\n if (!!productId) {\n logEvent.compliance_data = buildComplianceData(productId);\n }\n // eslint-disable-next-line camelcase\n\n messaging.logEvents.push(logEvent);\n}\n\nfunction buildComplianceData(productId: number): ComplianceData {\n const complianceData: ComplianceData = {\n privacy_context: {\n prequest: {\n origin_associated_product_id: productId\n }\n }\n };\n\n return complianceData;\n}\n\nexport function _createLogRequest(logEventQueue: LogEvent[]): LogRequest {\n const logRequest = {} as LogRequest;\n\n /* eslint-disable camelcase */\n logRequest.log_source = FCM_LOG_SOURCE.toString();\n logRequest.log_event = logEventQueue;\n /* eslint-enable camelcase */\n\n return logRequest;\n}\n\nexport function _mergeStrings(s1: string, s2: string): string {\n const resultArray = [];\n for (let i = 0; i < s1.length; i++) {\n resultArray.push(s1.charAt(i));\n if (i < s2.length) {\n resultArray.push(s2.charAt(i));\n }\n }\n\n return resultArray.join('');\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DEFAULT_VAPID_KEY, FCM_MSG } from '../util/constants';\nimport {\n MessagePayloadInternal,\n MessageType,\n NotificationPayloadInternal\n} from '../interfaces/internal-message-payload';\nimport {\n NotificationEvent,\n PushEvent,\n PushSubscriptionChangeEvent,\n ServiceWorkerGlobalScope,\n WindowClient\n} from '../util/sw-types';\nimport {\n deleteTokenInternal,\n getTokenInternal\n} from '../internals/token-manager';\n\nimport { MessagingService } from '../messaging-service';\nimport { dbGet } from '../internals/idb-manager';\nimport { externalizePayload } from '../helpers/externalizePayload';\nimport { isConsoleMessage } from '../helpers/is-console-message';\nimport { sleep } from '../helpers/sleep';\nimport { stageLog } from '../helpers/logToFirelog';\n\n// maxActions is an experimental property and not part of the official\n// TypeScript interface\n// https://developer.mozilla.org/en-US/docs/Web/API/Notification/maxActions\ninterface NotificationExperimental extends Notification {\n maxActions?: number;\n}\n\n// Let TS know that this is a service worker\ndeclare const self: ServiceWorkerGlobalScope;\n\nexport async function onSubChange(\n event: PushSubscriptionChangeEvent,\n messaging: MessagingService\n): Promise<void> {\n const { newSubscription } = event;\n if (!newSubscription) {\n // Subscription revoked, delete token\n await deleteTokenInternal(messaging);\n return;\n }\n\n const tokenDetails = await dbGet(messaging.firebaseDependencies);\n await deleteTokenInternal(messaging);\n\n messaging.vapidKey =\n tokenDetails?.subscriptionOptions?.vapidKey ?? DEFAULT_VAPID_KEY;\n await getTokenInternal(messaging);\n}\n\nexport async function onPush(\n event: PushEvent,\n messaging: MessagingService\n): Promise<void> {\n const internalPayload = getMessagePayloadInternal(event);\n if (!internalPayload) {\n // Failed to get parsed MessagePayload from the PushEvent. Skip handling the push.\n return;\n }\n\n // log to Firelog with user consent\n if (messaging.deliveryMetricsExportedToBigQueryEnabled) {\n await stageLog(messaging, internalPayload);\n }\n\n // foreground handling: eventually passed to onMessage hook\n const clientList = await getClientList();\n if (hasVisibleClients(clientList)) {\n return sendMessagePayloadInternalToWindows(clientList, internalPayload);\n }\n\n // background handling: display if possible and pass to onBackgroundMessage hook\n if (!!internalPayload.notification) {\n await showNotification(wrapInternalPayload(internalPayload));\n }\n\n if (!messaging) {\n return;\n }\n\n if (!!messaging.onBackgroundMessageHandler) {\n const payload = externalizePayload(internalPayload);\n\n if (typeof messaging.onBackgroundMessageHandler === 'function') {\n await messaging.onBackgroundMessageHandler(payload);\n } else {\n messaging.onBackgroundMessageHandler.next(payload);\n }\n }\n}\n\nexport async function onNotificationClick(\n event: NotificationEvent\n): Promise<void> {\n const internalPayload: MessagePayloadInternal =\n event.notification?.data?.[FCM_MSG];\n\n if (!internalPayload) {\n return;\n } else if (event.action) {\n // User clicked on an action button. This will allow developers to act on action button clicks\n // by using a custom onNotificationClick listener that they define.\n return;\n }\n\n // Prevent other listeners from receiving the event\n event.stopImmediatePropagation();\n event.notification.close();\n\n // Note clicking on a notification with no link set will focus the Chrome's current tab.\n const link = getLink(internalPayload);\n if (!link) {\n return;\n }\n\n // FM should only open/focus links from app's origin.\n const url = new URL(link, self.location.href);\n const originUrl = new URL(self.location.origin);\n\n if (url.host !== originUrl.host) {\n return;\n }\n\n let client = await getWindowClient(url);\n\n if (!client) {\n client = await self.clients.openWindow(link);\n\n // Wait three seconds for the client to initialize and set up the message handler so that it\n // can receive the message.\n await sleep(3000);\n } else {\n client = await client.focus();\n }\n\n if (!client) {\n // Window Client will not be returned if it's for a third party origin.\n return;\n }\n\n internalPayload.messageType = MessageType.NOTIFICATION_CLICKED;\n internalPayload.isFirebaseMessaging = true;\n return client.postMessage(internalPayload);\n}\n\nfunction wrapInternalPayload(\n internalPayload: MessagePayloadInternal\n): NotificationPayloadInternal {\n const wrappedInternalPayload: NotificationPayloadInternal = {\n ...(internalPayload.notification as unknown as NotificationPayloadInternal)\n };\n\n // Put the message payload under FCM_MSG name so we can identify the notification as being an FCM\n // notification vs a notification from somewhere else (i.e. normal web push or developer generated\n // notification).\n wrappedInternalPayload.data = {\n [FCM_MSG]: internalPayload\n };\n\n return wrappedInternalPayload;\n}\n\nfunction getMessagePayloadInternal({\n data\n}: PushEvent): MessagePayloadInternal | null {\n if (!data) {\n return null;\n }\n\n try {\n return data.json();\n } catch (err) {\n // Not JSON so not an FCM message.\n return null;\n }\n}\n\n/**\n * @param url The URL to look for when focusing a client.\n * @return Returns an existing window client or a newly opened WindowClient.\n */\nasync function getWindowClient(url: URL): Promise<WindowClient | null> {\n const clientList = await getClientList();\n\n for (const client of clientList) {\n const clientUrl = new URL(client.url, self.location.href);\n\n if (url.host === clientUrl.host) {\n return client;\n }\n }\n\n return null;\n}\n\n/**\n * @returns If there is currently a visible WindowClient, this method will resolve to true,\n * otherwise false.\n */\nfunction hasVisibleClients(clientList: WindowClient[]): boolean {\n return clientList.some(\n client =>\n client.visibilityState === 'visible' &&\n // Ignore chrome-extension clients as that matches the background pages of extensions, which\n // are always considered visible for some reason.\n !client.url.startsWith('chrome-extension://')\n );\n}\n\nfunction sendMessagePayloadInternalToWindows(\n clientList: WindowClient[],\n internalPayload: MessagePayloadInternal\n): void {\n internalPayload.isFirebaseMessaging = true;\n internalPayload.messageType = MessageType.PUSH_RECEIVED;\n\n for (const client of clientList) {\n client.postMessage(internalPayload);\n }\n}\n\nfunction getClientList(): Promise<WindowClient[]> {\n return self.clients.matchAll({\n type: 'window',\n includeUncontrolled: true\n // TS doesn't know that \"type: 'window'\" means it'll return WindowClient[]\n }) as Promise<WindowClient[]>;\n}\n\nfunction showNotification(\n notificationPayloadInternal: NotificationPayloadInternal\n): Promise<void> {\n // Note: Firefox does not support the maxActions property.\n // https://developer.mozilla.org/en-US/docs/Web/API/notification/maxActions\n const { actions } = notificationPayloadInternal;\n const { maxActions } = Notification as unknown as NotificationExperimental;\n if (actions && maxActions && actions.length > maxActions) {\n console.warn(\n `This browser only supports ${maxActions} actions. The remaining actions will not be displayed.`\n );\n }\n\n return self.registration.showNotification(\n /* title= */ notificationPayloadInternal.title ?? '',\n notificationPayloadInternal\n );\n}\n\nfunction getLink(payload: MessagePayloadInternal): string | null {\n // eslint-disable-next-line camelcase\n const link = payload.fcmOptions?.link ?? payload.notification?.click_action;\n if (link) {\n return link;\n }\n\n if (isConsoleMessage(payload.data)) {\n // Notification created in the Firebase Console. Redirect to origin.\n return self.location.origin;\n } else {\n return null;\n }\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ERROR_FACTORY, ErrorCode } from '../util/errors';\nimport { FirebaseApp, FirebaseOptions } from '@firebase/app';\n\nimport { AppConfig } from '../interfaces/app-config';\nimport { FirebaseError } from '@firebase/util';\n\nexport function extractAppConfig(app: FirebaseApp): AppConfig {\n if (!app || !app.options) {\n throw getMissingValueError('App Configuration Object');\n }\n\n if (!app.name) {\n throw getMissingValueError('App Name');\n }\n\n // Required app config keys\n const configKeys: ReadonlyArray<keyof FirebaseOptions> = [\n 'projectId',\n 'apiKey',\n 'appId',\n 'messagingSenderId'\n ];\n\n const { options } = app;\n for (const keyName of configKeys) {\n if (!options[keyName]) {\n throw getMissingValueError(keyName);\n }\n }\n\n return {\n appName: app.name,\n projectId: options.projectId!,\n apiKey: options.apiKey!,\n appId: options.appId!,\n senderId: options.messagingSenderId!\n };\n}\n\nfunction getMissingValueError(valueName: string): FirebaseError {\n return ERROR_FACTORY.create(ErrorCode.MISSING_APP_CONFIG_VALUES, {\n valueName\n });\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FirebaseApp, _FirebaseService } from '@firebase/app';\nimport { MessagePayload, NextFn, Observer } from './interfaces/public-types';\n\nimport { FirebaseAnalyticsInternalName } from '@firebase/analytics-interop-types';\nimport { FirebaseInternalDependencies } from './interfaces/internal-dependencies';\nimport { LogEvent } from './interfaces/logging-types';\nimport { Provider } from '@firebase/component';\nimport { _FirebaseInstallationsInternal } from '@firebase/installations';\nimport { extractAppConfig } from './helpers/extract-app-config';\n\nexport class MessagingService implements _FirebaseService {\n readonly app!: FirebaseApp;\n readonly firebaseDependencies!: FirebaseInternalDependencies;\n\n swRegistration?: ServiceWorkerRegistration;\n vapidKey?: string;\n // logging is only done with end user consent. Default to false.\n deliveryMetricsExportedToBigQueryEnabled: boolean = false;\n\n onBackgroundMessageHandler:\n | NextFn<MessagePayload>\n | Observer<MessagePayload>\n | null = null;\n\n onMessageHandler: NextFn<MessagePayload> | Observer<MessagePayload> | null =\n null;\n\n logEvents: LogEvent[] = [];\n isLogServiceStarted: boolean = false;\n\n constructor(\n app: FirebaseApp,\n installations: _FirebaseInstallationsInternal,\n analyticsProvider: Provider<FirebaseAnalyticsInternalName>\n ) {\n const appConfig = extractAppConfig(app);\n\n this.firebaseDependencies = {\n app,\n appConfig,\n installations,\n analyticsProvider\n };\n }\n\n _delete(): Promise<void> {\n return Promise.resolve();\n }\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Component,\n ComponentContainer,\n ComponentType,\n InstanceFactory\n} from '@firebase/component';\nimport {\n onNotificationClick,\n onPush,\n onSubChange\n} from '../listeners/sw-listeners';\n\nimport { GetTokenOptions } from '../interfaces/public-types';\nimport { MessagingInternal } from '@firebase/messaging-interop-types';\nimport { MessagingService } from '../messaging-service';\nimport { ServiceWorkerGlobalScope } from '../util/sw-types';\nimport { _registerComponent, registerVersion } from '@firebase/app';\nimport { getToken } from '../api/getToken';\nimport { messageEventListener } from '../listeners/window-listener';\n\nimport { name, version } from '../../package.json';\n\nconst WindowMessagingFactory: InstanceFactory<'messaging'> = (\n container: ComponentContainer\n) => {\n const messaging = new MessagingService(\n container.getProvider('app').getImmediate(),\n container.getProvider('installations-internal').getImmediate(),\n container.getProvider('analytics-internal')\n );\n\n navigator.serviceWorker.addEventListener('message', e =>\n messageEventListener(messaging as MessagingService, e)\n );\n\n return messaging;\n};\n\nconst WindowMessagingInternalFactory: InstanceFactory<'messaging-internal'> = (\n container: ComponentContainer\n) => {\n const messaging = container\n .getProvider('messaging')\n .getImmediate() as MessagingService;\n\n const messagingInternal: MessagingInternal = {\n getToken: (options?: GetTokenOptions) => getToken(messaging, options)\n };\n\n return messagingInternal;\n};\n\ndeclare const self: ServiceWorkerGlobalScope;\nconst SwMessagingFactory: InstanceFactory<'messaging'> = (\n container: ComponentContainer\n) => {\n const messaging = new MessagingService(\n container.getProvider('app').getImmediate(),\n container.getProvider('installations-internal').getImmediate(),\n container.getProvider('analytics-internal')\n );\n\n self.addEventListener('push', e => {\n e.waitUntil(onPush(e, messaging as MessagingService));\n });\n self.addEventListener('pushsubscriptionchange', e => {\n e.waitUntil(onSubChange(e, messaging as MessagingService));\n });\n self.addEventListener('notificationclick', e => {\n e.waitUntil(onNotificationClick(e));\n });\n\n return messaging;\n};\n\nexport function registerMessagingInWindow(): void {\n _registerComponent(\n new Component('messaging', WindowMessagingFactory, ComponentType.PUBLIC)\n );\n\n _registerComponent(\n new Component(\n 'messaging-internal',\n WindowMessagingInternalFactory,\n ComponentType.PRIVATE\n )\n );\n\n registerVersion(name, version);\n // BUILD_TARGET will be replaced by values like esm, cjs, etc during the compilation\n registerVersion(name, version, '__BUILD_TARGET__');\n}\n\n/**\n * The messaging instance registered in sw is named differently than that of in client. This is\n * because both `registerMessagingInWindow` and `registerMessagingInSw` would be called in\n * `messaging-compat` and component with the same name can only be registered once.\n */\nexport function registerMessagingInSw(): void {\n _registerComponent(\n new Component('messaging-sw', SwMessagingFactory, ComponentType.PUBLIC)\n );\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n areCookiesEnabled,\n isIndexedDBAvailable,\n validateIndexedDBOpenable\n} from '@firebase/util';\n\n/**\n * Checks if all required APIs exist in the browser.\n * @returns a Promise that resolves to a boolean.\n *\n * @public\n */\nexport async function isWindowSupported(): Promise<boolean> {\n try {\n // This throws if open() is unsupported, so adding it to the conditional\n // statement below can cause an uncaught error.\n await validateIndexedDBOpenable();\n } catch (e) {\n return false;\n }\n // firebase-js-sdk/issues/2393 reveals that idb#open in Safari iframe and Firefox private browsing\n // might be prohibited to run. In these contexts, an error would be thrown during the messaging\n // instantiating phase, informing the developers to import/call isSupported for special handling.\n return (\n typeof window !== 'undefined' &&\n isIndexedDBAvailable() &&\n areCookiesEnabled() &&\n 'serviceWorker' in navigator &&\n 'PushManager' in window &&\n 'Notification' in window &&\n 'fetch' in window &&\n ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&\n PushSubscription.prototype.hasOwnProperty('getKey')\n );\n}\n\n/**\n * Checks whether all required APIs exist within SW Context\n * @returns a Promise that resolves to a boolean.\n *\n * @public\n */\nexport async function isSwSupported(): Promise<boolean> {\n // firebase-js-sdk/issues/2393 reveals that idb#open in Safari iframe and Firefox private browsing\n // might be prohibited to run. In these contexts, an error would be thrown during the messaging\n // instantiating phase, informing the developers to import/call isSupported for special handling.\n return (\n isIndexedDBAvailable() &&\n (await validateIndexedDBOpenable()) &&\n 'PushManager' in self &&\n 'Notification' in self &&\n ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&\n PushSubscription.prototype.hasOwnProperty('getKey')\n );\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ERROR_FACTORY, ErrorCode } from '../util/errors';\n\nimport {\n MessagePayload,\n NextFn,\n Observer,\n Unsubscribe\n} from '../interfaces/public-types';\nimport { MessagingService } from '../messaging-service';\n\nexport function onBackgroundMessage(\n messaging: MessagingService,\n nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>\n): Unsubscribe {\n if (self.document !== undefined) {\n throw ERROR_FACTORY.create(ErrorCode.AVAILABLE_IN_SW);\n }\n\n messaging.onBackgroundMessageHandler = nextOrObserver;\n\n return () => {\n messaging.onBackgroundMessageHandler = null;\n };\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Messaging } from '../interfaces/public-types';\nimport { MessagingService } from '../messaging-service';\n\nexport function _setDeliveryMetricsExportedToBigQueryEnabled(\n messaging: Messaging,\n enable: boolean\n): void {\n (messaging as MessagingService).deliveryMetricsExportedToBigQueryEnabled =\n enable;\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ERROR_FACTORY, ErrorCode } from './util/errors';\nimport { FirebaseApp, _getProvider, getApp } from '@firebase/app';\nimport {\n GetTokenOptions,\n MessagePayload,\n Messaging\n} from './interfaces/public-types';\nimport {\n NextFn,\n Observer,\n Unsubscribe,\n getModularInstance\n} from '@firebase/util';\nimport { isSwSupported, isWindowSupported } from './api/isSupported';\n\nimport { MessagingService } from './messaging-service';\nimport { deleteToken as _deleteToken } from './api/deleteToken';\nimport { getToken as _getToken } from './api/getToken';\nimport { onBackgroundMessage as _onBackgroundMessage } from './api/onBackgroundMessage';\nimport { onMessage as _onMessage } from './api/onMessage';\nimport { _setDeliveryMetricsExportedToBigQueryEnabled } from './api/setDeliveryMetricsExportedToBigQueryEnabled';\n\n/**\n * Retrieves a Firebase Cloud Messaging instance.\n *\n * @returns The Firebase Cloud Messaging instance associated with the provided firebase app.\n *\n * @public\n */\nexport function getMessagingInWindow(app: FirebaseApp = getApp()): Messaging {\n // Conscious decision to make this async check non-blocking during the messaging instance\n // initialization phase for performance consideration. An error would be thrown latter for\n // developer's information. Developers can then choose to import and call `isSupported` for\n // special handling.\n isWindowSupported().then(\n isSupported => {\n // If `isWindowSupported()` resolved, but returned false.\n if (!isSupported) {\n throw ERROR_FACTORY.create(ErrorCode.UNSUPPORTED_BROWSER);\n }\n },\n _ => {\n // If `isWindowSupported()` rejected.\n throw ERROR_FACTORY.create(ErrorCode.INDEXED_DB_UNSUPPORTED);\n }\n );\n return _getProvider(getModularInstance(app), 'messaging').getImmediate();\n}\n\n/**\n * Retrieves a Firebase Cloud Messaging instance.\n *\n * @returns The Firebase Cloud Messaging instance associated with the provided firebase app.\n *\n * @public\n */\nexport function getMessagingInSw(app: FirebaseApp = getApp()): Messaging {\n // Conscious decision to make this async check non-blocking during the messaging instance\n // initialization phase for performance consideration. An error would be thrown latter for\n // developer's information. Developers can then choose to import and call `isSupported` for\n // special handling.\n isSwSupported().then(\n isSupported => {\n // If `isSwSupported()` resolved, but returned false.\n if (!isSupported) {\n throw ERROR_FACTORY.create(ErrorCode.UNSUPPORTED_BROWSER);\n }\n },\n _ => {\n // If `isSwSupported()` rejected.\n throw ERROR_FACTORY.create(ErrorCode.INDEXED_DB_UNSUPPORTED);\n }\n );\n return _getProvider(getModularInstance(app), 'messaging-sw').getImmediate();\n}\n\n/**\n * Subscribes the {@link Messaging} instance to push notifications. Returns a Firebase Cloud\n * Messaging registration token that can be used to send push messages to that {@link Messaging}\n * instance.\n *\n * If notification permission isn't already granted, this method asks the user for permission. The\n * returned promise rejects if the user does not allow the app to show notifications.\n *\n * @param messaging - The {@link Messaging} instance.\n * @param options - Provides an optional vapid key and an optional service worker registration.\n *\n * @returns The promise resolves with an FCM registration token.\n *\n * @public\n */\nexport async function getToken(\n messaging: Messaging,\n options?: GetTokenOptions\n): Promise<string> {\n messaging = getModularInstance(messaging);\n return _getToken(messaging as MessagingService, options);\n}\n\n/**\n * Deletes the registration token associated with this {@link Messaging} instance and unsubscribes\n * the {@link Messaging} instance from the push subscription.\n *\n * @param messaging - The {@link Messaging} instance.\n *\n * @returns The promise resolves when the token has been successfully deleted.\n *\n * @public\n */\nexport function deleteToken(messaging: Messaging): Promise<boolean> {\n messaging = getModularInstance(messaging);\n return _deleteToken(messaging as MessagingService);\n}\n\n/**\n * When a push message is received and the user is currently on a page for your origin, the\n * message is passed to the page and an `onMessage()` event is dispatched with the payload of\n * the push message.\n *\n *\n * @param messaging - The {@link Messaging} instance.\n * @param nextOrObserver - This function, or observer object with `next` defined,\n * is called when a message is received and the user is currently viewing your page.\n * @returns To stop listening for messages execute this returned function.\n *\n * @public\n */\nexport function onMessage(\n messaging: Messaging,\n nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>\n): Unsubscribe {\n messaging = getModularInstance(messaging);\n return _onMessage(messaging as MessagingService, nextOrObserver);\n}\n\n/**\n * Called when a message is received while the app is in the background. An app is considered to be\n * in the background if no active window is displayed.\n *\n * @param messaging - The {@link Messaging} instance.\n * @param nextOrObserver - This function, or observer object with `next` defined, is called when a\n * message is received and the app is currently in the background.\n *\n * @returns To stop listening for messages execute this returned function\n *\n * @public\n */\nexport function onBackgroundMessage(\n messaging: Messaging,\n nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>\n): Unsubscribe {\n messaging = getModularInstance(messaging);\n return _onBackgroundMessage(messaging as MessagingService, nextOrObserver);\n}\n\n/**\n * Enables or disables Firebase Cloud Messaging message delivery metrics export to BigQuery. By\n * default, message delivery metrics are not exported to BigQuery. Use this method to enable or\n * disable the export at runtime.\n *\n * @param messaging - The `FirebaseMessaging` instance.\n * @param enable - Whether Firebase Cloud Messaging should export message delivery metrics to\n * BigQuery.\n *\n * @public\n */\nexport function experimentalSetDeliveryMetricsExportedToBigQueryEnabled(\n messaging: Messaging,\n enable: boolean\n): void {\n messaging = getModularInstance(messaging);\n return _setDeliveryMetricsExportedToBigQueryEnabled(messaging, enable);\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport '@firebase/installations';\n\nimport { Messaging } from './interfaces/public-types';\nimport { registerMessagingInSw } from './helpers/register';\n\nexport * from './interfaces/public-types';\nexport {\n onBackgroundMessage,\n getMessagingInSw as getMessaging,\n experimentalSetDeliveryMetricsExportedToBigQueryEnabled\n} from './api';\nexport { isSwSupported as isSupported } from './api/isSupported';\n\ndeclare module '@firebase/component' {\n interface NameServiceMapping {\n 'messaging-sw': Messaging;\n }\n}\n\nregisterMessagingInSw();\n"],"names":["MessageType","onBackgroundMessage","_onBackgroundMessage"],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAKI,MAAM,iBAAiB,GAC5B,yFAAyF,CAAC;AAErF,MAAM,QAAQ,GAAG,4CAA4C,CAAC;AAErE;AACO,MAAM,OAAO,GAAG,SAAS,CAAC;AAE1B,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAgBrD;AACO,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAEzC,IAAYA,aAGX,CAAA;AAHD,CAAA,UAAY,WAAW,EAAA;AACrB,IAAA,WAAA,CAAA,WAAA,CAAA,cAAA,CAAA,GAAA,CAAA,CAAA,GAAA,cAAgB,CAAA;AAChB,IAAA,WAAA,CAAA,WAAA,CAAA,sBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,sBAAwB,CAAA;AAC1B,CAAC,EAHWA,aAAW,KAAXA,aAA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diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/package.json b/frontend-old/node_modules/@firebase/messaging/dist/esm/package.json
new file mode 100644
index 0000000..7c34deb
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/package.json
@@ -0,0 +1 @@
+{"type":"module"} \ No newline at end of file
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/api.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/api.d.ts
new file mode 100644
index 0000000..b2f938b
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/api.d.ts
@@ -0,0 +1,101 @@
+/**
+ * @license
+ * Copyright 2017 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { FirebaseApp } from '@firebase/app';
+import { GetTokenOptions, MessagePayload, Messaging } from './interfaces/public-types';
+import { NextFn, Observer, Unsubscribe } from '@firebase/util';
+/**
+ * Retrieves a Firebase Cloud Messaging instance.
+ *
+ * @returns The Firebase Cloud Messaging instance associated with the provided firebase app.
+ *
+ * @public
+ */
+export declare function getMessagingInWindow(app?: FirebaseApp): Messaging;
+/**
+ * Retrieves a Firebase Cloud Messaging instance.
+ *
+ * @returns The Firebase Cloud Messaging instance associated with the provided firebase app.
+ *
+ * @public
+ */
+export declare function getMessagingInSw(app?: FirebaseApp): Messaging;
+/**
+ * Subscribes the {@link Messaging} instance to push notifications. Returns a Firebase Cloud
+ * Messaging registration token that can be used to send push messages to that {@link Messaging}
+ * instance.
+ *
+ * If notification permission isn't already granted, this method asks the user for permission. The
+ * returned promise rejects if the user does not allow the app to show notifications.
+ *
+ * @param messaging - The {@link Messaging} instance.
+ * @param options - Provides an optional vapid key and an optional service worker registration.
+ *
+ * @returns The promise resolves with an FCM registration token.
+ *
+ * @public
+ */
+export declare function getToken(messaging: Messaging, options?: GetTokenOptions): Promise<string>;
+/**
+ * Deletes the registration token associated with this {@link Messaging} instance and unsubscribes
+ * the {@link Messaging} instance from the push subscription.
+ *
+ * @param messaging - The {@link Messaging} instance.
+ *
+ * @returns The promise resolves when the token has been successfully deleted.
+ *
+ * @public
+ */
+export declare function deleteToken(messaging: Messaging): Promise<boolean>;
+/**
+ * When a push message is received and the user is currently on a page for your origin, the
+ * message is passed to the page and an `onMessage()` event is dispatched with the payload of
+ * the push message.
+ *
+ *
+ * @param messaging - The {@link Messaging} instance.
+ * @param nextOrObserver - This function, or observer object with `next` defined,
+ * is called when a message is received and the user is currently viewing your page.
+ * @returns To stop listening for messages execute this returned function.
+ *
+ * @public
+ */
+export declare function onMessage(messaging: Messaging, nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>): Unsubscribe;
+/**
+ * Called when a message is received while the app is in the background. An app is considered to be
+ * in the background if no active window is displayed.
+ *
+ * @param messaging - The {@link Messaging} instance.
+ * @param nextOrObserver - This function, or observer object with `next` defined, is called when a
+ * message is received and the app is currently in the background.
+ *
+ * @returns To stop listening for messages execute this returned function
+ *
+ * @public
+ */
+export declare function onBackgroundMessage(messaging: Messaging, nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>): Unsubscribe;
+/**
+ * Enables or disables Firebase Cloud Messaging message delivery metrics export to BigQuery. By
+ * default, message delivery metrics are not exported to BigQuery. Use this method to enable or
+ * disable the export at runtime.
+ *
+ * @param messaging - The `FirebaseMessaging` instance.
+ * @param enable - Whether Firebase Cloud Messaging should export message delivery metrics to
+ * BigQuery.
+ *
+ * @public
+ */
+export declare function experimentalSetDeliveryMetricsExportedToBigQueryEnabled(messaging: Messaging, enable: boolean): void;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/deleteToken.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/deleteToken.d.ts
new file mode 100644
index 0000000..569c729
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/deleteToken.d.ts
@@ -0,0 +1,18 @@
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { MessagingService } from '../messaging-service';
+export declare function deleteToken(messaging: MessagingService): Promise<boolean>;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/getToken.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/getToken.d.ts
new file mode 100644
index 0000000..564d570
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/getToken.d.ts
@@ -0,0 +1,19 @@
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { MessagingService } from '../messaging-service';
+import { GetTokenOptions } from '../interfaces/public-types';
+export declare function getToken(messaging: MessagingService, options?: GetTokenOptions): Promise<string>;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/isSupported.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/isSupported.d.ts
new file mode 100644
index 0000000..635bc29
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/isSupported.d.ts
@@ -0,0 +1,30 @@
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Checks if all required APIs exist in the browser.
+ * @returns a Promise that resolves to a boolean.
+ *
+ * @public
+ */
+export declare function isWindowSupported(): Promise<boolean>;
+/**
+ * Checks whether all required APIs exist within SW Context
+ * @returns a Promise that resolves to a boolean.
+ *
+ * @public
+ */
+export declare function isSwSupported(): Promise<boolean>;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/onBackgroundMessage.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/onBackgroundMessage.d.ts
new file mode 100644
index 0000000..b427b38
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/onBackgroundMessage.d.ts
@@ -0,0 +1,19 @@
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { MessagePayload, NextFn, Observer, Unsubscribe } from '../interfaces/public-types';
+import { MessagingService } from '../messaging-service';
+export declare function onBackgroundMessage(messaging: MessagingService, nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>): Unsubscribe;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/onMessage.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/onMessage.d.ts
new file mode 100644
index 0000000..89ad796
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/onMessage.d.ts
@@ -0,0 +1,19 @@
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { MessagePayload, NextFn, Observer, Unsubscribe } from '../interfaces/public-types';
+import { MessagingService } from '../messaging-service';
+export declare function onMessage(messaging: MessagingService, nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>): Unsubscribe;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/setDeliveryMetricsExportedToBigQueryEnabled.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/setDeliveryMetricsExportedToBigQueryEnabled.d.ts
new file mode 100644
index 0000000..f368339
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/api/setDeliveryMetricsExportedToBigQueryEnabled.d.ts
@@ -0,0 +1,18 @@
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { Messaging } from '../interfaces/public-types';
+export declare function _setDeliveryMetricsExportedToBigQueryEnabled(messaging: Messaging, enable: boolean): void;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/array-base64-translator.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/array-base64-translator.d.ts
new file mode 100644
index 0000000..27e3eab
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/array-base64-translator.d.ts
@@ -0,0 +1,18 @@
+/**
+ * @license
+ * Copyright 2017 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export declare function arrayToBase64(array: Uint8Array | ArrayBuffer): string;
+export declare function base64ToArray(base64String: string): Uint8Array;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/externalizePayload.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/externalizePayload.d.ts
new file mode 100644
index 0000000..efc668b
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/externalizePayload.d.ts
@@ -0,0 +1,19 @@
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { MessagePayload } from '../interfaces/public-types';
+import { MessagePayloadInternal } from '../interfaces/internal-message-payload';
+export declare function externalizePayload(internalPayload: MessagePayloadInternal): MessagePayload;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/extract-app-config.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/extract-app-config.d.ts
new file mode 100644
index 0000000..306196f
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/extract-app-config.d.ts
@@ -0,0 +1,19 @@
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { FirebaseApp } from '@firebase/app';
+import { AppConfig } from '../interfaces/app-config';
+export declare function extractAppConfig(app: FirebaseApp): AppConfig;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/is-console-message.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/is-console-message.d.ts
new file mode 100644
index 0000000..3e53ab1
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/is-console-message.d.ts
@@ -0,0 +1,18 @@
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { ConsoleMessageData } from '../interfaces/internal-message-payload';
+export declare function isConsoleMessage(data: unknown): data is ConsoleMessageData;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/logToFirelog.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/logToFirelog.d.ts
new file mode 100644
index 0000000..64f04cc
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/logToFirelog.d.ts
@@ -0,0 +1,30 @@
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { LogEvent, LogRequest } from '../interfaces/logging-types';
+import { MessagePayloadInternal } from '../interfaces/internal-message-payload';
+import { MessagingService } from '../messaging-service';
+export declare function startLoggingService(messaging: MessagingService): void;
+/**
+ *
+ * @param messaging the messaging instance.
+ * @param offsetInMs this method execute after `offsetInMs` elapsed .
+ */
+export declare function _processQueue(messaging: MessagingService, offsetInMs: number): void;
+export declare function _dispatchLogEvents(messaging: MessagingService): Promise<void>;
+export declare function stageLog(messaging: MessagingService, internalPayload: MessagePayloadInternal): Promise<void>;
+export declare function _createLogRequest(logEventQueue: LogEvent[]): LogRequest;
+export declare function _mergeStrings(s1: string, s2: string): string;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/logToScion.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/logToScion.d.ts
new file mode 100644
index 0000000..400d38c
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/logToScion.d.ts
@@ -0,0 +1,19 @@
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { ConsoleMessageData, MessageType } from '../interfaces/internal-message-payload';
+import { MessagingService } from '../messaging-service';
+export declare function logToScion(messaging: MessagingService, messageType: MessageType, data: ConsoleMessageData): Promise<void>;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/migrate-old-database.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/migrate-old-database.d.ts
new file mode 100644
index 0000000..f1e879b
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/migrate-old-database.d.ts
@@ -0,0 +1,51 @@
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { TokenDetails } from '../interfaces/token-details';
+export interface V2TokenDetails {
+ fcmToken: string;
+ swScope: string;
+ vapidKey: string | Uint8Array;
+ subscription: PushSubscription;
+ fcmSenderId: string;
+ fcmPushSet: string;
+ createTime?: number;
+ endpoint?: string;
+ auth?: string;
+ p256dh?: string;
+}
+export interface V3TokenDetails {
+ fcmToken: string;
+ swScope: string;
+ vapidKey: Uint8Array;
+ fcmSenderId: string;
+ fcmPushSet: string;
+ endpoint: string;
+ auth: ArrayBuffer;
+ p256dh: ArrayBuffer;
+ createTime: number;
+}
+export interface V4TokenDetails {
+ fcmToken: string;
+ swScope: string;
+ vapidKey: Uint8Array;
+ fcmSenderId: string;
+ endpoint: string;
+ auth: ArrayBufferLike;
+ p256dh: ArrayBufferLike;
+ createTime: number;
+}
+export declare function migrateOldDatabase(senderId: string): Promise<TokenDetails | null>;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/register.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/register.d.ts
new file mode 100644
index 0000000..0efe2cd
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/register.d.ts
@@ -0,0 +1,23 @@
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export declare function registerMessagingInWindow(): void;
+/**
+ * The messaging instance registered in sw is named differently than that of in client. This is
+ * because both `registerMessagingInWindow` and `registerMessagingInSw` would be called in
+ * `messaging-compat` and component with the same name can only be registered once.
+ */
+export declare function registerMessagingInSw(): void;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/registerDefaultSw.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/registerDefaultSw.d.ts
new file mode 100644
index 0000000..fe0618e
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/registerDefaultSw.d.ts
@@ -0,0 +1,18 @@
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { MessagingService } from '../messaging-service';
+export declare function registerDefaultSw(messaging: MessagingService): Promise<void>;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/sleep.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/sleep.d.ts
new file mode 100644
index 0000000..f51e6cd
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/sleep.d.ts
@@ -0,0 +1,18 @@
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/** Returns a promise that resolves after given time passes. */
+export declare function sleep(ms: number): Promise<void>;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/updateSwReg.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/updateSwReg.d.ts
new file mode 100644
index 0000000..6e461e6
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/updateSwReg.d.ts
@@ -0,0 +1,18 @@
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { MessagingService } from '../messaging-service';
+export declare function updateSwReg(messaging: MessagingService, swRegistration?: ServiceWorkerRegistration | undefined): Promise<void>;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/updateVapidKey.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/updateVapidKey.d.ts
new file mode 100644
index 0000000..293f9e6
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/helpers/updateVapidKey.d.ts
@@ -0,0 +1,18 @@
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { MessagingService } from '../messaging-service';
+export declare function updateVapidKey(messaging: MessagingService, vapidKey?: string | undefined): Promise<void>;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/index.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/index.d.ts
new file mode 100644
index 0000000..ac3c137
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/index.d.ts
@@ -0,0 +1,32 @@
+/**
+ * The Firebase Cloud Messaging Web SDK.
+ * This SDK does not work in a Node.js environment.
+ *
+ * @packageDocumentation
+ */
+/**
+ * @license
+ * Copyright 2017 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import '@firebase/installations';
+import { Messaging } from './interfaces/public-types';
+export { getToken, deleteToken, onMessage, getMessagingInWindow as getMessaging } from './api';
+export { isWindowSupported as isSupported } from './api/isSupported';
+export * from './interfaces/public-types';
+declare module '@firebase/component' {
+ interface NameServiceMapping {
+ 'messaging': Messaging;
+ }
+}
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/index.sw.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/index.sw.d.ts
new file mode 100644
index 0000000..58ba7fa
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/index.sw.d.ts
@@ -0,0 +1,26 @@
+/**
+ * @license
+ * Copyright 2017 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import '@firebase/installations';
+import { Messaging } from './interfaces/public-types';
+export * from './interfaces/public-types';
+export { onBackgroundMessage, getMessagingInSw as getMessaging, experimentalSetDeliveryMetricsExportedToBigQueryEnabled } from './api';
+export { isSwSupported as isSupported } from './api/isSupported';
+declare module '@firebase/component' {
+ interface NameServiceMapping {
+ 'messaging-sw': Messaging;
+ }
+}
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/app-config.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/app-config.d.ts
new file mode 100644
index 0000000..6d74827
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/app-config.d.ts
@@ -0,0 +1,24 @@
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export interface AppConfig {
+ readonly appName: string;
+ readonly projectId: string;
+ readonly apiKey: string;
+ readonly appId: string;
+ /** Only used for old DB migration. */
+ readonly senderId: string;
+}
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/internal-dependencies.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/internal-dependencies.d.ts
new file mode 100644
index 0000000..05e6d28
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/internal-dependencies.d.ts
@@ -0,0 +1,27 @@
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { AppConfig } from './app-config';
+import { FirebaseAnalyticsInternalName } from '@firebase/analytics-interop-types';
+import { FirebaseApp } from '@firebase/app';
+import { Provider } from '@firebase/component';
+import { _FirebaseInstallationsInternal } from '@firebase/installations';
+export interface FirebaseInternalDependencies {
+ app: FirebaseApp;
+ appConfig: AppConfig;
+ installations: _FirebaseInstallationsInternal;
+ analyticsProvider: Provider<FirebaseAnalyticsInternalName>;
+}
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/internal-message-payload.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/internal-message-payload.d.ts
new file mode 100644
index 0000000..ce7b48c
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/internal-message-payload.d.ts
@@ -0,0 +1,65 @@
+/**
+ * @license
+ * Copyright 2018 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+import { CONSOLE_CAMPAIGN_ANALYTICS_ENABLED, CONSOLE_CAMPAIGN_ID, CONSOLE_CAMPAIGN_NAME, CONSOLE_CAMPAIGN_TIME } from '../util/constants';
+export interface MessagePayloadInternal {
+ notification?: NotificationPayloadInternal;
+ data?: unknown;
+ fcmOptions?: FcmOptionsInternal;
+ messageType?: MessageType;
+ isFirebaseMessaging?: boolean;
+ from: string;
+ fcmMessageId: string;
+ productId: number;
+ collapse_key: string;
+}
+interface NotificationAction {
+ action: string;
+ icon?: string;
+ title: string;
+}
+/**
+ * This interface defines experimental properties of NotificationOptions, that are not part of
+ * the interface in the generated DOM types at https://github.com/microsoft/TypeScript-DOM-lib-generator/blob/179bdd84a944933a3103f29c2274c9f5a857b693/baselines/dom.generated.d.ts#L1012
+ * https://developer.mozilla.org/en-US/docs/Web/API/Notification
+ */
+interface NotificationOptionsExperimental extends NotificationOptions {
+ readonly maxActions?: number;
+ readonly actions?: NotificationAction[];
+ readonly image?: string;
+ readonly renotify?: boolean;
+ readonly timestamp?: EpochTimeStamp;
+ readonly vibrate?: VibratePattern;
+}
+export interface NotificationPayloadInternal extends NotificationOptionsExperimental {
+ title: string;
+ click_action?: string;
+ icon?: string;
+}
+export interface FcmOptionsInternal {
+ link?: string;
+ analytics_label?: string;
+}
+export declare enum MessageType {
+ PUSH_RECEIVED = "push-received",
+ NOTIFICATION_CLICKED = "notification-clicked"
+}
+/** Additional data of a message sent from the FN Console. */
+export interface ConsoleMessageData {
+ [CONSOLE_CAMPAIGN_ID]: string;
+ [CONSOLE_CAMPAIGN_TIME]: string;
+ [CONSOLE_CAMPAIGN_NAME]?: string;
+ [CONSOLE_CAMPAIGN_ANALYTICS_ENABLED]?: '1';
+}
+export {};
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/logging-types.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/logging-types.d.ts
new file mode 100644
index 0000000..6e09f66
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/logging-types.d.ts
@@ -0,0 +1,60 @@
+/**
+ * @license
+ * Copyright 2021 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+export interface FcmEvent {
+ project_number: string;
+ message_id: string;
+ instance_id: string;
+ message_type: string;
+ sdk_platform: string;
+ package_name: string;
+ collapse_key: string;
+ event: string;
+ analytics_label?: string;
+}
+/**
+ * A LogRequest represents a batched collection of loggable events sent to firelog, each event to be
+ * processed and sent to Sawmill. Defined as in proto/clientanalytics.proto#LogRequest
+ */
+export interface LogRequest {
+ log_source: string;
+ log_event: LogEvent[];
+}
+export interface LogEvent {
+ event_time_ms: string;
+ source_extension_json_proto3: string;
+ compliance_data: ComplianceData;
+}
+export interface ComplianceData {
+ privacy_context: ExternalPrivacyContext;
+}
+export interface ExternalPrivacyContext {
+ prequest: ExternalPRequestContext;
+}
+export interface ExternalPRequestContext {
+ origin_associated_product_id: number;
+}
+export interface LogResponse {
+ nextRequestWaitMillis: number;
+ logResponseDetails: LogResponseDetails[];
+}
+interface LogResponseDetails {
+ responseAction: UserResponse;
+}
+export declare const enum UserResponse {
+ RESPONSE_ACTION_UNKNOWN = "RESPONSE_ACTION_UNKNOWN",
+ RETRY_REQUEST_LATER = "RETRY_REQUEST_LATER",
+ DELETE_REQUEST = "DELETE_REQUEST"
+}
+export {};
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/public-types.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/public-types.d.ts
new file mode 100644
index 0000000..56019e4
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/public-types.d.ts
@@ -0,0 +1,144 @@
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { FirebaseApp } from '@firebase/app';
+/**
+ * Display notification details. Details are sent through the
+ * {@link https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#notification | Send API}.
+ *
+ * @public
+ */
+export interface NotificationPayload {
+ /**
+ * The notification's title.
+ */
+ title?: string;
+ /**
+ * The notification's body text.
+ */
+ body?: string;
+ /**
+ * The URL of an image that is downloaded on the device and displayed in the notification.
+ */
+ image?: string;
+ /**
+ * The URL to use for the notification's icon. If you don't send this key in the request,
+ * FCM displays the launcher icon specified in your app manifest.
+ */
+ icon?: string;
+}
+/**
+ * Options for features provided by the FCM SDK for Web. See {@link
+ * https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#webpushfcmoptions |
+ * WebpushFcmOptions}.
+ *
+ * @public
+ */
+export interface FcmOptions {
+ /**
+ * The link to open when the user clicks on the notification.
+ */
+ link?: string;
+ /**
+ * The label associated with the message's analytics data.
+ */
+ analyticsLabel?: string;
+}
+/**
+ * Message payload that contains the notification payload that is represented with
+ * {@link NotificationPayload} and the data payload that contains an arbitrary
+ * number of key-value pairs sent by developers through the
+ * {@link https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#notification | Send API}.
+ *
+ * @public
+ */
+export interface MessagePayload {
+ /**
+ * {@inheritdoc NotificationPayload}
+ */
+ notification?: NotificationPayload;
+ /**
+ * Arbitrary key/value payload.
+ */
+ data?: {
+ [key: string]: string;
+ };
+ /**
+ * {@inheritdoc FcmOptions}
+ */
+ fcmOptions?: FcmOptions;
+ /**
+ * The sender of this message.
+ */
+ from: string;
+ /**
+ * The collapse key of the message. See
+ * {@link https://firebase.google.com/docs/cloud-messaging/concept-options#collapsible_and_non-collapsible_messages | Non-collapsible and collapsible messages}
+ */
+ collapseKey: string;
+ /**
+ * The message ID of a message.
+ */
+ messageId: string;
+}
+/**
+ * Options for {@link getToken}.
+ *
+ * @public
+ */
+export interface GetTokenOptions {
+ /**
+ * The public server key provided to push services. The key is used to
+ * authenticate push subscribers to receive push messages only from sending servers that hold
+ * the corresponding private key. If it is not provided, a default VAPID key is used. Note that some
+ * push services (Chrome Push Service) require a non-default VAPID key. Therefore, it is recommended
+ * to generate and import a VAPID key for your project with
+ * {@link https://firebase.google.com/docs/cloud-messaging/js/client#configure_web_credentials_in_your_app | Configure Web Credentials with FCM}.
+ * See
+ * {@link https://developers.google.com/web/fundamentals/push-notifications/web-push-protocol | The Web Push Protocol}
+ * for details on web push services.
+ */
+ vapidKey?: string;
+ /**
+ * The service worker registration for receiving push
+ * messaging. If the registration is not provided explicitly, you need to have a
+ * `firebase-messaging-sw.js` at your root location. See
+ * {@link https://firebase.google.com/docs/cloud-messaging/js/client#access_the_registration_token | Access the registration token}
+ * for more details.
+ */
+ serviceWorkerRegistration?: ServiceWorkerRegistration;
+}
+/**
+ * Public interface of the Firebase Cloud Messaging SDK.
+ *
+ * @public
+ */
+export interface Messaging {
+ /**
+ * The {@link @firebase/app#FirebaseApp} this `Messaging` instance is associated with.
+ */
+ app: FirebaseApp;
+}
+/**
+ * @internal
+ */
+export type _FirebaseMessagingName = 'messaging';
+export { NextFn, Observer, Unsubscribe } from '@firebase/util';
+declare module '@firebase/component' {
+ interface NameServiceMapping {
+ 'messaging': Messaging;
+ }
+}
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/token-details.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/token-details.d.ts
new file mode 100644
index 0000000..cab71a3
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/interfaces/token-details.d.ts
@@ -0,0 +1,32 @@
+/**
+ * @license
+ * Copyright 2018 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export interface TokenDetails {
+ token: string;
+ createTime: number;
+ /** Does not exist in Safari since it's not using Push API. */
+ subscriptionOptions?: SubscriptionOptions;
+}
+/**
+ * Additional options and values required by a Push API subscription.
+ */
+export interface SubscriptionOptions {
+ vapidKey: string;
+ swScope: string;
+ endpoint: string;
+ auth: string;
+ p256dh: string;
+}
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/internals/idb-manager.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/internals/idb-manager.d.ts
new file mode 100644
index 0000000..1aeb64f
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/internals/idb-manager.d.ts
@@ -0,0 +1,27 @@
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { FirebaseInternalDependencies } from '../interfaces/internal-dependencies';
+import { TokenDetails } from '../interfaces/token-details';
+export declare const DATABASE_NAME = "firebase-messaging-database";
+/** Gets record(s) from the objectStore that match the given key. */
+export declare function dbGet(firebaseDependencies: FirebaseInternalDependencies): Promise<TokenDetails | undefined>;
+/** Assigns or overwrites the record for the given key with the given value. */
+export declare function dbSet(firebaseDependencies: FirebaseInternalDependencies, tokenDetails: TokenDetails): Promise<TokenDetails>;
+/** Removes record(s) from the objectStore that match the given key. */
+export declare function dbRemove(firebaseDependencies: FirebaseInternalDependencies): Promise<void>;
+/** Deletes the DB. Useful for tests. */
+export declare function dbDelete(): Promise<void>;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/internals/requests.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/internals/requests.d.ts
new file mode 100644
index 0000000..b21909a
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/internals/requests.d.ts
@@ -0,0 +1,35 @@
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { SubscriptionOptions, TokenDetails } from '../interfaces/token-details';
+import { FirebaseInternalDependencies } from '../interfaces/internal-dependencies';
+export interface ApiResponse {
+ token?: string;
+ error?: {
+ message: string;
+ };
+}
+export interface ApiRequestBody {
+ web: {
+ endpoint: string;
+ p256dh: string;
+ auth: string;
+ applicationPubKey?: string;
+ };
+}
+export declare function requestGetToken(firebaseDependencies: FirebaseInternalDependencies, subscriptionOptions: SubscriptionOptions): Promise<string>;
+export declare function requestUpdateToken(firebaseDependencies: FirebaseInternalDependencies, tokenDetails: TokenDetails): Promise<string>;
+export declare function requestDeleteToken(firebaseDependencies: FirebaseInternalDependencies, token: string): Promise<void>;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/internals/token-manager.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/internals/token-manager.d.ts
new file mode 100644
index 0000000..bc4c50b
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/internals/token-manager.d.ts
@@ -0,0 +1,23 @@
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { MessagingService } from '../messaging-service';
+export declare function getTokenInternal(messaging: MessagingService): Promise<string>;
+/**
+ * This method deletes the token from the database, unsubscribes the token from FCM, and unregisters
+ * the push subscription if it exists.
+ */
+export declare function deleteTokenInternal(messaging: MessagingService): Promise<boolean>;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/listeners/sw-listeners.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/listeners/sw-listeners.d.ts
new file mode 100644
index 0000000..576110e
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/listeners/sw-listeners.d.ts
@@ -0,0 +1,21 @@
+/**
+ * @license
+ * Copyright 2017 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { NotificationEvent, PushEvent, PushSubscriptionChangeEvent } from '../util/sw-types';
+import { MessagingService } from '../messaging-service';
+export declare function onSubChange(event: PushSubscriptionChangeEvent, messaging: MessagingService): Promise<void>;
+export declare function onPush(event: PushEvent, messaging: MessagingService): Promise<void>;
+export declare function onNotificationClick(event: NotificationEvent): Promise<void>;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/listeners/window-listener.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/listeners/window-listener.d.ts
new file mode 100644
index 0000000..9412f5d
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/listeners/window-listener.d.ts
@@ -0,0 +1,18 @@
+/**
+ * @license
+ * Copyright 2017 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { MessagingService } from '../messaging-service';
+export declare function messageEventListener(messaging: MessagingService, event: MessageEvent): Promise<void>;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/messaging-service.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/messaging-service.d.ts
new file mode 100644
index 0000000..c622a47
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/messaging-service.d.ts
@@ -0,0 +1,36 @@
+/**
+ * @license
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { FirebaseApp, _FirebaseService } from '@firebase/app';
+import { MessagePayload, NextFn, Observer } from './interfaces/public-types';
+import { FirebaseAnalyticsInternalName } from '@firebase/analytics-interop-types';
+import { FirebaseInternalDependencies } from './interfaces/internal-dependencies';
+import { LogEvent } from './interfaces/logging-types';
+import { Provider } from '@firebase/component';
+import { _FirebaseInstallationsInternal } from '@firebase/installations';
+export declare class MessagingService implements _FirebaseService {
+ readonly app: FirebaseApp;
+ readonly firebaseDependencies: FirebaseInternalDependencies;
+ swRegistration?: ServiceWorkerRegistration;
+ vapidKey?: string;
+ deliveryMetricsExportedToBigQueryEnabled: boolean;
+ onBackgroundMessageHandler: NextFn<MessagePayload> | Observer<MessagePayload> | null;
+ onMessageHandler: NextFn<MessagePayload> | Observer<MessagePayload> | null;
+ logEvents: LogEvent[];
+ isLogServiceStarted: boolean;
+ constructor(app: FirebaseApp, installations: _FirebaseInstallationsInternal, analyticsProvider: Provider<FirebaseAnalyticsInternalName>);
+ _delete(): Promise<void>;
+}
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/compare-headers.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/compare-headers.d.ts
new file mode 100644
index 0000000..1a768d1
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/compare-headers.d.ts
@@ -0,0 +1,22 @@
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import './setup';
+declare class HeadersWithEntries extends Headers {
+ entries?(): Iterable<[string, string]>;
+}
+export declare function compareHeaders(expectedHeaders: HeadersWithEntries, actualHeaders: HeadersWithEntries): void;
+export {};
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/fakes/firebase-dependencies.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/fakes/firebase-dependencies.d.ts
new file mode 100644
index 0000000..8b623d4
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/fakes/firebase-dependencies.d.ts
@@ -0,0 +1,25 @@
+/**
+ * @license
+ * Copyright 2017 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { FirebaseAnalyticsInternalName } from '@firebase/analytics-interop-types';
+import { FirebaseInternalDependencies } from '../../interfaces/internal-dependencies';
+import { FirebaseOptions } from '@firebase/app';
+import { Provider } from '@firebase/component';
+import { _FirebaseInstallationsInternal } from '@firebase/installations';
+export declare function getFakeFirebaseDependencies(options?: FirebaseOptions): FirebaseInternalDependencies;
+export declare function getFakeApp(options?: FirebaseOptions): any;
+export declare function getFakeInstallations(): _FirebaseInstallationsInternal;
+export declare function getFakeAnalyticsProvider(): Provider<FirebaseAnalyticsInternalName>;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/fakes/logging-object.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/fakes/logging-object.d.ts
new file mode 100644
index 0000000..02d52f5
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/fakes/logging-object.d.ts
@@ -0,0 +1,18 @@
+/**
+ * @license
+ * Copyright 2021 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+import { LogEvent, LogResponse } from '../../interfaces/logging-types';
+export declare function getFakeLogEvent(): LogEvent;
+export declare function getSuccessResponse(): LogResponse;
+export declare function getFailedResponse(): LogResponse;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/fakes/messaging-service.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/fakes/messaging-service.d.ts
new file mode 100644
index 0000000..154a0d9
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/fakes/messaging-service.d.ts
@@ -0,0 +1,18 @@
+/**
+ * @license
+ * Copyright 2021 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { MessagingService } from '../../messaging-service';
+export declare function getFakeMessagingService(): MessagingService;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/fakes/service-worker.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/fakes/service-worker.d.ts
new file mode 100644
index 0000000..11b3a7d
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/fakes/service-worker.d.ts
@@ -0,0 +1,83 @@
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { ExtendableEvent } from '../../util/sw-types';
+export declare function mockServiceWorker(): void;
+export declare function restoreServiceWorker(): void;
+export declare class FakeServiceWorkerRegistration implements ServiceWorkerRegistration {
+ active: null;
+ installing: null;
+ waiting: null;
+ onupdatefound: null;
+ pushManager: FakePushManager;
+ scope: string;
+ navigationPreload: NavigationPreloadManager;
+ updateViaCache: ServiceWorkerUpdateViaCache;
+ getNotifications(): Promise<never[]>;
+ showNotification(): Promise<void>;
+ update(): Promise<void>;
+ unregister(): Promise<boolean>;
+ addEventListener(): void;
+ removeEventListener(): void;
+ dispatchEvent(): boolean;
+}
+declare class FakePushManager implements PushManager {
+ private subscription;
+ permissionState(): Promise<"granted">;
+ getSubscription(): Promise<FakePushSubscription | null>;
+ subscribe(): Promise<FakePushSubscription>;
+}
+export declare class FakePushSubscription implements PushSubscription {
+ endpoint: string;
+ expirationTime: number;
+ auth: string;
+ p256: string;
+ getKey(name: PushEncryptionKeyName): Uint8Array;
+ unsubscribe(): Promise<boolean>;
+ toJSON: () => PushSubscriptionJSON;
+ options: PushSubscriptionOptions;
+}
+/**
+ * Most of the fields in here are unused / deprecated. They are only added here to match the TS
+ * Event interface.
+ */
+export declare class FakeEvent implements ExtendableEvent {
+ type: string;
+ NONE: 0;
+ AT_TARGET: 2;
+ BUBBLING_PHASE: 3;
+ CAPTURING_PHASE: 1;
+ bubbles: boolean;
+ cancelable: boolean;
+ composed: boolean;
+ timeStamp: number;
+ isTrusted: boolean;
+ eventPhase: 0;
+ target: null;
+ currentTarget: null;
+ srcElement: null;
+ cancelBubble: boolean;
+ defaultPrevented: boolean;
+ returnValue: boolean;
+ preventDefault(): void;
+ stopPropagation(): void;
+ stopImmediatePropagation(): void;
+ initEvent(): void;
+ waitUntil(): void;
+ composedPath(): never[];
+ constructor(type: string, options?: EventInit);
+}
+export {};
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/fakes/token-details.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/fakes/token-details.d.ts
new file mode 100644
index 0000000..27d7257
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/fakes/token-details.d.ts
@@ -0,0 +1,18 @@
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { TokenDetails } from '../../interfaces/token-details';
+export declare function getFakeTokenDetails(): TokenDetails;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/setup.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/setup.d.ts
new file mode 100644
index 0000000..1c93d90
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/setup.d.ts
@@ -0,0 +1,17 @@
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export {};
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/sinon-types.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/sinon-types.d.ts
new file mode 100644
index 0000000..0466b57
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/testing/sinon-types.d.ts
@@ -0,0 +1,19 @@
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { SinonSpy, SinonStub } from 'sinon';
+export type Stub<T extends (...args: any) => any> = SinonStub<Parameters<T>, ReturnType<T>>;
+export type Spy<T extends (...args: any) => any> = SinonSpy<Parameters<T>, ReturnType<T>>;
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/util/constants.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/util/constants.d.ts
new file mode 100644
index 0000000..f5a2358
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/util/constants.d.ts
@@ -0,0 +1,40 @@
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export declare const DEFAULT_SW_PATH = "/firebase-messaging-sw.js";
+export declare const DEFAULT_SW_SCOPE = "/firebase-cloud-messaging-push-scope";
+export declare const DEFAULT_VAPID_KEY = "BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4";
+export declare const ENDPOINT = "https://fcmregistrations.googleapis.com/v1";
+/** Key of FCM Payload in Notification's data field. */
+export declare const FCM_MSG = "FCM_MSG";
+export declare const CONSOLE_CAMPAIGN_ID = "google.c.a.c_id";
+export declare const CONSOLE_CAMPAIGN_NAME = "google.c.a.c_l";
+export declare const CONSOLE_CAMPAIGN_TIME = "google.c.a.ts";
+/** Set to '1' if Analytics is enabled for the campaign */
+export declare const CONSOLE_CAMPAIGN_ANALYTICS_ENABLED = "google.c.a.e";
+export declare const TAG = "FirebaseMessaging: ";
+export declare const MAX_NUMBER_OF_EVENTS_PER_LOG_REQUEST = 1000;
+export declare const MAX_RETRIES = 3;
+export declare const LOG_INTERVAL_IN_MS = 86400000;
+export declare const DEFAULT_BACKOFF_TIME_MS = 5000;
+export declare const DEFAULT_REGISTRATION_TIMEOUT = 10000;
+export declare const FCM_LOG_SOURCE = 1249;
+export declare const SDK_PLATFORM_WEB = 3;
+export declare const EVENT_MESSAGE_DELIVERED = 1;
+export declare enum MessageType {
+ DATA_MESSAGE = 1,
+ DISPLAY_NOTIFICATION = 3
+}
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/util/errors.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/util/errors.d.ts
new file mode 100644
index 0000000..e985fff
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/util/errors.d.ts
@@ -0,0 +1,57 @@
+/**
+ * @license
+ * Copyright 2017 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { ErrorFactory, ErrorMap } from '@firebase/util';
+export declare const enum ErrorCode {
+ MISSING_APP_CONFIG_VALUES = "missing-app-config-values",
+ AVAILABLE_IN_WINDOW = "only-available-in-window",
+ AVAILABLE_IN_SW = "only-available-in-sw",
+ PERMISSION_DEFAULT = "permission-default",
+ PERMISSION_BLOCKED = "permission-blocked",
+ UNSUPPORTED_BROWSER = "unsupported-browser",
+ INDEXED_DB_UNSUPPORTED = "indexed-db-unsupported",
+ FAILED_DEFAULT_REGISTRATION = "failed-service-worker-registration",
+ TOKEN_SUBSCRIBE_FAILED = "token-subscribe-failed",
+ TOKEN_SUBSCRIBE_NO_TOKEN = "token-subscribe-no-token",
+ TOKEN_UNSUBSCRIBE_FAILED = "token-unsubscribe-failed",
+ TOKEN_UPDATE_FAILED = "token-update-failed",
+ TOKEN_UPDATE_NO_TOKEN = "token-update-no-token",
+ INVALID_BG_HANDLER = "invalid-bg-handler",
+ USE_SW_AFTER_GET_TOKEN = "use-sw-after-get-token",
+ INVALID_SW_REGISTRATION = "invalid-sw-registration",
+ USE_VAPID_KEY_AFTER_GET_TOKEN = "use-vapid-key-after-get-token",
+ INVALID_VAPID_KEY = "invalid-vapid-key"
+}
+export declare const ERROR_MAP: ErrorMap<ErrorCode>;
+interface ErrorParams {
+ [ErrorCode.MISSING_APP_CONFIG_VALUES]: {
+ valueName: string;
+ };
+ [ErrorCode.FAILED_DEFAULT_REGISTRATION]: {
+ browserErrorMessage: string;
+ };
+ [ErrorCode.TOKEN_SUBSCRIBE_FAILED]: {
+ errorInfo: string;
+ };
+ [ErrorCode.TOKEN_UNSUBSCRIBE_FAILED]: {
+ errorInfo: string;
+ };
+ [ErrorCode.TOKEN_UPDATE_FAILED]: {
+ errorInfo: string;
+ };
+}
+export declare const ERROR_FACTORY: ErrorFactory<ErrorCode, ErrorParams>;
+export {};
diff --git a/frontend-old/node_modules/@firebase/messaging/dist/esm/src/util/sw-types.d.ts b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/util/sw-types.d.ts
new file mode 100644
index 0000000..b7abd9a
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/messaging/dist/esm/src/util/sw-types.d.ts
@@ -0,0 +1,90 @@
+/**
+ * @license
+ * Copyright 2018 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Subset of Web Worker types from lib.webworker.d.ts
+ * https://github.com/Microsoft/TypeScript/blob/master/lib/lib.webworker.d.ts
+ *
+ * Since it's not possible to have both "dom" and "webworker" libs in a single project, we have to
+ * manually declare the web worker types we need.
+ */
+export interface ServiceWorkerGlobalScope {
+ readonly location: WorkerLocation;
+ readonly clients: Clients;
+ readonly registration: ServiceWorkerRegistration;
+ addEventListener<K extends keyof ServiceWorkerGlobalScopeEventMap>(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
+}
+export interface ServiceWorkerGlobalScopeEventMap {
+ notificationclick: NotificationEvent;
+ push: PushEvent;
+ pushsubscriptionchange: PushSubscriptionChangeEvent;
+}
+export interface Client {
+ readonly id: string;
+ readonly type: ClientTypes;
+ readonly url: string;
+ postMessage(message: any, transfer?: Transferable[]): void;
+}
+export interface ClientQueryOptions {
+ includeReserved?: boolean;
+ includeUncontrolled?: boolean;
+ type?: ClientTypes;
+}
+export interface WindowClient extends Client {
+ readonly focused: boolean;
+ readonly visibilityState: DocumentVisibilityState;
+ focus(): Promise<WindowClient>;
+ navigate(url: string): Promise<WindowClient>;
+}
+export interface Clients {
+ claim(): Promise<void>;
+ get(id: string): Promise<any>;
+ matchAll(options?: ClientQueryOptions): Promise<Client[]>;
+ openWindow(url: string): Promise<WindowClient | null>;
+}
+export interface ExtendableEvent extends Event {
+ waitUntil(f: Promise<any>): void;
+}
+export interface NotificationEvent extends ExtendableEvent {
+ readonly action: string;
+ readonly notification: Notification;
+}
+interface PushMessageData {
+ arrayBuffer(): ArrayBuffer;
+ blob(): Blob;
+ json(): any;
+ text(): string;
+}
+export interface PushEvent extends ExtendableEvent {
+ readonly data: PushMessageData | null;
+}
+export interface PushSubscriptionChangeEvent extends ExtendableEvent {
+ readonly newSubscription: PushSubscription | null;
+ readonly oldSubscription: PushSubscription | null;
+}
+interface WorkerLocation {
+ readonly hash: string;
+ readonly host: string;
+ readonly hostname: string;
+ readonly href: string;
+ readonly origin: string;
+ readonly pathname: string;
+ readonly port: string;
+ readonly protocol: string;
+ readonly search: string;
+ toString(): string;
+}
+export {};