@wix/web5-core 1.63.48 → 1.63.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/cjs/index.js +4 -26
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/esm/index.js +0 -3
  4. package/dist/esm/index.js.map +1 -1
  5. package/dist/types/index.d.ts +0 -1
  6. package/dist/types/index.d.ts.map +1 -1
  7. package/package.json +2 -2
  8. package/dist/cjs/privacy/consentGate.js +0 -129
  9. package/dist/cjs/privacy/consentGate.js.map +0 -1
  10. package/dist/cjs/privacy/consentOverride.js +0 -94
  11. package/dist/cjs/privacy/consentOverride.js.map +0 -1
  12. package/dist/cjs/privacy/detectProvider.js +0 -71
  13. package/dist/cjs/privacy/detectProvider.js.map +0 -1
  14. package/dist/cjs/privacy/index.js +0 -33
  15. package/dist/cjs/privacy/index.js.map +0 -1
  16. package/dist/cjs/privacy/providers/hostSuppliedProvider.js +0 -93
  17. package/dist/cjs/privacy/providers/hostSuppliedProvider.js.map +0 -1
  18. package/dist/cjs/privacy/providers/oneTrustProvider.js +0 -72
  19. package/dist/cjs/privacy/providers/oneTrustProvider.js.map +0 -1
  20. package/dist/cjs/privacy/providers/shopifyProvider.js +0 -181
  21. package/dist/cjs/privacy/providers/shopifyProvider.js.map +0 -1
  22. package/dist/cjs/privacy/types.js +0 -34
  23. package/dist/cjs/privacy/types.js.map +0 -1
  24. package/dist/esm/privacy/consentGate.js +0 -122
  25. package/dist/esm/privacy/consentGate.js.map +0 -1
  26. package/dist/esm/privacy/consentOverride.js +0 -87
  27. package/dist/esm/privacy/consentOverride.js.map +0 -1
  28. package/dist/esm/privacy/detectProvider.js +0 -65
  29. package/dist/esm/privacy/detectProvider.js.map +0 -1
  30. package/dist/esm/privacy/index.js +0 -8
  31. package/dist/esm/privacy/index.js.map +0 -1
  32. package/dist/esm/privacy/providers/hostSuppliedProvider.js +0 -85
  33. package/dist/esm/privacy/providers/hostSuppliedProvider.js.map +0 -1
  34. package/dist/esm/privacy/providers/oneTrustProvider.js +0 -66
  35. package/dist/esm/privacy/providers/oneTrustProvider.js.map +0 -1
  36. package/dist/esm/privacy/providers/shopifyProvider.js +0 -178
  37. package/dist/esm/privacy/providers/shopifyProvider.js.map +0 -1
  38. package/dist/esm/privacy/types.js +0 -30
  39. package/dist/esm/privacy/types.js.map +0 -1
  40. package/dist/types/privacy/consentGate.d.ts +0 -52
  41. package/dist/types/privacy/consentGate.d.ts.map +0 -1
  42. package/dist/types/privacy/consentOverride.d.ts +0 -33
  43. package/dist/types/privacy/consentOverride.d.ts.map +0 -1
  44. package/dist/types/privacy/detectProvider.d.ts +0 -25
  45. package/dist/types/privacy/detectProvider.d.ts.map +0 -1
  46. package/dist/types/privacy/index.d.ts +0 -8
  47. package/dist/types/privacy/index.d.ts.map +0 -1
  48. package/dist/types/privacy/providers/hostSuppliedProvider.d.ts +0 -29
  49. package/dist/types/privacy/providers/hostSuppliedProvider.d.ts.map +0 -1
  50. package/dist/types/privacy/providers/oneTrustProvider.d.ts +0 -15
  51. package/dist/types/privacy/providers/oneTrustProvider.d.ts.map +0 -1
  52. package/dist/types/privacy/providers/shopifyProvider.d.ts +0 -26
  53. package/dist/types/privacy/providers/shopifyProvider.d.ts.map +0 -1
  54. package/dist/types/privacy/types.d.ts +0 -32
  55. package/dist/types/privacy/types.d.ts.map +0 -1
