@schibsted/advertory 2.63.15-server-side-rendering → 2.63.16

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 (109) hide show
  1. package/core/aftenposten/es/index.css +1 -1
  2. package/core/aftenposten/es/index.d.ts +0 -2
  3. package/core/aftenposten/es/index.js +1 -1
  4. package/core/aftenposten/index.d.ts +0 -2
  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 +0 -2
  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 +0 -2
  11. package/core/aftonbladet/es/index.js +1 -1
  12. package/core/aftonbladet/index.d.ts +0 -2
  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 +0 -2
  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 +0 -2
  19. package/core/bt/es/index.js +1 -1
  20. package/core/bt/index.d.ts +0 -2
  21. package/core/bt/index.js +1 -1
  22. package/core/e24/es/index.css +1 -1
  23. package/core/e24/es/index.d.ts +0 -2
  24. package/core/e24/es/index.js +1 -1
  25. package/core/e24/index.d.ts +0 -2
  26. package/core/e24/index.js +1 -1
  27. package/core/fotbollskanalen/es/index.css +1 -1
  28. package/core/fotbollskanalen/es/index.d.ts +0 -2
  29. package/core/fotbollskanalen/es/index.js +1 -1
  30. package/core/fotbollskanalen/index.d.ts +0 -2
  31. package/core/fotbollskanalen/index.js +1 -1
  32. package/core/godare/index.d.ts +0 -2
  33. package/core/godare/index.js +1 -1
  34. package/core/godt/index.d.ts +0 -2
  35. package/core/godt/index.js +1 -1
  36. package/core/klart/index.d.ts +0 -2
  37. package/core/klart/index.js +1 -1
  38. package/core/koket/es/index.css +1 -1
  39. package/core/koket/es/index.d.ts +0 -2
  40. package/core/koket/es/index.js +1 -1
  41. package/core/koket/index.d.ts +0 -2
  42. package/core/koket/index.js +1 -1
  43. package/core/kompakt/index.d.ts +0 -2
  44. package/core/kompakt/index.js +1 -1
  45. package/core/minmote/index.d.ts +0 -2
  46. package/core/minmote/index.js +1 -1
  47. package/core/pent/index.d.ts +0 -2
  48. package/core/pent/index.js +1 -1
  49. package/core/sa/es/index.css +1 -1
  50. package/core/sa/es/index.d.ts +0 -2
  51. package/core/sa/es/index.js +1 -1
  52. package/core/sa/index.d.ts +0 -2
  53. package/core/sa/index.js +1 -1
  54. package/core/svd/es/index.css +1 -1
  55. package/core/svd/es/index.d.ts +0 -2
  56. package/core/svd/es/index.js +1 -1
  57. package/core/svd/index.d.ts +0 -2
  58. package/core/svd/index.js +1 -1
  59. package/core/svdv2/es/index.css +1 -1
  60. package/core/svdv2/es/index.d.ts +0 -2
  61. package/core/svdv2/es/index.js +1 -1
  62. package/core/tek/index.d.ts +0 -2
  63. package/core/tek/index.js +1 -1
  64. package/core/tv4/es/index.css +1 -1
  65. package/core/tv4/es/index.d.ts +0 -2
  66. package/core/tv4/es/index.js +1 -1
  67. package/core/tv4/index.d.ts +0 -2
  68. package/core/tv4/index.js +1 -1
  69. package/core/tvnu/index.d.ts +0 -2
  70. package/core/tvnu/index.js +1 -1
  71. package/core/vg/es/index.css +1 -1
  72. package/core/vg/es/index.d.ts +0 -2
  73. package/core/vg/es/index.js +1 -1
  74. package/core/vg/index.d.ts +0 -2
  75. package/core/vg/index.js +1 -1
  76. package/core/vgv2/es/index.css +1 -1
  77. package/core/vgv2/es/index.d.ts +0 -2
  78. package/core/vgv2/es/index.js +1 -1
  79. package/features/ad-native/index.d.ts +0 -2
  80. package/features/dr-edition/es/index.d.ts +0 -2
  81. package/features/dr-edition/index.d.ts +0 -2
  82. package/features/tracker/index.d.ts +1 -4
  83. package/features/tracker/index.js +1 -1
  84. package/package.json +1 -1
  85. package/sites/aftenposten/es/index.css +1 -1
  86. package/sites/aftenpostenv2/es/index.css +1 -1
  87. package/sites/aftonbladet/es/index.css +1 -1
  88. package/sites/aftonbladetv2/es/index.css +1 -1
  89. package/sites/bt/es/index.css +1 -1
  90. package/sites/e24/es/index.css +1 -1
  91. package/sites/sa/es/index.css +1 -1
  92. package/sites/svd/es/index.css +1 -1
  93. package/sites/svdv2/es/index.css +1 -1
  94. package/sites/tv4/es/index.css +1 -1
  95. package/sites/vg/es/index.css +1 -1
  96. package/sites/vgv2/es/index.css +1 -1
  97. package/types/core/interface/config.d.ts +0 -2
  98. package/types/features/tracker/index.d.ts +2 -3
  99. package/types/features/ad-server-side/banner-object.d.ts +0 -4
  100. package/types/features/ad-server-side/banner-object.test.d.ts +0 -1
  101. package/types/features/ad-server-side/constants.d.ts +0 -2
  102. package/types/features/ad-server-side/index.d.ts +0 -4
  103. package/types/features/ad-server-side/keywords.d.ts +0 -3
  104. package/types/features/ad-server-side/keywords.test.d.ts +0 -1
  105. package/types/features/ad-server-side/native-request.d.ts +0 -42
  106. package/types/features/ad-server-side/native-request.test.d.ts +0 -1
  107. package/types/features/ad-server-side/server-side-xandr-renderer.d.ts +0 -3
  108. package/types/features/ad-server-side/server-side-xandr-service.d.ts +0 -7
  109. package/types/features/interface/ad-server-side.d.ts +0 -54
