PageSourceSearch

https://www.veed.io/frontend-assets/dashboard-frontend/dashboard-static/push-manager-factory-B8a-CAK9.js

js veed.io collected 2026-09-24 08:25:17 UTC 8,390 bytes, 2 lines download raw bytes

1(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`7a58fa93a7a0f4bfe4323bd10ecc06c7f61b8211`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`3f711314-0460-4c12-b072-5ff2c57bc0bc`,e._sentryDebugIdIdentifier=`sentry-dbid-3f711314-0460-4c12-b072-5ff2c57bc0bc`)}catch{}})();import{r as e}from"./rolldown-runtime-BhwcDRyc.js";import{D as t,P as n,R as r,Z as i,_t as a,i as o,lt as s,n as c,r as l,ut as u}from"./event-logger-CDkW4feC.js";var d={qn:function(e){let t=(e+`=`.repeat((4-e.length%4)%4)).replace(/\-/g,`+`).replace(/_/g,`/`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;++e)r[e]=n.charCodeAt(e);return r}},f=class e{constructor(e,n,r,i,a,o,s,c,l,u,d){this.un=e,this.an=n,this.hn=r,this.cn=a,this.fn=o,this.ln=s,this.B=c,this.dn=l,this.pn=u,this.C=d,this.un=e,this.an=n,this.hn=r,this.bn=i+`/safari/`+n,this.cn=a||`/service-worker.js`,this.ln=s,this.B=c,this.dn=l||!1,this.pn=u||!1,this.C=d,this.yn=t.mn(),this.gn=t.vn()}wn(){return this.pn}kn(e,t,n,r,i){e.unsubscribe().then(e=>{e?this.Pn(t,n,r,i):(a.error(`Failed to unsubscribe device from push.`),typeof i==`function`&&i(!1))}).catch(e=>{a.error(`Push unsubscription error: `+e),typeof i==`function`&&i(!1)})}Dn(e,t,n){var r;let o=(e=>{if(typeof e==`string`)return e;if(e.endpoint.indexOf(`https://android.googleapis.com/gcm/send`)!==0)return e.endpoint;let t=e.endpoint,n=e;return n.Sn&&e.endpoint.indexOf(n.Sn)===-1&&(t=e.endpoint+`/`+n.Sn),t})(e),s=null,c=null,l=e;if(l.getKey!=null)try{let e=Array.from(new Uint8Array(l.getKey(`p256dh`))),t=Array.from(new Uint8Array(l.getKey(`auth`)));s=btoa(String.fromCharCode.apply(null,e)),c=btoa(String.fromCharCode.apply(null,t))}catch(e){a.error(i(e))}let u=(e=>{let t;return e.options&&(t=e.options.applicationServerKey)&&t.byteLength&&t.byteLength>0?btoa(String.fromCharCode.apply(null,Array.from(new Uint8Array(t)))).replace(/\+/g,`-`).replace(/\//g,`_`):null})(l);(r=this.un)==null||r.An(o,t,s,c,u),o&&typeof n==`function`&&n(o,s,c)}jn(){var e;(e=this.un)==null||e.xn(!0)}Nn(e,t){var n;(n=this.un)==null||n.xn(!1),a.info(e),typeof t==`function`&&t(!1)}Un(e,t,n,i){if(t.permission==="default")try{window.safari.pushNotification.requestPermission(this.bn,e,{api_key:this.an,device_id:this.hn?.ve().id||``},t=>{t.permission===`granted`&&this.un&&this.un.setPushNotificationSubscriptionType(r.NotificationSubscriptionTypes.OPTED_IN),this.Un(e,t,n,i)})}catch(e){this.Nn(`Could not request permission for push: `+e,i)}else t.permission===`denied`?this.Nn(`The user has blocked notifications from this site, or Safari push is not configured in the Braze dashboard.`,i):t.permission===`granted`&&(a.info(`Device successfully subscribed to push.`),this.Dn(t.deviceToken,new Date,n))}requestPermission(e,t,n){let r=r=>{switch(r){case`granted`:typeof e==`function`&&e();return;case`default`:typeof t==`function`&&t();return;case`denied`:typeof n==`function`&&n();return;default:a.error(`Received unexpected permission result `+r)}},i=!1;if(window.Notification.permission!=="default")r(Notification.permission);else{let e=window.Notification.requestPermission(e=>{i&&r(e)});e?e.then(e=>{r(e)}):i=!0}}Pn(e,n,r,i){let o={userVisibleOnly:!0};n!=null&&(o.applicationServerKey=n),e.pushManager.subscribe(o).then(e=>{a.info(`Device successfully subscribed to push.`),this.Dn(e,new Date,r)}).catch(e=>{t.isPushBlocked()?(a.info(`Permission for push notifications was denied.`),typeof i==`function`&&i(!1)):(a.error(`Push subscription failed: `+e),typeof i==`function`&&i(!0))})}Wn(){if(this.dn)return navigator.serviceWorker.getRegistration(this.cn);let e=this.fn?{scope:this.fn}:void 0;return navigator.serviceWorker.register(this.cn,e).then(()=>navigator.serviceWorker.ready.then(e=>(e&&typeof e.update==`function`&&e.update().catch(e=>{a.info(`ServiceWorker update failed: `+e)}),e)))}_n(e){this.dn||(e.unregister(),a.info(`Service worker successfully unregistered.`))}subscribe(i,c){if(!t.isPushSupported())return a.info(e.Tn),void(typeof c==`function`&&c(!1));if(this.yn){if(!this.dn&&window.location!=null){let e=this.cn;e.indexOf(window.location.host)===-1&&(e=window.location.host+e),e.indexOf(window.location.protocol)===-1&&(e=window.location.protocol+`//`+e)}if(t.isPushBlocked())return void this.Nn(`Notifications from this site are blocked. This may be a temporary embargo or a permanent denial.`,c);if(this.B&&!this.B.In()&&this.B.Et()===0)return a.info(`Waiting for VAPID key from server config before subscribing to push.`),void this.B.Vn(()=>{this.subscribe(i,c)});let e=()=>{a.info(`Permission for push notifications was denied.`),typeof c==`function`&&c(!1)},l=()=>{let e=`Permission for push notifications was ignored.`;t.isPushBlocked()&&(e+=` The browser has automatically blocked further permission requests for a period (probably 1 week).`),a.info(e),typeof c==`function`&&c(!0)},f=t.isPushPermissionGranted();this.requestPermission(()=>{!f&&this.un&&this.un.setPushNotificationSubscriptionType(r.NotificationSubscriptionTypes.OPTED_IN),this.Wn().then(e=>{if(e==null)return a.error("No service worker registration. Set the `manageServiceWorkerExternally` initialization option to fal
1se or ensure that your service worker is registered before calling registerPush."),void(typeof c==`function`&&c(!0));e.pushManager.getSubscription().then(t=>{let r=null;if(this.B?.In()!=null&&(r=d.qn(this.B.In())),t){let l,d=null,f=null;if(this.C&&(l=this.C.ft(n.gt.zn)),l&&!s(l)){let e;try{e=o.Rn(l).En}catch{e=null}e==null||isNaN(e.getTime())||e.getTime()===0||(d=e,f=new Date(d),f.setMonth(d.getMonth()+6))}r!=null&&t.options&&t.options.applicationServerKey&&t.options.applicationServerKey.byteLength&&t.options.applicationServerKey.byteLength>0&&!u(r,new Uint8Array(t.options.applicationServerKey))?(t.options.applicationServerKey.byteLength>12?a.info(`Device was already subscribed to push using a different VAPID provider, creating new subscription.`):a.info(`Attempting to upgrade a gcm_sender_id-based push registration to VAPID - depending on the browser this may or may not result in the same gcm_sender_id-based subscription.`),this.kn(t,e,r,i,c)):t.expirationTime&&new Date(t.expirationTime).valueOf()<=new Date().valueOf()?(a.info(`Push subscription is expired, creating new subscription.`),this.kn(t,e,r,i,c)):l&&s(l)?this.kn(t,e,r,i,c):f==null?(a.info(`No push subscription creation date found, creating new subscription.`),this.kn(t,e,r,i,c)):f.valueOf()<=new Date().valueOf()?(a.info(`Push subscription older than 6 months, creating new subscription.`),this.kn(t,e,r,i,c)):(a.info(`Device already subscribed to push, sending existing subscription to backend.`),this.Dn(t,d,i))}else this.Pn(e,r,i,c)}).catch(e=>{a.error(`Error checking current push subscriptions: `+e)})}).catch(e=>{a.error(`ServiceWorker registration failed: `+e)})},l,e)}else if(this.gn){if(this.ln==null||this.ln===``)return a.error(`You must supply the safariWebsitePushId initialization option in order to use registerPush on Safari`),void(typeof c==`function`&&c(!0));let e=window.safari.pushNotification.permission(this.ln);this.Un(this.ln,e,i,c)}}unsubscribe(n,r){if(!t.isPushSupported())return a.info(e.Tn),void(typeof r==`function`&&r());this.yn?navigator.serviceWorker.getRegistration(this.cn).then(e=>{e?e.pushManager.getSubscription().then(t=>{t?(this.jn(),t.unsubscribe().then(t=>{t?(a.info(`Device successfully unsubscribed from push.`),typeof n==`function`&&n()):(a.error(`Failed to unsubscribe device from push.`),typeof r==`function`&&r()),this._n(e)}).catch(e=>{a.error(`Push unsubscription error: `+e),typeof r==`function`&&r()})):(a.info(`Device already unsubscribed from push.`),typeof n==`function`&&n())}).catch(e=>{a.error(`Error unsubscribing from push: `+e),typeof r==`function`&&r()}):(a.info(`Device already unsubscribed from push.`),typeof n==`function`&&n())}):this.gn&&(this.jn(),a.info(`Device unsubscribed from push.`),typeof n==`function`&&n())}};f.Tn=`Push notifications are not supported in this browser.`;var p=e({default:()=>m}),m={l:!1,aa:null,ea:()=>(m.p(),m.aa||=new f(c.mr(),c.Ma(),c.ue(),c.Z(),c.ee(l._a),c.ee(l.Aa),c.ee(l.Ba),c.v(),c.ee(l.Ca),c.ee(l.Da),c.j()),m.aa),p:()=>{m.l||=(c.h(m),!0)},destroy:()=>{m.aa=null,m.l=!1}};export{m as n,p as t};
2//# sourceMappingURL=push-manager-factory-B8a-CAK9.js.map

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.