diff --git a/modules/33acrossIdSystem.js b/modules/33acrossIdSystem.js index 0a24ef54731..5320f562ae4 100644 --- a/modules/33acrossIdSystem.js +++ b/modules/33acrossIdSystem.js @@ -146,7 +146,7 @@ export const thirthyThreeAcrossIdSubmodule = { * @param {SubmoduleConfig} [config] * @returns {IdResponse|undefined} */ - getId({ params = { }, storage }, gdprConsentData) { + getId({ params = { }, storage: storageConfig }, gdprConsentData) { if (typeof params.pid !== 'string') { logError(`${MODULE_NAME}: Submodule requires a partner ID to be defined`); @@ -167,7 +167,11 @@ export const thirthyThreeAcrossIdSubmodule = { logError(`${MODULE_NAME}: ID reading error:`, err); } - handleFpId(responseObj.fp, storage); + if (!responseObj.envelope) { + deleteFromStorage(MODULE_NAME); + } + + handleFpId(responseObj.fp, storageConfig); cb(responseObj.envelope); }, @@ -176,7 +180,7 @@ export const thirthyThreeAcrossIdSubmodule = { cb(); } - }, calculateQueryStringParams(pid, gdprConsentData, storage), { method: 'GET', withCredentials: true }); + }, calculateQueryStringParams(pid, gdprConsentData, storageConfig), { method: 'GET', withCredentials: true }); } }; }, diff --git a/test/spec/modules/33acrossIdSystem_spec.js b/test/spec/modules/33acrossIdSystem_spec.js index 8f23d4614b5..0c91d54aba7 100644 --- a/test/spec/modules/33acrossIdSystem_spec.js +++ b/test/spec/modules/33acrossIdSystem_spec.js @@ -127,8 +127,8 @@ describe('33acrossIdSystem', () => { }); }); - context('if the response doesn\'t include a first-party ID', () => { - it('should try to remove any first-party ID that could be stored', () => { + context('if the response lacks a first-party ID', () => { + it('should wipe any existing first-party ID from storage', () => { const completeCallback = () => {}; const { callback } = thirthyThreeAcrossIdSubmodule.getId({ @@ -167,13 +167,16 @@ describe('33acrossIdSystem', () => { }); }); - context('if the response lacks a first-party ID', () => { - it('should wipe any existing first-party ID from storage', () => { + context('if the response lacks the 33across "envelope" ID', () => { + it('should wipe any existing "envelope" ID from storage', () => { const completeCallback = () => {}; const { callback } = thirthyThreeAcrossIdSubmodule.getId({ params: { pid: '12345' + }, + storage: { + type: 'html5' } }); @@ -182,20 +185,25 @@ describe('33acrossIdSystem', () => { const [request] = server.requests; const removeDataFromLocalStorage = sinon.stub(storage, 'removeDataFromLocalStorage'); + const setCookie = sinon.stub(storage, 'setCookie'); + const cookiesAreEnabled = sinon.stub(storage, 'cookiesAreEnabled').returns(true); request.respond(200, { 'Content-Type': 'application/json' }, JSON.stringify({ succeeded: true, data: { - envelope: 'foo' + envelope: '' // no 'envelope' field }, expires: 1645667805067 })); - expect(removeDataFromLocalStorage.calledOnceWithExactly('33acrossIdFp')).to.be.true; + expect(removeDataFromLocalStorage.calledWith('33acrossId')).to.be.true; + expect(setCookie.calledWith('33acrossId', '', sinon.match.string, 'Lax')).to.be.true; removeDataFromLocalStorage.restore(); + setCookie.restore(); + cookiesAreEnabled.restore(); }); });