@braze/web-sdk 4.2.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/index.d.ts +7 -6
  2. package/package.json +1 -1
  3. package/shared-lib/braze-shared-lib.js +1 -1
  4. package/shared-lib/encoding-utils.js +1 -1
  5. package/shared-lib/event-types.js +1 -1
  6. package/shared-lib/indexed-db-adapter.js +1 -1
  7. package/shared-lib/logger.js +1 -1
  8. package/shared-lib/supported-options.js +1 -1
  9. package/src/InAppMessage/display/html-message-to-html.js +1 -1
  10. package/src/InAppMessage/in-app-message-manager.js +1 -1
  11. package/src/InAppMessage/models/in-app-message.js +1 -1
  12. package/src/InAppMessage/models/modal-message.js +1 -1
  13. package/src/InAppMessage/models/slide-up-message.js +1 -1
  14. package/src/InAppMessage/models/templated-in-app-message.js +1 -1
  15. package/src/InAppMessage/ui/show-in-app-message.js +1 -1
  16. package/src/Push/is-push-blocked.js +1 -1
  17. package/src/Push/is-push-permission-granted.js +1 -1
  18. package/src/Push/is-push-supported.js +1 -1
  19. package/src/Push/push-manager-factory.js +1 -1
  20. package/src/Push/push-manager.js +1 -1
  21. package/src/Push/request-push-permission.js +1 -1
  22. package/src/Push/unregister-push.js +1 -1
  23. package/src/Push/utils/push-utils.js +1 -0
  24. package/src/User/user-manager.js +1 -1
  25. package/src/User/user.js +1 -1
  26. package/src/common/feed-display.js +1 -1
  27. package/src/l10n/l10n-manager-factory.js +1 -1
  28. package/src/managers/auth-manager.js +1 -1
  29. package/src/managers/braze-instance.js +1 -1
  30. package/src/managers/device-manager.js +1 -1
  31. package/src/managers/network-manager.js +1 -1
  32. package/src/managers/server-config-manager.js +1 -1
  33. package/src/managers/session-manager.js +1 -1
  34. package/src/managers/storage-manager-factory.js +1 -1
  35. package/src/managers/storage-manager.js +1 -1
  36. package/src/models/backend-errors.js +1 -1
  37. package/src/models/braze-event.js +1 -1
  38. package/src/models/device.js +1 -1
  39. package/src/models/identifier.js +1 -1
  40. package/src/models/push-token.js +1 -1
  41. package/src/models/server-config.js +1 -1
  42. package/src/request-controller.js +1 -1
  43. package/src/triggers/models/custom-event-data.js +1 -1
  44. package/src/triggers/models/custom-event-property-data.js +1 -1
  45. package/src/triggers/models/filter-set.js +1 -1
  46. package/src/triggers/models/filter.js +1 -1
  47. package/src/triggers/models/in-app-message-click-data.js +1 -1
  48. package/src/triggers/models/purchase-data.js +1 -1
  49. package/src/triggers/models/purchase-property-data.js +1 -1
  50. package/src/triggers/models/push-click-data.js +1 -1
  51. package/src/triggers/models/trigger-condition.js +1 -1
  52. package/src/triggers/models/trigger.js +1 -1
  53. package/src/triggers/triggers-provider-factory.js +1 -1
  54. package/src/triggers/triggers-provider.js +1 -1
  55. package/src/ui/js/attach-css.js +1 -1
  56. package/src/ui/js/feed-css.js +1 -1
  57. package/src/ui/js/iam-css.js +1 -1
  58. package/src/ui/js/load-font-awesome.js +1 -1
  59. package/src/util/base-device-parser.js +1 -1
  60. package/src/util/braze-actions.js +1 -1
  61. package/src/util/browser-detector.js +1 -1
  62. package/src/util/client-hints-parser.js +1 -1
  63. package/src/util/color-utils.js +1 -1
  64. package/src/util/device-constants.js +1 -1
  65. package/src/util/dom-utils.js +1 -1
  66. package/src/util/net.js +1 -1
  67. package/src/util/user-agent-parser.js +1 -1
  68. package/src/util/validation-utils.js +1 -1
  69. package/src/util/window-utils.js +1 -1
