@owlmeans/consent 0.1.18-rc.10

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 (76) hide show
  1. package/build/consts.d.ts +64 -0
  2. package/build/consts.d.ts.map +1 -0
  3. package/build/consts.js +90 -0
  4. package/build/consts.js.map +1 -0
  5. package/build/consts.local.d.ts +4 -0
  6. package/build/consts.local.d.ts.map +1 -0
  7. package/build/consts.local.js +4 -0
  8. package/build/consts.local.js.map +1 -0
  9. package/build/gtm.d.ts +72 -0
  10. package/build/gtm.d.ts.map +1 -0
  11. package/build/gtm.js +182 -0
  12. package/build/gtm.js.map +1 -0
  13. package/build/i18n/be.json +36 -0
  14. package/build/i18n/de.json +36 -0
  15. package/build/i18n/en.json +36 -0
  16. package/build/i18n/es.json +36 -0
  17. package/build/i18n/fr.json +36 -0
  18. package/build/i18n/pl.json +36 -0
  19. package/build/i18n/ru.json +36 -0
  20. package/build/i18n/uk.json +36 -0
  21. package/build/i18n.d.ts +16 -0
  22. package/build/i18n.d.ts.map +1 -0
  23. package/build/i18n.js +29 -0
  24. package/build/i18n.js.map +1 -0
  25. package/build/index.d.ts +12 -0
  26. package/build/index.d.ts.map +1 -0
  27. package/build/index.js +9 -0
  28. package/build/index.js.map +1 -0
  29. package/build/linker.d.ts +55 -0
  30. package/build/linker.d.ts.map +1 -0
  31. package/build/linker.js +334 -0
  32. package/build/linker.js.map +1 -0
  33. package/build/plugins.d.ts +30 -0
  34. package/build/plugins.d.ts.map +1 -0
  35. package/build/plugins.js +73 -0
  36. package/build/plugins.js.map +1 -0
  37. package/build/storage.d.ts +27 -0
  38. package/build/storage.d.ts.map +1 -0
  39. package/build/storage.js +86 -0
  40. package/build/storage.js.map +1 -0
  41. package/build/store.d.ts +16 -0
  42. package/build/store.d.ts.map +1 -0
  43. package/build/store.js +100 -0
  44. package/build/store.js.map +1 -0
  45. package/build/types.d.ts +205 -0
  46. package/build/types.d.ts.map +1 -0
  47. package/build/types.js +2 -0
  48. package/build/types.js.map +1 -0
  49. package/build/types.local.d.ts +5 -0
  50. package/build/types.local.d.ts.map +1 -0
  51. package/build/types.local.js +2 -0
  52. package/build/types.local.js.map +1 -0
  53. package/package.json +33 -0
  54. package/src/consts.local.ts +4 -0
  55. package/src/consts.ts +103 -0
  56. package/src/gtm.ts +216 -0
  57. package/src/i18n/be.json +36 -0
  58. package/src/i18n/de.json +36 -0
  59. package/src/i18n/en.json +36 -0
  60. package/src/i18n/es.json +36 -0
  61. package/src/i18n/fr.json +36 -0
  62. package/src/i18n/pl.json +36 -0
  63. package/src/i18n/ru.json +36 -0
  64. package/src/i18n/uk.json +36 -0
  65. package/src/i18n.ts +39 -0
  66. package/src/index.ts +14 -0
  67. package/src/linker.ts +369 -0
  68. package/src/plugins.ts +88 -0
  69. package/src/storage.ts +96 -0
  70. package/src/store.ts +126 -0
  71. package/src/types.local.ts +4 -0
  72. package/src/types.ts +218 -0
  73. package/tests/consent.spec.ts +256 -0
  74. package/tests/linker.spec.ts +774 -0
  75. package/tests/tracking.spec.ts +191 -0
  76. package/tsconfig.json +11 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linker.js","sourceRoot":"","sources":["../src/linker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAErM,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGtE,MAAM,YAAY,GAAG,CAAC,IAAqB,EAAqB,EAAE,CAChE,IAAI,EAAE,UAAU,IAAI,0BAA0B,CAAA;AAEhD,MAAM,UAAU,GAAG,CAAC,IAAqB,EAAqB,EAA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2
