{"version":3,"sources":["webpack:///./app/javascript/public/serviceworker-companion.js"],"names":["navigator","serviceWorker","register","scope","then","reg","console","log","pushManager","subscribe","userVisibleOnly","applicationServerKey","window","vapidPublicKey","subscribeSuccess","subscription","params","endpoint","p256dh","btoa","String","fromCharCode","apply","Uint8Array","getKey","replace","auth","$","ajax","type","url","data","fail","e"],"mappings":"gFAAA,YAAIA,UAAUC,eACZD,UAAUC,cAAcC,SAAS,oBAAqB,CAAEC,MAAO,MAC5DC,MAAK,SAASC,GACbC,QAAQC,IAAI,cAAe,8BAG3BF,EAAIG,YAAYC,UAAU,CACxBC,iBAAiB,EACjBC,qBAAsBC,OAAOC,iBAC5BT,KAAKU,EACV,IAGJ,IAAIA,EAAmB,SAAUC,GAC/BC,OAAS,CACPC,SAAUF,EAAaE,SACvBC,OAAQC,KAAKC,OAAOC,aAAaC,MAAM,KAAM,IAAIC,WAAWR,EAAaS,OAAO,aAC7EC,QAAQ,MAAO,KAAKA,QAAQ,MAAO,KACtCC,KAAMP,KAAKC,OAAOC,aAAaC,MAAM,KAAM,IAAIC,WAAWR,EAAaS,OAAO,WAC3EC,QAAQ,MAAO,KAAKA,QAAQ,MAAO,MAGxCE,EAAEC,KAAK,CACLC,KAAM,OACNC,IAAK,kBACLC,KAAMf,SACLgB,MAAK,SAAUC,GAChB3B,QAAQC,IAAI0B,EACd,GACF,C","file":"js/120-95dd1e3523bab2d99b70.chunk.js","sourcesContent":["if (navigator.serviceWorker) {\n navigator.serviceWorker.register('/serviceworker.js', { scope: '/' })\n .then(function(reg) {\n console.log('[Companion]', 'Service worker registered!');\n\n // プッシュ通知の購読\n reg.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: window.vapidPublicKey,\n }).then(subscribeSuccess);\n });\n}\n\nvar subscribeSuccess = function (subscription) {\n params = {\n endpoint: subscription.endpoint,\n p256dh: btoa(String.fromCharCode.apply(null, new Uint8Array(subscription.getKey('p256dh'))))\n .replace(/\\+/g, '-').replace(/\\//g, '_'),\n auth: btoa(String.fromCharCode.apply(null, new Uint8Array(subscription.getKey('auth'))))\n .replace(/\\+/g, '-').replace(/\\//g, '_')\n };\n\n $.ajax({\n type: 'POST',\n url: '/api/v1/devices',\n data: params\n }).fail(function (e) {\n console.log(e)\n });\n}"],"sourceRoot":""}