@owlmeans/consent 0.1.18-rc.8 → 0.1.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.
Files changed (120) hide show
  1. package/README.md +229 -0
  2. package/build/consts.d.ts +84 -23
  3. package/build/consts.d.ts.map +1 -1
  4. package/build/consts.js +110 -29
  5. package/build/consts.js.map +1 -1
  6. package/build/consts.local.d.ts +12 -0
  7. package/build/consts.local.d.ts.map +1 -0
  8. package/build/consts.local.js +12 -0
  9. package/build/consts.local.js.map +1 -0
  10. package/build/geo/types.d.ts +47 -0
  11. package/build/geo/types.d.ts.map +1 -0
  12. package/build/geo/types.js +2 -0
  13. package/build/geo/types.js.map +1 -0
  14. package/build/geo.d.ts +4 -0
  15. package/build/geo.d.ts.map +1 -0
  16. package/build/geo.js +96 -0
  17. package/build/geo.js.map +1 -0
  18. package/build/gtobserver/types.d.ts +75 -0
  19. package/build/gtobserver/types.d.ts.map +1 -0
  20. package/build/gtobserver/types.js +2 -0
  21. package/build/gtobserver/types.js.map +1 -0
  22. package/build/gtobserver.d.ts +7 -0
  23. package/build/gtobserver.d.ts.map +1 -0
  24. package/build/gtobserver.js +142 -0
  25. package/build/gtobserver.js.map +1 -0
  26. package/build/i18n/be.json +9 -4
  27. package/build/i18n/de.json +9 -4
  28. package/build/i18n/en.json +9 -4
  29. package/build/i18n/es.json +9 -4
  30. package/build/i18n/fr.json +9 -4
  31. package/build/i18n/pl.json +9 -4
  32. package/build/i18n/ru.json +9 -4
  33. package/build/i18n/types.d.ts +11 -0
  34. package/build/i18n/types.d.ts.map +1 -0
  35. package/build/i18n/types.js +2 -0
  36. package/build/i18n/types.js.map +1 -0
  37. package/build/i18n/uk.json +9 -4
  38. package/build/i18n.d.ts +4 -14
  39. package/build/i18n.d.ts.map +1 -1
  40. package/build/i18n.js +12 -27
  41. package/build/i18n.js.map +1 -1
  42. package/build/index.d.ts +13 -6
  43. package/build/index.d.ts.map +1 -1
  44. package/build/index.js +5 -4
  45. package/build/index.js.map +1 -1
  46. package/build/linker/types.d.ts +59 -0
  47. package/build/linker/types.d.ts.map +1 -0
  48. package/build/linker/types.js +2 -0
  49. package/build/linker/types.js.map +1 -0
  50. package/build/linker.d.ts +5 -76
  51. package/build/linker.d.ts.map +1 -1
  52. package/build/linker.js +290 -339
  53. package/build/linker.js.map +1 -1
  54. package/build/plugins/types.d.ts +42 -0
  55. package/build/plugins/types.d.ts.map +1 -0
  56. package/build/plugins/types.js +2 -0
  57. package/build/plugins/types.js.map +1 -0
  58. package/build/plugins.d.ts +4 -69
  59. package/build/plugins.d.ts.map +1 -1
  60. package/build/plugins.js +73 -62
  61. package/build/plugins.js.map +1 -1
  62. package/build/storage/types.d.ts +31 -0
  63. package/build/storage/types.d.ts.map +1 -0
  64. package/build/storage/types.js +2 -0
  65. package/build/storage/types.js.map +1 -0
  66. package/build/storage.d.ts +6 -22
  67. package/build/storage.d.ts.map +1 -1
  68. package/build/storage.js +72 -81
  69. package/build/storage.js.map +1 -1
  70. package/build/store.d.ts +2 -2
  71. package/build/store.d.ts.map +1 -1
  72. package/build/store.js +116 -67
  73. package/build/store.js.map +1 -1
  74. package/build/types.d.ts +147 -26
  75. package/build/types.d.ts.map +1 -1
  76. package/build/types.local.d.ts +9 -0
  77. package/build/types.local.d.ts.map +1 -0
  78. package/build/types.local.js +2 -0
  79. package/build/types.local.js.map +1 -0
  80. package/package.json +3 -3
  81. package/src/consts.local.ts +16 -0
  82. package/src/consts.ts +126 -34
  83. package/src/geo/types.ts +49 -0
  84. package/src/geo.ts +122 -0
  85. package/src/gtobserver/types.ts +73 -0
  86. package/src/gtobserver.ts +182 -0
  87. package/src/i18n/be.json +9 -4
  88. package/src/i18n/de.json +9 -4
  89. package/src/i18n/en.json +9 -4
  90. package/src/i18n/es.json +9 -4
  91. package/src/i18n/fr.json +9 -4
  92. package/src/i18n/pl.json +9 -4
  93. package/src/i18n/ru.json +9 -4
  94. package/src/i18n/types.ts +11 -0
  95. package/src/i18n/uk.json +9 -4
  96. package/src/i18n.ts +20 -32
  97. package/src/index.ts +13 -13
  98. package/src/linker/types.ts +59 -0
  99. package/src/linker.ts +301 -364
  100. package/src/plugins/types.ts +42 -0
  101. package/src/plugins.ts +82 -106
  102. package/src/storage/types.ts +31 -0
  103. package/src/storage.ts +75 -77
  104. package/src/store.ts +122 -69
  105. package/src/types.local.ts +9 -0
  106. package/src/types.ts +153 -25
  107. package/tests/consent.spec.ts +26 -28
  108. package/tests/geo.spec.ts +474 -0
  109. package/tests/linker.spec.ts +144 -309
  110. package/tests/tracking.spec.ts +14 -14
  111. package/build/functional.d.ts +0 -35
  112. package/build/functional.d.ts.map +0 -1
  113. package/build/functional.js +0 -67
  114. package/build/functional.js.map +0 -1
  115. package/build/gtm.d.ts +0 -72
  116. package/build/gtm.d.ts.map +0 -1
  117. package/build/gtm.js +0 -182
  118. package/build/gtm.js.map +0 -1
  119. package/src/functional.ts +0 -73
  120. package/src/gtm.ts +0 -220
