@schibsted/advertory 2.71.18 → 2.72.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/core/aftenposten/es/index.css +1 -1
  2. package/core/aftenposten/es/index.d.ts +3 -1
  3. package/core/aftenposten/es/index.js +1 -1
  4. package/core/aftenposten/index.d.ts +3 -1
  5. package/core/aftenposten/index.js +1 -1
  6. package/core/aftenpostenv2/es/index.css +1 -1
  7. package/core/aftenpostenv2/es/index.d.ts +3 -1
  8. package/core/aftenpostenv2/es/index.js +1 -1
  9. package/core/aftonbladet/es/index.css +1 -1
  10. package/core/aftonbladet/es/index.d.ts +3 -1
  11. package/core/aftonbladet/es/index.js +1 -1
  12. package/core/aftonbladet/index.d.ts +3 -1
  13. package/core/aftonbladet/index.js +1 -1
  14. package/core/aftonbladetv2/es/index.css +1 -1
  15. package/core/aftonbladetv2/es/index.d.ts +3 -1
  16. package/core/aftonbladetv2/es/index.js +1 -1
  17. package/core/bt/es/index.css +1 -1
  18. package/core/bt/es/index.d.ts +3 -1
  19. package/core/bt/es/index.js +1 -1
  20. package/core/bt/index.d.ts +3 -1
  21. package/core/bt/index.js +1 -1
  22. package/core/btv2/es/index.css +1 -1
  23. package/core/btv2/es/index.d.ts +3 -1
  24. package/core/btv2/es/index.js +1 -1
  25. package/core/e24/es/index.css +1 -1
  26. package/core/e24/es/index.d.ts +3 -1
  27. package/core/e24/es/index.js +1 -1
  28. package/core/e24/index.d.ts +3 -1
  29. package/core/e24/index.js +1 -1
  30. package/core/fotbollskanalen/es/index.css +1 -1
  31. package/core/fotbollskanalen/es/index.d.ts +3 -1
  32. package/core/fotbollskanalen/es/index.js +1 -1
  33. package/core/fotbollskanalen/index.d.ts +3 -1
  34. package/core/fotbollskanalen/index.js +1 -1
  35. package/core/godare/index.d.ts +3 -1
  36. package/core/godare/index.js +1 -1
  37. package/core/godt/index.d.ts +3 -1
  38. package/core/godt/index.js +1 -1
  39. package/core/klart/index.d.ts +3 -1
  40. package/core/klart/index.js +1 -1
  41. package/core/koket/es/index.css +1 -1
  42. package/core/koket/es/index.d.ts +3 -1
  43. package/core/koket/es/index.js +1 -1
  44. package/core/koket/index.d.ts +3 -1
  45. package/core/koket/index.js +1 -1
  46. package/core/kompakt/index.d.ts +3 -1
  47. package/core/kompakt/index.js +1 -1
  48. package/core/minmote/index.d.ts +3 -1
  49. package/core/minmote/index.js +1 -1
  50. package/core/pent/index.d.ts +3 -1
  51. package/core/pent/index.js +1 -1
  52. package/core/sa/es/index.css +1 -1
  53. package/core/sa/es/index.d.ts +3 -1
  54. package/core/sa/es/index.js +1 -1
  55. package/core/sa/index.d.ts +3 -1
  56. package/core/sa/index.js +1 -1
  57. package/core/sav2/es/index.css +1 -1
  58. package/core/sav2/es/index.d.ts +3 -1
  59. package/core/sav2/es/index.js +1 -1
  60. package/core/svd/es/index.css +1 -1
  61. package/core/svd/es/index.d.ts +3 -1
  62. package/core/svd/es/index.js +1 -1
  63. package/core/svd/index.d.ts +3 -1
  64. package/core/svd/index.js +1 -1
  65. package/core/svdv2/es/index.css +1 -1
  66. package/core/svdv2/es/index.d.ts +3 -1
  67. package/core/svdv2/es/index.js +1 -1
  68. package/core/tek/index.d.ts +3 -1
  69. package/core/tek/index.js +1 -1
  70. package/core/tv4/es/index.css +1 -1
  71. package/core/tv4/es/index.d.ts +3 -1
  72. package/core/tv4/es/index.js +1 -1
  73. package/core/tv4/index.d.ts +3 -1
  74. package/core/tv4/index.js +1 -1
  75. package/core/tvnu/index.d.ts +3 -1
  76. package/core/tvnu/index.js +1 -1
  77. package/core/vg/es/index.css +1 -1
  78. package/core/vg/es/index.d.ts +3 -1
  79. package/core/vg/es/index.js +1 -1
  80. package/core/vg/index.d.ts +3 -1
  81. package/core/vg/index.js +1 -1
  82. package/core/vgv2/es/index.css +1 -1
  83. package/core/vgv2/es/index.d.ts +3 -1
  84. package/core/vgv2/es/index.js +1 -1
  85. package/features/ad-native/index.d.ts +2 -0
  86. package/features/ad-native/index.js +1 -1
  87. package/features/dr-edition/es/index.d.ts +2 -0
  88. package/features/dr-edition/index.d.ts +2 -0
  89. package/features/kilkaya/es/index.d.ts +2 -0
  90. package/features/kilkaya/index.d.ts +2 -0
  91. package/features/tracker/index.d.ts +4 -1
  92. package/features/tracker/index.js +1 -1
  93. package/package.json +1 -1
  94. package/sites/aftenposten/es/index.css +1 -1
  95. package/sites/aftenposten/index.js +1 -1
  96. package/sites/aftenpostenv2/es/index.css +1 -1
  97. package/sites/aftonbladet/es/index.css +1 -1
  98. package/sites/aftonbladetv2/es/index.css +1 -1
  99. package/sites/bt/es/index.css +1 -1
  100. package/sites/bt/index.js +1 -1
  101. package/sites/btv2/es/index.css +1 -1
  102. package/sites/e24/es/index.css +1 -1
  103. package/sites/fotbollskanalen/es/index.css +1 -1
  104. package/sites/koket/es/index.css +1 -1
  105. package/sites/sa/es/index.css +1 -1
  106. package/sites/sa/index.js +1 -1
  107. package/sites/sav2/es/index.css +1 -1
  108. package/sites/svd/es/index.css +1 -1
  109. package/sites/svd/index.js +1 -1
  110. package/sites/svdv2/es/index.css +1 -1
  111. package/sites/tv4/es/index.css +1 -1
  112. package/sites/tvnu/index.js +1 -1
  113. package/sites/vg/es/index.css +1 -1
  114. package/sites/vg/index.js +1 -1
  115. package/sites/vgv2/es/index.css +1 -1
  116. package/styles/aftonbladetv2/styles.css +1 -1
  117. package/types/core/interface/ast.d.ts +1 -1
  118. package/types/core/interface/config.d.ts +2 -0
  119. package/types/features/ad-native/trackers/trackers.d.ts +1 -1
  120. package/types/features/ad-server-side/banner-object.d.ts +4 -0
  121. package/types/features/ad-server-side/banner-object.test.d.ts +1 -0
  122. package/types/features/ad-server-side/cogwheel.d.ts +3 -0
  123. package/types/features/ad-server-side/constants.d.ts +2 -0
  124. package/types/features/ad-server-side/index.d.ts +5 -0
  125. package/types/features/ad-server-side/keywords.d.ts +3 -0
  126. package/types/features/ad-server-side/keywords.test.d.ts +1 -0
  127. package/types/features/ad-server-side/native-request.d.ts +42 -0
  128. package/types/features/ad-server-side/native-request.test.d.ts +1 -0
  129. package/types/features/ad-server-side/server-side-xandr-renderer.d.ts +3 -0
  130. package/types/features/ad-server-side/server-side-xandr-service.d.ts +7 -0
  131. package/types/features/cogwheel/index.d.ts +1 -1
  132. package/types/features/interface/ad-native.d.ts +1 -0
  133. package/types/features/interface/ad-server-side.d.ts +48 -0
  134. package/types/features/tracker/index.d.ts +3 -2
