@wix/web5-core 1.63.17 → 1.63.18

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.
@@ -37,7 +37,7 @@ const DEFAULT_BUFFER_LIMIT = 50;
37
37
  const LOG_PREFIX = '[w5-consent]';
38
38
  const log = (...args) => {
39
39
  try {
40
- console.log(LOG_PREFIX, ...args);
40
+ console.debug(LOG_PREFIX, ...args);
41
41
  } catch {
42
42
  // A console that throws must never break a send.
43
43
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_types","require","DEFAULT_BUFFER_LIMIT","LOG_PREFIX","log","args","console","describe","s","analytics","performance","marketing","snapshot","UNKNOWN_CONSENT","engaged","provider","unsubscribeProvider","buffer","bufferLimit","droppedFromOverflow","listeners","Set","view","Object","freeze","consent","rebuildView","notify","listener","mayTransmit","purpose","state","exports","settleBuffer","length","stillHeld","releasing","held","push","dropped","label","send","transmit","unlockOnUserAction","isUserEngaged","mayPersistIdentity","getConsentSnapshot","getGateView","subscribeToConsent","add","delete","applySnapshot","next","installConsentProvider","initial","read","name","subscribe","getInstalledProviderName","_provider","setConsentBufferLimit","limit","Math","max","getConsentGateStats","resetConsentGateForTests","clear"],"sources":["../../../src/privacy/consentGate.ts"],"sourcesContent":["/**\n * The consent gate — DL #218.\n *\n * Every BI, telemetry and analytics emitter in web5 goes through `transmit()`\n * instead of calling its transport directly. The gate exists because the\n * consent signal resolves *after* the events that need it: Shopify's consent\n * API is not on the page by default and has to be requested, and the fedops\n * app-load pair fires inside that window. A boolean checked at each call site\n * can only ever drop an event that is already in flight; the gate can hold it.\n *\n * Two independent unlocks, and they do not compose as a plain \"either/or\":\n *\n * | consent | engaged | result |\n * |-----------|---------|---------------------------------|\n * | granted | either | transmit |\n * | unknown | no | hold in the buffer |\n * | unknown | yes | transmit, and flush what's held |\n * | denied | yes | still nothing |\n *\n * Denied outranks engaged. A visitor who refused analytics in the banner does\n * not re-enable tracking by typing a question.\n */\n\nimport {\n UNKNOWN_CONSENT,\n type ConsentProvider,\n type ConsentPurpose,\n type ConsentSnapshot,\n type GatedPurpose,\n} from './types';\n\n/** Held events are dropped past this many — a runaway emitter must not become a leak. */\nconst DEFAULT_BUFFER_LIMIT = 50;\n\n/**\n * One prefix for the whole consent trail, so `[w5-consent]` in the console\n * filter shows the full story: which CMP was found, what it answered, and for\n * every event whether it was sent, held, dropped or replayed.\n */\nconst LOG_PREFIX = '[w5-consent]';\n\nconst log = (...args: unknown[]): void => {\n try {\n console.log(LOG_PREFIX, ...args);\n } catch {\n // A console that throws must never break a send.\n }\n};\n\nconst describe = (s: ConsentSnapshot): string =>\n `analytics=${s.analytics} performance=${s.performance} marketing=${s.marketing}`;\n\ninterface HeldEvent {\n purpose: GatedPurpose;\n send: () => void;\n label: string;\n}\n\nexport interface GateView {\n consent: ConsentSnapshot;\n engaged: boolean;\n}\n\ntype Listener = () => void;\n\nlet snapshot: ConsentSnapshot = UNKNOWN_CONSENT;\nlet engaged = false;\nlet provider: ConsentProvider | null = null;\nlet unsubscribeProvider: (() => void) | null = null;\nlet buffer: HeldEvent[] = [];\nlet bufferLimit = DEFAULT_BUFFER_LIMIT;\nlet droppedFromOverflow = 0;\n\nconst listeners = new Set<Listener>();\n\n/**\n * Cached so `getGateView` is referentially stable between changes —\n * `useSyncExternalStore` re-renders forever if the snapshot is a fresh object\n * on every read.\n */\nlet view: GateView = Object.freeze({ consent: UNKNOWN_CONSENT, engaged: false });\n\nconst rebuildView = (): void => {\n view = Object.freeze({ consent: snapshot, engaged });\n};\n\nconst notify = (): void => {\n for (const listener of listeners) {\n try {\n listener();\n } catch {\n // A subscriber that throws must not stop the others, or stop a flush.\n }\n }\n};\n\n/**\n * Whether an event for `purpose` may go on the wire right now.\n *\n * `necessary` is always allowed. For everything else: explicit consent wins in\n * both directions, and engagement resolves only the `unknown` case.\n */\nexport const mayTransmit = (purpose: ConsentPurpose): boolean => {\n if (purpose === 'necessary') {\n return true;\n }\n const state = snapshot[purpose];\n if (state === 'denied') {\n return false;\n }\n if (state === 'granted') {\n return true;\n }\n return engaged;\n};\n\n/**\n * Release everything the gate is holding that is now allowed, and drop\n * everything that is now refused. Anything still `unknown` stays held.\n *\n * Order is preserved among released events, but a flush necessarily emits them\n * later than they were raised — a held app-load event reaches the wire after\n * the prompt that unlocked it. Anything reading these as a timeline has to\n * know that.\n */\nconst settleBuffer = (): void => {\n if (buffer.length === 0) {\n return;\n }\n const stillHeld: HeldEvent[] = [];\n const releasing: HeldEvent[] = [];\n\n for (const held of buffer) {\n if (mayTransmit(held.purpose)) {\n releasing.push(held);\n } else if (snapshot[held.purpose] === 'denied') {\n // dropped on the floor, deliberately and permanently\n } else {\n stillHeld.push(held);\n }\n }\n\n const dropped = buffer.length - stillHeld.length - releasing.length;\n buffer = stillHeld;\n\n if (releasing.length || dropped) {\n log(\n `settle — releasing ${releasing.length}` +\n (dropped ? `, dropping ${dropped} (refused)` : '') +\n (stillHeld.length ? `, still holding ${stillHeld.length}` : ''),\n );\n }\n\n for (const held of releasing) {\n try {\n log(` ↳ REPLAY ${held.label} (${held.purpose})`);\n held.send();\n } catch {\n // A failed send must not strand the rest of the flush.\n }\n }\n};\n\n/**\n * The single entry point for anything that would put a request on the wire.\n *\n * Allowed → sent now. Refused → dropped. Not yet known → held until an unlock\n * settles it, or discarded with the page.\n */\nexport const transmit = (\n purpose: ConsentPurpose,\n send: () => void,\n label = 'event',\n): void => {\n if (mayTransmit(purpose)) {\n log(`SEND ${label} (${purpose}) — allowed`);\n send();\n return;\n }\n if (purpose !== 'necessary' && snapshot[purpose] === 'denied') {\n log(`DROP ${label} (${purpose}) — visitor refused`);\n return;\n }\n if (buffer.length >= bufferLimit) {\n droppedFromOverflow += 1;\n log(\n `DROP ${label} (${purpose}) — buffer full at ${bufferLimit}, ${droppedFromOverflow} lost`,\n );\n return;\n }\n buffer.push({ purpose: purpose as GatedPurpose, send, label });\n log(`HOLD ${label} (${purpose}) — no answer yet, ${buffer.length} held`);\n};\n\n/**\n * The visitor did something deliberate — submitted a prompt — so the session\n * may be measured even though no CMP has answered.\n *\n * This is the unlock that keeps web5 measurable at all: on a Shopify store\n * with no privacy configuration the consent API never loads, consent stays\n * `unknown` forever, and without this every store would report nothing.\n *\n * It unlocks **transmission only**. Persistent identity stays gated on real\n * consent (see `mayPersistIdentity`) — typing a question is a reason to\n * measure the session, not a reason to persist an identifier across visits.\n * It also cannot override a `denied`.\n */\nexport const unlockOnUserAction = (): void => {\n if (engaged) {\n return;\n }\n engaged = true;\n log(\n `UNLOCK — visitor submitted a prompt; ${buffer.length} held event(s) to settle`,\n );\n rebuildView();\n settleBuffer();\n notify();\n};\n\n/** Whether the visitor has taken the deliberate action that unlocks the session. */\nexport const isUserEngaged = (): boolean => engaged;\n\n/**\n * Persistent, cross-visit storage of a visitor identifier requires real\n * consent — engagement is deliberately not enough.\n */\nexport const mayPersistIdentity = (): boolean => snapshot.analytics === 'granted';\n\nexport const getConsentSnapshot = (): ConsentSnapshot => snapshot;\n\n/** Referentially stable between changes, for `useSyncExternalStore`. */\nexport const getGateView = (): GateView => view;\n\nexport const subscribeToConsent = (listener: Listener): (() => void) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n};\n\nconst applySnapshot = (next: ConsentSnapshot): void => {\n if (\n next.analytics === snapshot.analytics &&\n next.marketing === snapshot.marketing &&\n next.performance === snapshot.performance\n ) {\n return;\n }\n log(`ANSWER — ${describe(snapshot)} → ${describe(next)}`);\n snapshot = Object.freeze({ ...next });\n rebuildView();\n settleBuffer();\n notify();\n};\n\n/**\n * Install the host's provider. Reads its current state immediately, *then*\n * subscribes — DL #217: a listener registered into an already-rendered page is\n * bound to an event that may have fired long before the bundle executed, so\n * subscribing alone would leave the gate permanently at `unknown`.\n */\nexport const installConsentProvider = (next: ConsentProvider): void => {\n unsubscribeProvider?.();\n provider = next;\n const initial = next.read();\n log(`provider installed: ${next.name} — reads ${describe(initial)}`);\n applySnapshot(initial);\n unsubscribeProvider = next.subscribe(applySnapshot);\n};\n\nexport const getInstalledProviderName = (): string | null => provider?.name ?? null;\n\nexport const setConsentBufferLimit = (limit: number): void => {\n bufferLimit = Math.max(0, limit);\n};\n\n/** Diagnostics only — how much the gate is holding, and what it had to drop. */\nexport const getConsentGateStats = (): {\n held: number;\n droppedFromOverflow: number;\n} => ({ held: buffer.length, droppedFromOverflow });\n\nexport const resetConsentGateForTests = (): void => {\n unsubscribeProvider?.();\n unsubscribeProvider = null;\n provider = null;\n snapshot = UNKNOWN_CONSENT;\n engaged = false;\n buffer = [];\n bufferLimit = DEFAULT_BUFFER_LIMIT;\n droppedFromOverflow = 0;\n listeners.clear();\n rebuildView();\n};\n"],"mappings":";;;;AAuBA,IAAAA,MAAA,GAAAC,OAAA;AAvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA;AACA,MAAMC,oBAAoB,GAAG,EAAE;;AAE/B;AACA;AACA;AACA;AACA;AACA,MAAMC,UAAU,GAAG,cAAc;AAEjC,MAAMC,GAAG,GAAGA,CAAC,GAAGC,IAAe,KAAW;EACxC,IAAI;IACFC,OAAO,CAACF,GAAG,CAACD,UAAU,EAAE,GAAGE,IAAI,CAAC;EAClC,CAAC,CAAC,MAAM;IACN;EAAA;AAEJ,CAAC;AAED,MAAME,QAAQ,GAAIC,CAAkB,IAClC,aAAaA,CAAC,CAACC,SAAS,gBAAgBD,CAAC,CAACE,WAAW,cAAcF,CAAC,CAACG,SAAS,EAAE;AAelF,IAAIC,QAAyB,GAAGC,sBAAe;AAC/C,IAAIC,OAAO,GAAG,KAAK;AACnB,IAAIC,QAAgC,GAAG,IAAI;AAC3C,IAAIC,mBAAwC,GAAG,IAAI;AACnD,IAAIC,MAAmB,GAAG,EAAE;AAC5B,IAAIC,WAAW,GAAGhB,oBAAoB;AACtC,IAAIiB,mBAAmB,GAAG,CAAC;AAE3B,MAAMC,SAAS,GAAG,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AAA,GAAAA,wBAAA;AAE7E,MAAME,qBAAqB,GAAIC,KAAa,IAAW;EAC5D3C,WAAW,GAAG4C,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEF,KAAK,CAAC;AAClC,CAAC;;AAED;AAAA7B,OAAA,CAAA4B,qBAAA,GAAAA,qBAAA;AACO,MAAMI,mBAAmB,GAAGA,CAAA,MAG7B;EAAE3B,IAAI,EAAEpB,MAAM,CAACiB,MAAM;EAAEf;AAAoB,CAAC,CAAC;AAACa,OAAA,CAAAgC,mBAAA,GAAAA,mBAAA;AAE7C,MAAMC,wBAAwB,GAAGA,CAAA,KAAY;EAClDjD,mBAAmB,YAAnBA,mBAAmB,CAAG,CAAC;EACvBA,mBAAmB,GAAG,IAAI;EAC1BD,QAAQ,GAAG,IAAI;EACfH,QAAQ,GAAGC,sBAAe;EAC1BC,OAAO,GAAG,KAAK;EACfG,MAAM,GAAG,EAAE;EACXC,WAAW,GAAGhB,oBAAoB;EAClCiB,mBAAmB,GAAG,CAAC;EACvBC,SAAS,CAAC8C,KAAK,CAAC,CAAC;EACjBxC,WAAW,CAAC,CAAC;AACf,CAAC;AAACM,OAAA,CAAAiC,wBAAA,GAAAA,wBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_types","require","DEFAULT_BUFFER_LIMIT","LOG_PREFIX","log","args","console","debug","describe","s","analytics","performance","marketing","snapshot","UNKNOWN_CONSENT","engaged","provider","unsubscribeProvider","buffer","bufferLimit","droppedFromOverflow","listeners","Set","view","Object","freeze","consent","rebuildView","notify","listener","mayTransmit","purpose","state","exports","settleBuffer","length","stillHeld","releasing","held","push","dropped","label","send","transmit","unlockOnUserAction","isUserEngaged","mayPersistIdentity","getConsentSnapshot","getGateView","subscribeToConsent","add","delete","applySnapshot","next","installConsentProvider","initial","read","name","subscribe","getInstalledProviderName","_provider","setConsentBufferLimit","limit","Math","max","getConsentGateStats","resetConsentGateForTests","clear"],"sources":["../../../src/privacy/consentGate.ts"],"sourcesContent":["/**\n * The consent gate — DL #218.\n *\n * Every BI, telemetry and analytics emitter in web5 goes through `transmit()`\n * instead of calling its transport directly. The gate exists because the\n * consent signal resolves *after* the events that need it: Shopify's consent\n * API is not on the page by default and has to be requested, and the fedops\n * app-load pair fires inside that window. A boolean checked at each call site\n * can only ever drop an event that is already in flight; the gate can hold it.\n *\n * Two independent unlocks, and they do not compose as a plain \"either/or\":\n *\n * | consent | engaged | result |\n * |-----------|---------|---------------------------------|\n * | granted | either | transmit |\n * | unknown | no | hold in the buffer |\n * | unknown | yes | transmit, and flush what's held |\n * | denied | yes | still nothing |\n *\n * Denied outranks engaged. A visitor who refused analytics in the banner does\n * not re-enable tracking by typing a question.\n */\n\nimport {\n UNKNOWN_CONSENT,\n type ConsentProvider,\n type ConsentPurpose,\n type ConsentSnapshot,\n type GatedPurpose,\n} from './types';\n\n/** Held events are dropped past this many — a runaway emitter must not become a leak. */\nconst DEFAULT_BUFFER_LIMIT = 50;\n\n/**\n * One prefix for the whole consent trail, so `[w5-consent]` in the console\n * filter shows the full story: which CMP was found, what it answered, and for\n * every event whether it was sent, held, dropped or replayed.\n */\nconst LOG_PREFIX = '[w5-consent]';\n\nconst log = (...args: unknown[]): void => {\n try {\n console.debug(LOG_PREFIX, ...args);\n } catch {\n // A console that throws must never break a send.\n }\n};\n\nconst describe = (s: ConsentSnapshot): string =>\n `analytics=${s.analytics} performance=${s.performance} marketing=${s.marketing}`;\n\ninterface HeldEvent {\n purpose: GatedPurpose;\n send: () => void;\n label: string;\n}\n\nexport interface GateView {\n consent: ConsentSnapshot;\n engaged: boolean;\n}\n\ntype Listener = () => void;\n\nlet snapshot: ConsentSnapshot = UNKNOWN_CONSENT;\nlet engaged = false;\nlet provider: ConsentProvider | null = null;\nlet unsubscribeProvider: (() => void) | null = null;\nlet buffer: HeldEvent[] = [];\nlet bufferLimit = DEFAULT_BUFFER_LIMIT;\nlet droppedFromOverflow = 0;\n\nconst listeners = new Set<Listener>();\n\n/**\n * Cached so `getGateView` is referentially stable between changes —\n * `useSyncExternalStore` re-renders forever if the snapshot is a fresh object\n * on every read.\n */\nlet view: GateView = Object.freeze({\n consent: UNKNOWN_CONSENT,\n engaged: false,\n});\n\nconst rebuildView = (): void => {\n view = Object.freeze({ consent: snapshot, engaged });\n};\n\nconst notify = (): void => {\n for (const listener of listeners) {\n try {\n listener();\n } catch {\n // A subscriber that throws must not stop the others, or stop a flush.\n }\n }\n};\n\n/**\n * Whether an event for `purpose` may go on the wire right now.\n *\n * `necessary` is always allowed. For everything else: explicit consent wins in\n * both directions, and engagement resolves only the `unknown` case.\n */\nexport const mayTransmit = (purpose: ConsentPurpose): boolean => {\n if (purpose === 'necessary') {\n return true;\n }\n const state = snapshot[purpose];\n if (state === 'denied') {\n return false;\n }\n if (state === 'granted') {\n return true;\n }\n return engaged;\n};\n\n/**\n * Release everything the gate is holding that is now allowed, and drop\n * everything that is now refused. Anything still `unknown` stays held.\n *\n * Order is preserved among released events, but a flush necessarily emits them\n * later than they were raised — a held app-load event reaches the wire after\n * the prompt that unlocked it. Anything reading these as a timeline has to\n * know that.\n */\nconst settleBuffer = (): void => {\n if (buffer.length === 0) {\n return;\n }\n const stillHeld: HeldEvent[] = [];\n const releasing: HeldEvent[] = [];\n\n for (const held of buffer) {\n if (mayTransmit(held.purpose)) {\n releasing.push(held);\n } else if (snapshot[held.purpose] === 'denied') {\n // dropped on the floor, deliberately and permanently\n } else {\n stillHeld.push(held);\n }\n }\n\n const dropped = buffer.length - stillHeld.length - releasing.length;\n buffer = stillHeld;\n\n if (releasing.length || dropped) {\n log(\n `settle — releasing ${releasing.length}` +\n (dropped ? `, dropping ${dropped} (refused)` : '') +\n (stillHeld.length ? `, still holding ${stillHeld.length}` : ''),\n );\n }\n\n for (const held of releasing) {\n try {\n log(` ↳ REPLAY ${held.label} (${held.purpose})`);\n held.send();\n } catch {\n // A failed send must not strand the rest of the flush.\n }\n }\n};\n\n/**\n * The single entry point for anything that would put a request on the wire.\n *\n * Allowed → sent now. Refused → dropped. Not yet known → held until an unlock\n * settles it, or discarded with the page.\n */\nexport const transmit = (\n purpose: ConsentPurpose,\n send: () => void,\n label = 'event',\n): void => {\n if (mayTransmit(purpose)) {\n log(`SEND ${label} (${purpose}) — allowed`);\n send();\n return;\n }\n if (purpose !== 'necessary' && snapshot[purpose] === 'denied') {\n log(`DROP ${label} (${purpose}) — visitor refused`);\n return;\n }\n if (buffer.length >= bufferLimit) {\n droppedFromOverflow += 1;\n log(\n `DROP ${label} (${purpose}) — buffer full at ${bufferLimit}, ${droppedFromOverflow} lost`,\n );\n return;\n }\n buffer.push({ purpose: purpose as GatedPurpose, send, label });\n log(`HOLD ${label} (${purpose}) — no answer yet, ${buffer.length} held`);\n};\n\n/**\n * The visitor did something deliberate — submitted a prompt — so the session\n * may be measured even though no CMP has answered.\n *\n * This is the unlock that keeps web5 measurable at all: on a Shopify store\n * with no privacy configuration the consent API never loads, consent stays\n * `unknown` forever, and without this every store would report nothing.\n *\n * It unlocks **transmission only**. Persistent identity stays gated on real\n * consent (see `mayPersistIdentity`) — typing a question is a reason to\n * measure the session, not a reason to persist an identifier across visits.\n * It also cannot override a `denied`.\n */\nexport const unlockOnUserAction = (): void => {\n if (engaged) {\n return;\n }\n engaged = true;\n log(\n `UNLOCK — visitor submitted a prompt; ${buffer.length} held event(s) to settle`,\n );\n rebuildView();\n settleBuffer();\n notify();\n};\n\n/** Whether the visitor has taken the deliberate action that unlocks the session. */\nexport const isUserEngaged = (): boolean => engaged;\n\n/**\n * Persistent, cross-visit storage of a visitor identifier requires real\n * consent — engagement is deliberately not enough.\n */\nexport const mayPersistIdentity = (): boolean =>\n snapshot.analytics === 'granted';\n\nexport const getConsentSnapshot = (): ConsentSnapshot => snapshot;\n\n/** Referentially stable between changes, for `useSyncExternalStore`. */\nexport const getGateView = (): GateView => view;\n\nexport const subscribeToConsent = (listener: Listener): (() => void) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n};\n\nconst applySnapshot = (next: ConsentSnapshot): void => {\n if (\n next.analytics === snapshot.analytics &&\n next.marketing === snapshot.marketing &&\n next.performance === snapshot.performance\n ) {\n return;\n }\n log(`ANSWER — ${describe(snapshot)} → ${describe(next)}`);\n snapshot = Object.freeze({ ...next });\n rebuildView();\n settleBuffer();\n notify();\n};\n\n/**\n * Install the host's provider. Reads its current state immediately, *then*\n * subscribes — DL #217: a listener registered into an already-rendered page is\n * bound to an event that may have fired long before the bundle executed, so\n * subscribing alone would leave the gate permanently at `unknown`.\n */\nexport const installConsentProvider = (next: ConsentProvider): void => {\n unsubscribeProvider?.();\n provider = next;\n const initial = next.read();\n log(`provider installed: ${next.name} — reads ${describe(initial)}`);\n applySnapshot(initial);\n unsubscribeProvider = next.subscribe(applySnapshot);\n};\n\nexport const getInstalledProviderName = (): string | null =>\n provider?.name ?? null;\n\nexport const setConsentBufferLimit = (limit: number): void => {\n bufferLimit = Math.max(0, limit);\n};\n\n/** Diagnostics only — how much the gate is holding, and what it had to drop. */\nexport const getConsentGateStats = (): {\n held: number;\n droppedFromOverflow: number;\n} => ({ held: buffer.length, droppedFromOverflow });\n\nexport const resetConsentGateForTests = (): void => {\n unsubscribeProvider?.();\n unsubscribeProvider = null;\n provider = null;\n snapshot = UNKNOWN_CONSENT;\n engaged = false;\n buffer = [];\n bufferLimit = DEFAULT_BUFFER_LIMIT;\n droppedFromOverflow = 0;\n listeners.clear();\n rebuildView();\n};\n"],"mappings":";;;;AAuBA,IAAAA,MAAA,GAAAC,OAAA;AAvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA;AACA,MAAMC,oBAAoB,GAAG,EAAE;;AAE/B;AACA;AACA;AACA;AACA;AACA,MAAMC,UAAU,GAAG,cAAc;AAEjC,MAAMC,GAAG,GAAGA,CAAC,GAAGC,IAAe,KAAW;EACxC,IAAI;IACFC,OAAO,CAACC,KAAK,CAACJ,UAAU,EAAE,GAAGE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Gate = () => {
60
60
  (0, _consentGate.installConsentProvider)(provider);
61
61
  } else {
62
62
  try {
63
- console.log('[w5-consent] no CMP detected (no host-supplied consent, no Shopify customerPrivacy, no OneTrust) — everything held until the visitor submits a prompt');
63
+ console.debug('[w5-consent] no CMP detected (no host-supplied consent, no Shopify customerPrivacy, no OneTrust) — everything held until the visitor submits a prompt');
64
64
  } catch {
65
65
  /* never break on a console */
66
66
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_consentGate","require","_consentOverride","_hostSuppliedProvider","_shopifyProvider","_oneTrustProvider","detectConsentProvider","forced","getConsentOverride","console","warn","name","read","overrideSnapshot","subscribe","hasHostSuppliedConsent","createHostSuppliedConsentProvider","isShopifyHost","createShopifyConsentProvider","isOneTrustHost","createOneTrustConsentProvider","exports","initConsentGate","provider","installConsentProvider","log"],"sources":["../../../src/privacy/detectProvider.ts"],"sourcesContent":["/**\n * Provider selection — DL #218.\n *\n * Detected at boot, not configured per client, because a merchant can install\n * a CMP long after we deploy and the bundle is not the source of truth for a\n * store's behaviour (DL #214).\n *\n * Order is host-supplied → Shopify → OneTrust → none. A host that publishes an\n * answer outranks anything we could sniff, because it knows things we cannot:\n * a server-side consent record, a CMP behind its own abstraction, or a legal\n * position we have no business guessing at.\n *\n * When nothing is detected the gate keeps its default — everything `unknown`,\n * held until the visitor acts. That is the case on every Shopify store with no\n * privacy configuration, which today is most of them.\n */\n\nimport { installConsentProvider } from './consentGate';\nimport { getConsentOverride, overrideSnapshot } from './consentOverride';\nimport type { ConsentProvider } from './types';\nimport {\n createHostSuppliedConsentProvider,\n hasHostSuppliedConsent,\n} from './providers/hostSuppliedProvider';\nimport {\n createShopifyConsentProvider,\n isShopifyHost,\n} from './providers/shopifyProvider';\nimport {\n createOneTrustConsentProvider,\n isOneTrustHost,\n} from './providers/oneTrustProvider';\n\nexport const detectConsentProvider = (): ConsentProvider | null => {\n // Debug override outranks every real signal, so the states a region or an\n // unconfigured store makes unreachable can still be walked by hand.\n const forced = getConsentOverride();\n if (forced) {\n console.warn(\n `[w5-consent] OVERRIDE ACTIVE — consent forced to \"${forced}\". This is a debug switch, not a real answer.`,\n );\n return {\n name: `override:${forced}`,\n read: () => overrideSnapshot(forced),\n subscribe: () => () => {},\n };\n }\n if (hasHostSuppliedConsent()) {\n return createHostSuppliedConsentProvider();\n }\n if (isShopifyHost()) {\n return createShopifyConsentProvider();\n }\n if (isOneTrustHost()) {\n return createOneTrustConsentProvider();\n }\n return null;\n};\n\n/**\n * Install the detected provider, if any. Call once at boot, before the first\n * emitter runs — anything raised earlier is held rather than lost, but the\n * sooner this runs the less the buffer has to carry.\n */\nexport const initConsentGate = (): ConsentProvider | null => {\n const provider = detectConsentProvider();\n if (provider) {\n installConsentProvider(provider);\n } else {\n try {\n console.log(\n '[w5-consent] no CMP detected (no host-supplied consent, no Shopify customerPrivacy, no OneTrust) — everything held until the visitor submits a prompt',\n );\n } catch {\n /* never break on a console */\n }\n }\n return provider;\n};\n"],"mappings":";;;;AAiBA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAEA,IAAAE,qBAAA,GAAAF,OAAA;AAIA,IAAAG,gBAAA,GAAAH,OAAA;AAIA,IAAAI,iBAAA,GAAAJ,OAAA;AA5BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBO,MAAMK,qBAAqB,GAAGA,CAAA,KAA8B;EACjE;EACA;EACA,MAAMC,MAAM,GAAG,IAAAC,mCAAkB,EAAC,CAAC;EACnC,IAAID,MAAM,EAAE;IACVE,OAAO,CAACC,IAAI,CACV,qDAAqDH,MAAM,+CAC7D,CAAC;IACD,OAAO;MACLI,IAAI,EAAE,YAAYJ,MAAM,EAAE;MAC1BK,IAAI,EAAEA,CAAA,KAAM,IAAAC,iCAAgB,EAACN,MAAM,CAAC;MACpCO,SAAS,EAAEA,CAAA,KAAM,MAAM,CAAC;IAC1B,CAAC;EACH;EACA,IAAI,IAAAC,4CAAsB,EAAC,CAAC,EAAE;IAC5B,OAAO,IAAAC,uDAAiC,EAAC,CAAC;EAC5C;EACA,IAAI,IAAAC,8BAAa,EAAC,CAAC,EAAE;IACnB,OAAO,IAAAC,6CAA4B,EAAC,CAAC;EACvC;EACA,IAAI,IAAAC,gCAAc,EAAC,CAAC,EAAE;IACpB,OAAO,IAAAC,+CAA6B,EAAC,CAAC;EACxC;EACA,OAAO,IAAI;AACb,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJAC,OAAA,CAAAf,qBAAA,GAAAA,qBAAA;AAKO,MAAMgB,eAAe,GAAGA,CAAA,KAA8B;EAC3D,MAAMC,QAAQ,GAAGjB,qBAAqB,CAAC,CAAC;EACxC,IAAIiB,QAAQ,EAAE;IACZ,IAAAC,mCAAsB,EAACD,QAAQ,CAAC;EAClC,CAAC,MAAM;IACL,IAAI;MACFd,OAAO,CAACgB,GAAG,CACT,uJACF,CAAC;IACH,CAAC,CAAC,MAAM;MACN;IAAA;EAEJ;EACA,OAAOF,QAAQ;AACjB,CAAC;AAACF,OAAA,CAAAC,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"names":["_consentGate","require","_consentOverride","_hostSuppliedProvider","_shopifyProvider","_oneTrustProvider","detectConsentProvider","forced","getConsentOverride","console","warn","name","read","overrideSnapshot","subscribe","hasHostSuppliedConsent","createHostSuppliedConsentProvider","isShopifyHost","createShopifyConsentProvider","isOneTrustHost","createOneTrustConsentProvider","exports","initConsentGate","provider","installConsentProvider","debug"],"sources":["../../../src/privacy/detectProvider.ts"],"sourcesContent":["/**\n * Provider selection — DL #218.\n *\n * Detected at boot, not configured per client, because a merchant can install\n * a CMP long after we deploy and the bundle is not the source of truth for a\n * store's behaviour (DL #214).\n *\n * Order is host-supplied → Shopify → OneTrust → none. A host that publishes an\n * answer outranks anything we could sniff, because it knows things we cannot:\n * a server-side consent record, a CMP behind its own abstraction, or a legal\n * position we have no business guessing at.\n *\n * When nothing is detected the gate keeps its default — everything `unknown`,\n * held until the visitor acts. That is the case on every Shopify store with no\n * privacy configuration, which today is most of them.\n */\n\nimport { installConsentProvider } from './consentGate';\nimport { getConsentOverride, overrideSnapshot } from './consentOverride';\nimport type { ConsentProvider } from './types';\nimport {\n createHostSuppliedConsentProvider,\n hasHostSuppliedConsent,\n} from './providers/hostSuppliedProvider';\nimport {\n createShopifyConsentProvider,\n isShopifyHost,\n} from './providers/shopifyProvider';\nimport {\n createOneTrustConsentProvider,\n isOneTrustHost,\n} from './providers/oneTrustProvider';\n\nexport const detectConsentProvider = (): ConsentProvider | null => {\n // Debug override outranks every real signal, so the states a region or an\n // unconfigured store makes unreachable can still be walked by hand.\n const forced = getConsentOverride();\n if (forced) {\n console.warn(\n `[w5-consent] OVERRIDE ACTIVE — consent forced to \"${forced}\". This is a debug switch, not a real answer.`,\n );\n return {\n name: `override:${forced}`,\n read: () => overrideSnapshot(forced),\n subscribe: () => () => {},\n };\n }\n if (hasHostSuppliedConsent()) {\n return createHostSuppliedConsentProvider();\n }\n if (isShopifyHost()) {\n return createShopifyConsentProvider();\n }\n if (isOneTrustHost()) {\n return createOneTrustConsentProvider();\n }\n return null;\n};\n\n/**\n * Install the detected provider, if any. Call once at boot, before the first\n * emitter runs — anything raised earlier is held rather than lost, but the\n * sooner this runs the less the buffer has to carry.\n */\nexport const initConsentGate = (): ConsentProvider | null => {\n const provider = detectConsentProvider();\n if (provider) {\n installConsentProvider(provider);\n } else {\n try {\n console.debug(\n '[w5-consent] no CMP detected (no host-supplied consent, no Shopify customerPrivacy, no OneTrust) — everything held until the visitor submits a prompt',\n );\n } catch {\n /* never break on a console */\n }\n }\n return provider;\n};\n"],"mappings":";;;;AAiBA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAEA,IAAAE,qBAAA,GAAAF,OAAA;AAIA,IAAAG,gBAAA,GAAAH,OAAA;AAIA,IAAAI,iBAAA,GAAAJ,OAAA;AA5BA;AACA;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
21
21
  /** What a host may publish. Anything missing stays `unknown`. */
22
22
 
23
23
  const coerce = value => {
24
- if (value === true) return 'granted';
25
- if (value === false) return 'denied';
24
+ if (value === true) {
25
+ return 'granted';
26
+ }
27
+ if (value === false) {
28
+ return 'denied';
29
+ }
26
30
  if (value === 'granted' || value === 'denied' || value === 'unknown') {
27
31
  return value;
28
32
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_types","require","HOST_CONSENT_GLOBAL","exports","coerce","value","normalize","input","UNKNOWN_CONSENT","analytics","marketing","performance","undefined","readGlobal","window","raw","hasHostSuppliedConsent","subscribers","Set","published","publishHostConsent","subscriber","createHostSuppliedConsentProvider","name","read","subscribe","onChange","add","delete","__resetHostConsentForTests","clear"],"sources":["../../../../src/privacy/providers/hostSuppliedProvider.ts"],"sourcesContent":["/**\n * Host-supplied provider — DL #218.\n *\n * The escape hatch for every CMP we cannot detect: a host page that already\n * knows its visitor's answer publishes it, and the gate believes it. This is\n * how Circana, feature.com and any merchant on Cookiebot/Osano/Klaviyo reach\n * the gate without web5 learning each vendor's API.\n *\n * Two ways in, because hosts differ in when they know:\n * - `window.__web5_consent__` set before the bundle loads, read at install\n * - `publishHostConsent()` called at any time afterwards\n */\n\nimport {\n UNKNOWN_CONSENT,\n type ConsentProvider,\n type ConsentSnapshot,\n type ConsentState,\n} from '../types';\n\nexport const HOST_CONSENT_GLOBAL = '__web5_consent__';\n\n/** What a host may publish. Anything missing stays `unknown`. */\nexport interface HostConsentInput {\n analytics?: ConsentState | boolean;\n marketing?: ConsentState | boolean;\n performance?: ConsentState | boolean;\n}\n\nconst coerce = (value: ConsentState | boolean | undefined): ConsentState => {\n if (value === true) return 'granted';\n if (value === false) return 'denied';\n if (value === 'granted' || value === 'denied' || value === 'unknown') {\n return value;\n }\n return 'unknown';\n};\n\nconst normalize = (input: HostConsentInput | null | undefined): ConsentSnapshot => {\n if (!input || typeof input !== 'object') {\n return UNKNOWN_CONSENT;\n }\n const analytics = coerce(input.analytics);\n return {\n analytics,\n marketing: coerce(input.marketing),\n // A host that speaks only about analytics is taken to mean the same for\n // load telemetry, which is the same wire and the same recipient.\n performance:\n input.performance === undefined ? analytics : coerce(input.performance),\n };\n};\n\nconst readGlobal = (): ConsentSnapshot => {\n if (typeof window === 'undefined') {\n return UNKNOWN_CONSENT;\n }\n const raw = (window as unknown as Record<string, unknown>)[HOST_CONSENT_GLOBAL];\n return normalize(raw as HostConsentInput | undefined);\n};\n\nexport const hasHostSuppliedConsent = (): boolean => {\n if (typeof window === 'undefined') {\n return false;\n }\n const raw = (window as unknown as Record<string, unknown>)[HOST_CONSENT_GLOBAL];\n return !!raw && typeof raw === 'object';\n};\n\nconst subscribers = new Set<(snapshot: ConsentSnapshot) => void>();\nlet published: ConsentSnapshot | null = null;\n\n/**\n * Called by the host — directly, or by the loader when it is handed consent in\n * its boot options — whenever the visitor's answer is known or changes.\n */\nexport const publishHostConsent = (input: HostConsentInput): void => {\n published = normalize(input);\n for (const subscriber of subscribers) {\n subscriber(published);\n }\n};\n\nexport const createHostSuppliedConsentProvider = (): ConsentProvider => ({\n name: 'host-supplied',\n\n read: () => published ?? readGlobal(),\n\n subscribe(onChange) {\n subscribers.add(onChange);\n return () => {\n subscribers.delete(onChange);\n };\n },\n});\n\nexport const __resetHostConsentForTests = (): void => {\n published = null;\n subscribers.clear();\n};\n"],"mappings":";;;;AAaA,IAAAA,MAAA,GAAAC,OAAA;AAbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASO,MAAMC,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG,kBAAkB;;AAErD;;AAOA,MAAME,MAAM,GAAIC,KAAyC,IAAmB;EAC1E,IAAIA,KAAK,KAAK,IAAI,EAAE,OAAO,SAAS;EACpC,IAAIA,KAAK,KAAK,KAAK,EAAE,OAAO,QAAQ;EACpC,IAAIA,KAAK,KAAK,SAAS,IAAIA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,SAAS,EA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F,CAAC;AAAChB,OAAA,CAAAiB,kBAAA,GAAAA,kBAAA;AAEK,MAAME,iCAAiC,GAAGA,CAAA,MAAwB;EACvEC,IAAI,EAAE,eAAe;EAErBC,IAAI,EAAEA,CAAA,KAAML,SAAS,IAAIN,UAAU,CAAC,CAAC;EAErCY,SAASA,CAACC,QAAQ,EAAE;IAClBT,WAAW,CAACU,GAAG,CAACD,QAAQ,CAAC;IACzB,OAAO,MAAM;MACXT,WAAW,CAACW,MAAM,CAACF,QAAQ,CAAC;IAC9B,CAAC;EACH;AACF,CAAC,CAAC;AAACvB,OAAA,CAAAmB,iCAAA,GAAAA,iCAAA;AAEI,MAAMO,0BAA0B,GAAGA,CAAA,KAAY;EACpDV,SAAS,GAAG,IAAI;EAChBF,WAAW,CAACa,KAAK,CAAC,CAAC;AACrB,CAAC;AAAC3B,OAAA,CAAA0B,0BAAA,GAAAA,0BAAA","ignoreList":[]}
1
+ {"version":3,"names":["_types","require","HOST_CONSENT_GLOBAL","exports","coerce","value","normalize","input","UNKNOWN_CONSENT","analytics","marketing","performance","undefined","readGlobal","window","raw","hasHostSuppliedConsent","subscribers","Set","published","publishHostConsent","subscriber","createHostSuppliedConsentProvider","name","read","subscribe","onChange","add","delete","__resetHostConsentForTests","clear"],"sources":["../../../../src/privacy/providers/hostSuppliedProvider.ts"],"sourcesContent":["/**\n * Host-supplied provider — DL #218.\n *\n * The escape hatch for every CMP we cannot detect: a host page that already\n * knows its visitor's answer publishes it, and the gate believes it. This is\n * how Circana, feature.com and any merchant on Cookiebot/Osano/Klaviyo reach\n * the gate without web5 learning each vendor's API.\n *\n * Two ways in, because hosts differ in when they know:\n * - `window.__web5_consent__` set before the bundle loads, read at install\n * - `publishHostConsent()` called at any time afterwards\n */\n\nimport {\n UNKNOWN_CONSENT,\n type ConsentProvider,\n type ConsentSnapshot,\n type ConsentState,\n} from '../types';\n\nexport const HOST_CONSENT_GLOBAL = '__web5_consent__';\n\n/** What a host may publish. Anything missing stays `unknown`. */\nexport interface HostConsentInput {\n analytics?: ConsentState | boolean;\n marketing?: ConsentState | boolean;\n performance?: ConsentState | boolean;\n}\n\nconst coerce = (value: ConsentState | boolean | undefined): ConsentState => {\n if (value === true) {\n return 'granted';\n }\n if (value === false) {\n return 'denied';\n }\n if (value === 'granted' || value === 'denied' || value === 'unknown') {\n return value;\n }\n return 'unknown';\n};\n\nconst normalize = (\n input: HostConsentInput | null | undefined,\n): ConsentSnapshot => {\n if (!input || typeof input !== 'object') {\n return UNKNOWN_CONSENT;\n }\n const analytics = coerce(input.analytics);\n return {\n analytics,\n marketing: coerce(input.marketing),\n // A host that speaks only about analytics is taken to mean the same for\n // load telemetry, which is the same wire and the same recipient.\n performance:\n input.performance === undefined ? analytics : coerce(input.performance),\n };\n};\n\nconst readGlobal = (): ConsentSnapshot => {\n if (typeof window === 'undefined') {\n return UNKNOWN_CONSENT;\n }\n const raw = (window as unknown as Record<string, unknown>)[\n HOST_CONSENT_GLOBAL\n ];\n return normalize(raw as HostConsentInput | undefined);\n};\n\nexport const hasHostSuppliedConsent = (): boolean => {\n if (typeof window === 'undefined') {\n return false;\n }\n const raw = (window as unknown as Record<string, unknown>)[\n HOST_CONSENT_GLOBAL\n ];\n return !!raw && typeof raw === 'object';\n};\n\nconst subscribers = new Set<(snapshot: ConsentSnapshot) => void>();\nlet published: ConsentSnapshot | null = null;\n\n/**\n * Called by the host — directly, or by the loader when it is handed consent in\n * its boot options — whenever the visitor's answer is known or changes.\n */\nexport const publishHostConsent = (input: HostConsentInput): void => {\n published = normalize(input);\n for (const subscriber of subscribers) {\n subscriber(published);\n }\n};\n\nexport const createHostSuppliedConsentProvider = (): ConsentProvider => ({\n name: 'host-supplied',\n\n read: () => published ?? readGlobal(),\n\n subscribe(onChange) {\n subscribers.add(onChange);\n return () => {\n subscribers.delete(onChange);\n };\n },\n});\n\nexport const __resetHostConsentForTests = (): void => {\n published = null;\n subscribers.clear();\n};\n"],"mappings":";;;;AAaA,IAAAA,MAAA,GAAAC,O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a,GAAG,IAAI,OAAOA,GAAG,KAAK,QAAQ;AACzC,CAAC;AAACZ,OAAA,CAAAa,sBAAA,GAAAA,sBAAA;AAEF,MAAMC,WAAW,GAAG,IAAIC,GAAG,CAAsC,CAAC;AAClE,IAAIC,SAAiC,GAAG,IAAI;;AAE5C;AACA;AACA;AACA;AACO,MAAMC,kBAAkB,GAAIb,KAAuB,IAAW;EACnEY,SAAS,GAAGb,SAAS,CAACC,KAAK,CAAC;EAC5B,KAAK,MAAMc,UAAU,IAAIJ,WAAW,EAAE;IACpCI,UAAU,CAACF,SAAS,CAAC;EACvB;AACF,CAAC;AAAChB,OAAA,CAAAiB,kBAAA,GAAAA,kBAAA;AAEK,MAAME,iCAAiC,GAAGA,CAAA,MAAwB;EACvEC,IAAI,EAAE,eAAe;EAErBC,IAAI,EAAEA,CAAA,KAAML,SAAS,IAAIN,UAAU,CAAC,CAAC;EAErCY,SAASA,CAACC,QAAQ,EAAE;IAClBT,WAAW,CAACU,GAAG,CAACD,QAAQ,CAAC;IACzB,OAAO,MAAM;MACXT,WAAW,CAACW,MAAM,CAACF,QAAQ,CAAC;IAC9B,CAAC;EACH;AACF,CAAC,CAAC;AAACvB,OAAA,CAAAmB,iCAAA,GAAAA,iCAAA;AAEI,MAAMO,0BAA0B,GAAGA,CAAA,KAAY;EACpDV,SAAS,GAAG,IAAI;EAChBF,WAAW,CAACa,KAAK,CAAC,CAAC;AACrB,CAAC;AAAC3B,OAAA,CAAA0B,0BAAA,GAAAA,0BAAA","ignoreList":[]}
@@ -31,7 +31,7 @@ const readSnapshot = () => {
31
31
  const groups = readGroups();
32
32
  if (groups !== null) {
33
33
  try {
34
- console.log(`[w5-consent] onetrust: active groups "${groups}"`);
34
+ console.debug(`[w5-consent] onetrust: active groups "${groups}"`);
35
35
  } catch {
36
36
  /* never break on a console */
37
37
  }
@@ -1 +1 @@
1
- {"version":3,"names":["ANALYTICS_CATEGORY","MARKETING_CATEGORY","readGroups","window","groups","OnetrustActiveGroups","isOneTrustHost","exports","readSnapshot","console","log","analytics","marketing","performance","includes","createOneTrustConsentProvider","name","read","subscribe","onChange","publish","addEventListener","removeEventListener"],"sources":["../../../../src/privacy/providers/oneTrustProvider.ts"],"sourcesContent":["/**\n * OneTrust provider — DL #218.\n *\n * Lifted from the consent check that used to live inside\n * `utils/analyticsEvents.ts`, with one deliberate behaviour change: that\n * function returned `true` when OneTrust was absent (\"host is responsible for\n * loading OneTrust\"), which on a Shopify storefront meant unconditional\n * default-allow. Absence is no longer this provider's problem — it is only\n * selected when OneTrust is actually on the page, and absence is handled by\n * the gate's own default.\n */\n\nimport type { ConsentProvider, ConsentSnapshot } from '../types';\n\n/** OneTrust's default taxonomy: C0002 is the performance/analytics category. */\nconst ANALYTICS_CATEGORY = 'C0002';\n/** C0004 is targeting/advertising. */\nconst MARKETING_CATEGORY = 'C0004';\n\nconst readGroups = (): string | null => {\n if (typeof window === 'undefined') {\n return null;\n }\n const groups = (window as unknown as { OnetrustActiveGroups?: unknown })\n .OnetrustActiveGroups;\n return typeof groups === 'string' ? groups : null;\n};\n\nexport const isOneTrustHost = (): boolean => readGroups() !== null;\n\nconst readSnapshot = (): ConsentSnapshot => {\n const groups = readGroups();\n if (groups !== null) {\n try {\n console.log(`[w5-consent] onetrust: active groups \"${groups}\"`);\n } catch {\n /* never break on a console */\n }\n }\n if (groups === null) {\n return { analytics: 'unknown', marketing: 'unknown', performance: 'unknown' };\n }\n // OneTrust publishes the *active* groups, so a category that is absent from\n // a string OneTrust has written is a refusal, not silence.\n const analytics = groups.includes(ANALYTICS_CATEGORY) ? 'granted' : 'denied';\n const marketing = groups.includes(MARKETING_CATEGORY) ? 'granted' : 'denied';\n return { analytics, marketing, performance: analytics };\n};\n\nexport const createOneTrustConsentProvider = (): ConsentProvider => ({\n name: 'onetrust',\n\n read: readSnapshot,\n\n subscribe(onChange) {\n const publish = () => onChange(readSnapshot());\n if (typeof window === 'undefined') {\n return () => {};\n }\n // OneTrust fires this on every banner interaction.\n window.addEventListener('OneTrustGroupsUpdated', publish);\n return () => {\n window.removeEventListener('OneTrustGroupsUpdated', publish);\n };\n },\n});\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA,MAAMA,kBAAkB,GAAG,OAAO;AAClC;AACA,MAAMC,kBAAkB,GAAG,OAAO;AAElC,MAAMC,UAAU,GAAGA,CAAA,KAAqB;EACtC,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;IACjC,OAAO,IAAI;EACb;EACA,MAAMC,MAAM,GAAID,MAAM,CACnBE,oBAAoB;EACvB,OAAO,OAAOD,MAAM,KAAK,QAAQ,GAAGA,MAAM,GAAG,IAAI;AACnD,CAAC;AAEM,MAAME,cAAc,GAAGA,CAAA,KAAeJ,UAAU,CAAC,CAAC,KAAK,IAAI;AAACK,OAAA,CAAAD,cAAA,GAAAA,cAAA;AAEnE,MAAME,YAAY,GAAGA,CAAA,KAAuB;EAC1C,MAAMJ,MAAM,GAAGF,UAAU,CAAC,CAAC;EAC3B,IAAIE,MAAM,KAAK,IAAI,EAAE;IACnB,IAAI;MACFK,OAAO,CAACC,GAAG,CAAC,yCAAyCN,MAAM,GAAG,CAAC;IACjE,CAAC,CAAC,MAAM;MACN;IAAA;EAEJ;EACA,IAAIA,MAAM,KAAK,IAAI,EAAE;IACnB,OAAO;MAAEO,SAAS,EAAE,SAAS;MAAEC,SAAS,EAAE,SAAS;MAAEC,WAAW,EAAE;IAAU,CAAC;EAC/E;EACA;EACA;EACA,MAAMF,SAAS,GAAGP,MAAM,CAACU,QAAQ,CAACd,kBAAkB,CAAC,GAAG,SAAS,GAAG,QAAQ;EAC5E,MAAMY,SAAS,GAAGR,MAAM,CAACU,QAAQ,CAACb,kBAAkB,CAAC,GAAG,SAAS,GAAG,QAAQ;EAC5E,OAAO;IAAEU,SAAS;IAAEC,SAAS;IAAEC,WAAW,EAAEF;EAAU,CAAC;AACzD,CAAC;AAEM,MAAMI,6BAA6B,GAAGA,CAAA,MAAwB;EACnEC,IAAI,EAAE,UAAU;EAEhBC,IAAI,EAAET,YAAY;EAElBU,SAASA,CAACC,QAAQ,EAAE;IAClB,MAAMC,OAAO,GAAGA,CAAA,KAAMD,QAAQ,CAACX,YAAY,CAAC,CAAC,CAAC;IAC9C,IAAI,OAAOL,MAAM,KAAK,WAAW,EAAE;MACjC,OAAO,MAAM,CAAC,CAAC;IACjB;IACA;IACAA,MAAM,CAACkB,gBAAgB,CAAC,uBAAuB,EAAED,OAAO,CAAC;IACzD,OAAO,MAAM;MACXjB,MAAM,CAACmB,mBAAmB,CAAC,uBAAuB,EAAEF,OAAO,CAAC;IAC9D,CAAC;EACH;AACF,CAAC,CAAC;AAACb,OAAA,CAAAQ,6BAAA,GAAAA,6BAAA","ignoreList":[]}
1
+ {"version":3,"names":["ANALYTICS_CATEGORY","MARKETING_CATEGORY","readGroups","window","groups","OnetrustActiveGroups","isOneTrustHost","exports","readSnapshot","console","debug","analytics","marketing","performance","includes","createOneTrustConsentProvider","name","read","subscribe","onChange","publish","addEventListener","removeEventListener"],"sources":["../../../../src/privacy/providers/oneTrustProvider.ts"],"sourcesContent":["/**\n * OneTrust provider — DL #218.\n *\n * Lifted from the consent check that used to live inside\n * `utils/analyticsEvents.ts`, with one deliberate behaviour change: that\n * function returned `true` when OneTrust was absent (\"host is responsible for\n * loading OneTrust\"), which on a Shopify storefront meant unconditional\n * default-allow. Absence is no longer this provider's problem — it is only\n * selected when OneTrust is actually on the page, and absence is handled by\n * the gate's own default.\n */\n\nimport type { ConsentProvider, ConsentSnapshot } from '../types';\n\n/** OneTrust's default taxonomy: C0002 is the performance/analytics category. */\nconst ANALYTICS_CATEGORY = 'C0002';\n/** C0004 is targeting/advertising. */\nconst MARKETING_CATEGORY = 'C0004';\n\nconst readGroups = (): string | null => {\n if (typeof window === 'undefined') {\n return null;\n }\n const groups = (window as unknown as { OnetrustActiveGroups?: unknown })\n .OnetrustActiveGroups;\n return typeof groups === 'string' ? groups : null;\n};\n\nexport const isOneTrustHost = (): boolean => readGroups() !== null;\n\nconst readSnapshot = (): ConsentSnapshot => {\n const groups = readGroups();\n if (groups !== null) {\n try {\n console.debug(`[w5-consent] onetrust: active groups \"${groups}\"`);\n } catch {\n /* never break on a console */\n }\n }\n if (groups === null) {\n return {\n analytics: 'unknown',\n marketing: 'unknown',\n performance: 'unknown',\n };\n }\n // OneTrust publishes the *active* groups, so a category that is absent from\n // a string OneTrust has written is a refusal, not silence.\n const analytics = groups.includes(ANALYTICS_CATEGORY) ? 'granted' : 'denied';\n const marketing = groups.includes(MARKETING_CATEGORY) ? 'granted' : 'denied';\n return { analytics, marketing, performance: analytics };\n};\n\nexport const createOneTrustConsentProvider = (): ConsentProvider => ({\n name: 'onetrust',\n\n read: readSnapshot,\n\n subscribe(onChange) {\n const publish = () => onChange(readSnapshot());\n if (typeof window === 'undefined') {\n return () => {};\n }\n // OneTrust fires this on every banner interaction.\n window.addEventListener('OneTrustGroupsUpdated', publish);\n return () => {\n window.removeEventListener('OneTrustGroupsUpdated', publish);\n };\n },\n});\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA,MAAMA,kBAAkB,GAAG,OAAO;AAClC;AACA,MAAMC,kBAAkB,GAAG,OAAO;AAElC,MAAMC,UAAU,GAAGA,CAAA,KAAqB;EACtC,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;IACjC,OAAO,IAAI;EACb;EACA,MAAMC,MAAM,GAAID,MAAM,CACnBE,oBAAoB;EACvB,OAAO,OAAOD,MAAM,KAAK,QAAQ,GAAGA,MAAM,GAAG,IAAI;AACnD,CAAC;AAEM,MAAME,cAAc,GAAGA,CAAA,KAAeJ,UAAU,CAAC,CAAC,KAAK,IAAI;AAACK,OAAA,CAAAD,cAAA,GAAAA,cAAA;AAEnE,MAAME,YAAY,GAAGA,CAAA,KAAuB;EAC1C,MAAMJ,MAAM,GAAGF,UAAU,CAAC,CAAC;EAC3B,IAAIE,MAAM,KAAK,IAAI,EAAE;IACnB,IAAI;MACFK,OAAO,CAACC,KAAK,CAAC,yCAAyCN,MAAM,GAAG,CAAC;IACnE,CAAC,CAAC,MAAM;MACN;IAAA;EAEJ;EACA,IAAIA,MAAM,KAAK,IAAI,EAAE;IACnB,OAAO;MACLO,SAAS,EAAE,SAAS;MACpBC,SAAS,EAAE,SAAS;MACpBC,WAAW,EAAE;IACf,CAAC;EACH;EACA;EACA;EACA,MAAMF,SAAS,GAAGP,MAAM,CAACU,QAAQ,CAACd,kBAAkB,CAAC,GAAG,SAAS,GAAG,QAAQ;EAC5E,MAAMY,SAAS,GAAGR,MAAM,CAACU,QAAQ,CAACb,kBAAkB,CAAC,GAAG,SAAS,GAAG,QAAQ;EAC5E,OAAO;IAAEU,SAAS;IAAEC,SAAS;IAAEC,WAAW,EAAEF;EAAU,CAAC;AACzD,CAAC;AAEM,MAAMI,6BAA6B,GAAGA,CAAA,MAAwB;EACnEC,IAAI,EAAE,UAAU;EAEhBC,IAAI,EAAET,YAAY;EAElBU,SAASA,CAACC,QAAQ,EAAE;IAClB,MAAMC,OAAO,GAAGA,CAAA,KAAMD,QAAQ,CAACX,YAAY,CAAC,CAAC,CAAC;IAC9C,IAAI,OAAOL,MAAM,KAAK,WAAW,EAAE;MACjC,OAAO,MAAM,CAAC,CAAC;IACjB;IACA;IACAA,MAAM,CAACkB,gBAAgB,CAAC,uBAAuB,EAAED,OAAO,CAAC;IACzD,OAAO,MAAM;MACXjB,MAAM,CAACmB,mBAAmB,CAAC,uBAAuB,EAAEF,OAAO,CAAC;IAC9D,CAAC;EACH;AACF,CAAC,CAAC;AAACb,OAAA,CAAAQ,6BAAA,GAAAA,6BAAA","ignoreList":[]}
@@ -32,7 +32,7 @@ const CONSENT_FEATURE = {
32
32
  };
33
33
  const log = (...args) => {
34
34
  try {
35
- console.log('[w5-consent] shopify:', ...args);
35
+ console.debug('[w5-consent] shopify:', ...args);
36
36
  } catch {
37
37
  /* never break on a console */
38
38
  }
@@ -46,8 +46,12 @@ const getShopify = () => {
46
46
  const isShopifyHost = () => getShopify() !== null;
47
47
  exports.isShopifyHost = isShopifyHost;
48
48
  const toState = value => {
49
- if (value === 'yes') return 'granted';
50
- if (value === 'no') return 'denied';
49
+ if (value === 'yes') {
50
+ return 'granted';
51
+ }
52
+ if (value === 'no') {
53
+ return 'denied';
54
+ }
51
55
  return null;
52
56
  };
53
57
  const readSnapshot = () => {
@@ -1 +1 @@
1
- {"version":3,"names":["_types","require","CONSENT_FEATURE","name","version","log","args","console","getShopify","window","Shopify","isShopifyHost","exports","toState","value","readSnapshot","_getShopify","privacy","customerPrivacy","UNKNOWN_CONSENT","consent","currentVisitorConsent","explicitAnalytics","analytics","explicitMarketing","marketing","allowed","analyticsProcessingAllowed","enforced","regulation","region","isRegulationEnforced","getRegulation","getRegion","bannerRequired","shouldShowBanner","permissiveDefault","fallbackWhenUnenforceable","performance","requestConsentApi","onReady","shopify","loadFeatures","error","createShopifyConsentProvider","read","subscribe","onChange","publish","document","addEventListener","removeEventListener"],"sources":["../../../../src/privacy/providers/shopifyProvider.ts"],"sourcesContent":["/**\n * Shopify Customer Privacy API provider — DL #218.\n *\n * Two things about this API shape the provider:\n *\n * 1. **It is not on the page by default.** `window.Shopify.customerPrivacy` is\n * `undefined` until somebody asks for it with `Shopify.loadFeatures`. The\n * theme app extension warms it so it is ready before the bundle mounts;\n * this provider still requests it, because the extension may not be\n * installed and the request is idempotent.\n *\n * 2. **`visitorConsentCollected` may have already fired.** The bundle executes\n * into an already-rendered storefront page (DL #217), so `read()` answers\n * from current state and the event is only ever an update.\n *\n * The region rule is the one judgement encoded here, and it keys off\n * `isRegulationEnforced()` rather than `shouldShowBanner()`. The two are not\n * interchangeable: the banner reflects what the *merchant* configured, while\n * enforcement reflects what the *visitor's jurisdiction* requires. A store with\n * an empty consent configuration reports \"no banner needed\" everywhere,\n * including inside the EU.\n */\n\nimport {\n UNKNOWN_CONSENT,\n type ConsentProvider,\n type ConsentSnapshot,\n type ConsentState,\n} from '../types';\n\ntype ShopifyConsentValue = 'yes' | 'no' | '' | undefined;\n\ninterface ShopifyVisitorConsent {\n analytics?: ShopifyConsentValue;\n marketing?: ShopifyConsentValue;\n preferences?: ShopifyConsentValue;\n sale_of_data?: ShopifyConsentValue;\n}\n\ninterface ShopifyCustomerPrivacy {\n analyticsProcessingAllowed?: () => boolean;\n marketingAllowed?: () => boolean;\n currentVisitorConsent?: () => ShopifyVisitorConsent;\n shouldShowBanner?: () => boolean;\n /** Whether a privacy regulation applies to this visitor's region. */\n isRegulationEnforced?: () => boolean;\n /** e.g. 'GDPR', 'CCPA'. */\n getRegulation?: () => string;\n /** e.g. 'DEBE' — country + subdivision. */\n getRegion?: () => string;\n}\n\ninterface ShopifyGlobal {\n customerPrivacy?: ShopifyCustomerPrivacy;\n loadFeatures?: (\n features: { name: string; version: string }[],\n callback: (error?: unknown) => void,\n ) => void;\n}\n\nconst CONSENT_FEATURE = { name: 'consent-tracking-api', version: '0.1' };\n\nconst log = (...args: unknown[]): void => {\n try {\n console.log('[w5-consent] shopify:', ...args);\n } catch {\n /* never break on a console */\n }\n};\n\nconst getShopify = (): ShopifyGlobal | null => {\n if (typeof window === 'undefined') {\n return null;\n }\n return (window as unknown as { Shopify?: ShopifyGlobal }).Shopify ?? null;\n};\n\nexport const isShopifyHost = (): boolean => getShopify() !== null;\n\nconst toState = (value: ShopifyConsentValue): ConsentState | null => {\n if (value === 'yes') return 'granted';\n if (value === 'no') return 'denied';\n return null;\n};\n\nconst readSnapshot = (): ConsentSnapshot => {\n const privacy = getShopify()?.customerPrivacy;\n if (!privacy) {\n log(\n 'customerPrivacy API not on the page — no answer available (store has no privacy configuration, or loadFeatures has not resolved yet)',\n );\n // The API has not loaded (or the store has no privacy configuration at\n // all). Not an answer — the gate holds, and the visitor's own action is\n // what unlocks the session.\n return UNKNOWN_CONSENT;\n }\n\n let consent: ShopifyVisitorConsent = {};\n try {\n consent = privacy.currentVisitorConsent?.() ?? {};\n } catch {\n // Present but not ready — treat as no answer yet.\n }\n\n const explicitAnalytics = toState(consent.analytics);\n const explicitMarketing = toState(consent.marketing);\n\n let allowed = false;\n try {\n allowed = privacy.analyticsProcessingAllowed?.() === true;\n } catch {\n allowed = false;\n }\n\n // Is a privacy regulation in force for *this visitor's* region? This is the\n // question that matters, and it is not the same question as \"is a banner\n // being shown\" — see the comment on `enforced` below.\n let enforced: boolean | null = null;\n let regulation = '';\n let region = '';\n try {\n if (typeof privacy.isRegulationEnforced === 'function') {\n enforced = privacy.isRegulationEnforced() === true;\n }\n regulation = privacy.getRegulation?.() ?? '';\n region = privacy.getRegion?.() ?? '';\n } catch {\n enforced = null;\n }\n\n let bannerRequired = true;\n try {\n bannerRequired = privacy.shouldShowBanner?.() !== false;\n } catch {\n bannerRequired = true;\n }\n\n /*\n * Measured on a live store from a Frankfurt IP, with no consent recorded:\n *\n * region 'DEBE' · regulation 'GDPR' · isRegulationEnforced() true\n * shouldShowBanner() false · analyticsProcessingAllowed() TRUE\n * getShopPrefs() { limit: [] }\n *\n * Shopify said tracking was allowed for a GDPR-protected visitor who had\n * never been asked, because the *merchant* had configured no consent\n * preferences. `shouldShowBanner()` and `analyticsProcessingAllowed()` both\n * describe the merchant's setup; neither is a statement about a legal basis.\n * A merchant's misconfiguration must not become our tracking decision, so\n * under an enforced regulation an absent answer stays `unknown` and the gate\n * holds — the visitor's own prompt is then the only thing that unlocks them.\n */\n const permissiveDefault = allowed || !bannerRequired;\n const fallbackWhenUnenforceable = permissiveDefault ? 'granted' : 'unknown';\n\n const analytics: ConsentState =\n explicitAnalytics ??\n (enforced === true ? 'unknown' : fallbackWhenUnenforceable);\n\n const marketing: ConsentState =\n explicitMarketing ??\n (enforced === true ? 'unknown' : !bannerRequired ? 'granted' : 'unknown');\n\n log(\n `read — visitorConsent.analytics=${consent.analytics ?? '(unset)'} ` +\n `analyticsProcessingAllowed=${allowed} bannerRequired=${bannerRequired} ` +\n `region=${region || '?'} regulation=${regulation || '?'} enforced=${\n enforced === null ? 'unavailable' : enforced\n }` +\n (enforced === true && explicitAnalytics === null\n ? ' → regulated and unanswered, holding'\n : '') +\n ` ⇒ ${analytics}`,\n );\n\n return {\n analytics,\n marketing,\n // Shopify has no separate performance bucket. Load telemetry carries an\n // app name and a session id to a Wix endpoint, so it answers to the same\n // answer analytics does rather than riding for free.\n performance: analytics,\n };\n};\n\n/**\n * Ask Shopify to load the consent API if it is not already there. Safe to call\n * more than once; the callback re-reads whatever state arrives.\n */\nconst requestConsentApi = (onReady: () => void): void => {\n const shopify = getShopify();\n if (!shopify || shopify.customerPrivacy || !shopify.loadFeatures) {\n return;\n }\n try {\n log('requesting consent-tracking-api via Shopify.loadFeatures…');\n shopify.loadFeatures([CONSENT_FEATURE], (error) => {\n if (error) {\n log('loadFeatures failed — gate stays held', error);\n return;\n }\n log('loadFeatures resolved — re-reading consent');\n onReady();\n });\n } catch {\n // Storefronts without the feature simply never resolve; the gate stays\n // held and engagement remains the only unlock.\n }\n};\n\nexport const createShopifyConsentProvider = (): ConsentProvider => ({\n name: 'shopify-customer-privacy',\n\n read: readSnapshot,\n\n subscribe(onChange) {\n const publish = () => {\n log('visitorConsentCollected — the visitor answered the banner');\n onChange(readSnapshot());\n };\n\n // The visitor may have answered the banner before this bundle existed, so\n // the event is an update — never the first read.\n if (typeof document !== 'undefined') {\n document.addEventListener('visitorConsentCollected', publish);\n }\n requestConsentApi(() => onChange(readSnapshot()));\n\n return () => {\n if (typeof document !== 'undefined') {\n document.removeEventListener('visitorConsentCollected', publish);\n }\n };\n },\n});\n"],"mappings":";;;;AAuBA,IAAAA,MAAA,GAAAC,OAAA;AAvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuCA,MAAMC,eAAe,GAAG;EAAEC,IAAI,EAAE,sBAAsB;EAAEC,OAAO,EAAE;AAAM,CAAC;AA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CAAChC,YAAY,CAAC,CAAC,CAAC;IAC1B,CAAC;;IAED;IACA;IACA,IAAI,OAAOkC,QAAQ,KAAK,WAAW,EAAE;MACnCA,QAAQ,CAACC,gBAAgB,CAAC,yBAAyB,EAAEF,OAAO,CAAC;IAC/D;IACAT,iBAAiB,CAAC,MAAMQ,QAAQ,CAAChC,YAAY,CAAC,CAAC,CAAC,CAAC;IAEjD,OAAO,MAAM;MACX,IAAI,OAAOkC,QAAQ,KAAK,WAAW,EAAE;QACnCA,QAAQ,CAACE,mBAAmB,CAAC,yBAAyB,EAAEH,OAAO,CAAC;MAClE;IACF,CAAC;EACH;AACF,CAAC,CAAC;AAACpC,OAAA,CAAAgC,4BAAA,GAAAA,4BAAA","ignoreList":[]}
1
+ {"version":3,"names":["_types","require","CONSENT_FEATURE","name","version","log","args","console","debug","getShopify","window","Shopify","isShopifyHost","exports","toState","value","readSnapshot","_getShopify","privacy","customerPrivacy","UNKNOWN_CONSENT","consent","currentVisitorConsent","explicitAnalytics","analytics","explicitMarketing","marketing","allowed","analyticsProcessingAllowed","enforced","regulation","region","isRegulationEnforced","getRegulation","getRegion","bannerRequired","shouldShowBanner","permissiveDefault","fallbackWhenUnenforceable","performance","requestConsentApi","onReady","shopify","loadFeatures","error","createShopifyConsentProvider","read","subscribe","onChange","publish","document","addEventListener","removeEventListener"],"sources":["../../../../src/privacy/providers/shopifyProvider.ts"],"sourcesContent":["/**\n * Shopify Customer Privacy API provider — DL #218.\n *\n * Two things about this API shape the provider:\n *\n * 1. **It is not on the page by default.** `window.Shopify.customerPrivacy` is\n * `undefined` until somebody asks for it with `Shopify.loadFeatures`. The\n * theme app extension warms it so it is ready before the bundle mounts;\n * this provider still requests it, because the extension may not be\n * installed and the request is idempotent.\n *\n * 2. **`visitorConsentCollected` may have already fired.** The bundle executes\n * into an already-rendered storefront page (DL #217), so `read()` answers\n * from current state and the event is only ever an update.\n *\n * The region rule is the one judgement encoded here, and it keys off\n * `isRegulationEnforced()` rather than `shouldShowBanner()`. The two are not\n * interchangeable: the banner reflects what the *merchant* configured, while\n * enforcement reflects what the *visitor's jurisdiction* requires. A store with\n * an empty consent configuration reports \"no banner needed\" everywhere,\n * including inside the EU.\n */\n\nimport {\n UNKNOWN_CONSENT,\n type ConsentProvider,\n type ConsentSnapshot,\n type ConsentState,\n} from '../types';\n\ntype ShopifyConsentValue = 'yes' | 'no' | '' | undefined;\n\ninterface ShopifyVisitorConsent {\n analytics?: ShopifyConsentValue;\n marketing?: ShopifyConsentValue;\n preferences?: ShopifyConsentValue;\n sale_of_data?: ShopifyConsentValue;\n}\n\ninterface ShopifyCustomerPrivacy {\n analyticsProcessingAllowed?: () => boolean;\n marketingAllowed?: () => boolean;\n currentVisitorConsent?: () => ShopifyVisitorConsent;\n shouldShowBanner?: () => boolean;\n /** Whether a privacy regulation applies to this visitor's region. */\n isRegulationEnforced?: () => boolean;\n /** e.g. 'GDPR', 'CCPA'. */\n getRegulation?: () => string;\n /** e.g. 'DEBE' — country + subdivision. */\n getRegion?: () => string;\n}\n\ninterface ShopifyGlobal {\n customerPrivacy?: ShopifyCustomerPrivacy;\n loadFeatures?: (\n features: { name: string; version: string }[],\n callback: (error?: unknown) => void,\n ) => void;\n}\n\nconst CONSENT_FEATURE = { name: 'consent-tracking-api', version: '0.1' };\n\nconst log = (...args: unknown[]): void => {\n try {\n console.debug('[w5-consent] shopify:', ...args);\n } catch {\n /* never break on a console */\n }\n};\n\nconst getShopify = (): ShopifyGlobal | null => {\n if (typeof window === 'undefined') {\n return null;\n }\n return (window as unknown as { Shopify?: ShopifyGlobal }).Shopify ?? null;\n};\n\nexport const isShopifyHost = (): boolean => getShopify() !== null;\n\nconst toState = (value: ShopifyConsentValue): ConsentState | null => {\n if (value === 'yes') {\n return 'granted';\n }\n if (value === 'no') {\n return 'denied';\n }\n return null;\n};\n\nconst readSnapshot = (): ConsentSnapshot => {\n const privacy = getShopify()?.customerPrivacy;\n if (!privacy) {\n log(\n 'customerPrivacy API not on the page — no answer available (store has no privacy configuration, or loadFeatures has not resolved yet)',\n );\n // The API has not loaded (or the store has no privacy configuration at\n // all). Not an answer — the gate holds, and the visitor's own action is\n // what unlocks the session.\n return UNKNOWN_CONSENT;\n }\n\n let consent: ShopifyVisitorConsent = {};\n try {\n consent = privacy.currentVisitorConsent?.() ?? {};\n } catch {\n // Present but not ready — treat as no answer yet.\n }\n\n const explicitAnalytics = toState(consent.analytics);\n const explicitMarketing = toState(consent.marketing);\n\n let allowed = false;\n try {\n allowed = privacy.analyticsProcessingAllowed?.() === true;\n } catch {\n allowed = false;\n }\n\n // Is a privacy regulation in force for *this visitor's* region? This is the\n // question that matters, and it is not the same question as \"is a banner\n // being shown\" — see the comment on `enforced` below.\n let enforced: boolean | null = null;\n let regulation = '';\n let region = '';\n try {\n if (typeof privacy.isRegulationEnforced === 'function') {\n enforced = privacy.isRegulationEnforced() === true;\n }\n regulation = privacy.getRegulation?.() ?? '';\n region = privacy.getRegion?.() ?? '';\n } catch {\n enforced = null;\n }\n\n let bannerRequired = true;\n try {\n bannerRequired = privacy.shouldShowBanner?.() !== false;\n } catch {\n bannerRequired = true;\n }\n\n /*\n * Measured on a live store from a Frankfurt IP, with no consent recorded:\n *\n * region 'DEBE' · regulation 'GDPR' · isRegulationEnforced() true\n * shouldShowBanner() false · analyticsProcessingAllowed() TRUE\n * getShopPrefs() { limit: [] }\n *\n * Shopify said tracking was allowed for a GDPR-protected visitor who had\n * never been asked, because the *merchant* had configured no consent\n * preferences. `shouldShowBanner()` and `analyticsProcessingAllowed()` both\n * describe the merchant's setup; neither is a statement about a legal basis.\n * A merchant's misconfiguration must not become our tracking decision, so\n * under an enforced regulation an absent answer stays `unknown` and the gate\n * holds — the visitor's own prompt is then the only thing that unlocks them.\n */\n const permissiveDefault = allowed || !bannerRequired;\n const fallbackWhenUnenforceable = permissiveDefault ? 'granted' : 'unknown';\n\n const analytics: ConsentState =\n explicitAnalytics ??\n (enforced === true ? 'unknown' : fallbackWhenUnenforceable);\n\n const marketing: ConsentState =\n explicitMarketing ??\n (enforced === true ? 'unknown' : !bannerRequired ? 'granted' : 'unknown');\n\n log(\n `read — visitorConsent.analytics=${consent.analytics ?? '(unset)'} ` +\n `analyticsProcessingAllowed=${allowed} bannerRequired=${bannerRequired} ` +\n `region=${region || '?'} regulation=${regulation || '?'} enforced=${\n enforced === null ? 'unavailable' : enforced\n }` +\n (enforced === true && explicitAnalytics === null\n ? ' → regulated and unanswered, holding'\n : '') +\n ` ⇒ ${analytics}`,\n );\n\n return {\n analytics,\n marketing,\n // Shopify has no separate performance bucket. Load telemetry carries an\n // app name and a session id to a Wix endpoint, so it answers to the same\n // answer analytics does rather than riding for free.\n performance: analytics,\n };\n};\n\n/**\n * Ask Shopify to load the consent API if it is not already there. Safe to call\n * more than once; the callback re-reads whatever state arrives.\n */\nconst requestConsentApi = (onReady: () => void): void => {\n const shopify = getShopify();\n if (!shopify || shopify.customerPrivacy || !shopify.loadFeatures) {\n return;\n }\n try {\n log('requesting consent-tracking-api via Shopify.loadFeatures…');\n shopify.loadFeatures([CONSENT_FEATURE], (error) => {\n if (error) {\n log('loadFeatures failed — gate stays held', error);\n return;\n }\n log('loadFeatures resolved — re-reading consent');\n onReady();\n });\n } catch {\n // Storefronts without the feature simply never resolve; the gate stays\n // held and engagement remains the only unlock.\n }\n};\n\nexport const createShopifyConsentProvider = (): ConsentProvider => ({\n name: 'shopify-customer-privacy',\n\n read: readSnapshot,\n\n subscribe(onChange) {\n const publish = () => {\n log('visitorConsentCollected — the visitor answered the banner');\n onChange(readSnapshot());\n };\n\n // The visitor may have answered the banner before this bundle existed, so\n // the event is an update — never the first read.\n if (typeof document !== 'undefined') {\n document.addEventListener('visitorConsentCollected', publish);\n }\n requestConsentApi(() => onChange(readSnapshot()));\n\n return () => {\n if (typeof document !== 'undefined') {\n document.removeEventListener('visitorConsentCollected', publish);\n }\n };\n },\n});\n"],"mappings":";;;;AAuBA,IAAAA,MAAA,GAAAC,OAAA;AAvBA;AACA;AACA;AAC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AGA,CAAA,MAAwB;EAClE1C,IAAI,EAAE,0BAA0B;EAEhC2C,IAAI,EAAE9B,YAAY;EAElB+B,SAASA,CAACC,QAAQ,EAAE;IAClB,MAAMC,OAAO,GAAGA,CAAA,KAAM;MACpB5C,GAAG,CAAC,2DAA2D,CAAC;MAChE2C,QAAQ,CAAChC,YAAY,CAAC,CAAC,CAAC;IAC1B,CAAC;;IAED;IACA;IACA,IAAI,OAAOkC,QAAQ,KAAK,WAAW,EAAE;MACnCA,QAAQ,CAACC,gBAAgB,CAAC,yBAAyB,EAAEF,OAAO,CAAC;IAC/D;IACAT,iBAAiB,CAAC,MAAMQ,QAAQ,CAAChC,YAAY,CAAC,CAAC,CAAC,CAAC;IAEjD,OAAO,MAAM;MACX,IAAI,OAAOkC,QAAQ,KAAK,WAAW,EAAE;QACnCA,QAAQ,CAACE,mBAAmB,CAAC,yBAAyB,EAAEH,OAAO,CAAC;MAClE;IACF,CAAC;EACH;AACF,CAAC,CAAC;AAACpC,OAAA,CAAAgC,4BAAA,GAAAA,4BAAA","ignoreList":[]}
@@ -37,7 +37,7 @@ const log = function () {
37
37
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
38
38
  args[_key] = arguments[_key];
39
39
  }
40
- console.log(LOG_PREFIX, ...args);
40
+ console.debug(LOG_PREFIX, ...args);
41
41
  } catch {
42
42
  // A console that throws must never break a send.
43
43
  }
@@ -1 +1 @@
1
- {"version":3,"names":["UNKNOWN_CONSENT","DEFAULT_BUFFER_LIMIT","LOG_PREFIX","log","_len","arguments","length","args","Array","_key","console","describe","s","analytics","performance","marketing","snapshot","engaged","provider","unsubscribeProvider","buffer","bufferLimit","droppedFromOverflow","listeners","Set","view","Object","freeze","consent","rebuildView","notify","listener","mayTransmit","purpose","state","settleBuffer","stillHeld","releasing","held","push","dropped","label","send","transmit","unlockOnUserAction","isUserEngaged","mayPersistIdentity","getConsentSnapshot","getGateView","subscribeToConsent","add","delete","applySnapshot","next","installConsentProvider","initial","read","name","subscribe","getInstalledProviderName","_provider","setConsentBufferLimit","limit","Math","max","getConsentGateStats","resetConsentGateForTests","clear"],"sources":["../../../src/privacy/consentGate.ts"],"sourcesContent":["/**\n * The consent gate — DL #218.\n *\n * Every BI, telemetry and analytics emitter in web5 goes through `transmit()`\n * instead of calling its transport directly. The gate exists because the\n * consent signal resolves *after* the events that need it: Shopify's consent\n * API is not on the page by default and has to be requested, and the fedops\n * app-load pair fires inside that window. A boolean checked at each call site\n * can only ever drop an event that is already in flight; the gate can hold it.\n *\n * Two independent unlocks, and they do not compose as a plain \"either/or\":\n *\n * | consent | engaged | result |\n * |-----------|---------|---------------------------------|\n * | granted | either | transmit |\n * | unknown | no | hold in the buffer |\n * | unknown | yes | transmit, and flush what's held |\n * | denied | yes | still nothing |\n *\n * Denied outranks engaged. A visitor who refused analytics in the banner does\n * not re-enable tracking by typing a question.\n */\n\nimport {\n UNKNOWN_CONSENT,\n type ConsentProvider,\n type ConsentPurpose,\n type ConsentSnapshot,\n type GatedPurpose,\n} from './types';\n\n/** Held events are dropped past this many — a runaway emitter must not become a leak. */\nconst DEFAULT_BUFFER_LIMIT = 50;\n\n/**\n * One prefix for the whole consent trail, so `[w5-consent]` in the console\n * filter shows the full story: which CMP was found, what it answered, and for\n * every event whether it was sent, held, dropped or replayed.\n */\nconst LOG_PREFIX = '[w5-consent]';\n\nconst log = (...args: unknown[]): void => {\n try {\n console.log(LOG_PREFIX, ...args);\n } catch {\n // A console that throws must never break a send.\n }\n};\n\nconst describe = (s: ConsentSnapshot): string =>\n `analytics=${s.analytics} performance=${s.performance} marketing=${s.marketing}`;\n\ninterface HeldEvent {\n purpose: GatedPurpose;\n send: () => void;\n label: string;\n}\n\nexport interface GateView {\n consent: ConsentSnapshot;\n engaged: boolean;\n}\n\ntype Listener = () => void;\n\nlet snapshot: ConsentSnapshot = UNKNOWN_CONSENT;\nlet engaged = false;\nlet provider: ConsentProvider | null = null;\nlet unsubscribeProvider: (() => void) | null = null;\nlet buffer: HeldEvent[] = [];\nlet bufferLimit = DEFAULT_BUFFER_LIMIT;\nlet droppedFromOverflow = 0;\n\nconst listeners = new Set<Listener>();\n\n/**\n * Cached so `getGateView` is referentially stable between changes —\n * `useSyncExternalStore` re-renders forever if the snapshot is a fresh object\n * on every read.\n */\nlet view: GateView = Object.freeze({ consent: UNKNOWN_CONSENT, engaged: false });\n\nconst rebuildView = (): void => {\n view = Object.freeze({ consent: snapshot, engaged });\n};\n\nconst notify = (): void => {\n for (const listener of listeners) {\n try {\n listener();\n } catch {\n // A subscriber that throws must not stop the others, or stop a flush.\n }\n }\n};\n\n/**\n * Whether an event for `purpose` may go on the wire right now.\n *\n * `necessary` is always allowed. For everything else: explicit consent wins in\n * both directions, and engagement resolves only the `unknown` case.\n */\nexport const mayTransmit = (purpose: ConsentPurpose): boolean => {\n if (purpose === 'necessary') {\n return true;\n }\n const state = snapshot[purpose];\n if (state === 'denied') {\n return false;\n }\n if (state === 'granted') {\n return true;\n }\n return engaged;\n};\n\n/**\n * Release everything the gate is holding that is now allowed, and drop\n * everything that is now refused. Anything still `unknown` stays held.\n *\n * Order is preserved among released events, but a flush necessarily emits them\n * later than they were raised — a held app-load event reaches the wire after\n * the prompt that unlocked it. Anything reading these as a timeline has to\n * know that.\n */\nconst settleBuffer = (): void => {\n if (buffer.length === 0) {\n return;\n }\n const stillHeld: HeldEvent[] = [];\n const releasing: HeldEvent[] = [];\n\n for (const held of buffer) {\n if (mayTransmit(held.purpose)) {\n releasing.push(held);\n } else if (snapshot[held.purpose] === 'denied') {\n // dropped on the floor, deliberately and permanently\n } else {\n stillHeld.push(held);\n }\n }\n\n const dropped = buffer.length - stillHeld.length - releasing.length;\n buffer = stillHeld;\n\n if (releasing.length || dropped) {\n log(\n `settle — releasing ${releasing.length}` +\n (dropped ? `, dropping ${dropped} (refused)` : '') +\n (stillHeld.length ? `, still holding ${stillHeld.length}` : ''),\n );\n }\n\n for (const held of releasing) {\n try {\n log(` ↳ REPLAY ${held.label} (${held.purpose})`);\n held.send();\n } catch {\n // A failed send must not strand the rest of the flush.\n }\n }\n};\n\n/**\n * The single entry point for anything that would put a request on the wire.\n *\n * Allowed → sent now. Refused → dropped. Not yet known → held until an unlock\n * settles it, or discarded with the page.\n */\nexport const transmit = (\n purpose: ConsentPurpose,\n send: () => void,\n label = 'event',\n): void => {\n if (mayTransmit(purpose)) {\n log(`SEND ${label} (${purpose}) — allowed`);\n send();\n return;\n }\n if (purpose !== 'necessary' && snapshot[purpose] === 'denied') {\n log(`DROP ${label} (${purpose}) — visitor refused`);\n return;\n }\n if (buffer.length >= bufferLimit) {\n droppedFromOverflow += 1;\n log(\n `DROP ${label} (${purpose}) — buffer full at ${bufferLimit}, ${droppedFromOverflow} lost`,\n );\n return;\n }\n buffer.push({ purpose: purpose as GatedPurpose, send, label });\n log(`HOLD ${label} (${purpose}) — no answer yet, ${buffer.length} held`);\n};\n\n/**\n * The visitor did something deliberate — submitted a prompt — so the session\n * may be measured even though no CMP has answered.\n *\n * This is the unlock that keeps web5 measurable at all: on a Shopify store\n * with no privacy configuration the consent API never loads, consent stays\n * `unknown` forever, and without this every store would report nothing.\n *\n * It unlocks **transmission only**. Persistent identity stays gated on real\n * consent (see `mayPersistIdentity`) — typing a question is a reason to\n * measure the session, not a reason to persist an identifier across visits.\n * It also cannot override a `denied`.\n */\nexport const unlockOnUserAction = (): void => {\n if (engaged) {\n return;\n }\n engaged = true;\n log(\n `UNLOCK — visitor submitted a prompt; ${buffer.length} held event(s) to settle`,\n );\n rebuildView();\n settleBuffer();\n notify();\n};\n\n/** Whether the visitor has taken the deliberate action that unlocks the session. */\nexport const isUserEngaged = (): boolean => engaged;\n\n/**\n * Persistent, cross-visit storage of a visitor identifier requires real\n * consent — engagement is deliberately not enough.\n */\nexport const mayPersistIdentity = (): boolean => snapshot.analytics === 'granted';\n\nexport const getConsentSnapshot = (): ConsentSnapshot => snapshot;\n\n/** Referentially stable between changes, for `useSyncExternalStore`. */\nexport const getGateView = (): GateView => view;\n\nexport const subscribeToConsent = (listener: Listener): (() => void) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n};\n\nconst applySnapshot = (next: ConsentSnapshot): void => {\n if (\n next.analytics === snapshot.analytics &&\n next.marketing === snapshot.marketing &&\n next.performance === snapshot.performance\n ) {\n return;\n }\n log(`ANSWER — ${describe(snapshot)} → ${describe(next)}`);\n snapshot = Object.freeze({ ...next });\n rebuildView();\n settleBuffer();\n notify();\n};\n\n/**\n * Install the host's provider. Reads its current state immediately, *then*\n * subscribes — DL #217: a listener registered into an already-rendered page is\n * bound to an event that may have fired long before the bundle executed, so\n * subscribing alone would leave the gate permanently at `unknown`.\n */\nexport const installConsentProvider = (next: ConsentProvider): void => {\n unsubscribeProvider?.();\n provider = next;\n const initial = next.read();\n log(`provider installed: ${next.name} — reads ${describe(initial)}`);\n applySnapshot(initial);\n unsubscribeProvider = next.subscribe(applySnapshot);\n};\n\nexport const getInstalledProviderName = (): string | null => provider?.name ?? null;\n\nexport const setConsentBufferLimit = (limit: number): void => {\n bufferLimit = Math.max(0, limit);\n};\n\n/** Diagnostics only — how much the gate is holding, and what it had to drop. */\nexport const getConsentGateStats = (): {\n held: number;\n droppedFromOverflow: number;\n} => ({ held: buffer.length, droppedFromOverflow });\n\nexport const resetConsentGateForTests = (): void => {\n unsubscribeProvider?.();\n unsubscribeProvider = null;\n provider = null;\n snapshot = UNKNOWN_CONSENT;\n engaged = false;\n buffer = [];\n bufferLimit = DEFAULT_BUFFER_LIMIT;\n droppedFromOverflow = 0;\n listeners.clear();\n rebuildView();\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,eAAe,QAKV,SAAS;;AAEhB;AACA,MAAMC,oBAAoB,GAAG,EAAE;;AAE/B;AACA;AACA;AACA;AACA;AACA,MAAMC,UAAU,GAAG,cAAc;AAEjC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;EACrElC,mBAAmB,YAAnBA,mBAAmB,CAAG,CAAC;EACvBD,QAAQ,GAAGmC,IAAI;EACf,MAAME,OAAO,GAAGF,IAAI,CAACG,IAAI,CAAC,CAAC;EAC3BrD,GAAG,CAAC,uBAAuBkD,IAAI,CAACI,IAAI,YAAY9C,QAAQ,CAAC4C,OAAO,CAAC,EAAE,CAAC;EACpEH,aAAa,CAACG,OAAO,CAAC;EACtBpC,mBAAmB,GAAGkC,IAAI,CAACK,SAAS,CAACN,aAAa,CAAC;AACrD,CAAC;AAED,OAAO,MAAMO,wBAAwB,GAAGA,CAAA;EAAA,IAAAC,SAAA;EAAA,OAAqB,EAAAA,SAAA,GAAA1C,QAAQ,qBAAR0C,SAAA,CAAUH,IAAI,KAAI,IAAI;AAAA;AAEnF,OAAO,MAAMI,qBAAqB,GAAIC,KAAa,IAAW;EAC5DzC,WAAW,GAAG0C,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEF,KAAK,CAAC;AAClC,CAAC;;AAED;AACA,OAAO,MAAMG,mBAAmB,GAAGA,CAAA,MAG7B;EAAE3B,IAAI,EAAElB,MAAM,CAACd,MAAM;EAAEgB;AAAoB,CAAC,CAAC;AAEnD,OAAO,MAAM4C,wBAAwB,GAAGA,CAAA,KAAY;EAClD/C,mBAAmB,YAAnBA,mBAAmB,CAAG,CAAC;EACvBA,mBAAmB,GAAG,IAAI;EAC1BD,QAAQ,GAAG,IAAI;EACfF,QAAQ,GAAGhB,eAAe;EAC1BiB,OAAO,GAAG,KAAK;EACfG,MAAM,GAAG,EAAE;EACXC,WAAW,GAAGpB,oBAAoB;EAClCqB,mBAAmB,GAAG,CAAC;EACvBC,SAAS,CAAC4C,KAAK,CAAC,CAAC;EACjBtC,WAAW,CAAC,CAAC;AACf,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["UNKNOWN_CONSENT","DEFAULT_BUFFER_LIMIT","LOG_PREFIX","log","_len","arguments","length","args","Array","_key","console","debug","describe","s","analytics","performance","marketing","snapshot","engaged","provider","unsubscribeProvider","buffer","bufferLimit","droppedFromOverflow","listeners","Set","view","Object","freeze","consent","rebuildView","notify","listener","mayTransmit","purpose","state","settleBuffer","stillHeld","releasing","held","push","dropped","label","send","transmit","unlockOnUserAction","isUserEngaged","mayPersistIdentity","getConsentSnapshot","getGateView","subscribeToConsent","add","delete","applySnapshot","next","installConsentProvider","initial","read","name","subscribe","getInstalledProviderName","_provider","setConsentBufferLimit","limit","Math","max","getConsentGateStats","resetConsentGateForTests","clear"],"sources":["../../../src/privacy/consentGate.ts"],"sourcesContent":["/**\n * The consent gate — DL #218.\n *\n * Every BI, telemetry and analytics emitter in web5 goes through `transmit()`\n * instead of calling its transport directly. The gate exists because the\n * consent signal resolves *after* the events that need it: Shopify's consent\n * API is not on the page by default and has to be requested, and the fedops\n * app-load pair fires inside that window. A boolean checked at each call site\n * can only ever drop an event that is already in flight; the gate can hold it.\n *\n * Two independent unlocks, and they do not compose as a plain \"either/or\":\n *\n * | consent | engaged | result |\n * |-----------|---------|---------------------------------|\n * | granted | either | transmit |\n * | unknown | no | hold in the buffer |\n * | unknown | yes | transmit, and flush what's held |\n * | denied | yes | still nothing |\n *\n * Denied outranks engaged. A visitor who refused analytics in the banner does\n * not re-enable tracking by typing a question.\n */\n\nimport {\n UNKNOWN_CONSENT,\n type ConsentProvider,\n type ConsentPurpose,\n type ConsentSnapshot,\n type GatedPurpose,\n} from './types';\n\n/** Held events are dropped past this many — a runaway emitter must not become a leak. */\nconst DEFAULT_BUFFER_LIMIT = 50;\n\n/**\n * One prefix for the whole consent trail, so `[w5-consent]` in the console\n * filter shows the full story: which CMP was found, what it answered, and for\n * every event whether it was sent, held, dropped or replayed.\n */\nconst LOG_PREFIX = '[w5-consent]';\n\nconst log = (...args: unknown[]): void => {\n try {\n console.debug(LOG_PREFIX, ...args);\n } catch {\n // A console that throws must never break a send.\n }\n};\n\nconst describe = (s: ConsentSnapshot): string =>\n `analytics=${s.analytics} performance=${s.performance} marketing=${s.marketing}`;\n\ninterface HeldEvent {\n purpose: GatedPurpose;\n send: () => void;\n label: string;\n}\n\nexport interface GateView {\n consent: ConsentSnapshot;\n engaged: boolean;\n}\n\ntype Listener = () => void;\n\nlet snapshot: ConsentSnapshot = UNKNOWN_CONSENT;\nlet engaged = false;\nlet provider: ConsentProvider | null = null;\nlet unsubscribeProvider: (() => void) | null = null;\nlet buffer: HeldEvent[] = [];\nlet bufferLimit = DEFAULT_BUFFER_LIMIT;\nlet droppedFromOverflow = 0;\n\nconst listeners = new Set<Listener>();\n\n/**\n * Cached so `getGateView` is referentially stable between changes —\n * `useSyncExternalStore` re-renders forever if the snapshot is a fresh object\n * on every read.\n */\nlet view: GateView = Object.freeze({\n consent: UNKNOWN_CONSENT,\n engaged: false,\n});\n\nconst rebuildView = (): void => {\n view = Object.freeze({ consent: snapshot, engaged });\n};\n\nconst notify = (): void => {\n for (const listener of listeners) {\n try {\n listener();\n } catch {\n // A subscriber that throws must not stop the others, or stop a flush.\n }\n }\n};\n\n/**\n * Whether an event for `purpose` may go on the wire right now.\n *\n * `necessary` is always allowed. For everything else: explicit consent wins in\n * both directions, and engagement resolves only the `unknown` case.\n */\nexport const mayTransmit = (purpose: ConsentPurpose): boolean => {\n if (purpose === 'necessary') {\n return true;\n }\n const state = snapshot[purpose];\n if (state === 'denied') {\n return false;\n }\n if (state === 'granted') {\n return true;\n }\n return engaged;\n};\n\n/**\n * Release everything the gate is holding that is now allowed, and drop\n * everything that is now refused. Anything still `unknown` stays held.\n *\n * Order is preserved among released events, but a flush necessarily emits them\n * later than they were raised — a held app-load event reaches the wire after\n * the prompt that unlocked it. Anything reading these as a timeline has to\n * know that.\n */\nconst settleBuffer = (): void => {\n if (buffer.length === 0) {\n return;\n }\n const stillHeld: HeldEvent[] = [];\n const releasing: HeldEvent[] = [];\n\n for (const held of buffer) {\n if (mayTransmit(held.purpose)) {\n releasing.push(held);\n } else if (snapshot[held.purpose] === 'denied') {\n // dropped on the floor, deliberately and permanently\n } else {\n stillHeld.push(held);\n }\n }\n\n const dropped = buffer.length - stillHeld.length - releasing.length;\n buffer = stillHeld;\n\n if (releasing.length || dropped) {\n log(\n `settle — releasing ${releasing.length}` +\n (dropped ? `, dropping ${dropped} (refused)` : '') +\n (stillHeld.length ? `, still holding ${stillHeld.length}` : ''),\n );\n }\n\n for (const held of releasing) {\n try {\n log(` ↳ REPLAY ${held.label} (${held.purpose})`);\n held.send();\n } catch {\n // A failed send must not strand the rest of the flush.\n }\n }\n};\n\n/**\n * The single entry point for anything that would put a request on the wire.\n *\n * Allowed → sent now. Refused → dropped. Not yet known → held until an unlock\n * settles it, or discarded with the page.\n */\nexport const transmit = (\n purpose: ConsentPurpose,\n send: () => void,\n label = 'event',\n): void => {\n if (mayTransmit(purpose)) {\n log(`SEND ${label} (${purpose}) — allowed`);\n send();\n return;\n }\n if (purpose !== 'necessary' && snapshot[purpose] === 'denied') {\n log(`DROP ${label} (${purpose}) — visitor refused`);\n return;\n }\n if (buffer.length >= bufferLimit) {\n droppedFromOverflow += 1;\n log(\n `DROP ${label} (${purpose}) — buffer full at ${bufferLimit}, ${droppedFromOverflow} lost`,\n );\n return;\n }\n buffer.push({ purpose: purpose as GatedPurpose, send, label });\n log(`HOLD ${label} (${purpose}) — no answer yet, ${buffer.length} held`);\n};\n\n/**\n * The visitor did something deliberate — submitted a prompt — so the session\n * may be measured even though no CMP has answered.\n *\n * This is the unlock that keeps web5 measurable at all: on a Shopify store\n * with no privacy configuration the consent API never loads, consent stays\n * `unknown` forever, and without this every store would report nothing.\n *\n * It unlocks **transmission only**. Persistent identity stays gated on real\n * consent (see `mayPersistIdentity`) — typing a question is a reason to\n * measure the session, not a reason to persist an identifier across visits.\n * It also cannot override a `denied`.\n */\nexport const unlockOnUserAction = (): void => {\n if (engaged) {\n return;\n }\n engaged = true;\n log(\n `UNLOCK — visitor submitted a prompt; ${buffer.length} held event(s) to settle`,\n );\n rebuildView();\n settleBuffer();\n notify();\n};\n\n/** Whether the visitor has taken the deliberate action that unlocks the session. */\nexport const isUserEngaged = (): boolean => engaged;\n\n/**\n * Persistent, cross-visit storage of a visitor identifier requires real\n * consent — engagement is deliberately not enough.\n */\nexport const mayPersistIdentity = (): boolean =>\n snapshot.analytics === 'granted';\n\nexport const getConsentSnapshot = (): ConsentSnapshot => snapshot;\n\n/** Referentially stable between changes, for `useSyncExternalStore`. */\nexport const getGateView = (): GateView => view;\n\nexport const subscribeToConsent = (listener: Listener): (() => void) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n};\n\nconst applySnapshot = (next: ConsentSnapshot): void => {\n if (\n next.analytics === snapshot.analytics &&\n next.marketing === snapshot.marketing &&\n next.performance === snapshot.performance\n ) {\n return;\n }\n log(`ANSWER — ${describe(snapshot)} → ${describe(next)}`);\n snapshot = Object.freeze({ ...next });\n rebuildView();\n settleBuffer();\n notify();\n};\n\n/**\n * Install the host's provider. Reads its current state immediately, *then*\n * subscribes — DL #217: a listener registered into an already-rendered page is\n * bound to an event that may have fired long before the bundle executed, so\n * subscribing alone would leave the gate permanently at `unknown`.\n */\nexport const installConsentProvider = (next: ConsentProvider): void => {\n unsubscribeProvider?.();\n provider = next;\n const initial = next.read();\n log(`provider installed: ${next.name} — reads ${describe(initial)}`);\n applySnapshot(initial);\n unsubscribeProvider = next.subscribe(applySnapshot);\n};\n\nexport const getInstalledProviderName = (): string | null =>\n provider?.name ?? null;\n\nexport const setConsentBufferLimit = (limit: number): void => {\n bufferLimit = Math.max(0, limit);\n};\n\n/** Diagnostics only — how much the gate is holding, and what it had to drop. */\nexport const getConsentGateStats = (): {\n held: number;\n droppedFromOverflow: number;\n} => ({ held: buffer.length, droppedFromOverflow });\n\nexport const resetConsentGateForTests = (): void => {\n unsubscribeProvider?.();\n unsubscribeProvider = null;\n provider = null;\n snapshot = UNKNOWN_CONSENT;\n engaged = false;\n buffer = [];\n bufferLimit = DEFAULT_BUFFER_LIMIT;\n droppedFromOverflow = 0;\n listeners.clear();\n rebuildView();\n};\n"],"mappings":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sB,mBAAmB,GAAG,CAAC;EACvBC,SAAS,CAAC4C,KAAK,CAAC,CAAC;EACjBtC,WAAW,CAAC,CAAC;AACf,CAAC","ignoreList":[]}
@@ -55,7 +55,7 @@ export const initConsentGate = () => {
55
55
  installConsentProvider(provider);
56
56
  } else {
57
57
  try {
58
- console.log('[w5-consent] no CMP detected (no host-supplied consent, no Shopify customerPrivacy, no OneTrust) — everything held until the visitor submits a prompt');
58
+ console.debug('[w5-consent] no CMP detected (no host-supplied consent, no Shopify customerPrivacy, no OneTrust) — everything held until the visitor submits a prompt');
59
59
  } catch {
60
60
  /* never break on a console */
61
61
  }
@@ -1 +1 @@
1
- {"version":3,"names":["installConsentProvider","getConsentOverride","overrideSnapshot","createHostSuppliedConsentProvider","hasHostSuppliedConsent","createShopifyConsentProvider","isShopifyHost","createOneTrustConsentProvider","isOneTrustHost","detectConsentProvider","forced","console","warn","name","read","subscribe","initConsentGate","provider","log"],"sources":["../../../src/privacy/detectProvider.ts"],"sourcesContent":["/**\n * Provider selection — DL #218.\n *\n * Detected at boot, not configured per client, because a merchant can install\n * a CMP long after we deploy and the bundle is not the source of truth for a\n * store's behaviour (DL #214).\n *\n * Order is host-supplied → Shopify → OneTrust → none. A host that publishes an\n * answer outranks anything we could sniff, because it knows things we cannot:\n * a server-side consent record, a CMP behind its own abstraction, or a legal\n * position we have no business guessing at.\n *\n * When nothing is detected the gate keeps its default — everything `unknown`,\n * held until the visitor acts. That is the case on every Shopify store with no\n * privacy configuration, which today is most of them.\n */\n\nimport { installConsentProvider } from './consentGate';\nimport { getConsentOverride, overrideSnapshot } from './consentOverride';\nimport type { ConsentProvider } from './types';\nimport {\n createHostSuppliedConsentProvider,\n hasHostSuppliedConsent,\n} from './providers/hostSuppliedProvider';\nimport {\n createShopifyConsentProvider,\n isShopifyHost,\n} from './providers/shopifyProvider';\nimport {\n createOneTrustConsentProvider,\n isOneTrustHost,\n} from './providers/oneTrustProvider';\n\nexport const detectConsentProvider = (): ConsentProvider | null => {\n // Debug override outranks every real signal, so the states a region or an\n // unconfigured store makes unreachable can still be walked by hand.\n const forced = getConsentOverride();\n if (forced) {\n console.warn(\n `[w5-consent] OVERRIDE ACTIVE — consent forced to \"${forced}\". This is a debug switch, not a real answer.`,\n );\n return {\n name: `override:${forced}`,\n read: () => overrideSnapshot(forced),\n subscribe: () => () => {},\n };\n }\n if (hasHostSuppliedConsent()) {\n return createHostSuppliedConsentProvider();\n }\n if (isShopifyHost()) {\n return createShopifyConsentProvider();\n }\n if (isOneTrustHost()) {\n return createOneTrustConsentProvider();\n }\n return null;\n};\n\n/**\n * Install the detected provider, if any. Call once at boot, before the first\n * emitter runs — anything raised earlier is held rather than lost, but the\n * sooner this runs the less the buffer has to carry.\n */\nexport const initConsentGate = (): ConsentProvider | null => {\n const provider = detectConsentProvider();\n if (provider) {\n installConsentProvider(provider);\n } else {\n try {\n console.log(\n '[w5-consent] no CMP detected (no host-supplied consent, no Shopify customerPrivacy, no OneTrust) — everything held until the visitor submits a prompt',\n );\n } catch {\n /* never break on a console */\n }\n }\n return provider;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,sBAAsB,QAAQ,eAAe;AACtD,SAASC,kBAAkB,EAAEC,gBAAgB,QAAQ,mBAAmB;AAExE,SACEC,iCAAiC,EACjCC,sBAAsB,QACjB,kCAAkC;AACzC,SACEC,4BAA4B,EAC5BC,aAAa,QACR,6BAA6B;AACpC,SACEC,6BAA6B,EAC7BC,cAAc,QACT,8BAA8B;AAErC,OAAO,MAAMC,qBAAqB,GAAGA,CAAA,KAA8B;EACjE;EACA;EACA,MAAMC,MAAM,GAAGT,kBAAkB,CAAC,CAAC;EACnC,IAAIS,MAAM,EAAE;IACVC,OAAO,CAACC,IAAI,CACV,qDAAqDF,MAAM,+CAC7D,CAAC;IACD,OAAO;MACLG,IAAI,EAAE,YAAYH,MAAM,EAAE;MAC1BI,IAAI,EAAEA,CAAA,KAAMZ,gBAAgB,CAACQ,MAAM,CAAC;MACpCK,SAAS,EAAEA,CAAA,KAAM,MAAM,CAAC;IAC1B,CAAC;EACH;EACA,IAAIX,sBAAsB,CAAC,CAAC,EAAE;IAC5B,OAAOD,iCAAiC,CAAC,CAAC;EAC5C;EACA,IAAIG,aAAa,CAAC,CAAC,EAAE;IACnB,OAAOD,4BAA4B,CAAC,CAAC;EACvC;EACA,IAAIG,cAAc,CAAC,CAAC,EAAE;IACpB,OAAOD,6BAA6B,CAAC,CAAC;EACxC;EACA,OAAO,IAAI;AACb,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMS,eAAe,GAAGA,CAAA,KAA8B;EAC3D,MAAMC,QAAQ,GAAGR,qBAAqB,CAAC,CAAC;EACxC,IAAIQ,QAAQ,EAAE;IACZjB,sBAAsB,CAACiB,QAAQ,CAAC;EAClC,CAAC,MAAM;IACL,IAAI;MACFN,OAAO,CAACO,GAAG,CACT,uJACF,CAAC;IACH,CAAC,CAAC,MAAM;MACN;IAAA;EAEJ;EACA,OAAOD,QAAQ;AACjB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["installConsentProvider","getConsentOverride","overrideSnapshot","createHostSuppliedConsentProvider","hasHostSuppliedConsent","createShopifyConsentProvider","isShopifyHost","createOneTrustConsentProvider","isOneTrustHost","detectConsentProvider","forced","console","warn","name","read","subscribe","initConsentGate","provider","debug"],"sources":["../../../src/privacy/detectProvider.ts"],"sourcesContent":["/**\n * Provider selection — DL #218.\n *\n * Detected at boot, not configured per client, because a merchant can install\n * a CMP long after we deploy and the bundle is not the source of truth for a\n * store's behaviour (DL #214).\n *\n * Order is host-supplied → Shopify → OneTrust → none. A host that publishes an\n * answer outranks anything we could sniff, because it knows things we cannot:\n * a server-side consent record, a CMP behind its own abstraction, or a legal\n * position we have no business guessing at.\n *\n * When nothing is detected the gate keeps its default — everything `unknown`,\n * held until the visitor acts. That is the case on every Shopify store with no\n * privacy configuration, which today is most of them.\n */\n\nimport { installConsentProvider } from './consentGate';\nimport { getConsentOverride, overrideSnapshot } from './consentOverride';\nimport type { ConsentProvider } from './types';\nimport {\n createHostSuppliedConsentProvider,\n hasHostSuppliedConsent,\n} from './providers/hostSuppliedProvider';\nimport {\n createShopifyConsentProvider,\n isShopifyHost,\n} from './providers/shopifyProvider';\nimport {\n createOneTrustConsentProvider,\n isOneTrustHost,\n} from './providers/oneTrustProvider';\n\nexport const detectConsentProvider = (): ConsentProvider | null => {\n // Debug override outranks every real signal, so the states a region or an\n // unconfigured store makes unreachable can still be walked by hand.\n const forced = getConsentOverride();\n if (forced) {\n console.warn(\n `[w5-consent] OVERRIDE ACTIVE — consent forced to \"${forced}\". This is a debug switch, not a real answer.`,\n );\n return {\n name: `override:${forced}`,\n read: () => overrideSnapshot(forced),\n subscribe: () => () => {},\n };\n }\n if (hasHostSuppliedConsent()) {\n return createHostSuppliedConsentProvider();\n }\n if (isShopifyHost()) {\n return createShopifyConsentProvider();\n }\n if (isOneTrustHost()) {\n return createOneTrustConsentProvider();\n }\n return null;\n};\n\n/**\n * Install the detected provider, if any. Call once at boot, before the first\n * emitter runs — anything raised earlier is held rather than lost, but the\n * sooner this runs the less the buffer has to carry.\n */\nexport const initConsentGate = (): ConsentProvider | null => {\n const provider = detectConsentProvider();\n if (provider) {\n installConsentProvider(provider);\n } else {\n try {\n console.debug(\n '[w5-consent] no CMP detected (no host-supplied consent, no Shopify customerPrivacy, no OneTrust) — everything held until the visitor submits a prompt',\n );\n } catch {\n /* never break on a console */\n }\n }\n return provider;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,sBAAsB,QAAQ,eAAe;AACtD,SAASC,kBAAkB,EAAEC,gBAAgB,QAAQ,mBAAmB;AAExE,SACEC,iCAAiC,EACjCC,sBAAsB,QACjB,kCAAkC;AACzC,SACEC,4BAA4B,EAC5BC,aAAa,QACR,6BAA6B;AACpC,SACEC,6BAA6B,EAC7BC,cAAc,QACT,8BAA8B;AAErC,OAAO,MAAMC,qBAAqB,GAAGA,CAAA,KAA8B;EACjE;EACA;EACA,MAAMC,MAAM,GAAGT,kBAAkB,CAAC,CAAC;EACnC,IAAIS,MAAM,EAAE;IACVC,OAAO,CAACC,IAAI,CACV,qDAAqDF,MAAM,+CAC7D,CAAC;IACD,OAAO;MACLG,IAAI,EAAE,YAAYH,MAAM,EAAE;MAC1BI,IAAI,EAAEA,CAAA,KAAMZ,gBAAgB,CAACQ,MAAM,CAAC;MACpCK,SAAS,EAAEA,CAAA,KAAM,MAAM,CAAC;IAC1B,CAAC;EACH;EACA,IAAIX,sBAAsB,CAAC,CAAC,EAAE;IAC5B,OAAOD,iCAAiC,CAAC,CAAC;EAC5C;EACA,IAAIG,aAAa,CAAC,CAAC,EAAE;IACnB,OAAOD,4BAA4B,CAAC,CAAC;EACvC;EACA,IAAIG,cAAc,CAAC,CAAC,EAAE;IACpB,OAAOD,6BAA6B,CAAC,CAAC;EACxC;EACA,OAAO,IAAI;AACb,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMS,eAAe,GAAGA,CAAA,KAA8B;EAC3D,MAAMC,QAAQ,GAAGR,qBAAqB,CAAC,CAAC;EACxC,IAAIQ,QAAQ,EAAE;IACZjB,sBAAsB,CAACiB,QAAQ,CAAC;EAClC,CAAC,MAAM;IACL,IAAI;MACFN,OAAO,CAACO,KAAK,CACX,uJACF,CAAC;IACH,CAAC,CAAC,MAAM;MACN;IAAA;EAEJ;EACA,OAAOD,QAAQ;AACjB,CAAC","ignoreList":[]}
@@ -17,8 +17,12 @@ export const HOST_CONSENT_GLOBAL = '__web5_consent__';
17
17
  /** What a host may publish. Anything missing stays `unknown`. */
18
18
 
19
19
  const coerce = value => {
20
- if (value === true) return 'granted';
21
- if (value === false) return 'denied';
20
+ if (value === true) {
21
+ return 'granted';
22
+ }
23
+ if (value === false) {
24
+ return 'denied';
25
+ }
22
26
  if (value === 'granted' || value === 'denied' || value === 'unknown') {
23
27
  return value;
24
28
  }
@@ -1 +1 @@
1
- {"version":3,"names":["UNKNOWN_CONSENT","HOST_CONSENT_GLOBAL","coerce","value","normalize","input","analytics","marketing","performance","undefined","readGlobal","window","raw","hasHostSuppliedConsent","subscribers","Set","published","publishHostConsent","subscriber","createHostSuppliedConsentProvider","name","read","subscribe","onChange","add","delete","__resetHostConsentForTests","clear"],"sources":["../../../../src/privacy/providers/hostSuppliedProvider.ts"],"sourcesContent":["/**\n * Host-supplied provider — DL #218.\n *\n * The escape hatch for every CMP we cannot detect: a host page that already\n * knows its visitor's answer publishes it, and the gate believes it. This is\n * how Circana, feature.com and any merchant on Cookiebot/Osano/Klaviyo reach\n * the gate without web5 learning each vendor's API.\n *\n * Two ways in, because hosts differ in when they know:\n * - `window.__web5_consent__` set before the bundle loads, read at install\n * - `publishHostConsent()` called at any time afterwards\n */\n\nimport {\n UNKNOWN_CONSENT,\n type ConsentProvider,\n type ConsentSnapshot,\n type ConsentState,\n} from '../types';\n\nexport const HOST_CONSENT_GLOBAL = '__web5_consent__';\n\n/** What a host may publish. Anything missing stays `unknown`. */\nexport interface HostConsentInput {\n analytics?: ConsentState | boolean;\n marketing?: ConsentState | boolean;\n performance?: ConsentState | boolean;\n}\n\nconst coerce = (value: ConsentState | boolean | undefined): ConsentState => {\n if (value === true) return 'granted';\n if (value === false) return 'denied';\n if (value === 'granted' || value === 'denied' || value === 'unknown') {\n return value;\n }\n return 'unknown';\n};\n\nconst normalize = (input: HostConsentInput | null | undefined): ConsentSnapshot => {\n if (!input || typeof input !== 'object') {\n return UNKNOWN_CONSENT;\n }\n const analytics = coerce(input.analytics);\n return {\n analytics,\n marketing: coerce(input.marketing),\n // A host that speaks only about analytics is taken to mean the same for\n // load telemetry, which is the same wire and the same recipient.\n performance:\n input.performance === undefined ? analytics : coerce(input.performance),\n };\n};\n\nconst readGlobal = (): ConsentSnapshot => {\n if (typeof window === 'undefined') {\n return UNKNOWN_CONSENT;\n }\n const raw = (window as unknown as Record<string, unknown>)[HOST_CONSENT_GLOBAL];\n return normalize(raw as HostConsentInput | undefined);\n};\n\nexport const hasHostSuppliedConsent = (): boolean => {\n if (typeof window === 'undefined') {\n return false;\n }\n const raw = (window as unknown as Record<string, unknown>)[HOST_CONSENT_GLOBAL];\n return !!raw && typeof raw === 'object';\n};\n\nconst subscribers = new Set<(snapshot: ConsentSnapshot) => void>();\nlet published: ConsentSnapshot | null = null;\n\n/**\n * Called by the host — directly, or by the loader when it is handed consent in\n * its boot options — whenever the visitor's answer is known or changes.\n */\nexport const publishHostConsent = (input: HostConsentInput): void => {\n published = normalize(input);\n for (const subscriber of subscribers) {\n subscriber(published);\n }\n};\n\nexport const createHostSuppliedConsentProvider = (): ConsentProvider => ({\n name: 'host-supplied',\n\n read: () => published ?? readGlobal(),\n\n subscribe(onChange) {\n subscribers.add(onChange);\n return () => {\n subscribers.delete(onChange);\n };\n },\n});\n\nexport const __resetHostConsentForTests = (): void => {\n published = null;\n subscribers.clear();\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,eAAe,QAIV,UAAU;AAEjB,OAAO,MAAMC,mBAAmB,GAAG,kBAAkB;;AAErD;;AAOA,MAAMC,MAAM,GAAIC,KAAyC,IAAmB;EAC1E,IAAIA,KAAK,KAAK,IAAI,EAAE,OAAO,SAAS;EACpC,IAAIA,KAAK,KAAK,KAAK,EAAE,OAAO,QAAQ;EACpC,IAAIA,KAAK,KAAK,SAAS,IAAIA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,SAAS,EAAE;IACpE,OAAOA,KAAK;EACd;EACA,OAAO,SAAS;AAClB,CAAC;AAED,MAAMC,SAAS,GAAIC,KAA0C,IAAsB;EACjF,IAAI,CAACA,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IACvC,OAAOL,eAAe;EACxB;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AAC;IACzB,OAAO,MAAM;MACXT,WAAW,CAACW,MAAM,CAACF,QAAQ,CAAC;IAC9B,CAAC;EACH;AACF,CAAC,CAAC;AAEF,OAAO,MAAMG,0BAA0B,GAAGA,CAAA,KAAY;EACpDV,SAAS,GAAG,IAAI;EAChBF,WAAW,CAACa,KAAK,CAAC,CAAC;AACrB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["UNKNOWN_CONSENT","HOST_CONSENT_GLOBAL","coerce","value","normalize","input","analytics","marketing","performance","undefined","readGlobal","window","raw","hasHostSuppliedConsent","subscribers","Set","published","publishHostConsent","subscriber","createHostSuppliedConsentProvider","name","read","subscribe","onChange","add","delete","__resetHostConsentForTests","clear"],"sources":["../../../../src/privacy/providers/hostSuppliedProvider.ts"],"sourcesContent":["/**\n * Host-supplied provider — DL #218.\n *\n * The escape hatch for every CMP we cannot detect: a host page that already\n * knows its visitor's answer publishes it, and the gate believes it. This is\n * how Circana, feature.com and any merchant on Cookiebot/Osano/Klaviyo reach\n * the gate without web5 learning each vendor's API.\n *\n * Two ways in, because hosts differ in when they know:\n * - `window.__web5_consent__` set before the bundle loads, read at install\n * - `publishHostConsent()` called at any time afterwards\n */\n\nimport {\n UNKNOWN_CONSENT,\n type ConsentProvider,\n type ConsentSnapshot,\n type ConsentState,\n} from '../types';\n\nexport const HOST_CONSENT_GLOBAL = '__web5_consent__';\n\n/** What a host may publish. Anything missing stays `unknown`. */\nexport interface HostConsentInput {\n analytics?: ConsentState | boolean;\n marketing?: ConsentState | boolean;\n performance?: ConsentState | boolean;\n}\n\nconst coerce = (value: ConsentState | boolean | undefined): ConsentState => {\n if (value === true) {\n return 'granted';\n }\n if (value === false) {\n return 'denied';\n }\n if (value === 'granted' || value === 'denied' || value === 'unknown') {\n return value;\n }\n return 'unknown';\n};\n\nconst normalize = (\n input: HostConsentInput | null | undefined,\n): ConsentSnapshot => {\n if (!input || typeof input !== 'object') {\n return UNKNOWN_CONSENT;\n }\n const analytics = coerce(input.analytics);\n return {\n analytics,\n marketing: coerce(input.marketing),\n // A host that speaks only about analytics is taken to mean the same for\n // load telemetry, which is the same wire and the same recipient.\n performance:\n input.performance === undefined ? analytics : coerce(input.performance),\n };\n};\n\nconst readGlobal = (): ConsentSnapshot => {\n if (typeof window === 'undefined') {\n return UNKNOWN_CONSENT;\n }\n const raw = (window as unknown as Record<string, unknown>)[\n HOST_CONSENT_GLOBAL\n ];\n return normalize(raw as HostConsentInput | undefined);\n};\n\nexport const hasHostSuppliedConsent = (): boolean => {\n if (typeof window === 'undefined') {\n return false;\n }\n const raw = (window as unknown as Record<string, unknown>)[\n HOST_CONSENT_GLOBAL\n ];\n return !!raw && typeof raw === 'object';\n};\n\nconst subscribers = new Set<(snapshot: ConsentSnapshot) => void>();\nlet published: ConsentSnapshot | null = null;\n\n/**\n * Called by the host — directly, or by the loader when it is handed consent in\n * its boot options — whenever the visitor's answer is known or changes.\n */\nexport const publishHostConsent = (input: HostConsentInput): void => {\n published = normalize(input);\n for (const subscriber of subscribers) {\n subscriber(published);\n }\n};\n\nexport const createHostSuppliedConsentProvider = (): ConsentProvider => ({\n name: 'host-supplied',\n\n read: () => published ?? readGlobal(),\n\n subscribe(onChange) {\n subscribers.add(onChange);\n return () => {\n subscribers.delete(onChange);\n };\n },\n});\n\nexport const __resetHostConsentForTests = (): void => {\n published = null;\n subscribers.clear();\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,eAAe,QAIV,UAAU;AAEjB,OAAO,MAAMC,mBAAmB,GAAG,kBAAkB;;AAErD;;AAOA,MAAMC,MAAM,GAAIC,KAAyC,IAAmB;EAC1E,IAAIA,KAAK,KAAK,IAAI,EAAE;IAClB,OAAO,SAAS;EAClB;EACA,IAAIA,KAAK,KAAK,KAAK,EAAE;IACnB,OAAO,QAAQ;EACjB;EACA,IAAIA,KAAK,KAAK,SAAS,IAAIA,KAAK,KAAK,QAAQ,IAAIA,KAAK,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CAAiC,GAAGA,CAAA,MAAwB;EACvEC,IAAI,EAAE,eAAe;EAErBC,IAAI,EAAEA,CAAA,KAAML,SAAS,IAAIN,UAAU,CAAC,CAAC;EAErCY,SAASA,CAACC,QAAQ,EAAE;IAClBT,WAAW,CAACU,GAAG,CAACD,QAAQ,CAAC;IACzB,OAAO,MAAM;MACXT,WAAW,CAACW,MAAM,CAACF,QAAQ,CAAC;IAC9B,CAAC;EACH;AACF,CAAC,CAAC;AAEF,OAAO,MAAMG,0BAA0B,GAAGA,CAAA,KAAY;EACpDV,SAAS,GAAG,IAAI;EAChBF,WAAW,CAACa,KAAK,CAAC,CAAC;AACrB,CAAC","ignoreList":[]}
@@ -26,7 +26,7 @@ const readSnapshot = () => {
26
26
  const groups = readGroups();
27
27
  if (groups !== null) {
28
28
  try {
29
- console.log(`[w5-consent] onetrust: active groups "${groups}"`);
29
+ console.debug(`[w5-consent] onetrust: active groups "${groups}"`);
30
30
  } catch {
31
31
  /* never break on a console */
32
32
  }
@@ -1 +1 @@
1
- {"version":3,"names":["ANALYTICS_CATEGORY","MARKETING_CATEGORY","readGroups","window","groups","OnetrustActiveGroups","isOneTrustHost","readSnapshot","console","log","analytics","marketing","performance","includes","createOneTrustConsentProvider","name","read","subscribe","onChange","publish","addEventListener","removeEventListener"],"sources":["../../../../src/privacy/providers/oneTrustProvider.ts"],"sourcesContent":["/**\n * OneTrust provider — DL #218.\n *\n * Lifted from the consent check that used to live inside\n * `utils/analyticsEvents.ts`, with one deliberate behaviour change: that\n * function returned `true` when OneTrust was absent (\"host is responsible for\n * loading OneTrust\"), which on a Shopify storefront meant unconditional\n * default-allow. Absence is no longer this provider's problem — it is only\n * selected when OneTrust is actually on the page, and absence is handled by\n * the gate's own default.\n */\n\nimport type { ConsentProvider, ConsentSnapshot } from '../types';\n\n/** OneTrust's default taxonomy: C0002 is the performance/analytics category. */\nconst ANALYTICS_CATEGORY = 'C0002';\n/** C0004 is targeting/advertising. */\nconst MARKETING_CATEGORY = 'C0004';\n\nconst readGroups = (): string | null => {\n if (typeof window === 'undefined') {\n return null;\n }\n const groups = (window as unknown as { OnetrustActiveGroups?: unknown })\n .OnetrustActiveGroups;\n return typeof groups === 'string' ? groups : null;\n};\n\nexport const isOneTrustHost = (): boolean => readGroups() !== null;\n\nconst readSnapshot = (): ConsentSnapshot => {\n const groups = readGroups();\n if (groups !== null) {\n try {\n console.log(`[w5-consent] onetrust: active groups \"${groups}\"`);\n } catch {\n /* never break on a console */\n }\n }\n if (groups === null) {\n return { analytics: 'unknown', marketing: 'unknown', performance: 'unknown' };\n }\n // OneTrust publishes the *active* groups, so a category that is absent from\n // a string OneTrust has written is a refusal, not silence.\n const analytics = groups.includes(ANALYTICS_CATEGORY) ? 'granted' : 'denied';\n const marketing = groups.includes(MARKETING_CATEGORY) ? 'granted' : 'denied';\n return { analytics, marketing, performance: analytics };\n};\n\nexport const createOneTrustConsentProvider = (): ConsentProvider => ({\n name: 'onetrust',\n\n read: readSnapshot,\n\n subscribe(onChange) {\n const publish = () => onChange(readSnapshot());\n if (typeof window === 'undefined') {\n return () => {};\n }\n // OneTrust fires this on every banner interaction.\n window.addEventListener('OneTrustGroupsUpdated', publish);\n return () => {\n window.removeEventListener('OneTrustGroupsUpdated', publish);\n };\n },\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA,MAAMA,kBAAkB,GAAG,OAAO;AAClC;AACA,MAAMC,kBAAkB,GAAG,OAAO;AAElC,MAAMC,UAAU,GAAGA,CAAA,KAAqB;EACtC,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;IACjC,OAAO,IAAI;EACb;EACA,MAAMC,MAAM,GAAID,MAAM,CACnBE,oBAAoB;EACvB,OAAO,OAAOD,MAAM,KAAK,QAAQ,GAAGA,MAAM,GAAG,IAAI;AACnD,CAAC;AAED,OAAO,MAAME,cAAc,GAAGA,CAAA,KAAeJ,UAAU,CAAC,CAAC,KAAK,IAAI;AAElE,MAAMK,YAAY,GAAGA,CAAA,KAAuB;EAC1C,MAAMH,MAAM,GAAGF,UAAU,CAAC,CAAC;EAC3B,IAAIE,MAAM,KAAK,IAAI,EAAE;IACnB,IAAI;MACFI,OAAO,CAACC,GAAG,CAAC,yCAAyCL,MAAM,GAAG,CAAC;IACjE,CAAC,CAAC,MAAM;MACN;IAAA;EAEJ;EACA,IAAIA,MAAM,KAAK,IAAI,EAAE;IACnB,OAAO;MAAEM,SAAS,EAAE,SAAS;MAAEC,SAAS,EAAE,SAAS;MAAEC,WAAW,EAAE;IAAU,CAAC;EAC/E;EACA;EACA;EACA,MAAMF,SAAS,GAAGN,MAAM,CAACS,QAAQ,CAACb,kBAAkB,CAAC,GAAG,SAAS,GAAG,QAAQ;EAC5E,MAAMW,SAAS,GAAGP,MAAM,CAACS,QAAQ,CAACZ,kBAAkB,CAAC,GAAG,SAAS,GAAG,QAAQ;EAC5E,OAAO;IAAES,SAAS;IAAEC,SAAS;IAAEC,WAAW,EAAEF;EAAU,CAAC;AACzD,CAAC;AAED,OAAO,MAAMI,6BAA6B,GAAGA,CAAA,MAAwB;EACnEC,IAAI,EAAE,UAAU;EAEhBC,IAAI,EAAET,YAAY;EAElBU,SAASA,CAACC,QAAQ,EAAE;IAClB,MAAMC,OAAO,GAAGA,CAAA,KAAMD,QAAQ,CAACX,YAAY,CAAC,CAAC,CAAC;IAC9C,IAAI,OAAOJ,MAAM,KAAK,WAAW,EAAE;MACjC,OAAO,MAAM,CAAC,CAAC;IACjB;IACA;IACAA,MAAM,CAACiB,gBAAgB,CAAC,uBAAuB,EAAED,OAAO,CAAC;IACzD,OAAO,MAAM;MACXhB,MAAM,CAACkB,mBAAmB,CAAC,uBAAuB,EAAEF,OAAO,CAAC;IAC9D,CAAC;EACH;AACF,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["ANALYTICS_CATEGORY","MARKETING_CATEGORY","readGroups","window","groups","OnetrustActiveGroups","isOneTrustHost","readSnapshot","console","debug","analytics","marketing","performance","includes","createOneTrustConsentProvider","name","read","subscribe","onChange","publish","addEventListener","removeEventListener"],"sources":["../../../../src/privacy/providers/oneTrustProvider.ts"],"sourcesContent":["/**\n * OneTrust provider — DL #218.\n *\n * Lifted from the consent check that used to live inside\n * `utils/analyticsEvents.ts`, with one deliberate behaviour change: that\n * function returned `true` when OneTrust was absent (\"host is responsible for\n * loading OneTrust\"), which on a Shopify storefront meant unconditional\n * default-allow. Absence is no longer this provider's problem — it is only\n * selected when OneTrust is actually on the page, and absence is handled by\n * the gate's own default.\n */\n\nimport type { ConsentProvider, ConsentSnapshot } from '../types';\n\n/** OneTrust's default taxonomy: C0002 is the performance/analytics category. */\nconst ANALYTICS_CATEGORY = 'C0002';\n/** C0004 is targeting/advertising. */\nconst MARKETING_CATEGORY = 'C0004';\n\nconst readGroups = (): string | null => {\n if (typeof window === 'undefined') {\n return null;\n }\n const groups = (window as unknown as { OnetrustActiveGroups?: unknown })\n .OnetrustActiveGroups;\n return typeof groups === 'string' ? groups : null;\n};\n\nexport const isOneTrustHost = (): boolean => readGroups() !== null;\n\nconst readSnapshot = (): ConsentSnapshot => {\n const groups = readGroups();\n if (groups !== null) {\n try {\n console.debug(`[w5-consent] onetrust: active groups \"${groups}\"`);\n } catch {\n /* never break on a console */\n }\n }\n if (groups === null) {\n return {\n analytics: 'unknown',\n marketing: 'unknown',\n performance: 'unknown',\n };\n }\n // OneTrust publishes the *active* groups, so a category that is absent from\n // a string OneTrust has written is a refusal, not silence.\n const analytics = groups.includes(ANALYTICS_CATEGORY) ? 'granted' : 'denied';\n const marketing = groups.includes(MARKETING_CATEGORY) ? 'granted' : 'denied';\n return { analytics, marketing, performance: analytics };\n};\n\nexport const createOneTrustConsentProvider = (): ConsentProvider => ({\n name: 'onetrust',\n\n read: readSnapshot,\n\n subscribe(onChange) {\n const publish = () => onChange(readSnapshot());\n if (typeof window === 'undefined') {\n return () => {};\n }\n // OneTrust fires this on every banner interaction.\n window.addEventListener('OneTrustGroupsUpdated', publish);\n return () => {\n window.removeEventListener('OneTrustGroupsUpdated', publish);\n };\n },\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA,MAAMA,kBAAkB,GAAG,OAAO;AAClC;AACA,MAAMC,kBAAkB,GAAG,OAAO;AAElC,MAAMC,UAAU,GAAGA,CAAA,KAAqB;EACtC,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;IACjC,OAAO,IAAI;EACb;EACA,MAAMC,MAAM,GAAID,MAAM,CACnBE,oBAAoB;EACvB,OAAO,OAAOD,MAAM,KAAK,QAAQ,GAAGA,MAAM,GAAG,IAAI;AACnD,CAAC;AAED,OAAO,MAAME,cAAc,GAAGA,CAAA,KAAeJ,UAAU,CAAC,CAAC,KAAK,IAAI;AAElE,MAAMK,YAAY,GAAGA,CAAA,KAAuB;EAC1C,MAAMH,MAAM,GAAGF,UAAU,CAAC,CAAC;EAC3B,IAAIE,MAAM,KAAK,IAAI,EAAE;IACnB,IAAI;MACFI,OAAO,CAACC,KAAK,CAAC,yCAAyCL,MAAM,GAAG,CAAC;IACnE,CAAC,CAAC,MAAM;MACN;IAAA;EAEJ;EACA,IAAIA,MAAM,KAAK,IAAI,EAAE;IACnB,OAAO;MACLM,SAAS,EAAE,SAAS;MACpBC,SAAS,EAAE,SAAS;MACpBC,WAAW,EAAE;IACf,CAAC;EACH;EACA;EACA;EACA,MAAMF,SAAS,GAAGN,MAAM,CAACS,QAAQ,CAACb,kBAAkB,CAAC,GAAG,SAAS,GAAG,QAAQ;EAC5E,MAAMW,SAAS,GAAGP,MAAM,CAACS,QAAQ,CAACZ,kBAAkB,CAAC,GAAG,SAAS,GAAG,QAAQ;EAC5E,OAAO;IAAES,SAAS;IAAEC,SAAS;IAAEC,WAAW,EAAEF;EAAU,CAAC;AACzD,CAAC;AAED,OAAO,MAAMI,6BAA6B,GAAGA,CAAA,MAAwB;EACnEC,IAAI,EAAE,UAAU;EAEhBC,IAAI,EAAET,YAAY;EAElBU,SAASA,CAACC,QAAQ,EAAE;IAClB,MAAMC,OAAO,GAAGA,CAAA,KAAMD,QAAQ,CAACX,YAAY,CAAC,CAAC,CAAC;IAC9C,IAAI,OAAOJ,MAAM,KAAK,WAAW,EAAE;MACjC,OAAO,MAAM,CAAC,CAAC;IACjB;IACA;IACAA,MAAM,CAACiB,gBAAgB,CAAC,uBAAuB,EAAED,OAAO,CAAC;IACzD,OAAO,MAAM;MACXhB,MAAM,CAACkB,mBAAmB,CAAC,uBAAuB,EAAEF,OAAO,CAAC;IAC9D,CAAC;EACH;AACF,CAAC,CAAC","ignoreList":[]}
@@ -31,7 +31,7 @@ const log = function () {
31
31
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
32
32
  args[_key] = arguments[_key];
33
33
  }
34
- console.log('[w5-consent] shopify:', ...args);
34
+ console.debug('[w5-consent] shopify:', ...args);
35
35
  } catch {
36
36
  /* never break on a console */
37
37
  }
@@ -44,8 +44,12 @@ const getShopify = () => {
44
44
  };
45
45
  export const isShopifyHost = () => getShopify() !== null;
46
46
  const toState = value => {
47
- if (value === 'yes') return 'granted';
48
- if (value === 'no') return 'denied';
47
+ if (value === 'yes') {
48
+ return 'granted';
49
+ }
50
+ if (value === 'no') {
51
+ return 'denied';
52
+ }
49
53
  return null;
50
54
  };
51
55
  const readSnapshot = () => {
@@ -1 +1 @@
1
- {"version":3,"names":["UNKNOWN_CONSENT","CONSENT_FEATURE","name","version","log","_len","arguments","length","args","Array","_key","console","getShopify","window","Shopify","isShopifyHost","toState","value","readSnapshot","_getShopify","privacy","customerPrivacy","consent","currentVisitorConsent","explicitAnalytics","analytics","explicitMarketing","marketing","allowed","analyticsProcessingAllowed","enforced","regulation","region","isRegulationEnforced","getRegulation","getRegion","bannerRequired","shouldShowBanner","permissiveDefault","fallbackWhenUnenforceable","performance","requestConsentApi","onReady","shopify","loadFeatures","error","createShopifyConsentProvider","read","subscribe","onChange","publish","document","addEventListener","removeEventListener"],"sources":["../../../../src/privacy/providers/shopifyProvider.ts"],"sourcesContent":["/**\n * Shopify Customer Privacy API provider — DL #218.\n *\n * Two things about this API shape the provider:\n *\n * 1. **It is not on the page by default.** `window.Shopify.customerPrivacy` is\n * `undefined` until somebody asks for it with `Shopify.loadFeatures`. The\n * theme app extension warms it so it is ready before the bundle mounts;\n * this provider still requests it, because the extension may not be\n * installed and the request is idempotent.\n *\n * 2. **`visitorConsentCollected` may have already fired.** The bundle executes\n * into an already-rendered storefront page (DL #217), so `read()` answers\n * from current state and the event is only ever an update.\n *\n * The region rule is the one judgement encoded here, and it keys off\n * `isRegulationEnforced()` rather than `shouldShowBanner()`. The two are not\n * interchangeable: the banner reflects what the *merchant* configured, while\n * enforcement reflects what the *visitor's jurisdiction* requires. A store with\n * an empty consent configuration reports \"no banner needed\" everywhere,\n * including inside the EU.\n */\n\nimport {\n UNKNOWN_CONSENT,\n type ConsentProvider,\n type ConsentSnapshot,\n type ConsentState,\n} from '../types';\n\ntype ShopifyConsentValue = 'yes' | 'no' | '' | undefined;\n\ninterface ShopifyVisitorConsent {\n analytics?: ShopifyConsentValue;\n marketing?: ShopifyConsentValue;\n preferences?: ShopifyConsentValue;\n sale_of_data?: ShopifyConsentValue;\n}\n\ninterface ShopifyCustomerPrivacy {\n analyticsProcessingAllowed?: () => boolean;\n marketingAllowed?: () => boolean;\n currentVisitorConsent?: () => ShopifyVisitorConsent;\n shouldShowBanner?: () => boolean;\n /** Whether a privacy regulation applies to this visitor's region. */\n isRegulationEnforced?: () => boolean;\n /** e.g. 'GDPR', 'CCPA'. */\n getRegulation?: () => string;\n /** e.g. 'DEBE' — country + subdivision. */\n getRegion?: () => string;\n}\n\ninterface ShopifyGlobal {\n customerPrivacy?: ShopifyCustomerPrivacy;\n loadFeatures?: (\n features: { name: string; version: string }[],\n callback: (error?: unknown) => void,\n ) => void;\n}\n\nconst CONSENT_FEATURE = { name: 'consent-tracking-api', version: '0.1' };\n\nconst log = (...args: unknown[]): void => {\n try {\n console.log('[w5-consent] shopify:', ...args);\n } catch {\n /* never break on a console */\n }\n};\n\nconst getShopify = (): ShopifyGlobal | null => {\n if (typeof window === 'undefined') {\n return null;\n }\n return (window as unknown as { Shopify?: ShopifyGlobal }).Shopify ?? null;\n};\n\nexport const isShopifyHost = (): boolean => getShopify() !== null;\n\nconst toState = (value: ShopifyConsentValue): ConsentState | null => {\n if (value === 'yes') return 'granted';\n if (value === 'no') return 'denied';\n return null;\n};\n\nconst readSnapshot = (): ConsentSnapshot => {\n const privacy = getShopify()?.customerPrivacy;\n if (!privacy) {\n log(\n 'customerPrivacy API not on the page — no answer available (store has no privacy configuration, or loadFeatures has not resolved yet)',\n );\n // The API has not loaded (or the store has no privacy configuration at\n // all). Not an answer — the gate holds, and the visitor's own action is\n // what unlocks the session.\n return UNKNOWN_CONSENT;\n }\n\n let consent: ShopifyVisitorConsent = {};\n try {\n consent = privacy.currentVisitorConsent?.() ?? {};\n } catch {\n // Present but not ready — treat as no answer yet.\n }\n\n const explicitAnalytics = toState(consent.analytics);\n const explicitMarketing = toState(consent.marketing);\n\n let allowed = false;\n try {\n allowed = privacy.analyticsProcessingAllowed?.() === true;\n } catch {\n allowed = false;\n }\n\n // Is a privacy regulation in force for *this visitor's* region? This is the\n // question that matters, and it is not the same question as \"is a banner\n // being shown\" — see the comment on `enforced` below.\n let enforced: boolean | null = null;\n let regulation = '';\n let region = '';\n try {\n if (typeof privacy.isRegulationEnforced === 'function') {\n enforced = privacy.isRegulationEnforced() === true;\n }\n regulation = privacy.getRegulation?.() ?? '';\n region = privacy.getRegion?.() ?? '';\n } catch {\n enforced = null;\n }\n\n let bannerRequired = true;\n try {\n bannerRequired = privacy.shouldShowBanner?.() !== false;\n } catch {\n bannerRequired = true;\n }\n\n /*\n * Measured on a live store from a Frankfurt IP, with no consent recorded:\n *\n * region 'DEBE' · regulation 'GDPR' · isRegulationEnforced() true\n * shouldShowBanner() false · analyticsProcessingAllowed() TRUE\n * getShopPrefs() { limit: [] }\n *\n * Shopify said tracking was allowed for a GDPR-protected visitor who had\n * never been asked, because the *merchant* had configured no consent\n * preferences. `shouldShowBanner()` and `analyticsProcessingAllowed()` both\n * describe the merchant's setup; neither is a statement about a legal basis.\n * A merchant's misconfiguration must not become our tracking decision, so\n * under an enforced regulation an absent answer stays `unknown` and the gate\n * holds — the visitor's own prompt is then the only thing that unlocks them.\n */\n const permissiveDefault = allowed || !bannerRequired;\n const fallbackWhenUnenforceable = permissiveDefault ? 'granted' : 'unknown';\n\n const analytics: ConsentState =\n explicitAnalytics ??\n (enforced === true ? 'unknown' : fallbackWhenUnenforceable);\n\n const marketing: ConsentState =\n explicitMarketing ??\n (enforced === true ? 'unknown' : !bannerRequired ? 'granted' : 'unknown');\n\n log(\n `read — visitorConsent.analytics=${consent.analytics ?? '(unset)'} ` +\n `analyticsProcessingAllowed=${allowed} bannerRequired=${bannerRequired} ` +\n `region=${region || '?'} regulation=${regulation || '?'} enforced=${\n enforced === null ? 'unavailable' : enforced\n }` +\n (enforced === true && explicitAnalytics === null\n ? ' → regulated and unanswered, holding'\n : '') +\n ` ⇒ ${analytics}`,\n );\n\n return {\n analytics,\n marketing,\n // Shopify has no separate performance bucket. Load telemetry carries an\n // app name and a session id to a Wix endpoint, so it answers to the same\n // answer analytics does rather than riding for free.\n performance: analytics,\n };\n};\n\n/**\n * Ask Shopify to load the consent API if it is not already there. Safe to call\n * more than once; the callback re-reads whatever state arrives.\n */\nconst requestConsentApi = (onReady: () => void): void => {\n const shopify = getShopify();\n if (!shopify || shopify.customerPrivacy || !shopify.loadFeatures) {\n return;\n }\n try {\n log('requesting consent-tracking-api via Shopify.loadFeatures…');\n shopify.loadFeatures([CONSENT_FEATURE], (error) => {\n if (error) {\n log('loadFeatures failed — gate stays held', error);\n return;\n }\n log('loadFeatures resolved — re-reading consent');\n onReady();\n });\n } catch {\n // Storefronts without the feature simply never resolve; the gate stays\n // held and engagement remains the only unlock.\n }\n};\n\nexport const createShopifyConsentProvider = (): ConsentProvider => ({\n name: 'shopify-customer-privacy',\n\n read: readSnapshot,\n\n subscribe(onChange) {\n const publish = () => {\n log('visitorConsentCollected — the visitor answered the banner');\n onChange(readSnapshot());\n };\n\n // The visitor may have answered the banner before this bundle existed, so\n // the event is an update — never the first read.\n if (typeof document !== 'undefined') {\n document.addEventListener('visitorConsentCollected', publish);\n }\n requestConsentApi(() => onChange(readSnapshot()));\n\n return () => {\n if (typeof document !== 'undefined') {\n document.removeEventListener('visitorConsentCollected', publish);\n }\n };\n },\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,eAAe,QAIV,UAAU;AAgCjB,MAAMC,eAAe,GAAG;EAAEC,IAAI,EAAE,sBAAsB;EAAEC,OAAO,EAAE;AAAM,CAAC;AAExE,MAAMC,GAAG,GAAG,SAAAA,CAAA,EAA8B;EACxC,IAAI;IAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EADUC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;MAAJF,IAAI,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;IAAA;IAEhBC,OAAO,CAACP,GAAG,CAAC,uBAAuB,EAAE,GAAGI,IAAI,CAAC;EAC/C,CAAC,CAAC,MAAM;IACN;EAAA;AAEJ,CAAC;AAED,MAAMI,UAAU,GAAGA,CAAA,KAA4B;EAC7C,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;IACjC,OAAO,IAAI;EACb;EACA,OAAQA,MAAM,CAA4CC,OAAO,IAAI,IAAI;AAC3E,CAAC;AAED,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAeH,UAAU,CAAC,CAAC,KAAK,IAAI;AAEjE,MAAMI,OAAO,GAAIC,KAA0B,IAA0B;EACnE,IA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args","Array","_key","console","debug","getShopify","window","Shopify","isShopifyHost","toState","value","readSnapshot","_getShopify","privacy","customerPrivacy","consent","currentVisitorConsent","explicitAnalytics","analytics","explicitMarketing","marketing","allowed","analyticsProcessingAllowed","enforced","regulation","region","isRegulationEnforced","getRegulation","getRegion","bannerRequired","shouldShowBanner","permissiveDefault","fallbackWhenUnenforceable","performance","requestConsentApi","onReady","shopify","loadFeatures","error","createShopifyConsentProvider","read","subscribe","onChange","publish","document","addEventListener","removeEventListener"],"sources":["../../../../src/privacy/providers/shopifyProvider.ts"],"sourcesContent":["/**\n * Shopify Customer Privacy API provider — DL #218.\n *\n * Two things about this API shape the provider:\n *\n * 1. **It is not on the page by default.** `window.Shopify.customerPrivacy` is\n * `undefined` until somebody asks for it with `Shopify.loadFeatures`. The\n * theme app extension warms it so it is ready before the bundle mounts;\n * this provider still requests it, because the extension may not be\n * installed and the request is idempotent.\n *\n * 2. **`visitorConsentCollected` may have already fired.** The bundle executes\n * into an already-rendered storefront page (DL #217), so `read()` answers\n * from current state and the event is only ever an update.\n *\n * The region rule is the one judgement encoded here, and it keys off\n * `isRegulationEnforced()` rather than `shouldShowBanner()`. The two are not\n * interchangeable: the banner reflects what the *merchant* configured, while\n * enforcement reflects what the *visitor's jurisdiction* requires. A store with\n * an empty consent configuration reports \"no banner needed\" everywhere,\n * including inside the EU.\n */\n\nimport {\n UNKNOWN_CONSENT,\n type ConsentProvider,\n type ConsentSnapshot,\n type ConsentState,\n} from '../types';\n\ntype ShopifyConsentValue = 'yes' | 'no' | '' | undefined;\n\ninterface ShopifyVisitorConsent {\n analytics?: ShopifyConsentValue;\n marketing?: ShopifyConsentValue;\n preferences?: ShopifyConsentValue;\n sale_of_data?: ShopifyConsentValue;\n}\n\ninterface ShopifyCustomerPrivacy {\n analyticsProcessingAllowed?: () => boolean;\n marketingAllowed?: () => boolean;\n currentVisitorConsent?: () => ShopifyVisitorConsent;\n shouldShowBanner?: () => boolean;\n /** Whether a privacy regulation applies to this visitor's region. */\n isRegulationEnforced?: () => boolean;\n /** e.g. 'GDPR', 'CCPA'. */\n getRegulation?: () => string;\n /** e.g. 'DEBE' — country + subdivision. */\n getRegion?: () => string;\n}\n\ninterface ShopifyGlobal {\n customerPrivacy?: ShopifyCustomerPrivacy;\n loadFeatures?: (\n features: { name: string; version: string }[],\n callback: (error?: unknown) => void,\n ) => void;\n}\n\nconst CONSENT_FEATURE = { name: 'consent-tracking-api', version: '0.1' };\n\nconst log = (...args: unknown[]): void => {\n try {\n console.debug('[w5-consent] shopify:', ...args);\n } catch {\n /* never break on a console */\n }\n};\n\nconst getShopify = (): ShopifyGlobal | null => {\n if (typeof window === 'undefined') {\n return null;\n }\n return (window as unknown as { Shopify?: ShopifyGlobal }).Shopify ?? null;\n};\n\nexport const isShopifyHost = (): boolean => getShopify() !== null;\n\nconst toState = (value: ShopifyConsentValue): ConsentState | null => {\n if (value === 'yes') {\n return 'granted';\n }\n if (value === 'no') {\n return 'denied';\n }\n return null;\n};\n\nconst readSnapshot = (): ConsentSnapshot => {\n const privacy = getShopify()?.customerPrivacy;\n if (!privacy) {\n log(\n 'customerPrivacy API not on the page — no answer available (store has no privacy configuration, or loadFeatures has not resolved yet)',\n );\n // The API has not loaded (or the store has no privacy configuration at\n // all). Not an answer — the gate holds, and the visitor's own action is\n // what unlocks the session.\n return UNKNOWN_CONSENT;\n }\n\n let consent: ShopifyVisitorConsent = {};\n try {\n consent = privacy.currentVisitorConsent?.() ?? {};\n } catch {\n // Present but not ready — treat as no answer yet.\n }\n\n const explicitAnalytics = toState(consent.analytics);\n const explicitMarketing = toState(consent.marketing);\n\n let allowed = false;\n try {\n allowed = privacy.analyticsProcessingAllowed?.() === true;\n } catch {\n allowed = false;\n }\n\n // Is a privacy regulation in force for *this visitor's* region? This is the\n // question that matters, and it is not the same question as \"is a banner\n // being shown\" — see the comment on `enforced` below.\n let enforced: boolean | null = null;\n let regulation = '';\n let region = '';\n try {\n if (typeof privacy.isRegulationEnforced === 'function') {\n enforced = privacy.isRegulationEnforced() === true;\n }\n regulation = privacy.getRegulation?.() ?? '';\n region = privacy.getRegion?.() ?? '';\n } catch {\n enforced = null;\n }\n\n let bannerRequired = true;\n try {\n bannerRequired = privacy.shouldShowBanner?.() !== false;\n } catch {\n bannerRequired = true;\n }\n\n /*\n * Measured on a live store from a Frankfurt IP, with no consent recorded:\n *\n * region 'DEBE' · regulation 'GDPR' · isRegulationEnforced() true\n * shouldShowBanner() false · analyticsProcessingAllowed() TRUE\n * getShopPrefs() { limit: [] }\n *\n * Shopify said tracking was allowed for a GDPR-protected visitor who had\n * never been asked, because the *merchant* had configured no consent\n * preferences. `shouldShowBanner()` and `analyticsProcessingAllowed()` both\n * describe the merchant's setup; neither is a statement about a legal basis.\n * A merchant's misconfiguration must not become our tracking decision, so\n * under an enforced regulation an absent answer stays `unknown` and the gate\n * holds — the visitor's own prompt is then the only thing that unlocks them.\n */\n const permissiveDefault = allowed || !bannerRequired;\n const fallbackWhenUnenforceable = permissiveDefault ? 'granted' : 'unknown';\n\n const analytics: ConsentState =\n explicitAnalytics ??\n (enforced === true ? 'unknown' : fallbackWhenUnenforceable);\n\n const marketing: ConsentState =\n explicitMarketing ??\n (enforced === true ? 'unknown' : !bannerRequired ? 'granted' : 'unknown');\n\n log(\n `read — visitorConsent.analytics=${consent.analytics ?? '(unset)'} ` +\n `analyticsProcessingAllowed=${allowed} bannerRequired=${bannerRequired} ` +\n `region=${region || '?'} regulation=${regulation || '?'} enforced=${\n enforced === null ? 'unavailable' : enforced\n }` +\n (enforced === true && explicitAnalytics === null\n ? ' → regulated and unanswered, holding'\n : '') +\n ` ⇒ ${analytics}`,\n );\n\n return {\n analytics,\n marketing,\n // Shopify has no separate performance bucket. Load telemetry carries an\n // app name and a session id to a Wix endpoint, so it answers to the same\n // answer analytics does rather than riding for free.\n performance: analytics,\n };\n};\n\n/**\n * Ask Shopify to load the consent API if it is not already there. Safe to call\n * more than once; the callback re-reads whatever state arrives.\n */\nconst requestConsentApi = (onReady: () => void): void => {\n const shopify = getShopify();\n if (!shopify || shopify.customerPrivacy || !shopify.loadFeatures) {\n return;\n }\n try {\n log('requesting consent-tracking-api via Shopify.loadFeatures…');\n shopify.loadFeatures([CONSENT_FEATURE], (error) => {\n if (error) {\n log('loadFeatures failed — gate stays held', error);\n return;\n }\n log('loadFeatures resolved — re-reading consent');\n onReady();\n });\n } catch {\n // Storefronts without the feature simply never resolve; the gate stays\n // held and engagement remains the only unlock.\n }\n};\n\nexport const createShopifyConsentProvider = (): ConsentProvider => ({\n name: 'shopify-customer-privacy',\n\n read: readSnapshot,\n\n subscribe(onChange) {\n const publish = () => {\n log('visitorConsentCollected — the visitor answered the banner');\n onChange(readSnapshot());\n };\n\n // The visitor may have answered the banner before this bundle existed, so\n // the event is an update — never the first read.\n if (typeof document !== 'undefined') {\n document.addEventListener('visitorConsentCollected', publish);\n }\n requestConsentApi(() => onChange(readSnapshot()));\n\n return () => {\n if (typeof document !== 'undefined') {\n document.removeEventListener('visitorConsentCollected', publish);\n }\n };\n },\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,eAAe,QAIV,UAAU;AAgCjB,MAAMC,eAAe,GAAG;EAAEC,IAAI,EAAE,sBAAsB;EAAEC,OAAO,EAAE;AAAM,CAAC;AAExE,MAAMC,GAAG,GAAG,SAAAA,CAAA,EAA8B;EACxC,IAAI;IAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EADUC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;MAAJF,IAAI,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;IAAA;IAEhBC,OAAO,CAACC,KAAK,CAAC,uBAAuB,EAAE,GAAGJ,IAAI,CAAC;EACjD,CAAC,CAAC,MAAM;IACN;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C;AAiBF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,SAAU,eAAe,KAAG,IAO9D,CAAC;AAEF,eAAO,MAAM,wBAAwB,QAAO,MAAM,GAAG,IAC7B,CAAC;AAEzB,eAAO,MAAM,qBAAqB,UAAW,MAAM,KAAG,IAErD,CAAC;AAEF,gFAAgF;AAChF,eAAO,MAAM,mBAAmB,QAAO;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB,MAAM,CAAC;CACqB,CAAC;AAEpD,eAAO,MAAM,wBAAwB,QAAO,IAW3C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"hostSuppliedProvider.d.ts","sourceRoot":"","sources":["../../../../src/privacy/providers/hostSuppliedProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAEL,KAAK,eAAe,EAEpB,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AAEtD,iEAAiE;AACjE,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC;IACnC,SAAS,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC;IACnC,WAAW,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC;CACtC;AAkCD,eAAO,MAAM,sBAAsB,QAAO,OAMzC,CAAC;AAKF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,UAAW,gBAAgB,KAAG,IAK5D,CAAC;AAEF,eAAO,MAAM,iCAAiC,QAAO,eAWnD,CAAC;AAEH,eAAO,MAAM,0BAA0B,QAAO,IAG7C,CAAC"}
1
+ {"version":3,"file":"hostSuppliedProvider.d.ts","sourceRoot":"","sources":["../../../../src/privacy/providers/hostSuppliedProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAEL,KAAK,eAAe,EAEpB,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AAEtD,iEAAiE;AACjE,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC;IACnC,SAAS,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC;IACnC,WAAW,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC;CACtC;AA0CD,eAAO,MAAM,sBAAsB,QAAO,OAQzC,CAAC;AAKF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,UAAW,gBAAgB,KAAG,IAK5D,CAAC;AAEF,eAAO,MAAM,iCAAiC,QAAO,eAWnD,CAAC;AAEH,eAAO,MAAM,0BAA0B,QAAO,IAG7C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"oneTrustProvider.d.ts","sourceRoot":"","sources":["../../../../src/privacy/providers/oneTrustProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,UAAU,CAAC;AAgBjE,eAAO,MAAM,cAAc,QAAO,OAAgC,CAAC;AAqBnE,eAAO,MAAM,6BAA6B,QAAO,eAgB/C,CAAC"}
1
+ {"version":3,"file":"oneTrustProvider.d.ts","sourceRoot":"","sources":["../../../../src/privacy/providers/oneTrustProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,UAAU,CAAC;AAgBjE,eAAO,MAAM,cAAc,QAAO,OAAgC,CAAC;AAyBnE,eAAO,MAAM,6BAA6B,QAAO,eAgB/C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"shopifyProvider.d.ts","sourceRoot":"","sources":["../../../../src/privacy/providers/shopifyProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAEL,KAAK,eAAe,EAGrB,MAAM,UAAU,CAAC;AAiDlB,eAAO,MAAM,aAAa,QAAO,OAAgC,CAAC;AAqIlE,eAAO,MAAM,4BAA4B,QAAO,eAwB9C,CAAC"}
1
+ {"version":3,"file":"shopifyProvider.d.ts","sourceRoot":"","sources":["../../../../src/privacy/providers/shopifyProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAEL,KAAK,eAAe,EAGrB,MAAM,UAAU,CAAC;AAiDlB,eAAO,MAAM,aAAa,QAAO,OAAgC,CAAC;AAyIlE,eAAO,MAAM,4BAA4B,QAAO,eAwB9C,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wix/web5-core",
3
3
  "license": "MIT",
4
- "version": "1.63.17",
4
+ "version": "1.63.18",
5
5
  "author": {
6
6
  "name": "tsachis",
7
7
  "email": "tsachis@wix.com"
@@ -100,5 +100,5 @@
100
100
  "wallaby": {
101
101
  "autoDetect": true
102
102
  },
103
- "falconPackageHash": "98eb3be073efd8e590f6f5c070fddc2f057b9af8dca165089623899c"
103
+ "falconPackageHash": "f8f308fde8424dad1460ce80f953015f5637c89178f2f507163b0a92"
104
104
  }