@@ -1 +1 @@
1
- import Yt from"./base-device-parser.js";import{Browsers as ri}from"./device-constants.js";export default class ti extends Yt{constructor(){if(super(),this.userAgentData=navigator.userAgentData,this.userAgentData){const t=this.ic();this.browser=t.browser||"Unknown Browser",this.version=t.version||"Unknown Version"}}tf(){return this.browser}ef(){return this.version}Zo(t){if(this.OS)return Promise.resolve(this.OS);const r=r=>{for(let s=0;s<t.length;s++){const e=ti.rf(r,t[s]);if(e)return this.OS=e,this.OS}return r};return this.userAgentData.platform?Promise.resolve(r(this.userAgentData.platform)):this.nc().then((t=>r(t.platform))).catch((()=>navigator.platform))}ic(){const t={},r=this.userAgentData.brands;if(r&&r.length)for(const s of r){const r=this.oc(ri),e=s.brand.match(r);if(e&&e.length>0){t.browser=e[0],t.version=s.version;break}}return t}oc(t){const r=[];for(const s in t)t[s]!==ri.vg&&r.push(t[s]);return new RegExp("("+r.join("|")+")","i")}nc(){return this.userAgentData.getHighEntropyValues?this.userAgentData.getHighEntropyValues(["platform"]):Promise.reject()}}
1
+ import Zt from"./base-device-parser.js";import{Browsers as ri}from"./device-constants.js";export default class ti extends Zt{constructor(){if(super(),this.userAgentData=navigator.userAgentData,this.userAgentData){const t=this.sc();this.browser=t.browser||"Unknown Browser",this.version=t.version||"Unknown Version"}}tf(){return this.browser}ef(){return this.version}Ko(t){if(this.OS)return Promise.resolve(this.OS);const r=r=>{for(let s=0;s<t.length;s++){const e=ti.rf(r,t[s]);if(e)return this.OS=e,this.OS}return r};return this.userAgentData.platform?Promise.resolve(r(this.userAgentData.platform)):this.ic().then((t=>r(t.platform))).catch((()=>navigator.platform))}sc(){const t={},r=this.userAgentData.brands;if(r&&r.length)for(const s of r){const r=this.nc(ri),e=s.brand.match(r);if(e&&e.length>0){t.browser=e[0],t.version=s.version;break}}return t}nc(t){const r=[];for(const s in t)t[s]!==ri.yg&&r.push(t[s]);return new RegExp("("+r.join("|")+")","i")}ic(){return this.userAgentData.getHighEntropyValues?this.userAgentData.getHighEntropyValues(["platform"]):Promise.reject()}}
@@ -1 +1 @@
1
- import et from"./browser-detector.js";export function isTransparent(r){return r=parseInt(r),!isNaN(r)&&(4278190080&r)>>>24==0}export function toRgba(r,t){if(r=parseInt(r),isNaN(r))return"";t=parseFloat(t),isNaN(t)&&(t=1);const n=255&(r>>>=0),e=(65280&r)>>>8,o=(16711680&r)>>>16,a=((4278190080&r)>>>24)/255;return et.bg()?"rgba("+[o,e,n,a*t].join(",")+")":"rgb("+[o,e,n].join(",")+")"}export function toRgb(r){if(r=parseInt(r),isNaN(r))return"";return"rgb("+[(16711680&(r>>>=0))>>>16,(65280&r)>>>8,255&r].join(",")+")"}
1
+ import et from"./browser-detector.js";export function isTransparent(r){return r=parseInt(r),!isNaN(r)&&(4278190080&r)>>>24==0}export function toRgba(r,t){if(r=parseInt(r),isNaN(r))return"";t=parseFloat(t),isNaN(t)&&(t=1);const n=255&(r>>>=0),e=(65280&r)>>>8,o=(16711680&r)>>>16,a=((4278190080&r)>>>24)/255;return et.vg()?"rgba("+[o,e,n,a*t].join(",")+")":"rgb("+[o,e,n].join(",")+")"}export function toRgb(r){if(r=parseInt(r),isNaN(r))return"";return"rgb("+[(16711680&(r>>>=0))>>>16,(65280&r)>>>8,255&r].join(",")+")"}
@@ -1 +1 @@
1
- export const Browsers={rE:"Chrome",eE:"Edge",vg:"Internet Explorer",EE:"Opera",yg:"Safari",oE:"Firefox"};export const OperatingSystems={Og:"Android",ln:"iOS",Bg:"Mac",mg:"Windows"};
1
+ export const Browsers={rE:"Chrome",eE:"Edge",yg:"Internet Explorer",EE:"Opera",Bg:"Safari",oE:"Firefox"};export const OperatingSystems={xg:"Android",ln:"iOS",kg:"Mac",Pg:"Windows"};
@@ -1 +1 @@
1
- export function _isInView(t,n,e,s){if(null==t)return!1;n=n||!1,e=e||!1;const i=t.getBoundingClientRect();return null!=i&&((i.top>=0&&i.top<=(window.innerHeight||document.documentElement.clientHeight)||!n)&&(i.left>=0||!s)&&(i.bottom>=0&&i.bottom<=(window.innerHeight||document.documentElement.clientHeight)||!e)&&(i.right<=(window.innerWidth||document.documentElement.clientWidth)||!s))}export const DOMUtils={cu:null,eo:_isInView};export const DIRECTIONS={Te:"up",$e:"down",ot:"left",et:"right"};export function supportsPassive(){if(null==DOMUtils.cu){DOMUtils.cu=!1;try{const t=Object.defineProperty({},"passive",{get:()=>{DOMUtils.cu=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(t){}}return DOMUtils.cu}export function addPassiveEventListener(t,n,e){t.addEventListener(n,e,!!supportsPassive()&&{passive:!0})}export function topIsInView(t){return DOMUtils.eo(t,!0,!1,!1)}export function bottomIsInView(t){return DOMUtils.eo(t,!1,!0,!1)}export function clickElement(t){if(t.onclick){const n=document.createEvent("MouseEvents");n.initEvent("click",!0,!0),t.onclick.apply(t,[n])}}export function detectSwipe(t,n,e){let s=null,i=null;addPassiveEventListener(t,"touchstart",(t=>{s=t.touches[0].clientX,i=t.touches[0].clientY})),addPassiveEventListener(t,"touchmove",(o=>{if(null==s||null==i)return;const l=s-o.touches[0].clientX,u=i-o.touches[0].clientY;Math.abs(l)>Math.abs(u)&&Math.abs(l)>=25?((l>0&&n===DIRECTIONS.ot||l<0&&n===DIRECTIONS.et)&&e(o),s=null,i=null):Math.abs(u)>=25&&((u>0&&n===DIRECTIONS.Te&&t.scrollTop===t.scrollHeight-t.offsetHeight||u<0&&n===DIRECTIONS.$e&&0===t.scrollTop)&&e(o),s=null,i=null)}))}export function buildSvg(t,n,e){const s="http://www.w3.org/2000/svg",i=document.createElementNS(s,"svg");i.setAttribute("viewBox",t),i.setAttribute("xmlns",s);const o=document.createElementNS(s,"path");return o.setAttribute("d",n),null!=e&&o.setAttribute("fill",e),i.appendChild(o),i}
1
+ export function _isInView(t,n,e,s){if(null==t)return!1;n=n||!1,e=e||!1;const i=t.getBoundingClientRect();return null!=i&&((i.top>=0&&i.top<=(window.innerHeight||document.documentElement.clientHeight)||!n)&&(i.left>=0||!s)&&(i.bottom>=0&&i.bottom<=(window.innerHeight||document.documentElement.clientHeight)||!e)&&(i.right<=(window.innerWidth||document.documentElement.clientWidth)||!s))}export const DOMUtils={wu:null,eo:_isInView};export const DIRECTIONS={Te:"up",$e:"down",ot:"left",et:"right"};export function supportsPassive(){if(null==DOMUtils.wu){DOMUtils.wu=!1;try{const t=Object.defineProperty({},"passive",{get:()=>{DOMUtils.wu=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(t){}}return DOMUtils.wu}export function addPassiveEventListener(t,n,e){t.addEventListener(n,e,!!supportsPassive()&&{passive:!0})}export function topIsInView(t){return DOMUtils.eo(t,!0,!1,!1)}export function bottomIsInView(t){return DOMUtils.eo(t,!1,!0,!1)}export function clickElement(t){if(t.onclick){const n=document.createEvent("MouseEvents");n.initEvent("click",!0,!0),t.onclick.apply(t,[n])}}export function detectSwipe(t,n,e){let s=null,i=null;addPassiveEventListener(t,"touchstart",(t=>{s=t.touches[0].clientX,i=t.touches[0].clientY})),addPassiveEventListener(t,"touchmove",(o=>{if(null==s||null==i)return;const l=s-o.touches[0].clientX,u=i-o.touches[0].clientY;Math.abs(l)>Math.abs(u)&&Math.abs(l)>=25?((l>0&&n===DIRECTIONS.ot||l<0&&n===DIRECTIONS.et)&&e(o),s=null,i=null):Math.abs(u)>=25&&((u>0&&n===DIRECTIONS.Te&&t.scrollTop===t.scrollHeight-t.offsetHeight||u<0&&n===DIRECTIONS.$e&&0===t.scrollTop)&&e(o),s=null,i=null)}))}export function buildSvg(t,n,e){const s="http://www.w3.org/2000/svg",i=document.createElementNS(s,"svg");i.setAttribute("viewBox",t),i.setAttribute("xmlns",s);const o=document.createElementNS(s,"path");return o.setAttribute("d",n),null!=e&&o.setAttribute("fill",e),i.appendChild(o),i}
package/src/util/net.js CHANGED
@@ -1 +1 @@
1
- import r from"../../shared-lib/braze-shared-lib.js";import Rt from"../models/backend-errors.js";const b={Hs:t=>{let e,o;try{const n=()=>{r.D.error("This browser does not have any supported ajax options!")};if(window.XMLHttpRequest?(e=new XMLHttpRequest,e||n()):n(),null!=e){const r=()=>{"function"==typeof t.error&&t.error(e.status),"function"==typeof t.kl&&t.kl(!1)};e.onload=()=>{let o=!1;if(4===e.readyState)if(o=e.status>=200&&e.status<300||304===e.status,o){if("function"==typeof t.S){let o,r;try{o=JSON.parse(e.responseText),r=e.getAllResponseHeaders()}catch(o){const n={error:""===e.responseText?Rt.fa:Rt.ma,response:e.responseText};t.S(n,r)}o&&t.S(o,r)}"function"==typeof t.kl&&t.kl(!0)}else r()},e.onerror=()=>{r()},e.ontimeout=()=>{r()},o=JSON.stringify(t.data),e.open("POST",t.url,!0),e.setRequestHeader("Content-type","application/json"),e.setRequestHeader("X-Requested-With","XMLHttpRequest");const n=t.headers||[];for(const t of n)e.setRequestHeader(t[0],t[1]);e.send(o)}}catch(t){r.D.error(`Network request error: ${t.message}`)}}};export const readResponseHeaders=t=>{let e={};const o=t.toString().split("\r\n");if(!o)return e;let r,n;for(const t of o)t&&(r=t.slice(0,t.indexOf(":")).toLowerCase().trim(),n=t.slice(t.indexOf(":")+1).trim(),e[r]=n);return e};export default b;
1
+ import r from"../../shared-lib/braze-shared-lib.js";import qt from"../models/backend-errors.js";const b={Hs:t=>{let e,o;try{const n=()=>{r.D.error("This browser does not have any supported ajax options!")};if(window.XMLHttpRequest?(e=new XMLHttpRequest,e||n()):n(),null!=e){const r=()=>{"function"==typeof t.error&&t.error(e.status),"function"==typeof t.Rl&&t.Rl(!1)};e.onload=()=>{let o=!1;if(4===e.readyState)if(o=e.status>=200&&e.status<300||304===e.status,o){if("function"==typeof t.S){let o,r;try{o=JSON.parse(e.responseText),r=e.getAllResponseHeaders()}catch(o){const n={error:""===e.responseText?qt.oa:qt.ha,response:e.responseText};t.S(n,r)}o&&t.S(o,r)}"function"==typeof t.Rl&&t.Rl(!0)}else r()},e.onerror=()=>{r()},e.ontimeout=()=>{r()},o=JSON.stringify(t.data),e.open("POST",t.url,!0),e.setRequestHeader("Content-type","application/json"),e.setRequestHeader("X-Requested-With","XMLHttpRequest");const n=t.headers||[];for(const t of n)e.setRequestHeader(t[0],t[1]);e.send(o)}}catch(t){r.D.error(`Network request error: ${t.message}`)}}};export const readResponseHeaders=t=>{let e={};const o=t.toString().split("\r\n");if(!o)return e;let r,n;for(const t of o)t&&(r=t.slice(0,t.indexOf(":")).toLowerCase().trim(),n=t.slice(t.indexOf(":")+1).trim(),e[r]=n);return e};export default b;
@@ -1 +1 @@
1
- import Yt from"./base-device-parser.js";import{Browsers as ri,OperatingSystems as ot}from"./device-constants.js";export default class ni extends Yt{constructor(){super(),this.au=ni.du(navigator.userAgent||"")}tf(){return this.au[0]||"Unknown Browser"}ef(){return this.au[1]||"Unknown Version"}Zo(r){for(let e=0;e<r.length;e++){let n=r[e].string,i=ni.rf(n,r[e]);if(i)return i===ot.Bg&&navigator.maxTouchPoints>1&&(i=ot.ln),Promise.resolve(i)}return Promise.resolve(navigator.platform)}static du(r){let e,n=r.match(/(samsungbrowser|tizen|roku|konqueror|icab|crios|opera|ucbrowser|chrome|safari|firefox|camino|msie|trident(?=\/))\/?\s*(\.?\d+(\.\d+)*)/i)||[];if(/trident/i.test(n[1]))return e=/\brv[ :]+(\.?\d+(\.\d+)*)/g.exec(r)||[],[ri.vg,e[1]||""];if(-1!==r.indexOf("(Web0S; Linux/SmartTV)"))return["LG Smart TV",null];if(-1!==r.indexOf("CrKey"))return["Chromecast",null];if(-1!==r.indexOf("BRAVIA")||-1!==r.indexOf("SonyCEBrowser")||-1!==r.indexOf("SonyDTV"))return["Sony Smart TV",null];if(-1!==r.indexOf("PhilipsTV"))return["Philips Smart TV",null];if(r.match(/\b(Roku)\b/))return["Roku",null];if(r.match(/\bAFTM\b/))return["Amazon Fire Stick",null];if(n[1]===ri.rE&&(e=r.match(/\b(OPR|Edge|EdgA|Edg|UCBrowser)\/(\.?\d+(\.\d+)*)/),null!=e))return e=e.slice(1),e[0]=e[0].replace("OPR",ri.EE),e[0]=e[0].replace("EdgA",ri.eE),"Edg"===e[0]&&(e[0]=ri.eE),[e[0],e[1]];if(n[1]===ri.yg&&(e=r.match(/\b(EdgiOS)\/(\.?\d+(\.\d+)*)/),null!=e))return e=e.slice(1),e[0]=e[0].replace("EdgiOS",ri.eE),[e[0],e[1]];if(n=n[2]?[n[1],n[2]]:[null,null],n[0]===ri.yg&&null!=(e=r.match(/version\/(\.?\d+(\.\d+)*)/i))&&n.splice(1,1,e[1]),null!=(e=r.match(/\b(UCBrowser)\/(\.?\d+(\.\d+)*)/))&&n.splice(1,1,e[2]),n[0]===ri.EE&&null!=(e=r.match(/mini\/(\.?\d+(\.\d+)*)/i)))return["Opera Mini",e[1]||""];if(n[0]){const r=n[0].toLowerCase();"msie"===r&&(n[0]=ri.vg),"crios"===r&&(n[0]=ri.rE),"tizen"===r&&(n[0]="Samsung Smart TV",n[1]=null),"samsungbrowser"===r&&(n[0]="Samsung Browser")}return n}}
1
+ import Zt from"./base-device-parser.js";import{Browsers as ri,OperatingSystems as ot}from"./device-constants.js";export default class ni extends Zt{constructor(){super(),this.du=ni.gu(navigator.userAgent||"")}tf(){return this.du[0]||"Unknown Browser"}ef(){return this.du[1]||"Unknown Version"}Ko(r){for(let e=0;e<r.length;e++){let n=r[e].string,i=ni.rf(n,r[e]);if(i)return i===ot.kg&&navigator.maxTouchPoints>1&&(i=ot.ln),Promise.resolve(i)}return Promise.resolve(navigator.platform)}static gu(r){let e,n=r.match(/(samsungbrowser|tizen|roku|konqueror|icab|crios|opera|ucbrowser|chrome|safari|firefox|camino|msie|trident(?=\/))\/?\s*(\.?\d+(\.\d+)*)/i)||[];if(/trident/i.test(n[1]))return e=/\brv[ :]+(\.?\d+(\.\d+)*)/g.exec(r)||[],[ri.yg,e[1]||""];if(-1!==r.indexOf("(Web0S; Linux/SmartTV)"))return["LG Smart TV",null];if(-1!==r.indexOf("CrKey"))return["Chromecast",null];if(-1!==r.indexOf("BRAVIA")||-1!==r.indexOf("SonyCEBrowser")||-1!==r.indexOf("SonyDTV"))return["Sony Smart TV",null];if(-1!==r.indexOf("PhilipsTV"))return["Philips Smart TV",null];if(r.match(/\b(Roku)\b/))return["Roku",null];if(r.match(/\bAFTM\b/))return["Amazon Fire Stick",null];if(n[1]===ri.rE&&(e=r.match(/\b(OPR|Edge|EdgA|Edg|UCBrowser)\/(\.?\d+(\.\d+)*)/),null!=e))return e=e.slice(1),e[0]=e[0].replace("OPR",ri.EE),e[0]=e[0].replace("EdgA",ri.eE),"Edg"===e[0]&&(e[0]=ri.eE),[e[0],e[1]];if(n[1]===ri.Bg&&(e=r.match(/\b(EdgiOS)\/(\.?\d+(\.\d+)*)/),null!=e))return e=e.slice(1),e[0]=e[0].replace("EdgiOS",ri.eE),[e[0],e[1]];if(n=n[2]?[n[1],n[2]]:[null,null],n[0]===ri.Bg&&null!=(e=r.match(/version\/(\.?\d+(\.\d+)*)/i))&&n.splice(1,1,e[1]),null!=(e=r.match(/\b(UCBrowser)\/(\.?\d+(\.\d+)*)/))&&n.splice(1,1,e[2]),n[0]===ri.EE&&null!=(e=r.match(/mini\/(\.?\d+(\.\d+)*)/i)))return["Opera Mini",e[1]||""];if(n[0]){const r=n[0].toLowerCase();"msie"===r&&(n[0]=ri.yg),"crios"===r&&(n[0]=ri.rE),"tizen"===r&&(n[0]="Samsung Smart TV",n[1]=null),"samsungbrowser"===r&&(n[0]="Samsung Browser")}return n}}
@@ -1 +1 @@
1
- import{isArray as p,isDate as yt,isObject as Jt,keys as rr}from"./code-utils.js";import{getByteLength as U}from"./string-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{toValidBackendTimeString as Nt}from"./date-utils.js";import{BRAZE_ACTIONS as _}from"./braze-actions.js";export const CUSTOM_DATA_REGEX=/^[^\x00-\x1F\x22]+$/;export const EMAIL_ADDRESS_REGEX=new RegExp(/^.+@.+\..+$/);export const CUSTOM_PROPERTIES_MAX_SIZE_BYTES=51200;export const CUSTOM_PROPERTIES_MAX_SIZE_STRING="50KB";export const BRAZE_ACTION_URI_REGEX=/^brazeActions:\/\/v\d+\//;export function _validatePropertyType(e){const t=typeof e;return null==e||"number"===t||"boolean"===t||yt(e)||"string"===t}export function _validateNestedProperties(e,t){if(p(e)&&p(t)){for(let r=0;r<e.length&&r<t.length;r++)if(yt(e[r])&&(t[r]=Nt(e[r])),!_validateNestedProperties(e[r],t[r]))return!1}else{if(!Jt(e))return _validatePropertyType(e);for(const r of rr(e))if(yt(e[r])&&(t[r]=Nt(e[r])),!_validateNestedProperties(e[r],t[r]))return!1}return!0}export function _validateEventPropertyValue(e,t,n,o){let i;return i=Jt(e)||p(e)?_validateNestedProperties(e,t):_validatePropertyType(e),i||r.D.error(`Cannot ${n} because ${o} "${e}" is invalid.`),i}export function validateStandardString(e,t,n,o){const i="string"==typeof e||null===e&&o;return i||r.D.error(`Cannot ${t} because ${n} "${e}" is invalid.`),i}export function validateCustomString(e,t,n){const o=null!=e&&"string"==typeof e&&(""===e||e.match(CUSTOM_DATA_REGEX));return o||r.D.error(`Cannot ${t} because ${n} "${e}" is invalid.`),o}export function validateCustomProperties(e,t,n,o,i){if(null==e&&(e={}),"object"!=typeof e||p(e))return r.D.error(`${t} requires that ${n} be an object. Ignoring ${i}.`),[!1,null];const a=JSON.stringify(e);if(U(a)>51200)return r.D.error(`Could not ${o} because ${n} was greater than the max size of 50KB.`),[!1,null];let s;try{s=JSON.parse(a)}catch(e){return r.D.error(`Could not ${o} because ${n} did not contain valid JSON.`),[!1,null]}for(let t in e){if(!validateCustomString(t,o,`the ${i} property name`))return[!1,null];const r=e[t];if(null==r){delete e[t],delete s[t];continue}yt(r)&&(s[t]=Nt(r));if(!_validateEventPropertyValue(r,s[t],o,`the ${i} property "${t}"`))return[!1,null]}return[!0,s]}export function isValidEmail(e){return"string"==typeof e&&null!=e.toLowerCase().match(EMAIL_ADDRESS_REGEX)}export function isValidBrazeActionJson(e){if(!(_.properties.type in e))return!1;switch(e[_.properties.type]){case _.types.ue:if(_.properties.me in e)return!0;break;case _.types.logCustomEvent:case _.types.setEmailNotificationSubscriptionType:case _.types.setPushNotificationSubscriptionType:case _.types.setCustomUserAttribute:case _.types.addToSubscriptionGroup:case _.types.removeFromSubscriptionGroup:case _.types.addToCustomAttributeArray:case _.types.removeFromCustomAttributeArray:case _.types.de:case _.types.pe:if(_.properties.fe in e)return!0;break;case _.types.requestPushPermission:return!0;default:return!1}return!1}export function isValidBrazeActionType(e){let t=!1;return Object.keys(_.types).forEach((r=>{_.types[r]!==e.toString()||(t=!0)})),t}
1
+ import{isArray as p,isDate as yt,isObject as jt,keys as rr}from"./code-utils.js";import{getByteLength as U}from"./string-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{toValidBackendTimeString as Nt}from"./date-utils.js";import{BRAZE_ACTIONS as _}from"./braze-actions.js";export const CUSTOM_DATA_REGEX=/^[^\x00-\x1F\x22]+$/;export const EMAIL_ADDRESS_REGEX=new RegExp(/^.+@.+\..+$/);export const CUSTOM_PROPERTIES_MAX_SIZE_BYTES=51200;export const CUSTOM_PROPERTIES_MAX_SIZE_STRING="50KB";export const BRAZE_ACTION_URI_REGEX=/^brazeActions:\/\/v\d+\//;export function _validatePropertyType(e){const t=typeof e;return null==e||"number"===t||"boolean"===t||yt(e)||"string"===t}export function _validateNestedProperties(e,t){if(p(e)&&p(t)){for(let r=0;r<e.length&&r<t.length;r++)if(yt(e[r])&&(t[r]=Nt(e[r])),!_validateNestedProperties(e[r],t[r]))return!1}else{if(!jt(e))return _validatePropertyType(e);for(const r of rr(e))if(yt(e[r])&&(t[r]=Nt(e[r])),!_validateNestedProperties(e[r],t[r]))return!1}return!0}export function _validateEventPropertyValue(e,t,n,o){let i;return i=jt(e)||p(e)?_validateNestedProperties(e,t):_validatePropertyType(e),i||r.D.error(`Cannot ${n} because ${o} "${e}" is invalid.`),i}export function validateStandardString(e,t,n,o){const i="string"==typeof e||null===e&&o;return i||r.D.error(`Cannot ${t} because ${n} "${e}" is invalid.`),i}export function validateCustomString(e,t,n){const o=null!=e&&"string"==typeof e&&(""===e||e.match(CUSTOM_DATA_REGEX));return o||r.D.error(`Cannot ${t} because ${n} "${e}" is invalid.`),o}export function validateCustomProperties(e,t,n,o,i){if(null==e&&(e={}),"object"!=typeof e||p(e))return r.D.error(`${t} requires that ${n} be an object. Ignoring ${i}.`),[!1,null];const a=JSON.stringify(e);if(U(a)>51200)return r.D.error(`Could not ${o} because ${n} was greater than the max size of 50KB.`),[!1,null];let s;try{s=JSON.parse(a)}catch(e){return r.D.error(`Could not ${o} because ${n} did not contain valid JSON.`),[!1,null]}for(let t in e){if(!validateCustomString(t,o,`the ${i} property name`))return[!1,null];const r=e[t];if(null==r){delete e[t],delete s[t];continue}yt(r)&&(s[t]=Nt(r));if(!_validateEventPropertyValue(r,s[t],o,`the ${i} property "${t}"`))return[!1,null]}return[!0,s]}export function isValidEmail(e){return"string"==typeof e&&null!=e.toLowerCase().match(EMAIL_ADDRESS_REGEX)}export function isValidBrazeActionJson(e){if(!(_.properties.type in e))return!1;switch(e[_.properties.type]){case _.types.ue:if(_.properties.me in e)return!0;break;case _.types.logCustomEvent:case _.types.setEmailNotificationSubscriptionType:case _.types.setPushNotificationSubscriptionType:case _.types.setCustomUserAttribute:case _.types.addToSubscriptionGroup:case _.types.removeFromSubscriptionGroup:case _.types.addToCustomAttributeArray:case _.types.removeFromCustomAttributeArray:case _.types.de:case _.types.pe:if(_.properties.fe in e)return!0;break;case _.types.requestPushPermission:return!0;default:return!1}return!1}export function isValidBrazeActionType(e){let t=!1;return Object.keys(_.types).forEach((r=>{_.types[r]!==e.toString()||(t=!0)})),t}
@@ -1 +1 @@
1
- export const ORIENTATION={PORTRAIT:0,LANDSCAPE:1};export function _isPhone(){return screen.width<=600}export function _getOrientation(){if("orientation"in window)return 90===Math.abs(window.orientation)||270===window.orientation?ORIENTATION.LANDSCAPE:ORIENTATION.PORTRAIT;if("screen"in window){let n=window.screen.orientation||screen.mozOrientation||screen.msOrientation;return null!=n&&"object"==typeof n&&(n=n.type),"landscape-primary"===n||"landscape-secondary"===n?ORIENTATION.LANDSCAPE:ORIENTATION.PORTRAIT}return ORIENTATION.PORTRAIT}export function _openUri(n,e,r){e||null!=r&&r.metaKey?window.open(n):window.location=n}export function _getCurrentUrl(){return window.location.href}export const WindowUtils={openUri:_openUri,so:_isPhone,io:_getOrientation,Tn:_getCurrentUrl};
1
+ export const ORIENTATION={PORTRAIT:0,LANDSCAPE:1};export function _isPhone(){return screen.width<=600}export function _getOrientation(){if("orientation"in window)return 90===Math.abs(window.orientation)||270===window.orientation?ORIENTATION.LANDSCAPE:ORIENTATION.PORTRAIT;if("screen"in window){let n=window.screen.orientation||screen.mozOrientation||screen.msOrientation;return null!=n&&"object"==typeof n&&(n=n.type),"landscape-primary"===n||"landscape-secondary"===n?ORIENTATION.LANDSCAPE:ORIENTATION.PORTRAIT}return ORIENTATION.PORTRAIT}export function _openUri(n,e,r){e||null!=r&&r.metaKey?window.open(n):window.location=n}export function _getCurrentUrl(){return window.location.href}export const WindowUtils={openUri:_openUri,so:_isPhone,io:_getOrientation,hn:_getCurrentUrl};