+ /** Register a plugin. Replace-by-alias; sorted by priority (higher first) on every read. */
3
+ export declare const registerConsentPlugin: (plugin: ConsentPlugin) => void;
4
+ /** Every registered plugin, priority-sorted (higher first, ties keep insertion order). */
5
+ export declare const consentPlugins: () => ConsentPlugin[];
6
+ /**
7
+ * Ask every registered plugin to decorate `url` with this document's decision, in priority order,
8
+ * stopping at the first one that actually changes it. A plugin whose own rules refuse (a foreign
9
+ * host, a `noreferrer` link, no local decision yet) returns `null` and is skipped, not an error.
10
+ */
11
+ export declare const decorateConsentUrl: (url: string | URL, record: ConsentRecord | null, opts: ConsentOptions) => URL;
12
+ /**
13
+ * Every domain this document's decision is disclosed to, current host first, deduplicated — what a
14
+ * dialog or a policy page lists. A plugin that runs on this host but names no domains of its own
15
+ * (nothing registered, or `domains` not implemented) leaves the list at just the current host,
16
+ * which is always correct to show even with no plugin at all.
17
+ */
18
+ export declare const consentDomains: (opts: ConsentOptions) => string[];
19
+ /** Try every registered plugin's `adopt`, in priority order, and use the first decision offered. */
20
+ export declare const adoptConsent: (opts: ConsentOptions) => ConsentRecord | null;
21
+ /**
22
+ * Try every registered plugin's `adoptLanguage`, in priority order, and use the first language
23
+ * offered. The caller persists it (`writeConsentLanguage`) — and has to do that BEFORE its i18n
24
+ * layer reads storage, which is why the inline `<head>` fragment (`consentLinkerScript`) is the
25
+ * one that normally does.
26
+ */
27
+ export declare const adoptConsentLanguage: (opts: ConsentOptions) => string | null;
28
+ /** Run every registered plugin's `start`, in priority order. `consentStore.init` calls this once. */
29
+ export declare const startConsentPlugins: (opts: ConsentOptions) => void;
30
+ //# sourceMappingURL=plugins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAS9E,4FAA4F;AAC5F,eAAO,MAAM,qBAAqB,WAAY,aAAa,KAAG,IAE7D,CAAA;AAED,0FAA0F;AAC1F,eAAO,MAAM,cAAc,QAAO,aAAa,EAC8B,CAAA;AAE7E;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,QACxB,MAAM,GAAG,GAAG,UAAU,aAAa,GAAG,IAAI,QAAQ,cAAc,KACpE,GAaF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,SAAU,cAAc,KAAG,MAAM,EAK3D,CAAA;AAED,oGAAoG;AACpG,eAAO,MAAM,YAAY,SAAU,cAAc,KAAG,aAAa,GAAG,IASnE,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,SAAU,cAAc,KAAG,MAAM,GAAG,IASpE,CAAA;AAED,qGAAqG;AACrG,eAAO,MAAM,mBAAmB,SAAU,cAAc,KAAG,IAI1D,CAAA"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Module-global by design, like `@owlmeans/client-auth/login`'s method/step registries: consent is
3
+ * one thing per document, not per component tree, and a plugin is installed once at bundle scope
4
+ * (an Astro island, a script tag, a React app) regardless of how many components read the store.
5
+ */
6
+ const plugins = new Map();
7
+ /** Register a plugin. Replace-by-alias; sorted by priority (higher first) on every read. */
8
+ export const registerConsentPlugin = (plugin) => {
9
+ plugins.set(plugin.alias, plugin);
10
+ };
11
+ /** Every registered plugin, priority-sorted (higher first, ties keep insertion order). */
12
+ export const consentPlugins = () => [...plugins.values()].sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
13
+ /**
14
+ * Ask every registered plugin to decorate `url` with this document's decision, in priority order,
15
+ * stopping at the first one that actually changes it. A plugin whose own rules refuse (a foreign
16
+ * host, a `noreferrer` link, no local decision yet) returns `null` and is skipped, not an error.
17
+ */
18
+ export const decorateConsentUrl = (url, record, opts) => {
19
+ let result = url instanceof URL ? url : new URL(url);
20
+ for (const plugin of consentPlugins()) {
21
+ if (plugin.decorate == null) {
22
+ continue;
23
+ }
24
+ const decorated = plugin.decorate(result, record, opts);
25
+ if (decorated != null) {
26
+ result = decorated;
27
+ }
28
+ }
29
+ return result;
30
+ };
31
+ /**
32
+ * Every domain this document's decision is disclosed to, current host first, deduplicated — what a
33
+ * dialog or a policy page lists. A plugin that runs on this host but names no domains of its own
34
+ * (nothing registered, or `domains` not implemented) leaves the list at just the current host,
35
+ * which is always correct to show even with no plugin at all.
36
+ */
37
+ export const consentDomains = (opts) => {
38
+ const host = typeof location !== 'undefined' ? location.hostname : '';
39
+ const named = consentPlugins().flatMap(plugin => plugin.domains?.(opts) ?? []);
40
+ return [...new Set([host, ...named].filter(domain => domain !== ''))];
41
+ };
42
+ /** Try every registered plugin's `adopt`, in priority order, and use the first decision offered. */
43
+ export const adoptConsent = (opts) => {
44
+ for (const plugin of consentPlugins()) {
45
+ const adopted = plugin.adopt?.(opts);
46
+ if (adopted != null) {
47
+ return adopted;
48
+ }
49
+ }
50
+ return null;
51
+ };
52
+ /**
53
+ * Try every registered plugin's `adoptLanguage`, in priority order, and use the first language
54
+ * offered. The caller persists it (`writeConsentLanguage`) — and has to do that BEFORE its i18n
55
+ * layer reads storage, which is why the inline `<head>` fragment (`consentLinkerScript`) is the
56
+ * one that normally does.
57
+ */
58
+ export const adoptConsentLanguage = (opts) => {
59
+ for (const plugin of consentPlugins()) {
60
+ const adopted = plugin.adoptLanguage?.(opts);
61
+ if (adopted != null) {
62
+ return adopted;
63
+ }
64
+ }
65
+ return null;
66
+ };
67
+ /** Run every registered plugin's `start`, in priority order. `consentStore.init` calls this once. */
68
+ export const startConsentPlugins = (opts) => {
69
+ for (const plugin of consentPlugins()) {
70
+ plugin.start?.(opts);
71
+ }
72
+ };
73
+ //# sourceMappingURL=plugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAA;AAEhD,4FAA4F;AAC5F,MAAM,CAAC,MAAM,qBAAqB,GAA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record up to the current shape.
4
+ *
5
+ * A record with no `v` was written before the essential category existed, when it was implicitly
6
+ * always granted. The visitor DID choose; upgrading in place honours that choice, where treating
7
+ * the record as unusable would re-prompt everyone who has ever visited.
8
+ */
9
+ export declare const migrateConsent: (raw: ConsentRecord | null) => ConsentRecord | null;
10
+ /**
11
+ * What this browser has already chosen, or null.
12
+ *
13
+ * localStorage first and the cookie second, because that is the order the widget this generalises
14
+ * used and the two can disagree: a visitor who cleared site data but kept cookies still has an
15
+ * answer, and asking them again would be wrong.
16
+ */
17
+ export declare const readConsent: (opts?: ConsentOptions) => ConsentRecord | null;
18
+ /**
19
+ * Record the choice in both places.
20
+ *
21
+ * Two stores rather than one because neither is reliable alone: localStorage is cleared by "clear
22
+ * site data" while the cookie survives it, and the cookie is refused where third-party storage is
23
+ * blocked while localStorage may not be.
24
+ */
25
+ export declare const writeConsent: (record: ConsentRecord, opts?: ConsentOptions) => void;
26
+ export declare const clearConsent: (opts?: ConsentOptions) => void;
27
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAiB/D;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,QAAS,aAAa,GAAG,IAAI,KAAG,aAAa,GAAG,IAGH,CAAA;AAWxE;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,UAAW,cAAc,KAAG,aAAa,GAAG,IAQnE,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,WAAY,aAAa,SAAS,cAAc,KAAG,IAkB3E,CAAA;AAED,eAAO,MAAM,YAAY,UAAW,cAAc,KAAG,IAUpD,CAAA"}
@@ -0,0 +1,86 @@
1
+ import { CONSENT_COOKIE_DAYS, CONSENT_ESSENTIAL, CONSENT_KEY, CONSENT_SCHEMA_VERSION, } from './consts.js';
2
+ const key = (opts) => opts?.storageKey ?? CONSENT_KEY;
3
+ const parse = (raw) => {
4
+ if (raw == null || raw === '') {
5
+ return null;
6
+ }
7
+ try {
8
+ const value = JSON.parse(raw);
9
+ return value != null && typeof value === 'object' ? value : null;
10
+ }
11
+ catch {
12
+ return null;
13
+ }
14
+ };
15
+ /**
16
+ * Bring a stored record up to the current shape.
17
+ *
18
+ * A record with no `v` was written before the essential category existed, when it was implicitly
19
+ * always granted. The visitor DID choose; upgrading in place honours that choice, where treating
20
+ * the record as unusable would re-prompt everyone who has ever visited.
21
+ */
22
+ export const migrateConsent = (raw) => raw == null ? null
23
+ : raw.v === CONSENT_SCHEMA_VERSION ? raw
24
+ : { ...raw, [CONSENT_ESSENTIAL]: true, v: CONSENT_SCHEMA_VERSION };
25
+ const fromCookie = (name) => {
26
+ if (typeof document === 'undefined') {
27
+ return null;
28
+ }
29
+ const parts = `; ${document.cookie}`.split(`; ${name}=`);
30
+ return parts.length === 2 ? parts.pop()?.split(';').shift() ?? null : null;
31
+ };
32
+ /**
33
+ * What this browser has already chosen, or null.
34
+ *
35
+ * localStorage first and the cookie second, because that is the order the widget this generalises
36
+ * used and the two can disagree: a visitor who cleared site data but kept cookies still has an
37
+ * answer, and asking them again would be wrong.
38
+ */
39
+ export const readConsent = (opts) => {
40
+ const name = key(opts);
41
+ let raw = null;
42
+ try {
43
+ raw = typeof localStorage !== 'undefined' ? localStorage.getItem(name) : null;
44
+ }
45
+ catch { /* private modes and blocked storage both throw; the cookie may still answer */ }
46
+ return migrateConsent(parse(raw) ?? parse(fromCookie(name)));
47
+ };
48
+ /**
49
+ * Record the choice in both places.
50
+ *
51
+ * Two stores rather than one because neither is reliable alone: localStorage is cleared by "clear
52
+ * site data" while the cookie survives it, and the cookie is refused where third-party storage is
53
+ * blocked while localStorage may not be.
54
+ */
55
+ export const writeConsent = (record, opts) => {
56
+ const name = key(opts);
57
+ const value = JSON.stringify({ ...record, v: CONSENT_SCHEMA_VERSION });
58
+ try {
59
+ if (typeof localStorage !== 'undefined') {
60
+ localStorage.setItem(name, value);
61
+ }
62
+ }
63
+ catch { /* the cookie below is the fallback */ }
64
+ if (typeof document === 'undefined') {
65
+ return;
66
+ }
67
+ const days = opts?.cookieDays ?? CONSENT_COOKIE_DAYS;
68
+ const expires = new Date(Date.now() + days * 24 * 60 * 60 * 1000).toUTCString();
69
+ const domain = opts?.cookieDomain != null ? `;domain=${opts.cookieDomain}` : '';
70
+ // `SameSite=Lax` is stated rather than left to the browser default, which differs between them.
71
+ // This cookie is never sent cross-site on purpose — it records a preference, not a session.
72
+ document.cookie = `${name}=${value};expires=${expires};path=/;SameSite=Lax${domain}`;
73
+ };
74
+ export const clearConsent = (opts) => {
75
+ const name = key(opts);
76
+ try {
77
+ if (typeof localStorage !== 'undefined') {
78
+ localStorage.removeItem(name);
79
+ }
80
+ }
81
+ catch { /* nothing to remove if storage was never available */ }
82
+ if (typeof document !== 'undefined') {
83
+ document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/`;
84
+ }
85
+ };
86
+ //# sourceMappingURL=storage.js.map
@@ -0,0 +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,QA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C1D,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,CAAA;IACtB,IAAI,CAAC;QACH,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE,CAAC;YACxC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QAC/B,CAAC;IACH,CAAC;IAAC,MAAM,CAAC,CAAC,sDAAsD,CAAC,CAAC;IAClE,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;QACpC,QAAQ,CAAC,MAAM,GAAG,GAAG,IAAI,gDAAgD,CAAA;IAC3E,CAAC;AACH,CAAC,CAAA"}
@@ -0,0 +1,16 @@
1
+ import type { ConsentReason, ConsentStore } from './types.js';
2
+ /**
3
+ * The consent state of this DOCUMENT.
4
+ *
5
+ * A module singleton rather than something hung off a context, because that is what consent
6
+ * actually is — a property of the browser and the page, not of one component tree. It also has to
7
+ * be reachable from places that are not React at all: the sign-in precondition runs inside a click
8
+ * handler, and a tag-manager helper runs before any component has mounted.
9
+ */
10
+ export declare const makeConsentStore: () => ConsentStore;
11
+ export declare const consentStore: ConsentStore;
12
+ /** Open the preferences dialog from anywhere — a footer link, a policy page, a login gate. */
13
+ export declare const openConsent: (reason?: ConsentReason) => void;
14
+ /** Whether a category is granted, for the callers that are not components. */
15
+ export declare const isConsented: (key: string) => boolean;
16
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACuB,aAAa,EAA+B,YAAY,EAC1F,MAAM,YAAY,CAAA;AAEnB;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,QAAO,YAoGnC,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"}
package/build/store.js ADDED
@@ -0,0 +1,100 @@
1
+ import { CONSENT_KEY, DEFAULT_CONSENT_CATEGORIES } from './consts.js';
2
+ import { applyConsent, pushConsentDefaults } from './gtm.js';
3
+ import { consentLinker, stripConsentLinkParam, writeConsentLanguage } from './linker.js';
4
+ import { adoptConsent, adoptConsentLanguage, registerConsentPlugin, startConsentPlugins } from './plugins.js';
5
+ import { readConsent, writeConsent } from './storage.js';
6
+ /**
7
+ * The consent state of this DOCUMENT.
8
+ *
9
+ * A module singleton rather than something hung off a context, because that is what consent
10
+ * actually is — a property of the browser and the page, not of one component tree. It also has to
11
+ * be reachable from places that are not React at all: the sign-in precondition runs inside a click
12
+ * handler, and a tag-manager helper runs before any component has mounted.
13
+ */
14
+ export const makeConsentStore = () => {
15
+ const listeners = new Set();
16
+ let state = { record: null, open: false, reason: null };
17
+ let options = {};
18
+ const publish = (next) => {
19
+ state = { ...state, ...next };
20
+ listeners.forEach(listener => listener(state));
21
+ };
22
+ const resolved = () => ({
23
+ ...options,
24
+ categories: options.categories ?? DEFAULT_CONSENT_CATEGORIES,
25
+ storageKey: options.storageKey ?? CONSENT_KEY,
26
+ });
27
+ const store = {
28
+ get: () => state,
29
+ subscribe: listener => {
30
+ listeners.add(listener);
31
+ return () => { listeners.delete(listener); };
32
+ },
33
+ init: opts => {
34
+ options = { ...options, ...opts };
35
+ // Before anything is read, so a page with no stored answer still declares what is denied.
36
+ pushConsentDefaults(options);
37
+ if (options.linker != null) {
38
+ // Replace-by-alias (`registerConsentPlugin`), so a second `init` (a re-mounted provider,
39
+ // StrictMode) never double-installs the click listener — `consentLinker().start` also
40
+ // guards itself with its own closured flag, belt and braces.
41
+ registerConsentPlugin(consentLinker());
42
+ startConsentPlugins(options);
43
+ }
44
+ let record = readConsent(options);
45
+ // Only when THIS document has no decision yet — an existing one always wins, exactly as the
46
+ // ordinary "ask" path would never overwrite a stored record either.
47
+ if (record == null && options.linker != null) {
48
+ record = adoptConsent(options);
49
+ if (record != null) {
50
+ writeConsent(record, options);
51
+ }
52
+ }
53
+ if (options.linker != null) {
54
+ // The language the link carried, stored at once — the interface language is strictly
55
+ // necessary storage, so no decision is consulted. A page that stamped the inline head
56
+ // fragment has already done this and stripped the parameter, which leaves nothing here.
57
+ const carried = adoptConsentLanguage(options);
58
+ if (carried != null) {
59
+ writeConsentLanguage(carried, options);
60
+ }
61
+ // Always, whether or not anything was adopted — a stale or foreign parameter is exactly as
62
+ // much noise in the visible URL as an adopted one, and a page that already had its own
63
+ // decision may still have arrived with one attached.
64
+ stripConsentLinkParam(options);
65
+ }
66
+ if (record != null) {
67
+ applyConsent(record, options);
68
+ publish({ record, open: false, reason: null });
69
+ return;
70
+ }
71
+ publish({ record: null, open: true, reason: 'initial' });
72
+ },
73
+ save: record => {
74
+ writeConsent(record, options);
75
+ applyConsent(record, options);
76
+ publish({ record, open: false, reason: null });
77
+ },
78
+ acceptAll: () => {
79
+ const record = Object.fromEntries(resolved().categories.map(category => [category.key, true]));
80
+ store.save(record);
81
+ },
82
+ open: (reason) => { publish({ open: true, reason: reason ?? 'reopen' }); },
83
+ close: () => { publish({ open: false, reason: null }); },
84
+ granted: key => {
85
+ const category = resolved().categories.find(candidate => candidate.key === key);
86
+ if (category?.required === true) {
87
+ return true;
88
+ }
89
+ return state.record?.[key] === true;
90
+ },
91
+ options: resolved,
92
+ };
93
+ return store;
94
+ };
95
+ export const consentStore = makeConsentStore();
96
+ /** Open the preferences dialog from anywhere — a footer link, a policy page, a login gate. */
97
+ export const openConsent = (reason) => consentStore.open(reason);
98
+ /** Whether a category is granted, for the callers that are not components. */
99
+ export const isConsented = (key) => consentStore.granted(key);
100
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAA;AACrE,OAAO,EAAE,YAAY,EAAE,m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G,CAAC,KAAK,IAAI,CAAA;QACrC,CAAC;QAED,OAAO,EAAE,QAAQ;KAClB,CAAA;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAiB,gBAAgB,EAAE,CAAA;AAE5D,8FAA8F;AAC9F,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAsB,EAAQ,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AAEtF,8EAA8E;AAC9E,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAW,EAAW,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA"}
@@ -0,0 +1,205 @@
1
+ /**
2
+ * Google Consent Mode v2 signals.
3
+ *
4
+ * Named here rather than left as free strings because a typo in a signal name is silent: the tag
5
+ * manager simply never sees the update, and the only symptom is analytics that stay switched off
6
+ * for everyone who agreed to them.
7
+ */
8
+ import { CONSENT_LINK_VERSION } from './consts.local.js';
9
+ import { CONSENT_LOCALES } from './consts.js';
10
+ export type ConsentSignal = 'ad_storage' | 'ad_user_data' | 'ad_personalization' | 'analytics_storage' | 'functionality_storage' | 'personalization_storage' | 'security_storage';
11
+ export interface ConsentCategory {
12
+ /** Stable storage key. `essential` is reserved and always required. */
13
+ key: string;
14
+ /**
15
+ * Always granted, rendered locked and labelled as required.
16
+ *
17
+ * Strictly-necessary storage does not need consent, and a dialog that presents it as a choice is
18
+ * itself a dark pattern. A required category is disclosure, not a question.
19
+ */
20
+ required?: boolean;
21
+ /** Resolved through `translate`; the built-in bundle supplies the default set in 8 languages. */
22
+ labelKey: string;
23
+ descriptionKey: string;
24
+ /**
25
+ * The window global this category yields to: `window[globalVar] = granted`, written on every
26
+ * apply and BEFORE the tag-manager push.
27
+ *
28
+ * This is the seam for anything that cannot subscribe — a custom-HTML tag reading a flag, a
29
+ * hand-placed pixel, a script that only ever runs once. Without it, integrating a tag that is
30
+ * not Consent-Mode-aware means reaching into this package.
31
+ */
32
+ globalVar?: string;
33
+ /** Consent Mode v2 signals this category drives. */
34
+ signals?: ConsentSignal[];
35
+ /** dataLayer event pushed when this category transitions from denied to granted. */
36
+ event?: string;
37
+ }
38
+ /**
39
+ * One third-party service the site runs under a consent category, as the cookie policy discloses
40
+ * it.
41
+ *
42
+ * A category says WHY something is stored; a service says WHO receives it. A regulator reading
43
+ * the policy wants the second — "analytics cookies" discloses nothing about which company learns
44
+ * what a visitor did — so a site that runs a tag lists it here, beside the category that gates
45
+ * it. Plain data rather than keys: the name, the provider and the purpose are whatever the party
46
+ * adding the tag knows about it, and `@owlmeans/web-gtm`'s `googleTagServices(id)` is the
47
+ * disclosure for a Google tag.
48
+ */
49
+ export interface ConsentService {
50
+ /** Display name: "Google Analytics". */
51
+ name: string;
52
+ /** Who receives the data: "Google LLC". */
53
+ provider: string;
54
+ /**
55
+ * The `ConsentCategory.key` this service runs under: `'analytics'`, `'marketing'`,
56
+ * `'essential'`, or a custom key. A service whose category is not in force is still disclosed,
57
+ * in a trailing group of its own — hiding it would hide something that may still run.
58
+ */
59
+ category: string;
60
+ /** One sentence on what it does with the data. */
61
+ purpose?: string;
62
+ /** Cookie names it may set: `['_ga', '_ga_<ID>']`. */
63
+ cookies?: string[];
64
+ /** The provider's own privacy policy. */
65
+ privacyHref?: string;
66
+ }
67
+ /** `v` is the schema version; every other key is a category key. */
68
+ export interface ConsentRecord {
69
+ v?: number;
70
+ [category: string]: boolean | number | undefined;
71
+ }
72
+ export interface ConsentOptions {
73
+ categories?: ConsentCategory[];
74
+ storageKey?: string;
75
+ cookieDays?: number;
76
+ /**
77
+ * Left undefined by default, and that is deliberate: setting a domain orphans the existing
78
+ * host-only cookie, so every visitor who has already chosen would be asked again.
79
+ */
80
+ cookieDomain?: string;
81
+ /** Skip every dataLayer and global write. For tests, and for an app that runs no tags. */
82
+ silent?: boolean;
83
+ /**
84
+ * Cross-domain consent: share this decision, and adopt one, between the listed first-party
85
+ * domains — a visitor who already decided on one need not decide again on another. See
86
+ * `consentLinker`/`ConsentPlugin` in `./plugins.js` and `./linker.js`.
87
+ */
88
+ linker?: ConsentLinkerOptions;
89
+ }
90
+ export interface ConsentLinkerOptions {
91
+ /**
92
+ * Every domain this decision is shared with, the current host included or not — either way, the
93
+ * current host is always part of the disclosed list (`consentDomains`), since a visitor reads
94
+ * "applies to" as the whole set, not just the others.
95
+ */
96
+ domains: string[];
97
+ /** The URL parameter a decorated link carries the decision in. Defaults to `owlcc`. */
98
+ param?: string;
99
+ /** How old a decorated link's timestamp may be and still be trusted, in seconds. Defaults to 300. */
100
+ maxAge?: number;
101
+ /**
102
+ * Carry the visitor's interface language along with the decision, so a visitor reading the site
103
+ * in Polish arrives on the next domain in Polish. Its PRESENCE turns the sending side on (a link
104
+ * to a listed domain carries this document's `<html lang>`); `supported` turns the receiving side
105
+ * on — which stores the carried language whatever the cookie decision says, because the interface
106
+ * language is strictly necessary. See `ConsentLinkerLanguage`.
107
+ */
108
+ language?: ConsentLinkerLanguage;
109
+ }
110
+ export interface ConsentLinkerLanguage {
111
+ /**
112
+ * RECEIVING side: the languages this application can render. A carried language is adopted only
113
+ * when it is one of these, exactly or by its base tag (`de-DE` → `de`), and is then stored at
114
+ * once — the interface language is strictly necessary storage, so no cookie decision gates it;
115
+ * anything else is ignored and the application keeps choosing its own. Leave it out on a site
116
+ * that only SENDS its language.
117
+ */
118
+ supported?: string[];
119
+ /**
120
+ * RECEIVING side: the `localStorage` key an explicit language choice lives under. Defaults to
121
+ * `owlmeans-lng`, the key `@owlmeans/client-i18n` reads before it renders anything.
122
+ */
123
+ storageKey?: string;
124
+ }
125
+ /** Why the dialog is open. `login` is what the sign-in precondition raises. */
126
+ export type ConsentReason = 'initial' | 'reopen' | 'login' | string;
127
+ export interface ConsentState {
128
+ record: ConsentRecord | null;
129
+ open: boolean;
130
+ reason: ConsentReason | null;
131
+ }
132
+ export type ConsentListener = (state: ConsentState) => void;
133
+ export interface ConsentStore {
134
+ get: () => ConsentState;
135
+ subscribe: (listener: ConsentListener) => () => void;
136
+ /** Push the defaults, load and migrate any stored record, apply it, and open when there is none. */
137
+ init: (opts?: ConsentOptions) => void;
138
+ save: (record: ConsentRecord) => void;
139
+ acceptAll: () => void;
140
+ open: (reason?: ConsentReason) => void;
141
+ close: () => void;
142
+ /** Imperative reader, for the callers that are not React. */
143
+ granted: (key: string) => boolean;
144
+ options: () => ConsentOptions & {
145
+ categories: ConsentCategory[];
146
+ storageKey: string;
147
+ };
148
+ }
149
+ export type ConsentLocale = (typeof CONSENT_LOCALES)[number];
150
+ /** The decoded, not-yet-validated payload a decorated link's parameter carries. */
151
+ export interface ConsentLinkPayload {
152
+ v: typeof CONSENT_LINK_VERSION;
153
+ /** One entry per OPTIONAL category this site knows, `1` granted / `0` denied. */
154
+ c: Record<string, 0 | 1>;
155
+ /** Unix seconds the link was decorated at. */
156
+ t: number;
157
+ /**
158
+ * The interface language of the page the link was on (a BCP 47 tag, lower-cased) — present only
159
+ * when the sender has `linker.language` set and its `<html lang>` names one. Optional on the
160
+ * wire, so a receiver that predates it reads the same `v: 2` payload and ignores the field.
161
+ */
162
+ l?: string;
163
+ }
164
+ /**
165
+ * An extension seam for `@owlmeans/consent`: something that reacts to this document's consent
166
+ * decision, or supplies one from elsewhere, without the core store knowing anything about where
167
+ * that decision came from.
168
+ *
169
+ * `consentLinker` (`./linker.js`) is the one built-in plugin — cross-domain consent through
170
+ * decorated links — but nothing here is specific to it. A registry rather than a fixed option on
171
+ * `ConsentOptions` because the store has zero dependencies today and stays that way: a plugin is
172
+ * opt-in code an application imports for its own reason, never a bundled feature this package
173
+ * pulls in whether or not anything uses it.
174
+ */
175
+ export interface ConsentPlugin {
176
+ /** Stable identity. Registering the same alias again REPLACES the earlier plugin. */
177
+ alias: string;
178
+ /** Run order when more than one plugin implements the same hook. Higher first. Defaults to 0. */
179
+ priority?: number;
180
+ /** Installed once, the first time `consentStore.init` runs with this plugin registered. */
181
+ start?: (opts: ConsentOptions) => void;
182
+ /**
183
+ * Offer a decision from outside this document's own storage — e.g. one carried on the URL that
184
+ * led here. Returns a full record to adopt, or `null` to defer to the next plugin / the ordinary
185
+ * "ask" path. Never called once a stored record already exists.
186
+ */
187
+ adopt?: (opts: ConsentOptions) => ConsentRecord | null;
188
+ /**
189
+ * Offer an interface language from outside this document's own storage — e.g. the one the page
190
+ * that led here was read in. Returns a language the application supports, or `null` to keep
191
+ * choosing its own. Only a CANDIDATE: it says what the link carried, and `writeConsentLanguage`
192
+ * stores it — unconditionally, since the interface language is strictly necessary storage.
193
+ */
194
+ adoptLanguage?: (opts: ConsentOptions) => string | null;
195
+ /**
196
+ * Rewrite an outgoing URL to carry this document's current decision — and its language — or
197
+ * `null` to leave it untouched (a foreign host, a link that opts out, nothing to carry yet).
198
+ * `record` is `null` while the visitor has not decided: a plugin that also carries something
199
+ * else (the language) still has a reason to decorate then.
200
+ */
201
+ decorate?: (url: URL, record: ConsentRecord | null, opts: ConsentOptions) => URL | null;
202
+ /** Extra domains this decision is understood to apply to, for disclosure — never deduplicated here. */
203
+ domains?: (opts: ConsentOptions) => string[];
204
+ }
205
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C,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,OAAO,CAAA;IAClB,iGAAiG;IACjG,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE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,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;CAC7C"}
package/build/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export interface ConsentWindow {
2
+ dataLayer?: unknown[];
3
+ [flag: string]: unknown;
4
+ }
5
+ //# 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"}
@@ -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":""}