@@ -1 +1 @@
1
- {"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EAAE,iBAAiB,EAAE,WAAW,EAAE,sBAAsB,GAC5E,MAAM,aAAa,CAAA;AAGpB,MAAM,GAAG,GAAG,CAAC,IAAqB,EAAU,EAAE,CAAC,IAAI,EAAE,UAAU,IAAI,WAAW,CAAA;AAE9E,MAAM,KAAK,GAAG,CAAC,GAA8B,EAAwB,EAAE;IACrE,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,KAAK,EAAE,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAA;IACb,CAAC;IACD,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAY,CAAA;QAExC,OAAO,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAsB,CAAC,CAAC,CAAC,IAAI,CAAA;IACnF,CA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;YAC/E,QAAQ,CAAC,MAAM,GAAG,GAAG,IAAI,iDAAiD,MAAM,EAAE,CAAA;QACpF,CAAC;IACH,CAAC,CAAA;IAED,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,CAAA;AACpE,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,0BAA0B,EAAE,CAAA;AAEhE,sFAAsF;AACtF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAqB,EAAwB,EAAE,CAAC,oBAAoB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;AAElH,uFAAuF;AACvF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAqB,EAAE,IAAqB,EAAQ,EAAE,CACjF,oBAAoB,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;AAEjD,uFAAuF;AACvF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAqB,EAAQ,EAAE,CAAC,oBAAoB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA"}
package/build/store.d.ts CHANGED
@@ -9,8 +9,8 @@ import type { ConsentReason, ConsentStore } from './types.js';
9
9
  */
10
10
  export declare const makeConsentStore: () => ConsentStore;
11
11
  export declare const consentStore: ConsentStore;
12
- /** Open the preferences dialog from anywhere — a footer link, a policy page, a login gate. */
12
+ /** @deprecated compat:factory-refactor — use `consentStore.open(…)` */
13
13
  export declare const openConsent: (reason?: ConsentReason) => void;
14
- /** Whether a category is granted, for the callers that are not components. */
14
+ /** @deprecated compat:factory-refactor — use `consentStore.granted(…)` */
15
15
  export declare const isConsented: (key: string) => boolean;
16
16
  //# sourceMappingURL=store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACuB,aAAa,EAA+B,YAAY,EAC1F,MAAM,YAAY,CAAA;AAEnB;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,QAAO,YAyInC,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,YAAiC,CAAA;AAE5D,8FAA8F;AAC9F,eAAO,MAAM,WAAW,YAAa,aAAa,KAAG,IAAiC,CAAA;AAEtF,8EAA8E;AAC9E,eAAO,MAAM,WAAW,QAAS,MAAM,KAAG,OAAoC,CAAA"}
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACuB,aAAa,EAA+B,YAAY,EAC1F,MAAM,YAAY,CAAA;AAGnB;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,QAAO,YA6LnC,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,YAAiC,CAAA;AAE5D,uEAAuE;AACvE,eAAO,MAAM,WAAW,YAAa,aAAa,KAAG,IAAiC,CAAA;AAEtF,0EAA0E;AAC1E,eAAO,MAAM,WAAW,QAAS,MAAM,KAAG,OAAoC,CAAA"}
package/build/store.js CHANGED
@@ -1,9 +1,10 @@
1
- import { CONSENT_FUNCTIONAL, CONSENT_KEY, CONSENT_LANGUAGE_EVENT, CONSENT_PENDING_LANGUAGE, DEFAULT_CONSENT_CATEGORIES, } from './consts.js';
2
- import { purgeFunctionalStorage } from './functional.js';
3
- import { applyConsent, pushConsentDefaults } from './gtm.js';
4
- import { consentLinker, stripConsentLinkParam, writeConsentLanguage } from './linker.js';
5
- import { adoptConsent, adoptConsentLanguage, registerConsentPlugin, startConsentPlugins } from './plugins.js';
6
- import { readConsent, writeConsent } from './storage.js';
1
+ import { CONSENT_IDLE_STATE, CONSENT_KEY, CONSENT_STATE_ATTRIBUTE, DEFAULT_CONSENT_CATEGORIES, } from './consts.js';
2
+ import { CLOUDFLARE_LOCATOR_ALIAS } from './consts.local.js';
3
+ import { consentModeHelper } from './gtobserver.js';
4
+ import { consentGeoHelper } from './geo.js';
5
+ import { consentLinkHelper } from './linker.js';
6
+ import { consentPluginHelper } from './plugins.js';
7
+ import { consentStorageHelper } from './storage.js';
7
8
  /**
8
9
  * The consent state of this DOCUMENT.
9
10
  *
@@ -14,44 +15,65 @@ import { readConsent, writeConsent } from './storage.js';
14
15
  */
