{"version":3,"sources":["webpack:///firebase-messaging.js","webpack:///./messaging/index.js","webpack:///../messaging/dist/esm/src/helpers/array-buffer-to-base64.js","webpack:///../messaging/dist/esm/src/models/clean-v1-undefined.js","webpack:///../messaging/dist/esm/src/models/token-details-model.js","webpack:///../messaging/dist/esm/index.js","webpack:///../messaging/dist/esm/src/models/errors.js","webpack:///../messaging/dist/esm/src/models/db-interface.js","webpack:///../messaging/dist/esm/src/models/fcm-details.js","webpack:///../messaging/dist/esm/src/models/iid-model.js","webpack:///../messaging/dist/esm/src/models/vapid-details-model.js","webpack:///../messaging/dist/esm/src/controllers/controller-interface.js","webpack:///../messaging/dist/esm/src/models/worker-page-message.js","webpack:///../messaging/dist/esm/src/models/default-sw.js","webpack:///../messaging/dist/esm/src/helpers/base64-to-array-buffer.js","webpack:///../messaging/dist/esm/src/controllers/window-controller.js","webpack:///../messaging/dist/esm/src/controllers/sw-controller.js"],"names":["webpackJsonpFirebase","117","module","exports","__webpack_require__","118","__webpack_exports__","toBase64","arrayBuffer","uint8Version","Uint8Array","window","btoa","String","fromCharCode","apply","handleDb","db","objectStoreNames","contains","OLD_OBJECT_STORE_NAME","transaction","objectStore","iidModel","iid_model","openCursorRequest","openCursor","onerror","event","console","warn","onsuccess","cursor","result","tokenDetails","value","deleteToken","fcmSenderId","fcmToken","fcmPushSet","continue","close","indexedDB","deleteDatabase","OLD_DB_NAME","cleanV1","request","open","ValidateInput","registerMessaging","instance","factoryMethod","app","self","sw_controller","window_controller","namespaceExports","Messaging","INTERNAL","registerService","Object","defineProperty","errors__a","tslib_es6","cjs","CODES","AVAILABLE_IN_WINDOW","AVAILABLE_IN_SW","SHOULD_BE_INHERITED","BAD_SENDER_ID","INCORRECT_GCM_SENDER_ID","PERMISSION_DEFAULT","PERMISSION_BLOCKED","UNSUPPORTED_BROWSER","NOTIFICATIONS_BLOCKED","FAILED_DEFAULT_REGISTRATION","SW_REGISTRATION_EXPECTED","GET_SUBSCRIPTION_FAILED","INVALID_SAVED_TOKEN","SW_REG_REDUNDANT","TOKEN_SUBSCRIBE_FAILED","TOKEN_SUBSCRIBE_NO_TOKEN","TOKEN_SUBSCRIBE_NO_PUSH_SET","TOKEN_UNSUBSCRIBE_FAILED","TOKEN_UPDATE_FAILED","TOKEN_UPDATE_NO_TOKEN","USE_SW_BEFORE_GET_TOKEN","INVALID_DELETE_TOKEN","DELETE_TOKEN_NOT_FOUND","DELETE_SCOPE_NOT_FOUND","BG_HANDLER_FUNCTION_EXPECTED","NO_WINDOW_CLIENT_TO_MSG","UNABLE_TO_RESUBSCRIBE","NO_FCM_TOKEN_FOR_RESUBSCRIBE","FAILED_TO_DELETE_TOKEN","NO_SW_IN_REG","BAD_SCOPE","BAD_VAPID_KEY","BAD_SUBSCRIPTION","BAD_TOKEN","BAD_PUSH_SET","FAILED_DELETE_VAPID_KEY","INVALID_PUBLIC_VAPID_KEY","USE_PUBLIC_KEY_BEFORE_GET_TOKEN","PUBLIC_KEY_DECRYPTION_FAILED","ERROR_MAP","errors","codes","map","db_interface_DBInterface","DBInterface","dbName","dbVersion","this","errorFactory_","DB_NAME_","dbVersion_","openDbPromise_","TRANSACTION_READ_WRITE","prototype","openDatabase","_this","Promise","resolve","reject","target","error","onupgradeneeded","onDBUpgrade","err","closeDatabase","then","create","db_interface","array_buffer_to_base64","replace","DEFAULT_PUBLIC_VAPID_KEY","SUBSCRIPTION_DETAILS","userVisibleOnly","applicationServerKey","fcm_details","ENDPOINT","iid_model_IIDModel","IIDModel","getToken","senderId","subscription","publicVapidKey","p256dh","auth","fcmSubscribeBody","endpoint","headers","Headers","append","subscribeOptions","method","body","fetch","response","json","catch","fcmTokenResponse","message","token","pushSet","updateToken","fcmUpdateBody","updateFetchRes","updateOptions","fetchResponse","ok","fcmUnsubscribeBody","unsubscribeOptions","DB_NAME","DB_VERSION","swScope","vapidKey","token_details_model_TokenDetailsModel","_super","TokenDetailsModel","call","evt","oldVersion","createObjectStore","keyPath","createIndex","unique","validateInputs_","input","_a","length","PushSubscription","getTokenDetailsFromToken","index","get","getTokenDetailsFromSWScope","scopeRequest","saveTokenDetails","details","createTime","Date","now","put","delete","token_details_model","vapid_details_model_DB_NAME","vapid_details_model_DB_VERSION","vapid_details_model_VapidDetailsModel","VapidDetailsModel","getVapidFromSWScope","saveVapidDetails","deleteVapidDetails","vapid_details_model","SENDER_ID_OPTION_NAME","controller_interface_ControllerInterface","ControllerInterface","options","messagingSenderId_","tokenDetailsModel_","vapidDetailsModel_","iidModel_","currentPermission","getNotificationPermission_","notification_permission","swReg","getSWRegistration_","reg","scope","manageExistingToken","getNewToken","isTokenStillValid","isValid","getPublicVapidKey_","publicKey","updatedToken","getPushSubscription_","pushSubscription","allDetails","iidTokenDetails","registration","pushManager","getSubscription","unsubscribe","requestPermission","useServiceWorker","usePublicVapidKey","b64PublicKey","onMessage","nextOrObserver","optError","optCompleted","onTokenRefresh","setBackgroundMessageHandler","callback","all","Notification","permission","getTokenDetailsModel","getVapidDetailsModel","getIIDModel","controller_interface","PARAMS","TYPE_OF_MSG","DATA","msgType","PUSH_MSG_RECEIVED","NOTIFICATION_CLICKED","createNewMsg","msgData","worker_page_message","TYPES_OF_MSG","default_sw","path","base64_to_array_buffer","base64String","padding","repeat","base64","rawData","atob","outputArray","i","charCodeAt","window_controller_WindowController","WindowController","messageObserver_","onMessage_","observer","tokenRefreshObserver_","onTokenRefresh_","registrationToUse_","manifestCheckPromise_","setupSWMessageListener_","isSupported_","manifestCheck_","manifestTag","document","querySelector","href","manifestContent","managePermissionResult","permissionPromise","ServiceWorkerRegistration","publicVapidKeyToUse_","parsedKey","waitForRegistrationToActivate_","serviceWorker","installing","waiting","active","state","stateChangeListener","removeEventListener","addEventListener","navigator","register","browserErrorMessage","update","swRegistration","subscribe","data","workerPageMessage","pushMessage","next","hasOwnProperty","sw_controller_SWController","SWController","e","onPush_","onSubChange_","onNotificationClick_","bgMessageHandler_","msgPayload","handleMsgPromise","hasVisibleClients_","hasVisibleClients","notification","sendMessageToWindowClients_","notificationDetails","getNotificationData_","notificationTitle_1","title","showNotification","waitUntil","promiseChain","stopImmediatePropagation","clickAction","getWindowClient_","windowClient","focus","clients","openWindow","internalMsg","attemptToMessageClient_","notificationInformation","assign","url","parsedURL","URL","location","matchAll","type","includeUncontrolled","clientList","suitableClient","client","postMessage","some","visibilityState","vapidKeyFromDatabase","esm","Error"],"mappings":";;;;;AAKA,IACQA,sBAAsB,IAExBC,IACA,SAAUC,EAAQC,EAASC,GCOjCA,EAAA,MDgBMC,IACA,SAAUH,EAAQI,EAAqBF,GAE7C,YEpBA,SAAAG,GAAAC,GACA,GAAAC,GAAA,GAAAC,YAAAF,EACA,OAAAG,QAAAC,KAAAC,OAAAC,aAAAC,MAAA,KAAAN,ICYA,QAAAO,GAAAC,GACA,GAAAA,EAAAC,iBAAAC,SAAAC,GAAA,CAKA,GAAAC,GAAAJ,EAAAI,YAAAD,GACAE,EAAAD,EAAAC,YAAAF,GACAG,EAAA,GAAAC,GACAC,EAAAH,EAAAI,YACAD,GAAAE,QAAA,SAAAC,GAEAC,QAAAC,KAAA,6BAAAF,IAEAH,EAAAM,UAAA,WACA,GAAAC,GAAAP,EAAAQ,MACA,IAAAD,EAAA,CAGA,GAAAE,GAAAF,EAAAG,KACAZ,GAAAa,YAAAF,EAAAG,YAAAH,EAAAI,SAAAJ,EAAAK,YACAP,EAAAQ,eAGAvB,GAAAwB,QACAC,UAAAC,eAAAC,KAIA,QAAAC,KACA,GAAAC,GAAAJ,UAAAK,KAAAH,EACAE,GAAAnB,QAAA,SAAAC,KAGAkB,EAAAf,UAAA,SAAAH,GAEAZ,EADA8B,EAAAb,SCvCA,QAAAe,MCNA,QAAAC,GAAAC,GACA,GACAC,GAAA,SAAAC,GACA,MAAAC,OAAA,4BAAAA,MACA,GAAAC,GAAAF,GAGA,GAAAG,GAAAH,IAEAI,GAEAC,UAAAF,EAEAL,GAAAQ,SAAAC,gBAZA,YAYAR,EAAAK,GLIAI,OAAOC,eAAevD,EAAqB,cAAgB6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AR,IACA,OAAA5D,MAAA0S,QACAU,UACAC,KAAA,SACAC,qBAAA,IAEAxO,KAAA,SAAAyO,GACA,GAAAX,GAAAnF,EAAAF,aAAAE,EAAAC,aAAAL,kBAAAmE,EACA,OAAAnN,SAAAqI,IAAA6G,EAAAhQ,IAAA,SAAAkQ,GACA,MAAArP,GAAAyO,EAAAY,EAAAb,SAUA1B,EAAAhN,UAAA2G,EAAA,WACA,MAAAxG,SAAAC,QAAAtE,KAAA2L,eAMAuF,EAAAhN,UAAAkH,EAAA,WACA,GAAAhH,GAAAR,IACA,OAAAA,MAAAiH,IACA/F,KAAA,SAAA8F,GACA,MAAAxG,GAAA0I,uBAAAjD,oBAAAe,EAAAG,SAEAjG,KAAA,SAAA+O,GACA,cAAAA,EACAtO,EAAAJ,yBAEA0O,KAGA3C,GACClE,GACD/M,EAAA,EhBm1DI6T,EAAM/W,EAAoB,EK1pE9BE,GAAA,kBAAA2C,EAkCAA,EAAAkU,EAAA,aLqqEG,MACO,MAAMrP,GACN,KAAUsP,OACR","file":"firebase-messaging.js","sourcesContent":["/*!\n * @license Firebase v4.10.1\n * Build: rev-e70ef37\n * Terms: https://firebase.google.com/terms/\n */\ntry {\n webpackJsonpFirebase([3],{\n\n/***/ 117:\n/***/ (function(module, exports, __webpack_require__) {\n\n/**\n * Copyright 2017 Google Inc.\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__webpack_require__(118);\n\n\n/***/ }),\n\n/***/ 118:\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\nObject.defineProperty(__webpack_exports__, \"__esModule\", { value: true });\n\n// EXTERNAL MODULE: /tmp/tmp-9321BpTjZrU60EO5/node_modules/tslib/tslib.es6.js\nvar tslib_es6 = __webpack_require__(2);\n\n// EXTERNAL MODULE: ../util/dist/cjs/index.js\nvar cjs = __webpack_require__(0);\nvar cjs_default = /*#__PURE__*/__webpack_require__.n(cjs);\n\n// CONCATENATED MODULE: ../messaging/dist/esm/src/models/errors.js\n/**\n * Copyright 2017 Google Inc.\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\nvar CODES = {\n AVAILABLE_IN_WINDOW: 'only-available-in-window',\n AVAILABLE_IN_SW: 'only-available-in-sw',\n SHOULD_BE_INHERITED: 'should-be-overriden',\n BAD_SENDER_ID: 'bad-sender-id',\n INCORRECT_GCM_SENDER_ID: 'incorrect-gcm-sender-id',\n PERMISSION_DEFAULT: 'permission-default',\n PERMISSION_BLOCKED: 'permission-blocked',\n UNSUPPORTED_BROWSER: 'unsupported-browser',\n NOTIFICATIONS_BLOCKED: 'notifications-blocked',\n FAILED_DEFAULT_REGISTRATION: 'failed-serviceworker-registration',\n SW_REGISTRATION_EXPECTED: 'sw-registration-expected',\n GET_SUBSCRIPTION_FAILED: 'get-subscription-failed',\n INVALID_SAVED_TOKEN: 'invalid-saved-token',\n SW_REG_REDUNDANT: 'sw-reg-redundant',\n TOKEN_SUBSCRIBE_FAILED: 'token-subscribe-failed',\n TOKEN_SUBSCRIBE_NO_TOKEN: 'token-subscribe-no-token',\n TOKEN_SUBSCRIBE_NO_PUSH_SET: 'token-subscribe-no-push-set',\n TOKEN_UNSUBSCRIBE_FAILED: 'token-unsubscribe-failed',\n TOKEN_UPDATE_FAILED: 'token-update-failed',\n TOKEN_UPDATE_NO_TOKEN: 'token-update-no-token',\n USE_SW_BEFORE_GET_TOKEN: 'use-sw-before-get-token',\n INVALID_DELETE_TOKEN: 'invalid-delete-token',\n DELETE_TOKEN_NOT_FOUND: 'delete-token-not-found',\n DELETE_SCOPE_NOT_FOUND: 'delete-scope-not-found',\n BG_HANDLER_FUNCTION_EXPECTED: 'bg-handler-function-expected',\n NO_WINDOW_CLIENT_TO_MSG: 'no-window-client-to-msg',\n UNABLE_TO_RESUBSCRIBE: 'unable-to-resubscribe',\n NO_FCM_TOKEN_FOR_RESUBSCRIBE: 'no-fcm-token-for-resubscribe',\n FAILED_TO_DELETE_TOKEN: 'failed-to-delete-token',\n NO_SW_IN_REG: 'no-sw-in-reg',\n BAD_SCOPE: 'bad-scope',\n BAD_VAPID_KEY: 'bad-vapid-key',\n BAD_SUBSCRIPTION: 'bad-subscription',\n BAD_TOKEN: 'bad-token',\n BAD_PUSH_SET: 'bad-push-set',\n FAILED_DELETE_VAPID_KEY: 'failed-delete-vapid-key',\n INVALID_PUBLIC_VAPID_KEY: 'invalid-public-vapid-key',\n USE_PUBLIC_KEY_BEFORE_GET_TOKEN: 'use-public-key-before-get-token',\n PUBLIC_KEY_DECRYPTION_FAILED: 'public-vapid-key-decryption-failed'\n};\nvar ERROR_MAP = (errors__a = {},\n errors__a[CODES.AVAILABLE_IN_WINDOW] = 'This method is available in a Window context.',\n errors__a[CODES.AVAILABLE_IN_SW] = 'This method is available in a service worker ' + 'context.',\n errors__a[CODES.SHOULD_BE_INHERITED] = 'This method should be overriden by ' + 'extended classes.',\n errors__a[CODES.BAD_SENDER_ID] = \"Please ensure that 'messagingSenderId' is set \" +\n 'correctly in the options passed into firebase.initializeApp().',\n errors__a[CODES.PERMISSION_DEFAULT] = 'The required permissions were not granted and ' + 'dismissed instead.',\n errors__a[CODES.PERMISSION_BLOCKED] = 'The required permissions were not granted and ' + 'blocked instead.',\n errors__a[CODES.UNSUPPORTED_BROWSER] = \"This browser doesn't support the API's \" +\n 'required to use the firebase SDK.',\n errors__a[CODES.NOTIFICATIONS_BLOCKED] = 'Notifications have been blocked.',\n errors__a[CODES.FAILED_DEFAULT_REGISTRATION] = 'We are unable to register the ' +\n 'default service worker. {$browserErrorMessage}',\n errors__a[CODES.SW_REGISTRATION_EXPECTED] = 'A service worker registration was the ' + 'expected input.',\n errors__a[CODES.GET_SUBSCRIPTION_FAILED] = 'There was an error when trying to get ' +\n 'any existing Push Subscriptions.',\n errors__a[CODES.INVALID_SAVED_TOKEN] = 'Unable to access details of the saved token.',\n errors__a[CODES.SW_REG_REDUNDANT] = 'The service worker being used for push was made ' + 'redundant.',\n errors__a[CODES.TOKEN_SUBSCRIBE_FAILED] = 'A problem occured while subscribing the ' + 'user to FCM: {$message}',\n errors__a[CODES.TOKEN_SUBSCRIBE_NO_TOKEN] = 'FCM returned no token when subscribing ' + 'the user to push.',\n errors__a[CODES.TOKEN_SUBSCRIBE_NO_PUSH_SET] = 'FCM returned an invalid response ' + 'when getting an FCM token.',\n errors__a[CODES.TOKEN_UNSUBSCRIBE_FAILED] = 'A problem occured while unsubscribing the ' + 'user from FCM: {$message}',\n errors__a[CODES.TOKEN_UPDATE_FAILED] = 'A problem occured while updating the ' + 'user from FCM: {$message}',\n errors__a[CODES.TOKEN_UPDATE_NO_TOKEN] = 'FCM returned no token when updating ' + 'the user to push.',\n errors__a[CODES.USE_SW_BEFORE_GET_TOKEN] = 'You must call useServiceWorker() before ' +\n 'calling getToken() to ensure your service worker is used.',\n errors__a[CODES.INVALID_DELETE_TOKEN] = 'You must pass a valid token into ' +\n 'deleteToken(), i.e. the token from getToken().',\n errors__a[CODES.DELETE_TOKEN_NOT_FOUND] = 'The deletion attempt for token could not ' +\n 'be performed as the token was not found.',\n errors__a[CODES.DELETE_SCOPE_NOT_FOUND] = 'The deletion attempt for service worker ' +\n 'scope could not be performed as the scope was not found.',\n errors__a[CODES.BG_HANDLER_FUNCTION_EXPECTED] = 'The input to ' + 'setBackgroundMessageHandler() must be a function.',\n errors__a[CODES.NO_WINDOW_CLIENT_TO_MSG] = 'An attempt was made to message a ' + 'non-existant window client.',\n errors__a[CODES.UNABLE_TO_RESUBSCRIBE] = 'There was an error while re-subscribing ' +\n 'the FCM token for push messaging. Will have to resubscribe the ' +\n 'user on next visit. {$message}',\n errors__a[CODES.NO_FCM_TOKEN_FOR_RESUBSCRIBE] = 'Could not find an FCM token ' +\n 'and as a result, unable to resubscribe. Will have to resubscribe the ' +\n 'user on next visit.',\n errors__a[CODES.FAILED_TO_DELETE_TOKEN] = 'Unable to delete the currently saved token.',\n errors__a[CODES.NO_SW_IN_REG] = 'Even though the service worker registration was ' +\n 'successful, there was a problem accessing the service worker itself.',\n errors__a[CODES.INCORRECT_GCM_SENDER_ID] = \"Please change your web app manifest's \" +\n \"'gcm_sender_id' value to '103953800507' to use Firebase messaging.\",\n errors__a[CODES.BAD_SCOPE] = 'The service worker scope must be a string with at ' +\n 'least one character.',\n errors__a[CODES.BAD_VAPID_KEY] = 'The public VAPID key is not a Uint8Array with 65 bytes.',\n errors__a[CODES.BAD_SUBSCRIPTION] = 'The subscription must be a valid ' + 'PushSubscription.',\n errors__a[CODES.BAD_TOKEN] = 'The FCM Token used for storage / lookup was not ' +\n 'a valid token string.',\n errors__a[CODES.BAD_PUSH_SET] = 'The FCM push set used for storage / lookup was not ' +\n 'not a valid push set string.',\n errors__a[CODES.FAILED_DELETE_VAPID_KEY] = 'The VAPID key could not be deleted.',\n errors__a[CODES.INVALID_PUBLIC_VAPID_KEY] = 'The public VAPID key must be a string.',\n errors__a[CODES.PUBLIC_KEY_DECRYPTION_FAILED] = 'The public VAPID key did not equal ' + '65 bytes when decrypted.',\n errors__a);\n/* harmony default export */ var errors = ({\n codes: CODES,\n map: ERROR_MAP\n});\nvar errors__a;\n\n//# sourceMappingURL=errors.js.map\n\n// CONCATENATED MODULE: ../messaging/dist/esm/src/models/db-interface.js\n/**\n * Copyright 2017 Google Inc.\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\n\nvar db_interface_DBInterface = /** @class */ (function () {\n /**\n * @param {string} dbName\n * @param {number} dbVersion\n */\n function DBInterface(dbName, dbVersion) {\n this.errorFactory_ = new cjs[\"ErrorFactory\"]('messaging', 'Messaging', errors.map);\n this.DB_NAME_ = dbName;\n this.dbVersion_ = dbVersion;\n this.openDbPromise_ = null;\n this.TRANSACTION_READ_WRITE = 'readwrite';\n }\n /**\n * Get the indexedDB as a promsie.\n * @protected\n * @return {!Promise} The IndexedDB database\n */\n DBInterface.prototype.openDatabase = function () {\n var _this = this;\n if (this.openDbPromise_) {\n return this.openDbPromise_;\n }\n this.openDbPromise_ = new Promise(function (resolve, reject) {\n var request = indexedDB.open(_this.DB_NAME_, _this.dbVersion_);\n request.onerror = function (event) {\n reject(event.target.error);\n };\n request.onsuccess = function (event) {\n resolve(event.target.result);\n };\n request.onupgradeneeded = function (event) {\n try {\n var db = event.target.result;\n _this.onDBUpgrade(db, event);\n }\n catch (err) {\n // close the database as it can't be used.\n db.close();\n reject(err);\n }\n };\n });\n return this.openDbPromise_;\n };\n /**\n * Close the currently open database.\n * @return {!Promise} Returns the result of the promise chain.\n */\n DBInterface.prototype.closeDatabase = function () {\n var _this = this;\n return Promise.resolve().then(function () {\n if (_this.openDbPromise_) {\n return _this.openDbPromise_.then(function (db) {\n db.close();\n _this.openDbPromise_ = null;\n });\n }\n });\n };\n /**\n * @protected\n * @param {!IDBDatabase} db\n */\n DBInterface.prototype.onDBUpgrade = function (db, event) {\n throw this.errorFactory_.create(errors.codes.SHOULD_BE_INHERITED);\n };\n return DBInterface;\n}());\n/* harmony default export */ var db_interface = (db_interface_DBInterface);\n\n//# sourceMappingURL=db-interface.js.map\n\n// CONCATENATED MODULE: ../messaging/dist/esm/src/helpers/array-buffer-to-base64.js\n/**\n * Copyright 2017 Google Inc.\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 */\nfunction toBase64(arrayBuffer) {\n var uint8Version = new Uint8Array(arrayBuffer);\n return window.btoa(String.fromCharCode.apply(null, uint8Version));\n}\n/* harmony default export */ var array_buffer_to_base64 = (function (arrayBuffer) {\n var base64String = toBase64(arrayBuffer);\n return base64String\n .replace(/=/g, '')\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_');\n});\n\n//# sourceMappingURL=array-buffer-to-base64.js.map\n\n// CONCATENATED MODULE: ../messaging/dist/esm/src/models/fcm-details.js\n/**\n * Copyright 2017 Google Inc.\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\nvar DEFAULT_PUBLIC_VAPID_KEY = new Uint8Array([\n 0x04,\n 0x33,\n 0x94,\n 0xf7,\n 0xdf,\n 0xa1,\n 0xeb,\n 0xb1,\n 0xdc,\n 0x03,\n 0xa2,\n 0x5e,\n 0x15,\n 0x71,\n 0xdb,\n 0x48,\n 0xd3,\n 0x2e,\n 0xed,\n 0xed,\n 0xb2,\n 0x34,\n 0xdb,\n 0xb7,\n 0x47,\n 0x3a,\n 0x0c,\n 0x8f,\n 0xc4,\n 0xcc,\n 0xe1,\n 0x6f,\n 0x3c,\n 0x8c,\n 0x84,\n 0xdf,\n 0xab,\n 0xb6,\n 0x66,\n 0x3e,\n 0xf2,\n 0x0c,\n 0xd4,\n 0x8b,\n 0xfe,\n 0xe3,\n 0xf9,\n 0x76,\n 0x2f,\n 0x14,\n 0x1c,\n 0x63,\n 0x08,\n 0x6a,\n 0x6f,\n 0x2d,\n 0xb1,\n 0x1a,\n 0x95,\n 0xb0,\n 0xce,\n 0x37,\n 0xc0,\n 0x9c,\n 0x6e\n]);\nvar SUBSCRIPTION_DETAILS = {\n userVisibleOnly: true,\n applicationServerKey: DEFAULT_PUBLIC_VAPID_KEY\n};\n/* harmony default export */ var fcm_details = ({\n DEFAULT_PUBLIC_VAPID_KEY: DEFAULT_PUBLIC_VAPID_KEY,\n SUBSCRIPTION_DETAILS: SUBSCRIPTION_DETAILS,\n ENDPOINT: 'https://fcm.googleapis.com'\n // ENDPOINT: 'https://jmt17.google.com'\n});\n\n//# sourceMappingURL=fcm-details.js.map\n\n// CONCATENATED MODULE: ../messaging/dist/esm/src/models/iid-model.js\n/**\n * Copyright 2017 Google Inc.\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\n\n\n\nvar iid_model_IIDModel = /** @class */ (function () {\n function IIDModel() {\n this.errorFactory_ = new cjs[\"ErrorFactory\"]('messaging', 'Messaging', errors.map);\n }\n /**\n * Given a PushSubscription and messagingSenderId, get an FCM token.\n * @public\n * @param {string} senderId The 'messagingSenderId' to tie the token to.\n * @param {PushSubscription} subscription The PushSusbcription to \"federate\".\n * @param {Uint8Array} publicVapidKey The public VAPID key.\n * @return {Promise} Returns the FCM token to be used in place\n * of the PushSubscription.\n */\n IIDModel.prototype.getToken = function (senderId, subscription, publicVapidKey) {\n var _this = this;\n var p256dh = array_buffer_to_base64(subscription['getKey']('p256dh'));\n var auth = array_buffer_to_base64(subscription['getKey']('auth'));\n var fcmSubscribeBody = \"authorized_entity=\" + senderId + \"&\" +\n (\"endpoint=\" + subscription.endpoint + \"&\") +\n (\"encryption_key=\" + p256dh + \"&\") +\n (\"encryption_auth=\" + auth);\n if (publicVapidKey !== fcm_details.DEFAULT_PUBLIC_VAPID_KEY) {\n var applicationPubKey = array_buffer_to_base64(publicVapidKey);\n fcmSubscribeBody += \"&application_pub_key=\" + applicationPubKey;\n }\n var headers = new Headers();\n headers.append('Content-Type', 'application/x-www-form-urlencoded');\n var subscribeOptions = {\n method: 'POST',\n headers: headers,\n body: fcmSubscribeBody\n };\n return fetch(fcm_details.ENDPOINT + '/fcm/connect/subscribe', subscribeOptions)\n .then(function (response) { return response.json(); })\n .catch(function () {\n throw _this.errorFactory_.create(errors.codes.TOKEN_SUBSCRIBE_FAILED);\n })\n .then(function (response) {\n var fcmTokenResponse = response;\n if (fcmTokenResponse['error']) {\n var message = fcmTokenResponse['error']['message'];\n throw _this.errorFactory_.create(errors.codes.TOKEN_SUBSCRIBE_FAILED, {\n message: message\n });\n }\n if (!fcmTokenResponse['token']) {\n throw _this.errorFactory_.create(errors.codes.TOKEN_SUBSCRIBE_NO_TOKEN);\n }\n if (!fcmTokenResponse['pushSet']) {\n throw _this.errorFactory_.create(errors.codes.TOKEN_SUBSCRIBE_NO_PUSH_SET);\n }\n return {\n token: fcmTokenResponse['token'],\n pushSet: fcmTokenResponse['pushSet']\n };\n });\n };\n /**\n * Update the underlying token details for fcmToken.\n */\n IIDModel.prototype.updateToken = function (senderId, fcmToken, fcmPushSet, subscription, publicVapidKey) {\n var _this = this;\n var p256dh = array_buffer_to_base64(subscription['getKey']('p256dh'));\n var auth = array_buffer_to_base64(subscription['getKey']('auth'));\n var fcmUpdateBody = \"push_set=\" + fcmPushSet + \"&\" +\n (\"token=\" + fcmToken + \"&\") +\n (\"authorized_entity=\" + senderId + \"&\") +\n (\"endpoint=\" + subscription.endpoint + \"&\") +\n (\"encryption_key=\" + p256dh + \"&\") +\n (\"encryption_auth=\" + auth);\n if (publicVapidKey !== fcm_details.DEFAULT_PUBLIC_VAPID_KEY) {\n var applicationPubKey = array_buffer_to_base64(publicVapidKey);\n fcmUpdateBody += \"&application_pub_key=\" + applicationPubKey;\n }\n var headers = new Headers();\n headers.append('Content-Type', 'application/x-www-form-urlencoded');\n var updateOptions = {\n method: 'POST',\n headers: headers,\n body: fcmUpdateBody\n };\n var updateFetchRes;\n return fetch(fcm_details.ENDPOINT + '/fcm/connect/subscribe', updateOptions)\n .then(function (fetchResponse) {\n updateFetchRes = fetchResponse;\n return fetchResponse.json();\n })\n .catch(function () {\n throw _this.errorFactory_.create(errors.codes.TOKEN_UPDATE_FAILED);\n })\n .then(function (fcmTokenResponse) {\n if (!updateFetchRes.ok) {\n var message = fcmTokenResponse['error']['message'];\n throw _this.errorFactory_.create(errors.codes.TOKEN_UPDATE_FAILED, {\n message: message\n });\n }\n if (!fcmTokenResponse['token']) {\n throw _this.errorFactory_.create(errors.codes.TOKEN_UPDATE_NO_TOKEN);\n }\n return fcmTokenResponse['token'];\n });\n };\n /**\n * Given a fcmToken, pushSet and messagingSenderId, delete an FCM token.\n */\n IIDModel.prototype.deleteToken = function (senderId, fcmToken, fcmPushSet) {\n var _this = this;\n var fcmUnsubscribeBody = \"authorized_entity=\" + senderId + \"&\" +\n (\"token=\" + fcmToken + \"&\") +\n (\"pushSet=\" + fcmPushSet);\n var headers = new Headers();\n headers.append('Content-Type', 'application/x-www-form-urlencoded');\n var unsubscribeOptions = {\n method: 'POST',\n headers: headers,\n body: fcmUnsubscribeBody\n };\n return fetch(fcm_details.ENDPOINT + '/fcm/connect/unsubscribe', unsubscribeOptions).then(function (fetchResponse) {\n if (!fetchResponse.ok) {\n return fetchResponse.json().then(function (fcmTokenResponse) {\n if (fcmTokenResponse['error']) {\n var message = fcmTokenResponse['error']['message'];\n throw _this.errorFactory_.create(errors.codes.TOKEN_UNSUBSCRIBE_FAILED, {\n message: message\n });\n }\n }, function (err) {\n throw _this.errorFactory_.create(errors.codes.TOKEN_UNSUBSCRIBE_FAILED);\n });\n }\n });\n };\n return IIDModel;\n}());\n/* harmony default export */ var iid_model = (iid_model_IIDModel);\n\n//# sourceMappingURL=iid-model.js.map\n\n// CONCATENATED MODULE: ../messaging/dist/esm/src/models/clean-v1-undefined.js\n/**\n * Copyright 2017 Google Inc.\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 * There seems to have been a bug in the messaging SDK versions <= 4.9.x\n * where the IndexedDB model was using a database name of 'undefined'.\n *\n * In 4.10.x we changed the model implementation, but kept the database\n * name as it should have been. This however introduced an issue where\n * two tokens were pointing to the same underlying PushSubscription.\n *\n * This code will look for the undefined database and delete any of the\n * underlying tokens.\n */\n\nvar OLD_DB_NAME = 'undefined';\nvar OLD_OBJECT_STORE_NAME = 'fcm_token_object_Store';\nfunction handleDb(db) {\n if (!db.objectStoreNames.contains(OLD_OBJECT_STORE_NAME)) {\n // We found a database with the name 'undefined', but our expected object\n // store isn't defined.\n return;\n }\n var transaction = db.transaction(OLD_OBJECT_STORE_NAME);\n var objectStore = transaction.objectStore(OLD_OBJECT_STORE_NAME);\n var iidModel = new iid_model();\n var openCursorRequest = objectStore.openCursor();\n openCursorRequest.onerror = function (event) {\n // NOOP - Nothing we can do.\n console.warn('Unable to cleanup old IDB.', event);\n };\n openCursorRequest.onsuccess = function () {\n var cursor = openCursorRequest.result;\n if (cursor) {\n // cursor.value contains the current record being iterated through\n // this is where you'd do something with the result\n var tokenDetails = cursor.value;\n iidModel.deleteToken(tokenDetails.fcmSenderId, tokenDetails.fcmToken, tokenDetails.fcmPushSet);\n cursor.continue();\n }\n else {\n db.close();\n indexedDB.deleteDatabase(OLD_DB_NAME);\n }\n };\n}\nfunction cleanV1() {\n var request = indexedDB.open(OLD_DB_NAME);\n request.onerror = function (event) {\n // NOOP - Nothing we can do.\n };\n request.onsuccess = function (event) {\n var db = request.result;\n handleDb(db);\n };\n}\n\n\n//# sourceMappingURL=clean-v1-undefined.js.map\n\n// CONCATENATED MODULE: ../messaging/dist/esm/src/models/token-details-model.js\n/**\n * Copyright 2017 Google Inc.\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\n\n\n\n\nvar FCM_TOKEN_OBJ_STORE = 'fcm_token_object_Store';\nvar DB_NAME = 'fcm_token_details_db';\nvar DB_VERSION = 2;\n/** @record */\nfunction ValidateInput() { }\n/** @type {string|undefined} */\nValidateInput.prototype.fcmToken;\n/** @type {string|undefined} */\nValidateInput.prototype.swScope;\n/** @type {string|undefined} */\nValidateInput.prototype.vapidKey;\n/** @type {PushSubscription|undefined} */\nValidateInput.prototype.subscription;\n/** @type {string|undefined} */\nValidateInput.prototype.fcmSenderId;\n/** @type {string|undefined} */\nValidateInput.prototype.fcmPushSet;\nvar token_details_model_TokenDetailsModel = /** @class */ (function (_super) {\n tslib_es6[\"__extends\"](TokenDetailsModel, _super);\n function TokenDetailsModel() {\n return _super.call(this, DB_NAME, DB_VERSION) || this;\n }\n TokenDetailsModel.prototype.onDBUpgrade = function (db, evt) {\n if (evt.oldVersion < 1) {\n // New IDB instance\n var objectStore = db.createObjectStore(FCM_TOKEN_OBJ_STORE, {\n keyPath: 'swScope'\n });\n // Make sure the sender ID can be searched\n objectStore.createIndex('fcmSenderId', 'fcmSenderId', {\n unique: false\n });\n objectStore.createIndex('fcmToken', 'fcmToken', {\n unique: true\n });\n }\n if (evt.oldVersion < 2) {\n // Prior to version 2, we were using either 'fcm_token_details_db'\n // or 'undefined' as the database name due to bug in the SDK\n // So remove the old tokens and databases.\n cleanV1();\n }\n };\n /**\n * This method takes an object and will check for known arguments and\n * validate the input.\n * @private\n * @param {!ValidateInput} input\n * @return {!Promise} Returns promise that resolves if input is valid,\n * rejects otherwise.\n */\n TokenDetailsModel.prototype.validateInputs_ = function (input) {\n return tslib_es6[\"__awaiter\"](this, void 0, void 0, function () {\n return tslib_es6[\"__generator\"](this, function (_a) {\n if (input.fcmToken) {\n if (typeof input.fcmToken !== 'string' || input.fcmToken.length === 0) {\n return [2 /*return*/, Promise.reject(this.errorFactory_.create(errors.codes.BAD_TOKEN))];\n }\n }\n if (input.swScope) {\n if (typeof input.swScope !== 'string' || input.swScope.length === 0) {\n return [2 /*return*/, Promise.reject(this.errorFactory_.create(errors.codes.BAD_SCOPE))];\n }\n }\n if (input.vapidKey) {\n if (!(input.vapidKey instanceof Uint8Array) ||\n input.vapidKey.length !== 65) {\n return [2 /*return*/, Promise.reject(this.errorFactory_.create(errors.codes.BAD_VAPID_KEY))];\n }\n }\n if (input.subscription) {\n if (!(input.subscription instanceof PushSubscription)) {\n return [2 /*return*/, Promise.reject(this.errorFactory_.create(errors.codes.BAD_SUBSCRIPTION))];\n }\n }\n if (input.fcmSenderId) {\n if (typeof input.fcmSenderId !== 'string' ||\n input.fcmSenderId.length === 0) {\n return [2 /*return*/, Promise.reject(this.errorFactory_.create(errors.codes.BAD_SENDER_ID))];\n }\n }\n if (input.fcmPushSet) {\n if (typeof input.fcmPushSet !== 'string' ||\n input.fcmPushSet.length === 0) {\n return [2 /*return*/, Promise.reject(this.errorFactory_.create(errors.codes.BAD_PUSH_SET))];\n }\n }\n return [2 /*return*/];\n });\n });\n };\n /**\n * Given a token, this method will look up the details in indexedDB.\n * @param {string} fcmToken\n * @return {Promise} The details associated with that token.\n */\n TokenDetailsModel.prototype.getTokenDetailsFromToken = function (fcmToken) {\n var _this = this;\n if (!fcmToken) {\n return Promise.reject(this.errorFactory_.create(errors.codes.BAD_TOKEN));\n }\n return this.validateInputs_({ fcmToken: fcmToken })\n .then(function () {\n return _this.openDatabase();\n })\n .then(function (db) {\n return new Promise(function (resolve, reject) {\n var transaction = db.transaction([FCM_TOKEN_OBJ_STORE]);\n var objectStore = transaction.objectStore(FCM_TOKEN_OBJ_STORE);\n var index = objectStore.index('fcmToken');\n var request = index.get(fcmToken);\n request.onerror = function (event) {\n reject(event.target.error);\n };\n request.onsuccess = function (event) {\n var result = event.target.result\n ? event.target.result\n : null;\n resolve(result);\n };\n });\n });\n };\n /**\n * Given a service worker scope, this method will look up the details in\n * indexedDB.\n * @public\n * @param {string} swScope\n * @return {Promise} The details associated with that token.\n */\n TokenDetailsModel.prototype.getTokenDetailsFromSWScope = function (swScope) {\n var _this = this;\n if (!swScope) {\n return Promise.reject(this.errorFactory_.create(errors.codes.BAD_SCOPE));\n }\n return this.validateInputs_({ swScope: swScope })\n .then(function () {\n return _this.openDatabase();\n })\n .then(function (db) {\n return new Promise(function (resolve, reject) {\n var transaction = db.transaction([FCM_TOKEN_OBJ_STORE]);\n var objectStore = transaction.objectStore(FCM_TOKEN_OBJ_STORE);\n var scopeRequest = objectStore.get(swScope);\n scopeRequest.onerror = function (event) {\n reject(event.target.error);\n };\n scopeRequest.onsuccess = function (event) {\n var result = event.target.result\n ? event.target.result\n : null;\n resolve(result);\n };\n });\n });\n };\n /**\n * Save the details for the fcm token for re-use at a later date.\n * @param {{swScope: !string, vapidKey: !string,\n * subscription: !PushSubscription, fcmSenderId: !string, fcmToken: !string,\n * fcmPushSet: !string}} input A plain js object containing args to save.\n * @return {Promise}\n */\n TokenDetailsModel.prototype.saveTokenDetails = function (_a) {\n var _this = this;\n var swScope = _a.swScope, vapidKey = _a.vapidKey, subscription = _a.subscription, fcmSenderId = _a.fcmSenderId, fcmToken = _a.fcmToken, fcmPushSet = _a.fcmPushSet;\n if (!swScope) {\n return Promise.reject(this.errorFactory_.create(errors.codes.BAD_SCOPE));\n }\n if (!vapidKey) {\n return Promise.reject(this.errorFactory_.create(errors.codes.BAD_VAPID_KEY));\n }\n if (!subscription) {\n return Promise.reject(this.errorFactory_.create(errors.codes.BAD_SUBSCRIPTION));\n }\n if (!fcmSenderId) {\n return Promise.reject(this.errorFactory_.create(errors.codes.BAD_SENDER_ID));\n }\n if (!fcmToken) {\n return Promise.reject(this.errorFactory_.create(errors.codes.BAD_TOKEN));\n }\n if (!fcmPushSet) {\n return Promise.reject(this.errorFactory_.create(errors.codes.BAD_PUSH_SET));\n }\n return this.validateInputs_({\n swScope: swScope,\n vapidKey: vapidKey,\n subscription: subscription,\n fcmSenderId: fcmSenderId,\n fcmToken: fcmToken,\n fcmPushSet: fcmPushSet\n })\n .then(function () {\n return _this.openDatabase();\n })\n .then(function (db) {\n /**\n * @dict\n */\n var details = {\n swScope: swScope,\n vapidKey: array_buffer_to_base64(vapidKey),\n endpoint: subscription.endpoint,\n auth: array_buffer_to_base64(subscription['getKey']('auth')),\n p256dh: array_buffer_to_base64(subscription['getKey']('p256dh')),\n fcmSenderId: fcmSenderId,\n fcmToken: fcmToken,\n fcmPushSet: fcmPushSet,\n createTime: Date.now()\n };\n return new Promise(function (resolve, reject) {\n var transaction = db.transaction([FCM_TOKEN_OBJ_STORE], _this.TRANSACTION_READ_WRITE);\n var objectStore = transaction.objectStore(FCM_TOKEN_OBJ_STORE);\n var request = objectStore.put(details);\n request.onerror = function (event) {\n reject(event.target.error);\n };\n request.onsuccess = function (event) {\n resolve();\n };\n });\n });\n };\n /**\n * This method deletes details of the current FCM token.\n * It's returning a promise in case we need to move to an async\n * method for deleting at a later date.\n * @return {Promise} Resolves once the FCM token details have been\n * deleted and returns the deleted details.\n */\n TokenDetailsModel.prototype.deleteToken = function (token) {\n var _this = this;\n if (typeof token !== 'string' || token.length === 0) {\n return Promise.reject(this.errorFactory_.create(errors.codes.INVALID_DELETE_TOKEN));\n }\n return this.getTokenDetailsFromToken(token).then(function (details) {\n if (!details) {\n throw _this.errorFactory_.create(errors.codes.DELETE_TOKEN_NOT_FOUND);\n }\n return _this.openDatabase().then(function (db) {\n return new Promise(function (resolve, reject) {\n var transaction = db.transaction([FCM_TOKEN_OBJ_STORE], _this.TRANSACTION_READ_WRITE);\n var objectStore = transaction.objectStore(FCM_TOKEN_OBJ_STORE);\n var request = objectStore.delete(details['swScope']);\n request.onerror = function (event) {\n reject(event.target.error);\n };\n request.onsuccess = function (event) {\n if (event.target.result === 0) {\n reject(_this.errorFactory_.create(errors.codes.FAILED_TO_DELETE_TOKEN));\n return;\n }\n resolve(details);\n };\n });\n });\n });\n };\n return TokenDetailsModel;\n}(db_interface));\n/* harmony default export */ var token_details_model = (token_details_model_TokenDetailsModel);\n\n//# sourceMappingURL=token-details-model.js.map\n\n// CONCATENATED MODULE: ../messaging/dist/esm/src/models/vapid-details-model.js\n/**\n * Copyright 2017 Google Inc.\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\n\n\nvar FCM_VAPID_OBJ_STORE = 'fcm_vapid_object_Store';\nvar vapid_details_model_DB_NAME = 'fcm_vapid_details_db';\nvar vapid_details_model_DB_VERSION = 1;\nvar UNCOMPRESSED_PUBLIC_KEY_SIZE = 65;\nvar vapid_details_model_VapidDetailsModel = /** @class */ (function (_super) {\n tslib_es6[\"__extends\"](VapidDetailsModel, _super);\n function VapidDetailsModel() {\n return _super.call(this, vapid_details_model_DB_NAME, vapid_details_model_DB_VERSION) || this;\n }\n /**\n * @override\n * @param {IDBDatabase} db\n */\n VapidDetailsModel.prototype.onDBUpgrade = function (db) {\n db.createObjectStore(FCM_VAPID_OBJ_STORE, {\n keyPath: 'swScope'\n });\n };\n /**\n * Given a service worker scope, this method will look up the vapid key\n * in indexedDB.\n */\n VapidDetailsModel.prototype.getVapidFromSWScope = function (swScope) {\n if (typeof swScope !== 'string' || swScope.length === 0) {\n return Promise.reject(this.errorFactory_.create(errors.codes.BAD_SCOPE));\n }\n return this.openDatabase().then(function (db) {\n return new Promise(function (resolve, reject) {\n var transaction = db.transaction([FCM_VAPID_OBJ_STORE]);\n var objectStore = transaction.objectStore(FCM_VAPID_OBJ_STORE);\n var scopeRequest = objectStore.get(swScope);\n scopeRequest.onerror = function () {\n reject(scopeRequest.error);\n };\n scopeRequest.onsuccess = function () {\n var result = scopeRequest.result;\n var vapidKey = null;\n if (result) {\n vapidKey = result.vapidKey;\n }\n resolve(vapidKey);\n };\n });\n });\n };\n /**\n * Save a vapid key against a swScope for later date.\n */\n VapidDetailsModel.prototype.saveVapidDetails = function (swScope, vapidKey) {\n var _this = this;\n if (typeof swScope !== 'string' || swScope.length === 0) {\n return Promise.reject(this.errorFactory_.create(errors.codes.BAD_SCOPE));\n }\n if (vapidKey === null || vapidKey.length !== UNCOMPRESSED_PUBLIC_KEY_SIZE) {\n return Promise.reject(this.errorFactory_.create(errors.codes.BAD_VAPID_KEY));\n }\n var details = {\n swScope: swScope,\n vapidKey: vapidKey\n };\n return this.openDatabase().then(function (db) {\n return new Promise(function (resolve, reject) {\n var transaction = db.transaction([FCM_VAPID_OBJ_STORE], _this.TRANSACTION_READ_WRITE);\n var objectStore = transaction.objectStore(FCM_VAPID_OBJ_STORE);\n var request = objectStore.put(details);\n request.onerror = function () {\n reject(request.error);\n };\n request.onsuccess = function () {\n resolve();\n };\n });\n });\n };\n /**\n * This method deletes details of the current FCM VAPID key for a SW scope.\n * Resolves once the scope/vapid details have been deleted and returns the\n * deleted vapid key.\n */\n VapidDetailsModel.prototype.deleteVapidDetails = function (swScope) {\n var _this = this;\n return this.getVapidFromSWScope(swScope).then(function (vapidKey) {\n if (!vapidKey) {\n throw _this.errorFactory_.create(errors.codes.DELETE_SCOPE_NOT_FOUND);\n }\n return _this.openDatabase().then(function (db) {\n return new Promise(function (resolve, reject) {\n var transaction = db.transaction([FCM_VAPID_OBJ_STORE], _this.TRANSACTION_READ_WRITE);\n var objectStore = transaction.objectStore(FCM_VAPID_OBJ_STORE);\n var request = objectStore.delete(swScope);\n request.onerror = function () {\n reject(request.error);\n };\n request.onsuccess = function () {\n if (request.result === 0) {\n reject(_this.errorFactory_.create(errors.codes.FAILED_DELETE_VAPID_KEY));\n return;\n }\n resolve(vapidKey);\n };\n });\n });\n });\n };\n return VapidDetailsModel;\n}(db_interface));\n/* harmony default export */ var vapid_details_model = (vapid_details_model_VapidDetailsModel);\n\n//# sourceMappingURL=vapid-details-model.js.map\n\n// CONCATENATED MODULE: ../messaging/dist/esm/src/models/notification-permission.js\n/**\n * Copyright 2017 Google Inc.\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/* harmony default export */ var notification_permission = ({\n granted: 'granted',\n default: 'default',\n denied: 'denied'\n});\n\n//# sourceMappingURL=notification-permission.js.map\n\n// CONCATENATED MODULE: ../messaging/dist/esm/src/controllers/controller-interface.js\n/**\n * Copyright 2017 Google Inc.\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\n\n\n\n\n\n\nvar SENDER_ID_OPTION_NAME = 'messagingSenderId';\n// Database cache should be invalidated once a week.\nvar TOKEN_EXPIRATION_MILLIS = 7 * 24 * 60 * 60 * 1000; // 7 days\nvar controller_interface_ControllerInterface = /** @class */ (function () {\n /**\n * An interface of the Messaging Service API\n * @param {!firebase.app.App} app\n */\n function ControllerInterface(app) {\n var _this = this;\n this.errorFactory_ = new cjs[\"ErrorFactory\"]('messaging', 'Messaging', errors.map);\n if (!app.options[SENDER_ID_OPTION_NAME] ||\n typeof app.options[SENDER_ID_OPTION_NAME] !== 'string') {\n throw this.errorFactory_.create(errors.codes.BAD_SENDER_ID);\n }\n this.messagingSenderId_ = app.options[SENDER_ID_OPTION_NAME];\n this.tokenDetailsModel_ = new token_details_model();\n this.vapidDetailsModel_ = new vapid_details_model();\n this.iidModel_ = new iid_model();\n this.app = app;\n this.INTERNAL = {};\n this.INTERNAL.delete = function () { return _this.delete(); };\n }\n /**\n * @export\n */\n ControllerInterface.prototype.getToken = function () {\n var _this = this;\n // Check with permissions\n var currentPermission = this.getNotificationPermission_();\n if (currentPermission !== notification_permission.granted) {\n if (currentPermission === notification_permission.denied) {\n return Promise.reject(this.errorFactory_.create(errors.codes.NOTIFICATIONS_BLOCKED));\n }\n // We must wait for permission to be granted\n return Promise.resolve(null);\n }\n var swReg;\n return this.getSWRegistration_()\n .then(function (reg) {\n swReg = reg;\n return _this.tokenDetailsModel_.getTokenDetailsFromSWScope(swReg.scope);\n })\n .then(function (tokenDetails) {\n if (tokenDetails) {\n return _this.manageExistingToken(tokenDetails, swReg);\n }\n return _this.getNewToken(swReg);\n });\n };\n /**\n * manageExistingToken is triggered if there's an existing FCM token in the\n * database and it can take 3 different actions:\n * 1) Retrieve the existing FCM token from the database.\n * 2) If VAPID details have changed: Delete the existing token and create a\n * new one with the new VAPID key.\n * 3) If the database cache is invalidated: Send a request to FCM to update\n * the token, and to check if the token is still valid on FCM-side.\n */\n ControllerInterface.prototype.manageExistingToken = function (tokenDetails, swReg) {\n var _this = this;\n return this.isTokenStillValid(tokenDetails).then(function (isValid) {\n if (isValid) {\n var now = Date.now();\n if (now < tokenDetails['createTime'] + TOKEN_EXPIRATION_MILLIS) {\n return tokenDetails['fcmToken'];\n }\n else {\n return _this.updateToken(tokenDetails, swReg);\n }\n }\n else {\n // If the VAPID details are updated, delete the existing token,\n // and create a new one.\n return _this.deleteToken(tokenDetails['fcmToken']).then(function () {\n return _this.getNewToken(swReg);\n });\n }\n });\n };\n /*\n * Checks if the tokenDetails match the details provided in the clients.\n */\n ControllerInterface.prototype.isTokenStillValid = function (tokenDetails) {\n // TODO Validate rest of the details.\n return this.getPublicVapidKey_().then(function (publicKey) {\n if (array_buffer_to_base64(publicKey) !== tokenDetails['vapidKey']) {\n return false;\n }\n return true;\n });\n };\n ControllerInterface.prototype.updateToken = function (tokenDetails, swReg) {\n var _this = this;\n var publicVapidKey;\n var updatedToken;\n var subscription;\n return this.getPublicVapidKey_()\n .then(function (publicKey) {\n publicVapidKey = publicKey;\n return _this.getPushSubscription_(swReg, publicVapidKey);\n })\n .then(function (pushSubscription) {\n subscription = pushSubscription;\n return _this.iidModel_.updateToken(_this.messagingSenderId_, tokenDetails['fcmToken'], tokenDetails['fcmPushSet'], subscription, publicVapidKey);\n })\n .catch(function (err) {\n return _this.deleteToken(tokenDetails['fcmToken']).then(function () {\n throw err;\n });\n })\n .then(function (token) {\n updatedToken = token;\n var allDetails = {\n swScope: swReg.scope,\n vapidKey: publicVapidKey,\n subscription: subscription,\n fcmSenderId: _this.messagingSenderId_,\n fcmToken: updatedToken,\n fcmPushSet: tokenDetails['fcmPushSet']\n };\n return _this.tokenDetailsModel_.saveTokenDetails(allDetails);\n })\n .then(function () {\n return _this.vapidDetailsModel_.saveVapidDetails(swReg.scope, publicVapidKey);\n })\n .then(function () {\n return updatedToken;\n });\n };\n ControllerInterface.prototype.getNewToken = function (swReg) {\n var _this = this;\n var publicVapidKey;\n var subscription;\n var tokenDetails;\n return this.getPublicVapidKey_()\n .then(function (publicKey) {\n publicVapidKey = publicKey;\n return _this.getPushSubscription_(swReg, publicVapidKey);\n })\n .then(function (pushSubscription) {\n subscription = pushSubscription;\n return _this.iidModel_.getToken(_this.messagingSenderId_, subscription, publicVapidKey);\n })\n .then(function (iidTokenDetails) {\n tokenDetails = iidTokenDetails;\n var allDetails = {\n swScope: swReg.scope,\n vapidKey: publicVapidKey,\n subscription: subscription,\n fcmSenderId: _this.messagingSenderId_,\n fcmToken: tokenDetails['token'],\n fcmPushSet: tokenDetails['pushSet']\n };\n return _this.tokenDetailsModel_.saveTokenDetails(allDetails);\n })\n .then(function () {\n return _this.vapidDetailsModel_.saveVapidDetails(swReg.scope, publicVapidKey);\n })\n .then(function () {\n return tokenDetails['token'];\n });\n };\n /**\n * This method deletes tokens that the token manager looks after,\n * unsubscribes the token from FCM and then unregisters the push\n * subscription if it exists. It returns a promise that indicates\n * whether or not the unsubscribe request was processed successfully.\n * @export\n */\n ControllerInterface.prototype.deleteToken = function (token) {\n var _this = this;\n return this.tokenDetailsModel_\n .deleteToken(token)\n .then(function (details) {\n return _this.iidModel_.deleteToken(details['fcmSenderId'], details['fcmToken'], details['fcmPushSet']);\n })\n .then(function () {\n return _this.getSWRegistration_()\n .then(function (registration) {\n if (registration) {\n return registration.pushManager.getSubscription();\n }\n })\n .then(function (subscription) {\n if (subscription) {\n return subscription.unsubscribe();\n }\n });\n });\n };\n ControllerInterface.prototype.getSWRegistration_ = function () {\n throw this.errorFactory_.create(errors.codes.SHOULD_BE_INHERITED);\n };\n ControllerInterface.prototype.getPublicVapidKey_ = function () {\n throw this.errorFactory_.create(errors.codes.SHOULD_BE_INHERITED);\n };\n //\n // The following methods should only be available in the window.\n //\n ControllerInterface.prototype.requestPermission = function () {\n throw this.errorFactory_.create(errors.codes.AVAILABLE_IN_WINDOW);\n };\n ControllerInterface.prototype.getPushSubscription_ = function (registration, publicVapidKey) {\n throw this.errorFactory_.create(errors.codes.AVAILABLE_IN_WINDOW);\n };\n /**\n * @export\n * @param {!ServiceWorkerRegistration} registration\n */\n ControllerInterface.prototype.useServiceWorker = function (registration) {\n throw this.errorFactory_.create(errors.codes.AVAILABLE_IN_WINDOW);\n };\n /**\n * @export\n * @param {!string} b64PublicKey\n */\n ControllerInterface.prototype.usePublicVapidKey = function (b64PublicKey) {\n throw this.errorFactory_.create(errors.codes.AVAILABLE_IN_WINDOW);\n };\n /**\n * @export\n * @param {!firebase.Observer|function(*)} nextOrObserver\n * @param {function(!Error)=} optError\n * @param {function()=} optCompleted\n * @return {!function()}\n */\n ControllerInterface.prototype.onMessage = function (nextOrObserver, optError, optCompleted) {\n throw this.errorFactory_.create(errors.codes.AVAILABLE_IN_WINDOW);\n };\n /**\n * @export\n * @param {!firebase.Observer|function()} nextOrObserver An observer object\n * or a function triggered on token refresh.\n * @param {function(!Error)=} optError Optional A function\n * triggered on token refresh error.\n * @param {function()=} optCompleted Optional function triggered when the\n * observer is removed.\n * @return {!function()} The unsubscribe function for the observer.\n */\n ControllerInterface.prototype.onTokenRefresh = function (nextOrObserver, optError, optCompleted) {\n throw this.errorFactory_.create(errors.codes.AVAILABLE_IN_WINDOW);\n };\n //\n // The following methods are used by the service worker only.\n //\n /**\n * @export\n * @param {function(Object)} callback\n */\n ControllerInterface.prototype.setBackgroundMessageHandler = function (callback) {\n throw this.errorFactory_.create(errors.codes.AVAILABLE_IN_SW);\n };\n //\n // The following methods are used by the service themselves and not exposed\n // publicly or not expected to be used by developers.\n //\n /**\n * This method is required to adhere to the Firebase interface.\n * It closes any currently open indexdb database connections.\n */\n ControllerInterface.prototype.delete = function () {\n return Promise.all([\n this.tokenDetailsModel_.closeDatabase(),\n this.vapidDetailsModel_.closeDatabase()\n ]);\n };\n /**\n * Returns the current Notification Permission state.\n * @private\n * @return {string} The currenct permission state.\n */\n ControllerInterface.prototype.getNotificationPermission_ = function () {\n return Notification.permission;\n };\n ControllerInterface.prototype.getTokenDetailsModel = function () {\n return this.tokenDetailsModel_;\n };\n ControllerInterface.prototype.getVapidDetailsModel = function () {\n return this.vapidDetailsModel_;\n };\n /**\n * @protected\n * @returns {IIDModel}\n */\n ControllerInterface.prototype.getIIDModel = function () {\n return this.iidModel_;\n };\n return ControllerInterface;\n}());\n/* harmony default export */ var controller_interface = (controller_interface_ControllerInterface);\n\n//# sourceMappingURL=controller-interface.js.map\n\n// CONCATENATED MODULE: ../messaging/dist/esm/src/models/worker-page-message.js\n/**\n * Copyright 2017 Google Inc.\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// These fields are strings to prevent closure from thinking goog.getMsg\n// should be used to initialise the values\nvar PARAMS = {\n TYPE_OF_MSG: 'firebase-messaging-msg-type',\n DATA: 'firebase-messaging-msg-data'\n};\n// This value isn't using the TYPE_OF_MSG short hand as closure\n// expects the variable to be defined via goog.getMsg\nvar msgType = {\n PUSH_MSG_RECEIVED: 'push-msg-received',\n NOTIFICATION_CLICKED: 'notification-clicked'\n};\nvar createNewMsg = function (msgType, msgData) {\n var message = (_a = {},\n _a[PARAMS.TYPE_OF_MSG] = msgType,\n _a[PARAMS.DATA] = msgData,\n _a);\n return message;\n var _a;\n};\n/* harmony default export */ var worker_page_message = ({\n PARAMS: PARAMS,\n TYPES_OF_MSG: msgType,\n createNewMsg: createNewMsg\n});\n\n//# sourceMappingURL=worker-page-message.js.map\n\n// CONCATENATED MODULE: ../messaging/dist/esm/src/models/default-sw.js\n/**\n * Copyright 2017 Google Inc.\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/* harmony default export */ var default_sw = ({\n path: '/firebase-messaging-sw.js',\n scope: '/firebase-cloud-messaging-push-scope'\n});\n\n//# sourceMappingURL=default-sw.js.map\n\n// CONCATENATED MODULE: ../messaging/dist/esm/src/helpers/base64-to-array-buffer.js\n/**\n * Copyright 2017 Google Inc.\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/* harmony default export */ var base64_to_array_buffer = (function (base64String) {\n var padding = '='.repeat((4 - base64String.length % 4) % 4);\n var base64 = (base64String + padding)\n .replace(/\\-/g, '+')\n .replace(/_/g, '/');\n var rawData = window.atob(base64);\n var outputArray = new Uint8Array(rawData.length);\n for (var i = 0; i < rawData.length; ++i) {\n outputArray[i] = rawData.charCodeAt(i);\n }\n return outputArray;\n});\n\n//# sourceMappingURL=base64-to-array-buffer.js.map\n\n// CONCATENATED MODULE: ../messaging/dist/esm/src/controllers/window-controller.js\n/**\n * Copyright 2017 Google Inc.\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\n\n\n\n\n\n\n\n\nvar window_controller_WindowController = /** @class */ (function (_super) {\n tslib_es6[\"__extends\"](WindowController, _super);\n /**\n * A service that provides a MessagingService instance.\n * @param {!firebase.app.App} app\n */\n function WindowController(app) {\n var _this = _super.call(this, app) || this;\n _this.messageObserver_ = null;\n _this.onMessage_ = Object(cjs[\"createSubscribe\"])(function (observer) {\n _this.messageObserver_ = observer;\n });\n _this.tokenRefreshObserver_ = null;\n _this.onTokenRefresh_ = Object(cjs[\"createSubscribe\"])(function (observer) {\n _this.tokenRefreshObserver_ = observer;\n });\n /**\n * @private\n * @type {ServiceWorkerRegistration}\n */\n _this.registrationToUse_;\n /**\n * @private\n * @type {Promise}\n */\n _this.manifestCheckPromise_;\n /**\n * @private\n * @type {firebase.Observer}\n */\n _this.messageObserver_ = null;\n /**\n * @private {!firebase.Subscribe} The subscribe function to the onMessage\n * observer.\n */\n _this.onMessage_ = Object(cjs[\"createSubscribe\"])(function (observer) {\n _this.messageObserver_ = observer;\n });\n /**\n * @private\n * @type {firebase.Observer}\n */\n _this.tokenRefreshObserver_ = null;\n _this.onTokenRefresh_ = Object(cjs[\"createSubscribe\"])(function (observer) {\n _this.tokenRefreshObserver_ = observer;\n });\n _this.setupSWMessageListener_();\n return _this;\n }\n /**\n * This method returns an FCM token if it can be generated.\n * The return promise will reject if the browser doesn't support\n * FCM, if permission is denied for notifications or it's not\n * possible to generate a token.\n * @export\n * @return {Promise | Promise} Returns a promise the\n * resolves to an FCM token or null if permission isn't granted.\n */\n WindowController.prototype.getToken = function () {\n var _this = this;\n // Check that the required API's are available\n if (!this.isSupported_()) {\n return Promise.reject(this.errorFactory_.create(errors.codes.UNSUPPORTED_BROWSER));\n }\n return this.manifestCheck_().then(function () {\n return _super.prototype.getToken.call(_this);\n });\n };\n /**\n * The method checks that a manifest is defined and has the correct GCM\n * sender ID.\n * @private\n * @return {Promise} Returns a promise that resolves if the manifest matches\n * our required sender ID\n */\n WindowController.prototype.manifestCheck_ = function () {\n var _this = this;\n if (this.manifestCheckPromise_) {\n return this.manifestCheckPromise_;\n }\n var manifestTag = document.querySelector('link[rel=\"manifest\"]');\n if (!manifestTag) {\n this.manifestCheckPromise_ = Promise.resolve();\n }\n else {\n this.manifestCheckPromise_ = fetch(manifestTag.href)\n .then(function (response) {\n return response.json();\n })\n .catch(function () {\n // If the download or parsing fails allow check.\n // We only want to error if we KNOW that the gcm_sender_id is incorrect.\n })\n .then(function (manifestContent) {\n if (!manifestContent) {\n return;\n }\n if (!manifestContent['gcm_sender_id']) {\n return;\n }\n if (manifestContent['gcm_sender_id'] !== '103953800507') {\n throw _this.errorFactory_.create(errors.codes.INCORRECT_GCM_SENDER_ID);\n }\n });\n }\n return this.manifestCheckPromise_;\n };\n /**\n * Request permission if it is not currently granted\n * @export\n * @returns {Promise} Resolves if the permission was granted, otherwise\n * rejects\n */\n WindowController.prototype.requestPermission = function () {\n return tslib_es6[\"__awaiter\"](this, void 0, void 0, function () {\n var _this = this;\n return tslib_es6[\"__generator\"](this, function (_a) {\n if (Notification.permission === notification_permission.granted) {\n return [2 /*return*/];\n }\n return [2 /*return*/, new Promise(function (resolve, reject) {\n var managePermissionResult = function (result) {\n if (result === notification_permission.granted) {\n return resolve();\n }\n else if (result === notification_permission.denied) {\n return reject(_this.errorFactory_.create(errors.codes.PERMISSION_BLOCKED));\n }\n else {\n return reject(_this.errorFactory_.create(errors.codes.PERMISSION_DEFAULT));\n }\n };\n // The Notification.requestPermission API was changed to\n // return a promise so now have to handle both in case\n // browsers stop support callbacks for promised version\n var permissionPromise = Notification.requestPermission(managePermissionResult);\n if (permissionPromise) {\n // Prefer the promise version as it's the future API.\n permissionPromise.then(managePermissionResult);\n }\n })];\n });\n });\n };\n /**\n * This method allows a developer to override the default service worker and\n * instead use a custom service worker.\n * @export\n * @param {!ServiceWorkerRegistration} registration The service worker\n * registration that should be used to receive the push messages.\n */\n WindowController.prototype.useServiceWorker = function (registration) {\n if (!(registration instanceof ServiceWorkerRegistration)) {\n throw this.errorFactory_.create(errors.codes.SW_REGISTRATION_EXPECTED);\n }\n if (typeof this.registrationToUse_ !== 'undefined') {\n throw this.errorFactory_.create(errors.codes.USE_SW_BEFORE_GET_TOKEN);\n }\n this.registrationToUse_ = registration;\n };\n /**\n * This method allows a developer to override the default vapid key\n * and instead use a custom VAPID public key.\n * @export\n * @param {!string} publicKey A URL safe base64 encoded string.\n */\n WindowController.prototype.usePublicVapidKey = function (publicKey) {\n if (typeof publicKey !== 'string') {\n throw this.errorFactory_.create(errors.codes.INVALID_PUBLIC_VAPID_KEY);\n }\n if (typeof this.publicVapidKeyToUse_ !== 'undefined') {\n throw this.errorFactory_.create(errors.codes.USE_PUBLIC_KEY_BEFORE_GET_TOKEN);\n }\n var parsedKey = base64_to_array_buffer(publicKey);\n if (parsedKey.length !== 65) {\n throw this.errorFactory_.create(errors.codes.PUBLIC_KEY_DECRYPTION_FAILED);\n }\n this.publicVapidKeyToUse_ = parsedKey;\n };\n /**\n * @export\n * @param {!firebase.Observer|function(*)} nextOrObserver An observer object\n * or a function triggered on message.\n * @param {function(!Error)=} optError Optional A function triggered on\n * message error.\n * @param {function()=} optCompleted Optional function triggered when the\n * observer is removed.\n * @return {!function()} The unsubscribe function for the observer.\n */\n WindowController.prototype.onMessage = function (nextOrObserver, optError, optCompleted) {\n return this.onMessage_(nextOrObserver, optError, optCompleted);\n };\n /**\n * @export\n * @param {!firebase.Observer|function()} nextOrObserver An observer object\n * or a function triggered on token refresh.\n * @param {function(!Error)=} optError Optional A function\n * triggered on token refresh error.\n * @param {function()=} optCompleted Optional function triggered when the\n * observer is removed.\n * @return {!function()} The unsubscribe function for the observer.\n */\n WindowController.prototype.onTokenRefresh = function (nextOrObserver, optError, optCompleted) {\n return this.onTokenRefresh_(nextOrObserver, optError, optCompleted);\n };\n /**\n * Given a registration, wait for the service worker it relates to\n * become activer\n * @private\n * @param {ServiceWorkerRegistration} registration Registration to wait\n * for service worker to become active\n * @return {Promise} Wait for service worker\n * registration to become active\n */\n WindowController.prototype.waitForRegistrationToActivate_ = function (registration) {\n var _this = this;\n var serviceWorker = registration.installing || registration.waiting || registration.active;\n return new Promise(function (resolve, reject) {\n if (!serviceWorker) {\n // This is a rare scenario but has occured in firefox\n reject(_this.errorFactory_.create(errors.codes.NO_SW_IN_REG));\n return;\n }\n // Because the Promise function is called on next tick there is a\n // small chance that the worker became active or redundant already.\n if (serviceWorker.state === 'activated') {\n resolve(registration);\n return;\n }\n if (serviceWorker.state === 'redundant') {\n reject(_this.errorFactory_.create(errors.codes.SW_REG_REDUNDANT));\n return;\n }\n var stateChangeListener = function () {\n if (serviceWorker.state === 'activated') {\n resolve(registration);\n }\n else if (serviceWorker.state === 'redundant') {\n reject(_this.errorFactory_.create(errors.codes.SW_REG_REDUNDANT));\n }\n else {\n // Return early and wait to next state change\n return;\n }\n serviceWorker.removeEventListener('statechange', stateChangeListener);\n };\n serviceWorker.addEventListener('statechange', stateChangeListener);\n });\n };\n /**\n * This will regiater the default service worker and return the registration\n * @private\n * @return {Promise} The service worker\n * registration to be used for the push service.\n */\n WindowController.prototype.getSWRegistration_ = function () {\n var _this = this;\n if (this.registrationToUse_) {\n return this.waitForRegistrationToActivate_(this.registrationToUse_);\n }\n // Make the registration null so we know useServiceWorker will not\n // use a new service worker as registrationToUse_ is no longer undefined\n this.registrationToUse_ = null;\n return navigator.serviceWorker\n .register(default_sw.path, {\n scope: default_sw.scope\n })\n .catch(function (err) {\n throw _this.errorFactory_.create(errors.codes.FAILED_DEFAULT_REGISTRATION, {\n browserErrorMessage: err.message\n });\n })\n .then(function (registration) {\n return _this.waitForRegistrationToActivate_(registration).then(function () {\n _this.registrationToUse_ = registration;\n // We update after activation due to an issue with Firefox v49 where\n // a race condition occassionally causes the service work to not\n // install\n registration.update();\n return registration;\n });\n });\n };\n /**\n * This will return the default VAPID key or the uint8array version of the public VAPID key\n * provided by the developer.\n * @private\n */\n WindowController.prototype.getPublicVapidKey_ = function () {\n if (this.publicVapidKeyToUse_) {\n return Promise.resolve(this.publicVapidKeyToUse_);\n }\n return Promise.resolve(fcm_details.DEFAULT_PUBLIC_VAPID_KEY);\n };\n /**\n * Gets a PushSubscription for the current user.\n * @private\n * @param {ServiceWorkerRegistration} registration\n * @return {Promise}\n */\n WindowController.prototype.getPushSubscription_ = function (swRegistration, publicVapidKey) {\n // Check for existing subscription first\n var subscription;\n var fcmTokenDetails;\n return swRegistration.pushManager.getSubscription().then(function (subscription) {\n if (subscription) {\n return subscription;\n }\n return swRegistration.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: publicVapidKey\n });\n });\n };\n /**\n * This method will set up a message listener to handle\n * events from the service worker that should trigger\n * events in the page.\n *\n * @private\n */\n WindowController.prototype.setupSWMessageListener_ = function () {\n var _this = this;\n if (!('serviceWorker' in navigator)) {\n return;\n }\n navigator.serviceWorker.addEventListener('message', function (event) {\n if (!event.data || !event.data[worker_page_message.PARAMS.TYPE_OF_MSG]) {\n // Not a message from FCM\n return;\n }\n var workerPageMessage = event.data;\n switch (workerPageMessage[worker_page_message.PARAMS.TYPE_OF_MSG]) {\n case worker_page_message.TYPES_OF_MSG.PUSH_MSG_RECEIVED:\n case worker_page_message.TYPES_OF_MSG.NOTIFICATION_CLICKED:\n var pushMessage = workerPageMessage[worker_page_message.PARAMS.DATA];\n if (_this.messageObserver_) {\n _this.messageObserver_.next(pushMessage);\n }\n break;\n default:\n // Noop.\n break;\n }\n }, false);\n };\n /**\n * Checks to see if the required API's are valid or not.\n * @private\n * @return {boolean} Returns true if the desired APIs are available.\n */\n WindowController.prototype.isSupported_ = function () {\n return ('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 return WindowController;\n}(controller_interface));\n/* harmony default export */ var window_controller = (window_controller_WindowController);\n\n//# sourceMappingURL=window-controller.js.map\n\n// CONCATENATED MODULE: ../messaging/dist/esm/src/controllers/sw-controller.js\n/**\n * Copyright 2017 Google Inc.\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\n\n\n\n\nvar FCM_MSG = 'FCM_MSG';\nvar sw_controller_SWController = /** @class */ (function (_super) {\n tslib_es6[\"__extends\"](SWController, _super);\n function SWController(app) {\n var _this = _super.call(this, app) || this;\n self.addEventListener('push', function (e) { return _this.onPush_(e); }, false);\n self.addEventListener('pushsubscriptionchange', function (e) { return _this.onSubChange_(e); }, false);\n self.addEventListener('notificationclick', function (e) { return _this.onNotificationClick_(e); }, false);\n /**\n * @private\n * @type {function(Object)|null}\n */\n _this.bgMessageHandler_ = null;\n return _this;\n }\n /**\n * A handler for push events that shows notifications based on the content of\n * the payload.\n *\n * The payload must be a JSON-encoded Object with a `notification` key. The\n * value of the `notification` property will be used as the NotificationOptions\n * object passed to showNotification. Additionally, the `title` property of the\n * notification object will be used as the title.\n *\n * If there is no notification data in the payload then no notification will be\n * shown.\n * @private\n */\n SWController.prototype.onPush_ = function (event) {\n var _this = this;\n var msgPayload;\n try {\n msgPayload = event.data.json();\n }\n catch (err) {\n // Not JSON so not an FCM message\n return;\n }\n var handleMsgPromise = this.hasVisibleClients_().then(function (hasVisibleClients) {\n if (hasVisibleClients) {\n // Do not need to show a notification.\n if (msgPayload.notification || _this.bgMessageHandler_) {\n // Send to page\n return _this.sendMessageToWindowClients_(msgPayload);\n }\n return;\n }\n var notificationDetails = _this.getNotificationData_(msgPayload);\n if (notificationDetails) {\n var notificationTitle_1 = notificationDetails.title || '';\n return _this.getSWRegistration_().then(function (reg) {\n return reg.showNotification(notificationTitle_1, notificationDetails);\n });\n }\n else if (_this.bgMessageHandler_) {\n return _this.bgMessageHandler_(msgPayload);\n }\n });\n event.waitUntil(handleMsgPromise);\n };\n /**\n * @private\n */\n SWController.prototype.onSubChange_ = function (event) {\n var _this = this;\n var promiseChain = this.getSWRegistration_()\n .then(function (registration) {\n return registration.pushManager\n .getSubscription()\n .then(function (subscription) {\n // TODO: Check if it's still valid\n // TODO: If not, then update token\n })\n .catch(function (err) {\n // The best thing we can do is log this to the terminal so\n // developers might notice the error.\n var tokenDetailsModel = _this.getTokenDetailsModel();\n return tokenDetailsModel\n .getTokenDetailsFromSWScope(registration.scope)\n .then(function (tokenDetails) {\n if (!tokenDetails) {\n // This should rarely occure, but could if indexedDB\n // is corrupted or wiped\n throw err;\n }\n // Attempt to delete the token if we know it's bad\n return _this.deleteToken(tokenDetails['fcmToken']).then(function () {\n throw err;\n });\n });\n });\n })\n .catch(function (err) {\n throw _this.errorFactory_.create(errors.codes.UNABLE_TO_RESUBSCRIBE, {\n message: err\n });\n });\n event.waitUntil(promiseChain);\n };\n /**\n * @private\n */\n SWController.prototype.onNotificationClick_ = function (event) {\n var _this = this;\n if (!(event.notification &&\n event.notification.data &&\n event.notification.data[FCM_MSG])) {\n // Not an FCM notification, do nothing.\n return;\n }\n // Prevent other listeners from receiving the event\n event.stopImmediatePropagation();\n event.notification.close();\n var msgPayload = event.notification.data[FCM_MSG];\n if (!msgPayload['notification']) {\n // Nothing to do.\n return;\n }\n var clickAction = msgPayload['notification']['click_action'];\n if (!clickAction) {\n // Nothing to do.\n return;\n }\n var promiseChain = this.getWindowClient_(clickAction)\n .then(function (windowClient) {\n if (!windowClient) {\n // Unable to find window client so need to open one.\n return self.clients.openWindow(clickAction);\n }\n return windowClient.focus();\n })\n .then(function (windowClient) {\n if (!windowClient) {\n // Window Client will not be returned if it's for a third party origin.\n return;\n }\n // Delete notification data from payload before sending to the page.\n var notificationData = msgPayload['notification'];\n delete msgPayload['notification'];\n var internalMsg = worker_page_message.createNewMsg(worker_page_message.TYPES_OF_MSG.NOTIFICATION_CLICKED, msgPayload);\n // Attempt to send a message to the client to handle the data\n // Is affected by: https://github.com/slightlyoff/ServiceWorker/issues/728\n return _this.attemptToMessageClient_(windowClient, internalMsg);\n });\n event.waitUntil(promiseChain);\n };\n /**\n * @private\n * @param {Object} msgPayload\n * @return {NotificationOptions|undefined}\n */\n SWController.prototype.getNotificationData_ = function (msgPayload) {\n if (!msgPayload) {\n return;\n }\n if (typeof msgPayload.notification !== 'object') {\n return;\n }\n var notificationInformation = Object.assign({}, msgPayload.notification);\n // Put the message payload under FCM_MSG name so we can identify the\n // notification as being an FCM notification vs a notification from\n // somewhere else (i.e. normal web push or developer generated\n // notification).\n notificationInformation['data'] = (_a = {},\n _a[FCM_MSG] = msgPayload,\n _a);\n return notificationInformation;\n var _a;\n };\n /**\n * Calling setBackgroundMessageHandler will opt in to some specific\n * behaviours.\n * 1.) If a notification doesn't need to be shown due to a window already\n * being visible, then push messages will be sent to the page.\n * 2.) If a notification needs to be shown, and the message contains no\n * notification data this method will be called\n * and the promise it returns will be passed to event.waitUntil.\n * If you do not set this callback then all push messages will let and the\n * developer can handle them in a their own 'push' event callback\n * @export\n * @param {function(Object)} callback The callback to be called when a push\n * message is received and a notification must be shown. The callback will\n * be given the data from the push message.\n */\n SWController.prototype.setBackgroundMessageHandler = function (callback) {\n if (!callback || typeof callback !== 'function') {\n throw this.errorFactory_.create(errors.codes.BG_HANDLER_FUNCTION_EXPECTED);\n }\n this.bgMessageHandler_ = callback;\n };\n /**\n * @private\n * @param {string} url The URL to look for when focusing a client.\n * @return {Object} Returns an existing window client or a newly opened\n * WindowClient.\n */\n SWController.prototype.getWindowClient_ = function (url) {\n // Use URL to normalize the URL when comparing to windowClients.\n // This at least handles whether to include trailing slashes or not\n var parsedURL = new URL(url, self.location).href;\n return self.clients\n .matchAll({\n type: 'window',\n includeUncontrolled: true\n })\n .then(function (clientList) {\n var suitableClient = null;\n for (var i = 0; i < clientList.length; i++) {\n var parsedClientUrl = new URL(clientList[i].url, self.location).href;\n if (parsedClientUrl === parsedURL) {\n suitableClient = clientList[i];\n break;\n }\n }\n if (suitableClient) {\n return suitableClient;\n }\n return null;\n });\n };\n /**\n * This message will attempt to send the message to a window client.\n * @private\n * @param {Object} client The WindowClient to send the message to.\n * @param {Object} message The message to send to the client.\n * @returns {Promise} Returns a promise that resolves after sending the\n * message. This does not guarantee that the message was successfully\n * received.\n */\n SWController.prototype.attemptToMessageClient_ = function (client, message) {\n return tslib_es6[\"__awaiter\"](this, void 0, void 0, function () {\n return tslib_es6[\"__generator\"](this, function (_a) {\n // NOTE: This returns a promise in case this API is abstracted later on to\n // do additional work\n if (!client) {\n return [2 /*return*/, Promise.reject(this.errorFactory_.create(errors.codes.NO_WINDOW_CLIENT_TO_MSG))];\n }\n client.postMessage(message);\n return [2 /*return*/];\n });\n });\n };\n /**\n * @private\n * @returns {Promise} If there is currently a visible WindowClient,\n * this method will resolve to true, otherwise false.\n */\n SWController.prototype.hasVisibleClients_ = function () {\n return self.clients\n .matchAll({\n type: 'window',\n includeUncontrolled: true\n })\n .then(function (clientList) {\n return clientList.some(function (client) { return client.visibilityState === 'visible'; });\n });\n };\n /**\n * @private\n * @param {Object} msgPayload The data from the push event that should be sent\n * to all available pages.\n * @returns {Promise} Returns a promise that resolves once the message\n * has been sent to all WindowClients.\n */\n SWController.prototype.sendMessageToWindowClients_ = function (msgPayload) {\n var _this = this;\n return self.clients\n .matchAll({\n type: 'window',\n includeUncontrolled: true\n })\n .then(function (clientList) {\n var internalMsg = worker_page_message.createNewMsg(worker_page_message.TYPES_OF_MSG.PUSH_MSG_RECEIVED, msgPayload);\n return Promise.all(clientList.map(function (client) {\n return _this.attemptToMessageClient_(client, internalMsg);\n }));\n });\n };\n /**\n * This will register the default service worker and return the registration.\n * @private\n * @return {Promise} The service worker\n * registration to be used for the push service.\n */\n SWController.prototype.getSWRegistration_ = function () {\n return Promise.resolve(self.registration);\n };\n /**\n * This will return the default VAPID key or the uint8array version of the\n * public VAPID key provided by the developer.\n */\n SWController.prototype.getPublicVapidKey_ = function () {\n var _this = this;\n return this.getSWRegistration_()\n .then(function (swReg) {\n return _this.getVapidDetailsModel().getVapidFromSWScope(swReg.scope);\n })\n .then(function (vapidKeyFromDatabase) {\n if (vapidKeyFromDatabase === null) {\n return fcm_details.DEFAULT_PUBLIC_VAPID_KEY;\n }\n return vapidKeyFromDatabase;\n });\n };\n return SWController;\n}(controller_interface));\n/* harmony default export */ var sw_controller = (sw_controller_SWController);\n\n//# sourceMappingURL=sw-controller.js.map\n\n// EXTERNAL MODULE: ../app/dist/esm/index.js + 1 modules\nvar esm = __webpack_require__(7);\n\n// CONCATENATED MODULE: ../messaging/dist/esm/index.js\n/* harmony export (immutable) */ __webpack_exports__[\"registerMessaging\"] = registerMessaging;\n/**\n * Copyright 2017 Google Inc.\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\n\n\nfunction registerMessaging(instance) {\n var messagingName = 'messaging';\n var factoryMethod = function (app) {\n if (self && 'ServiceWorkerGlobalScope' in self) {\n return new sw_controller(app);\n }\n // Assume we are in the window context.\n return new window_controller(app);\n };\n var namespaceExports = {\n // no-inline\n Messaging: window_controller\n };\n instance.INTERNAL.registerService(messagingName, factoryMethod, namespaceExports);\n}\nregisterMessaging(esm[\"firebase\"]);\n\n//# sourceMappingURL=index.js.map\n\n\n/***/ })\n\n},[117]);\n } catch(error) {\n throw new Error(\n 'Cannot instantiate firebase-messaging.js - ' +\n 'be sure to load firebase-app.js first.'\n )\n }\n\n\n// WEBPACK FOOTER //\n// firebase-messaging.js","/**\n * Copyright 2017 Google Inc.\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\nrequire('@firebase/messaging');\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./messaging/index.js\n// module id = 117\n// module chunks = 3","/**\n * Copyright 2017 Google Inc.\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 */\nfunction toBase64(arrayBuffer) {\n var uint8Version = new Uint8Array(arrayBuffer);\n return window.btoa(String.fromCharCode.apply(null, uint8Version));\n}\nexport default (function (arrayBuffer) {\n var base64String = toBase64(arrayBuffer);\n return base64String\n .replace(/=/g, '')\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_');\n});\n\n//# sourceMappingURL=array-buffer-to-base64.js.map\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ../messaging/dist/esm/src/helpers/array-buffer-to-base64.js\n// module id = null\n// module chunks = ","/**\n * Copyright 2017 Google Inc.\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 * There seems to have been a bug in the messaging SDK versions <= 4.9.x\n * where the IndexedDB model was using a database name of 'undefined'.\n *\n * In 4.10.x we changed the model implementation, but kept the database\n * name as it should have been. This however introduced an issue where\n * two tokens were pointing to the same underlying PushSubscription.\n *\n * This code will look for the undefined database and delete any of the\n * underlying tokens.\n */\nimport IIDModel from '../models/iid-model';\nvar OLD_DB_NAME = 'undefined';\nvar OLD_OBJECT_STORE_NAME = 'fcm_token_object_Store';\nfunction handleDb(db) {\n if (!db.objectStoreNames.contains(OLD_OBJECT_STORE_NAME)) {\n // We found a database with the name 'undefined', but our expected object\n // store isn't defined.\n return;\n }\n var transaction = db.transaction(OLD_OBJECT_STORE_NAME);\n var objectStore = transaction.objectStore(OLD_OBJECT_STORE_NAME);\n var iidModel = new IIDModel();\n var openCursorRequest = objectStore.openCursor();\n openCursorRequest.onerror = function (event) {\n // NOOP - Nothing we can do.\n console.warn('Unable to cleanup old IDB.', event);\n };\n openCursorRequest.onsuccess = function () {\n var cursor = openCursorRequest.result;\n if (cursor) {\n // cursor.value contains the current record being iterated through\n // this is where you'd do something with the result\n var tokenDetails = cursor.value;\n iidModel.deleteToken(tokenDetails.fcmSenderId, tokenDetails.fcmToken, tokenDetails.fcmPushSet);\n cursor.continue();\n }\n else {\n db.close();\n indexedDB.deleteDatabase(OLD_DB_NAME);\n }\n };\n}\nfunction cleanV1() {\n var request = indexedDB.open(OLD_DB_NAME);\n request.onerror = function (event) {\n // NOOP - Nothing we can do.\n };\n request.onsuccess = function (event) {\n var db = request.result;\n handleDb(db);\n };\n}\nexport { cleanV1 };\n\n//# sourceMappingURL=clean-v1-undefined.js.map\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ../messaging/dist/esm/src/models/clean-v1-undefined.js\n// module id = null\n// module chunks = ","/**\n * Copyright 2017 Google Inc.\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'use strict';\nimport * as tslib_1 from \"tslib\";\nimport DBInterface from './db-interface';\nimport Errors from './errors';\nimport arrayBufferToBase64 from '../helpers/array-buffer-to-base64';\nimport { cleanV1 } from './clean-v1-undefined';\nvar FCM_TOKEN_OBJ_STORE = 'fcm_token_object_Store';\nvar DB_NAME = 'fcm_token_details_db';\nvar DB_VERSION = 2;\n/** @record */\nfunction ValidateInput() { }\n/** @type {string|undefined} */\nValidateInput.prototype.fcmToken;\n/** @type {string|undefined} */\nValidateInput.prototype.swScope;\n/** @type {string|undefined} */\nValidateInput.prototype.vapidKey;\n/** @type {PushSubscription|undefined} */\nValidateInput.prototype.subscription;\n/** @type {string|undefined} */\nValidateInput.prototype.fcmSenderId;\n/** @type {string|undefined} */\nValidateInput.prototype.fcmPushSet;\nvar TokenDetailsModel = /** @class */ (function (_super) {\n tslib_1.__extends(TokenDetailsModel, _super);\n function TokenDetailsModel() {\n return _super.call(this, DB_NAME, DB_VERSION) || this;\n }\n TokenDetailsModel.prototype.onDBUpgrade = function (db, evt) {\n if (evt.oldVersion < 1) {\n // New IDB instance\n var objectStore = db.createObjectStore(FCM_TOKEN_OBJ_STORE, {\n keyPath: 'swScope'\n });\n // Make sure the sender ID can be searched\n objectStore.createIndex('fcmSenderId', 'fcmSenderId', {\n unique: false\n });\n objectStore.createIndex('fcmToken', 'fcmToken', {\n unique: true\n });\n }\n if (evt.oldVersion < 2) {\n // Prior to version 2, we were using either 'fcm_token_details_db'\n // or 'undefined' as the database name due to bug in the SDK\n // So remove the old tokens and databases.\n cleanV1();\n }\n };\n /**\n * This method takes an object and will check for known arguments and\n * validate the input.\n * @private\n * @param {!ValidateInput} input\n * @return {!Promise} Returns promise that resolves if input is valid,\n * rejects otherwise.\n */\n TokenDetailsModel.prototype.validateInputs_ = function (input) {\n return tslib_1.__awaiter(this, void 0, void 0, function () {\n return tslib_1.__generator(this, function (_a) {\n if (input.fcmToken) {\n if (typeof input.fcmToken !== 'string' || input.fcmToken.length === 0) {\n return [2 /*return*/, Promise.reject(this.errorFactory_.create(Errors.codes.BAD_TOKEN))];\n }\n }\n if (input.swScope) {\n if (typeof input.swScope !== 'string' || input.swScope.length === 0) {\n return [2 /*return*/, Promise.reject(this.errorFactory_.create(Errors.codes.BAD_SCOPE))];\n }\n }\n if (input.vapidKey) {\n if (!(input.vapidKey instanceof Uint8Array) ||\n input.vapidKey.length !== 65) {\n return [2 /*return*/, Promise.reject(this.errorFactory_.create(Errors.codes.BAD_VAPID_KEY))];\n }\n }\n if (input.subscription) {\n if (!(input.subscription instanceof PushSubscription)) {\n return [2 /*return*/, Promise.reject(this.errorFactory_.create(Errors.codes.BAD_SUBSCRIPTION))];\n }\n }\n if (input.fcmSenderId) {\n if (typeof input.fcmSenderId !== 'string' ||\n input.fcmSenderId.length === 0) {\n return [2 /*return*/, Promise.reject(this.errorFactory_.create(Errors.codes.BAD_SENDER_ID))];\n }\n }\n if (input.fcmPushSet) {\n if (typeof input.fcmPushSet !== 'string' ||\n input.fcmPushSet.length === 0) {\n return [2 /*return*/, Promise.reject(this.errorFactory_.create(Errors.codes.BAD_PUSH_SET))];\n }\n }\n return [2 /*return*/];\n });\n });\n };\n /**\n * Given a token, this method will look up the details in indexedDB.\n * @param {string} fcmToken\n * @return {Promise} The details associated with that token.\n */\n TokenDetailsModel.prototype.getTokenDetailsFromToken = function (fcmToken) {\n var _this = this;\n if (!fcmToken) {\n return Promise.reject(this.errorFactory_.create(Errors.codes.BAD_TOKEN));\n }\n return this.validateInputs_({ fcmToken: fcmToken })\n .then(function () {\n return _this.openDatabase();\n })\n .then(function (db) {\n return new Promise(function (resolve, reject) {\n var transaction = db.transaction([FCM_TOKEN_OBJ_STORE]);\n var objectStore = transaction.objectStore(FCM_TOKEN_OBJ_STORE);\n var index = objectStore.index('fcmToken');\n var request = index.get(fcmToken);\n request.onerror = function (event) {\n reject(event.target.error);\n };\n request.onsuccess = function (event) {\n var result = event.target.result\n ? event.target.result\n : null;\n resolve(result);\n };\n });\n });\n };\n /**\n * Given a service worker scope, this method will look up the details in\n * indexedDB.\n * @public\n * @param {string} swScope\n * @return {Promise} The details associated with that token.\n */\n TokenDetailsModel.prototype.getTokenDetailsFromSWScope = function (swScope) {\n var _this = this;\n if (!swScope) {\n return Promise.reject(this.errorFactory_.create(Errors.codes.BAD_SCOPE));\n }\n return this.validateInputs_({ swScope: swScope })\n .then(function () {\n return _this.openDatabase();\n })\n .then(function (db) {\n return new Promise(function (resolve, reject) {\n var transaction = db.transaction([FCM_TOKEN_OBJ_STORE]);\n var objectStore = transaction.objectStore(FCM_TOKEN_OBJ_STORE);\n var scopeRequest = objectStore.get(swScope);\n scopeRequest.onerror = function (event) {\n reject(event.target.error);\n };\n scopeRequest.onsuccess = function (event) {\n var result = event.target.result\n ? event.target.result\n : null;\n resolve(result);\n };\n });\n });\n };\n /**\n * Save the details for the fcm token for re-use at a later date.\n * @param {{swScope: !string, vapidKey: !string,\n * subscription: !PushSubscription, fcmSenderId: !string, fcmToken: !string,\n * fcmPushSet: !string}} input A plain js object containing args to save.\n * @return {Promise}\n */\n TokenDetailsModel.prototype.saveTokenDetails = function (_a) {\n var _this = this;\n var swScope = _a.swScope, vapidKey = _a.vapidKey, subscription = _a.subscription, fcmSenderId = _a.fcmSenderId, fcmToken = _a.fcmToken, fcmPushSet = _a.fcmPushSet;\n if (!swScope) {\n return Promise.reject(this.errorFactory_.create(Errors.codes.BAD_SCOPE));\n }\n if (!vapidKey) {\n return Promise.reject(this.errorFactory_.create(Errors.codes.BAD_VAPID_KEY));\n }\n if (!subscription) {\n return Promise.reject(this.errorFactory_.create(Errors.codes.BAD_SUBSCRIPTION));\n }\n if (!fcmSenderId) {\n return Promise.reject(this.errorFactory_.create(Errors.codes.BAD_SENDER_ID));\n }\n if (!fcmToken) {\n return Promise.reject(this.errorFactory_.create(Errors.codes.BAD_TOKEN));\n }\n if (!fcmPushSet) {\n return Promise.reject(this.errorFactory_.create(Errors.codes.BAD_PUSH_SET));\n }\n return this.validateInputs_({\n swScope: swScope,\n vapidKey: vapidKey,\n subscription: subscription,\n fcmSenderId: fcmSenderId,\n fcmToken: fcmToken,\n fcmPushSet: fcmPushSet\n })\n .then(function () {\n return _this.openDatabase();\n })\n .then(function (db) {\n /**\n * @dict\n */\n var details = {\n swScope: swScope,\n vapidKey: arrayBufferToBase64(vapidKey),\n endpoint: subscription.endpoint,\n auth: arrayBufferToBase64(subscription['getKey']('auth')),\n p256dh: arrayBufferToBase64(subscription['getKey']('p256dh')),\n fcmSenderId: fcmSenderId,\n fcmToken: fcmToken,\n fcmPushSet: fcmPushSet,\n createTime: Date.now()\n };\n return new Promise(function (resolve, reject) {\n var transaction = db.transaction([FCM_TOKEN_OBJ_STORE], _this.TRANSACTION_READ_WRITE);\n var objectStore = transaction.objectStore(FCM_TOKEN_OBJ_STORE);\n var request = objectStore.put(details);\n request.onerror = function (event) {\n reject(event.target.error);\n };\n request.onsuccess = function (event) {\n resolve();\n };\n });\n });\n };\n /**\n * This method deletes details of the current FCM token.\n * It's returning a promise in case we need to move to an async\n * method for deleting at a later date.\n * @return {Promise} Resolves once the FCM token details have been\n * deleted and returns the deleted details.\n */\n TokenDetailsModel.prototype.deleteToken = function (token) {\n var _this = this;\n if (typeof token !== 'string' || token.length === 0) {\n return Promise.reject(this.errorFactory_.create(Errors.codes.INVALID_DELETE_TOKEN));\n }\n return this.getTokenDetailsFromToken(token).then(function (details) {\n if (!details) {\n throw _this.errorFactory_.create(Errors.codes.DELETE_TOKEN_NOT_FOUND);\n }\n return _this.openDatabase().then(function (db) {\n return new Promise(function (resolve, reject) {\n var transaction = db.transaction([FCM_TOKEN_OBJ_STORE], _this.TRANSACTION_READ_WRITE);\n var objectStore = transaction.objectStore(FCM_TOKEN_OBJ_STORE);\n var request = objectStore.delete(details['swScope']);\n request.onerror = function (event) {\n reject(event.target.error);\n };\n request.onsuccess = function (event) {\n if (event.target.result === 0) {\n reject(_this.errorFactory_.create(Errors.codes.FAILED_TO_DELETE_TOKEN));\n return;\n }\n resolve(details);\n };\n });\n });\n });\n };\n return TokenDetailsModel;\n}(DBInterface));\nexport default TokenDetailsModel;\n\n//# sourceMappingURL=token-details-model.js.map\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ../messaging/dist/esm/src/models/token-details-model.js\n// module id = null\n// module chunks = ","/**\n * Copyright 2017 Google Inc.\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'use strict';\nimport WindowController from './src/controllers/window-controller';\nimport SWController from './src/controllers/sw-controller';\nimport { firebase } from '@firebase/app';\nexport function registerMessaging(instance) {\n var messagingName = 'messaging';\n var factoryMethod = function (app) {\n if (self && 'ServiceWorkerGlobalScope' in self) {\n return new SWController(app);\n }\n // Assume we are in the window context.\n return new WindowController(app);\n };\n var namespaceExports = {\n // no-inline\n Messaging: WindowController\n };\n instance.INTERNAL.registerService(messagingName, factoryMethod, namespaceExports);\n}\nregisterMessaging(firebase);\n\n//# sourceMappingURL=index.js.map\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ../messaging/dist/esm/index.js\n// module id = null\n// module chunks = ","/**\n * Copyright 2017 Google Inc.\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'use strict';\nvar CODES = {\n AVAILABLE_IN_WINDOW: 'only-available-in-window',\n AVAILABLE_IN_SW: 'only-available-in-sw',\n SHOULD_BE_INHERITED: 'should-be-overriden',\n BAD_SENDER_ID: 'bad-sender-id',\n INCORRECT_GCM_SENDER_ID: 'incorrect-gcm-sender-id',\n PERMISSION_DEFAULT: 'permission-default',\n PERMISSION_BLOCKED: 'permission-blocked',\n UNSUPPORTED_BROWSER: 'unsupported-browser',\n NOTIFICATIONS_BLOCKED: 'notifications-blocked',\n FAILED_DEFAULT_REGISTRATION: 'failed-serviceworker-registration',\n SW_REGISTRATION_EXPECTED: 'sw-registration-expected',\n GET_SUBSCRIPTION_FAILED: 'get-subscription-failed',\n INVALID_SAVED_TOKEN: 'invalid-saved-token',\n SW_REG_REDUNDANT: 'sw-reg-redundant',\n TOKEN_SUBSCRIBE_FAILED: 'token-subscribe-failed',\n TOKEN_SUBSCRIBE_NO_TOKEN: 'token-subscribe-no-token',\n TOKEN_SUBSCRIBE_NO_PUSH_SET: 'token-subscribe-no-push-set',\n TOKEN_UNSUBSCRIBE_FAILED: 'token-unsubscribe-failed',\n TOKEN_UPDATE_FAILED: 'token-update-failed',\n TOKEN_UPDATE_NO_TOKEN: 'token-update-no-token',\n USE_SW_BEFORE_GET_TOKEN: 'use-sw-before-get-token',\n INVALID_DELETE_TOKEN: 'invalid-delete-token',\n DELETE_TOKEN_NOT_FOUND: 'delete-token-not-found',\n DELETE_SCOPE_NOT_FOUND: 'delete-scope-not-found',\n BG_HANDLER_FUNCTION_EXPECTED: 'bg-handler-function-expected',\n NO_WINDOW_CLIENT_TO_MSG: 'no-window-client-to-msg',\n UNABLE_TO_RESUBSCRIBE: 'unable-to-resubscribe',\n NO_FCM_TOKEN_FOR_RESUBSCRIBE: 'no-fcm-token-for-resubscribe',\n FAILED_TO_DELETE_TOKEN: 'failed-to-delete-token',\n NO_SW_IN_REG: 'no-sw-in-reg',\n BAD_SCOPE: 'bad-scope',\n BAD_VAPID_KEY: 'bad-vapid-key',\n BAD_SUBSCRIPTION: 'bad-subscription',\n BAD_TOKEN: 'bad-token',\n BAD_PUSH_SET: 'bad-push-set',\n FAILED_DELETE_VAPID_KEY: 'failed-delete-vapid-key',\n INVALID_PUBLIC_VAPID_KEY: 'invalid-public-vapid-key',\n USE_PUBLIC_KEY_BEFORE_GET_TOKEN: 'use-public-key-before-get-token',\n PUBLIC_KEY_DECRYPTION_FAILED: 'public-vapid-key-decryption-failed'\n};\nvar ERROR_MAP = (_a = {},\n _a[CODES.AVAILABLE_IN_WINDOW] = 'This method is available in a Window context.',\n _a[CODES.AVAILABLE_IN_SW] = 'This method is available in a service worker ' + 'context.',\n _a[CODES.SHOULD_BE_INHERITED] = 'This method should be overriden by ' + 'extended classes.',\n _a[CODES.BAD_SENDER_ID] = \"Please ensure that 'messagingSenderId' is set \" +\n 'correctly in the options passed into firebase.initializeApp().',\n _a[CODES.PERMISSION_DEFAULT] = 'The required permissions were not granted and ' + 'dismissed instead.',\n _a[CODES.PERMISSION_BLOCKED] = 'The required permissions were not granted and ' + 'blocked instead.',\n _a[CODES.UNSUPPORTED_BROWSER] = \"This browser doesn't support the API's \" +\n 'required to use the firebase SDK.',\n _a[CODES.NOTIFICATIONS_BLOCKED] = 'Notifications have been blocked.',\n _a[CODES.FAILED_DEFAULT_REGISTRATION] = 'We are unable to register the ' +\n 'default service worker. {$browserErrorMessage}',\n _a[CODES.SW_REGISTRATION_EXPECTED] = 'A service worker registration was the ' + 'expected input.',\n _a[CODES.GET_SUBSCRIPTION_FAILED] = 'There was an error when trying to get ' +\n 'any existing Push Subscriptions.',\n _a[CODES.INVALID_SAVED_TOKEN] = 'Unable to access details of the saved token.',\n _a[CODES.SW_REG_REDUNDANT] = 'The service worker being used for push was made ' + 'redundant.',\n _a[CODES.TOKEN_SUBSCRIBE_FAILED] = 'A problem occured while subscribing the ' + 'user to FCM: {$message}',\n _a[CODES.TOKEN_SUBSCRIBE_NO_TOKEN] = 'FCM returned no token when subscribing ' + 'the user to push.',\n _a[CODES.TOKEN_SUBSCRIBE_NO_PUSH_SET] = 'FCM returned an invalid response ' + 'when getting an FCM token.',\n _a[CODES.TOKEN_UNSUBSCRIBE_FAILED] = 'A problem occured while unsubscribing the ' + 'user from FCM: {$message}',\n _a[CODES.TOKEN_UPDATE_FAILED] = 'A problem occured while updating the ' + 'user from FCM: {$message}',\n _a[CODES.TOKEN_UPDATE_NO_TOKEN] = 'FCM returned no token when updating ' + 'the user to push.',\n _a[CODES.USE_SW_BEFORE_GET_TOKEN] = 'You must call useServiceWorker() before ' +\n 'calling getToken() to ensure your service worker is used.',\n _a[CODES.INVALID_DELETE_TOKEN] = 'You must pass a valid token into ' +\n 'deleteToken(), i.e. the token from getToken().',\n _a[CODES.DELETE_TOKEN_NOT_FOUND] = 'The deletion attempt for token could not ' +\n 'be performed as the token was not found.',\n _a[CODES.DELETE_SCOPE_NOT_FOUND] = 'The deletion attempt for service worker ' +\n 'scope could not be performed as the scope was not found.',\n _a[CODES.BG_HANDLER_FUNCTION_EXPECTED] = 'The input to ' + 'setBackgroundMessageHandler() must be a function.',\n _a[CODES.NO_WINDOW_CLIENT_TO_MSG] = 'An attempt was made to message a ' + 'non-existant window client.',\n _a[CODES.UNABLE_TO_RESUBSCRIBE] = 'There was an error while re-subscribing ' +\n 'the FCM token for push messaging. Will have to resubscribe the ' +\n 'user on next visit. {$message}',\n _a[CODES.NO_FCM_TOKEN_FOR_RESUBSCRIBE] = 'Could not find an FCM token ' +\n 'and as a result, unable to resubscribe. Will have to resubscribe the ' +\n 'user on next visit.',\n _a[CODES.FAILED_TO_DELETE_TOKEN] = 'Unable to delete the currently saved token.',\n _a[CODES.NO_SW_IN_REG] = 'Even though the service worker registration was ' +\n 'successful, there was a problem accessing the service worker itself.',\n _a[CODES.INCORRECT_GCM_SENDER_ID] = \"Please change your web app manifest's \" +\n \"'gcm_sender_id' value to '103953800507' to use Firebase messaging.\",\n _a[CODES.BAD_SCOPE] = 'The service worker scope must be a string with at ' +\n 'least one character.',\n _a[CODES.BAD_VAPID_KEY] = 'The public VAPID key is not a Uint8Array with 65 bytes.',\n _a[CODES.BAD_SUBSCRIPTION] = 'The subscription must be a valid ' + 'PushSubscription.',\n _a[CODES.BAD_TOKEN] = 'The FCM Token used for storage / lookup was not ' +\n 'a valid token string.',\n _a[CODES.BAD_PUSH_SET] = 'The FCM push set used for storage / lookup was not ' +\n 'not a valid push set string.',\n _a[CODES.FAILED_DELETE_VAPID_KEY] = 'The VAPID key could not be deleted.',\n _a[CODES.INVALID_PUBLIC_VAPID_KEY] = 'The public VAPID key must be a string.',\n _a[CODES.PUBLIC_KEY_DECRYPTION_FAILED] = 'The public VAPID key did not equal ' + '65 bytes when decrypted.',\n _a);\nexport default {\n codes: CODES,\n map: ERROR_MAP\n};\nvar _a;\n\n//# sourceMappingURL=errors.js.map\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ../messaging/dist/esm/src/models/errors.js\n// module id = null\n// module chunks = ","/**\n * Copyright 2017 Google Inc.\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'use strict';\nimport { ErrorFactory } from '@firebase/util';\nimport Errors from './errors';\nvar DBInterface = /** @class */ (function () {\n /**\n * @param {string} dbName\n * @param {number} dbVersion\n */\n function DBInterface(dbName, dbVersion) {\n this.errorFactory_ = new ErrorFactory('messaging', 'Messaging', Errors.map);\n this.DB_NAME_ = dbName;\n this.dbVersion_ = dbVersion;\n this.openDbPromise_ = null;\n this.TRANSACTION_READ_WRITE = 'readwrite';\n }\n /**\n * Get the indexedDB as a promsie.\n * @protected\n * @return {!Promise} The IndexedDB database\n */\n DBInterface.prototype.openDatabase = function () {\n var _this = this;\n if (this.openDbPromise_) {\n return this.openDbPromise_;\n }\n this.openDbPromise_ = new Promise(function (resolve, reject) {\n var request = indexedDB.open(_this.DB_NAME_, _this.dbVersion_);\n request.onerror = function (event) {\n reject(event.target.error);\n };\n request.onsuccess = function (event) {\n resolve(event.target.result);\n };\n request.onupgradeneeded = function (event) {\n try {\n var db = event.target.result;\n _this.onDBUpgrade(db, event);\n }\n catch (err) {\n // close the database as it can't be used.\n db.close();\n reject(err);\n }\n };\n });\n return this.openDbPromise_;\n };\n /**\n * Close the currently open database.\n * @return {!Promise} Returns the result of the promise chain.\n */\n DBInterface.prototype.closeDatabase = function () {\n var _this = this;\n return Promise.resolve().then(function () {\n if (_this.openDbPromise_) {\n return _this.openDbPromise_.then(function (db) {\n db.close();\n _this.openDbPromise_ = null;\n });\n }\n });\n };\n /**\n * @protected\n * @param {!IDBDatabase} db\n */\n DBInterface.prototype.onDBUpgrade = function (db, event) {\n throw this.errorFactory_.create(Errors.codes.SHOULD_BE_INHERITED);\n };\n return DBInterface;\n}());\nexport default DBInterface;\n\n//# sourceMappingURL=db-interface.js.map\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ../messaging/dist/esm/src/models/db-interface.js\n// module id = null\n// module chunks = ","/**\n * Copyright 2017 Google Inc.\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'use strict';\nvar DEFAULT_PUBLIC_VAPID_KEY = new Uint8Array([\n 0x04,\n 0x33,\n 0x94,\n 0xf7,\n 0xdf,\n 0xa1,\n 0xeb,\n 0xb1,\n 0xdc,\n 0x03,\n 0xa2,\n 0x5e,\n 0x15,\n 0x71,\n 0xdb,\n 0x48,\n 0xd3,\n 0x2e,\n 0xed,\n 0xed,\n 0xb2,\n 0x34,\n 0xdb,\n 0xb7,\n 0x47,\n 0x3a,\n 0x0c,\n 0x8f,\n 0xc4,\n 0xcc,\n 0xe1,\n 0x6f,\n 0x3c,\n 0x8c,\n 0x84,\n 0xdf,\n 0xab,\n 0xb6,\n 0x66,\n 0x3e,\n 0xf2,\n 0x0c,\n 0xd4,\n 0x8b,\n 0xfe,\n 0xe3,\n 0xf9,\n 0x76,\n 0x2f,\n 0x14,\n 0x1c,\n 0x63,\n 0x08,\n 0x6a,\n 0x6f,\n 0x2d,\n 0xb1,\n 0x1a,\n 0x95,\n 0xb0,\n 0xce,\n 0x37,\n 0xc0,\n 0x9c,\n 0x6e\n]);\nvar SUBSCRIPTION_DETAILS = {\n userVisibleOnly: true,\n applicationServerKey: DEFAULT_PUBLIC_VAPID_KEY\n};\nexport default {\n DEFAULT_PUBLIC_VAPID_KEY: DEFAULT_PUBLIC_VAPID_KEY,\n SUBSCRIPTION_DETAILS: SUBSCRIPTION_DETAILS,\n ENDPOINT: 'https://fcm.googleapis.com'\n // ENDPOINT: 'https://jmt17.google.com'\n};\n\n//# sourceMappingURL=fcm-details.js.map\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ../messaging/dist/esm/src/models/fcm-details.js\n// module id = null\n// module chunks = ","/**\n * Copyright 2017 Google Inc.\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'use strict';\nimport { ErrorFactory } from '@firebase/util';\nimport Errors from './errors';\nimport arrayBufferToBase64 from '../helpers/array-buffer-to-base64';\nimport FCMDetails from './fcm-details';\nvar IIDModel = /** @class */ (function () {\n function IIDModel() {\n this.errorFactory_ = new ErrorFactory('messaging', 'Messaging', Errors.map);\n }\n /**\n * Given a PushSubscription and messagingSenderId, get an FCM token.\n * @public\n * @param {string} senderId The 'messagingSenderId' to tie the token to.\n * @param {PushSubscription} subscription The PushSusbcription to \"federate\".\n * @param {Uint8Array} publicVapidKey The public VAPID key.\n * @return {Promise} Returns the FCM token to be used in place\n * of the PushSubscription.\n */\n IIDModel.prototype.getToken = function (senderId, subscription, publicVapidKey) {\n var _this = this;\n var p256dh = arrayBufferToBase64(subscription['getKey']('p256dh'));\n var auth = arrayBufferToBase64(subscription['getKey']('auth'));\n var fcmSubscribeBody = \"authorized_entity=\" + senderId + \"&\" +\n (\"endpoint=\" + subscription.endpoint + \"&\") +\n (\"encryption_key=\" + p256dh + \"&\") +\n (\"encryption_auth=\" + auth);\n if (publicVapidKey !== FCMDetails.DEFAULT_PUBLIC_VAPID_KEY) {\n var applicationPubKey = arrayBufferToBase64(publicVapidKey);\n fcmSubscribeBody += \"&application_pub_key=\" + applicationPubKey;\n }\n var headers = new Headers();\n headers.append('Content-Type', 'application/x-www-form-urlencoded');\n var subscribeOptions = {\n method: 'POST',\n headers: headers,\n body: fcmSubscribeBody\n };\n return fetch(FCMDetails.ENDPOINT + '/fcm/connect/subscribe', subscribeOptions)\n .then(function (response) { return response.json(); })\n .catch(function () {\n throw _this.errorFactory_.create(Errors.codes.TOKEN_SUBSCRIBE_FAILED);\n })\n .then(function (response) {\n var fcmTokenResponse = response;\n if (fcmTokenResponse['error']) {\n var message = fcmTokenResponse['error']['message'];\n throw _this.errorFactory_.create(Errors.codes.TOKEN_SUBSCRIBE_FAILED, {\n message: message\n });\n }\n if (!fcmTokenResponse['token']) {\n throw _this.errorFactory_.create(Errors.codes.TOKEN_SUBSCRIBE_NO_TOKEN);\n }\n if (!fcmTokenResponse['pushSet']) {\n throw _this.errorFactory_.create(Errors.codes.TOKEN_SUBSCRIBE_NO_PUSH_SET);\n }\n return {\n token: fcmTokenResponse['token'],\n pushSet: fcmTokenResponse['pushSet']\n };\n });\n };\n /**\n * Update the underlying token details for fcmToken.\n */\n IIDModel.prototype.updateToken = function (senderId, fcmToken, fcmPushSet, subscription, publicVapidKey) {\n var _this = this;\n var p256dh = arrayBufferToBase64(subscription['getKey']('p256dh'));\n var auth = arrayBufferToBase64(subscription['getKey']('auth'));\n var fcmUpdateBody = \"push_set=\" + fcmPushSet + \"&\" +\n (\"token=\" + fcmToken + \"&\") +\n (\"authorized_entity=\" + senderId + \"&\") +\n (\"endpoint=\" + subscription.endpoint + \"&\") +\n (\"encryption_key=\" + p256dh + \"&\") +\n (\"encryption_auth=\" + auth);\n if (publicVapidKey !== FCMDetails.DEFAULT_PUBLIC_VAPID_KEY) {\n var applicationPubKey = arrayBufferToBase64(publicVapidKey);\n fcmUpdateBody += \"&application_pub_key=\" + applicationPubKey;\n }\n var headers = new Headers();\n headers.append('Content-Type', 'application/x-www-form-urlencoded');\n var updateOptions = {\n method: 'POST',\n headers: headers,\n body: fcmUpdateBody\n };\n var updateFetchRes;\n return fetch(FCMDetails.ENDPOINT + '/fcm/connect/subscribe', updateOptions)\n .then(function (fetchResponse) {\n updateFetchRes = fetchResponse;\n return fetchResponse.json();\n })\n .catch(function () {\n throw _this.errorFactory_.create(Errors.codes.TOKEN_UPDATE_FAILED);\n })\n .then(function (fcmTokenResponse) {\n if (!updateFetchRes.ok) {\n var message = fcmTokenResponse['error']['message'];\n throw _this.errorFactory_.create(Errors.codes.TOKEN_UPDATE_FAILED, {\n message: message\n });\n }\n if (!fcmTokenResponse['token']) {\n throw _this.errorFactory_.create(Errors.codes.TOKEN_UPDATE_NO_TOKEN);\n }\n return fcmTokenResponse['token'];\n });\n };\n /**\n * Given a fcmToken, pushSet and messagingSenderId, delete an FCM token.\n */\n IIDModel.prototype.deleteToken = function (senderId, fcmToken, fcmPushSet) {\n var _this = this;\n var fcmUnsubscribeBody = \"authorized_entity=\" + senderId + \"&\" +\n (\"token=\" + fcmToken + \"&\") +\n (\"pushSet=\" + fcmPushSet);\n var headers = new Headers();\n headers.append('Content-Type', 'application/x-www-form-urlencoded');\n var unsubscribeOptions = {\n method: 'POST',\n headers: headers,\n body: fcmUnsubscribeBody\n };\n return fetch(FCMDetails.ENDPOINT + '/fcm/connect/unsubscribe', unsubscribeOptions).then(function (fetchResponse) {\n if (!fetchResponse.ok) {\n return fetchResponse.json().then(function (fcmTokenResponse) {\n if (fcmTokenResponse['error']) {\n var message = fcmTokenResponse['error']['message'];\n throw _this.errorFactory_.create(Errors.codes.TOKEN_UNSUBSCRIBE_FAILED, {\n message: message\n });\n }\n }, function (err) {\n throw _this.errorFactory_.create(Errors.codes.TOKEN_UNSUBSCRIBE_FAILED);\n });\n }\n });\n };\n return IIDModel;\n}());\nexport default IIDModel;\n\n//# sourceMappingURL=iid-model.js.map\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ../messaging/dist/esm/src/models/iid-model.js\n// module id = null\n// module chunks = ","/**\n * Copyright 2017 Google Inc.\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'use strict';\nimport * as tslib_1 from \"tslib\";\nimport DBInterface from './db-interface';\nimport Errors from './errors';\nvar FCM_VAPID_OBJ_STORE = 'fcm_vapid_object_Store';\nvar DB_NAME = 'fcm_vapid_details_db';\nvar DB_VERSION = 1;\nvar UNCOMPRESSED_PUBLIC_KEY_SIZE = 65;\nvar VapidDetailsModel = /** @class */ (function (_super) {\n tslib_1.__extends(VapidDetailsModel, _super);\n function VapidDetailsModel() {\n return _super.call(this, DB_NAME, DB_VERSION) || this;\n }\n /**\n * @override\n * @param {IDBDatabase} db\n */\n VapidDetailsModel.prototype.onDBUpgrade = function (db) {\n db.createObjectStore(FCM_VAPID_OBJ_STORE, {\n keyPath: 'swScope'\n });\n };\n /**\n * Given a service worker scope, this method will look up the vapid key\n * in indexedDB.\n */\n VapidDetailsModel.prototype.getVapidFromSWScope = function (swScope) {\n if (typeof swScope !== 'string' || swScope.length === 0) {\n return Promise.reject(this.errorFactory_.create(Errors.codes.BAD_SCOPE));\n }\n return this.openDatabase().then(function (db) {\n return new Promise(function (resolve, reject) {\n var transaction = db.transaction([FCM_VAPID_OBJ_STORE]);\n var objectStore = transaction.objectStore(FCM_VAPID_OBJ_STORE);\n var scopeRequest = objectStore.get(swScope);\n scopeRequest.onerror = function () {\n reject(scopeRequest.error);\n };\n scopeRequest.onsuccess = function () {\n var result = scopeRequest.result;\n var vapidKey = null;\n if (result) {\n vapidKey = result.vapidKey;\n }\n resolve(vapidKey);\n };\n });\n });\n };\n /**\n * Save a vapid key against a swScope for later date.\n */\n VapidDetailsModel.prototype.saveVapidDetails = function (swScope, vapidKey) {\n var _this = this;\n if (typeof swScope !== 'string' || swScope.length === 0) {\n return Promise.reject(this.errorFactory_.create(Errors.codes.BAD_SCOPE));\n }\n if (vapidKey === null || vapidKey.length !== UNCOMPRESSED_PUBLIC_KEY_SIZE) {\n return Promise.reject(this.errorFactory_.create(Errors.codes.BAD_VAPID_KEY));\n }\n var details = {\n swScope: swScope,\n vapidKey: vapidKey\n };\n return this.openDatabase().then(function (db) {\n return new Promise(function (resolve, reject) {\n var transaction = db.transaction([FCM_VAPID_OBJ_STORE], _this.TRANSACTION_READ_WRITE);\n var objectStore = transaction.objectStore(FCM_VAPID_OBJ_STORE);\n var request = objectStore.put(details);\n request.onerror = function () {\n reject(request.error);\n };\n request.onsuccess = function () {\n resolve();\n };\n });\n });\n };\n /**\n * This method deletes details of the current FCM VAPID key for a SW scope.\n * Resolves once the scope/vapid details have been deleted and returns the\n * deleted vapid key.\n */\n VapidDetailsModel.prototype.deleteVapidDetails = function (swScope) {\n var _this = this;\n return this.getVapidFromSWScope(swScope).then(function (vapidKey) {\n if (!vapidKey) {\n throw _this.errorFactory_.create(Errors.codes.DELETE_SCOPE_NOT_FOUND);\n }\n return _this.openDatabase().then(function (db) {\n return new Promise(function (resolve, reject) {\n var transaction = db.transaction([FCM_VAPID_OBJ_STORE], _this.TRANSACTION_READ_WRITE);\n var objectStore = transaction.objectStore(FCM_VAPID_OBJ_STORE);\n var request = objectStore.delete(swScope);\n request.onerror = function () {\n reject(request.error);\n };\n request.onsuccess = function () {\n if (request.result === 0) {\n reject(_this.errorFactory_.create(Errors.codes.FAILED_DELETE_VAPID_KEY));\n return;\n }\n resolve(vapidKey);\n };\n });\n });\n });\n };\n return VapidDetailsModel;\n}(DBInterface));\nexport default VapidDetailsModel;\n\n//# sourceMappingURL=vapid-details-model.js.map\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ../messaging/dist/esm/src/models/vapid-details-model.js\n// module id = null\n// module chunks = ","/**\n * Copyright 2017 Google Inc.\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'use strict';\nimport { ErrorFactory } from '@firebase/util';\nimport Errors from '../models/errors';\nimport TokenDetailsModel from '../models/token-details-model';\nimport VapidDetailsModel from '../models/vapid-details-model';\nimport NOTIFICATION_PERMISSION from '../models/notification-permission';\nimport IIDModel from '../models/iid-model';\nimport arrayBufferToBase64 from '../helpers/array-buffer-to-base64';\nvar SENDER_ID_OPTION_NAME = 'messagingSenderId';\n// Database cache should be invalidated once a week.\nexport var TOKEN_EXPIRATION_MILLIS = 7 * 24 * 60 * 60 * 1000; // 7 days\nvar ControllerInterface = /** @class */ (function () {\n /**\n * An interface of the Messaging Service API\n * @param {!firebase.app.App} app\n */\n function ControllerInterface(app) {\n var _this = this;\n this.errorFactory_ = new ErrorFactory('messaging', 'Messaging', Errors.map);\n if (!app.options[SENDER_ID_OPTION_NAME] ||\n typeof app.options[SENDER_ID_OPTION_NAME] !== 'string') {\n throw this.errorFactory_.create(Errors.codes.BAD_SENDER_ID);\n }\n this.messagingSenderId_ = app.options[SENDER_ID_OPTION_NAME];\n this.tokenDetailsModel_ = new TokenDetailsModel();\n this.vapidDetailsModel_ = new VapidDetailsModel();\n this.iidModel_ = new IIDModel();\n this.app = app;\n this.INTERNAL = {};\n this.INTERNAL.delete = function () { return _this.delete(); };\n }\n /**\n * @export\n */\n ControllerInterface.prototype.getToken = function () {\n var _this = this;\n // Check with permissions\n var currentPermission = this.getNotificationPermission_();\n if (currentPermission !== NOTIFICATION_PERMISSION.granted) {\n if (currentPermission === NOTIFICATION_PERMISSION.denied) {\n return Promise.reject(this.errorFactory_.create(Errors.codes.NOTIFICATIONS_BLOCKED));\n }\n // We must wait for permission to be granted\n return Promise.resolve(null);\n }\n var swReg;\n return this.getSWRegistration_()\n .then(function (reg) {\n swReg = reg;\n return _this.tokenDetailsModel_.getTokenDetailsFromSWScope(swReg.scope);\n })\n .then(function (tokenDetails) {\n if (tokenDetails) {\n return _this.manageExistingToken(tokenDetails, swReg);\n }\n return _this.getNewToken(swReg);\n });\n };\n /**\n * manageExistingToken is triggered if there's an existing FCM token in the\n * database and it can take 3 different actions:\n * 1) Retrieve the existing FCM token from the database.\n * 2) If VAPID details have changed: Delete the existing token and create a\n * new one with the new VAPID key.\n * 3) If the database cache is invalidated: Send a request to FCM to update\n * the token, and to check if the token is still valid on FCM-side.\n */\n ControllerInterface.prototype.manageExistingToken = function (tokenDetails, swReg) {\n var _this = this;\n return this.isTokenStillValid(tokenDetails).then(function (isValid) {\n if (isValid) {\n var now = Date.now();\n if (now < tokenDetails['createTime'] + TOKEN_EXPIRATION_MILLIS) {\n return tokenDetails['fcmToken'];\n }\n else {\n return _this.updateToken(tokenDetails, swReg);\n }\n }\n else {\n // If the VAPID details are updated, delete the existing token,\n // and create a new one.\n return _this.deleteToken(tokenDetails['fcmToken']).then(function () {\n return _this.getNewToken(swReg);\n });\n }\n });\n };\n /*\n * Checks if the tokenDetails match the details provided in the clients.\n */\n ControllerInterface.prototype.isTokenStillValid = function (tokenDetails) {\n // TODO Validate rest of the details.\n return this.getPublicVapidKey_().then(function (publicKey) {\n if (arrayBufferToBase64(publicKey) !== tokenDetails['vapidKey']) {\n return false;\n }\n return true;\n });\n };\n ControllerInterface.prototype.updateToken = function (tokenDetails, swReg) {\n var _this = this;\n var publicVapidKey;\n var updatedToken;\n var subscription;\n return this.getPublicVapidKey_()\n .then(function (publicKey) {\n publicVapidKey = publicKey;\n return _this.getPushSubscription_(swReg, publicVapidKey);\n })\n .then(function (pushSubscription) {\n subscription = pushSubscription;\n return _this.iidModel_.updateToken(_this.messagingSenderId_, tokenDetails['fcmToken'], tokenDetails['fcmPushSet'], subscription, publicVapidKey);\n })\n .catch(function (err) {\n return _this.deleteToken(tokenDetails['fcmToken']).then(function () {\n throw err;\n });\n })\n .then(function (token) {\n updatedToken = token;\n var allDetails = {\n swScope: swReg.scope,\n vapidKey: publicVapidKey,\n subscription: subscription,\n fcmSenderId: _this.messagingSenderId_,\n fcmToken: updatedToken,\n fcmPushSet: tokenDetails['fcmPushSet']\n };\n return _this.tokenDetailsModel_.saveTokenDetails(allDetails);\n })\n .then(function () {\n return _this.vapidDetailsModel_.saveVapidDetails(swReg.scope, publicVapidKey);\n })\n .then(function () {\n return updatedToken;\n });\n };\n ControllerInterface.prototype.getNewToken = function (swReg) {\n var _this = this;\n var publicVapidKey;\n var subscription;\n var tokenDetails;\n return this.getPublicVapidKey_()\n .then(function (publicKey) {\n publicVapidKey = publicKey;\n return _this.getPushSubscription_(swReg, publicVapidKey);\n })\n .then(function (pushSubscription) {\n subscription = pushSubscription;\n return _this.iidModel_.getToken(_this.messagingSenderId_, subscription, publicVapidKey);\n })\n .then(function (iidTokenDetails) {\n tokenDetails = iidTokenDetails;\n var allDetails = {\n swScope: swReg.scope,\n vapidKey: publicVapidKey,\n subscription: subscription,\n fcmSenderId: _this.messagingSenderId_,\n fcmToken: tokenDetails['token'],\n fcmPushSet: tokenDetails['pushSet']\n };\n return _this.tokenDetailsModel_.saveTokenDetails(allDetails);\n })\n .then(function () {\n return _this.vapidDetailsModel_.saveVapidDetails(swReg.scope, publicVapidKey);\n })\n .then(function () {\n return tokenDetails['token'];\n });\n };\n /**\n * This method deletes tokens that the token manager looks after,\n * unsubscribes the token from FCM and then unregisters the push\n * subscription if it exists. It returns a promise that indicates\n * whether or not the unsubscribe request was processed successfully.\n * @export\n */\n ControllerInterface.prototype.deleteToken = function (token) {\n var _this = this;\n return this.tokenDetailsModel_\n .deleteToken(token)\n .then(function (details) {\n return _this.iidModel_.deleteToken(details['fcmSenderId'], details['fcmToken'], details['fcmPushSet']);\n })\n .then(function () {\n return _this.getSWRegistration_()\n .then(function (registration) {\n if (registration) {\n return registration.pushManager.getSubscription();\n }\n })\n .then(function (subscription) {\n if (subscription) {\n return subscription.unsubscribe();\n }\n });\n });\n };\n ControllerInterface.prototype.getSWRegistration_ = function () {\n throw this.errorFactory_.create(Errors.codes.SHOULD_BE_INHERITED);\n };\n ControllerInterface.prototype.getPublicVapidKey_ = function () {\n throw this.errorFactory_.create(Errors.codes.SHOULD_BE_INHERITED);\n };\n //\n // The following methods should only be available in the window.\n //\n ControllerInterface.prototype.requestPermission = function () {\n throw this.errorFactory_.create(Errors.codes.AVAILABLE_IN_WINDOW);\n };\n ControllerInterface.prototype.getPushSubscription_ = function (registration, publicVapidKey) {\n throw this.errorFactory_.create(Errors.codes.AVAILABLE_IN_WINDOW);\n };\n /**\n * @export\n * @param {!ServiceWorkerRegistration} registration\n */\n ControllerInterface.prototype.useServiceWorker = function (registration) {\n throw this.errorFactory_.create(Errors.codes.AVAILABLE_IN_WINDOW);\n };\n /**\n * @export\n * @param {!string} b64PublicKey\n */\n ControllerInterface.prototype.usePublicVapidKey = function (b64PublicKey) {\n throw this.errorFactory_.create(Errors.codes.AVAILABLE_IN_WINDOW);\n };\n /**\n * @export\n * @param {!firebase.Observer|function(*)} nextOrObserver\n * @param {function(!Error)=} optError\n * @param {function()=} optCompleted\n * @return {!function()}\n */\n ControllerInterface.prototype.onMessage = function (nextOrObserver, optError, optCompleted) {\n throw this.errorFactory_.create(Errors.codes.AVAILABLE_IN_WINDOW);\n };\n /**\n * @export\n * @param {!firebase.Observer|function()} nextOrObserver An observer object\n * or a function triggered on token refresh.\n * @param {function(!Error)=} optError Optional A function\n * triggered on token refresh error.\n * @param {function()=} optCompleted Optional function triggered when the\n * observer is removed.\n * @return {!function()} The unsubscribe function for the observer.\n */\n ControllerInterface.prototype.onTokenRefresh = function (nextOrObserver, optError, optCompleted) {\n throw this.errorFactory_.create(Errors.codes.AVAILABLE_IN_WINDOW);\n };\n //\n // The following methods are used by the service worker only.\n //\n /**\n * @export\n * @param {function(Object)} callback\n */\n ControllerInterface.prototype.setBackgroundMessageHandler = function (callback) {\n throw this.errorFactory_.create(Errors.codes.AVAILABLE_IN_SW);\n };\n //\n // The following methods are used by the service themselves and not exposed\n // publicly or not expected to be used by developers.\n //\n /**\n * This method is required to adhere to the Firebase interface.\n * It closes any currently open indexdb database connections.\n */\n ControllerInterface.prototype.delete = function () {\n return Promise.all([\n this.tokenDetailsModel_.closeDatabase(),\n this.vapidDetailsModel_.closeDatabase()\n ]);\n };\n /**\n * Returns the current Notification Permission state.\n * @private\n * @return {string} The currenct permission state.\n */\n ControllerInterface.prototype.getNotificationPermission_ = function () {\n return Notification.permission;\n };\n ControllerInterface.prototype.getTokenDetailsModel = function () {\n return this.tokenDetailsModel_;\n };\n ControllerInterface.prototype.getVapidDetailsModel = function () {\n return this.vapidDetailsModel_;\n };\n /**\n * @protected\n * @returns {IIDModel}\n */\n ControllerInterface.prototype.getIIDModel = function () {\n return this.iidModel_;\n };\n return ControllerInterface;\n}());\nexport default ControllerInterface;\n\n//# sourceMappingURL=controller-interface.js.map\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ../messaging/dist/esm/src/controllers/controller-interface.js\n// module id = null\n// module chunks = ","/**\n * Copyright 2017 Google Inc.\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'use strict';\n// These fields are strings to prevent closure from thinking goog.getMsg\n// should be used to initialise the values\nvar PARAMS = {\n TYPE_OF_MSG: 'firebase-messaging-msg-type',\n DATA: 'firebase-messaging-msg-data'\n};\n// This value isn't using the TYPE_OF_MSG short hand as closure\n// expects the variable to be defined via goog.getMsg\nvar msgType = {\n PUSH_MSG_RECEIVED: 'push-msg-received',\n NOTIFICATION_CLICKED: 'notification-clicked'\n};\nvar createNewMsg = function (msgType, msgData) {\n var message = (_a = {},\n _a[PARAMS.TYPE_OF_MSG] = msgType,\n _a[PARAMS.DATA] = msgData,\n _a);\n return message;\n var _a;\n};\nexport default {\n PARAMS: PARAMS,\n TYPES_OF_MSG: msgType,\n createNewMsg: createNewMsg\n};\n\n//# sourceMappingURL=worker-page-message.js.map\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ../messaging/dist/esm/src/models/worker-page-message.js\n// module id = null\n// module chunks = ","/**\n * Copyright 2017 Google Inc.\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'use strict';\nexport default {\n path: '/firebase-messaging-sw.js',\n scope: '/firebase-cloud-messaging-push-scope'\n};\n\n//# sourceMappingURL=default-sw.js.map\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ../messaging/dist/esm/src/models/default-sw.js\n// module id = null\n// module chunks = ","/**\n * Copyright 2017 Google Inc.\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 */\nexport default (function (base64String) {\n var padding = '='.repeat((4 - base64String.length % 4) % 4);\n var base64 = (base64String + padding)\n .replace(/\\-/g, '+')\n .replace(/_/g, '/');\n var rawData = window.atob(base64);\n var outputArray = new Uint8Array(rawData.length);\n for (var i = 0; i < rawData.length; ++i) {\n outputArray[i] = rawData.charCodeAt(i);\n }\n return outputArray;\n});\n\n//# sourceMappingURL=base64-to-array-buffer.js.map\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ../messaging/dist/esm/src/helpers/base64-to-array-buffer.js\n// module id = null\n// module chunks = ","/**\n * Copyright 2017 Google Inc.\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'use strict';\nimport * as tslib_1 from \"tslib\";\nimport ControllerInterface from './controller-interface';\nimport Errors from '../models/errors';\nimport WorkerPageMessage from '../models/worker-page-message';\nimport DefaultSW from '../models/default-sw';\nimport NOTIFICATION_PERMISSION from '../models/notification-permission';\nimport FCMDetails from '../models/fcm-details';\nimport base64ToArrayBuffer from '../helpers/base64-to-array-buffer';\nimport { createSubscribe } from '@firebase/util';\nvar WindowController = /** @class */ (function (_super) {\n tslib_1.__extends(WindowController, _super);\n /**\n * A service that provides a MessagingService instance.\n * @param {!firebase.app.App} app\n */\n function WindowController(app) {\n var _this = _super.call(this, app) || this;\n _this.messageObserver_ = null;\n _this.onMessage_ = createSubscribe(function (observer) {\n _this.messageObserver_ = observer;\n });\n _this.tokenRefreshObserver_ = null;\n _this.onTokenRefresh_ = createSubscribe(function (observer) {\n _this.tokenRefreshObserver_ = observer;\n });\n /**\n * @private\n * @type {ServiceWorkerRegistration}\n */\n _this.registrationToUse_;\n /**\n * @private\n * @type {Promise}\n */\n _this.manifestCheckPromise_;\n /**\n * @private\n * @type {firebase.Observer}\n */\n _this.messageObserver_ = null;\n /**\n * @private {!firebase.Subscribe} The subscribe function to the onMessage\n * observer.\n */\n _this.onMessage_ = createSubscribe(function (observer) {\n _this.messageObserver_ = observer;\n });\n /**\n * @private\n * @type {firebase.Observer}\n */\n _this.tokenRefreshObserver_ = null;\n _this.onTokenRefresh_ = createSubscribe(function (observer) {\n _this.tokenRefreshObserver_ = observer;\n });\n _this.setupSWMessageListener_();\n return _this;\n }\n /**\n * This method returns an FCM token if it can be generated.\n * The return promise will reject if the browser doesn't support\n * FCM, if permission is denied for notifications or it's not\n * possible to generate a token.\n * @export\n * @return {Promise | Promise} Returns a promise the\n * resolves to an FCM token or null if permission isn't granted.\n */\n WindowController.prototype.getToken = function () {\n var _this = this;\n // Check that the required API's are available\n if (!this.isSupported_()) {\n return Promise.reject(this.errorFactory_.create(Errors.codes.UNSUPPORTED_BROWSER));\n }\n return this.manifestCheck_().then(function () {\n return _super.prototype.getToken.call(_this);\n });\n };\n /**\n * The method checks that a manifest is defined and has the correct GCM\n * sender ID.\n * @private\n * @return {Promise} Returns a promise that resolves if the manifest matches\n * our required sender ID\n */\n WindowController.prototype.manifestCheck_ = function () {\n var _this = this;\n if (this.manifestCheckPromise_) {\n return this.manifestCheckPromise_;\n }\n var manifestTag = document.querySelector('link[rel=\"manifest\"]');\n if (!manifestTag) {\n this.manifestCheckPromise_ = Promise.resolve();\n }\n else {\n this.manifestCheckPromise_ = fetch(manifestTag.href)\n .then(function (response) {\n return response.json();\n })\n .catch(function () {\n // If the download or parsing fails allow check.\n // We only want to error if we KNOW that the gcm_sender_id is incorrect.\n })\n .then(function (manifestContent) {\n if (!manifestContent) {\n return;\n }\n if (!manifestContent['gcm_sender_id']) {\n return;\n }\n if (manifestContent['gcm_sender_id'] !== '103953800507') {\n throw _this.errorFactory_.create(Errors.codes.INCORRECT_GCM_SENDER_ID);\n }\n });\n }\n return this.manifestCheckPromise_;\n };\n /**\n * Request permission if it is not currently granted\n * @export\n * @returns {Promise} Resolves if the permission was granted, otherwise\n * rejects\n */\n WindowController.prototype.requestPermission = function () {\n return tslib_1.__awaiter(this, void 0, void 0, function () {\n var _this = this;\n return tslib_1.__generator(this, function (_a) {\n if (Notification.permission === NOTIFICATION_PERMISSION.granted) {\n return [2 /*return*/];\n }\n return [2 /*return*/, new Promise(function (resolve, reject) {\n var managePermissionResult = function (result) {\n if (result === NOTIFICATION_PERMISSION.granted) {\n return resolve();\n }\n else if (result === NOTIFICATION_PERMISSION.denied) {\n return reject(_this.errorFactory_.create(Errors.codes.PERMISSION_BLOCKED));\n }\n else {\n return reject(_this.errorFactory_.create(Errors.codes.PERMISSION_DEFAULT));\n }\n };\n // The Notification.requestPermission API was changed to\n // return a promise so now have to handle both in case\n // browsers stop support callbacks for promised version\n var permissionPromise = Notification.requestPermission(managePermissionResult);\n if (permissionPromise) {\n // Prefer the promise version as it's the future API.\n permissionPromise.then(managePermissionResult);\n }\n })];\n });\n });\n };\n /**\n * This method allows a developer to override the default service worker and\n * instead use a custom service worker.\n * @export\n * @param {!ServiceWorkerRegistration} registration The service worker\n * registration that should be used to receive the push messages.\n */\n WindowController.prototype.useServiceWorker = function (registration) {\n if (!(registration instanceof ServiceWorkerRegistration)) {\n throw this.errorFactory_.create(Errors.codes.SW_REGISTRATION_EXPECTED);\n }\n if (typeof this.registrationToUse_ !== 'undefined') {\n throw this.errorFactory_.create(Errors.codes.USE_SW_BEFORE_GET_TOKEN);\n }\n this.registrationToUse_ = registration;\n };\n /**\n * This method allows a developer to override the default vapid key\n * and instead use a custom VAPID public key.\n * @export\n * @param {!string} publicKey A URL safe base64 encoded string.\n */\n WindowController.prototype.usePublicVapidKey = function (publicKey) {\n if (typeof publicKey !== 'string') {\n throw this.errorFactory_.create(Errors.codes.INVALID_PUBLIC_VAPID_KEY);\n }\n if (typeof this.publicVapidKeyToUse_ !== 'undefined') {\n throw this.errorFactory_.create(Errors.codes.USE_PUBLIC_KEY_BEFORE_GET_TOKEN);\n }\n var parsedKey = base64ToArrayBuffer(publicKey);\n if (parsedKey.length !== 65) {\n throw this.errorFactory_.create(Errors.codes.PUBLIC_KEY_DECRYPTION_FAILED);\n }\n this.publicVapidKeyToUse_ = parsedKey;\n };\n /**\n * @export\n * @param {!firebase.Observer|function(*)} nextOrObserver An observer object\n * or a function triggered on message.\n * @param {function(!Error)=} optError Optional A function triggered on\n * message error.\n * @param {function()=} optCompleted Optional function triggered when the\n * observer is removed.\n * @return {!function()} The unsubscribe function for the observer.\n */\n WindowController.prototype.onMessage = function (nextOrObserver, optError, optCompleted) {\n return this.onMessage_(nextOrObserver, optError, optCompleted);\n };\n /**\n * @export\n * @param {!firebase.Observer|function()} nextOrObserver An observer object\n * or a function triggered on token refresh.\n * @param {function(!Error)=} optError Optional A function\n * triggered on token refresh error.\n * @param {function()=} optCompleted Optional function triggered when the\n * observer is removed.\n * @return {!function()} The unsubscribe function for the observer.\n */\n WindowController.prototype.onTokenRefresh = function (nextOrObserver, optError, optCompleted) {\n return this.onTokenRefresh_(nextOrObserver, optError, optCompleted);\n };\n /**\n * Given a registration, wait for the service worker it relates to\n * become activer\n * @private\n * @param {ServiceWorkerRegistration} registration Registration to wait\n * for service worker to become active\n * @return {Promise} Wait for service worker\n * registration to become active\n */\n WindowController.prototype.waitForRegistrationToActivate_ = function (registration) {\n var _this = this;\n var serviceWorker = registration.installing || registration.waiting || registration.active;\n return new Promise(function (resolve, reject) {\n if (!serviceWorker) {\n // This is a rare scenario but has occured in firefox\n reject(_this.errorFactory_.create(Errors.codes.NO_SW_IN_REG));\n return;\n }\n // Because the Promise function is called on next tick there is a\n // small chance that the worker became active or redundant already.\n if (serviceWorker.state === 'activated') {\n resolve(registration);\n return;\n }\n if (serviceWorker.state === 'redundant') {\n reject(_this.errorFactory_.create(Errors.codes.SW_REG_REDUNDANT));\n return;\n }\n var stateChangeListener = function () {\n if (serviceWorker.state === 'activated') {\n resolve(registration);\n }\n else if (serviceWorker.state === 'redundant') {\n reject(_this.errorFactory_.create(Errors.codes.SW_REG_REDUNDANT));\n }\n else {\n // Return early and wait to next state change\n return;\n }\n serviceWorker.removeEventListener('statechange', stateChangeListener);\n };\n serviceWorker.addEventListener('statechange', stateChangeListener);\n });\n };\n /**\n * This will regiater the default service worker and return the registration\n * @private\n * @return {Promise} The service worker\n * registration to be used for the push service.\n */\n WindowController.prototype.getSWRegistration_ = function () {\n var _this = this;\n if (this.registrationToUse_) {\n return this.waitForRegistrationToActivate_(this.registrationToUse_);\n }\n // Make the registration null so we know useServiceWorker will not\n // use a new service worker as registrationToUse_ is no longer undefined\n this.registrationToUse_ = null;\n return navigator.serviceWorker\n .register(DefaultSW.path, {\n scope: DefaultSW.scope\n })\n .catch(function (err) {\n throw _this.errorFactory_.create(Errors.codes.FAILED_DEFAULT_REGISTRATION, {\n browserErrorMessage: err.message\n });\n })\n .then(function (registration) {\n return _this.waitForRegistrationToActivate_(registration).then(function () {\n _this.registrationToUse_ = registration;\n // We update after activation due to an issue with Firefox v49 where\n // a race condition occassionally causes the service work to not\n // install\n registration.update();\n return registration;\n });\n });\n };\n /**\n * This will return the default VAPID key or the uint8array version of the public VAPID key\n * provided by the developer.\n * @private\n */\n WindowController.prototype.getPublicVapidKey_ = function () {\n if (this.publicVapidKeyToUse_) {\n return Promise.resolve(this.publicVapidKeyToUse_);\n }\n return Promise.resolve(FCMDetails.DEFAULT_PUBLIC_VAPID_KEY);\n };\n /**\n * Gets a PushSubscription for the current user.\n * @private\n * @param {ServiceWorkerRegistration} registration\n * @return {Promise}\n */\n WindowController.prototype.getPushSubscription_ = function (swRegistration, publicVapidKey) {\n // Check for existing subscription first\n var subscription;\n var fcmTokenDetails;\n return swRegistration.pushManager.getSubscription().then(function (subscription) {\n if (subscription) {\n return subscription;\n }\n return swRegistration.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: publicVapidKey\n });\n });\n };\n /**\n * This method will set up a message listener to handle\n * events from the service worker that should trigger\n * events in the page.\n *\n * @private\n */\n WindowController.prototype.setupSWMessageListener_ = function () {\n var _this = this;\n if (!('serviceWorker' in navigator)) {\n return;\n }\n navigator.serviceWorker.addEventListener('message', function (event) {\n if (!event.data || !event.data[WorkerPageMessage.PARAMS.TYPE_OF_MSG]) {\n // Not a message from FCM\n return;\n }\n var workerPageMessage = event.data;\n switch (workerPageMessage[WorkerPageMessage.PARAMS.TYPE_OF_MSG]) {\n case WorkerPageMessage.TYPES_OF_MSG.PUSH_MSG_RECEIVED:\n case WorkerPageMessage.TYPES_OF_MSG.NOTIFICATION_CLICKED:\n var pushMessage = workerPageMessage[WorkerPageMessage.PARAMS.DATA];\n if (_this.messageObserver_) {\n _this.messageObserver_.next(pushMessage);\n }\n break;\n default:\n // Noop.\n break;\n }\n }, false);\n };\n /**\n * Checks to see if the required API's are valid or not.\n * @private\n * @return {boolean} Returns true if the desired APIs are available.\n */\n WindowController.prototype.isSupported_ = function () {\n return ('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 return WindowController;\n}(ControllerInterface));\nexport default WindowController;\n\n//# sourceMappingURL=window-controller.js.map\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ../messaging/dist/esm/src/controllers/window-controller.js\n// module id = null\n// module chunks = ","/**\n * Copyright 2017 Google Inc.\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'use strict';\nimport * as tslib_1 from \"tslib\";\nimport ControllerInterface from './controller-interface';\nimport Errors from '../models/errors';\nimport FCMDetails from '../models/fcm-details';\nimport WorkerPageMessage from '../models/worker-page-message';\nvar FCM_MSG = 'FCM_MSG';\nvar SWController = /** @class */ (function (_super) {\n tslib_1.__extends(SWController, _super);\n function SWController(app) {\n var _this = _super.call(this, app) || this;\n self.addEventListener('push', function (e) { return _this.onPush_(e); }, false);\n self.addEventListener('pushsubscriptionchange', function (e) { return _this.onSubChange_(e); }, false);\n self.addEventListener('notificationclick', function (e) { return _this.onNotificationClick_(e); }, false);\n /**\n * @private\n * @type {function(Object)|null}\n */\n _this.bgMessageHandler_ = null;\n return _this;\n }\n /**\n * A handler for push events that shows notifications based on the content of\n * the payload.\n *\n * The payload must be a JSON-encoded Object with a `notification` key. The\n * value of the `notification` property will be used as the NotificationOptions\n * object passed to showNotification. Additionally, the `title` property of the\n * notification object will be used as the title.\n *\n * If there is no notification data in the payload then no notification will be\n * shown.\n * @private\n */\n SWController.prototype.onPush_ = function (event) {\n var _this = this;\n var msgPayload;\n try {\n msgPayload = event.data.json();\n }\n catch (err) {\n // Not JSON so not an FCM message\n return;\n }\n var handleMsgPromise = this.hasVisibleClients_().then(function (hasVisibleClients) {\n if (hasVisibleClients) {\n // Do not need to show a notification.\n if (msgPayload.notification || _this.bgMessageHandler_) {\n // Send to page\n return _this.sendMessageToWindowClients_(msgPayload);\n }\n return;\n }\n var notificationDetails = _this.getNotificationData_(msgPayload);\n if (notificationDetails) {\n var notificationTitle_1 = notificationDetails.title || '';\n return _this.getSWRegistration_().then(function (reg) {\n return reg.showNotification(notificationTitle_1, notificationDetails);\n });\n }\n else if (_this.bgMessageHandler_) {\n return _this.bgMessageHandler_(msgPayload);\n }\n });\n event.waitUntil(handleMsgPromise);\n };\n /**\n * @private\n */\n SWController.prototype.onSubChange_ = function (event) {\n var _this = this;\n var promiseChain = this.getSWRegistration_()\n .then(function (registration) {\n return registration.pushManager\n .getSubscription()\n .then(function (subscription) {\n // TODO: Check if it's still valid\n // TODO: If not, then update token\n })\n .catch(function (err) {\n // The best thing we can do is log this to the terminal so\n // developers might notice the error.\n var tokenDetailsModel = _this.getTokenDetailsModel();\n return tokenDetailsModel\n .getTokenDetailsFromSWScope(registration.scope)\n .then(function (tokenDetails) {\n if (!tokenDetails) {\n // This should rarely occure, but could if indexedDB\n // is corrupted or wiped\n throw err;\n }\n // Attempt to delete the token if we know it's bad\n return _this.deleteToken(tokenDetails['fcmToken']).then(function () {\n throw err;\n });\n });\n });\n })\n .catch(function (err) {\n throw _this.errorFactory_.create(Errors.codes.UNABLE_TO_RESUBSCRIBE, {\n message: err\n });\n });\n event.waitUntil(promiseChain);\n };\n /**\n * @private\n */\n SWController.prototype.onNotificationClick_ = function (event) {\n var _this = this;\n if (!(event.notification &&\n event.notification.data &&\n event.notification.data[FCM_MSG])) {\n // Not an FCM notification, do nothing.\n return;\n }\n // Prevent other listeners from receiving the event\n event.stopImmediatePropagation();\n event.notification.close();\n var msgPayload = event.notification.data[FCM_MSG];\n if (!msgPayload['notification']) {\n // Nothing to do.\n return;\n }\n var clickAction = msgPayload['notification']['click_action'];\n if (!clickAction) {\n // Nothing to do.\n return;\n }\n var promiseChain = this.getWindowClient_(clickAction)\n .then(function (windowClient) {\n if (!windowClient) {\n // Unable to find window client so need to open one.\n return self.clients.openWindow(clickAction);\n }\n return windowClient.focus();\n })\n .then(function (windowClient) {\n if (!windowClient) {\n // Window Client will not be returned if it's for a third party origin.\n return;\n }\n // Delete notification data from payload before sending to the page.\n var notificationData = msgPayload['notification'];\n delete msgPayload['notification'];\n var internalMsg = WorkerPageMessage.createNewMsg(WorkerPageMessage.TYPES_OF_MSG.NOTIFICATION_CLICKED, msgPayload);\n // Attempt to send a message to the client to handle the data\n // Is affected by: https://github.com/slightlyoff/ServiceWorker/issues/728\n return _this.attemptToMessageClient_(windowClient, internalMsg);\n });\n event.waitUntil(promiseChain);\n };\n /**\n * @private\n * @param {Object} msgPayload\n * @return {NotificationOptions|undefined}\n */\n SWController.prototype.getNotificationData_ = function (msgPayload) {\n if (!msgPayload) {\n return;\n }\n if (typeof msgPayload.notification !== 'object') {\n return;\n }\n var notificationInformation = Object.assign({}, msgPayload.notification);\n // Put the message payload under FCM_MSG name so we can identify the\n // notification as being an FCM notification vs a notification from\n // somewhere else (i.e. normal web push or developer generated\n // notification).\n notificationInformation['data'] = (_a = {},\n _a[FCM_MSG] = msgPayload,\n _a);\n return notificationInformation;\n var _a;\n };\n /**\n * Calling setBackgroundMessageHandler will opt in to some specific\n * behaviours.\n * 1.) If a notification doesn't need to be shown due to a window already\n * being visible, then push messages will be sent to the page.\n * 2.) If a notification needs to be shown, and the message contains no\n * notification data this method will be called\n * and the promise it returns will be passed to event.waitUntil.\n * If you do not set this callback then all push messages will let and the\n * developer can handle them in a their own 'push' event callback\n * @export\n * @param {function(Object)} callback The callback to be called when a push\n * message is received and a notification must be shown. The callback will\n * be given the data from the push message.\n */\n SWController.prototype.setBackgroundMessageHandler = function (callback) {\n if (!callback || typeof callback !== 'function') {\n throw this.errorFactory_.create(Errors.codes.BG_HANDLER_FUNCTION_EXPECTED);\n }\n this.bgMessageHandler_ = callback;\n };\n /**\n * @private\n * @param {string} url The URL to look for when focusing a client.\n * @return {Object} Returns an existing window client or a newly opened\n * WindowClient.\n */\n SWController.prototype.getWindowClient_ = function (url) {\n // Use URL to normalize the URL when comparing to windowClients.\n // This at least handles whether to include trailing slashes or not\n var parsedURL = new URL(url, self.location).href;\n return self.clients\n .matchAll({\n type: 'window',\n includeUncontrolled: true\n })\n .then(function (clientList) {\n var suitableClient = null;\n for (var i = 0; i < clientList.length; i++) {\n var parsedClientUrl = new URL(clientList[i].url, self.location).href;\n if (parsedClientUrl === parsedURL) {\n suitableClient = clientList[i];\n break;\n }\n }\n if (suitableClient) {\n return suitableClient;\n }\n return null;\n });\n };\n /**\n * This message will attempt to send the message to a window client.\n * @private\n * @param {Object} client The WindowClient to send the message to.\n * @param {Object} message The message to send to the client.\n * @returns {Promise} Returns a promise that resolves after sending the\n * message. This does not guarantee that the message was successfully\n * received.\n */\n SWController.prototype.attemptToMessageClient_ = function (client, message) {\n return tslib_1.__awaiter(this, void 0, void 0, function () {\n return tslib_1.__generator(this, function (_a) {\n // NOTE: This returns a promise in case this API is abstracted later on to\n // do additional work\n if (!client) {\n return [2 /*return*/, Promise.reject(this.errorFactory_.create(Errors.codes.NO_WINDOW_CLIENT_TO_MSG))];\n }\n client.postMessage(message);\n return [2 /*return*/];\n });\n });\n };\n /**\n * @private\n * @returns {Promise} If there is currently a visible WindowClient,\n * this method will resolve to true, otherwise false.\n */\n SWController.prototype.hasVisibleClients_ = function () {\n return self.clients\n .matchAll({\n type: 'window',\n includeUncontrolled: true\n })\n .then(function (clientList) {\n return clientList.some(function (client) { return client.visibilityState === 'visible'; });\n });\n };\n /**\n * @private\n * @param {Object} msgPayload The data from the push event that should be sent\n * to all available pages.\n * @returns {Promise} Returns a promise that resolves once the message\n * has been sent to all WindowClients.\n */\n SWController.prototype.sendMessageToWindowClients_ = function (msgPayload) {\n var _this = this;\n return self.clients\n .matchAll({\n type: 'window',\n includeUncontrolled: true\n })\n .then(function (clientList) {\n var internalMsg = WorkerPageMessage.createNewMsg(WorkerPageMessage.TYPES_OF_MSG.PUSH_MSG_RECEIVED, msgPayload);\n return Promise.all(clientList.map(function (client) {\n return _this.attemptToMessageClient_(client, internalMsg);\n }));\n });\n };\n /**\n * This will register the default service worker and return the registration.\n * @private\n * @return {Promise} The service worker\n * registration to be used for the push service.\n */\n SWController.prototype.getSWRegistration_ = function () {\n return Promise.resolve(self.registration);\n };\n /**\n * This will return the default VAPID key or the uint8array version of the\n * public VAPID key provided by the developer.\n */\n SWController.prototype.getPublicVapidKey_ = function () {\n var _this = this;\n return this.getSWRegistration_()\n .then(function (swReg) {\n return _this.getVapidDetailsModel().getVapidFromSWScope(swReg.scope);\n })\n .then(function (vapidKeyFromDatabase) {\n if (vapidKeyFromDatabase === null) {\n return FCMDetails.DEFAULT_PUBLIC_VAPID_KEY;\n }\n return vapidKeyFromDatabase;\n });\n };\n return SWController;\n}(ControllerInterface));\nexport default SWController;\n\n//# sourceMappingURL=sw-controller.js.map\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ../messaging/dist/esm/src/controllers/sw-controller.js\n// module id = null\n// module chunks = "],"sourceRoot":""}