PageSourceSearch

https://www.is.fi/service-worker.js

js is.fi collected 2026-09-24 08:35:53 UTC 14,685 bytes, 1 lines download raw bytes

1const h={A:function(e){(void 0!==e||void 0===h.m)&&(h.m=!!e),h.D||(h.D=!0)},M:function(){h.D=!1,h.m=void 0,h.j=void 0},O:function(e){"function"!=typeof e?h.info("Ignoring setLogger call since logger is not a function"):(h.A(),h.j=e)},P:function(){h.A(),h.m?(console.log("Disabling Braze logging"),h.m=!1):(console.log("Enabled Braze logging"),h.m=!0)},info:function(e){h.m&&(e="Braze: "+e,null!=h.j?h.j(e):console.log(e))},warn:function(e){h.m&&(e="Braze SDK Warning: "+e+" (v6.13.0)",null!=h.j?h.j(e):console.warn(e))},error:function(e){h.m&&(e="Braze SDK Error: "+e+" (v6.13.0)",null!=h.j?h.j(e):console.error(e))}};function l(){if("u">typeof window&&window.crypto){if("function"==typeof window.crypto.randomUUID)return window.crypto.randomUUID();if("function"==typeof window.crypto.getRandomValues)try{var e=new Uint8Array(16);window.crypto.getRandomValues(e),e[6]=15&e[6]|64,e[8]=63&e[8]|128;let n=Array.from(e,e=>("0"+e.toString(16)).slice(-2));return[n.slice(0,4).join(""),n.slice(4,6).join(""),n.slice(6,8).join(""),n.slice(8,10).join(""),n.slice(10,16).join("")].join("-")}catch(e){}}return(e=(e=!1)=>{let n=(Math.random().toString(16)+"000000000").substr(2,8);return e?"-"+n.substr(0,4)+"-"+n.substr(4,4):n})()+e(!0)+e(!0)+e()}function q(e){if("indexedDB"in e.parent)return e.parent.indexedDB}function r(e){var n;try{if(null==q(e))return!1;let t=null==(n=q(e))?void 0:n.open("Braze IndexedDB Support Test");if(t&&(t.onupgradeneeded=()=>t.result.close(),t.onsuccess=()=>t.result.close()),"u">typeof window){let t=(n=window).L||n.K||n.N;if(t&&t.J&&t.J.id)return e.j.info("Not using IndexedDB for storage because we are running inside an extension"),!1}return!0}catch(n){return e.j.info("Not using IndexedDB for storage due to following error: "+n),!1}}function v(e,n,t){var o;let i=null==(o=q(e))?void 0:o.open(e.h.l,e.h.VERSION);return null==i?("function"==typeof t&&t(),!1):(i.onupgradeneeded=n=>{var t;for(let o in e.j.info("Upgrading indexedDB "+e.h.l+" to v"+e.h.VERSION+"..."),n=null==(t=n.target)?void 0:t.result,e.h.g)t=o,e.h.g.hasOwnProperty(o)&&!n.objectStoreNames.contains(e.h.g[t])&&n.createObjectStore(e.h.g[t])},i.onsuccess=o=>{var i;let a=null==(i=o.target)?void 0:i.result;a.onversionchange=()=>{a.close(),"function"==typeof t&&t(),e.j.error("Needed to close the database unexpectedly because of an upgrade in another tab")},n(a)},i.onerror=n=>{var o;return e.j.info("Could not open indexedDB "+e.h.l+" v"+e.h.VERSION+": "+(null==(o=n.target)?void 0:o.errorCode)),"function"==typeof t&&t(),!0},!0)}function w(e,n,t,o){r(e)?v(e,i=>{if(i.objectStoreNames.contains(n)){var a=i.transaction([n],"readonly");a.oncomplete=()=>i.close(),(a=a.objectStore(n).openCursor(null,"prev")).onerror=()=>{e.j.error("Could not open cursor for "+n+" on indexedDB "+e.h.l),"function"==typeof o&&o()},a.onsuccess=e=>{var n;null!=(e=null==(n=e.target)?void 0:n.result)&&null!=e.value&&null!=e.key?t(e.key,e.value):"function"==typeof o&&o()}}else e.j.error("Could not retrieve last record from "+n+" on indexedDB "+e.h.l+" - "+n+" is not a valid objectStore"),"function"==typeof o&&o(),i.close()},o):"function"==typeof o&&o()}class x{constructor(){this.h=y,this.j=h,this.parent="u"<typeof window?self:window,this.h=y,this.j=h}setItem(e,n,t,o,i){if(!r(this))return"function"==typeof i&&i(),!1;let a=this;return v(this,s=>{if(s.objectStoreNames.contains(e)){var u=s.transaction([e],"readwrite");u.oncomplete=()=>s.close(),(u=u.objectStore(e).put(t,n)).onerror=()=>{a.j.error("Could not store object "+n+" in "+e+" on indexedDB "+a.h.l),"function"==typeof i&&i()},u.onsuccess=()=>{"function"==typeof o&&o()}}else a.j.error("Could not store object "+n+" in "+e+" on indexedDB "+a.h.l+" - "+e+" is not a valid objectStore"),"function"==typeof i&&i(),s.close()},i)}getItem(e,n,t){if(!r(this))return!1;let o=this;return v(this,i=>{if(i.objectStoreNames.contains(e)){var a=i.transaction([e],"readonly");a.oncomplete=()=>i.close(),(a=a.objectStore(e).get(n)).onerror=()=>{o.j.error("Could not retrieve object "+n+" in "+e+" on indexedDB "+o.h.l)},a.onsuccess=e=>{var n;null!=(e=null==(n=e.target)?void 0:n.result)&&t(e)}}else o.j.error("Could not retrieve object "+n+" in "+e+" on indexedDB "+o.h.l+" - "+e+" is not a valid objectStore"),i.close()})}clearData(){if(!r(this))return!1;let e=[];for(let n in this.h.g)this.h.g.hasOwnProperty(n)&&this.h.g[n]!==this.h.g.B&&e.push(this.h.g[n]);let n=this;return v(this,function(t){let o=t.transaction(e,"readwrite");o.oncomplete=()=>t.close();for(let t=0;t<e.length;t++)o.objectStore(e[t]).clear().onerror=function(){n.j.error("Could not clear "+this.source.name+" on indexedDB "+n.h.l)};o.onerror=function(){n.j.error("Could not clear object stores on indexedDB "+n.h.l)}})}}var y={l:"AppboyServiceWorkerAsyncStorage",VERSION:6,g:{o:"data",H:"pushClicks",C:"pushSubscribed",v:"fallbackDevice",F:"cardUpdates",B:"optOut",G:"pendingData",I:"sdkAuthenticationSignature"},s:1};function z(){return new Promise(function(e,n){w(new x,y.g.B,n,e)})}function A(){return new Promise(e=>{w(new x,y.g.I,(n,t)=>{e(t)},()=>{e(null)})})}function C(e,n,t){h.info(`${n} due to SDK Authentication failure with error code ${t.error_code}. The data will be logged on the user's next session start.`),new x().setItem(y.g.G,l(),e)}function D(e,n,t){return new Promise(function(o,i){let a={};a.time=Math.floor(new Date().valueOf()/1e3),a.device_id=t,a.api_key=e,a.sdk_version="6.13.0",a.sdk_flavor="amp",a.respond_with={config:{config_time:0}},fetch(n+"/data/",{method:"POST",headers:{"Content-type":"application/json","X-Braze-Api-Key":e,"X-Braze-Last-Req-Ms-Ago":72e5,"X-Braze-Req-Attempt":1},body:JSON.stringify(a)}).then(function(e){return e.ok||h.error("Unable to get config: "+e.status),e.json()}).then(function(e){if(e.error&&(h.error("Unable to get config: "+e.error),i()),e.auth_error&&(h.error("Unable to get config due to authentication error. SDK Authentication does not support AMP pages."),i()),!e.error&&!e.auth_error){e=e.config.vapid_public_key;var n="=".repeat((4-e.length%4)%4);n=new Uint8Array((e=atob(e=(e+n).replace(/\-/g,"+").replace(/_/g,"/"))).length);for(let t=0;t<e.length;++t)n[t]=e.charCodeAt(t);o({userVisibleOnly:!0,applicationServerKey:n})}}).catch(function(e){h.error("Unable to get config: "+e),i()})})}function E(e,n,t,o,i,a,s,u,c){return A().then(f=>new Promise(function(d,p){let g={};g.device_id=t,g.api_key=e,g.sdk_version="6.13.0",null!=a&&(g.sdk_flavor=a);var b=null;let m=null,j=null;i&&(j=i.endpoint,i.getKey&&(b=btoa(String.fromCharCode.apply(null,new Uint8Array(i.getKey("p256dh")))),m=btoa(String.fromCharCode.apply(null,new Uint8Array(i.getKey("auth")))))),g.time=Math.floor(new Date().valueOf()/1e3),g.attributes=[{user_id:o,push_token:j,custom_push_public_key:b,custom_push_user_auth:m}],b={"Content-type":"application/json","X-Braze-Api-Key":g.api_key,"X-Braze-Last-Req-Ms-Ago":72e5,"X-Braze-Req-Attempt":1},f&&c&&(b["X-Braze-Auth-Signature"]=f),fetch(n+"/data/",{method:"POST",headers:b,body:JSON.stringify(g)}).then(function(e){return e.ok||h.error(u+" "+e.status),e.json()}).then(function(e){e.error&&(h.error(u+" "+e.error),p()),e.auth_error&&(C(g,u,e.auth_error),p()),e.error||e.auth_error||(h.info(s),d())}).catch(function(e){h.error(u+" "+e),p()})}))}function F(e,n){return z().then(function(){return A()}).then(function(t){w(new x,y.g.o,function(o,i){o=Math.floor(new Date().valueOf()/1e3);let a=i.data;a.time=o,e.time=o,e.user_id=i.userId,a.events=[e],a.sdk_version="6.13.0",o={"Content-Type":"application/json","X-Braze-Api-Key":a.api_key,"X-Braze-Last-Req-Ms-Ago":72e5,"X-Braze-Req-Attempt":1},t&&i.sdkAuthEnabled&&(o["X-Braze-Auth-Signature"]=t),fetch(i.baseUrl+"/data/",{method:"POST",headers:o,body:JSON.stringify(a)}).then(function(e){return e.ok||h.error("Unable to log "+n+": "+e.status),e.json()}).then(function(e){return e.error&&h.error("Unable to log "+n+":",e.error),e.auth_error&&C(a,"Unable to log "+n,e.auth_error),e.error||e.auth_error||h.info("Successfully logged "+n),Promise.resolve()}).catch(function(e){return h.error("Unable to log "+n+":",e),Promise.resolve()})})}).catch(function(){return Promise.reject("Not sending data to Braze backend due to opt-out.")})}function G(){let e=self.location.search.match(/apiKey=([^&]+)/i);return e?e[1]:(h.error("Missing API key in query params."),null)}function J(){let e=self.location.search.match(/baseUrl=([^&]+)/i);return e?e[1]:(h.error("Missing base URL in query params."),null)}function K(e,n){self.clients.matchAll().then(function(t){for(let o=0;o<t.length;o++)t[o].postMessage({command:e,payload:n})})}function L(e,n,t,o,i){return D(e,n,t).then(function(e){return self.registration.pushManager.subscribe(e)}).then(function(a){return K("amp-web-push-subscribe",null),E(e,n,t,o,a,"amp","Successfully sent AMP push subscription to Braze backend.","Unable to send AMP push subscription to Braze backend.",i)}).catch(function(){return h.error("Failed to subscribe for AMP push."),Promise.reject()})}function M(){self.registration.pushManager.getSubscription().then(function(e){return e?self.registration.pushManager.permissionState(e.options):null}).then(function(e){K("amp-web-push-subscription-state","granted"===e)})}function N(){let e=new x;return new Promise(function(n,t){w(e,y.g.o,function(e,o){L(o.data.api_key,o.baseUrl,o.data.device_id,o.userId,o.sdkAuthEnabled).then(function(){n()}).catch(function(){t()})},function(){let o=G(),i=J();w(e,y.g.v,function(e,a){L(o,i,a,null).then(function(){n()}).catch(function(){t()})},function(){let a=l();new Promise(function(n,t){e.setItem(y.g.v,y.s,a,n,t)}).then(function(){return L(o,i,a,null)}).then(function(){n()}).catch(function(){t()})})})}).then(function(){return new Promise(function(n,t){e.setItem(y.g.C,y.s,!0,n,t)})})}function O(){return self.registration.pushManager.getSubscription().then(function(e){return e.unsubscribe()}).then(function(){K("amp-web-push-unsubscribe",null);let e=new x;return new Promise(function(n,t){w(e,y.g.o,function(e,o){E(o.data.api_key,o.baseUrl,o.data.device_id,o.userId,null,"amp","Successfully sent AMP push unsubscription to Braze backend.","Unable to send AMP push unsubscription to Braze backend.",o.sdkAuthEnabled).then(function(){n()}).catch(function(){t()})}
1,function(){w(e,y.g.v,function(e,o){E(e=G(),J(),o,null,null,"amp","Successfully sent AMP push unsubscription to Braze backend.","Unable to send AMP push unsubscription to Braze backend.",null).then(function(){n()}).catch(function(){t()})},function(){h.error("No device found during unsubscription."),t()})})}).then(function(){return new Promise(function(n,t){e.setItem(y.g.C,y.s,!1,n,t)})})}).catch(function(){return h.error("Failed to unsubscribe for AMP push."),Promise.reject()})}function Q(e,n){e.waitUntil(n.catch(function(e){e&&h.info(e)}))}function R(e){return null!=e&&(!0===(e=e._ab)||"true"===e)}function S(e){if(null==e||0===Object.keys(e).length)return Promise.reject("Server has no pending push message for this registration. Ignoring push event.");let n=e.t,t=e.a,o=e.i,i=e.img,a={url:e.u,ab_ids:{cid:e.cid},extra:e.e},s=e.ri;e.ab_push_fetch_test_triggers_key&&(h.info("Service worker 6.13.0 found trigger fetch key in push payload."),a.fetchTriggers=!0);var u=e.ab_cd;null!=u&&new x().setItem(y.g.F,new Date().valueOf(),{userId:e.ab_cd_uid,card:u}),e=e.pab||[],u={};for(let n=0;n<e.length;n++)if(null!=e[n]&&null!=e[n].action){let t;switch(e[n].a){case"ab_none":t=null;break;case"ab_uri":(null==(t=e[n].u)||""===t)&&(t="/")}u[e[n].action]=t}return a.actionTargets=u,h.info("Displaying push notification!"),self.registration.showNotification(n,{body:t,icon:o,image:i,data:a,actions:e,requireInteraction:s}).catch(function(e){h.info(e)})}h.A(!0),self.addEventListener("install",function(e){e.waitUntil(self.skipWaiting())}),self.addEventListener("activate",function(){return self.clients.claim()}),self.addEventListener("push",function(e){if(h.info("Service worker 6.13.0 received push"),null!=e.data&&null!=e.data.json){let n=e.data.json();R(n)?Q(e,S(n)):h.info("Service worker 6.13.0 ignoring non-Braze push")}else Q(e,new Promise(function(e,n){w(new x,y.g.o,function(t,o){let i=o.data;z().then(function(){return fetch(o.baseUrl+"/web_push/",{method:"POST",headers:{"Content-type":"application/json","X-Braze-Api-Key":i.api_key},body:JSON.stringify(i)})}).then(function(e){return e.ok?e.json():(h.error("Unable to retrieve push payload from server: "+e.status),Promise.reject())}).then(function(n){h.info("Retrieved push payload from server"),R(n)?e(S(n)):(h.info("Service worker 6.13.0 ignoring non-Braze push"),e())}).catch(function(e){n("Unable to retrieve push payload from server or user has opt-out: "+e)})})}))}),self.addEventListener("notificationclick",function(e){if(e&&e.notification&&(e.notification.close(),null!=Notification&&Notification.prototype.hasOwnProperty("data")&&e.notification.data&&e.notification.data.ab_ids)){var n,t=null!=e.action&&""!==e.action,o=t?F({name:"ca",data:{cid:e.notification.data.ab_ids.cid,a:e.action}},"push button click"):F({name:"pc",data:{cid:e.notification.data.ab_ids.cid}},"push click");if(!t){let n={lastClick:new Date().valueOf(),trackingString:e.notification.data.ab_ids.cid};e.notification.data.fetchTriggers&&(n.fetchTriggers=!0);let t=new x;var i=o.then(function(){return new Promise(function(e,o){t.setItem(y.g.H,y.s,n,e,o)})}).catch(function(){return h.info("Not storing push click due to no click event being created."),Promise.resolve()})}if(t)var a=e.notification.data.actionTargets[e.action];else(null==(a=e.notification.data.url)||""===a)&&(a="/");null!=a&&""!==a&&(n=clients.matchAll({type:"window"}).then(function(){if(clients.openWindow)return clients.openWindow(a)})),Q(e,Promise.all([n,i]))}}),self.addEventListener("pushsubscriptionchange",function(e){Q(e,z().then(function(){let n={userVisibleOnly:!0};return null!=e.oldSubscription&&(n=e.oldSubscription.options),self.registration.pushManager.subscribe(n)}).then(function(e){return new Promise(function(n,t){w(new x,y.g.o,function(o,i){E(i.data.api_key,i.baseUrl,i.data.device_id,i.userId,e,null,"Successfully resubscribed user after expiration","Unable to resubscribe user",i.sdkAuthEnabled).then(function(){n()}).catch(function(){t()})})})}).catch(function(){return Promise.reject("Not resubscribing user for push due to opt-out.")}))}),self.addEventListener("message",function(e){e.waitUntil&&e.data.command&&e.waitUntil(z().then(function(){switch(e.data.command){case"amp-web-push-subscription-state":return M(),Promise.resolve();case"amp-web-push-subscribe":return N();case"amp-web-push-unsubscribe":return O();default:return Promise.resolve()}}).catch(function(){return h.info("Ignoring message from amp-web-push due to opt-out."),Promise.resolve()}))});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.