Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable tpc via client #3983

Merged
merged 16 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions client/luigi-client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,14 @@ 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
Expand Down
7 changes: 5 additions & 2 deletions client/src/lifecycleManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -139,7 +140,7 @@ class LifecycleManager extends LuigiClientBase {
}

_tpcCheck() {
if (this.currentContext?.internal?.thirdPartyCookieCheck?.disabled) {
if (this.currentContext?.internal?.thirdPartyCookieCheck?.disabled || this.disableTpcCheck) {
return;
}
let tpc = 'enabled';
Expand Down Expand Up @@ -226,11 +227,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)) {
Expand Down
5 changes: 2 additions & 3 deletions client/src/luigi-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -105,7 +105,6 @@ class LuigiClient {
return lifecycleManager.setViewGroupData(value);
}


/**
* @private
*/
Expand Down
1 change: 1 addition & 0 deletions docs/luigi-client-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down