@@ -212,6 +212,8 @@ interface Placement {
212
212
  drEdition?: DrEditionPlacementConfig;
213
213
  isBackfill?: boolean;
214
214
  takeoverCookieCapForSharedPlacement?: boolean;
215
+ serverSidePlacement?: boolean;
216
+ xandrPlacementId?: number;
215
217
  supportsNonRTB?: boolean;
216
218
  }
217
219
  interface Placements {
@@ -212,6 +212,8 @@ interface Placement {
212
212
  drEdition?: DrEditionPlacementConfig;
213
213
  isBackfill?: boolean;
214
214
  takeoverCookieCapForSharedPlacement?: boolean;
215
+ serverSidePlacement?: boolean;
216
+ xandrPlacementId?: number;
215
217
  supportsNonRTB?: boolean;
216
218
  }
217
219
  interface Placements {
@@ -208,6 +208,8 @@ interface Placement {
208
208
  drEdition?: DrEditionPlacementConfig;
209
209
  isBackfill?: boolean;
210
210
  takeoverCookieCapForSharedPlacement?: boolean;
211
+ serverSidePlacement?: boolean;
212
+ xandrPlacementId?: number;
211
213
  supportsNonRTB?: boolean;
212
214
  }
213
215
  interface Placements {
@@ -208,6 +208,8 @@ interface Placement {
208
208
  drEdition?: DrEditionPlacementConfig;
209
209
  isBackfill?: boolean;
210
210
  takeoverCookieCapForSharedPlacement?: boolean;
211
+ serverSidePlacement?: boolean;
212
+ xandrPlacementId?: number;
211
213
  supportsNonRTB?: boolean;
212
214
  }
213
215
  interface Placements {
@@ -232,6 +232,8 @@ interface Placement {
232
232
  drEdition?: DrEditionPlacementConfig;
233
233
  isBackfill?: boolean;
234
234
  takeoverCookieCapForSharedPlacement?: boolean;
235
+ serverSidePlacement?: boolean;
236
+ xandrPlacementId?: number;
235
237
  supportsNonRTB?: boolean;
236
238
  }
237
239
  interface Placements {
@@ -472,7 +474,8 @@ declare const getUserIdsObject: (country: Country) => UserIdsObject;
472
474
  declare const getPPIDLoggedInStatus: () => PPIDLoggedInStatusKeywords;
473
475
  declare const getPPIDRelevantYieldConfig: (country: Country) => RelevantYieldPPIDConfig | object;
474
476
  declare const getPPIDNorstatString: (country: Country) => string;
477
+ declare const getOpenRtbEids: (country: Country) => Array<RelevantYieldEids>;
475
478
  declare const getVideoPPIDs: (country: Country) => Promise<string>;
476
479
  declare const getFinnBlinkUserId: () => Promise<string>;
477
480
 
478
- export { getFinnBlinkUserId, getPPIDLoggedInStatus, getPPIDNorstatString, getPPIDRelevantYieldConfig, getUserIdsObject, getVideoPPIDs, setXandrPPIDs };
481
+ export { getFinnBlinkUserId, getOpenRtbEids, getPPIDLoggedInStatus, getPPIDNorstatString, getPPIDRelevantYieldConfig, getUserIdsObject, getVideoPPIDs, setXandrPPIDs };
@@ -1 +1 @@
1
- "use strict";function e(e,i,n,t){return new(n||(n=Promise))(function(s,d){function r(e){try{a(t.next(e))}catch(e){d(e)}}function o(e){try{a(t.throw(e))}catch(e){d(e)}}function a(e){var i;e.done?s(e.value):(i=e.value,i instanceof n?i:new n(function(e){e(i)})).then(r,o)}a((t=t.apply(e,i||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const i={get:(i,n)=>e(void 0,void 0,void 0,function*(){const e=yield fetch(i,n);if(!e.ok)throw new Error(e.statusText);return yield e.json()}),post:(i,n,t)=>e(void 0,void 0,void 0,function*(){const e=JSON.stringify(t),s=yield fetch(i,{method:"POST",headers:n,body:e});if(!s.ok)throw new Error(s.statusText);return yield s.json()})},n=(e,i)=>{const n="[Advertory LOG]: ";location.search.includes("ast_debug=true")&&(i?console.log(n,e,i):console.log(n,e))},t=864e5,s=(()=>{const e=e=>{const i=window.localStorage.getItem(e);if(!i)return null;try{return JSON.parse(i)}catch(e){return n("Error with parsing localStorage data"),null}},i=(e,i)=>{window.localStorage.setItem(e,JSON.stringify(i))};return{get:e,set:i,setWithTimestamp:(e,n,s=t)=>{const d={data:n,expirationTime:(new Date).getTime()+s};i(e,JSON.stringify(d))},getByTimestamp:(i,s=t)=>{const d=e(i);if(!d)return null;if(!s)return d;try{const{expirationTime:e,data:i}=JSON.parse(d);return(new Date).getTime()<=e?i:null}catch(e){return n("Error with parsing localStorage data"),null}}}})(),d={NO:"no",SE:"se"},r="advertory:ppids-cache",o={[d.SE]:`SCH${d.SE.toUpperCase()}-EnvHash`,[d.NO]:`SCH${d.NO.toUpperCase()}-EnvHash`},a={[d.SE]:`SCH${d.SE.toUpperCase()}-UserHash`,[d.NO]:`SCH${d.NO.toUpperCase()}-UserHash`},l={[d.SE]:`sch${d.SE}-envhash-v3`,[d.NO]:`sch${d.NO}-envhash-v3`},c={[d.SE]:`sch${d.SE}-userhash-v3`,[d.NO]:`sch${d.NO}-userhash-v3`},u={[d.SE]:`'sch${d.SE}-iosid-v3'`,[d.NO]:`'sch${d.NO}-iosid-v3'`},p={[d.SE]:`sch${d.SE}-androidid-v3`,[d.NO]:`sch${d.NO}-androidid-v3`},v={[d.SE]:"sdrn:schibsted.com:user",[d.NO]:"sdrn:spid.no:user"};class h{constructor(){this.eids=[]}add(e,i){return e&&this.eids.push({id:e,source:i}),this}buildRyEids(){return this.eids.map(({id:e,source:i})=>({source:i,uids:[{id:e,atype:1,ext:{stype:"ppuid"}}]}))}buildEids(){return[...this.eids]}buildVideoEids(){return this.eids.map(({id:e,source:i})=>`${i},${e}`).join("|")}buildNorstatPath(){const e=this.eids[0];return e?`${e.source}-${e.id}`:""}buildNorstatQuery(e){const i=new URLSearchParams;return this.eids.slice(1).forEach(({id:n,source:t})=>{i.append(e,`${t}-${n}`)}),i}}const f=e=>new Promise(i=>{if(!window._tcf_||!(null==e?void 0:e.enabled))return void i(!1);const t=(()=>{if(!window._tcf_)return null;const e=window._tcf_.getPermissionSync("CMP:advertising");if(null===e)return null;const i=Number(e);return n("Advertising permission value obtained synchronously: ",e),Boolean(i)})();if(null!==t)return void i(t);let s=!1;const d=e=>{s||(n("Resolving advertising permission value obtained"),s=!0,i(e))},r=setTimeout(()=>{n("Advertising permission timed out, resolving with false"),d(!1)},3e3);window._tcf_.onTcfReady(()=>{n("On Tcf Ready called, waiting for permission"),clearTimeout(r)}),window._tcf_.getPermission("CMP:advertising",e=>{clearTimeout(r);const i=Number(e);n("Advertising permission value obtained asynchronously: ",e),d(Boolean(i))})}),P="cmp:loaded";let g="undefined"!=typeof window?window._tcf_:void 0,I=!1;const y=(i,t,s)=>{const r=!!(null==i?void 0:i.enabled),o=(null==i?void 0:i.timeout)||3e3,a=(l="bypass_tcf",new URLSearchParams(window.location.search).get(l));var l;const c=()=>{if(!(null==i?void 0:i.enabled))return!0;if(((e,i)=>e?!!i&&(n("TCF bypass param detected, returning consent: true"),!0):(n("TCF is not enabled, returning consent: true"),!0))(r,a))return!0;if(I)return null;if(!g)throw new Error("[Advertory]: getConsentSync method was called before the tcfManager was available.");const e=g.getConsentedToAllSync();return n(`TCF consented to all is: ${e}`),g.getConsentedToAllSync()};return{initConsentManager:()=>(null==i?void 0:i.enabled)?new Promise((e,i)=>{if(n("Getting TCF consent manager..."),window._tcf_)return n("TCF consent manager is already available"),g=window._tcf_,void e(g);n("TCF consent manager is not available");const t=()=>{n("CMP loaded, resolving consent manager..."),s&&clearTimeout(s),window._tcf_?(g=window._tcf_,e(g)):i(new Error("CMP loaded but window._tcf_ is not defined"))},s=setTimeout(()=>{document.removeEventListener(P,t),I=!0,i(new Error("Timeout waiting for CMP to load"))},o);n("Listening for CMP loaded event..."),document.addEventListener(P,t,{once:!0})}):Promise.resolve(null),getConsentSync:c,getConsentAsync:()=>e(void 0,void 0,void 0,function*(){if(null==i?void 0:i.schibstedAdChoicesOverrideValue)return n(`Schibsted Ad Choices override value is set, returning override value: ${i.schibstedAdChoicesOverrideValue}`),Boolean(Number(i.schibstedAdChoicesOverrideValue));const e=(null==i?void 0:i.schibstedAdChoicesEnabled)&&s===d.SE,t=(null==i?void 0:i.schibstedAdChoicesEnabled)&&s===d.NO;if(e||t)return n("Schibsted Ad Choices is enabled, getting advertising permissions..."),yield f(i);if(!(null==i?void 0:i.enabled))return!0;const r=c();return null!==r?r:yield new Promise((e,i)=>{try{if(!g)throw new Error("[Advertory]: getConsentAsync method was called before the tcfManager was available.");let i=!1;const t=n=>{i||(i=!0,e(n))},s=setTimeout(()=>{n("TCF isConsentedToAll timed out, resolving with false"),t(!1)},o);g.onTcfReady(()=>{n("On Tcf Ready called, waiting for consent"),clearTimeout(s)}),g.isConsentedToAll(i=>{clearTimeout(s),e(i)})}catch(e){i(e)}})})}},m=new class{constructor(){this.ppid1=null,this.ppid2=null}processPPIDs(i){return e(this,arguments,void 0,function*(e,i=1e4){var n,t;const s=yield Promise.race([new Promise(e=>{setTimeout(()=>e({xandr:{ppId1:"",ppId2:""}}),i)}),e.instance.getAdvertisingIdentifiers()]);this.setPPIDs(null===(n=s.xandr)||void 0===n?void 0:n.ppId1,null===(t=s.xandr)||void 0===t?void 0:t.ppId2)})}getPPIDs(){var e,i;return null!==this.ppid1&&null!==this.ppid2||n("PPIDv2s accessed before they have been initialized"),{ppid1:null!==(e=this.ppid1)&&void 0!==e?e:"",ppid2:null!==(i=this.ppid2)&&void 0!==i?i:""}}setPPIDs(e,i){this.ppid1=null!=e?e:"",this.ppid2=null!=i?i:""}},w=new class{constructor(){this.ppid1=null,this.ppid2=null,this.idfv=null,this.anId=null}processPPIDs(i,n){return e(this,void 0,void 0,function*(){var e,t,d,o,a,l,c,u,p,v,h;const f=s.get(r),P=yield this.getNewPPIDs(i,n);if(this.shouldHash(f,P)){const n=null!==(e=i.hasherUrl)&&void 0!==e?e:"https://hasher.schibsted.com/api/v1/hash",s=this.createHasherPayload(P),r=yield this.hashPPIDs(s,n);return r?(this.cachePPIDs(s,r,null===(t=P.idfv)||void 0===t?void 0:t.plain,null===(d=P.anId)||void 0===d?void 0:d.plain),void this.setPPIDs(null!==(o=r.userId)&&void 0!==o?o:"",null!==(a=r.environmentId)&&void 0!==a?a:"",null===(l=P.idfv)||void 0===l?void 0:l.plain,null===(c=P.anId)||void 0===c?void 0:c.plain)):void this.setPPIDs("","")}this.setPPIDs(null!==(u=null==f?void 0:f.userId.hashed)&&void 0!==u?u:"",null!==(p=null==f?void 0:f.environmentId.hashed)&&void 0!==p?p:"",null===(v=null==P?void 0:P.idfv)||void 0===v?void 0:v.plain,null===(h=null==P?void 0:P.anId)||void 0===h?void 0:h.plain)})}getPPIDs(){var e,i;return null!==this.ppid1&&null!==this.ppid2||n("PPIDv3s accessed before they have been initialized"),{ppid1:null!==(e=this.ppid1)&&void 0!==e?e:"",ppid2:null!==(i=this.ppid2)&&void 0!==i?i:"",idfv:this.idfv,anId:this.anId}}setPPIDs(e,i,n,t){this.ppid1=null!=e?e:"",this.ppid2=null!=i?i:"",this.idfv=null!=n?n:null,this.anId=null!=t?t:null}shouldHash(e,i){var n,t;if(!e)return!0;for(const s in e){if((null===(n=e[s])||void 0===n?void 0:n.plain)!==(null===(t=i[s])||void 0===t?void 0:t.plain))return!0}return!1}cachePPIDs(e,i,n,t){const d=Object.assign(Object.assign({clientId:{plain:e.clientId},userId:{plain:e.userId,hashed:i.userId},environmentId:{plain:e.environmentId,hashed:i.environmentId},trackerType:{plain:e.trackerType},trackerVersion:{plain:e.trackerVersion}},n?{idfv:{plain:n}}:{}),t?{anId:{plain:t}}:{});s.set(r,d)}hashPPIDs(t,s){return e(this,void 0,void 0,function*(){try{const e=new Headers({"Content-Type":"application/json"});return yield i.post(s,e,t)}catch(e){return n("Error with hashing PPIDs",e),null}})}getNewPPIDs(i,n){return e(this,arguments,void 0,function*({clientId:i,instance:n},t){const s=yield((i,n)=>e(void 0,void 0,void 0,function*(){const e=yield i.getUserId();return e?`${v[n]}:${e}`:null}))(n,t),d=yield(i=>e(void 0,void 0,void 0,function*(){const e=yield i.getEnvironmentId();return e?`sdrn:schibsted:environment:${e}`:null}))(n),r=window.advertory_idfv,o=window.advertory_anId;return Object.assign(Object.assign({clientId:{plain:i},userId:{plain:s},environmentId:{plain:d},trackerType:{plain:"Advertory"},trackerVersion:{plain:"1.0.0"}},r?{idfv:{plain:r}}:{}),o?{anId:{plain:o}}:{})})}createHasherPayload({clientId:e,trackerType:i,trackerVersion:n,userId:t,environmentId:s}){return{clientId:e.plain,trackerType:i.plain,trackerVersion:n.plain,userId:t.plain,environmentId:s.plain}}};exports.getFinnBlinkUserId=()=>e(void 0,void 0,void 0,function*(){const{ppid2:e}=w.getPPIDs();return e}),exports.getPPIDLoggedInStatus=()=>{const{ppid1:e,ppid2:i}=m.getPPIDs();return{"aa-sch-schuserhash":e?"1":"0","aa-sch-schenvhash":i?"1":"0"}},exports.getPPIDNorstatString=e=>{const{ppid1:i,ppid2:n}=m.getPPIDs(),{ppid1:t,ppid2:s}=w.getPPIDs(),d=(new h).add(n,o[e]).add(i,a[e]).add(s,l[e]).add(t,c[e]);return`${d.buildNorstatPath()}?${d.buildNorstatQuery("alias").toString()}`},exports.getPPIDRelevantYieldConfig=e=>{const{ppid1:i,ppid2:n}=m.getPPIDs(),{ppid1:t,ppid2:s,idfv:d,anId:r}=w.getPPIDs();if(!n)return{};return{userSync:{userIds:[{name:"pubProvidedId",params:{eids:(new h).add(n,o[e]).add(i,a[e]).add(s,l[e]).add(t,c[e]).add(d,u[e]).add(r,p[e]).buildRyEids()}}]}}},exports.getUserIdsObject=e=>{const{ppid1:i,ppid2:n}=m.getPPIDs(),{ppid1:t,ppid2:s,idfv:d,anId:r}=w.getPPIDs();return{userIds:[{type:"extendedIDs",eids:(new h).add(n,o[e]).add(i,a[e]).add(s,l[e]).add(t,c[e]).add(d,u[e]).add(r,p[e]).buildEids()}]}},exports.getVideoPPIDs=i=>e(void 0,void 0,void 0,function*(){const{ppid1:e,ppid2:n}=m.getPPIDs(),{ppid1:t,ppid2:s}=w.getPPIDs(),d=(new h).add(n,o[i]).add(e,a[i]).add(s,l[i]).add(t,c[i]);return yield new Promise(e=>{e(d.buildVideoEids())})}),exports.setXandrPPIDs=i=>e(void 0,void 0,void 0,function*(){const{tracker:t,tcf:s,country:d,isMobileApp:r}=i,o=yield((i,t,s,...d)=>e(void 0,[i,t,s,...d],void 0,function*(e,i,t,s="NOT SPECIFIED FEATURE"){if(!(null==e?void 0:e.schibstedConsentToPayEnabled))return n(`Schibsted Consent to Pay is not enabled, returning true for ${s}`),!0;if(null==e?void 0:e.schibstedAdChoicesOverrideValue)return n(`Schibsted Ad Choices override value is set, returning override value: ${null==e?void 0:e.schibstedAdChoicesOverrideValue} for ${s}`),Boolean(Number(null==e?void 0:e.schibstedAdChoicesOverrideValue));const{getConsentAsync:d}=y(e,0,t);return(yield d())?(n(`Schibsted Ad Choices consent given according to TCF consent manager for ${s}`),!0):(n(`Schibsted Ad Choices consent not given according to TCF consent manager for ${s}`),!1)}))(s,r,d,"setXandrPPIDs");if(!o)return;if(!t)return;(yield Promise.allSettled([m.processPPIDs(t,null==s?void 0:s.timeout),w.processPPIDs(t,d)])).forEach((e,i)=>{if("rejected"===e.status){n(`Cannot fetch PPIDs v${i+2}`,e.reason)}})});
1
+ "use strict";function e(e,i,n,t){return new(n||(n=Promise))(function(s,d){function r(e){try{a(t.next(e))}catch(e){d(e)}}function o(e){try{a(t.throw(e))}catch(e){d(e)}}function a(e){var i;e.done?s(e.value):(i=e.value,i instanceof n?i:new n(function(e){e(i)})).then(r,o)}a((t=t.apply(e,i||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const i={get:(i,n)=>e(void 0,void 0,void 0,function*(){const e=yield fetch(i,n);if(!e.ok)throw new Error(e.statusText);return yield e.json()}),post:(i,n,t)=>e(void 0,void 0,void 0,function*(){const e=JSON.stringify(t),s=yield fetch(i,{method:"POST",headers:n,body:e});if(!s.ok)throw new Error(s.statusText);return yield s.json()})},n=(e,i)=>{const n="[Advertory LOG]: ";location.search.includes("ast_debug=true")&&(i?console.log(n,e,i):console.log(n,e))},t=864e5,s=(()=>{const e=e=>{const i=window.localStorage.getItem(e);if(!i)return null;try{return JSON.parse(i)}catch(e){return n("Error with parsing localStorage data"),null}},i=(e,i)=>{window.localStorage.setItem(e,JSON.stringify(i))};return{get:e,set:i,setWithTimestamp:(e,n,s=t)=>{const d={data:n,expirationTime:(new Date).getTime()+s};i(e,JSON.stringify(d))},getByTimestamp:(i,s=t)=>{const d=e(i);if(!d)return null;if(!s)return d;try{const{expirationTime:e,data:i}=JSON.parse(d);return(new Date).getTime()<=e?i:null}catch(e){return n("Error with parsing localStorage data"),null}}}})(),d={NO:"no",SE:"se"},r="advertory:ppids-cache",o={[d.SE]:`SCH${d.SE.toUpperCase()}-EnvHash`,[d.NO]:`SCH${d.NO.toUpperCase()}-EnvHash`},a={[d.SE]:`SCH${d.SE.toUpperCase()}-UserHash`,[d.NO]:`SCH${d.NO.toUpperCase()}-UserHash`},l={[d.SE]:`sch${d.SE}-envhash-v3`,[d.NO]:`sch${d.NO}-envhash-v3`},c={[d.SE]:`sch${d.SE}-userhash-v3`,[d.NO]:`sch${d.NO}-userhash-v3`},u={[d.SE]:`'sch${d.SE}-iosid-v3'`,[d.NO]:`'sch${d.NO}-iosid-v3'`},p={[d.SE]:`sch${d.SE}-androidid-v3`,[d.NO]:`sch${d.NO}-androidid-v3`},v={[d.SE]:"sdrn:schibsted.com:user",[d.NO]:"sdrn:spid.no:user"};class h{constructor(){this.eids=[]}add(e,i){return e&&this.eids.push({id:e,source:i}),this}buildRyEids(){return this.eids.map(({id:e,source:i})=>({source:i,uids:[{id:e,atype:1,ext:{stype:"ppuid"}}]}))}buildEids(){return[...this.eids]}buildVideoEids(){return this.eids.map(({id:e,source:i})=>`${i},${e}`).join("|")}buildNorstatPath(){const e=this.eids[0];return e?`${e.source}-${e.id}`:""}buildNorstatQuery(e){const i=new URLSearchParams;return this.eids.slice(1).forEach(({id:n,source:t})=>{i.append(e,`${t}-${n}`)}),i}}const f=e=>new Promise(i=>{if(!window._tcf_||!(null==e?void 0:e.enabled))return void i(!1);const t=(()=>{if(!window._tcf_)return null;const e=window._tcf_.getPermissionSync("CMP:advertising");if(null===e)return null;const i=Number(e);return n("Advertising permission value obtained synchronously: ",e),Boolean(i)})();if(null!==t)return void i(t);let s=!1;const d=e=>{s||(n("Resolving advertising permission value obtained"),s=!0,i(e))},r=setTimeout(()=>{n("Advertising permission timed out, resolving with false"),d(!1)},3e3);window._tcf_.onTcfReady(()=>{n("On Tcf Ready called, waiting for permission"),clearTimeout(r)}),window._tcf_.getPermission("CMP:advertising",e=>{clearTimeout(r);const i=Number(e);n("Advertising permission value obtained asynchronously: ",e),d(Boolean(i))})}),P="cmp:loaded";let g="undefined"!=typeof window?window._tcf_:void 0,I=!1;const y=(i,t,s)=>{const r=!!(null==i?void 0:i.enabled),o=(null==i?void 0:i.timeout)||3e3,a=(l="bypass_tcf",new URLSearchParams(window.location.search).get(l));var l;const c=()=>{if(!(null==i?void 0:i.enabled))return!0;if(((e,i)=>e?!!i&&(n("TCF bypass param detected, returning consent: true"),!0):(n("TCF is not enabled, returning consent: true"),!0))(r,a))return!0;if(I)return null;if(!g)throw new Error("[Advertory]: getConsentSync method was called before the tcfManager was available.");const e=g.getConsentedToAllSync();return n(`TCF consented to all is: ${e}`),g.getConsentedToAllSync()};return{initConsentManager:()=>(null==i?void 0:i.enabled)?new Promise((e,i)=>{if(n("Getting TCF consent manager..."),window._tcf_)return n("TCF consent manager is already available"),g=window._tcf_,void e(g);n("TCF consent manager is not available");const t=()=>{n("CMP loaded, resolving consent manager..."),s&&clearTimeout(s),window._tcf_?(g=window._tcf_,e(g)):i(new Error("CMP loaded but window._tcf_ is not defined"))},s=setTimeout(()=>{document.removeEventListener(P,t),I=!0,i(new Error("Timeout waiting for CMP to load"))},o);n("Listening for CMP loaded event..."),document.addEventListener(P,t,{once:!0})}):Promise.resolve(null),getConsentSync:c,getConsentAsync:()=>e(void 0,void 0,void 0,function*(){if(null==i?void 0:i.schibstedAdChoicesOverrideValue)return n(`Schibsted Ad Choices override value is set, returning override value: ${i.schibstedAdChoicesOverrideValue}`),Boolean(Number(i.schibstedAdChoicesOverrideValue));const e=(null==i?void 0:i.schibstedAdChoicesEnabled)&&s===d.SE,t=(null==i?void 0:i.schibstedAdChoicesEnabled)&&s===d.NO;if(e||t)return n("Schibsted Ad Choices is enabled, getting advertising permissions..."),yield f(i);if(!(null==i?void 0:i.enabled))return!0;const r=c();return null!==r?r:yield new Promise((e,i)=>{try{if(!g)throw new Error("[Advertory]: getConsentAsync method was called before the tcfManager was available.");let i=!1;const t=n=>{i||(i=!0,e(n))},s=setTimeout(()=>{n("TCF isConsentedToAll timed out, resolving with false"),t(!1)},o);g.onTcfReady(()=>{n("On Tcf Ready called, waiting for consent"),clearTimeout(s)}),g.isConsentedToAll(i=>{clearTimeout(s),e(i)})}catch(e){i(e)}})})}},w=new class{constructor(){this.ppid1=null,this.ppid2=null}processPPIDs(i){return e(this,arguments,void 0,function*(e,i=1e4){var n,t;const s=yield Promise.race([new Promise(e=>{setTimeout(()=>e({xandr:{ppId1:"",ppId2:""}}),i)}),e.instance.getAdvertisingIdentifiers()]);this.setPPIDs(null===(n=s.xandr)||void 0===n?void 0:n.ppId1,null===(t=s.xandr)||void 0===t?void 0:t.ppId2)})}getPPIDs(){var e,i;return null!==this.ppid1&&null!==this.ppid2||n("PPIDv2s accessed before they have been initialized"),{ppid1:null!==(e=this.ppid1)&&void 0!==e?e:"",ppid2:null!==(i=this.ppid2)&&void 0!==i?i:""}}setPPIDs(e,i){this.ppid1=null!=e?e:"",this.ppid2=null!=i?i:""}},m=new class{constructor(){this.ppid1=null,this.ppid2=null,this.idfv=null,this.anId=null}processPPIDs(i,n){return e(this,void 0,void 0,function*(){var e,t,d,o,a,l,c,u,p,v,h;const f=s.get(r),P=yield this.getNewPPIDs(i,n);if(this.shouldHash(f,P)){const n=null!==(e=i.hasherUrl)&&void 0!==e?e:"https://hasher.schibsted.com/api/v1/hash",s=this.createHasherPayload(P),r=yield this.hashPPIDs(s,n);return r?(this.cachePPIDs(s,r,null===(t=P.idfv)||void 0===t?void 0:t.plain,null===(d=P.anId)||void 0===d?void 0:d.plain),void this.setPPIDs(null!==(o=r.userId)&&void 0!==o?o:"",null!==(a=r.environmentId)&&void 0!==a?a:"",null===(l=P.idfv)||void 0===l?void 0:l.plain,null===(c=P.anId)||void 0===c?void 0:c.plain)):void this.setPPIDs("","")}this.setPPIDs(null!==(u=null==f?void 0:f.userId.hashed)&&void 0!==u?u:"",null!==(p=null==f?void 0:f.environmentId.hashed)&&void 0!==p?p:"",null===(v=null==P?void 0:P.idfv)||void 0===v?void 0:v.plain,null===(h=null==P?void 0:P.anId)||void 0===h?void 0:h.plain)})}getPPIDs(){var e,i;return null!==this.ppid1&&null!==this.ppid2||n("PPIDv3s accessed before they have been initialized"),{ppid1:null!==(e=this.ppid1)&&void 0!==e?e:"",ppid2:null!==(i=this.ppid2)&&void 0!==i?i:"",idfv:this.idfv,anId:this.anId}}setPPIDs(e,i,n,t){this.ppid1=null!=e?e:"",this.ppid2=null!=i?i:"",this.idfv=null!=n?n:null,this.anId=null!=t?t:null}shouldHash(e,i){var n,t;if(!e)return!0;for(const s in e){if((null===(n=e[s])||void 0===n?void 0:n.plain)!==(null===(t=i[s])||void 0===t?void 0:t.plain))return!0}return!1}cachePPIDs(e,i,n,t){const d=Object.assign(Object.assign({clientId:{plain:e.clientId},userId:{plain:e.userId,hashed:i.userId},environmentId:{plain:e.environmentId,hashed:i.environmentId},trackerType:{plain:e.trackerType},trackerVersion:{plain:e.trackerVersion}},n?{idfv:{plain:n}}:{}),t?{anId:{plain:t}}:{});s.set(r,d)}hashPPIDs(t,s){return e(this,void 0,void 0,function*(){try{const e=new Headers({"Content-Type":"application/json"});return yield i.post(s,e,t)}catch(e){return n("Error with hashing PPIDs",e),null}})}getNewPPIDs(i,n){return e(this,arguments,void 0,function*({clientId:i,instance:n},t){const s=yield((i,n)=>e(void 0,void 0,void 0,function*(){const e=yield i.getUserId();return e?`${v[n]}:${e}`:null}))(n,t),d=yield(i=>e(void 0,void 0,void 0,function*(){const e=yield i.getEnvironmentId();return e?`sdrn:schibsted:environment:${e}`:null}))(n),r=window.advertory_idfv,o=window.advertory_anId;return Object.assign(Object.assign({clientId:{plain:i},userId:{plain:s},environmentId:{plain:d},trackerType:{plain:"Advertory"},trackerVersion:{plain:"1.0.0"}},r?{idfv:{plain:r}}:{}),o?{anId:{plain:o}}:{})})}createHasherPayload({clientId:e,trackerType:i,trackerVersion:n,userId:t,environmentId:s}){return{clientId:e.plain,trackerType:i.plain,trackerVersion:n.plain,userId:t.plain,environmentId:s.plain}}};exports.getFinnBlinkUserId=()=>e(void 0,void 0,void 0,function*(){const{ppid2:e}=m.getPPIDs();return e}),exports.getOpenRtbEids=e=>{const{ppid1:i,ppid2:n}=w.getPPIDs(),{ppid1:t,ppid2:s}=m.getPPIDs();return(new h).add(n,o[e]).add(i,a[e]).add(s,l[e]).add(t,c[e]).buildRyEids()},exports.getPPIDLoggedInStatus=()=>{const{ppid1:e,ppid2:i}=w.getPPIDs();return{"aa-sch-schuserhash":e?"1":"0","aa-sch-schenvhash":i?"1":"0"}},exports.getPPIDNorstatString=e=>{const{ppid1:i,ppid2:n}=w.getPPIDs(),{ppid1:t,ppid2:s}=m.getPPIDs(),d=(new h).add(n,o[e]).add(i,a[e]).add(s,l[e]).add(t,c[e]);return`${d.buildNorstatPath()}?${d.buildNorstatQuery("alias").toString()}`},exports.getPPIDRelevantYieldConfig=e=>{const{ppid1:i,ppid2:n}=w.getPPIDs(),{ppid1:t,ppid2:s,idfv:d,anId:r}=m.getPPIDs();if(!n)return{};return{userSync:{userIds:[{name:"pubProvidedId",params:{eids:(new h).add(n,o[e]).add(i,a[e]).add(s,l[e]).add(t,c[e]).add(d,u[e]).add(r,p[e]).buildRyEids()}}]}}},exports.getUserIdsObject=e=>{const{ppid1:i,ppid2:n}=w.getPPIDs(),{ppid1:t,ppid2:s,idfv:d,anId:r}=m.getPPIDs();return{userIds:[{type:"extendedIDs",eids:(new h).add(n,o[e]).add(i,a[e]).add(s,l[e]).add(t,c[e]).add(d,u[e]).add(r,p[e]).buildEids()}]}},exports.getVideoPPIDs=i=>e(void 0,void 0,void 0,function*(){const{ppid1:e,ppid2:n}=w.getPPIDs(),{ppid1:t,ppid2:s}=m.getPPIDs(),d=(new h).add(n,o[i]).add(e,a[i]).add(s,l[i]).add(t,c[i]);return yield new Promise(e=>{e(d.buildVideoEids())})}),exports.setXandrPPIDs=i=>e(void 0,void 0,void 0,function*(){const{tracker:t,tcf:s,country:d,isMobileApp:r}=i,o=yield((i,t,s,...d)=>e(void 0,[i,t,s,...d],void 0,function*(e,i,t,s="NOT SPECIFIED FEATURE"){if(!(null==e?void 0:e.schibstedConsentToPayEnabled))return n(`Schibsted Consent to Pay is not enabled, returning true for ${s}`),!0;if(null==e?void 0:e.schibstedAdChoicesOverrideValue)return n(`Schibsted Ad Choices override value is set, returning override value: ${null==e?void 0:e.schibstedAdChoicesOverrideValue} for ${s}`),Boolean(Number(null==e?void 0:e.schibstedAdChoicesOverrideValue));const{getConsentAsync:d}=y(e,0,t);return(yield d())?(n(`Schibsted Ad Choices consent given according to TCF consent manager for ${s}`),!0):(n(`Schibsted Ad Choices consent not given according to TCF consent manager for ${s}`),!1)}))(s,r,d,"setXandrPPIDs");if(!o)return;if(!t)return;(yield Promise.allSettled([w.processPPIDs(t,null==s?void 0:s.timeout),m.processPPIDs(t,d)])).forEach((e,i)=>{if("rejected"===e.status){n(`Cannot fetch PPIDs v${i+2}`,e.reason)}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schibsted/advertory",
3
- "version": "2.71.18",
3
+ "version": "2.72.1",
4
4
  "scripts": {
5
5
  "build": "node node_modules/rollup/dist/bin/rollup -c rollup-config/default.mjs && npm run post:build",
6
6
  "build:dev": "MODE=dev NODE_OPTIONS=--max-old-space-size=131072 npm run build",