@@ -281,8 +281,6 @@ interface Placement {
281
281
  drEdition?: DrEditionPlacementConfig;
282
282
  isBackfill?: boolean;
283
283
  takeoverCookieCapForSharedPlacement?: boolean;
284
- serverSidePlacement?: boolean;
285
- xandrPlacementId?: number;
286
284
  }
287
285
  interface Placements {
288
286
  desktop: Array<Placement>;
@@ -284,8 +284,6 @@ interface Placement {
284
284
  drEdition?: DrEditionPlacementConfig;
285
285
  isBackfill?: boolean;
286
286
  takeoverCookieCapForSharedPlacement?: boolean;
287
- serverSidePlacement?: boolean;
288
- xandrPlacementId?: number;
289
287
  }
290
288
  interface Placements {
291
289
  desktop: Array<Placement>;
@@ -284,8 +284,6 @@ interface Placement {
284
284
  drEdition?: DrEditionPlacementConfig;
285
285
  isBackfill?: boolean;
286
286
  takeoverCookieCapForSharedPlacement?: boolean;
287
- serverSidePlacement?: boolean;
288
- xandrPlacementId?: number;
289
287
  }
290
288
  interface Placements {
291
289
  desktop: Array<Placement>;
@@ -229,8 +229,6 @@ interface Placement {
229
229
  drEdition?: DrEditionPlacementConfig;
230
230
  isBackfill?: boolean;
231
231
  takeoverCookieCapForSharedPlacement?: boolean;
232
- serverSidePlacement?: boolean;
233
- xandrPlacementId?: number;
234
232
  }
235
233
  interface Placements {
236
234
  desktop: Array<Placement>;
@@ -441,7 +439,6 @@ declare const getUserIdsObject: (country: Country) => UserIdsObject;
441
439
  declare const getPPIDLoggedInStatus: () => PPIDLoggedInStatusKeywords;
442
440
  declare const getPPIDRelevantYieldConfig: (country: Country) => RelevantYieldPPIDConfig | object;
443
441
  declare const getPPIDNorstatString: (country: Country) => string;
444
- declare const getOpenRtbEids: (country: Country) => Array<RelevantYieldEids>;
445
442
  declare const getVideoPPIDs: (country: Country) => Promise<string>;
446
443
 
447
- export { getOpenRtbEids, getPPIDLoggedInStatus, getPPIDNorstatString, getPPIDRelevantYieldConfig, getUserIdsObject, getVideoPPIDs, setXandrPPIDs };
444
+ export { 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 P=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))})}),f="cmp:loaded";let g,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(f,t),I=!0,i(new Error("Timeout waiting for CMP to load"))},o);n("Listening for CMP loaded event..."),document.addEventListener(f,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,r=(null==i?void 0:i.schibstedAdChoicesEnabled)&&!t&&s===d.NO;if(e||r)return n("Schibsted Ad Choices is enabled, getting advertising permissions..."),yield P(i);if(!(null==i?void 0:i.enabled))return!0;const a=c();return null!==a?a: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 P=s.get(r),f=yield this.getNewPPIDs(i,n);if(this.shouldHash(P,f)){const n=null!==(e=i.hasherUrl)&&void 0!==e?e:"https://hasher.schibsted.com/api/v1/hash",s=this.createHasherPayload(f),r=yield this.hashPPIDs(s,n);return r?(this.cachePPIDs(s,r,null===(t=f.idfv)||void 0===t?void 0:t.plain,null===(d=f.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=f.idfv)||void 0===l?void 0:l.plain,null===(c=f.anId)||void 0===c?void 0:c.plain)):void this.setPPIDs("","")}this.setPPIDs(null!==(u=null==P?void 0:P.userId.hashed)&&void 0!==u?u:"",null!==(p=null==P?void 0:P.environmentId.hashed)&&void 0!==p?p:"",null===(v=null==f?void 0:f.idfv)||void 0===v?void 0:v.plain,null===(h=null==f?void 0:f.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.getOpenRtbEids=e=>{const{ppid1:i,ppid2:n}=m.getPPIDs(),{ppid1:t,ppid2:s}=w.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}=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,i,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,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,r=(null==i?void 0:i.schibstedAdChoicesEnabled)&&!t&&s===d.NO;if(e||r)return n("Schibsted Ad Choices is enabled, getting advertising permissions..."),yield f(i);if(!(null==i?void 0:i.enabled))return!0;const a=c();return null!==a?a: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.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,i,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)}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schibsted/advertory",
3
- "version": "2.63.15-server-side-rendering",
3
+ "version": "2.63.16",
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",