@aifeatures/react 0.28.0 → 0.28.1
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.
- package/dist/consent-reader.cjs +1 -1
- package/dist/consent-reader.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/consent-reader.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var d=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var R=(n,t)=>{for(var r in t)d(n,r,{get:t[r],enumerable:!0})},
|
|
1
|
+
"use strict";var d=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var R=(n,t)=>{for(var r in t)d(n,r,{get:t[r],enumerable:!0})},h=(n,t,r,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of w(t))!S.call(n,o)&&o!==r&&d(n,o,{get:()=>t[o],enumerable:!(e=y(t,o))||e.enumerable});return n};var b=n=>h(d({},"__esModule",{value:!0}),n);var X={};R(X,{CONSENT_COOKIE_PREFIX:()=>a,readSharedConsentRecord:()=>G,readSharedConsentStatus:()=>m,subscribeToConsentRecord:()=>H});module.exports=b(X);var k=["functional","analytics","advertising"];var a="af-consent-",x=/^[A-Za-z0-9_-]+$/;function $(n){if(!x.test(n))throw new TypeError(`aifeatures consent: invalid config id ${JSON.stringify(n)} \u2014 expected only A-Z a-z 0-9 _ - (the id returned by setup_cookie_consent).`);return`${a}${n}`}var O=1,E=365*24*60*60,_=E*1e3,N=1440*60*1e3,u="aifeatures:consent-storage";var T=["landingsite.dev","agncy.dev","agcy.dev","getlandingsite.com"];var c;function l(n){return n.endsWith(".")?n.slice(0,-1):n}function A(){return c!==void 0?c:typeof window<"u"?l(window.location.hostname):""}function I(n){let t=l(n);return T.some(r=>t===r||t.endsWith(`.${r}`))}function L(n){if(typeof document>"u")return[];let t;try{t=document.cookie}catch{return[]}let r=[];for(let e of t.split(";")){let o=e.indexOf("=");o!==-1&&e.slice(0,o).trim()===n&&r.push(e.slice(o+1).trim())}return r}function P(){if(typeof window>"u")return[];let n=[];for(let t of["localStorage","sessionStorage"])try{let r=window[t];r&&n.push(r)}catch{}return n}function D(n){let t=[];for(let r of P())try{let e=r.getItem(n);e!==null&&t.push(e)}catch{}return t}function s(n){return typeof n=="boolean"}function F(n,t){let r;try{r=JSON.parse(decodeURIComponent(n))}catch{return{kind:"invalid",reason:"malformed"}}if(typeof r!="object"||r===null)return{kind:"invalid",reason:"malformed"};let e=r;if(e.v!==O)return typeof e.v=="number"&&Number.isInteger(e.v)&&e.v>0?{kind:"absent-in-place",reason:"taxonomy-version"}:{kind:"invalid",reason:"malformed"};if(typeof e.ts!="number"||!Number.isFinite(e.ts))return{kind:"invalid",reason:"malformed"};if(e.ts-Date.now()>N)return{kind:"invalid",reason:"malformed"};if(typeof e.cid!="string"||e.cid.length===0)return{kind:"invalid",reason:"malformed"};if(typeof e.grants!="object"||e.grants===null)return{kind:"invalid",reason:"malformed"};let o=e.grants;return!s(o.functional)||!s(o.analytics)||!s(o.advertising)?{kind:"invalid",reason:"malformed"}:e.cid!==t?{kind:"absent-in-place",reason:"malformed"}:e.revision!==void 0&&(typeof e.revision!="string"||e.revision.trim()==="")||e.gpcOverride!==void 0&&!s(e.gpcOverride)?{kind:"invalid",reason:"malformed"}:Date.now()-e.ts>_?{kind:"invalid",reason:"expired"}:{kind:"valid",record:{v:e.v,ts:e.ts,cid:e.cid,grants:{functional:o.functional,analytics:o.analytics,advertising:o.advertising},...e.revision!==void 0?{revision:e.revision}:{},...e.gpcOverride===!0?{gpcOverride:!0}:{}}}}function U(n){let t=$(n);if(I(A()))return{values:D(t),mirror:!1};let r=L(t);if(r.length>0)return{values:r,mirror:!1};let e=M(t);return{values:e===null?[]:[e],mirror:!0}}function M(n){if(typeof window>"u")return null;try{return window.localStorage.getItem(n)}catch{return null}}function V(n){let{values:t,mirror:r}=U(n);if(t.length===0)return{status:{status:"no-record"},clearable:!1};let e=null,o=!0;for(let v of t){let i=F(v,n);if(i.kind==="valid")return r&&k.some(C=>i.record.grants[C])?{status:{status:"unreadable",reason:"unverified-mirror"},clearable:!1}:{status:{status:"answered",record:i.record},clearable:!1};i.reason!=="expired"&&(o=!1),(e===null||e==="expired")&&(e=i.reason)}return{status:{status:"unreadable",reason:e??"malformed"},clearable:o}}function f(n){return V(n).status}function g(n){if(typeof window>"u")return()=>{};let t=e=>{(e.key===null||e.key.startsWith(a))&&n()},r=()=>n();return window.addEventListener("storage",t),window.addEventListener(u,r),()=>{window.removeEventListener("storage",t),window.removeEventListener(u,r)}}function m({acceptCids:n}){let t=null;for(let r of n){let e;try{e=f(r)}catch{p||(p=!0,console.error(`aifeatures consent: invalid config id ${JSON.stringify(r)} in acceptCids \u2014 nothing can be honored for it. Check the value against the config id setup_cookie_consent returned.`)),e={status:"unreadable",reason:"malformed"}}if(e.status==="answered")return typeof navigator<"u"&&!!navigator.globalPrivacyControl&&e.record.gpcOverride!==!0&&e.record.grants.advertising?{status:"answered",record:{...e.record,grants:{...e.record.grants,advertising:!1}}}:e;e.status==="unreadable"&&(t??(t=e))}return t??{status:"no-record"}}var p=!1;function G(n){let t=m(n);return t.status==="answered"?t.record:null}var H=g;0&&(module.exports={CONSENT_COOKIE_PREFIX,readSharedConsentRecord,readSharedConsentStatus,subscribeToConsentRecord});
|
package/dist/consent-reader.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var v=["functional","analytics","advertising"];var a="af-consent-",C=/^[A-Za-z0-9_-]+$/;function y(n){if(!C.test(n))throw new TypeError(`aifeatures consent: invalid config id ${JSON.stringify(n)} \u2014 expected only A-Z a-z 0-9 _ - (the id returned by setup_cookie_consent).`);return`${a}${n}`}var w=1,S=365*24*60*60,R=S*1e3,
|
|
1
|
+
var v=["functional","analytics","advertising"];var a="af-consent-",C=/^[A-Za-z0-9_-]+$/;function y(n){if(!C.test(n))throw new TypeError(`aifeatures consent: invalid config id ${JSON.stringify(n)} \u2014 expected only A-Z a-z 0-9 _ - (the id returned by setup_cookie_consent).`);return`${a}${n}`}var w=1,S=365*24*60*60,R=S*1e3,h=1440*60*1e3,d="aifeatures:consent-storage";var b=["landingsite.dev","agncy.dev","agcy.dev","getlandingsite.com"];var u;function c(n){return n.endsWith(".")?n.slice(0,-1):n}function k(){return u!==void 0?u:typeof window<"u"?c(window.location.hostname):""}function x(n){let t=c(n);return b.some(r=>t===r||t.endsWith(`.${r}`))}function $(n){if(typeof document>"u")return[];let t;try{t=document.cookie}catch{return[]}let r=[];for(let e of t.split(";")){let o=e.indexOf("=");o!==-1&&e.slice(0,o).trim()===n&&r.push(e.slice(o+1).trim())}return r}function O(){if(typeof window>"u")return[];let n=[];for(let t of["localStorage","sessionStorage"])try{let r=window[t];r&&n.push(r)}catch{}return n}function E(n){let t=[];for(let r of O())try{let e=r.getItem(n);e!==null&&t.push(e)}catch{}return t}function s(n){return typeof n=="boolean"}function _(n,t){let r;try{r=JSON.parse(decodeURIComponent(n))}catch{return{kind:"invalid",reason:"malformed"}}if(typeof r!="object"||r===null)return{kind:"invalid",reason:"malformed"};let e=r;if(e.v!==w)return typeof e.v=="number"&&Number.isInteger(e.v)&&e.v>0?{kind:"absent-in-place",reason:"taxonomy-version"}:{kind:"invalid",reason:"malformed"};if(typeof e.ts!="number"||!Number.isFinite(e.ts))return{kind:"invalid",reason:"malformed"};if(e.ts-Date.now()>h)return{kind:"invalid",reason:"malformed"};if(typeof e.cid!="string"||e.cid.length===0)return{kind:"invalid",reason:"malformed"};if(typeof e.grants!="object"||e.grants===null)return{kind:"invalid",reason:"malformed"};let o=e.grants;return!s(o.functional)||!s(o.analytics)||!s(o.advertising)?{kind:"invalid",reason:"malformed"}:e.cid!==t?{kind:"absent-in-place",reason:"malformed"}:e.revision!==void 0&&(typeof e.revision!="string"||e.revision.trim()==="")||e.gpcOverride!==void 0&&!s(e.gpcOverride)?{kind:"invalid",reason:"malformed"}:Date.now()-e.ts>R?{kind:"invalid",reason:"expired"}:{kind:"valid",record:{v:e.v,ts:e.ts,cid:e.cid,grants:{functional:o.functional,analytics:o.analytics,advertising:o.advertising},...e.revision!==void 0?{revision:e.revision}:{},...e.gpcOverride===!0?{gpcOverride:!0}:{}}}}function N(n){let t=y(n);if(x(k()))return{values:E(t),mirror:!1};let r=$(t);if(r.length>0)return{values:r,mirror:!1};let e=T(t);return{values:e===null?[]:[e],mirror:!0}}function T(n){if(typeof window>"u")return null;try{return window.localStorage.getItem(n)}catch{return null}}function A(n){let{values:t,mirror:r}=N(n);if(t.length===0)return{status:{status:"no-record"},clearable:!1};let e=null,o=!0;for(let p of t){let i=_(p,n);if(i.kind==="valid")return r&&v.some(m=>i.record.grants[m])?{status:{status:"unreadable",reason:"unverified-mirror"},clearable:!1}:{status:{status:"answered",record:i.record},clearable:!1};i.reason!=="expired"&&(o=!1),(e===null||e==="expired")&&(e=i.reason)}return{status:{status:"unreadable",reason:e??"malformed"},clearable:o}}function l(n){return A(n).status}function f(n){if(typeof window>"u")return()=>{};let t=e=>{(e.key===null||e.key.startsWith(a))&&n()},r=()=>n();return window.addEventListener("storage",t),window.addEventListener(d,r),()=>{window.removeEventListener("storage",t),window.removeEventListener(d,r)}}function I({acceptCids:n}){let t=null;for(let r of n){let e;try{e=l(r)}catch{g||(g=!0,console.error(`aifeatures consent: invalid config id ${JSON.stringify(r)} in acceptCids \u2014 nothing can be honored for it. Check the value against the config id setup_cookie_consent returned.`)),e={status:"unreadable",reason:"malformed"}}if(e.status==="answered")return typeof navigator<"u"&&!!navigator.globalPrivacyControl&&e.record.gpcOverride!==!0&&e.record.grants.advertising?{status:"answered",record:{...e.record,grants:{...e.record.grants,advertising:!1}}}:e;e.status==="unreadable"&&(t??(t=e))}return t??{status:"no-record"}}var g=!1;function D(n){let t=I(n);return t.status==="answered"?t.record:null}var F=f;export{a as CONSENT_COOKIE_PREFIX,D as readSharedConsentRecord,I as readSharedConsentStatus,F as subscribeToConsentRecord};
|