15
16
  export const makeConsentStore = () => {
16
17
  const listeners = new Set();
17
- let state = { record: null, open: false, reason: null };
18
+ const waiting = new Set();
19
+ let state = CONSENT_IDLE_STATE;
18
20
  let options = {};
19
- // A language that arrived with a link (or was chosen) before the visitor granted functional
20
- // storage. Memory only — it is never written until the grant, and it dies with the page.
21
- let pendingLanguage = null;
21
+ /** The one country lookup of this document, while it runs. */
22
+ let lookup = null;
23
+ /** What the last lookup decided — a later `init` never locates the same visitor twice. */
24
+ let verdict = null;
25
+ /** `<html data-consent>`: what a test waits on and a stylesheet may key on. */
26
+ const mark = () => {
27
+ const root = typeof document !== 'undefined' ? document.documentElement : undefined;
28
+ if (root == null || typeof root.setAttribute !== 'function') {
29
+ return;
30
+ }
31
+ root.setAttribute(CONSENT_STATE_ATTRIBUTE, state.open ? 'open'
32
+ : state.locating != null ? 'locating'
33
+ : state.record != null ? 'decided' : 'idle');
34
+ };
22
35
  const publish = (next) => {
23
36
  state = { ...state, ...next };
37
+ mark();
24
38
  listeners.forEach(listener => listener(state));
39
+ if (state.locating == null && lookup == null && waiting.size > 0) {
40
+ const settled = [...waiting];
41
+ waiting.clear();
42
+ settled.forEach(resolve => resolve(state));
43
+ }
44
+ };
45
+ const resolved = () => ({
46
+ ...options,
47
+ categories: options.categories ?? DEFAULT_CONSENT_CATEGORIES,
48
+ storageKey: options.storageKey ?? CONSENT_KEY,
49
+ });
50
+ const ask = () => {
51
+ publish({ record: null, open: true, reason: 'initial', locating: null });
25
52
  };
26
53
  /**
27
- * Bring functional storage in line with the record, now.
28
- *
29
- * Granted: a language that was waiting is written, and the application is told (`CONSENT_LANGUAGE_EVENT`)
30
- * so it can switch this very page instead of the next load. Not granted — a refusal, a withdrawal,
31
- * or a record that never answered the question — every functional key is REMOVED: a preference
32
- * must not outlive the consent to remember it. What was waiting stays waiting; the visitor may
33
- * still grant it later in this page's life.
54
+ * What a finished lookup does — unless the visitor got there first: a decision saved meanwhile, or
55
+ * the window opened for a reason of its own (signing in), always wins over the location.
34
56
  */
35
- const settleFunctional = () => {
36
- if (state.record?.[CONSENT_FUNCTIONAL] !== true) {
37
- purgeFunctionalStorage(options);
57
+ const settle = (result, pending) => {
58
+ verdict = result;
59
+ lookup = null;
60
+ if (state.record != null || (state.open && state.reason !== 'initial')) {
61
+ publish({ locating: null });
38
62
  return;
39
63
  }
40
- if (pendingLanguage == null) {
64
+ if (result === 'auto') {
65
+ const record = consentGeoHelper.automaticRecord(resolved());
66
+ consentStorageHelper.writeConsent(record, options);
67
+ consentModeHelper.applyConsent(record, options);
68
+ publish({ record, open: false, reason: null, locating: null });
41
69
  return;
42
70
  }
43
- const language = pendingLanguage;
44
- pendingLanguage = null;
45
- if (writeConsentLanguage(language, options) && typeof window !== 'undefined'
46
- && typeof window.dispatchEvent === 'function' && typeof CustomEvent === 'function') {
47
- window.dispatchEvent(new CustomEvent(CONSENT_LANGUAGE_EVENT, { detail: { language } }));
71
+ if (pending != null) {
72
+ // A grant derived somewhere nobody had to be asked does not survive arriving where they must.
73
+ consentStorageHelper.clearConsent(options);
48
74
  }
75
+ ask();
49
76
  };
50
- const resolved = () => ({
51
- ...options,
52
- categories: options.categories ?? DEFAULT_CONSENT_CATEGORIES,
53
- storageKey: options.storageKey ?? CONSENT_KEY,
54
- });
55
77
  const store = {
56
78
  get: () => state,
57
79
  subscribe: listener => {
@@ -61,59 +83,84 @@ export const makeConsentStore = () => {
61
83
  init: opts => {
62
84
  options = { ...options, ...opts };
63
85
  // Before anything is read, so a page with no stored answer still declares what is denied.
64
- pushConsentDefaults(options);
86
+ consentModeHelper.pushConsentDefaults(options);
65
87
  if (options.linker != null) {
66
- // Replace-by-alias (`registerConsentPlugin`), so a second `init` (a re-mounted provider,
67
- // StrictMode) never double-installs the click listener — `consentLinker().start` also
68
- // guards itself with its own closured flag, belt and braces.
69
- registerConsentPlugin(consentLinker());
70
- startConsentPlugins(options);
88
+ // Registered once: `start` installs the click listener of THAT instance, and a second
89
+ // instance (a second `init` — a re-mounted provider, StrictMode, `loadGtm`) would install
90
+ // its own beside it.
91
+ if (!consentPluginHelper.consentPlugins().some(plugin => plugin.alias === 'linker')) {
92
+ consentPluginHelper.registerConsentPlugin(consentLinkHelper.consentLinker());
93
+ }
94
+ consentPluginHelper.startConsentPlugins(options);
71
95
  }
72
- let record = readConsent(options);
73
- // Only when THIS document has no decision yet — an existing one always wins, exactly as the
74
- // ordinary "ask" path would never overwrite a stored record either.
75
- if (record == null && options.linker != null) {
76
- record = adoptConsent(options);
77
- if (record != null) {
78
- writeConsent(record, options);
96
+ if (options.geo?.cloudflare != null && options.geo.cloudflare !== false
97
+ && !consentPluginHelper.consentPlugins().some(plugin => plugin.alias === CLOUDFLARE_LOCATOR_ALIAS)) {
98
+ consentPluginHelper.registerConsentPlugin(consentGeoHelper.cloudflareLocator());
99
+ }
100
+ let record = consentStorageHelper.readConsent(options);
101
+ const automatic = consentGeoHelper.autoState(record);
102
+ // An automatic decision past its age is held back — applied nowhere — until the visitor is
103
+ // located again, exactly as the head scripts already skipped it.
104
+ const pending = automatic === 'stale' ? record : null;
105
+ if (pending != null) {
106
+ record = null;
107
+ }
108
+ // An explicit decision carried from another domain always beats none — and beats an automatic
109
+ // one, which nobody chose. An explicit stored one always wins, as the ordinary "ask" path
110
+ // would never overwrite it either.
111
+ if ((record == null || automatic != null) && options.linker != null) {
112
+ const adopted = consentPluginHelper.adoptConsent(options);
113
+ if (adopted != null) {
114
+ consentStorageHelper.writeConsent(adopted, options);
115
+ record = adopted;
79
116
  }
80
117
  }
81
118
  if (options.linker != null) {
82
- // What the link carried, or what the inline head fragment already took off it and left on
83
- // `window` (it strips the parameter, so this is the only place that still knows). Held, not
84
- // written: whether it may be stored is settled below, against the record.
85
- const win = typeof window !== 'undefined' ? window : null;
86
- const inline = win?.[CONSENT_PENDING_LANGUAGE];
87
- pendingLanguage = adoptConsentLanguage(options) ?? (typeof inline === 'string' ? inline : pendingLanguage);
88
- if (win != null && inline !== undefined) {
89
- delete win[CONSENT_PENDING_LANGUAGE];
119
+ // The language the link carried, stored at once — the interface language is strictly
120
+ // necessary storage, so no decision is consulted. A page that stamped the inline head
121
+ // fragment has already done this and stripped the parameter, which leaves nothing here.
122
+ const carried = consentPluginHelper.adoptConsentLanguage(options);
123
+ if (carried != null) {
124
+ consentLinkHelper.writeConsentLanguage(carried, options);
90
125
  }
91
126
  // Always, whether or not anything was adopted — a stale or foreign parameter is exactly as
92
127
  // much noise in the visible URL as an adopted one, and a page that already had its own
93
128
  // decision may still have arrived with one attached.
94
- stripConsentLinkParam(options);
129
+ consentLinkHelper.stripConsentLinkParam(options);
95
130
  }
96
131
  if (record != null) {
97
- applyConsent(record, options);
98
- publish({ record, open: false, reason: null });
99
- settleFunctional();
132
+ consentModeHelper.applyConsent(record, options);
133
+ publish({ record, open: false, reason: null, locating: null });
134
+ return;
135
+ }
136
+ if (lookup != null) {
137
+ return;
138
+ }
139
+ // The window is already open for a reason of its own (signing in): the visitor is answering.
140
+ if (state.open && state.reason !== 'initial') {
100
141
  return;
101
142
  }
102
- publish({ record: null, open: true, reason: 'initial' });
103
- settleFunctional();
143
+ if (verdict === 'ask' || !consentGeoHelper.enabled(options)) {
144
+ ask();
145
+ return;
146
+ }
147
+ // A first visit waits behind the spinner; a re-check runs silently, nothing applied meanwhile.
148
+ publish({ record: null, open: false, reason: null, locating: pending != null ? 'recheck' : 'first' });
149
+ lookup = consentGeoHelper.decide(options).then(result => settle(result, pending));
104
150
  },
105
151
  save: record => {
106
- writeConsent(record, options);
107
- applyConsent(record, options);
108
- publish({ record, open: false, reason: null });
109
- // After the record is stored: `writeConsentLanguage` reads it back to decide.
110
- settleFunctional();
152
+ const { auto: _auto, ...explicit } = record;
153
+ consentStorageHelper.writeConsent(explicit, options);
154
+ consentModeHelper.applyConsent(explicit, options);
155
+ publish({ record: explicit, open: false, reason: null, locating: null });
111
156
  },
112
157
  acceptAll: () => {
113
158
  const record = Object.fromEntries(resolved().categories.map(category => [category.key, true]));
114
159
  store.save(record);
115
160
  },
116
- open: (reason) => { publish({ open: true, reason: reason ?? 'reopen' }); },
161
+ open: (reason) => {
162
+ publish({ open: true, reason: reason ?? 'reopen', locating: null });
163
+ },
117
164
  close: () => { publish({ open: false, reason: null }); },
118
165
  granted: key => {
119
166
  const category = resolved().categories.find(candidate => candidate.key === key);
@@ -123,13 +170,15 @@ export const makeConsentStore = () => {
123
170
  return state.record?.[key] === true;
124
171
  },
125
172
  options: resolved,
126
- pendingLanguage: () => pendingLanguage,
173
+ settled: () => state.locating == null && lookup == null
174
+ ? Promise.resolve(state)
175
+ : new Promise(resolve => { waiting.add(resolve); }),
127
176
  };
128
177
  return store;
129
178
  };
130
179
  export const consentStore = makeConsentStore();
131
- /** Open the preferences dialog from anywhere — a footer link, a policy page, a login gate. */
180
+ /** @deprecated compat:factory-refactor — use `consentStore.open(…)` */
132
181
  export const openConsent = (reason) => consentStore.open(reason);
133
- /** Whether a category is granted, for the callers that are not components. */
182
+ /** @deprecated compat:factory-refactor — use `consentStore.granted(…)` */
134
183
  export const isConsented = (key) => consentStore.granted(key);
135
184
  //# sourceMappingURL=store.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAAE,WAAW,EAAE,sBAAsB,EAAE,wBAAwB,EACjF,0BAA0B,GAC3B,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACxF,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,mBA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ply never sees the update, and the only symptom is analytics that stay switched off
6
6
  * for everyone who agreed to them.
7
7
  */
8
+ import { CONSENT_LINK_VERSION } from './consts.local.js';
8
9
  export type ConsentSignal = 'ad_storage' | 'ad_user_data' | 'ad_personalization' | 'analytics_storage' | 'functionality_storage' | 'personalization_storage' | 'security_storage';
9
10
  export interface ConsentCategory {
10
11
  /** Stable storage key. `essential` is reserved and always required. */
@@ -16,7 +17,7 @@ export interface ConsentCategory {
16
17
  * itself a dark pattern. A required category is disclosure, not a question.
17
18
  */
18
19
  required?: boolean;
19
- /** Resolved through `translate`; the built-in bundle supplies the default set in 7 languages. */
20
+ /** Resolved through `translate`; the built-in bundle supplies the default set in 8 languages. */
20
21
  labelKey: string;
21
22
  descriptionKey: string;
22
23
  /**
@@ -62,11 +63,55 @@ export interface ConsentService {
62
63
  /** The provider's own privacy policy. */
63
64
  privacyHref?: string;
64
65
  }
65
- /** `v` is the schema version; every other key is a category key. */
66
+ /**
67
+ * `v` is the schema version and `auto` marks an automatic decision; every other key is a category
68
+ * key — so neither `v` nor `auto` may ever name a category.
69
+ */
66
70
  export interface ConsentRecord {
67
71
  v?: number;
72
+ /**
73
+ * Unix seconds at which this record was DERIVED rather than chosen: the visitor was located
74
+ * outside every consent-requiring country (`ConsentGeoOptions`) and nobody asked them. Present
75
+ * only on an automatic decision — an explicit save drops it. An automatic decision is trusted for
76
+ * `CONSENT_AUTO_MAX_AGE` seconds and then counts as undecided until the visitor is located again,
77
+ * so a traveller who crosses into a consent country is asked there instead of carrying a grant
78
+ * nobody gave. It never travels on a linker link as the visitor's own choice.
79
+ */
80
+ auto?: number;
68
81
  [category: string]: boolean | number | undefined;
69
82
  }
83
+ /** Where a locator places the visitor. */
84
+ export interface ConsentGeoLocation {
85
+ /** ISO 3166-1 alpha-2, upper case — `PL`, `US`. Anything else counts as "not located". */
86
+ country: string;
87
+ }
88
+ export interface ConsentCloudflareOptions {
89
+ /** The same-origin path of Cloudflare's trace endpoint. Defaults to `CONSENT_TRACE_PATH`. */
90
+ path?: string;
91
+ }
92
+ /**
93
+ * Ask only where the law requires it: locate the visitor first, and decide automatically wherever
94
+ * no consent is required.
95
+ *
96
+ * Its presence turns the gate on. The country comes from the registered locators
97
+ * (`ConsentGeoPlugin`, highest priority first, the first usable answer wins); `cloudflare` adds the
98
+ * built-in one. A visitor nobody can locate — no locator, every one of them failing, an unusable
99
+ * code, `timeout` passing — is asked, exactly as without the gate.
100
+ */
101
+ export interface ConsentGeoOptions {
102
+ /**
103
+ * The built-in locator: a same-origin GET of Cloudflare's `/cdn-cgi/trace`, reading `loc=`. It
104
+ * answers only where the host is proxied by Cloudflare — anywhere else (a local dev server, a
105
+ * self-hosted export) it fails, and the visitor is asked.
106
+ */
107
+ cloudflare?: boolean | ConsentCloudflareOptions;
108
+ /** The countries where consent is asked. Defaults to `CONSENT_REQUIRED_COUNTRIES`. */
109
+ countries?: readonly string[];
110
+ /** How long locating may take before the visitor is asked anyway, in ms. `CONSENT_GEO_TIMEOUT`. */
111
+ timeout?: number;
112
+ }
113
+ /** Which lookup is running: the first one (the page waits behind a spinner) or a silent re-check. */
114
+ export type ConsentLocating = 'first' | 'recheck';
70
115
  export interface ConsentOptions {
71
116
  categories?: ConsentCategory[];
72
117
  storageKey?: string;
@@ -78,19 +123,14 @@ export interface ConsentOptions {
78
123
  cookieDomain?: string;
79
124
  /** Skip every dataLayer and global write. For tests, and for an app that runs no tags. */
80
125
  silent?: boolean;
81
- /**
82
- * The `localStorage` keys that hold this application's functional preferences (the interface
83
- * language, today). They may exist only while the visitor has granted `functional`: `init` and
84
- * `save` remove every one of them the moment it is not granted. Defaults to the language key
85
- * (`owlmeans-lng`); `linker.language.storageKey` is always included.
86
- */
87
- functionalKeys?: string[];
88
126
  /**
89
127
  * Cross-domain consent: share this decision, and adopt one, between the listed first-party
90
128
  * domains — a visitor who already decided on one need not decide again on another. See
91
129
  * `consentLinker`/`ConsentPlugin` in `./plugins.js` and `./linker.js`.
92
130
  */
93
131
  linker?: ConsentLinkerOptions;
132
+ /** Ask only in consent-requiring countries — see `ConsentGeoOptions`. Off when absent. */
133
+ geo?: ConsentGeoOptions;
94
134
  }
95
135
  export interface ConsentLinkerOptions {
96
136
  /**
@@ -107,56 +147,137 @@ export interface ConsentLinkerOptions {
107
147
  * Carry the visitor's interface language along with the decision, so a visitor reading the site
108
148
  * in Polish arrives on the next domain in Polish. Its PRESENCE turns the sending side on (a link
109
149
  * to a listed domain carries this document's `<html lang>`); `supported` turns the receiving side
110
- * on — which still stores nothing until functional storage is granted there. See
111
- * `ConsentLinkerLanguage`.
150
+ * on — which stores the carried language whatever the cookie decision says, because the interface
151
+ * language is strictly necessary. See `ConsentLinkerLanguage`.
112
152
  */
113
153
  language?: ConsentLinkerLanguage;
114
154
  }
115
155
  export interface ConsentLinkerLanguage {
116
156
  /**
117
157
  * RECEIVING side: the languages this application can render. A carried language is adopted only
118
- * when it is one of these, exactly or by its base tag (`de-DE` → `de`). It is stored only while
119
- * the visitor has granted `functional` on this document — until then it is held in memory, and
120
- * stored if they grant it later in this page's life (`CONSENT_LANGUAGE_EVENT` tells the app);
158
+ * when it is one of these, exactly or by its base tag (`de-DE` → `de`), and is then stored at
159
+ * once — the interface language is strictly necessary storage, so no cookie decision gates it;
121
160
  * anything else is ignored and the application keeps choosing its own. Leave it out on a site
122
161
  * that only SENDS its language.
123
162
  */
124
163
  supported?: string[];
125
164
  /**
126
165
  * RECEIVING side: the `localStorage` key an explicit language choice lives under. Defaults to
127
- * `owlmeans-lng`, the key `@owlmeans/client-i18n` reads before it renders anything. It is a
128
- * functional key: written only while `functional` is granted, removed when it is not.
166
+ * `owlmeans-lng`, the key `@owlmeans/client-i18n` reads before it renders anything.
129
167
  */
130
168
  storageKey?: string;
131
169
  }
132
- /** Why the dialog is open. `login` is what the sign-in precondition raises. */
133
- export type ConsentReason = 'initial' | 'reopen' | 'login' | string;
170
+ /**
171
+ * Why the consent UI is open. `initial` is the first ask (the bar, in bar mode); `preferences` is the
172
+ * bar's own "Cookie preferences"; `reopen` a footer link or the corner button; `login` what the
173
+ * sign-in precondition raises. Every reason but `initial` opens the preferences window.
174
+ */
175
+ export type ConsentReason = 'initial' | 'reopen' | 'login' | 'preferences' | string;
134
176
  export interface ConsentState {
135
177
  record: ConsentRecord | null;
136
178
  open: boolean;
137
179
  reason: ConsentReason | null;
180
+ /** A country lookup is running (`ConsentGeoOptions`); `null` once it settled, or when there is none. */
181
+ locating: ConsentLocating | null;
182
+ }
183
+ export interface ConsentListener {
184
+ (state: ConsentState): void;
138
185
  }
139
- export type ConsentListener = (state: ConsentState) => void;
140
186
  export interface ConsentStore {
141
187
  get: () => ConsentState;
142
188
  subscribe: (listener: ConsentListener) => () => void;
143
- /** Push the defaults, load and migrate any stored record, apply it, and open when there is none. */
189
+ /**
190
+ * Push the defaults, load and migrate any stored record, apply it — and, when there is none,
191
+ * either ask at once or, with `geo` set, locate the visitor first and ask or decide automatically.
192
+ * Synchronous: a lookup runs in the background, `locating` says so, and `settled()` waits for it.
193
+ */
144
194
  init: (opts?: ConsentOptions) => void;
195
+ /** Record an explicit decision. Always explicit: an `auto` key on `record` is dropped. */
145
196
  save: (record: ConsentRecord) => void;
146
197
  acceptAll: () => void;
198
+ /** Open the consent UI from anywhere — a footer link, a policy page, a login gate. */
147
199
  open: (reason?: ConsentReason) => void;
148
200
  close: () => void;
149
201
  /** Imperative reader, for the callers that are not React. */
150
202
  granted: (key: string) => boolean;
151
- /**
152
- * A language that arrived with a link and is waiting for the visitor to grant `functional`
153
- * storage — memory only, or `null`. It is written (and `CONSENT_LANGUAGE_EVENT` dispatched) the
154
- * moment the grant is saved.
155
- */
156
- pendingLanguage: () => string | null;
157
203
  options: () => ConsentOptions & {
158
204
  categories: ConsentCategory[];
159
205
  storageKey: string;
160
206
  };
207
+ /** The state once no country lookup is running — at once when none is. */
208
+ settled: () => Promise<ConsentState>;
209
+ }
210
+ /** A language the dialog's built-in copy is carried in (`CONSENT_LOCALES`). */
211
+ export type ConsentLocale = 'en' | 'pl' | 'ru' | 'be' | 'uk' | 'es' | 'de' | 'fr';
212
+ /** The decoded, not-yet-validated payload a decorated link's parameter carries. */
213
+ export interface ConsentLinkPayload {
214
+ v: typeof CONSENT_LINK_VERSION;
215
+ /** One entry per OPTIONAL category this site knows, `1` granted / `0` denied. */
216
+ c: Record<string, 0 | 1>;
217
+ /** Unix seconds the link was decorated at. */
218
+ t: number;
219
+ /**
220
+ * The interface language of the page the link was on (a BCP 47 tag, lower-cased) — present only
221
+ * when the sender has `linker.language` set and its `<html lang>` names one. Optional on the
222
+ * wire, so a receiver that predates it reads the same `v: 2` payload and ignores the field.
223
+ */
224
+ l?: string;
225
+ }
226
+ /**
227
+ * An extension seam for `@owlmeans/consent`: something that reacts to this document's consent
228
+ * decision, or supplies one from elsewhere, without the core store knowing anything about where
229
+ * that decision came from.
230
+ *
231
+ * `consentLinker` (`./linker.js`) is the one built-in plugin — cross-domain consent through
232
+ * decorated links — but nothing here is specific to it. A registry rather than a fixed option on
233
+ * `ConsentOptions` because the store has zero dependencies today and stays that way: a plugin is
234
+ * opt-in code an application imports for its own reason, never a bundled feature this package
235
+ * pulls in whether or not anything uses it.
236
+ */
237
+ export interface ConsentPlugin {
238
+ /** Stable identity. Registering the same alias again REPLACES the earlier plugin. */
239
+ alias: string;
240
+ /** Run order when more than one plugin implements the same hook. Higher first. Defaults to 0. */
241
+ priority?: number;
242
+ /** Installed once, the first time `consentStore.init` runs with this plugin registered. */
243
+ start?: (opts: ConsentOptions) => void;
244
+ /**
245
+ * Offer a decision from outside this document's own storage — e.g. one carried on the URL that
246
+ * led here. Returns a full record to adopt, or `null` to defer to the next plugin / the ordinary
247
+ * "ask" path. Never called once a stored record already exists.
248
+ */
249
+ adopt?: (opts: ConsentOptions) => ConsentRecord | null;
250
+ /**
251
+ * Offer an interface language from outside this document's own storage — e.g. the one the page
252
+ * that led here was read in. Returns a language the application supports, or `null` to keep
253
+ * choosing its own. Only a CANDIDATE: it says what the link carried, and `writeConsentLanguage`
254
+ * stores it — unconditionally, since the interface language is strictly necessary storage.
255
+ */
256
+ adoptLanguage?: (opts: ConsentOptions) => string | null;
257
+ /**
258
+ * Rewrite an outgoing URL to carry this document's current decision — and its language — or
259
+ * `null` to leave it untouched (a foreign host, a link that opts out, nothing to carry yet).
260
+ * `record` is `null` while the visitor has not decided: a plugin that also carries something
261
+ * else (the language) still has a reason to decorate then.
262
+ */
263
+ decorate?: (url: URL, record: ConsentRecord | null, opts: ConsentOptions) => URL | null;
264
+ /** Extra domains this decision is understood to apply to, for disclosure — never deduplicated here. */
265
+ domains?: (opts: ConsentOptions) => string[];
266
+ /**
267
+ * Find the visitor's country, or throw when it cannot tell. Asked only while `opts.geo` is set
268
+ * and nothing is stored; locators run highest priority first and the first usable country wins,
269
+ * so a throw (or an unusable code) hands over to the next one — the built-in Cloudflare locator
270
+ * sits at the very bottom.
271
+ */
272
+ locate?: (opts: ConsentOptions) => Promise<ConsentGeoLocation>;
273
+ }
274
+ /**
275
+ * The country-detection plugin: one async method that resolves the visitor's country or throws.
276
+ * Register it with `consentPluginHelper.registerConsentPlugin` — or, in an OwlMeans application,
277
+ * with `@owlmeans/web-panel/consent`'s `appendConsentGeoPlugin(context, plugin)` while the context is
278
+ * configured.
279
+ */
280
+ export interface ConsentGeoPlugin extends ConsentPlugin {
281
+ locate: (opts: ConsentOptions) => Promise<ConsentGeoLocation>;
161
282
  }
162
283
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GACrB,YAAY,GAAG,cAAc,GAAG,oBAAoB,GACpD,mBAAmB,GAAG,uBAAuB,GAC7C,yBAAyB,GAAG,kBAAkB,CAAA;AAElD,MAAM,WAAW,eAAe;IAC9B,uEAAuE;IACvE,GAAG,EAAE,MAAM,CAAA;IACX;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OA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B,CAAA;IAC9B,iFAAiF;IACjF,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;IACxB,8CAA8C;IAC9C,CAAC,EAAE,MAAM,CAAA;IACT;;;;OAIG;IACH,CAAC,CAAC,EAAE,MAAM,CAAA;CACX;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,aAAa;IAC5B,qFAAqF;IACrF,KAAK,EAAE,MAAM,CAAA;IACb,iGAAiG;IACjG,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,2FAA2F;IAC3F,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAA;IACtC;;;;OAIG;IACH,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,aAAa,GAAG,IAAI,CAAA;IACtD;;;;;OAKG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,MAAM,GAAG,IAAI,CAAA;IACvD;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,EAAE,IAAI,EAAE,cAAc,KAAK,GAAG,GAAG,IAAI,CAAA;IACvF,uGAAuG;IACvG,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,MAAM,EAAE,CAAA;IAC5C;;;;;OAKG;IACH,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAA;CAC/D;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,MAAM,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAA;CAC9D"}
@@ -0,0 +1,9 @@
1
+ export interface ConsentWindow {
2
+ dataLayer?: unknown[];
3
+ [flag: string]: unknown;
4
+ }
5
+ /** The one navigator field the automatic decision reads: Global Privacy Control. */
6
+ export interface ConsentNavigator {
7
+ globalPrivacyControl?: boolean;
8
+ }
9
+ //# sourceMappingURL=types.local.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.local.d.ts","sourceRoot":"","sources":["../src/types.local.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,OAAO,EAAE,CAAA;IACrB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;CACxB;AAED,oFAAoF;AACpF,MAAM,WAAW,gBAAgB;IAC/B,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.local.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.local.js","sourceRoot":"","sources":["../src/types.local.ts"],"names":[],"mappings":""}