@owlmeans/consent 0.1.18-rc.9 → 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.
- package/README.md +229 -0
- package/build/consts.d.ts +78 -3
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +104 -0
- package/build/consts.js.map +1 -1
- package/build/consts.local.d.ts +12 -0
- package/build/consts.local.d.ts.map +1 -0
- package/build/consts.local.js +12 -0
- package/build/consts.local.js.map +1 -0
- package/build/geo/types.d.ts +47 -0
- package/build/geo/types.d.ts.map +1 -0
- package/build/geo/types.js +2 -0
- package/build/geo/types.js.map +1 -0
- package/build/geo.d.ts +4 -0
- package/build/geo.d.ts.map +1 -0
- package/build/geo.js +96 -0
- package/build/geo.js.map +1 -0
- package/build/gtobserver/types.d.ts +75 -0
- package/build/gtobserver/types.d.ts.map +1 -0
- package/build/gtobserver/types.js +2 -0
- package/build/gtobserver/types.js.map +1 -0
- package/build/gtobserver.d.ts +7 -0
- package/build/gtobserver.d.ts.map +1 -0
- package/build/gtobserver.js +142 -0
- package/build/gtobserver.js.map +1 -0
- package/build/i18n/be.json +8 -1
- package/build/i18n/de.json +8 -1
- package/build/i18n/en.json +8 -1
- package/build/i18n/es.json +8 -1
- package/build/i18n/fr.json +8 -1
- package/build/i18n/pl.json +8 -1
- package/build/i18n/ru.json +8 -1
- package/build/i18n/types.d.ts +11 -0
- package/build/i18n/types.d.ts.map +1 -0
- package/build/i18n/types.js +2 -0
- package/build/i18n/types.js.map +1 -0
- package/build/i18n/uk.json +8 -1
- package/build/i18n.d.ts +4 -14
- package/build/i18n.d.ts.map +1 -1
- package/build/i18n.js +12 -27
- package/build/i18n.js.map +1 -1
- package/build/index.d.ts +13 -5
- package/build/index.d.ts.map +1 -1
- package/build/index.js +5 -3
- package/build/index.js.map +1 -1
- package/build/linker/types.d.ts +59 -0
- package/build/linker/types.d.ts.map +1 -0
- package/build/linker/types.js +2 -0
- package/build/linker/types.js.map +1 -0
- package/build/linker.d.ts +5 -74
- package/build/linker.d.ts.map +1 -1
- package/build/linker.js +290 -324
- package/build/linker.js.map +1 -1
- package/build/plugins/types.d.ts +42 -0
- package/build/plugins/types.d.ts.map +1 -0
- package/build/plugins/types.js +2 -0
- package/build/plugins/types.js.map +1 -0
- package/build/plugins.d.ts +4 -68
- package/build/plugins.d.ts.map +1 -1
- package/build/plugins.js +73 -61
- package/build/plugins.js.map +1 -1
- package/build/storage/types.d.ts +31 -0
- package/build/storage/types.d.ts.map +1 -0
- package/build/storage/types.js +2 -0
- package/build/storage/types.js.map +1 -0
- package/build/storage.d.ts +6 -22
- package/build/storage.d.ts.map +1 -1
- package/build/storage.js +72 -81
- package/build/storage.js.map +1 -1
- package/build/store.d.ts +2 -2
- package/build/store.d.ts.map +1 -1
- package/build/store.js +115 -31
- package/build/store.js.map +1 -1
- package/build/types.d.ts +141 -5
- package/build/types.d.ts.map +1 -1
- package/build/types.local.d.ts +9 -0
- package/build/types.local.d.ts.map +1 -0
- package/build/types.local.js +2 -0
- package/build/types.local.js.map +1 -0
- package/package.json +3 -3
- package/src/consts.local.ts +16 -0
- package/src/consts.ts +120 -3
- package/src/geo/types.ts +49 -0
- package/src/geo.ts +122 -0
- package/src/gtobserver/types.ts +73 -0
- package/src/gtobserver.ts +182 -0
- package/src/i18n/be.json +8 -1
- package/src/i18n/de.json +8 -1
- package/src/i18n/en.json +8 -1
- package/src/i18n/es.json +8 -1
- package/src/i18n/fr.json +8 -1
- package/src/i18n/pl.json +8 -1
- package/src/i18n/ru.json +8 -1
- package/src/i18n/types.ts +11 -0
- package/src/i18n/uk.json +8 -1
- package/src/i18n.ts +20 -32
- package/src/index.ts +13 -12
- package/src/linker/types.ts +59 -0
- package/src/linker.ts +301 -349
- package/src/plugins/types.ts +42 -0
- package/src/plugins.ts +82 -105
- package/src/storage/types.ts +31 -0
- package/src/storage.ts +75 -77
- package/src/store.ts +125 -31
- package/src/types.local.ts +9 -0
- package/src/types.ts +148 -5
- package/tests/consent.spec.ts +26 -28
- package/tests/geo.spec.ts +474 -0
- package/tests/linker.spec.ts +68 -74
- package/tests/tracking.spec.ts +14 -14
- package/build/gtm.d.ts +0 -72
- package/build/gtm.d.ts.map +0 -1
- package/build/gtm.js +0 -182
- package/build/gtm.js.map +0 -1
- package/src/gtm.ts +0 -220
package/src/i18n/pl.json
CHANGED
|
@@ -32,5 +32,12 @@
|
|
|
32
32
|
"privacy": "Polityka prywatności",
|
|
33
33
|
"terms": "Regulamin",
|
|
34
34
|
"domains": "Ten wybór dotyczy: {{domains}}.",
|
|
35
|
-
"policyDomains": "Ten wybór dotyczy następujących domen:"
|
|
35
|
+
"policyDomains": "Ten wybór dotyczy następujących domen:",
|
|
36
|
+
"barTitle": "Pliki cookie w tym serwisie",
|
|
37
|
+
"barDescription": "Używamy niezbędnych plików cookie, aby serwis działał — do logowania, zapewnienia bezpieczeństwa i zapamiętania Twoich wyborów. Za Twoją zgodą użylibyśmy również tych opcjonalnych plików cookie: {{categories}}. Pozostają wyłączone, dopóki na nie nie zezwolisz, a swój wybór możesz w każdej chwili zmienić lub wycofać w preferencjach plików cookie.",
|
|
38
|
+
"barDescriptionEssential": "Ten serwis używa wyłącznie niezbędnych plików cookie — do logowania, zapewnienia bezpieczeństwa i zapamiętania Twoich wyborów. Nie wymagają one zgody i nie można ich wyłączyć.",
|
|
39
|
+
"acceptMandatory": "Akceptuj tylko niezbędne",
|
|
40
|
+
"locating": "Sprawdzamy Twój region…",
|
|
41
|
+
"autoReason": "Te ustawienia zastosowano automatycznie, ponieważ tam, skąd przeglądasz serwis, zgoda na pliki cookie nie jest wymagana. Możesz je zmienić w każdej chwili.",
|
|
42
|
+
"policyRegional": "Tam, gdzie prawo miejsca pobytu odwiedzającego wymaga uprzedniej zgody — w UE i EOG, w Wielkiej Brytanii, Szwajcarii i innych krajach o podobnych przepisach — opcjonalne pliki cookie pozostają wyłączone, dopóki odwiedzający na nie nie zezwoli. W pozostałych krajach są domyślnie włączone, chyba że przeglądarka wysyła sygnał Global Privacy Control, który traktujemy jako odmowę; w każdej chwili można je wyłączyć przyciskiem poniżej."
|
|
36
43
|
}
|
package/src/i18n/ru.json
CHANGED
|
@@ -32,5 +32,12 @@
|
|
|
32
32
|
"privacy": "Политика конфиденциальности",
|
|
33
33
|
"terms": "Условия использования",
|
|
34
34
|
"domains": "Этот выбор применяется к {{domains}}.",
|
|
35
|
-
"policyDomains": "Этот выбор применяется к следующим доменам:"
|
|
35
|
+
"policyDomains": "Этот выбор применяется к следующим доменам:",
|
|
36
|
+
"barTitle": "Файлы cookie на этом сайте",
|
|
37
|
+
"barDescription": "Мы используем необходимые файлы cookie для работы сайта — для входа, обеспечения безопасности и запоминания вашего выбора. С вашего согласия мы также использовали бы следующие необязательные файлы cookie: {{categories}}. Они остаются выключенными, пока вы их не разрешите, а свой выбор вы можете в любой момент изменить или отозвать в настройках файлов cookie.",
|
|
38
|
+
"barDescriptionEssential": "Этот сайт использует только необходимые файлы cookie — для входа, обеспечения безопасности и запоминания вашего выбора. Они не требуют согласия и не могут быть отключены.",
|
|
39
|
+
"acceptMandatory": "Принять только необходимые",
|
|
40
|
+
"locating": "Определяем ваш регион…",
|
|
41
|
+
"autoReason": "Эти настройки применены автоматически, поскольку там, откуда вы просматриваете сайт, согласие на файлы cookie не требуется. Вы можете изменить их в любой момент.",
|
|
42
|
+
"policyRegional": "Там, где закон места пребывания посетителя требует предварительного согласия, — в ЕС и ЕЭЗ, Великобритании, Швейцарии и других странах с аналогичными правилами — необязательные файлы cookie остаются выключенными, пока посетитель их не разрешит. В остальных странах они включены по умолчанию, кроме случаев, когда браузер передаёт сигнал Global Privacy Control, который учитывается как отказ; их можно отключить в любой момент кнопкой ниже."
|
|
36
43
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ConsentLocale } from '../types.js'
|
|
2
|
+
|
|
3
|
+
/** The dialog's built-in copy: the locale it is read in, the house translate shape, placeholders. */
|
|
4
|
+
export interface ConsentI18nHelper {
|
|
5
|
+
/** A locale reduced to one the built-in copy carries — its base tag, else `en`. */
|
|
6
|
+
normalizeLocale: (locale?: string) => ConsentLocale
|
|
7
|
+
/** `(key, defaultValue) => string`, the house shape, backed by the built-in bundle. */
|
|
8
|
+
defaultConsentTranslate: (locale?: string) => (key: string, defaultValue: string) => string
|
|
9
|
+
/** Substitute `{{name}}` placeholders. Enough for the two the policy page needs. */
|
|
10
|
+
interpolate: (text: string, values: Record<string, string | number>) => string
|
|
11
|
+
}
|
package/src/i18n/uk.json
CHANGED
|
@@ -32,5 +32,12 @@
|
|
|
32
32
|
"privacy": "Політика конфіденційності",
|
|
33
33
|
"terms": "Умови користування",
|
|
34
34
|
"domains": "Цей вибір застосовується до {{domains}}.",
|
|
35
|
-
"policyDomains": "Цей вибір застосовується до таких доменів:"
|
|
35
|
+
"policyDomains": "Цей вибір застосовується до таких доменів:",
|
|
36
|
+
"barTitle": "Файли cookie на цьому сайті",
|
|
37
|
+
"barDescription": "Ми використовуємо необхідні файли cookie для роботи сайту — для входу, забезпечення безпеки та запам'ятовування вашого вибору. За вашою згодою ми також використовували б такі необов'язкові файли cookie: {{categories}}. Вони залишаються вимкненими, доки ви їх не дозволите, а свій вибір ви можете будь-коли змінити або відкликати в налаштуваннях файлів cookie.",
|
|
38
|
+
"barDescriptionEssential": "Цей сайт використовує лише необхідні файли cookie — для входу, забезпечення безпеки та запам'ятовування вашого вибору. Вони не потребують згоди й не можуть бути вимкнені.",
|
|
39
|
+
"acceptMandatory": "Прийняти лише необхідні",
|
|
40
|
+
"locating": "Визначаємо ваш регіон…",
|
|
41
|
+
"autoReason": "Ці налаштування застосовано автоматично, оскільки там, звідки ви переглядаєте сайт, згода на файли cookie не потрібна. Ви можете змінити їх будь-коли.",
|
|
42
|
+
"policyRegional": "Там, де закон місця перебування відвідувача вимагає попередньої згоди, — у ЄС і ЄЕЗ, Великій Британії, Швейцарії та інших країнах із подібними правилами — необов'язкові файли cookie залишаються вимкненими, доки відвідувач їх не дозволить. В інших країнах вони ввімкнені за замовчуванням, крім випадків, коли браузер надсилає сигнал Global Privacy Control, який враховується як відмова; їх можна будь-коли вимкнути кнопкою нижче."
|
|
36
43
|
}
|
package/src/i18n.ts
CHANGED
|
@@ -1,39 +1,27 @@
|
|
|
1
|
-
import { CONSENT_LOCALES } from './consts.js'
|
|
2
|
-
import type { ConsentLocale } from './
|
|
1
|
+
import { CONSENT_LOCALES, DEFAULT_CONSENT_MESSAGES } from './consts.js'
|
|
2
|
+
import type { ConsentLocale } from './types.js'
|
|
3
|
+
import type { ConsentI18nHelper } from './i18n/types.js'
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import be from './i18n/be.json' with { type: 'json' }
|
|
8
|
-
import uk from './i18n/uk.json' with { type: 'json' }
|
|
9
|
-
import es from './i18n/es.json' with { type: 'json' }
|
|
10
|
-
import de from './i18n/de.json' with { type: 'json' }
|
|
11
|
-
import fr from './i18n/fr.json' with { type: 'json' }
|
|
5
|
+
export const createConsentI18nHelper = (): ConsentI18nHelper => {
|
|
6
|
+
const normalizeLocale = (locale?: string): ConsentLocale => {
|
|
7
|
+
const base = (locale ?? 'en').toLowerCase().split('-')[0]
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* overrides every one of these.
|
|
20
|
-
*/
|
|
21
|
-
export const DEFAULT_CONSENT_MESSAGES: Record<ConsentLocale, Record<string, string>> = {
|
|
22
|
-
en, pl, ru, be, uk, es, de, fr,
|
|
23
|
-
}
|
|
9
|
+
return CONSENT_LOCALES.includes(base as ConsentLocale) ? base as ConsentLocale : 'en'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const defaultConsentTranslate = (locale?: string) =>
|
|
13
|
+
(key: string, defaultValue: string): string =>
|
|
14
|
+
DEFAULT_CONSENT_MESSAGES[normalizeLocale(locale)]?.[key] ?? defaultValue
|
|
24
15
|
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
const interpolate = (text: string, values: Record<string, string | number>): string =>
|
|
17
|
+
text.replace(/\{\{([a-z]+)\}\}/gi, (whole, name: string) =>
|
|
18
|
+
values[name] != null ? String(values[name]) : whole)
|
|
27
19
|
|
|
28
|
-
return
|
|
20
|
+
return { normalizeLocale, defaultConsentTranslate, interpolate }
|
|
29
21
|
}
|
|
30
22
|
|
|
31
|
-
|
|
32
|
-
export const defaultConsentTranslate = (locale?: string) =>
|
|
33
|
-
(key: string, defaultValue: string): string =>
|
|
34
|
-
DEFAULT_CONSENT_MESSAGES[normalizeLocale(locale)]?.[key] ?? defaultValue
|
|
23
|
+
export const consentI18nHelper = createConsentI18nHelper()
|
|
35
24
|
|
|
36
|
-
/**
|
|
37
|
-
export const
|
|
38
|
-
|
|
39
|
-
values[name] != null ? String(values[name]) : whole)
|
|
25
|
+
/** @deprecated compat:factory-refactor — use `consentI18nHelper.defaultConsentTranslate(…)` */
|
|
26
|
+
export const defaultConsentTranslate = (locale?: string): (key: string, defaultValue: string) => string =>
|
|
27
|
+
consentI18nHelper.defaultConsentTranslate(locale)
|
package/src/index.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
export type * from './types.js'
|
|
2
|
+
export type * from './gtobserver/types.js'
|
|
3
|
+
export type * from './i18n/types.js'
|
|
4
|
+
export type * from './linker/types.js'
|
|
5
|
+
export type * from './plugins/types.js'
|
|
6
|
+
export type * from './storage/types.js'
|
|
7
|
+
export type * from './geo/types.js'
|
|
2
8
|
export * from './consts.js'
|
|
3
9
|
export * from './storage.js'
|
|
4
|
-
export * from './
|
|
10
|
+
export * from './gtobserver.js'
|
|
5
11
|
export * from './store.js'
|
|
6
12
|
export * from './i18n.js'
|
|
7
|
-
export
|
|
8
|
-
export {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} from './
|
|
12
|
-
export
|
|
13
|
-
export {
|
|
14
|
-
consentLinker, encodeConsentLink, decodeConsentLink, stripConsentLinkParam, consentLinkerScript,
|
|
15
|
-
writeConsentLanguage,
|
|
16
|
-
CONSENT_LINK_PARAM, CONSENT_LINK_MAX_AGE, CONSENT_LINK_SKEW,
|
|
17
|
-
} from './linker.js'
|
|
13
|
+
export * from './geo.js'
|
|
14
|
+
export type { ConsentPlugin } from './types.js'
|
|
15
|
+
export { createConsentPluginHelper, consentPluginHelper, decorateConsentUrl } from './plugins.js'
|
|
16
|
+
export type { ConsentLinkPayload } from './types.js'
|
|
17
|
+
export { createConsentLinkHelper, consentLinkHelper, encodeConsentLink, consentLinkerScript } from './linker.js'
|
|
18
|
+
export { CONSENT_LINK_PARAM, CONSENT_LINK_MAX_AGE, CONSENT_LINK_SKEW } from './consts.js'
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ConsentLinkPayload, ConsentOptions, ConsentPlugin, ConsentRecord } from '../types.js'
|
|
2
|
+
|
|
3
|
+
/** Cross-domain consent: the decorated-link parameter, the linker plugin and its inline twin. */
|
|
4
|
+
export interface ConsentLinkHelper {
|
|
5
|
+
/**
|
|
6
|
+
* The link parameter's value: the current document's decision as `c` (one `0`/`1` per optional
|
|
7
|
+
* category — empty while `record` is `null`, i.e. before the visitor has decided, and for an
|
|
8
|
+
* automatic decision, which is not the visitor's to carry) and, when
|
|
9
|
+
* `opts.linker.language` is set, the page's language as `l`.
|
|
10
|
+
*/
|
|
11
|
+
encodeConsentLink: (record: ConsentRecord | null, opts?: ConsentOptions) => string
|
|
12
|
+
/** Parse-only — no trust decision here, that is `consentLinker(opts).adopt`'s job. Never throws. */
|
|
13
|
+
decodeConsentLink: (value: string) => ConsentLinkPayload | null
|
|
14
|
+
/**
|
|
15
|
+
* Persist an adopted language where the application's i18n layer reads its explicit choice from —
|
|
16
|
+
* `linker.language.storageKey`, `owlmeans-lng` by default. Unconditional: the interface language is
|
|
17
|
+
* strictly necessary storage (the visitor picked it, and the site cannot speak to them without it),
|
|
18
|
+
* so no cookie decision — none yet, a refusal, an old record — stands between it and the device.
|
|
19
|
+
*
|
|
20
|
+
* It overwrites what is there on purpose: the carried language is the one the visitor was reading a
|
|
21
|
+
* moment ago, which outranks a choice they made on this domain some other day. Storage that refuses
|
|
22
|
+
* the write is not an error. Returns whether the language was written.
|
|
23
|
+
*/
|
|
24
|
+
writeConsentLanguage: (language: string, opts?: ConsentOptions) => boolean
|
|
25
|
+
/**
|
|
26
|
+
* Cross-domain consent: share this decision, and adopt one, between the domains named in
|
|
27
|
+
* `opts.linker.domains`.
|
|
28
|
+
*
|
|
29
|
+
* `start` decorates outgoing first-party links; `adopt` reads and validates an incoming one;
|
|
30
|
+
* `domains` discloses the list a dialog or policy page names. `decorate` is generic (a bare `URL`,
|
|
31
|
+
* no DOM) so the same trust rule serves a real anchor click and a programmatic navigation
|
|
32
|
+
* (`decorateConsentUrl`) alike — the `rel="noreferrer"` exemption is a DOM-only concept and is
|
|
33
|
+
* therefore checked by `start`'s click handler, never here.
|
|
34
|
+
*/
|
|
35
|
+
consentLinker: () => ConsentPlugin
|
|
36
|
+
/**
|
|
37
|
+
* Remove the link parameter from the visible URL, keeping every other parameter and the hash — the
|
|
38
|
+
* real-TS equivalent of what {@link consentLinkerScript}'s embedded fragment already did inline.
|
|
39
|
+
* Idempotent: a page with no head script calls this from `consentStore.init` and it strips once; a
|
|
40
|
+
* page that ALSO carried the head script finds the parameter already gone and does nothing.
|
|
41
|
+
*/
|
|
42
|
+
stripConsentLinkParam: (opts: ConsentOptions) => void
|
|
43
|
+
/**
|
|
44
|
+
* The inline `<head>` fragment that adopts a decorated link's decision and strips the parameter —
|
|
45
|
+
* standalone, so a page can stamp it even where nothing else here runs (a legal page with no tag
|
|
46
|
+
* script). `@owlmeans/web-gtm`'s `consentBootstrapScript` embeds this SAME fragment right after
|
|
47
|
+
* pushing Consent Mode's defaults, so a page that has both never runs it twice with different
|
|
48
|
+
* effect — the second attempt finds the parameter already gone and does nothing.
|
|
49
|
+
*
|
|
50
|
+
* Mirrors `consentLinker().adopt` exactly (v2, referrer + freshness/skew + full optional coverage +
|
|
51
|
+
* no existing record — or only an automatic one, which the visitor's own choice replaces), but as hand-rolled JS text rather than a call into this module — the same
|
|
52
|
+
* discipline `consentBootstrapScript`/`consentGateScript` already follow, because this has to run
|
|
53
|
+
* before any bundle (this module included) has loaded. The parameter is ALWAYS stripped via
|
|
54
|
+
* `history.replaceState`, whether or not the trust rule accepts it: a stale or foreign `owlcc` is
|
|
55
|
+
* exactly as much noise as an adopted one, and neither belongs in the visible URL or in what a page
|
|
56
|
+
* reload, a shared link or a browser history entry carries forward.
|
|
57
|
+
*/
|
|
58
|
+
consentLinkerScript: (opts: ConsentOptions) => string
|
|
59
|
+
}
|