Skip to content

Commit c0c8b58

Browse files
authored
[BUGFIX] AdagioBidAdapter getDataFromLocalStorage (#5081)
* AdagioBidAdapter: fix getDataFromLocalStorage * AdagioBidAdapter: bump fix version 2.2.1
1 parent 198f63e commit c0c8b58

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

modules/adagioBidAdapter.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import sha256 from 'crypto-js/sha256.js';
77
import { getStorageManager } from '../src/storageManager.js';
88

99
const BIDDER_CODE = 'adagio';
10-
const VERSION = '2.2.0';
10+
const VERSION = '2.2.1';
1111
const FEATURES_VERSION = '1';
1212
const ENDPOINT = 'https://mp.4dex.io/prebid';
1313
const SUPPORTED_MEDIA_TYPES = ['banner'];
1414
const ADAGIO_TAG_URL = 'https://script.4dex.io/localstore.js';
1515
const ADAGIO_LOCALSTORAGE_KEY = 'adagioScript';
1616
const GVLID = 617;
17-
const storage = getStorageManager(GVLID);
17+
const storage = getStorageManager(GVLID, 'adagio');
1818

1919
export const ADAGIO_PUBKEY = `-----BEGIN PUBLIC KEY-----
2020
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9el0+OEn6fvEh1RdVHQu4cnT0
@@ -23,10 +23,8 @@ t0b0lsHN+W4n9kitS/DZ/xnxWK/9vxhv0ZtL1LL/rwR5Mup7rmJbNtDoNBw4TIGj
2323
pV6EP3MTLosuUEpLaQIDAQAB
2424
-----END PUBLIC KEY-----`;
2525

26-
export function getAdagioScript() {
26+
export function adagioScriptFromLocalStorageCb(ls) {
2727
try {
28-
const ls = storage.getDataFromLocalStorage(ADAGIO_LOCALSTORAGE_KEY);
29-
3028
if (!ls) {
3129
utils.logWarn('Adagio Script not found');
3230
return;
@@ -58,6 +56,12 @@ export function getAdagioScript() {
5856
}
5957
}
6058

59+
export function getAdagioScript() {
60+
storage.getDataFromLocalStorage(ADAGIO_LOCALSTORAGE_KEY, (ls) => {
61+
adagioScriptFromLocalStorageCb(ls)
62+
});
63+
}
64+
6165
function canAccessTopWindow() {
6266
try {
6367
if (utils.getWindowTop().location.href) {

test/spec/modules/adagioBidAdapter_spec.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { expect } from 'chai';
2-
import { getAdagioScript, spec } from 'modules/adagioBidAdapter.js';
2+
import { adagioScriptFromLocalStorageCb, spec } from 'modules/adagioBidAdapter.js';
33
import { newBidder } from 'src/adapters/bidderFactory.js';
44
import * as utils from 'src/utils.js';
55

66
describe('adagioAdapter', () => {
77
let utilsMock;
88
const adapter = newBidder(spec);
99
const ENDPOINT = 'https://mp.4dex.io/prebid';
10-
const VERSION = '2.2.0';
10+
const VERSION = '2.2.1';
1111

1212
beforeEach(function() {
1313
localStorage.removeItem('adagioScript');
@@ -738,7 +738,7 @@ describe('adagioAdapter', () => {
738738
});
739739
});
740740

741-
describe('getAdagioScript', () => {
741+
describe('adagioScriptFromLocalStorageCb', () => {
742742
const VALID_HASH = 'Lddcw3AADdQDrPtbRJkKxvA+o1CtScGDIMNRpHB3NnlC/FYmy/9RKXelKrYj/sjuWusl5YcOpo+lbGSkk655i8EKuDiOvK6ae/imxSrmdziIp+S/TA6hTFJXcB8k1Q9OIp4CMCT52jjXgHwX6G0rp+uYoCR25B1jHaHnpH26A6I=';
743743
const INVALID_HASH = 'invalid';
744744
const VALID_SCRIPT_CONTENT = 'var _ADAGIO=function(){};(_ADAGIO)();\n';
@@ -752,7 +752,7 @@ describe('adagioAdapter', () => {
752752
utilsMock.expects('logWarn').withExactArgs('No hash found in Adagio script').never();
753753
utilsMock.expects('logWarn').withExactArgs('Invalid Adagio script found').never();
754754

755-
getAdagioScript();
755+
adagioScriptFromLocalStorageCb(localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY));
756756

757757
expect(localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY)).to.equals('// hash: ' + VALID_HASH + '\n' + VALID_SCRIPT_CONTENT);
758758
utilsMock.verify();
@@ -765,7 +765,7 @@ describe('adagioAdapter', () => {
765765
utilsMock.expects('logWarn').withExactArgs('No hash found in Adagio script').never();
766766
utilsMock.expects('logWarn').withExactArgs('Invalid Adagio script found').once();
767767

768-
getAdagioScript();
768+
adagioScriptFromLocalStorageCb(localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY));
769769

770770
expect(localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY)).to.be.null;
771771
utilsMock.verify();
@@ -778,7 +778,7 @@ describe('adagioAdapter', () => {
778778
utilsMock.expects('logWarn').withExactArgs('No hash found in Adagio script').never();
779779
utilsMock.expects('logWarn').withExactArgs('Invalid Adagio script found').once();
780780

781-
getAdagioScript();
781+
adagioScriptFromLocalStorageCb(localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY));
782782

783783
expect(localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY)).to.be.null;
784784
utilsMock.verify();
@@ -791,7 +791,7 @@ describe('adagioAdapter', () => {
791791
utilsMock.expects('logWarn').withExactArgs('No hash found in Adagio script').once();
792792
utilsMock.expects('logWarn').withExactArgs('Invalid Adagio script found').never();
793793

794-
getAdagioScript();
794+
adagioScriptFromLocalStorageCb(localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY));
795795

796796
expect(localStorage.getItem(ADAGIO_LOCALSTORAGE_KEY)).to.be.null;
797797
utilsMock.verify();

0 commit comments

Comments
 (0)