@@ -1,85 +0,0 @@
1
- /**
2
- * Host-supplied provider — DL #218.
3
- *
4
- * The escape hatch for every CMP we cannot detect: a host page that already
5
- * knows its visitor's answer publishes it, and the gate believes it. This is
6
- * how Circana, feature.com and any merchant on Cookiebot/Osano/Klaviyo reach
7
- * the gate without web5 learning each vendor's API.
8
- *
9
- * Two ways in, because hosts differ in when they know:
10
- * - `window.__web5_consent__` set before the bundle loads, read at install
11
- * - `publishHostConsent()` called at any time afterwards
12
- */
13
-
14
- import { UNKNOWN_CONSENT } from '../types.js';
15
- export const HOST_CONSENT_GLOBAL = '__web5_consent__';
16
-
17
- /** What a host may publish. Anything missing stays `unknown`. */
18
-
19
- const coerce = value => {
20
- if (value === true) {
21
- return 'granted';
22
- }
23
- if (value === false) {
24
- return 'denied';
25
- }
26
- if (value === 'granted' || value === 'denied' || value === 'unknown') {
27
- return value;
28
- }
29
- return 'unknown';
30
- };
31
- const normalize = input => {
32
- if (!input || typeof input !== 'object') {
33
- return UNKNOWN_CONSENT;
34
- }
35
- const analytics = coerce(input.analytics);
36
- return {
37
- analytics,
38
- marketing: coerce(input.marketing),
39
- // A host that speaks only about analytics is taken to mean the same for
40
- // load telemetry, which is the same wire and the same recipient.
41
- performance: input.performance === undefined ? analytics : coerce(input.performance)
42
- };
43
- };
44
- const readGlobal = () => {
45
- if (typeof window === 'undefined') {
46
- return UNKNOWN_CONSENT;
47
- }
48
- const raw = window[HOST_CONSENT_GLOBAL];
49
- return normalize(raw);
50
- };
51
- export const hasHostSuppliedConsent = () => {
52
- if (typeof window === 'undefined') {
53
- return false;
54
- }
55
- const raw = window[HOST_CONSENT_GLOBAL];
56
- return !!raw && typeof raw === 'object';
57
- };
58
- const subscribers = new Set();
59
- let published = null;
60
-
61
- /**
62
- * Called by the host — directly, or by the loader when it is handed consent in
63
- * its boot options — whenever the visitor's answer is known or changes.
64
- */
65
- export const publishHostConsent = input => {
66
- published = normalize(input);
67
- for (const subscriber of subscribers) {
68
- subscriber(published);
69
- }
70
- };
71
- export const createHostSuppliedConsentProvider = () => ({
72
- name: 'host-supplied',
73
- read: () => published ?? readGlobal(),
74
- subscribe(onChange) {
75
- subscribers.add(onChange);
76
- return () => {
77
- subscribers.delete(onChange);
78
- };
79
- }
80
- });
81
- export const __resetHostConsentForTests = () => {
82
- published = null;
83
- subscribers.clear();
84
- };
85
- //# sourceMappingURL=hostSuppliedProvider.js.map
@@ -1 +0,0 @@
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,KAAK,SAAS,EAAE;IACpE,OAAOA,KAAK;EACd;EACA,OAAO,SAAS;AAClB,CAAC;AAED,MAAMC,SAAS,GACbC,KAA0C,IACtB;EACpB,IAAI,CAACA,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IACvC,OAAOL,eAAe;EACxB;EACA,MAAMM,SAAS,GAAGJ,MAAM,CAACG,KAAK,CAACC,SAAS,CAAC;EACzC,OAAO;IACLA,SAAS;IACTC,SAAS,EAAEL,MAAM,CAACG,KAAK,CAACE,SAAS,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AAY;EACpDV,SAAS,GAAG,IAAI;EAChBF,WAAW,CAACa,KAAK,CAAC,CAAC;AACrB,CAAC","ignoreList":[]}
@@ -1,66 +0,0 @@
1
- /**
2
- * OneTrust provider — DL #218.
3
- *
4
- * Lifted from the consent check that used to live inside
5
- * `utils/analyticsEvents.ts`, with one deliberate behaviour change: that
6
- * function returned `true` when OneTrust was absent ("host is responsible for
7
- * loading OneTrust"), which on a Shopify storefront meant unconditional
8
- * default-allow. Absence is no longer this provider's problem — it is only
9
- * selected when OneTrust is actually on the page, and absence is handled by
10
- * the gate's own default.
11
- */
12
-
13
- /** OneTrust's default taxonomy: C0002 is the performance/analytics category. */
14
- const ANALYTICS_CATEGORY = 'C0002';
15
- /** C0004 is targeting/advertising. */
16
- const MARKETING_CATEGORY = 'C0004';
17
- const readGroups = () => {
18
- if (typeof window === 'undefined') {
19
- return null;
20
- }
21
- const groups = window.OnetrustActiveGroups;
22
- return typeof groups === 'string' ? groups : null;
23
- };
24
- export const isOneTrustHost = () => readGroups() !== null;
25
- const readSnapshot = () => {
26
- const groups = readGroups();
27
- if (groups !== null) {
28
- try {
29
- console.debug(`[w5-consent] onetrust: active groups "${groups}"`);
30
- } catch {
31
- /* never break on a console */
32
- }
33
- }
34
- if (groups === null) {
35
- return {
36
- analytics: 'unknown',
37
- marketing: 'unknown',
38
- performance: 'unknown'
39
- };
40
- }
41
- // OneTrust publishes the *active* groups, so a category that is absent from
42
- // a string OneTrust has written is a refusal, not silence.
43
- const analytics = groups.includes(ANALYTICS_CATEGORY) ? 'granted' : 'denied';
44
- const marketing = groups.includes(MARKETING_CATEGORY) ? 'granted' : 'denied';
45
- return {
46
- analytics,
47
- marketing,
48
- performance: analytics
49
- };
50
- };
51
- export const createOneTrustConsentProvider = () => ({
52
- name: 'onetrust',
53
- read: readSnapshot,
54
- subscribe(onChange) {
55
- const publish = () => onChange(readSnapshot());
56
- if (typeof window === 'undefined') {
57
- return () => {};
58
- }
59
- // OneTrust fires this on every banner interaction.
60
- window.addEventListener('OneTrustGroupsUpdated', publish);
61
- return () => {
62
- window.removeEventListener('OneTrustGroupsUpdated', publish);
63
- };
64
- }
65
- });
66
- //# sourceMappingURL=oneTrustProvider.js.map
@@ -1 +0,0 @@
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":[]}
@@ -1,178 +0,0 @@
1
- /**
2
- * Shopify Customer Privacy API provider — DL #218.
3
- *
4
- * Two things about this API shape the provider:
5
- *
6
- * 1. **It is not on the page by default.** `window.Shopify.customerPrivacy` is
7
- * `undefined` until somebody asks for it with `Shopify.loadFeatures`. The
8
- * theme app extension warms it so it is ready before the bundle mounts;
9
- * this provider still requests it, because the extension may not be
10
- * installed and the request is idempotent.
11
- *
12
- * 2. **`visitorConsentCollected` may have already fired.** The bundle executes
13
- * into an already-rendered storefront page (DL #217), so `read()` answers
14
- * from current state and the event is only ever an update.
15
- *
16
- * The region rule is the one judgement encoded here, and it keys off
17
- * `isRegulationEnforced()` rather than `shouldShowBanner()`. The two are not
18
- * interchangeable: the banner reflects what the *merchant* configured, while
19
- * enforcement reflects what the *visitor's jurisdiction* requires. A store with
20
- * an empty consent configuration reports "no banner needed" everywhere,
21
- * including inside the EU.
22
- */
23
-
24
- import { UNKNOWN_CONSENT } from '../types.js';
25
- const CONSENT_FEATURE = {
26
- name: 'consent-tracking-api',
27
- version: '0.1'
28
- };
29
- const log = function () {
30
- try {
31
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
32
- args[_key] = arguments[_key];
33
- }
34
- console.debug('[w5-consent] shopify:', ...args);
35
- } catch {
36
- /* never break on a console */
37
- }
38
- };
39
- const getShopify = () => {
40
- if (typeof window === 'undefined') {
41
- return null;
42
- }
43
- return window.Shopify ?? null;
44
- };
45
- export const isShopifyHost = () => getShopify() !== null;
46
- const toState = value => {
47
- if (value === 'yes') {
48
- return 'granted';
49
- }
50
- if (value === 'no') {
51
- return 'denied';
52
- }
53
- return null;
54
- };
55
- const readSnapshot = () => {
56
- var _getShopify;
57
- const privacy = (_getShopify = getShopify()) == null ? void 0 : _getShopify.customerPrivacy;
58
- if (!privacy) {
59
- log('customerPrivacy API not on the page — no answer available (store has no privacy configuration, or loadFeatures has not resolved yet)');
60
- // The API has not loaded (or the store has no privacy configuration at
61
- // all). Not an answer — the gate holds, and the visitor's own action is
62
- // what unlocks the session.
63
- return UNKNOWN_CONSENT;
64
- }
65
- let consent = {};
66
- try {
67
- consent = (privacy.currentVisitorConsent == null ? void 0 : privacy.currentVisitorConsent()) ?? {};
68
- } catch {
69
- // Present but not ready — treat as no answer yet.
70
- }
71
- const explicitAnalytics = toState(consent.analytics);
72
- const explicitMarketing = toState(consent.marketing);
73
- let allowed = false;
74
- try {
75
- allowed = (privacy.analyticsProcessingAllowed == null ? void 0 : privacy.analyticsProcessingAllowed()) === true;
76
- } catch {
77
- allowed = false;
78
- }
79
-
80
- // Is a privacy regulation in force for *this visitor's* region? This is the
81
- // question that matters, and it is not the same question as "is a banner
82
- // being shown" — see the comment on `enforced` below.
83
- let enforced = null;
84
- let regulation = '';
85
- let region = '';
86
- try {
87
- if (typeof privacy.isRegulationEnforced === 'function') {
88
- enforced = privacy.isRegulationEnforced() === true;
89
- }
90
- regulation = (privacy.getRegulation == null ? void 0 : privacy.getRegulation()) ?? '';
91
- region = (privacy.getRegion == null ? void 0 : privacy.getRegion()) ?? '';
92
- } catch {
93
- enforced = null;
94
- }
95
- let bannerRequired = true;
96
- try {
97
- bannerRequired = (privacy.shouldShowBanner == null ? void 0 : privacy.shouldShowBanner()) !== false;
98
- } catch {
99
- bannerRequired = true;
100
- }
101
-
102
- /*
103
- * Measured on a live store from a Frankfurt IP, with no consent recorded:
104
- *
105
- * region 'DEBE' · regulation 'GDPR' · isRegulationEnforced() true
106
- * shouldShowBanner() false · analyticsProcessingAllowed() TRUE
107
- * getShopPrefs() { limit: [] }
108
- *
109
- * Shopify said tracking was allowed for a GDPR-protected visitor who had
110
- * never been asked, because the *merchant* had configured no consent
111
- * preferences. `shouldShowBanner()` and `analyticsProcessingAllowed()` both
112
- * describe the merchant's setup; neither is a statement about a legal basis.
113
- * A merchant's misconfiguration must not become our tracking decision, so
114
- * under an enforced regulation an absent answer stays `unknown` and the gate
115
- * holds — the visitor's own prompt is then the only thing that unlocks them.
116
- */
117
- const permissiveDefault = allowed || !bannerRequired;
118
- const fallbackWhenUnenforceable = permissiveDefault ? 'granted' : 'unknown';
119
- const analytics = explicitAnalytics ?? (enforced === true ? 'unknown' : fallbackWhenUnenforceable);
120
- const marketing = explicitMarketing ?? (enforced === true ? 'unknown' : !bannerRequired ? 'granted' : 'unknown');
121
- log(`read — visitorConsent.analytics=${consent.analytics ?? '(unset)'} ` + `analyticsProcessingAllowed=${allowed} bannerRequired=${bannerRequired} ` + `region=${region || '?'} regulation=${regulation || '?'} enforced=${enforced === null ? 'unavailable' : enforced}` + (enforced === true && explicitAnalytics === null ? ' → regulated and unanswered, holding' : '') + ` ⇒ ${analytics}`);
122
- return {
123
- analytics,
124
- marketing,
125
- // Shopify has no separate performance bucket. Load telemetry carries an
126
- // app name and a session id to a Wix endpoint, so it answers to the same
127
- // answer analytics does rather than riding for free.
128
- performance: analytics
129
- };
130
- };
131
-
132
- /**
133
- * Ask Shopify to load the consent API if it is not already there. Safe to call
134
- * more than once; the callback re-reads whatever state arrives.
135
- */
136
- const requestConsentApi = onReady => {
137
- const shopify = getShopify();
138
- if (!shopify || shopify.customerPrivacy || !shopify.loadFeatures) {
139
- return;
140
- }
141
- try {
142
- log('requesting consent-tracking-api via Shopify.loadFeatures…');
143
- shopify.loadFeatures([CONSENT_FEATURE], error => {
144
- if (error) {
145
- log('loadFeatures failed — gate stays held', error);
146
- return;
147
- }
148
- log('loadFeatures resolved — re-reading consent');
149
- onReady();
150
- });
151
- } catch {
152
- // Storefronts without the feature simply never resolve; the gate stays
153
- // held and engagement remains the only unlock.
154
- }
155
- };
156
- export const createShopifyConsentProvider = () => ({
157
- name: 'shopify-customer-privacy',
158
- read: readSnapshot,
159
- subscribe(onChange) {
160
- const publish = () => {
161
- log('visitorConsentCollected — the visitor answered the banner');
162
- onChange(readSnapshot());
163
- };
164
-
165
- // The visitor may have answered the banner before this bundle existed, so
166
- // the event is an update — never the first read.
167
- if (typeof document !== 'undefined') {
168
- document.addEventListener('visitorConsentCollected', publish);
169
- }
170
- requestConsentApi(() => onChange(readSnapshot()));
171
- return () => {
172
- if (typeof document !== 'undefined') {
173
- document.removeEventListener('visitorConsentCollected', publish);
174
- }
175
- };
176
- }
177
- });
178
- //# sourceMappingURL=shopifyProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["UNKNOWN_CONSENT","CONSENT_FEATURE","name","version","log","_len","arguments","length","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;EAAA;AAEJ,CAAC;AAED,MAAMK,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,IAAIA,KAAK,KAAK,KAAK,EAAE;IAC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, because "we have not been told" is not the same
5
- * answer as "no" and must not be collapsed into one: a visitor who has not
6
- * been asked can still be unlocked by their own action, a visitor who
7
- * refused never can.
8
- */
9
-
10
- /**
11
- * `necessary` is never gated — auth tokens and the configuration fetch are
12
- * what make the widget work at all, and a visitor who loaded the page asked
13
- * for that much. Everything else answers to the gate.
14
- */
15
-
16
- export const UNKNOWN_CONSENT = Object.freeze({
17
- performance: 'unknown',
18
- analytics: 'unknown',
19
- marketing: 'unknown'
20
- });
21
-
22
- /**
23
- * A consent provider adapts one host's CMP to the gate.
24
- *
25
- * `read()` must answer synchronously with what is known *now*. Providers are
26
- * installed into an already-rendered storefront page (DL #217), so a provider
27
- * that only subscribes is inert — the event it waits for may have fired long
28
- * before the bundle executed. Always read first, then subscribe.
29
- */
30
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["UNKNOWN_CONSENT","Object","freeze","performance","analytics","marketing"],"sources":["../../../src/privacy/types.ts"],"sourcesContent":["/**\n * Consent vocabulary shared by the gate and every provider.\n *\n * DL #218. Three states, because \"we have not been told\" is not the same\n * answer as \"no\" and must not be collapsed into one: a visitor who has not\n * been asked can still be unlocked by their own action, a visitor who\n * refused never can.\n */\n\nexport type ConsentState = 'granted' | 'denied' | 'unknown';\n\n/**\n * `necessary` is never gated — auth tokens and the configuration fetch are\n * what make the widget work at all, and a visitor who loaded the page asked\n * for that much. Everything else answers to the gate.\n */\nexport type ConsentPurpose =\n | 'necessary'\n | 'performance'\n | 'analytics'\n | 'marketing';\n\nexport type GatedPurpose = Exclude<ConsentPurpose, 'necessary'>;\n\nexport type ConsentSnapshot = Record<GatedPurpose, ConsentState>;\n\nexport const UNKNOWN_CONSENT: ConsentSnapshot = Object.freeze({\n performance: 'unknown',\n analytics: 'unknown',\n marketing: 'unknown',\n});\n\n/**\n * A consent provider adapts one host's CMP to the gate.\n *\n * `read()` must answer synchronously with what is known *now*. Providers are\n * installed into an already-rendered storefront page (DL #217), so a provider\n * that only subscribes is inert — the event it waits for may have fired long\n * before the bundle executed. Always read first, then subscribe.\n */\nexport interface ConsentProvider {\n readonly name: string;\n read(): ConsentSnapshot;\n subscribe(onChange: (snapshot: ConsentSnapshot) => void): () => void;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;;AAWA,OAAO,MAAMA,eAAgC,GAAGC,MAAM,CAACC,MAAM,CAAC;EAC5DC,WAAW,EAAE,SAAS;EACtBC,SAAS,EAAE,SAAS;EACpBC,SAAS,EAAE;AACb,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -1,52 +0,0 @@
1
- /**
2
- * The consent gate — DL #218 (revised).
3
- *
4
- * Legal cleared analytics/BI transmission to need no consent gate, so the old
5
- * `transmit()` + buffer machinery is gone. What analytics emitters used to route
6
- * through the gate now goes straight to the wire.
7
- *
8
- * Analytics AND performance telemetry both go straight to the wire now, so there
9
- * is nothing left to "transmit"-gate. What remains is the consent SIGNAL —
10
- * snapshot, engagement, provider — behind a single predicate:
11
- *
12
- * - `mayPersistToken()` — whether the visitor's OAuth token may be written to
13
- * localStorage. Persisting the token persists a cross-visit visitor identity
14
- * (its refresh token), which is the one thing consent still governs. Truth
15
- * table: granted → yes; denied → never; unknown → only once the visitor
16
- * engaged.
17
- *
18
- * Engagement (`unlockOnUserAction`, fired when the visitor submits a prompt)
19
- * resolves the `unknown` case — typing a question is a reason to remember this
20
- * visitor for the session — but it never overrides a `denied`.
21
- */
22
- import { type ConsentProvider, type ConsentSnapshot } from './types';
23
- type Listener = () => void;
24
- /**
25
- * Whether the visitor's OAuth token may be persisted to `localStorage`.
26
- *
27
- * Persisting the token persists a cross-visit visitor identity (the refresh
28
- * token re-identifies the visitor on their next visit), so it answers to
29
- * consent — the one thing that still does. Explicit consent wins in both
30
- * directions; engagement resolves only the `unknown` case. The token still
31
- * lives in memory for the session regardless — only the write to storage is
32
- * gated.
33
- */
34
- export declare const mayPersistToken: () => boolean;
35
- /**
36
- * The visitor did something deliberate — submitted a prompt — so we may remember
37
- * them for the session even though no CMP has answered. Unlocks the `unknown`
38
- * case only; it cannot override a `denied`.
39
- */
40
- export declare const unlockOnUserAction: () => void;
41
- export declare const getConsentSnapshot: () => ConsentSnapshot;
42
- export declare const subscribeToConsent: (listener: Listener) => (() => void);
43
- /**
44
- * Install the host's provider. Reads its current state immediately, *then*
45
- * subscribes — DL #217: a listener registered into an already-rendered page is
46
- * bound to an event that may have fired long before the bundle executed, so
47
- * subscribing alone would leave the gate permanently at `unknown`.
48
- */
49
- export declare const installConsentProvider: (next: ConsentProvider) => void;
50
- export declare const resetConsentGateForTests: () => void;
51
- export {};
52
- //# sourceMappingURL=consentGate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"consentGate.d.ts","sourceRoot":"","sources":["../../../src/privacy/consentGate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,eAAe,EACrB,MAAM,SAAS,CAAC;AAejB,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC;AAkB3B;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,QAAO,OASlC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,QAAO,IAOrC,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAO,eAA2B,CAAC;AAElE,eAAO,MAAM,kBAAkB,aAAc,QAAQ,KAAG,CAAC,MAAM,IAAI,CAKlE,CAAC;AAeF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,SAAU,eAAe,KAAG,IAM9D,CAAC;AAEF,eAAO,MAAM,wBAAwB,QAAO,IAM3C,CAAC"}
@@ -1,33 +0,0 @@
1
- /**
2
- * Consent override (debug-only) — DL #218.
3
- *
4
- * Shopify only serves its cookie banner where consent is legally required, so
5
- * from most of the world `shouldShowBanner()` is `false` and there is no way to
6
- * reach the `unknown` or `denied` branches by hand. Development stores often
7
- * have no privacy configuration at all, which pins the gate at `unknown`
8
- * forever. Neither is a bug, and both make the interesting states unreachable
9
- * from a browser.
10
- *
11
- * This forces the gate's answer so all four rows of the truth table can be
12
- * walked on any store, in any region, published or not.
13
- *
14
- * ?w5consent=granted | denied | unknown (one-shot)
15
- * localStorage["w5_consent_override"] (sticky)
16
- *
17
- * **The two are not equally trusted, on purpose.** A link is something one
18
- * person can send another, so a query param may only ever *reduce* what is
19
- * collected: `denied` is honoured anywhere, while `granted` and `unknown` are
20
- * honoured only on a local origin. Turning tracking *on* for someone else by
21
- * sending them a URL is exactly the thing this whole feature exists to
22
- * prevent. On a real storefront, set the localStorage key in devtools — which
23
- * is a deliberate act by the person whose browser it is.
24
- */
25
- import type { ConsentSnapshot, ConsentState } from './types';
26
- export declare const CONSENT_OVERRIDE_KEY = "w5_consent_override";
27
- export declare const CONSENT_OVERRIDE_QUERY_PARAM = "w5consent";
28
- /** The forced consent state, or `null` when no override is active. */
29
- export declare const getConsentOverride: () => ConsentState | null;
30
- export declare const overrideSnapshot: (state: ConsentState) => ConsentSnapshot;
31
- /** Persist the override and apply it on the next load. `null` clears it. */
32
- export declare const setConsentOverride: (state: ConsentState | null) => void;
33
- //# sourceMappingURL=consentOverride.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"consentOverride.d.ts","sourceRoot":"","sources":["../../../src/privacy/consentOverride.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE7D,eAAO,MAAM,oBAAoB,wBAAwB,CAAC;AAC1D,eAAO,MAAM,4BAA4B,cAAc,CAAC;AAoDxD,sEAAsE;AACtE,eAAO,MAAM,kBAAkB,QAAO,YAAY,GAAG,IAClB,CAAC;AAEpC,eAAO,MAAM,gBAAgB,UAAW,YAAY,KAAG,eAIrD,CAAC;AAEH,4EAA4E;AAC5E,eAAO,MAAM,kBAAkB,UAAW,YAAY,GAAG,IAAI,KAAG,IAU/D,CAAC"}
@@ -1,25 +0,0 @@
1
- /**
2
- * Provider selection — DL #218.
3
- *
4
- * Detected at boot, not configured per client, because a merchant can install
5
- * a CMP long after we deploy and the bundle is not the source of truth for a
6
- * store's behaviour (DL #214).
7
- *
8
- * Order is host-supplied → Shopify → OneTrust → none. A host that publishes an
9
- * answer outranks anything we could sniff, because it knows things we cannot:
10
- * a server-side consent record, a CMP behind its own abstraction, or a legal
11
- * position we have no business guessing at.
12
- *
13
- * When nothing is detected the gate keeps its default — everything `unknown`,
14
- * held until the visitor acts. That is the case on every Shopify store with no
15
- * privacy configuration, which today is most of them.
16
- */
17
- import type { ConsentProvider } from './types';
18
- export declare const detectConsentProvider: () => ConsentProvider | null;
19
- /**
20
- * Install the detected provider, if any. Call once at boot, before the first
21
- * emitter runs — anything raised earlier is held rather than lost, but the
22
- * sooner this runs the less the buffer has to carry.
23
- */
24
- export declare const initConsentGate: () => ConsentProvider | null;
25
- //# sourceMappingURL=detectProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"detectProvider.d.ts","sourceRoot":"","sources":["../../../src/privacy/detectProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAc/C,eAAO,MAAM,qBAAqB,QAAO,eAAe,GAAG,IAwB1D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAO,eAAe,GAAG,IAcpD,CAAC"}
@@ -1,8 +0,0 @@
1
- export { type ConsentState, type ConsentPurpose, type GatedPurpose, type ConsentSnapshot, type ConsentProvider, UNKNOWN_CONSENT, } from './types';
2
- export { unlockOnUserAction, mayPersistToken, getConsentSnapshot, subscribeToConsent, installConsentProvider, resetConsentGateForTests, } from './consentGate';
3
- export { detectConsentProvider, initConsentGate } from './detectProvider';
4
- export { CONSENT_OVERRIDE_KEY, CONSENT_OVERRIDE_QUERY_PARAM, getConsentOverride, setConsentOverride, } from './consentOverride';
5
- export { createShopifyConsentProvider, isShopifyHost, } from './providers/shopifyProvider';
6
- export { createOneTrustConsentProvider, isOneTrustHost, } from './providers/oneTrustProvider';
7
- export { type HostConsentInput, HOST_CONSENT_GLOBAL, createHostSuppliedConsentProvider, hasHostSuppliedConsent, publishHostConsent, } from './providers/hostSuppliedProvider';
8
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/privacy/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,eAAe,GAChB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAE1E,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAC5B,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,4BAA4B,EAC5B,aAAa,GACd,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,6BAA6B,EAC7B,cAAc,GACf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,KAAK,gBAAgB,EACrB,mBAAmB,EACnB,iCAAiC,EACjC,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,kCAAkC,CAAC"}
@@ -1,29 +0,0 @@
1
- /**
2
- * Host-supplied provider — DL #218.
3
- *
4
- * The escape hatch for every CMP we cannot detect: a host page that already
5
- * knows its visitor's answer publishes it, and the gate believes it. This is
6
- * how Circana, feature.com and any merchant on Cookiebot/Osano/Klaviyo reach
7
- * the gate without web5 learning each vendor's API.
8
- *
9
- * Two ways in, because hosts differ in when they know:
10
- * - `window.__web5_consent__` set before the bundle loads, read at install
11
- * - `publishHostConsent()` called at any time afterwards
12
- */
13
- import { type ConsentProvider, type ConsentState } from '../types';
14
- export declare const HOST_CONSENT_GLOBAL = "__web5_consent__";
15
- /** What a host may publish. Anything missing stays `unknown`. */
16
- export interface HostConsentInput {
17
- analytics?: ConsentState | boolean;
18
- marketing?: ConsentState | boolean;
19
- performance?: ConsentState | boolean;
20
- }
21
- export declare const hasHostSuppliedConsent: () => boolean;
22
- /**
23
- * Called by the host — directly, or by the loader when it is handed consent in
24
- * its boot options — whenever the visitor's answer is known or changes.
25
- */
26
- export declare const publishHostConsent: (input: HostConsentInput) => void;
27
- export declare const createHostSuppliedConsentProvider: () => ConsentProvider;
28
- export declare const __resetHostConsentForTests: () => void;
29
- //# sourceMappingURL=hostSuppliedProvider.d.ts.map
@@ -1 +0,0 @@
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,15 +0,0 @@
1
- /**
2
- * OneTrust provider — DL #218.
3
- *
4
- * Lifted from the consent check that used to live inside
5
- * `utils/analyticsEvents.ts`, with one deliberate behaviour change: that
6
- * function returned `true` when OneTrust was absent ("host is responsible for
7
- * loading OneTrust"), which on a Shopify storefront meant unconditional
8
- * default-allow. Absence is no longer this provider's problem — it is only
9
- * selected when OneTrust is actually on the page, and absence is handled by
10
- * the gate's own default.
11
- */
12
- import type { ConsentProvider } from '../types';
13
- export declare const isOneTrustHost: () => boolean;
14
- export declare const createOneTrustConsentProvider: () => ConsentProvider;
15
- //# sourceMappingURL=oneTrustProvider.d.ts.map
@@ -1 +0,0 @@
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"}