@tilli-pro/cookieconsent-plugin 0.1.0
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/eslint.config.js +13 -0
- package/package.json +38 -0
- package/src/_consts.ts +8 -0
- package/src/assets/cookie.ts +11 -0
- package/src/assets/index.ts +5 -0
- package/src/assets/logo.ts +21 -0
- package/src/config/categories/index.ts +53 -0
- package/src/config/categories/labels.ts +20 -0
- package/src/config/cookies/_utils.server.ts +24 -0
- package/src/config/cookies/_utils.ts +53 -0
- package/src/config/cookies/analytics/datadog.ts +38 -0
- package/src/config/cookies/common-translations.ts +31 -0
- package/src/config/cookies/functional/brf/v2.ts +34 -0
- package/src/config/cookies/index.ts +22 -0
- package/src/config/cookies/necessary/brf/v2-auth.ts +51 -0
- package/src/config/cookies/necessary/next-auth.ts +106 -0
- package/src/config/cookies/types.ts +45 -0
- package/src/config/gui-options/html-components/ManageCookiePrefsButton.ts +121 -0
- package/src/config/gui-options/html-components/TilliXCallout.ts +34 -0
- package/src/config/gui-options/html-components/assets/CookieIcon.ts +15 -0
- package/src/config/gui-options/index.ts +19 -0
- package/src/config/gui-options/scripts/cookiePrefsButtonDragObserver.ts +180 -0
- package/src/config/gui-options/scripts/forceDisableReactRemoveScroll.ts +152 -0
- package/src/config/gui-options/scripts/injectManageCookiePrefsButton.ts +50 -0
- package/src/config/index.ts +15 -0
- package/src/config/translations/de/index.ts +103 -0
- package/src/config/translations/en/index.ts +103 -0
- package/src/config/translations/es/index.ts +103 -0
- package/src/config/translations/fr/index.ts +103 -0
- package/src/config/translations/index.ts +15 -0
- package/src/config/translations/it/index.ts +103 -0
- package/src/config/translations/types.ts +2 -0
- package/src/react-components/CookieConsentInit.client.tsx +34 -0
- package/src/react-components/CookieConsentInit.server.tsx +14 -0
- package/src/react-components/_types.ts +7 -0
- package/src/react-components/_utils.ts +62 -0
- package/src/react-components/styles/tenants/freeman.css +63 -0
- package/src/react-components/styles/tenants/frontier.css +71 -0
- package/tsconfig.json +15 -0
package/eslint.config.js
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
import baseConfig from "@tilli-pro/eslint-config/base";
|
2
|
+
import nextjsConfig from "@tilli-pro/eslint-config/nextjs";
|
3
|
+
import reactConfig from "@tilli-pro/eslint-config/react";
|
4
|
+
|
5
|
+
/** @type {import('typescript-eslint').Config} */
|
6
|
+
export default [
|
7
|
+
{
|
8
|
+
ignores: [".next/**"],
|
9
|
+
},
|
10
|
+
...baseConfig,
|
11
|
+
...reactConfig,
|
12
|
+
...nextjsConfig,
|
13
|
+
];
|
package/package.json
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
{
|
2
|
+
"name": "@tilli-pro/cookieconsent-plugin",
|
3
|
+
"version": "0.1.0",
|
4
|
+
"private": false,
|
5
|
+
"publishConfig": {
|
6
|
+
"access": "public"
|
7
|
+
},
|
8
|
+
"type": "module",
|
9
|
+
"exports": {
|
10
|
+
"./*": {
|
11
|
+
"types": "./dist/*.d.ts",
|
12
|
+
"default": "./src/*.ts"
|
13
|
+
}
|
14
|
+
},
|
15
|
+
"dependencies": {
|
16
|
+
"@tilli-pro/cookieconsent": "3.0.1",
|
17
|
+
"next": "14.2.15"
|
18
|
+
},
|
19
|
+
"devDependencies": {
|
20
|
+
"@tilli-pro/eslint-config": "0.3.7",
|
21
|
+
"@tilli-pro/prettier-config": "0.1.3",
|
22
|
+
"@tilli-pro/tsconfig": "0.1.2",
|
23
|
+
"@types/node": "20.17.10",
|
24
|
+
"@types/react": "18.3.11",
|
25
|
+
"@types/react-dom": "18.3.0",
|
26
|
+
"eslint": "9.12.0",
|
27
|
+
"prettier": "3.3.3",
|
28
|
+
"typescript": "5.6.2"
|
29
|
+
},
|
30
|
+
"prettier": "@tilli-pro/prettier-config",
|
31
|
+
"scripts": {
|
32
|
+
"build": "tsc",
|
33
|
+
"clean": "git clean -xdf .cache .turbo dist node_modules",
|
34
|
+
"format": "prettier --check . --ignore-path ../../.gitignore --ignore-path .gitignore",
|
35
|
+
"lint": "eslint",
|
36
|
+
"typecheck": "tsc --noEmit --emitDeclarationOnly false"
|
37
|
+
}
|
38
|
+
}
|
package/src/_consts.ts
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
export const COOKIE_CONSENT_ENABLED = true;
|
2
|
+
|
3
|
+
/** NOTE(IMPORTANT): if bumped (e.g. 2 -> 3): users who had already consented to the prev. revision # will be prompted again for re-consent (w/ a notice that the policy has changed) */
|
4
|
+
export const REVISION = 0; // "revision" refers to our cookie/privacy policy version number (handled by a simple incremental counter rather than traditional "semvar" syntax)
|
5
|
+
export const COOKIE_PREFERENCES_COOKIE_NAME = "_tilli_cookie-preferences"; // name of the cookie that stores the user's cookie preferences
|
6
|
+
|
7
|
+
/** __tests__ */
|
8
|
+
export const COOKIE_CONSENT_TEST_SEARCH_PARAM_KEY_PREFIX = "cc-";
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/** cookie icon */
|
2
|
+
export default `<?xml version="1.0" encoding="UTF-8"?>
|
3
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
4
|
+
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
5
|
+
<path d="M12 2a10 10 0 1 0 10 10 4 4 0 0 1-5-5 4 4 0 0 1-5-5" />
|
6
|
+
<path d="M8.5 8.5v.01" />
|
7
|
+
<path d="M16 15.5v.01" />
|
8
|
+
<path d="M12 12v.01" />
|
9
|
+
<path d="M11 17v.01" />
|
10
|
+
<path d="M7 14v.01" />
|
11
|
+
</svg>`;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/** tilli logo */
|
2
|
+
export default `<?xml version="1.0" encoding="UTF-8"?>
|
3
|
+
<svg id="tilli-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1834.47 2048.44">
|
4
|
+
<defs>
|
5
|
+
<style>
|
6
|
+
.tilli-icon-u-left {
|
7
|
+
fill: #335ef6;
|
8
|
+
}
|
9
|
+
|
10
|
+
.tilli-icon-u-right {
|
11
|
+
fill: #02b1ff;
|
12
|
+
}
|
13
|
+
</style>
|
14
|
+
</defs>
|
15
|
+
<g id="tilli-icon-u-group">
|
16
|
+
<path id="tilli-icon-u-left" class="tilli-icon-u-left"
|
17
|
+
d="M711.62,188.01v1089.71c0,450.86,412.22,394.72,412.22,394.72,0,0-18.66,376-412.22,376S0,1841.73,0,1390.88v-713.71L711.62,188.01Z" />
|
18
|
+
<path id="tilli-icon-u-right" class="tilli-icon-u-right"
|
19
|
+
d="M1834.47,0v1032.69c0,640.64-711.62,638.86-711.62,638.86V488.28L1834.47,0Z" />
|
20
|
+
</g>
|
21
|
+
</svg>`;
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import type { CookieConsentConfig } from "@tilli-pro/cookieconsent";
|
2
|
+
|
3
|
+
import cookies from "../cookies";
|
4
|
+
import { LABELS } from "./labels";
|
5
|
+
|
6
|
+
// TODO: determine whether we need to add "language support" here... This file is probably just for backend purposes.
|
7
|
+
const __LANGUAGE__ = "en"; // "English" ("English")
|
8
|
+
|
9
|
+
export default {
|
10
|
+
necessary: {
|
11
|
+
enabled: true, // "necessary" category is always enabled.
|
12
|
+
readOnly: true,
|
13
|
+
services: {
|
14
|
+
/** tilliX (BRF) */
|
15
|
+
tilliX: {
|
16
|
+
label: LABELS.en.necessary.tilliX,
|
17
|
+
cookies: [...cookies.necessary.brf(__LANGUAGE__)],
|
18
|
+
},
|
19
|
+
},
|
20
|
+
},
|
21
|
+
functional: {
|
22
|
+
services: {
|
23
|
+
/** tilliX (BRF) */
|
24
|
+
tilliX: {
|
25
|
+
label: LABELS.en.functional.tilliX,
|
26
|
+
cookies: [...cookies.functional.brf(__LANGUAGE__)],
|
27
|
+
},
|
28
|
+
},
|
29
|
+
autoClear: {
|
30
|
+
cookies: [
|
31
|
+
{
|
32
|
+
name: /^(tx-theme)/, // tilliX theme (-> "light" | "dark")
|
33
|
+
},
|
34
|
+
],
|
35
|
+
},
|
36
|
+
},
|
37
|
+
analytics: {
|
38
|
+
services: {
|
39
|
+
/** Datadog (RUM) */
|
40
|
+
datadog: {
|
41
|
+
label: LABELS.en.analytics.datadog,
|
42
|
+
cookies: [...cookies.analytics.datadog(__LANGUAGE__)],
|
43
|
+
},
|
44
|
+
},
|
45
|
+
autoClear: {
|
46
|
+
cookies: [
|
47
|
+
{
|
48
|
+
name: /^(_tilli_analytics_dd_)/, // Datadog (RUM)
|
49
|
+
},
|
50
|
+
],
|
51
|
+
},
|
52
|
+
},
|
53
|
+
} satisfies CookieConsentConfig["categories"];
|
@@ -0,0 +1,20 @@
|
|
1
|
+
const PRODUCTS = {
|
2
|
+
tilliX: '<a href="https://tilli.pro" target="_blank">tilliX</a>',
|
3
|
+
nudge: '<a href="https://tilli.pro" target="_blank">Nudge</a>',
|
4
|
+
gps: '<a href="https://tilli.pro" target="_blank">GPS</a>',
|
5
|
+
};
|
6
|
+
|
7
|
+
export const LABELS = {
|
8
|
+
en: {
|
9
|
+
necessary: {
|
10
|
+
tilliX: PRODUCTS.tilliX,
|
11
|
+
},
|
12
|
+
functional: {
|
13
|
+
tilliX: PRODUCTS.tilliX,
|
14
|
+
},
|
15
|
+
analytics: {
|
16
|
+
datadog:
|
17
|
+
'<a href="https://www.datadoghq.com" target="_blank">Datadog</a>',
|
18
|
+
},
|
19
|
+
},
|
20
|
+
};
|
@@ -0,0 +1,24 @@
|
|
1
|
+
/** 🚧 INTENDED FOR Next.js USAGE ONLY!!! (server-side cookie validation) */
|
2
|
+
|
3
|
+
import "server-only";
|
4
|
+
|
5
|
+
import { cookies as getServerSideCookies } from "next/headers";
|
6
|
+
|
7
|
+
import type { ConsentCategory, ServiceName, UserCookieConsent } from "./types";
|
8
|
+
import {
|
9
|
+
getUsersCookieConsent as _getUsersCookieConsent,
|
10
|
+
hasUserConsentedTo as _hasUserConsentedTo,
|
11
|
+
} from "./_utils";
|
12
|
+
|
13
|
+
/** server-side wrapper for {@link ./_utils.ts getUsersCookieConsent}. */
|
14
|
+
export const getUsersCookieConsent = (
|
15
|
+
cookies = getServerSideCookies(),
|
16
|
+
): UserCookieConsent | null => _getUsersCookieConsent(cookies);
|
17
|
+
|
18
|
+
/** server-side wrapper for {@link ./_utils.ts hasUserConsentedTo}. */
|
19
|
+
export const hasUserConsentedTo = <
|
20
|
+
T extends ConsentCategory,
|
21
|
+
U extends ServiceName<T>,
|
22
|
+
>(
|
23
|
+
...args: [T, U]
|
24
|
+
): boolean => _hasUserConsentedTo(getUsersCookieConsent(), ...args);
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import type { ReadonlyRequestCookies } from "next/dist/server/web/spec-extension/adapters/request-cookies";
|
2
|
+
|
3
|
+
import type {
|
4
|
+
ConsentCategory,
|
5
|
+
RawTilliCookieConsentValue,
|
6
|
+
ServiceName,
|
7
|
+
UserCookieConsent,
|
8
|
+
} from "./types";
|
9
|
+
import { COOKIE_PREFERENCES_COOKIE_NAME } from "../../_consts";
|
10
|
+
|
11
|
+
/** type-safe way to get the user's cookie consent (incl. prefs + metadata)
|
12
|
+
* > requires the cookies to be passed in (if server-side, use `cookies()`) */
|
13
|
+
export const getUsersCookieConsent = (
|
14
|
+
cookies: ReadonlyRequestCookies,
|
15
|
+
): UserCookieConsent | null => {
|
16
|
+
try {
|
17
|
+
return JSON.parse(
|
18
|
+
(cookies.get(COOKIE_PREFERENCES_COOKIE_NAME)?.value as
|
19
|
+
| RawTilliCookieConsentValue
|
20
|
+
| undefined) ?? "",
|
21
|
+
) as UserCookieConsent;
|
22
|
+
} catch {
|
23
|
+
return null;
|
24
|
+
}
|
25
|
+
};
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Checks if the user has consented to a specific service within a given consent category.
|
29
|
+
*
|
30
|
+
* @template T - The type of the consent category.
|
31
|
+
* @template U - The type of the service name within the consent category.
|
32
|
+
*
|
33
|
+
* @param userCookieConsent - The user's cookie consent object, which may be undefined.
|
34
|
+
* @param category - The consent category to check.
|
35
|
+
* @param service - The specific service within the consent category to check.
|
36
|
+
*
|
37
|
+
* @returns `true` if the user has consented to the specified service within the given category, `false` otherwise.
|
38
|
+
*
|
39
|
+
* @example
|
40
|
+
* ```ts
|
41
|
+
* const userCookieConsent = getUsersCookieConsent(cookies);
|
42
|
+
* const hasConsented = hasUserConsentedTo(userCookieConsent, "analytics", "datadog");
|
43
|
+
* ```
|
44
|
+
*/
|
45
|
+
export const hasUserConsentedTo = <
|
46
|
+
T extends ConsentCategory,
|
47
|
+
U extends ServiceName<T>,
|
48
|
+
>(
|
49
|
+
userCookieConsent: UserCookieConsent | null | undefined,
|
50
|
+
category: T,
|
51
|
+
service: U,
|
52
|
+
): boolean =>
|
53
|
+
userCookieConsent?.services?.[category]?.includes(service) ?? false;
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import type { Language } from "../../translations/types";
|
2
|
+
import type { CookieTableItem } from "../types";
|
3
|
+
import { LABELS } from "../../categories/labels";
|
4
|
+
import commonTranslations from "../common-translations";
|
5
|
+
|
6
|
+
const COOKIE_PREFIX = "_tilli_analytics_dd_"; // remapped from library default ("_dd_")
|
7
|
+
|
8
|
+
export const translations = {
|
9
|
+
de: {
|
10
|
+
[`${COOKIE_PREFIX}s`]:
|
11
|
+
"Speichert Ihre Sitzungskennung und einige grundlegende Metadaten",
|
12
|
+
},
|
13
|
+
en: {
|
14
|
+
[`${COOKIE_PREFIX}s`]:
|
15
|
+
"Stores your session identifier and some basic metadata",
|
16
|
+
},
|
17
|
+
es: {
|
18
|
+
[`${COOKIE_PREFIX}s`]:
|
19
|
+
"Almacena tu identificador de sesión y algunos metadatos básicos",
|
20
|
+
},
|
21
|
+
fr: {
|
22
|
+
[`${COOKIE_PREFIX}s`]:
|
23
|
+
"Stocke votre identifiant de session et quelques métadonnées de base",
|
24
|
+
},
|
25
|
+
it: {
|
26
|
+
[`${COOKIE_PREFIX}s`]:
|
27
|
+
"Memorizza il tuo identificatore di sessione e alcuni metadati di base",
|
28
|
+
},
|
29
|
+
} as const;
|
30
|
+
|
31
|
+
export default (lang: Language): CookieTableItem[] => [
|
32
|
+
{
|
33
|
+
name: `${COOKIE_PREFIX}s`,
|
34
|
+
service: LABELS.en.analytics.datadog,
|
35
|
+
description: translations[lang][`${COOKIE_PREFIX}s`],
|
36
|
+
expiration: commonTranslations[lang]["session-end"],
|
37
|
+
},
|
38
|
+
];
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import type { Language } from "../translations/types";
|
2
|
+
|
3
|
+
type CommonTranslations = "session-end" | "1 year" | "15 minutes";
|
4
|
+
|
5
|
+
export default {
|
6
|
+
de: {
|
7
|
+
"session-end": "Sitzungsende",
|
8
|
+
"1 year": "1 Jahr",
|
9
|
+
"15 minutes": "15 Minuten",
|
10
|
+
},
|
11
|
+
en: {
|
12
|
+
"session-end": "session-end",
|
13
|
+
"1 year": "1 year",
|
14
|
+
"15 minutes": "15 minutes",
|
15
|
+
},
|
16
|
+
es: {
|
17
|
+
"session-end": "fin de la sesión",
|
18
|
+
"1 year": "1 año",
|
19
|
+
"15 minutes": "15 minutos",
|
20
|
+
},
|
21
|
+
fr: {
|
22
|
+
"session-end": "fin de session",
|
23
|
+
"1 year": "1 an",
|
24
|
+
"15 minutes": "15 minutes",
|
25
|
+
},
|
26
|
+
it: {
|
27
|
+
"session-end": "fine della sessione",
|
28
|
+
"1 year": "1 anno",
|
29
|
+
"15 minutes": "15 minuti",
|
30
|
+
},
|
31
|
+
} as const satisfies Record<Language, Record<CommonTranslations, string>>;
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import type { Language } from "../../../translations/types";
|
2
|
+
import type { CookieTableItem } from "../../types";
|
3
|
+
import { LABELS } from "../../../categories/labels";
|
4
|
+
import commonTranslations from "../../common-translations";
|
5
|
+
|
6
|
+
const COOKIE_PREFIX = "tx-";
|
7
|
+
|
8
|
+
export const translations = {
|
9
|
+
de: {
|
10
|
+
[`${COOKIE_PREFIX}theme`]: "Speichert Ihre ausgewählte Oberflächenthematik",
|
11
|
+
},
|
12
|
+
en: {
|
13
|
+
[`${COOKIE_PREFIX}theme`]: "Keeps track of your selected interface theme",
|
14
|
+
},
|
15
|
+
es: {
|
16
|
+
[`${COOKIE_PREFIX}theme`]: "Guarda el tema de interfaz que seleccionaste",
|
17
|
+
},
|
18
|
+
fr: {
|
19
|
+
[`${COOKIE_PREFIX}theme`]: "Enregistre votre thème d'interface sélectionné",
|
20
|
+
},
|
21
|
+
it: {
|
22
|
+
[`${COOKIE_PREFIX}theme`]:
|
23
|
+
"Tiene traccia del tema dell'interfaccia selezionato",
|
24
|
+
},
|
25
|
+
} as const;
|
26
|
+
|
27
|
+
export default (lang: Language): CookieTableItem[] => [
|
28
|
+
{
|
29
|
+
name: `${COOKIE_PREFIX}theme`,
|
30
|
+
service: LABELS.en.functional.tilliX,
|
31
|
+
description: translations[lang][`${COOKIE_PREFIX}theme`],
|
32
|
+
expiration: commonTranslations[lang]["1 year"],
|
33
|
+
},
|
34
|
+
];
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import type { Language } from "../translations/types";
|
2
|
+
import type { CookieSections } from "./types";
|
3
|
+
import analytics_datadog from "./analytics/datadog";
|
4
|
+
import functional_brfV2 from "./functional/brf/v2";
|
5
|
+
import necessary_brfV2Auth from "./necessary/brf/v2-auth";
|
6
|
+
import necessary_nextAuth from "./necessary/next-auth";
|
7
|
+
|
8
|
+
export default {
|
9
|
+
necessary: {
|
10
|
+
brf: (lang: Language) => [
|
11
|
+
...necessary_nextAuth(lang),
|
12
|
+
...necessary_brfV2Auth(lang),
|
13
|
+
],
|
14
|
+
nextAuth: necessary_nextAuth,
|
15
|
+
},
|
16
|
+
functional: {
|
17
|
+
brf: (lang: Language) => [...functional_brfV2(lang)],
|
18
|
+
},
|
19
|
+
analytics: {
|
20
|
+
datadog: analytics_datadog,
|
21
|
+
},
|
22
|
+
} satisfies CookieSections;
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import type { Language } from "../../../translations/types";
|
2
|
+
import type { CookieTableItem } from "../../types";
|
3
|
+
import { LABELS } from "../../../categories/labels";
|
4
|
+
import commonTranslations from "../../common-translations";
|
5
|
+
|
6
|
+
const COOKIE_PREFIX = "tx-brf-session:";
|
7
|
+
|
8
|
+
export const translations = {
|
9
|
+
de: {
|
10
|
+
[`${COOKIE_PREFIX}<i>i</i>`]:
|
11
|
+
"Speichert Ihre <i>i</i><sup>te</sup> aktive Sitzungskennung",
|
12
|
+
[`${COOKIE_PREFIX}meta`]: "Ihre unverfallenen Sitzungsindizes (siehe oben)",
|
13
|
+
},
|
14
|
+
en: {
|
15
|
+
[`${COOKIE_PREFIX}<i>i</i>`]:
|
16
|
+
"Stores your <i>i</i><sup>th</sup> active session identifier",
|
17
|
+
[`${COOKIE_PREFIX}meta`]: "Your unexpired session indicies (view above)",
|
18
|
+
},
|
19
|
+
es: {
|
20
|
+
[`${COOKIE_PREFIX}<i>i</i>`]:
|
21
|
+
"Almacena tu identificador de sesión activa número <i>i</i><sup>th</sup>",
|
22
|
+
[`${COOKIE_PREFIX}meta`]: "Tus índices de sesión no caducados (ver arriba)",
|
23
|
+
},
|
24
|
+
fr: {
|
25
|
+
[`${COOKIE_PREFIX}<i>i</i>`]:
|
26
|
+
"Stocke votre identifiant de session active <i>i</i><sup>ème</sup>",
|
27
|
+
[`${COOKIE_PREFIX}meta`]:
|
28
|
+
"Vos indices de session non expirés (voir ci-dessus)",
|
29
|
+
},
|
30
|
+
it: {
|
31
|
+
[`${COOKIE_PREFIX}<i>i</i>`]:
|
32
|
+
"Memorizza il tuo identificatore di sessione attiva numero <i>i</i><sup>esimo</sup>",
|
33
|
+
[`${COOKIE_PREFIX}meta`]:
|
34
|
+
"I tuoi indici di sessione non scaduti (vedi sopra)",
|
35
|
+
},
|
36
|
+
} as const;
|
37
|
+
|
38
|
+
export default (lang: Language): CookieTableItem[] => [
|
39
|
+
{
|
40
|
+
name: `${COOKIE_PREFIX}<i>i</i>`,
|
41
|
+
service: LABELS.en.necessary.tilliX,
|
42
|
+
description: translations[lang][`${COOKIE_PREFIX}<i>i</i>`],
|
43
|
+
expiration: commonTranslations[lang]["session-end"],
|
44
|
+
},
|
45
|
+
{
|
46
|
+
name: `${COOKIE_PREFIX}meta`,
|
47
|
+
service: LABELS.en.necessary.tilliX,
|
48
|
+
description: translations[lang][`${COOKIE_PREFIX}meta`],
|
49
|
+
expiration: commonTranslations[lang]["1 year"],
|
50
|
+
},
|
51
|
+
];
|
@@ -0,0 +1,106 @@
|
|
1
|
+
import type { Language } from "../../translations/types";
|
2
|
+
import type { CookieTableItem } from "../types";
|
3
|
+
import { LABELS } from "../../categories/labels";
|
4
|
+
import commonTranslations from "../common-translations";
|
5
|
+
|
6
|
+
const COOKIE_PREFIX = "tx-brf-auth."; // remapped from library default ("next-auth.")
|
7
|
+
|
8
|
+
export const translations = {
|
9
|
+
de: {
|
10
|
+
[`${COOKIE_PREFIX}session-token`]:
|
11
|
+
"Speichert Ihre aktuelle Sitzungskennung",
|
12
|
+
[`${COOKIE_PREFIX}csrf-token`]:
|
13
|
+
'Verhindert <a href="https://de.wikipedia.org/wiki/Cross-Site-Request-Forgery" target="_blank">CSRF-Angriffe</a>',
|
14
|
+
[`${COOKIE_PREFIX}callback-url`]:
|
15
|
+
"Wir leiten Sie nach der Authentifizierung hierhin weiter",
|
16
|
+
[`${COOKIE_PREFIX}nonce`]: "Eindeutige Kennung für jede Anfrage",
|
17
|
+
[`${COOKIE_PREFIX}state`]: "URL-Zustand während der Authentifizierung",
|
18
|
+
[`${COOKIE_PREFIX}pkce.code_verifier`]:
|
19
|
+
"Verhindert Code-Injection-Angriffe",
|
20
|
+
},
|
21
|
+
en: {
|
22
|
+
[`${COOKIE_PREFIX}session-token`]: "Stores your current session identifier",
|
23
|
+
[`${COOKIE_PREFIX}csrf-token`]:
|
24
|
+
'Prevents <a href="https://en.wikipedia.org/wiki/Cross-site_request_forgery" target="_blank">CSRF attacks</a>',
|
25
|
+
[`${COOKIE_PREFIX}callback-url`]:
|
26
|
+
"We'll redirect you here post-authentication",
|
27
|
+
[`${COOKIE_PREFIX}nonce`]: "Unique identifier for each request",
|
28
|
+
[`${COOKIE_PREFIX}state`]: "URL state during authentication",
|
29
|
+
[`${COOKIE_PREFIX}pkce.code_verifier`]: "Prevents code injection attacks",
|
30
|
+
},
|
31
|
+
es: {
|
32
|
+
[`${COOKIE_PREFIX}session-token`]:
|
33
|
+
"Almacena tu identificador de sesión actual",
|
34
|
+
[`${COOKIE_PREFIX}csrf-token`]:
|
35
|
+
'Previene <a href="https://es.wikipedia.org/wiki/Cross-Site_Request_Forgery" target="_blank">ataques CSRF</a>',
|
36
|
+
[`${COOKIE_PREFIX}callback-url`]:
|
37
|
+
"Te redirigiremos aquí después de la autenticación",
|
38
|
+
[`${COOKIE_PREFIX}nonce`]: "Identificador único para cada solicitud",
|
39
|
+
[`${COOKIE_PREFIX}state`]: "Estado de la URL durante la autenticación",
|
40
|
+
[`${COOKIE_PREFIX}pkce.code_verifier`]:
|
41
|
+
"Previene ataques de inyección de código",
|
42
|
+
},
|
43
|
+
fr: {
|
44
|
+
[`${COOKIE_PREFIX}session-token`]:
|
45
|
+
"Stocke votre identifiant de session actuel",
|
46
|
+
[`${COOKIE_PREFIX}csrf-token`]:
|
47
|
+
'Empêche les <a href="https://fr.wikipedia.org/wiki/Cross-site_request_forgery" target="_blank">attaques CSRF</a>',
|
48
|
+
[`${COOKIE_PREFIX}callback-url`]:
|
49
|
+
"Nous vous redirigerons ici après l'authentification",
|
50
|
+
[`${COOKIE_PREFIX}nonce`]: "Identifiant unique pour chaque demande",
|
51
|
+
[`${COOKIE_PREFIX}state`]: "État de l'URL pendant l'authentification",
|
52
|
+
[`${COOKIE_PREFIX}pkce.code_verifier`]:
|
53
|
+
"Empêche les attaques par injection de code",
|
54
|
+
},
|
55
|
+
it: {
|
56
|
+
[`${COOKIE_PREFIX}session-token`]:
|
57
|
+
"Memorizza il tuo identificatore di sessione corrente",
|
58
|
+
[`${COOKIE_PREFIX}csrf-token`]:
|
59
|
+
'Previene <a href="https://it.wikipedia.org/wiki/Cross-site_request_forgery" target="_blank">attacchi CSRF</a>',
|
60
|
+
[`${COOKIE_PREFIX}callback-url`]:
|
61
|
+
"Ti reindirizzeremo qui dopo l'autenticazione",
|
62
|
+
[`${COOKIE_PREFIX}nonce`]: "Identificatore univoco per ogni richiesta",
|
63
|
+
[`${COOKIE_PREFIX}state`]: "Stato dell'URL durante l'autenticazione",
|
64
|
+
[`${COOKIE_PREFIX}pkce.code_verifier`]:
|
65
|
+
"Previene attacchi di iniezione di codice",
|
66
|
+
},
|
67
|
+
} as const;
|
68
|
+
|
69
|
+
export default (lang: Language): CookieTableItem[] => [
|
70
|
+
{
|
71
|
+
name: `${COOKIE_PREFIX}session-token`,
|
72
|
+
service: LABELS.en.necessary.tilliX,
|
73
|
+
description: translations[lang][`${COOKIE_PREFIX}session-token`],
|
74
|
+
expiration: commonTranslations[lang]["session-end"],
|
75
|
+
},
|
76
|
+
{
|
77
|
+
name: `${COOKIE_PREFIX}csrf-token`,
|
78
|
+
service: LABELS.en.necessary.tilliX,
|
79
|
+
description: translations[lang][`${COOKIE_PREFIX}csrf-token`],
|
80
|
+
expiration: commonTranslations[lang]["1 year"],
|
81
|
+
},
|
82
|
+
{
|
83
|
+
name: `${COOKIE_PREFIX}callback-url`,
|
84
|
+
service: LABELS.en.necessary.tilliX,
|
85
|
+
description: translations[lang][`${COOKIE_PREFIX}callback-url`],
|
86
|
+
expiration: commonTranslations[lang]["1 year"],
|
87
|
+
},
|
88
|
+
// {
|
89
|
+
// name: `${COOKIE_PREFIX}nonce`,
|
90
|
+
// service: LABELS.en.necessary.tilliX,
|
91
|
+
// description: translations[lang][`${COOKIE_PREFIX}nonce`],
|
92
|
+
// expiration: commonTranslations[lang]["1 year"],
|
93
|
+
// },
|
94
|
+
// {
|
95
|
+
// name: `${COOKIE_PREFIX}state`,
|
96
|
+
// service: LABELS.en.necessary.tilliX,
|
97
|
+
// description: translations[lang][`${COOKIE_PREFIX}state`],
|
98
|
+
// expiration: commonTranslations[lang]["15 minutes"],
|
99
|
+
// },
|
100
|
+
// {
|
101
|
+
// name: `${COOKIE_PREFIX}pkce.code_verifier`,
|
102
|
+
// service: LABELS.en.necessary.tilliX,
|
103
|
+
// description: translations[lang][`${COOKIE_PREFIX}pkce.code_verifier`],
|
104
|
+
// expiration: commonTranslations[lang]["15 minutes"],
|
105
|
+
// },
|
106
|
+
];
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import type { CookieValue } from "@tilli-pro/cookieconsent";
|
2
|
+
|
3
|
+
import type cookies from ".";
|
4
|
+
import type { LABELS } from "../categories/labels";
|
5
|
+
import type { Language } from "../translations/types";
|
6
|
+
|
7
|
+
export type CookieTableHeaders = {
|
8
|
+
name: string;
|
9
|
+
service: string;
|
10
|
+
description: string;
|
11
|
+
expiration: string;
|
12
|
+
};
|
13
|
+
|
14
|
+
export type CookieTableItem = {
|
15
|
+
name: string; // -> "tx-theme" | "_tilli_analytics_dd_s"
|
16
|
+
service: string; // -> "tilliX" | "Datadog"
|
17
|
+
description: string; // -> "Keeps track of your selected theme." | 'Cookie set by <a href="https://www.datadoghq.com" target="_blank">Datadog</a>.'
|
18
|
+
expiration: string; // -> "Expires after 1 year" | "Session"
|
19
|
+
};
|
20
|
+
|
21
|
+
type CookieSection = Record<string, (lang: Language) => CookieTableItem[]>;
|
22
|
+
|
23
|
+
export interface CookieSections {
|
24
|
+
necessary?: CookieSection;
|
25
|
+
performance?: CookieSection;
|
26
|
+
functional?: CookieSection;
|
27
|
+
advertising?: CookieSection;
|
28
|
+
analytics?: CookieSection;
|
29
|
+
}
|
30
|
+
|
31
|
+
type ExtractServiceNames<T> = {
|
32
|
+
[K in keyof T]: (keyof T[K])[];
|
33
|
+
};
|
34
|
+
|
35
|
+
export interface UserCookieConsent extends Omit<CookieValue, "services"> {
|
36
|
+
services: ExtractServiceNames<(typeof LABELS)["en"]>; // -> { necessary: ["tilliX"], ..., analytics: ["datadog"] }
|
37
|
+
}
|
38
|
+
|
39
|
+
export type RawTilliCookieConsentValue = string & {
|
40
|
+
__struct: UserCookieConsent;
|
41
|
+
}; // URI-encoded JSON string
|
42
|
+
|
43
|
+
export type ConsentCategory = keyof typeof cookies; // -> "necessary" | "functional" | "analytics"
|
44
|
+
export type ServiceName<T extends ConsentCategory> =
|
45
|
+
keyof (typeof LABELS)["en"][T]; // -> "tilliX" | "datadog"
|