From 110782c299752e9430cd79d07048f9e021187964 Mon Sep 17 00:00:00 2001 From: Maximilian Haupt Date: Fri, 10 Jul 2026 09:15:26 +0200 Subject: [PATCH 1/2] feat: handle reconsent in OneTrust adapter --- .../src/OnetrustCmpAdapter.test.ts | 17 +++++++++++++++ .../src/OnetrustCmpAdapter.ts | 21 +++++++++++-------- .../src/react-native-onetrust-cmp.d.ts | 1 + 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/packages/react-native-contentpass-cmp-onetrust/src/OnetrustCmpAdapter.test.ts b/packages/react-native-contentpass-cmp-onetrust/src/OnetrustCmpAdapter.test.ts index a53bf52..e5b0d51 100644 --- a/packages/react-native-contentpass-cmp-onetrust/src/OnetrustCmpAdapter.test.ts +++ b/packages/react-native-contentpass-cmp-onetrust/src/OnetrustCmpAdapter.test.ts @@ -81,6 +81,7 @@ function createMockSdk(overrides: Partial = {}): { .fn() .mockResolvedValue(createPreferenceCenterData()), saveConsent: jest.fn().mockResolvedValue(undefined), + shouldShowBanner: jest.fn().mockResolvedValue(false), getConsentStatusForCategory: jest.fn().mockResolvedValue(1), addEventListener: jest.fn( (eventName: OTEventName, handler: EventHandler) => { @@ -112,6 +113,22 @@ describe('createOnetrustCmpAdapter', () => { }); describe('OnetrustCmpAdapter', () => { + it('should report full consent when all purposes are accepted and no banner is required', async () => { + const { sdk } = createMockSdk(); + const adapter = await createOnetrustCmpAdapter(sdk); + + await expect(adapter.hasFullConsent()).resolves.toBe(true); + }); + + it('should report missing consent when OneTrust requires reconsent', async () => { + const { sdk } = createMockSdk({ + shouldShowBanner: jest.fn().mockResolvedValue(true), + }); + const adapter = await createOnetrustCmpAdapter(sdk); + + await expect(adapter.hasFullConsent()).resolves.toBe(false); + }); + it('should emit consent status when OneTrust confirms preference-center choices', async () => { const { sdk, eventHandlers } = createMockSdk({ getConsentStatusForCategory: jest diff --git a/packages/react-native-contentpass-cmp-onetrust/src/OnetrustCmpAdapter.ts b/packages/react-native-contentpass-cmp-onetrust/src/OnetrustCmpAdapter.ts index ac40eaf..9b64ecb 100644 --- a/packages/react-native-contentpass-cmp-onetrust/src/OnetrustCmpAdapter.ts +++ b/packages/react-native-contentpass-cmp-onetrust/src/OnetrustCmpAdapter.ts @@ -111,17 +111,20 @@ export default class OnetrustCmpAdapter implements CmpAdapter { }); } - // FIXME handle reconsent scenarios hasFullConsent = async (): Promise => { console.debug('[OnetrustCmpAdapter::hasFullConsent]'); - const consentStatuses = await Promise.all( - this.groupIds.map((groupId) => - this.sdk.getConsentStatusForCategory(groupId) - ) - ); - - return consentStatuses.every( - (consentStatus: number) => consentStatus === 1 + const [shouldShowBanner, consentStatuses] = await Promise.all([ + this.sdk.shouldShowBanner(), + Promise.all( + this.groupIds.map((groupId) => + this.sdk.getConsentStatusForCategory(groupId) + ) + ), + ]); + + return ( + !shouldShowBanner && + consentStatuses.every((consentStatus: number) => consentStatus === 1) ); }; diff --git a/packages/react-native-contentpass-cmp-onetrust/src/react-native-onetrust-cmp.d.ts b/packages/react-native-contentpass-cmp-onetrust/src/react-native-onetrust-cmp.d.ts index 0cfb384..9bda601 100644 --- a/packages/react-native-contentpass-cmp-onetrust/src/react-native-onetrust-cmp.d.ts +++ b/packages/react-native-contentpass-cmp-onetrust/src/react-native-onetrust-cmp.d.ts @@ -19,6 +19,7 @@ declare module 'react-native-onetrust-cmp' { getBannerData(): Promise; getPreferenceCenterData(): Promise; saveConsent(interaction: OTConsentInteraction): Promise; + shouldShowBanner(): Promise; getConsentStatusForCategory(categoryId: string): Promise; addEventListener( eventName: OTEventName, From 02b68fe44f979462344e5c5885598ae148335bb9 Mon Sep 17 00:00:00 2001 From: Maximilian Haupt Date: Fri, 10 Jul 2026 09:16:41 +0200 Subject: [PATCH 2/2] chore: bump versions --- packages/react-native-contentpass-cmp-onetrust/CHANGELOG.md | 6 ++++++ packages/react-native-contentpass-cmp-onetrust/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/react-native-contentpass-cmp-onetrust/CHANGELOG.md b/packages/react-native-contentpass-cmp-onetrust/CHANGELOG.md index 65bcb55..42a9922 100644 --- a/packages/react-native-contentpass-cmp-onetrust/CHANGELOG.md +++ b/packages/react-native-contentpass-cmp-onetrust/CHANGELOG.md @@ -1,5 +1,11 @@ # @contentpass/react-native-contentpass-cmp-onetrust +## 0.3.2 + +### Patch Changes + +- Handle reconsent in OneTrust adapter + ## 0.3.1 ### Patch Changes diff --git a/packages/react-native-contentpass-cmp-onetrust/package.json b/packages/react-native-contentpass-cmp-onetrust/package.json index d7cf5e2..ff4ae1a 100644 --- a/packages/react-native-contentpass-cmp-onetrust/package.json +++ b/packages/react-native-contentpass-cmp-onetrust/package.json @@ -1,6 +1,6 @@ { "name": "@contentpass/react-native-contentpass-cmp-onetrust", - "version": "0.3.1", + "version": "0.3.2", "description": "Contentpass OneTrust CMP adapter", "source": "./src/index.ts", "main": "./lib/commonjs/index.js",