New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@braze/web-sdk

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@braze/web-sdk - npm Package Compare versions

Comparing version 4.0.1 to 4.0.2

2

package.json
{
"name": "@braze/web-sdk",
"version": "4.0.1",
"version": "4.0.2",
"description": "Braze SDK for web sites and other JS platforms.",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -1,1 +0,1 @@

const Ae={init:function(n){void 0===n&&void 0!==Ae.zg||(Ae.zg=!!n),Ae.Dg||(Ae.Dg=!0)},destroy:function(){Ae.Dg=!1,Ae.zg=void 0,Ae.nd=void 0},setLogger:function(n){"function"==typeof n?(Ae.init(),Ae.nd=n):Ae.info("Ignoring setLogger call since logger is not a function")},toggleLogging:function(){Ae.init(),Ae.zg?(console.log("Disabling Braze logging"),Ae.zg=!1):(console.log("Enabled Braze logging"),Ae.zg=!0)},info:function(n){if(Ae.zg){const o="Braze: "+n;null!=Ae.nd?Ae.nd(o):console.log(o)}},warn:function(n){if(Ae.zg){const o="Braze SDK Warning: "+n+" (v4.0.1)";null!=Ae.nd?Ae.nd(o):console.warn(o)}},error:function(n){if(Ae.zg){const o="Braze SDK Error: "+n+" (v4.0.1)";null!=Ae.nd?Ae.nd(o):console.error(o)}}};export default Ae;
const Ae={init:function(n){void 0===n&&void 0!==Ae.zg||(Ae.zg=!!n),Ae.Dg||(Ae.Dg=!0)},destroy:function(){Ae.Dg=!1,Ae.zg=void 0,Ae.nd=void 0},setLogger:function(n){"function"==typeof n?(Ae.init(),Ae.nd=n):Ae.info("Ignoring setLogger call since logger is not a function")},toggleLogging:function(){Ae.init(),Ae.zg?(console.log("Disabling Braze logging"),Ae.zg=!1):(console.log("Enabled Braze logging"),Ae.zg=!0)},info:function(n){if(Ae.zg){const o="Braze: "+n;null!=Ae.nd?Ae.nd(o):console.log(o)}},warn:function(n){if(Ae.zg){const o="Braze SDK Warning: "+n+" (v4.0.2)";null!=Ae.nd?Ae.nd(o):console.warn(o)}},error:function(n){if(Ae.zg){const o="Braze SDK Error: "+n+" (v4.0.2)";null!=Ae.nd?Ae.nd(o):console.error(o)}}};export default Ae;

@@ -1,1 +0,1 @@

import{Card,Banner,CaptionedImage,ClassicCard,ControlCard}from"../index.js";import{dateFromUnixTimestamp as h,rehydrateDateAfterJsonization as w}from"../../util/date-utils.js";import r from"../../../shared-lib/braze-shared-lib.js";export function newCard(e,n,t,o,i,l,u,d,a,s,w,f,m,C,p,c,x,F){let b;if(n===Card.es.Ct||n===Card.es.dt)b=new ClassicCard(e,t,o,i,l,u,d,a,s,w,f,m,C,p,c,x);else if(n===Card.es.st)b=new CaptionedImage(e,t,o,i,l,u,d,a,s,w,f,m,C,p,c,x);else if(n===Card.es.rs)b=new Banner(e,t,i,u,d,a,s,w,f,m,C,p,c,x);else{if(n!==Card.es.Rt)return r.D.error("Ignoring card with unknown type "+n),null;b=new ControlCard(e,t,d,s,C,p)}return F&&(b.test=F),b}export function newCardFromContentCardsJson(e){if(e[Card.ct.At])return null;const n=e[Card.ct.ns],r=e[Card.ct.ts],t=e[Card.ct.ls],o=e[Card.ct.it],i=e[Card.ct.os],l=e[Card.ct.ht],u=h(e[Card.ct.us]),d=u;let a;a=e[Card.ct.ps]===Card.Dt?null:h(e[Card.ct.ps]);return newCard(n,r,t,o,i,l,d,u,null,a,e[Card.ct.URL],e[Card.ct.bs],e[Card.ct.fs],e[Card.ct.xs],e[Card.ct.js],e[Card.ct.zs],e[Card.ct.gs],e[Card.ct.ks]||!1)}export function newCardFromFeedJson(e){return newCard(e.id,e.type,e.viewed,e.title,e.image,e.description,h(e.created),h(e.updated),e.categories,h(e.expires_at),e.url,e.domain,e.aspect_ratio,e.extras,!1,!1)}export function newCardFromSerializedValue(e){return newCard(e[Card.hs.ns],e[Card.hs.ts],e[Card.hs.ls],e[Card.hs.it],e[Card.hs.os],e[Card.hs.ht],w(e[Card.hs.cs]),w(e[Card.hs.us]),e[Card.hs.ds],w(e[Card.hs.ps]),e[Card.hs.URL],e[Card.hs.bs],e[Card.hs.fs],e[Card.hs.xs],e[Card.hs.js],e[Card.hs.zs],e[Card.hs.gs],e[Card.hs.ks]||!1)??void 0}
import{Card,Banner,CaptionedImage,ClassicCard,ControlCard}from"../index.js";import{dateFromUnixTimestamp as h,rehydrateDateAfterJsonization as w}from"../../util/date-utils.js";import r from"../../../shared-lib/braze-shared-lib.js";export function newCard(e,n,t,o,i,l,u,d,a,s,w,f,m,C,p,c,x,F){let b;if(n===Card.es.Ct||n===Card.es.dt)b=new ClassicCard(e,t,o,i,l,u,d,a,s,w,f,m,C,p,c,x);else if(n===Card.es.st)b=new CaptionedImage(e,t,o,i,l,u,d,a,s,w,f,m,C,p,c,x);else if(n===Card.es.rs)b=new Banner(e,t,i,u,d,a,s,w,f,m,C,p,c,x);else{if(n!==Card.es.Rt)return r.D.error("Ignoring card with unknown type "+n),null;b=new ControlCard(e,t,d,s,C,p)}return F&&(b.test=F),b}export function newCardFromContentCardsJson(e){if(e[Card.ct.At])return null;const n=e[Card.ct.ns],r=e[Card.ct.ts],t=e[Card.ct.ls],o=e[Card.ct.it],i=e[Card.ct.os],l=e[Card.ct.ht],u=h(e[Card.ct.us]),d=u;let a;a=e[Card.ct.ps]===Card.Dt?null:h(e[Card.ct.ps]);return newCard(n,r,t,o,i,l,d,u,null,a,e[Card.ct.URL],e[Card.ct.bs],e[Card.ct.fs],e[Card.ct.xs],e[Card.ct.js],e[Card.ct.zs],e[Card.ct.gs],e[Card.ct.ks]||!1)}export function newCardFromFeedJson(e){return newCard(e.id,e.type,e.viewed,e.title,e.image,e.description,h(e.created),h(e.updated),e.categories,h(e.expires_at),e.url,e.domain,e.aspect_ratio,e.extras,!1,!1)}export function newCardFromSerializedValue(e){return newCard(e[Card.hs.ns],e[Card.hs.ts],e[Card.hs.ls],e[Card.hs.it],e[Card.hs.os],e[Card.hs.ht],w(e[Card.hs.cs]),w(e[Card.hs.us]),e[Card.hs.ds],w(e[Card.hs.ps]),e[Card.hs.URL],e[Card.hs.bs],e[Card.hs.fs],e[Card.hs.xs],e[Card.hs.js],e[Card.hs.zs],e[Card.hs.gs],e[Card.hs.ks]||!1)||void 0}

@@ -1,1 +0,1 @@

import St from"./auth-manager.js";import C from"../common/base-provider.js";import et from"../util/browser-detector.js";import _t from"./device-manager.js";import DeviceProperties from"../Core/device-properties.js";import{isArray as p,keys as X,validateValueIsFromEnum as B,values as It}from"../util/code-utils.js";import{logDeprecationWarning as At}from"../util/deprecation-utils.js";import Nt from"./network-manager.js";import wt from"../request-controller.js";import Tt from"./server-config-manager.js";import Ot from"./session-manager.js";import r from"../../shared-lib/braze-shared-lib.js";import K,{STORAGE_KEYS as o}from"./storage-manager.js";import vt from"./storage-manager-factory.js";import u from"./subscription-manager.js";import{TriggersProviderFactory as Q}from"../triggers/triggers-provider-factory.js";import pt from"../User/user-manager.js";import{User}from"../User/index.js";import{parseQueryStringKeyValues as st}from"../util/url-utils.js";import{WindowUtils as P}from"../util/window-utils.js";const D={$n:"allowCrawlerActivity",ea:"baseUrl",Yn:"noCookies",Xn:"devicePropertyAllowlist",ta:"disablePushTokenMaintenance",Zn:"enableLogging",ho:"enableSdkAuthentication",ia:"manageServiceWorkerExternally",lo:"minimumIntervalBetweenTriggerActionsInSeconds",uo:"sessionTimeoutInSeconds",po:"appVersion",na:"serviceWorkerLocation",ra:"safariWebsitePushId",zn:"localization",yi:"contentSecurityNonce",co:"enableHtmlInAppMessages",mo:"allowUserSuppliedJavascript",vi:"inAppMessageZIndex",zi:"openInAppMessagesInNewTab",tn:"openCardsInNewTab",en:"openNewsFeedCardsInNewTab",Oi:"requireExplicitInAppMessageDismissal",Eo:"doNotLoadFontAwesome",_o:"sdkFlavor"};class Ct{constructor(){this.fo=!1,this.Io=!1,this.Ao=new u,this.So=new u,this.No={},this.wo=[],this.To=[],this.De=[],this.Oo="4.0.1"}vo(t){this.Ao.Et(t)}Mi(t){this.So.Et(t)}initialize(t,i){if(this.bo())return r.D.info("Braze has already been initialized with an API key."),!0;this.No=i||{};let s=this.nn(D.Zn);const e=st(P.Pn());if(e&&"true"===e.brazeLogging&&(s=!0),r.D.init(s),r.D.info(`Initialization Options: ${JSON.stringify(this.No,null,2)}`),null==t||""===t||"string"!=typeof t)return r.D.error("Braze requires a valid API key to be initialized."),!1;this.Wi=t;let n=this.nn(D.ea);if(null==n||""===n||"string"!=typeof n)return r.D.error("Braze requires a valid baseUrl to be initialized."),!1;if(n=n.replace(/(\.[a-z]+)[^\.]*$/i,"$1/api/v3"),0!==n.indexOf("http")&&(n="https://"+n),this.Co=n,et.Lo&&!this.nn(D.$n))return r.D.info("Ignoring activity from crawler bot "+navigator.userAgent),this.Io=!0,!1;const a=this.nn(Ct.Yn)||!1;if(this.h=vt.Po(t,a),new K.ne(null,!0).wr(o.ae))return r.D.info("Ignoring all activity due to previous opt out"),this.Io=!0,!1;for(const t of X(this.No))-1===It(r.Ro).indexOf(t)&&r.D.warn(`Ignoring unknown initialization option '${t}'.`);const h=["mparticle","wordpress","tealium"];if(null!=this.nn(D._o)){const t=this.nn(D._o);-1!==h.indexOf(t)?this.Mo=t:r.D.error("Invalid sdk flavor passed: "+t)}let l=this.nn(r.Ro.Xn);if(null!=l)if(p(l)){const t=[];for(let i=0;i<l.length;i++)B(DeviceProperties,l[i],"devicePropertyAllowlist contained an invalid value.","DeviceProperties")&&t.push(l[i]);l=t}else r.D.error("devicePropertyAllowlist must be an array. Defaulting to all properties."),l=null;this.xi=new _t(this.h,l),this.wt=new Tt(this.h),this.v=new pt(this.wt,this.h),this.j=new Ot(this.h,this.v,this.wt,this.nn(D.uo));const c=new u;return this.yo=new St(this.h,this.nn(D.ho),c),this.Ut(c),this.jt=new Nt(this.xi,this.h,this.yo,this.v,this.j,this.wt,this.Wi,this.Co,this.Oo,this.Mo,this.nn(D.po)),this.Is=new wt(this.Wi,this.Co,this.j,this.xi,this.v,this.wt,this.h,(t=>{if(this.bo())for(const i of this.re())i._s(t)}),this.yo,this.jt),this.Is.initialize(),r.D.info(`Initialized for the Braze backend at "${this.nn(D.ea)}" with API key "${this.Wi}".`),null!=this.nn(D.co)&&At("enableHtmlInAppMessages","initialization option","allowUserSuppliedJavascript"),Q.init(),this.Ao.Nt(this.No),this.fo=!0,!0}destroy(t){if(r.D.destroy(),this.bo()){this.So.Nt(),this.So.removeAllSubscriptions();for(const t of this.wo)t.destroy();this.wo=[];for(const t of this.To)t.clearData(!1);this.To=[],this.removeAllSubscriptions(),this.De=[],this.Is.destroy(),this.Is=null,this.yo=null,this.xi=null,this.jt=null,this.wt=null,this.j=null,this.v=null,this.No={},this.Mo=void 0,this.fo=!1,this.Io=!1,t&&(this.h=null)}}rr(){if(this.Do())return!1;if(!this.bo())throw new Error("Braze must be initialized before calling methods.");return!0}aa(){return this.Wi}ti(){return this.yo}ce(){return this.xi}nr(){return this.jt}nn(t){return this.No[t]}re(){return this.To}pr(){return this.Is}ir(){return this.wt}g(){return this.j}l(){return this.h}jr(){if(this.v&&this.Is)return new User(this.v,this.Is)}p(){return this.v}tr(){return!0===this.nn(D.mo)||!0===this.nn(D.co)}u(t){let i=!1;for(const s of this.wo)s===t&&(i=!0);i||this.wo.push(t)}ar(t){let i=!1;for(const s of this.To)s.constructor===t.constructor&&(i=!0);t instanceof C&&!i&&this.To.push(t)}Ut(t){t instanceof u&&this.De.push(t)}removeAllSubscriptions(){if(this.rr())for(const t of this.De)t.removeAllSubscriptions()}removeSubscription(t){if(this.rr())for(const i of this.De)i.removeSubscription(t)}le(t){this.Io=t}bo(){return this.fo}Do(){return this.Io}}const e=new Ct;export{e as default,Ct as BrazeSdkInstance,D as OPTIONS};
import St from"./auth-manager.js";import C from"../common/base-provider.js";import et from"../util/browser-detector.js";import _t from"./device-manager.js";import DeviceProperties from"../Core/device-properties.js";import{isArray as p,keys as X,validateValueIsFromEnum as B,values as It}from"../util/code-utils.js";import{logDeprecationWarning as At}from"../util/deprecation-utils.js";import Nt from"./network-manager.js";import wt from"../request-controller.js";import Tt from"./server-config-manager.js";import Ot from"./session-manager.js";import r from"../../shared-lib/braze-shared-lib.js";import K,{STORAGE_KEYS as o}from"./storage-manager.js";import vt from"./storage-manager-factory.js";import u from"./subscription-manager.js";import{TriggersProviderFactory as Q}from"../triggers/triggers-provider-factory.js";import pt from"../User/user-manager.js";import{User}from"../User/index.js";import{parseQueryStringKeyValues as st}from"../util/url-utils.js";import{WindowUtils as P}from"../util/window-utils.js";const D={$n:"allowCrawlerActivity",ea:"baseUrl",Yn:"noCookies",Xn:"devicePropertyAllowlist",ta:"disablePushTokenMaintenance",Zn:"enableLogging",ho:"enableSdkAuthentication",ia:"manageServiceWorkerExternally",lo:"minimumIntervalBetweenTriggerActionsInSeconds",uo:"sessionTimeoutInSeconds",po:"appVersion",na:"serviceWorkerLocation",ra:"safariWebsitePushId",zn:"localization",yi:"contentSecurityNonce",co:"enableHtmlInAppMessages",mo:"allowUserSuppliedJavascript",vi:"inAppMessageZIndex",zi:"openInAppMessagesInNewTab",tn:"openCardsInNewTab",en:"openNewsFeedCardsInNewTab",Oi:"requireExplicitInAppMessageDismissal",Eo:"doNotLoadFontAwesome",_o:"sdkFlavor"};class Ct{constructor(){this.fo=!1,this.Io=!1,this.Ao=new u,this.So=new u,this.No={},this.wo=[],this.To=[],this.De=[],this.Oo="4.0.2"}vo(t){this.Ao.Et(t)}Mi(t){this.So.Et(t)}initialize(t,i){if(this.bo())return r.D.info("Braze has already been initialized with an API key."),!0;this.No=i||{};let s=this.nn(D.Zn);const e=st(P.Pn());if(e&&"true"===e.brazeLogging&&(s=!0),r.D.init(s),r.D.info(`Initialization Options: ${JSON.stringify(this.No,null,2)}`),null==t||""===t||"string"!=typeof t)return r.D.error("Braze requires a valid API key to be initialized."),!1;this.Wi=t;let n=this.nn(D.ea);if(null==n||""===n||"string"!=typeof n)return r.D.error("Braze requires a valid baseUrl to be initialized."),!1;if(n=n.replace(/(\.[a-z]+)[^\.]*$/i,"$1/api/v3"),0!==n.indexOf("http")&&(n="https://"+n),this.Co=n,et.Lo&&!this.nn(D.$n))return r.D.info("Ignoring activity from crawler bot "+navigator.userAgent),this.Io=!0,!1;const a=this.nn(Ct.Yn)||!1;if(this.h=vt.Po(t,a),new K.ne(null,!0).wr(o.ae))return r.D.info("Ignoring all activity due to previous opt out"),this.Io=!0,!1;for(const t of X(this.No))-1===It(r.Ro).indexOf(t)&&r.D.warn(`Ignoring unknown initialization option '${t}'.`);const h=["mparticle","wordpress","tealium"];if(null!=this.nn(D._o)){const t=this.nn(D._o);-1!==h.indexOf(t)?this.Mo=t:r.D.error("Invalid sdk flavor passed: "+t)}let l=this.nn(r.Ro.Xn);if(null!=l)if(p(l)){const t=[];for(let i=0;i<l.length;i++)B(DeviceProperties,l[i],"devicePropertyAllowlist contained an invalid value.","DeviceProperties")&&t.push(l[i]);l=t}else r.D.error("devicePropertyAllowlist must be an array. Defaulting to all properties."),l=null;this.xi=new _t(this.h,l),this.wt=new Tt(this.h),this.v=new pt(this.wt,this.h),this.j=new Ot(this.h,this.v,this.wt,this.nn(D.uo));const c=new u;return this.yo=new St(this.h,this.nn(D.ho),c),this.Ut(c),this.jt=new Nt(this.xi,this.h,this.yo,this.v,this.j,this.wt,this.Wi,this.Co,this.Oo,this.Mo,this.nn(D.po)),this.Is=new wt(this.Wi,this.Co,this.j,this.xi,this.v,this.wt,this.h,(t=>{if(this.bo())for(const i of this.re())i._s(t)}),this.yo,this.jt),this.Is.initialize(),r.D.info(`Initialized for the Braze backend at "${this.nn(D.ea)}" with API key "${this.Wi}".`),null!=this.nn(D.co)&&At("enableHtmlInAppMessages","initialization option","allowUserSuppliedJavascript"),Q.init(),this.Ao.Nt(this.No),this.fo=!0,!0}destroy(t){if(r.D.destroy(),this.bo()){this.So.Nt(),this.So.removeAllSubscriptions();for(const t of this.wo)t.destroy();this.wo=[];for(const t of this.To)t.clearData(!1);this.To=[],this.removeAllSubscriptions(),this.De=[],this.Is.destroy(),this.Is=null,this.yo=null,this.xi=null,this.jt=null,this.wt=null,this.j=null,this.v=null,this.No={},this.Mo=void 0,this.fo=!1,this.Io=!1,t&&(this.h=null)}}rr(){if(this.Do())return!1;if(!this.bo())throw new Error("Braze must be initialized before calling methods.");return!0}aa(){return this.Wi}ti(){return this.yo}ce(){return this.xi}nr(){return this.jt}nn(t){return this.No[t]}re(){return this.To}pr(){return this.Is}ir(){return this.wt}g(){return this.j}l(){return this.h}jr(){if(this.v&&this.Is)return new User(this.v,this.Is)}p(){return this.v}tr(){return!0===this.nn(D.mo)||!0===this.nn(D.co)}u(t){let i=!1;for(const s of this.wo)s===t&&(i=!0);i||this.wo.push(t)}ar(t){let i=!1;for(const s of this.To)s.constructor===t.constructor&&(i=!0);t instanceof C&&!i&&this.To.push(t)}Ut(t){t instanceof u&&this.De.push(t)}removeAllSubscriptions(){if(this.rr())for(const t of this.De)t.removeAllSubscriptions()}removeSubscription(t){if(this.rr())for(const i of this.De)i.removeSubscription(t)}le(t){this.Io=t}bo(){return this.fo}Do(){return this.Io}}const e=new Ct;export{e as default,Ct as BrazeSdkInstance,D as OPTIONS};

@@ -1,1 +0,1 @@

import et from"../util/browser-detector.js";import ue from"../models/braze-event.js";import mt from"../models/identifier.js";import{isArray as p,keys as X,validateValueIsFromEnum as B,values as It}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{User}from"../User/index.js";export const STORAGE_KEYS={Cr:{Ur:"ab.storage.userId",zo:"ab.storage.deviceId",Dh:"ab.storage.sessionId"},q:{ga:"ab.test",_a:"ab.storage.events",Ta:"ab.storage.attributes",Aa:"ab.storage.attributes.anonymous_user",Jo:"ab.storage.device",Ko:"ab.storage.sdk_metadata",Ho:"ab.storage.session_id_for_cached_metadata",Wn:"ab.storage.pushToken",Ks:"ab.storage.newsFeed",Qs:"ab.storage.lastNewsFeedRefresh",P:"ab.storage.cardImpressions",nh:"ab.storage.serverConfig",Oa:"ab.storage.triggers",Ra:"ab.storage.triggers.ts",Ch:"ab.storage.messagingSessionStart",Wt:"ab.storage.cc",Cs:"ab.storage.ccLastFullSync",ws:"ab.storage.ccLastCardUpdated",$:"ab.storage.ccClicks",O:"ab.storage.ccImpressions",K:"ab.storage.ccDismissals",ba:"ab.storage.lastDisplayedTriggerTimesById",Ia:"ab.storage.lastDisplayedTriggerTime",Ka:"ab.storage.triggerFireInstancesById",Kn:"ab.storage.signature"},ae:"ab.optOut"};export default class K{constructor(t,e){this.Ya=t,this.Da=e}Lr(t,e){let s=e;null!=e&&e instanceof mt&&(s=e.ss()),this.Ya.store(t,s)}Ga(t){const e=this._r(t);null!=e&&(e._h=(new Date).valueOf(),this.Lr(t,e))}_r(t){return mt.jn(this.Ya.wr(t))}qh(t){this.Ya.remove(t)}so(t){if(null==t||0===t.length)return!1;p(t)||(t=[t]);let e=this.Da.wr(STORAGE_KEYS.q._a);null!=e&&p(e)||(e=[]);for(let s=0;s<t.length;s++)e.push(t[s].ss());return this.Da.store(STORAGE_KEYS.q._a,e)}Hh(t){return null!=t&&this.so([t])}va(){let t=this.Da.wr(STORAGE_KEYS.q._a);this.Da.remove(STORAGE_KEYS.q._a),null==t&&(t=[]);const e=[];let s=!1,o=null;if(p(t))for(let s=0;s<t.length;s++)ue.Na(t[s])?e.push(ue.jn(t[s])):o=s;else s=!0;if(s||null!=o){let n="Stored events could not be deserialized as Events";s&&(n+=", was "+Object.prototype.toString.call(t)+" not an array"),null!=o&&(n+=", value at index "+o+" does not look like an event"),n+=", serialized values were of type "+typeof t+": "+JSON.stringify(t),e.push(new ue(null,r.A.Vo,(new Date).valueOf(),null,{e:n}))}return e}B(t,e){return!!B(STORAGE_KEYS.q,t,"StorageManager cannot store object.","STORAGE_KEYS.OBJECTS")&&this.Da.store(t,e)}I(t){return!!B(STORAGE_KEYS.q,t,"StorageManager cannot retrieve object.","STORAGE_KEYS.OBJECTS")&&this.Da.wr(t)}$s(t){return!!B(STORAGE_KEYS.q,t,"StorageManager cannot remove object.","STORAGE_KEYS.OBJECTS")&&(this.Da.remove(t),!0)}clearData(){const t=X(STORAGE_KEYS.Cr),e=X(STORAGE_KEYS.q);for(let e=0;e<t.length;e++){const s=t[e];this.Ya.remove(STORAGE_KEYS.Cr[s])}for(let t=0;t<e.length;t++){const s=e[t];this.Da.remove(STORAGE_KEYS.q[s])}}pa(t){return t||STORAGE_KEYS.q.Aa}ca(t){let e=this.Da.wr(STORAGE_KEYS.q.Ta);null==e&&(e={});const s=this.pa(t[User.Fn]);for(let r in t)r===User.Fn||null!=e[s]&&null!=e[s][r]||this.Mr(t[User.Fn],r,t[r])}Mr(t,e,s){let r=this.Da.wr(STORAGE_KEYS.q.Ta);null==r&&(r={});const o=this.pa(t);let n=r[o];if(null==n&&(n={},null!=t&&(n[User.Fn]=t)),e===User.Kr){null==n[e]&&(n[e]={});for(let t in s)n[e][t]=s[t]}else n[e]=s;return r[o]=n,this.Da.store(STORAGE_KEYS.q.Ta,r)}Ma(){const t=this.Da.wr(STORAGE_KEYS.q.Ta);this.Da.remove(STORAGE_KEYS.q.Ta);const e=[];for(let s in t)null!=t[s]&&e.push(t[s]);return e}Gr(t){const e=this.Da.wr(STORAGE_KEYS.q.Ta);if(null!=e){const s=this.pa(null),r=e[s];null!=r&&(e[s]=void 0,this.Da.store(STORAGE_KEYS.q.Ta,e),r[User.Fn]=t,this.ca(r))}const s=this._r(STORAGE_KEYS.Cr.Dh);let r=null;null!=s&&(r=s.Ir);const o=this.va();if(null!=o)for(let e=0;e<o.length;e++){const s=o[e];null==s.userId&&s.sessionId==r&&(s.userId=t),this.Hh(s)}}Ca(){return this.Da.ya}}K.Ea=class{constructor(t){this.Wi=t,this.ya=et.Ua()?3:10}wa(t){return t+"."+this.Wi}store(t,e){const s={v:e};try{return localStorage.setItem(this.wa(t),JSON.stringify(s)),!0}catch(t){return r.D.info("Storage failure: "+t.message),!1}}wr(t){try{const e=JSON.parse(localStorage.getItem(this.wa(t)));return null==e?null:e.v}catch(t){return r.D.info("Storage retrieval failure: "+t.message),null}}remove(t){try{localStorage.removeItem(this.wa(t))}catch(t){return r.D.info("Storage removal failure: "+t.message),!1}}};K.ne=class{constructor(t,e){this.Wi=t,this.Ba=this.Fa(),this.La=525949,this.Pa=!!e}wa(t){return null!=this.Wi?t+"."+this.Wi:t}Fa(){let t=0,e=document.location.hostname;const s=e.split("."),r="ab._gd";for(;t<s.length-1&&-1===document.cookie.indexOf(r+"="+r);)t++,e="."+s.slice(-1-t).join("."),document.cookie=r+"="+r+";domain="+e+";";return document.cookie=r+"=;expires="+new Date(0).toGMTString()+";domain="+e+";",e}ie(){const t=new Date;return t.setTime(t.getTime()+60*this.La*1e3),t.getFullYear()}xa(){const t=It(STORAGE_KEYS.Cr),e=document.cookie.split(";");for(let s=0;s<e.length;s++){let r=e[s];for(;" "===r.charAt(0);)r=r.substring(1);let o=!1;for(let e=0;e<t.length;e++)if(0===r.indexOf(t[e])){o=!0;break}if(o){const t=r.split("=")[0];-1===t.indexOf("."+this.Wi)&&this.Ja(t)}}}store(t,e){this.xa();const s=new Date;s.setTime(s.getTime()+60*this.La*1e3);const o="expires="+s.toUTCString(),n="domain="+this.Ba;let i;i=this.Pa?e:encodeURIComponent(JSON.stringify(e));const a=this.wa(t)+"="+i+";"+o+";"+n+";path=/";return a.length>=4093?(r.D.info("Storage failure: string is "+a.length+" chars which is too large to store as a cookie."),!1):(document.cookie=a,!0)}wr(t){const e=[],s=this.wa(t)+"=",o=document.cookie.split(";");for(let n=0;n<o.length;n++){let i=o[n];for(;" "===i.charAt(0);)i=i.substring(1);if(0===i.indexOf(s))try{let t;t=this.Pa?i.substring(s.length,i.length):JSON.parse(decodeURIComponent(i.substring(s.length,i.length))),e.push(t)}catch(e){return r.D.info("Storage retrieval failure: "+e.message),this.remove(t),null}}return e.length>0?e[e.length-1]:null}remove(t){this.Ja(this.wa(t))}Ja(t){const e=t+"=;expires="+new Date(0).toGMTString();document.cookie=e,document.cookie=e+";path=/",document.cookie=e+";path="+document.location.pathname;const s=e+";domain="+this.Ba;document.cookie=s,document.cookie=s+";path=/",document.cookie=s+";path="+document.location.pathname}};K.fa=class{constructor(){this.ka={},this.za=5242880,this.ya=3}store(t,e){const s={value:e},o=this.Qa(e);return o>this.za?(r.D.info("Storage failure: object is ≈"+o+" bytes which is greater than the max of "+this.za),!1):(this.ka[t]=s,!0)}Qa(t){const e=[],s=[t];let r=0;for(;s.length;){const t=s.pop();if("boolean"==typeof t)r+=4;else if("string"==typeof t)r+=2*t.length;else if("number"==typeof t)r+=8;else if("object"==typeof t&&-1===e.indexOf(t)){e.push(t);for(let e in t)s.push(t[e])}}return r}wr(t){const e=this.ka[t];return null==e?null:e.value}remove(t){this.ka[t]=null}};K.Sa=class{constructor(t,e,s){this.Va=[],e&&this.Va.push(new K.ne(t)),s&&this.Va.push(new K.Ea(t)),this.Va.push(new K.fa(t))}store(t,e){let s=!0;for(let r=0;r<this.Va.length;r++)s=this.Va[r].store(t,e)&&s;return s}wr(t){for(let e=0;e<this.Va.length;e++){const s=this.Va[e].wr(t);if(null!=s)return s}return null}remove(t){for(let e=0;e<this.Va.length;e++)this.Va[e].remove(t)}};
import et from"../util/browser-detector.js";import ue from"../models/braze-event.js";import mt from"../models/identifier.js";import{isArray as p,keys as X,validateValueIsFromEnum as B,values as It}from"../util/code-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{User}from"../User/index.js";export const STORAGE_KEYS={Cr:{Ur:"ab.storage.userId",zo:"ab.storage.deviceId",Dh:"ab.storage.sessionId"},q:{ga:"ab.test",_a:"ab.storage.events",Ta:"ab.storage.attributes",Aa:"ab.storage.attributes.anonymous_user",Jo:"ab.storage.device",Ko:"ab.storage.sdk_metadata",Ho:"ab.storage.session_id_for_cached_metadata",Wn:"ab.storage.pushToken",Ks:"ab.storage.newsFeed",Qs:"ab.storage.lastNewsFeedRefresh",P:"ab.storage.cardImpressions",nh:"ab.storage.serverConfig",Oa:"ab.storage.triggers",Ra:"ab.storage.triggers.ts",Ch:"ab.storage.messagingSessionStart",Wt:"ab.storage.cc",Cs:"ab.storage.ccLastFullSync",ws:"ab.storage.ccLastCardUpdated",$:"ab.storage.ccClicks",O:"ab.storage.ccImpressions",K:"ab.storage.ccDismissals",ba:"ab.storage.lastDisplayedTriggerTimesById",Ia:"ab.storage.lastDisplayedTriggerTime",Ka:"ab.storage.triggerFireInstancesById",Kn:"ab.storage.signature"},ae:"ab.optOut"};export default class K{constructor(t,e){this.Ya=t,this.Da=e}Lr(t,e){let s=e;null!=e&&e instanceof mt&&(s=e.ss()),this.Ya.store(t,s)}Ga(t){const e=this._r(t);null!=e&&(e._h=(new Date).valueOf(),this.Lr(t,e))}_r(t){return mt.jn(this.Ya.wr(t))}qh(t){this.Ya.remove(t)}so(t){if(null==t||0===t.length)return!1;p(t)||(t=[t]);let e=this.Da.wr(STORAGE_KEYS.q._a);null!=e&&p(e)||(e=[]);for(let s=0;s<t.length;s++)e.push(t[s].ss());return this.Da.store(STORAGE_KEYS.q._a,e)}Hh(t){return null!=t&&this.so([t])}va(){let t=this.Da.wr(STORAGE_KEYS.q._a);this.Da.remove(STORAGE_KEYS.q._a),null==t&&(t=[]);const e=[];let s=!1,o=null;if(p(t))for(let s=0;s<t.length;s++)ue.Na(t[s])?e.push(ue.jn(t[s])):o=s;else s=!0;if(s||null!=o){let n="Stored events could not be deserialized as Events";s&&(n+=", was "+Object.prototype.toString.call(t)+" not an array"),null!=o&&(n+=", value at index "+o+" does not look like an event"),n+=", serialized values were of type "+typeof t+": "+JSON.stringify(t),e.push(new ue(null,r.A.Vo,(new Date).valueOf(),null,{e:n}))}return e}B(t,e){return!!B(STORAGE_KEYS.q,t,"StorageManager cannot store object.","STORAGE_KEYS.OBJECTS")&&this.Da.store(t,e)}I(t){return!!B(STORAGE_KEYS.q,t,"StorageManager cannot retrieve object.","STORAGE_KEYS.OBJECTS")&&this.Da.wr(t)}$s(t){return!!B(STORAGE_KEYS.q,t,"StorageManager cannot remove object.","STORAGE_KEYS.OBJECTS")&&(this.Da.remove(t),!0)}clearData(){const t=X(STORAGE_KEYS.Cr),e=X(STORAGE_KEYS.q);for(let e=0;e<t.length;e++){const s=t[e];this.Ya.remove(STORAGE_KEYS.Cr[s])}for(let t=0;t<e.length;t++){const s=e[t];this.Da.remove(STORAGE_KEYS.q[s])}}pa(t){return t||STORAGE_KEYS.q.Aa}ca(t){let e=this.Da.wr(STORAGE_KEYS.q.Ta);null==e&&(e={});const s=this.pa(t[User.Fn]);for(let r in t)r===User.Fn||null!=e[s]&&null!=e[s][r]||this.Mr(t[User.Fn],r,t[r])}Mr(t,e,s){let r=this.Da.wr(STORAGE_KEYS.q.Ta);null==r&&(r={});const o=this.pa(t);let n=r[o];if(null==n&&(n={},null!=t&&(n[User.Fn]=t)),e===User.Kr){null==n[e]&&(n[e]={});for(let t in s)n[e][t]=s[t]}else n[e]=s;return r[o]=n,this.Da.store(STORAGE_KEYS.q.Ta,r)}Ma(){const t=this.Da.wr(STORAGE_KEYS.q.Ta);this.Da.remove(STORAGE_KEYS.q.Ta);const e=[];for(let s in t)null!=t[s]&&e.push(t[s]);return e}Gr(t){const e=this.Da.wr(STORAGE_KEYS.q.Ta);if(null!=e){const s=this.pa(null),r=e[s];null!=r&&(e[s]=void 0,this.Da.store(STORAGE_KEYS.q.Ta,e),r[User.Fn]=t,this.ca(r))}const s=this._r(STORAGE_KEYS.Cr.Dh);let r=null;null!=s&&(r=s.Ir);const o=this.va();if(null!=o)for(let e=0;e<o.length;e++){const s=o[e];null==s.userId&&s.sessionId==r&&(s.userId=t),this.Hh(s)}}Ca(){return this.Da.ya}}K.Ea=class{constructor(t){this.Wi=t,this.ya=et.Ua()?3:10}wa(t){return t+"."+this.Wi}store(t,e){const s={v:e};try{return localStorage.setItem(this.wa(t),JSON.stringify(s)),!0}catch(t){return r.D.info("Storage failure: "+t.message),!1}}wr(t){try{const e=JSON.parse(localStorage.getItem(this.wa(t)));return null==e?null:e.v}catch(t){return r.D.info("Storage retrieval failure: "+t.message),null}}remove(t){try{localStorage.removeItem(this.wa(t))}catch(t){return r.D.info("Storage removal failure: "+t.message),!1}}};K.ne=class{constructor(t,e){this.Wi=t,this.Ba=this.Fa(),this.La=576e3,this.Pa=!!e}wa(t){return null!=this.Wi?t+"."+this.Wi:t}Fa(){let t=0,e=document.location.hostname;const s=e.split("."),r="ab._gd";for(;t<s.length-1&&-1===document.cookie.indexOf(r+"="+r);)t++,e="."+s.slice(-1-t).join("."),document.cookie=r+"="+r+";domain="+e+";";return document.cookie=r+"=;expires="+new Date(0).toGMTString()+";domain="+e+";",e}ie(){const t=new Date;return t.setTime(t.getTime()+60*this.La*1e3),t.getFullYear()}xa(){const t=It(STORAGE_KEYS.Cr),e=document.cookie.split(";");for(let s=0;s<e.length;s++){let r=e[s];for(;" "===r.charAt(0);)r=r.substring(1);let o=!1;for(let e=0;e<t.length;e++)if(0===r.indexOf(t[e])){o=!0;break}if(o){const t=r.split("=")[0];-1===t.indexOf("."+this.Wi)&&this.Ja(t)}}}store(t,e){this.xa();const s=new Date;s.setTime(s.getTime()+60*this.La*1e3);const o="expires="+s.toUTCString(),n="domain="+this.Ba;let i;i=this.Pa?e:encodeURIComponent(JSON.stringify(e));const a=this.wa(t)+"="+i+";"+o+";"+n+";path=/";return a.length>=4093?(r.D.info("Storage failure: string is "+a.length+" chars which is too large to store as a cookie."),!1):(document.cookie=a,!0)}wr(t){const e=[],s=this.wa(t)+"=",o=document.cookie.split(";");for(let n=0;n<o.length;n++){let i=o[n];for(;" "===i.charAt(0);)i=i.substring(1);if(0===i.indexOf(s))try{let t;t=this.Pa?i.substring(s.length,i.length):JSON.parse(decodeURIComponent(i.substring(s.length,i.length))),e.push(t)}catch(e){return r.D.info("Storage retrieval failure: "+e.message),this.remove(t),null}}return e.length>0?e[e.length-1]:null}remove(t){this.Ja(this.wa(t))}Ja(t){const e=t+"=;expires="+new Date(0).toGMTString();document.cookie=e,document.cookie=e+";path=/",document.cookie=e+";path="+document.location.pathname;const s=e+";domain="+this.Ba;document.cookie=s,document.cookie=s+";path=/",document.cookie=s+";path="+document.location.pathname}};K.fa=class{constructor(){this.ka={},this.za=5242880,this.ya=3}store(t,e){const s={value:e},o=this.Qa(e);return o>this.za?(r.D.info("Storage failure: object is ≈"+o+" bytes which is greater than the max of "+this.za),!1):(this.ka[t]=s,!0)}Qa(t){const e=[],s=[t];let r=0;for(;s.length;){const t=s.pop();if("boolean"==typeof t)r+=4;else if("string"==typeof t)r+=2*t.length;else if("number"==typeof t)r+=8;else if("object"==typeof t&&-1===e.indexOf(t)){e.push(t);for(let e in t)s.push(t[e])}}return r}wr(t){const e=this.ka[t];return null==e?null:e.value}remove(t){this.ka[t]=null}};K.Sa=class{constructor(t,e,s){this.Va=[],e&&this.Va.push(new K.ne(t)),s&&this.Va.push(new K.Ea(t)),this.Va.push(new K.fa(t))}store(t,e){let s=!0;for(let r=0;r<this.Va.length;r++)s=this.Va[r].store(t,e)&&s;return s}wr(t){for(let e=0;e<this.Va.length;e++){const s=this.Va[e].wr(t);if(null!=s)return s}return null}remove(t){for(let e=0;e<this.Va.length;e++)this.Va[e].remove(t)}};

@@ -1,1 +0,1 @@

export default class jt{constructor(t,s,i,h,l,e,r){this.hh=t||0,this.gh=s||[],this.mh=i||[],this.fh=h||[],this.ph=l,null!=l&&""!==l||(this.ph=null),this.oh=e||null,this.uh=r||{}}ss(){return{s:"4.0.1",l:this.hh,e:this.gh,a:this.mh,p:this.fh,m:this.ph,v:this.oh,c:this.uh}}static jn(t){let s=t.l;return"4.0.1"!==t.s&&(s=0),new jt(s,t.e,t.a,t.p,t.m,t.v,t.c)}}
export default class jt{constructor(t,s,i,h,l,e,r){this.hh=t||0,this.gh=s||[],this.mh=i||[],this.fh=h||[],this.ph=l,null!=l&&""!==l||(this.ph=null),this.oh=e||null,this.uh=r||{}}ss(){return{s:"4.0.2",l:this.hh,e:this.gh,a:this.mh,p:this.fh,m:this.ph,v:this.oh,c:this.uh}}static jn(t){let s=t.l;return"4.0.2"!==t.s&&(s=0),new jt(s,t.e,t.a,t.p,t.m,t.v,t.c)}}

@@ -1,1 +0,1 @@

import me from"../InAppMessage/in-app-message-manager-factory.js";import e,{OPTIONS as D}from"../managers/braze-instance.js";import ir from"./triggers-provider.js";export const TriggersProviderFactory={t:!1,provider:null,er:()=>(TriggersProviderFactory.init(),TriggersProviderFactory.provider),rg:()=>{TriggersProviderFactory.provider||(TriggersProviderFactory.provider=new ir(e.nn(D.lo)??30,me.m().Be(),e.l(),e.pr(),me.m()),e.ar(TriggersProviderFactory.provider))},init:()=>{TriggersProviderFactory.t||(TriggersProviderFactory.rg(),e.u(TriggersProviderFactory),TriggersProviderFactory.t=!0)},destroy:()=>{TriggersProviderFactory.provider=null,TriggersProviderFactory.t=!1}};
import me from"../InAppMessage/in-app-message-manager-factory.js";import e,{OPTIONS as D}from"../managers/braze-instance.js";import ir from"./triggers-provider.js";export const TriggersProviderFactory={t:!1,provider:null,er:()=>(TriggersProviderFactory.init(),TriggersProviderFactory.provider),rg:()=>{if(!TriggersProviderFactory.provider){const r=e.nn(D.lo);TriggersProviderFactory.provider=new ir(null!=r?r:30,me.m().Be(),e.l(),e.pr(),me.m()),e.ar(TriggersProviderFactory.provider)}},init:()=>{TriggersProviderFactory.t||(TriggersProviderFactory.rg(),e.u(TriggersProviderFactory),TriggersProviderFactory.t=!0)},destroy:()=>{TriggersProviderFactory.provider=null,TriggersProviderFactory.t=!1}};

@@ -1,1 +0,1 @@

import e,{OPTIONS as D}from"../../managers/braze-instance.js";export function attachCSS(n,t,o){const c=n??document.querySelector("head"),s=`ab-${t}-css-definitions-${"4.0.1".replace(/\./g,"-")}`,a=c.ownerDocument??document;if(null==a.getElementById(s)){const n=a.createElement("style");n.innerHTML=o,n.id=s;const t=e.nn(D.yi);null!=t&&n.setAttribute("nonce",t),c.appendChild(n)}}
import e,{OPTIONS as D}from"../../managers/braze-instance.js";export function attachCSS(n,t,o){const c=n||document.querySelector("head"),s=`ab-${t}-css-definitions-${"4.0.2".replace(/\./g,"-")}`,a=c.ownerDocument||document;if(null==a.getElementById(s)){const n=a.createElement("style");n.innerHTML=o,n.id=s;const t=e.nn(D.yi);null!=t&&n.setAttribute("nonce",t),c.appendChild(n)}}

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc