package.cjs.react-utils.BrowserPushNotifications.pushHelper.js.map Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of neeto-commons-frontend Show documentation
Show all versions of neeto-commons-frontend Show documentation
A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.
{"version":3,"file":"pushHelper.js","names":["_devices","_interopRequireDefault","require","_registerServiceWorker","createBrowserSubscription","_ref","_asyncToGenerator2","_regenerator","mark","_callee","subscription","payload","wrap","_callee$","_context","prev","next","device","platform","devicesApi","create","localStorage","setItem","JSON","stringify","toJSON","keys","auth","t0","logger","error","stop","_x","apply","arguments","destroyBrowserSubscription","exports","_ref2","_callee2","deviceId","_callee2$","_context2","unsubscribeBrowserNotifications","parse","getItem","destroy","removeItem","registerBrowserNotifications","_ref3","_callee3","vapidPublicKey","response","_args3","_callee3$","_context3","length","undefined","process","env","VAPID_PUBLIC_KEY","registerServiceWorker","sent"],"sources":["../../../../src/react-utils/BrowserPushNotifications/pushHelper.js"],"sourcesContent":["// THIS FILE HAS BEEN ADDED BY NEETO NOTIFICATIONS ENGINE\n// AND IS USED FOR BROWSER NOTIFICATIONS\n// CONTACT NEETO NOTIFICATIONS TEAM BEFORE MODIFYING THIS FILE\n\nimport devicesApi from \"./devices\";\nimport {\n unsubscribeBrowserNotifications,\n registerServiceWorker,\n} from \"./registerServiceWorker\";\n\nconst createBrowserSubscription = async subscription => {\n if (subscription) {\n const payload = { device: { subscription, platform: \"browser\" } };\n try {\n await devicesApi.create(payload);\n localStorage.setItem(\n \"deviceId\",\n JSON.stringify(subscription.toJSON().keys.auth)\n );\n } catch (err) {\n logger.error(\"Device registration Failed: \", err);\n }\n } else {\n logger.error(\n \"Something went wrong while registering device for browser subscription\"\n );\n }\n};\n\nexport const destroyBrowserSubscription = async () => {\n try {\n await unsubscribeBrowserNotifications();\n const deviceId = JSON.parse(localStorage.getItem(\"deviceId\"));\n await devicesApi.destroy(deviceId);\n localStorage.removeItem(\"deviceId\");\n } catch (err) {\n logger.error(\n \"Something went wrong while unsubscribing browser notification:\",\n err\n );\n }\n};\n\nexport const registerBrowserNotifications = async (\n vapidPublicKey = process.env.VAPID_PUBLIC_KEY\n) => {\n const response = await registerServiceWorker(vapidPublicKey);\n await createBrowserSubscription(response);\n};\n"],"mappings":";;;;;;;;;AAIA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AALA;AACA;AACA;;AAQA,IAAME,yBAAyB;EAAA,IAAAC,IAAA,OAAAC,kBAAA,0BAAAC,YAAA,YAAAC,IAAA,CAAG,SAAAC,QAAMC,YAAY;IAAA,IAAAC,OAAA;IAAA,OAAAJ,YAAA,YAAAK,IAAA,UAAAC,SAAAC,QAAA;MAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;QAAA;UAAA,KAC9CN,YAAY;YAAAI,QAAA,CAAAE,IAAA;YAAA;UAAA;UACRL,OAAO,GAAG;YAAEM,MAAM,EAAE;cAAEP,YAAY,EAAZA,YAAY;cAAEQ,QAAQ,EAAE;YAAU;UAAE,CAAC;UAAAJ,QAAA,CAAAC,IAAA;UAAAD,QAAA,CAAAE,IAAA;UAAA,OAEzDG,mBAAU,CAACC,MAAM,CAACT,OAAO,CAAC;QAAA;UAChCU,YAAY,CAACC,OAAO,CAClB,UAAU,EACVC,IAAI,CAACC,SAAS,CAACd,YAAY,CAACe,MAAM,CAAC,CAAC,CAACC,IAAI,CAACC,IAAI,CAChD,CAAC;UAACb,QAAA,CAAAE,IAAA;UAAA;QAAA;UAAAF,QAAA,CAAAC,IAAA;UAAAD,QAAA,CAAAc,EAAA,GAAAd,QAAA;UAEFe,MAAM,CAACC,KAAK,CAAC,8BAA8B,EAAAhB,QAAA,CAAAc,EAAK,CAAC;QAAC;UAAAd,QAAA,CAAAE,IAAA;UAAA;QAAA;UAGpDa,MAAM,CAACC,KAAK,CACV,wEACF,CAAC;QAAC;QAAA;UAAA,OAAAhB,QAA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