From 83eb75f6ea4b85a6ad06a236dc84a7daa5a4d3c6 Mon Sep 17 00:00:00 2001 From: JohannesDoberer Date: Mon, 7 Oct 2024 22:27:16 +0200 Subject: [PATCH 1/9] Disable tpc check via Luigi Client --- client/luigi-client.d.ts | 13 +++++++++++++ client/src/lifecycleManager.js | 18 ++++++++++++++++-- client/src/luigi-client.js | 3 +++ docs/luigi-client-api.md | 17 +++++++++++++++++ 4 files changed, 49 insertions(+), 2 deletions(-) diff --git a/client/luigi-client.d.ts b/client/luigi-client.d.ts index b40368e043..070bd113fe 100644 --- a/client/luigi-client.d.ts +++ b/client/luigi-client.d.ts @@ -781,6 +781,19 @@ export type setAnchor = (anchor: String) => void; export function setViewGroupData(value: Object): void; export type setViewGroupData = (value: Object) => void; +/** + * Disables the TPC (Third-Party Cookies) check via Luigi Client. + * + * This function sets a custom attribute `'disable-lui-tpc-check'` on the `` element + * of the document. It has to be called in the callback function of the addInitListener. + * @since NEXTRELEASE + * @memberof Lifecycle + * @example + * LuigiClient.disableTpcCheck(); +*/ +export function disableTpcCheck(): void; +export type disableTpcCheck = () => void; + /** * Read search query parameters which are sent from Luigi core * @memberof Lifecycle diff --git a/client/src/lifecycleManager.js b/client/src/lifecycleManager.js index 5b9f2fab5d..78502da0d9 100644 --- a/client/src/lifecycleManager.js +++ b/client/src/lifecycleManager.js @@ -12,7 +12,7 @@ class LifecycleManager extends LuigiClientBase { this.luigiInitialized = false; this.defaultContextKeys = ['context', 'internal', 'nodeParams', 'pathParams', 'searchParams']; this.setCurrentContext( - this.defaultContextKeys.reduce(function(acc, key) { + this.defaultContextKeys.reduce(function (acc, key) { acc[key] = {}; return acc; }, {}) @@ -139,7 +139,7 @@ class LifecycleManager extends LuigiClientBase { } _tpcCheck() { - if (this.currentContext?.internal?.thirdPartyCookieCheck?.disabled) { + if (this.currentContext?.internal?.thirdPartyCookieCheck?.disabled || document.head.getAttribute('disable-lui-tpc-check')) { return; } let tpc = 'enabled'; @@ -580,5 +580,19 @@ class LifecycleManager extends LuigiClientBase { data }); } + + /** + * Disables the TPC (Third-Party Cookies) check via Luigi Client. + * + * This function sets a custom attribute `'disable-lui-tpc-check'` on the `` element + * of the document. It has to be called in the callback function of the addInitListener. + * @since NEXTRELEASE + * @memberof Lifecycle + * @example + * LuigiClient.disableTpcCheck(); + */ + disableTpcCheck() { + document.head.setAttribute('disable-lui-tpc-check', true); + } } export const lifecycleManager = new LifecycleManager(); diff --git a/client/src/luigi-client.js b/client/src/luigi-client.js index 9e6be7adbf..47180bf5fe 100644 --- a/client/src/luigi-client.js +++ b/client/src/luigi-client.js @@ -104,6 +104,9 @@ class LuigiClient { setViewGroupData(value) { return lifecycleManager.setViewGroupData(value); } + disableTpcCheck(){ + return lifecycleManager.disableTpcCheck(); + } /** diff --git a/docs/luigi-client-api.md b/docs/luigi-client-api.md index a13e9351bb..7b07f1825d 100644 --- a/docs/luigi-client-api.md +++ b/docs/luigi-client-api.md @@ -516,6 +516,23 @@ LuigiClient.setViewGroupData({'vg1':' Luigi rocks!'}) * **since**: 2.2.0 +#### disableTpcCheck + +Disables the TPC (Third-Party Cookies) check via Luigi Client. + +This function sets a custom attribute `'disable-lui-tpc-check'` on the `` element +of the document. It has to be called in the callback function of the addInitListener. + +##### Examples + +```javascript +LuigiClient.disableTpcCheck(); +``` + +**Meta** + +* **since**: NEXTRELEASE + ### Lifecycle~initListenerCallback Callback of the addInitListener From ae5b730de732c47d915447c8749704712e8389e1 Mon Sep 17 00:00:00 2001 From: JohannesDoberer Date: Mon, 7 Oct 2024 22:27:54 +0200 Subject: [PATCH 2/9] prettier --- client/luigi-client.d.ts | 18 +++++++++--------- client/src/lifecycleManager.js | 25 ++++++++++++++----------- client/src/luigi-client.js | 3 +-- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/client/luigi-client.d.ts b/client/luigi-client.d.ts index 070bd113fe..811228773f 100644 --- a/client/luigi-client.d.ts +++ b/client/luigi-client.d.ts @@ -782,15 +782,15 @@ export function setViewGroupData(value: Object): void; export type setViewGroupData = (value: Object) => void; /** - * Disables the TPC (Third-Party Cookies) check via Luigi Client. - * - * This function sets a custom attribute `'disable-lui-tpc-check'` on the `` element - * of the document. It has to be called in the callback function of the addInitListener. - * @since NEXTRELEASE - * @memberof Lifecycle - * @example - * LuigiClient.disableTpcCheck(); -*/ + * Disables the TPC (Third-Party Cookies) check via Luigi Client. + * + * This function sets a custom attribute `'disable-lui-tpc-check'` on the `` element + * of the document. It has to be called in the callback function of the addInitListener. + * @since NEXTRELEASE + * @memberof Lifecycle + * @example + * LuigiClient.disableTpcCheck(); + */ export function disableTpcCheck(): void; export type disableTpcCheck = () => void; diff --git a/client/src/lifecycleManager.js b/client/src/lifecycleManager.js index 78502da0d9..c84e992fa1 100644 --- a/client/src/lifecycleManager.js +++ b/client/src/lifecycleManager.js @@ -12,7 +12,7 @@ class LifecycleManager extends LuigiClientBase { this.luigiInitialized = false; this.defaultContextKeys = ['context', 'internal', 'nodeParams', 'pathParams', 'searchParams']; this.setCurrentContext( - this.defaultContextKeys.reduce(function (acc, key) { + this.defaultContextKeys.reduce(function(acc, key) { acc[key] = {}; return acc; }, {}) @@ -139,7 +139,10 @@ class LifecycleManager extends LuigiClientBase { } _tpcCheck() { - if (this.currentContext?.internal?.thirdPartyCookieCheck?.disabled || document.head.getAttribute('disable-lui-tpc-check')) { + if ( + this.currentContext?.internal?.thirdPartyCookieCheck?.disabled || + document.head.getAttribute('disable-lui-tpc-check') + ) { return; } let tpc = 'enabled'; @@ -582,15 +585,15 @@ class LifecycleManager extends LuigiClientBase { } /** - * Disables the TPC (Third-Party Cookies) check via Luigi Client. - * - * This function sets a custom attribute `'disable-lui-tpc-check'` on the `` element - * of the document. It has to be called in the callback function of the addInitListener. - * @since NEXTRELEASE - * @memberof Lifecycle - * @example - * LuigiClient.disableTpcCheck(); - */ + * Disables the TPC (Third-Party Cookies) check via Luigi Client. + * + * This function sets a custom attribute `'disable-lui-tpc-check'` on the `` element + * of the document. It has to be called in the callback function of the addInitListener. + * @since NEXTRELEASE + * @memberof Lifecycle + * @example + * LuigiClient.disableTpcCheck(); + */ disableTpcCheck() { document.head.setAttribute('disable-lui-tpc-check', true); } diff --git a/client/src/luigi-client.js b/client/src/luigi-client.js index 47180bf5fe..62c6bdb5f4 100644 --- a/client/src/luigi-client.js +++ b/client/src/luigi-client.js @@ -104,11 +104,10 @@ class LuigiClient { setViewGroupData(value) { return lifecycleManager.setViewGroupData(value); } - disableTpcCheck(){ + disableTpcCheck() { return lifecycleManager.disableTpcCheck(); } - /** * @private */ From 4d15081b5a4664e7a2546130d0b130f22a046e12 Mon Sep 17 00:00:00 2001 From: JohannesDoberer Date: Tue, 8 Oct 2024 20:57:26 +0200 Subject: [PATCH 3/9] change docu --- client/luigi-client.d.ts | 2 +- client/src/lifecycleManager.js | 2 +- docs/luigi-client-api.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/luigi-client.d.ts b/client/luigi-client.d.ts index 811228773f..642ee5d157 100644 --- a/client/luigi-client.d.ts +++ b/client/luigi-client.d.ts @@ -785,7 +785,7 @@ export type setViewGroupData = (value: Object) => void; * Disables the TPC (Third-Party Cookies) check via Luigi Client. * * This function sets a custom attribute `'disable-lui-tpc-check'` on the `` element - * of the document. It has to be called in the callback function of the addInitListener. + * of the document. It has to be called once the DOM is ready. * @since NEXTRELEASE * @memberof Lifecycle * @example diff --git a/client/src/lifecycleManager.js b/client/src/lifecycleManager.js index c84e992fa1..61367cdc97 100644 --- a/client/src/lifecycleManager.js +++ b/client/src/lifecycleManager.js @@ -588,7 +588,7 @@ class LifecycleManager extends LuigiClientBase { * Disables the TPC (Third-Party Cookies) check via Luigi Client. * * This function sets a custom attribute `'disable-lui-tpc-check'` on the `` element - * of the document. It has to be called in the callback function of the addInitListener. + * of the document. It has to be called once the DOM is ready. * @since NEXTRELEASE * @memberof Lifecycle * @example diff --git a/docs/luigi-client-api.md b/docs/luigi-client-api.md index 7b07f1825d..0ce4cfff08 100644 --- a/docs/luigi-client-api.md +++ b/docs/luigi-client-api.md @@ -521,7 +521,7 @@ LuigiClient.setViewGroupData({'vg1':' Luigi rocks!'}) Disables the TPC (Third-Party Cookies) check via Luigi Client. This function sets a custom attribute `'disable-lui-tpc-check'` on the `` element -of the document. It has to be called in the callback function of the addInitListener. +of the document. It has to be called once the DOM is ready. ##### Examples From 9337e9da63b162c7d175603b9393f6c784dccbc5 Mon Sep 17 00:00:00 2001 From: JohannesDoberer Date: Thu, 10 Oct 2024 10:36:35 +0200 Subject: [PATCH 4/9] disable tpc refactor --- client/src/lifecycleManager.js | 21 +++++---------------- client/src/luigi-client.js | 4 ++-- docs/luigi-client-api.md | 18 +----------------- 3 files changed, 8 insertions(+), 35 deletions(-) diff --git a/client/src/lifecycleManager.js b/client/src/lifecycleManager.js index 61367cdc97..3494b2c852 100644 --- a/client/src/lifecycleManager.js +++ b/client/src/lifecycleManager.js @@ -9,6 +9,7 @@ class LifecycleManager extends LuigiClientBase { /** @private */ constructor() { super(); + this.disableTpcCheck=false; this.luigiInitialized = false; this.defaultContextKeys = ['context', 'internal', 'nodeParams', 'pathParams', 'searchParams']; this.setCurrentContext( @@ -141,7 +142,7 @@ class LifecycleManager extends LuigiClientBase { _tpcCheck() { if ( this.currentContext?.internal?.thirdPartyCookieCheck?.disabled || - document.head.getAttribute('disable-lui-tpc-check') + this.disableTpcCheck ) { return; } @@ -229,11 +230,13 @@ class LifecycleManager extends LuigiClientBase { /** * Registers a listener called with the context object and the Luigi Core domain as soon as Luigi is instantiated. Defer your application bootstrap if you depend on authentication data coming from Luigi. * @param {Lifecycle~initListenerCallback} initFn the function that is called once Luigi is initialized, receives current context and origin as parameters + * @param {boolean} disableTpcCheck if set to `true` third party cookie check will be disabled via LuigiClient. * @memberof Lifecycle * @example * const initListenerId = LuigiClient.addInitListener((context) => storeContextToMF(context)) */ - addInitListener(initFn) { + addInitListener(initFn, disableTpcCheck) { + this.disableTpcCheck = disableTpcCheck; const id = helpers.getRandomId(); this._onInitFns[id] = initFn; if (this.luigiInitialized && helpers.isFunction(initFn)) { @@ -583,19 +586,5 @@ class LifecycleManager extends LuigiClientBase { data }); } - - /** - * Disables the TPC (Third-Party Cookies) check via Luigi Client. - * - * This function sets a custom attribute `'disable-lui-tpc-check'` on the `` element - * of the document. It has to be called once the DOM is ready. - * @since NEXTRELEASE - * @memberof Lifecycle - * @example - * LuigiClient.disableTpcCheck(); - */ - disableTpcCheck() { - document.head.setAttribute('disable-lui-tpc-check', true); - } } export const lifecycleManager = new LifecycleManager(); diff --git a/client/src/luigi-client.js b/client/src/luigi-client.js index 62c6bdb5f4..2b5a6b2d4f 100644 --- a/client/src/luigi-client.js +++ b/client/src/luigi-client.js @@ -26,8 +26,8 @@ class LuigiClient { } } - addInitListener(initFn) { - return lifecycleManager.addInitListener(initFn); + addInitListener(initFn, disableTpcCheck) { + return lifecycleManager.addInitListener(initFn, disableTpcCheck); } removeInitListener(id) { return lifecycleManager.removeInitListener(id); diff --git a/docs/luigi-client-api.md b/docs/luigi-client-api.md index 0ce4cfff08..bfd865e856 100644 --- a/docs/luigi-client-api.md +++ b/docs/luigi-client-api.md @@ -136,6 +136,7 @@ Registers a listener called with the context object and the Luigi Core domain as ##### Parameters * `initFn` **[Lifecycle~initListenerCallback](#lifecycleinitlistenercallback)** the function that is called once Luigi is initialized, receives current context and origin as parameters +* `disableTpcCheck` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** if set to `true` third party cookie check will be disabled via LuigiClient. ##### Examples @@ -516,23 +517,6 @@ LuigiClient.setViewGroupData({'vg1':' Luigi rocks!'}) * **since**: 2.2.0 -#### disableTpcCheck - -Disables the TPC (Third-Party Cookies) check via Luigi Client. - -This function sets a custom attribute `'disable-lui-tpc-check'` on the `` element -of the document. It has to be called once the DOM is ready. - -##### Examples - -```javascript -LuigiClient.disableTpcCheck(); -``` - -**Meta** - -* **since**: NEXTRELEASE - ### Lifecycle~initListenerCallback Callback of the addInitListener From 4d4e893313d3e94982e449068d5b652fcfdbef7e Mon Sep 17 00:00:00 2001 From: JohannesDoberer Date: Thu, 10 Oct 2024 10:37:22 +0200 Subject: [PATCH 5/9] prettier --- client/src/lifecycleManager.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/client/src/lifecycleManager.js b/client/src/lifecycleManager.js index 3494b2c852..f186c1b6d1 100644 --- a/client/src/lifecycleManager.js +++ b/client/src/lifecycleManager.js @@ -9,7 +9,7 @@ class LifecycleManager extends LuigiClientBase { /** @private */ constructor() { super(); - this.disableTpcCheck=false; + this.disableTpcCheck = false; this.luigiInitialized = false; this.defaultContextKeys = ['context', 'internal', 'nodeParams', 'pathParams', 'searchParams']; this.setCurrentContext( @@ -140,10 +140,7 @@ class LifecycleManager extends LuigiClientBase { } _tpcCheck() { - if ( - this.currentContext?.internal?.thirdPartyCookieCheck?.disabled || - this.disableTpcCheck - ) { + if (this.currentContext?.internal?.thirdPartyCookieCheck?.disabled || this.disableTpcCheck) { return; } let tpc = 'enabled'; From f4c3b03a1e97d33dfc91535596093d8f04ae94d9 Mon Sep 17 00:00:00 2001 From: JohannesDoberer Date: Thu, 10 Oct 2024 10:53:46 +0200 Subject: [PATCH 6/9] leftovers --- client/luigi-client.d.ts | 13 ------------- client/src/luigi-client.js | 3 --- 2 files changed, 16 deletions(-) diff --git a/client/luigi-client.d.ts b/client/luigi-client.d.ts index 642ee5d157..b40368e043 100644 --- a/client/luigi-client.d.ts +++ b/client/luigi-client.d.ts @@ -781,19 +781,6 @@ export type setAnchor = (anchor: String) => void; export function setViewGroupData(value: Object): void; export type setViewGroupData = (value: Object) => void; -/** - * Disables the TPC (Third-Party Cookies) check via Luigi Client. - * - * This function sets a custom attribute `'disable-lui-tpc-check'` on the `` element - * of the document. It has to be called once the DOM is ready. - * @since NEXTRELEASE - * @memberof Lifecycle - * @example - * LuigiClient.disableTpcCheck(); - */ -export function disableTpcCheck(): void; -export type disableTpcCheck = () => void; - /** * Read search query parameters which are sent from Luigi core * @memberof Lifecycle diff --git a/client/src/luigi-client.js b/client/src/luigi-client.js index 2b5a6b2d4f..e275a5d0d3 100644 --- a/client/src/luigi-client.js +++ b/client/src/luigi-client.js @@ -104,9 +104,6 @@ class LuigiClient { setViewGroupData(value) { return lifecycleManager.setViewGroupData(value); } - disableTpcCheck() { - return lifecycleManager.disableTpcCheck(); - } /** * @private From 143c49907002ccd1b88593d317868a8aa9bece8e Mon Sep 17 00:00:00 2001 From: JohannesDoberer Date: Thu, 10 Oct 2024 11:05:07 +0200 Subject: [PATCH 7/9] typescript declaration --- client/luigi-client.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/luigi-client.d.ts b/client/luigi-client.d.ts index b40368e043..9937fbad9f 100644 --- a/client/luigi-client.d.ts +++ b/client/luigi-client.d.ts @@ -594,10 +594,11 @@ export declare interface StorageManager { /** * Registers a listener called with the context object and the Luigi Core domain as soon as Luigi is instantiated. Defer your application bootstrap if you depend on authentication data coming from Luigi. * @param {Lifecycle~initListenerCallback} initFn the function that is called once Luigi is initialized, receives current context and origin as parameters + * @param {boolean} disableTpcCheck if set to `true` third party cookie check will be disabled via LuigiClient. * @memberof Lifecycle */ -export function addInitListener(initFn: (context: Context, origin?: string) => void): number; -export type addInitListener = (initFn: (context: Context, origin?: string) => void) => number; +export function addInitListener(initFn: (context: Context, origin?: string) => void, disableTpcCheck: boolean): number; +export type addInitListener = (initFn: (context: Context, origin?: string) => void, disableTpcCheck: boolean) => number; /** * Callback of the addInitListener From 77a72be8a39d7932d348bad76256690fff7a35fd Mon Sep 17 00:00:00 2001 From: JohannesDoberer Date: Thu, 10 Oct 2024 11:41:23 +0200 Subject: [PATCH 8/9] tpc optional --- client/luigi-client.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/luigi-client.d.ts b/client/luigi-client.d.ts index 9937fbad9f..fef0a0ef6c 100644 --- a/client/luigi-client.d.ts +++ b/client/luigi-client.d.ts @@ -597,8 +597,8 @@ export declare interface StorageManager { * @param {boolean} disableTpcCheck if set to `true` third party cookie check will be disabled via LuigiClient. * @memberof Lifecycle */ -export function addInitListener(initFn: (context: Context, origin?: string) => void, disableTpcCheck: boolean): number; -export type addInitListener = (initFn: (context: Context, origin?: string) => void, disableTpcCheck: boolean) => number; +export function addInitListener(initFn: (context: Context, origin?: string) => void, disableTpcCheck?: boolean): number; +export type addInitListener = (initFn: (context: Context, origin?: string) => void, disableTpcCheck?: boolean) => number; /** * Callback of the addInitListener From 0dc4a30e628a9ca427ce12f7c7d8f46279d0e12e Mon Sep 17 00:00:00 2001 From: JohannesDoberer Date: Thu, 10 Oct 2024 11:41:44 +0200 Subject: [PATCH 9/9] prettier --- client/luigi-client.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/luigi-client.d.ts b/client/luigi-client.d.ts index fef0a0ef6c..0215750fc3 100644 --- a/client/luigi-client.d.ts +++ b/client/luigi-client.d.ts @@ -598,7 +598,10 @@ export declare interface StorageManager { * @memberof Lifecycle */ export function addInitListener(initFn: (context: Context, origin?: string) => void, disableTpcCheck?: boolean): number; -export type addInitListener = (initFn: (context: Context, origin?: string) => void, disableTpcCheck?: boolean) => number; +export type addInitListener = ( + initFn: (context: Context, origin?: string) => void, + disableTpcCheck?: boolean +) => number; /** * Callback of the addInitListener