@optable/web-sdk 0.20.0 → 0.21.0

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.
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see sdk.js.LICENSE.txt */
2
- (()=>{var __webpack_modules__={396:t=>{t.exports=function(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}},312:(module,exports,__webpack_require__)=>{var __WEBPACK_AMD_DEFINE_RESULT__;(function(){"use strict";var ERROR="input is invalid type",WINDOW="object"==typeof window,root=WINDOW?window:{};root.JS_SHA256_NO_WINDOW&&(WINDOW=!1);var WEB_WORKER=!WINDOW&&"object"==typeof self,NODE_JS=!root.JS_SHA256_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;NODE_JS?root=__webpack_require__.g:WEB_WORKER&&(root=self);var COMMON_JS=!root.JS_SHA256_NO_COMMON_JS&&module.exports,AMD=__webpack_require__.amdO,ARRAY_BUFFER=!root.JS_SHA256_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,HEX_CHARS="0123456789abcdef".split(""),EXTRA=[-2147483648,8388608,32768,128],SHIFT=[24,16,8,0],K=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],OUTPUT_TYPES=["hex","array","digest","arrayBuffer"],blocks=[];!root.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),!ARRAY_BUFFER||!root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});var createOutputMethod=function(t,e){return function(i){return new Sha256(e,!0).update(i)[t]()}},createMethod=function(t){var e=createOutputMethod("hex",t);NODE_JS&&(e=nodeWrap(e,t)),e.create=function(){return new Sha256(t)},e.update=function(t){return e.create().update(t)};for(var i=0;i<OUTPUT_TYPES.length;++i){var r=OUTPUT_TYPES[i];e[r]=createOutputMethod(r,t)}return e},nodeWrap=function(method,is224){var crypto=eval("require('crypto')"),Buffer=eval("require('buffer').Buffer"),algorithm=is224?"sha224":"sha256",nodeMethod=function(t){if("string"==typeof t)return crypto.createHash(algorithm).update(t,"utf8").digest("hex");if(null==t)throw new Error(ERROR);return t.constructor===ArrayBuffer&&(t=new Uint8Array(t)),Array.isArray(t)||ArrayBuffer.isView(t)||t.constructor===Buffer?crypto.createHash(algorithm).update(new Buffer(t)).digest("hex"):method(t)};return nodeMethod},createHmacOutputMethod=function(t,e){return function(i,r){return new HmacSha256(i,e,!0).update(r)[t]()}},createHmacMethod=function(t){var e=createHmacOutputMethod("hex",t);e.create=function(e){return new HmacSha256(e,t)},e.update=function(t,i){return e.create(t).update(i)};for(var i=0;i<OUTPUT_TYPES.length;++i){var r=OUTPUT_TYPES[i];e[r]=createHmacOutputMethod(r,t)}return e};function Sha256(t,e){e?(blocks[0]=blocks[16]=blocks[1]=blocks[2]=blocks[3]=blocks[4]=blocks[5]=blocks[6]=blocks[7]=blocks[8]=blocks[9]=blocks[10]=blocks[11]=blocks[12]=blocks[13]=blocks[14]=blocks[15]=0,this.blocks=blocks):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=t}function HmacSha256(t,e,i){var r,o=typeof t;if("string"===o){var n,s=[],a=t.length,h=0;for(r=0;r<a;++r)(n=t.charCodeAt(r))<128?s[h++]=n:n<2048?(s[h++]=192|n>>6,s[h++]=128|63&n):n<55296||n>=57344?(s[h++]=224|n>>12,s[h++]=128|n>>6&63,s[h++]=128|63&n):(n=65536+((1023&n)<<10|1023&t.charCodeAt(++r)),s[h++]=240|n>>18,s[h++]=128|n>>12&63,s[h++]=128|n>>6&63,s[h++]=128|63&n);t=s}else{if("object"!==o)throw new Error(ERROR);if(null===t)throw new Error(ERROR);if(ARRAY_BUFFER&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||ARRAY_BUFFER&&ArrayBuffer.isView(t)))throw new Error(ERROR)}t.length>64&&(t=new Sha256(e,!0).update(t).array());var c=[],d=[];for(r=0;r<64;++r){var u=t[r]||0;c[r]=92^u,d[r]=54^u}Sha256.call(this,e,i),this.update(d),this.oKeyPad=c,this.inner=!0,this.sharedMemory=i}Sha256.prototype.update=function(t){if(!this.finalized){var e,i=typeof t;if("string"!==i){if("object"!==i)throw new Error(ERROR);if(null===t)throw new Error(ERROR);if(ARRAY_BUFFER&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||ARRAY_BUFFER&&ArrayBuffer.isView(t)))throw new Error(ERROR);e=!0}for(var r,o,n=0,s=t.length,a=this.blocks;n<s;){if(this.hashed&&(this.hashed=!1,a[0]=this.block,a[16]=a[1]=a[2]=a[3]=a[4]=a[5]=a[6]=a[7]=a[8]=a[9]=a[10]=a[11]=a[12]=a[13]=a[14]=a[15]=0),e)for(o=this.start;n<s&&o<64;++n)a[o>>2]|=t[n]<<SHIFT[3&o++];else for(o=this.start;n<s&&o<64;++n)(r=t.charCodeAt(n))<128?a[o>>2]|=r<<SHIFT[3&o++]:r<2048?(a[o>>2]|=(192|r>>6)<<SHIFT[3&o++],a[o>>2]|=(128|63&r)<<SHIFT[3&o++]):r<55296||r>=57344?(a[o>>2]|=(224|r>>12)<<SHIFT[3&o++],a[o>>2]|=(128|r>>6&63)<<SHIFT[3&o++],a[o>>2]|=(128|63&r)<<SHIFT[3&o++]):(r=65536+((1023&r)<<10|1023&t.charCodeAt(++n)),a[o>>2]|=(240|r>>18)<<SHIFT[3&o++],a[o>>2]|=(128|r>>12&63)<<SHIFT[3&o++],a[o>>2]|=(128|r>>6&63)<<SHIFT[3&o++],a[o>>2]|=(128|63&r)<<SHIFT[3&o++]);this.lastByteIndex=o,this.bytes+=o-this.start,o>=64?(this.block=a[16],this.start=o-64,this.hash(),this.hashed=!0):this.start=o}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}},Sha256.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex;t[16]=this.block,t[e>>2]|=EXTRA[3&e],this.block=t[16],e>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}},Sha256.prototype.hash=function(){var t,e,i,r,o,n,s,a,h,c=this.h0,d=this.h1,u=this.h2,p=this.h3,l=this.h4,_=this.h5,f=this.h6,g=this.h7,w=this.blocks;for(t=16;t<64;++t)e=((o=w[t-15])>>>7|o<<25)^(o>>>18|o<<14)^o>>>3,i=((o=w[t-2])>>>17|o<<15)^(o>>>19|o<<13)^o>>>10,w[t]=w[t-16]+e+w[t-7]+i|0;for(h=d&u,t=0;t<64;t+=4)this.first?(this.is224?(n=300032,g=(o=w[0]-1413257819)-150054599|0,p=o+24177077|0):(n=704751109,g=(o=w[0]-210244248)-1521486534|0,p=o+143694565|0),this.first=!1):(e=(c>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),r=(n=c&d)^c&u^h,g=p+(o=g+(i=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7))+(l&_^~l&f)+K[t]+w[t])|0,p=o+(e+r)|0),e=(p>>>2|p<<30)^(p>>>13|p<<19)^(p>>>22|p<<10),r=(s=p&c)^p&d^n,f=u+(o=f+(i=(g>>>6|g<<26)^(g>>>11|g<<21)^(g>>>25|g<<7))+(g&l^~g&_)+K[t+1]+w[t+1])|0,e=((u=o+(e+r)|0)>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),r=(a=u&p)^u&c^s,_=d+(o=_+(i=(f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7))+(f&g^~f&l)+K[t+2]+w[t+2])|0,e=((d=o+(e+r)|0)>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),r=(h=d&u)^d&p^a,l=c+(o=l+(i=(_>>>6|_<<26)^(_>>>11|_<<21)^(_>>>25|_<<7))+(_&f^~_&g)+K[t+3]+w[t+3])|0,c=o+(e+r)|0;this.h0=this.h0+c|0,this.h1=this.h1+d|0,this.h2=this.h2+u|0,this.h3=this.h3+p|0,this.h4=this.h4+l|0,this.h5=this.h5+_|0,this.h6=this.h6+f|0,this.h7=this.h7+g|0},Sha256.prototype.hex=function(){this.finalize();var t=this.h0,e=this.h1,i=this.h2,r=this.h3,o=this.h4,n=this.h5,s=this.h6,a=this.h7,h=HEX_CHARS[t>>28&15]+HEX_CHARS[t>>24&15]+HEX_CHARS[t>>20&15]+HEX_CHARS[t>>16&15]+HEX_CHARS[t>>12&15]+HEX_CHARS[t>>8&15]+HEX_CHARS[t>>4&15]+HEX_CHARS[15&t]+HEX_CHARS[e>>28&15]+HEX_CHARS[e>>24&15]+HEX_CHARS[e>>20&15]+HEX_CHARS[e>>16&15]+HEX_CHARS[e>>12&15]+HEX_CHARS[e>>8&15]+HEX_CHARS[e>>4&15]+HEX_CHARS[15&e]+HEX_CHARS[i>>28&15]+HEX_CHARS[i>>24&15]+HEX_CHARS[i>>20&15]+HEX_CHARS[i>>16&15]+HEX_CHARS[i>>12&15]+HEX_CHARS[i>>8&15]+HEX_CHARS[i>>4&15]+HEX_CHARS[15&i]+HEX_CHARS[r>>28&15]+HEX_CHARS[r>>24&15]+HEX_CHARS[r>>20&15]+HEX_CHARS[r>>16&15]+HEX_CHARS[r>>12&15]+HEX_CHARS[r>>8&15]+HEX_CHARS[r>>4&15]+HEX_CHARS[15&r]+HEX_CHARS[o>>28&15]+HEX_CHARS[o>>24&15]+HEX_CHARS[o>>20&15]+HEX_CHARS[o>>16&15]+HEX_CHARS[o>>12&15]+HEX_CHARS[o>>8&15]+HEX_CHARS[o>>4&15]+HEX_CHARS[15&o]+HEX_CHARS[n>>28&15]+HEX_CHARS[n>>24&15]+HEX_CHARS[n>>20&15]+HEX_CHARS[n>>16&15]+HEX_CHARS[n>>12&15]+HEX_CHARS[n>>8&15]+HEX_CHARS[n>>4&15]+HEX_CHARS[15&n]+HEX_CHARS[s>>28&15]+HEX_CHARS[s>>24&15]+HEX_CHARS[s>>20&15]+HEX_CHARS[s>>16&15]+HEX_CHARS[s>>12&15]+HEX_CHARS[s>>8&15]+HEX_CHARS[s>>4&15]+HEX_CHARS[15&s];return this.is224||(h+=HEX_CHARS[a>>28&15]+HEX_CHARS[a>>24&15]+HEX_CHARS[a>>20&15]+HEX_CHARS[a>>16&15]+HEX_CHARS[a>>12&15]+HEX_CHARS[a>>8&15]+HEX_CHARS[a>>4&15]+HEX_CHARS[15&a]),h},Sha256.prototype.toString=Sha256.prototype.hex,Sha256.prototype.digest=function(){this.finalize();var t=this.h0,e=this.h1,i=this.h2,r=this.h3,o=this.h4,n=this.h5,s=this.h6,a=this.h7,h=[t>>24&255,t>>16&255,t>>8&255,255&t,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24&255,i>>16&255,i>>8&255,255&i,r>>24&255,r>>16&255,r>>8&255,255&r,o>>24&255,o>>16&255,o>>8&255,255&o,n>>24&255,n>>16&255,n>>8&255,255&n,s>>24&255,s>>16&255,s>>8&255,255&s];return this.is224||h.push(a>>24&255,a>>16&255,a>>8&255,255&a),h},Sha256.prototype.array=Sha256.prototype.digest,Sha256.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(this.is224?28:32),e=new DataView(t);return e.setUint32(0,this.h0),e.setUint32(4,this.h1),e.setUint32(8,this.h2),e.setUint32(12,this.h3),e.setUint32(16,this.h4),e.setUint32(20,this.h5),e.setUint32(24,this.h6),this.is224||e.setUint32(28,this.h7),t},HmacSha256.prototype=new Sha256,HmacSha256.prototype.finalize=function(){if(Sha256.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();Sha256.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(t),Sha256.prototype.finalize.call(this)}};var exports=createMethod();exports.sha256=exports,exports.sha224=createMethod(!0),exports.sha256.hmac=createHmacMethod(),exports.sha224.hmac=createHmacMethod(!0),COMMON_JS?module.exports=exports:(root.sha256=exports.sha256,root.sha224=exports.sha224,AMD&&(__WEBPACK_AMD_DEFINE_RESULT__=function(){return exports}.call(exports,__webpack_require__,exports,module),void 0===__WEBPACK_AMD_DEFINE_RESULT__||(module.exports=__WEBPACK_AMD_DEFINE_RESULT__)))})()}},__webpack_module_cache__={};function __webpack_require__(t){var e=__webpack_module_cache__[t];if(void 0!==e)return e.exports;var i=__webpack_module_cache__[t]={exports:{}};return __webpack_modules__[t](i,i.exports,__webpack_require__),i.exports}__webpack_require__.amdO={},__webpack_require__.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return __webpack_require__.d(e,{a:e}),e},__webpack_require__.d=(t,e)=>{for(var i in e)__webpack_require__.o(e,i)&&!__webpack_require__.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),__webpack_require__.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var __webpack_exports__={};(()=>{"use strict";var t=__webpack_require__(396),e=__webpack_require__.n(t);const i={r:"v0.20.0"},r={insecure:!1,cookies:!0,initPassport:!0,identityHeaderName:"X-Optable-Visitor"};async function o(t){const e=await d("/config",t,{method:"GET",headers:{Accept:"application/json"}});return new c(t).setSite(e),e}var n;!function(t){t[t.DeviceID=1]="DeviceID",t[t.InAppImpression=2]="InAppImpression",t[t.PersonID=3]="PersonID"}(n||(n={}));const s="loblawmedia.ca";function a(t){return{user:{data:(t?.audience??[]).map((t=>({name:t.provider,segment:t.ids,ext:{segtax:t.rtb_segtax}}))),ext:{eids:(t?.user??[]).map((t=>({source:t.provider,uids:t.ids.map((t=>{let{id:e}=t;return{id:e,atype:n.PersonID}}))})))}}}}function h(t){const e={};if(!t)return e;for(const i of t.audience??[])i.keyspace&&(i.keyspace in e||(e[i.keyspace]=[]),e[i.keyspace].push(...i.ids.map((t=>t.id))));return e}class c{constructor(t){this.Config=t,e()(this,"passportKey",void 0),e()(this,"targetingV1Key",void 0),e()(this,"targetingKey",void 0),e()(this,"lmpidKey",void 0),e()(this,"siteKey",void 0);const i=btoa(function(t){const e=new Uint16Array(t.length);for(let i=0;i<e.length;i++)e[i]=t.charCodeAt(i);return String.fromCharCode(...new Uint8Array(e.buffer))}(`${this.Config.host}/${this.Config.site}`));this.targetingV1Key="OPTABLE_TGT_"+i,this.passportKey="OPTABLE_PASS_"+i,this.targetingKey="OPTABLE_V2_TGT_"+i,this.lmpidKey="__lmpid",this.siteKey="OPTABLE_SITE_"+i}getPassport(){return window.localStorage.getItem(this.passportKey)}getV1Targeting(){const t=window.localStorage.getItem(this.targetingV1Key),e=t?JSON.parse(t):null;return e?{user:[],audience:Object.entries(e).map((t=>{let[e,i]=t;return{provider:"optable.co",keyspace:e,rtb_segtax:5001,ids:[].concat(i).map((t=>({id:String(t)})))}}))}:null}getTargeting(){const t=window.localStorage.getItem(this.targetingKey);return(t?JSON.parse(t):null)||this.getV1Targeting()}setPassport(t){t&&t.length>0&&window.localStorage.setItem(this.passportKey,t)}setTargeting(t){t&&(window.localStorage.setItem(this.targetingKey,JSON.stringify(t)),this.setLmpid(t))}setSite(t){t&&window.localStorage.setItem(this.siteKey,JSON.stringify(t))}getSite(){const t=window.localStorage.getItem(this.siteKey);return t?JSON.parse(t):null}setLmpid(t){const e=t.user?.find((t=>t.provider===s));if(!e)return;const i=e.ids?.[0]?.id??"";window.localStorage.setItem(this.lmpidKey,i),window.__lmpid=i}getLmpid(){return window.__lmpid||window.localStorage.getItem(this.lmpidKey)||null}clearPassport(){window.localStorage.removeItem(this.passportKey)}clearTargeting(){window.localStorage.removeItem(this.targetingKey)}clearSite(){window.localStorage.removeItem(this.siteKey)}}async function d(t,e,r){const o=await globalThis.fetch(function(t,e,r){const{site:o,host:n,insecure:s,cookies:a}=e,h=new URL(`${o}${t}`,`${s?"http":"https"}://${n}`);h.searchParams.set("osdk",`web-${i.r}`);const d={...r};if(a)d.credentials="include",h.searchParams.set("cookies","yes");else{const t=new c(e).getPassport();h.searchParams.set("cookies","no"),d.headers=new Headers,t&&d.headers.set(e.identityHeaderName,t)}return new Request(h.toString(),d)}(t,e,r)),n=o.headers.get("Content-Type"),s=n?.startsWith("application/json")?await o.json():await o.text();if(!o.ok)throw new Error(s.error);return o.headers.has(e.identityHeaderName)&&new c(e).setPassport(o.headers.get(e.identityHeaderName)||""),s}var u=__webpack_require__(312);class p{constructor(t){var i;e()(this,"dcn",void 0),e()(this,"init",void 0),this.dcn=(i=t,{...r,...i});const n=()=>{};this.init=this.dcn.initPassport?o(this.dcn).then(n).catch(n):Promise.resolve()}async identify(){await this.init;for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return function(t,e){return d("/identify",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}(this.dcn,e.filter((t=>t)))}async uid2Token(t){return await this.init,function(t,e){return d("/uid2/token",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}(this.dcn,t)}async targeting(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"__passport__";return await this.init,async function(t,e){const i="/v2/targeting?"+new URLSearchParams({id:e}).toString(),r=await d(i,t,{method:"GET",headers:{Accept:"application/json"}});return r&&new c(t).setTargeting(r),r}(this.dcn,t)}targetingFromCache(){return t=this.dcn,new c(t).getTargeting();var t}async site(){return o(this.dcn)}siteFromCache(){return t=this.dcn,new c(t).getSite();var t}targetingClearCache(){var t;t=this.dcn,new c(t).clearTargeting()}lmpidFromCache(){return t=this.dcn,new c(t).getLmpid();var t}async prebidORTB2(){return a(await this.targeting())}prebidORTB2FromCache(){return a(this.targetingFromCache())}async targetingKeyValues(){return h(await this.targeting())}targetingKeyValuesFromCache(){return h(this.targetingFromCache())}async witness(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return await this.init,function(t,e,i){const r={event:e,properties:i};return d("/witness",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}(this.dcn,t,e)}async profile(t){return await this.init,function(t,e){const i={traits:e};return d("/profile",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}(this.dcn,t)}async tokenize(t){return await this.init,function(t,e){let i={id:e};return d("/v1/tokenize",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}(this.dcn,t)}static eid(t){return t?"e:"+u.sha256.hex(t.toLowerCase().trim()):""}static cid(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i="c:";if("string"!=typeof t)throw new Error("Invalid ppid");if("number"!=typeof e||isNaN(e)||e<0||e>9)throw new Error("Invalid variant");return e>0&&(i=`c${e}:`),t?i+t.trim():""}static TargetingKeyValues(t){return h(t)}static PrebidORTB2(t){return a(t)}}e()(p,"version",i.r);const l=p;function _(t){return{advertiserId:t.advertiserId?.toString(),campaignId:t.campaignId?.toString(),creativeId:t.creativeId?.toString(),isEmpty:t.isEmpty?.toString(),lineItemId:t.lineItemId?.toString(),serviceName:t.serviceName?.toString(),size:t.size?.toString(),slotElementId:t.slot?.getSlotElementId(),sourceAgnosticCreativeId:t.sourceAgnosticCreativeId?.toString(),sourceAgnosticLineItemId:t.sourceAgnosticLineItemId?.toString()}}l.prototype.installGPTEventListeners=function(){const t=this;t.installGPTEventListeners=function(){},window.googletag=window.googletag||{cmd:[]};const e=window.googletag;e.cmd.push((function(){e.pubads().addEventListener("slotRenderEnded",(function(e){t.witness("googletag.events.slotRenderEnded",_(e))})),e.pubads().addEventListener("impressionViewable",(function(e){t.witness("googletag.events.impressionViewable",_(e))}))}))},l.prototype.installGPTSecureSignals=function(){this.installGPTSecureSignals=function(){},window.googletag=window.googletag||{cmd:[],secureSignalProviders:[]};const t=window.googletag,e=this.lmpidFromCache();e&&t.cmd.push((function(){t.secureSignalProviders.push({id:s,collectorFunction:function(){return Promise.resolve(e)}})}))};const f=/^[a-f0-9]{64}$/i;l.prototype.tryIdentifyFromParams=function(t,e){const i=new RegExp(`^${t||"oeid"}$`,"i"),r=new URLSearchParams(window.location.search);let o="";for(const[t,e]of r)if(i.test(t)){o=e;break}""!=o&&(e||function(t){return f.test(t)}(o))&&this.identify((e||"e")+":"+o.toLowerCase())},l.prototype.auctionConfigFromCache=function(){const t=this.siteFromCache();return t?t.auctionConfig??null:null},l.prototype.installGPTAuctionConfigs=function(t){const e=this;e.installGPTAuctionConfigs=function(){},window.googletag=window.googletag||{cmd:[]};const i=window.googletag;i.cmd.push((function(){let r=i.pubads().getSlots();t&&(r=r.filter(t));const o=e.auctionConfigFromCache();if(o)for(const t of r){const e=t.getSizes(),i=[];for(const t of e)"fluid"!==t&&i.push({configKey:o.seller+"-"+t.getWidth()+"x"+t.getHeight(),auctionConfig:{...o,requestedSize:{width:t.getWidth()+"px",height:t.getHeight()+"px"}}});t.setConfig({componentAuction:i})}}))},l.prototype.runAdAuction=async function(t,e){if(!("runAdAuction"in navigator))throw"run-ad-auction not supported";const i=document.getElementById(t);if(!i)throw"spot not found";const r=function(t){const e=window.getComputedStyle(t,null);return{width:e.getPropertyValue("width"),height:e.getPropertyValue("height")}}(i),o=this.auctionConfigFromCache();if(!o)return!1;const n={...o,requestedSize:r,resolveToConfig:!0},s=e?.iframe??!1;s&&(n.resolveToConfig=!1);const a=await navigator.runAdAuction(n);if(!a)return i.replaceChildren(),!1;if(s){const t=document.createElement("iframe");t.src=a,t.style.border="none",t.style.width=r.width,t.style.height=r.height,i.replaceChildren(t)}else{const t=document.createElement("fencedframe");t.config=a,t.style.border="none",i.replaceChildren(t)}return!0},l.prototype.joinAdInterestGroups=async function(){if(!("joinAdInterestGroup"in navigator))throw"join-ad-interest-group not supported";const t=await this.site();if(!t.interestGroupPixel)throw"origin not enabled for protected audience apis";const e=new URL(t.interestGroupPixel),i=document.createElement("iframe");i.src=e.toString(),i.allow="join-ad-interest-group "+e.origin,i.style.display="none";const r=new Promise(((t,e)=>{window.addEventListener("message",(r=>{r.source===i.contentWindow&&("success"!==r.data.result?e():t())}))}));return document.body.appendChild(i),r},l.prototype.getTopics=async function(){if(!("browsingTopics"in document))throw"browsing-topics not supported";const t=await this.site();if(!t.getTopicsURL)throw"origin not enabled for topics api";const e=new URL(t.getTopicsURL),i=document.createElement("iframe");i.src=e.toString(),i.allow="browsing-topics "+e.origin,i.style.display="none";const r=new Promise(((t,e)=>{window.addEventListener("message",(r=>{r.source===i.contentWindow&&(r.data.error?e(new Error(r.data.error.toString())):t(r.data.result))}))}));return document.body.appendChild(i),r},l.prototype.ingestTopics=function(){this.getTopics().then((t=>{if(!t.length)return;const e=t.reduce(((t,e)=>{const i=`topics_v${e.taxonomyVersion}`;return t[i]?t[i]+=",":t[i]="",t[i]+=String(e.topic),t}),{});this.profile(e)})).catch((()=>{}))},window.optable=window.optable||{},window.optable.SDK=l,window.optable.cmd=new class{constructor(t){if(this.cmds=t,Array.isArray(this.cmds))for(const t of this.cmds)"function"==typeof t&&t()}push(t){t()}}(window.optable.cmd||[])})()})();
2
+ (()=>{var t={396:t=>{t.exports=function(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}},312:(t,e,i)=>{var r;!function(){"use strict";var e="input is invalid type",n="object"==typeof window,s=n?window:{};s.JS_SHA256_NO_WINDOW&&(n=!1);var o=!n&&"object"==typeof self,a=!s.JS_SHA256_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;a?s=i.g:o&&(s=self);var h=!s.JS_SHA256_NO_COMMON_JS&&t.exports,c=i.amdO,u=!s.JS_SHA256_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,d="0123456789abcdef".split(""),p=[-2147483648,8388608,32768,128],l=[24,16,8,0],f=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],g=["hex","array","digest","arrayBuffer"],y=[];!s.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),!u||!s.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});var w=function(t,e){return function(i){return new A(e,!0).update(i)[t]()}},m=function(t){var e=w("hex",t);a&&(e=v(e,t)),e.create=function(){return new A(t)},e.update=function(t){return e.create().update(t)};for(var i=0;i<g.length;++i){var r=g[i];e[r]=w(r,t)}return e},v=function(t,r){var n,o=i(394),a=i(903).Buffer,h=r?"sha224":"sha256";return n=a.from&&!s.JS_SHA256_NO_BUFFER_FROM?a.from:function(t){return new a(t)},function(i){if("string"==typeof i)return o.createHash(h).update(i,"utf8").digest("hex");if(null==i)throw new Error(e);return i.constructor===ArrayBuffer&&(i=new Uint8Array(i)),Array.isArray(i)||ArrayBuffer.isView(i)||i.constructor===a?o.createHash(h).update(n(i)).digest("hex"):t(i)}},S=function(t,e){return function(i,r){return new T(i,e,!0).update(r)[t]()}},b=function(t){var e=S("hex",t);e.create=function(e){return new T(e,t)},e.update=function(t,i){return e.create(t).update(i)};for(var i=0;i<g.length;++i){var r=g[i];e[r]=S(r,t)}return e};function A(t,e){e?(y[0]=y[16]=y[1]=y[2]=y[3]=y[4]=y[5]=y[6]=y[7]=y[8]=y[9]=y[10]=y[11]=y[12]=y[13]=y[14]=y[15]=0,this.blocks=y):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=t}function T(t,i,r){var n,s=typeof t;if("string"===s){var o,a=[],h=t.length,c=0;for(n=0;n<h;++n)(o=t.charCodeAt(n))<128?a[c++]=o:o<2048?(a[c++]=192|o>>>6,a[c++]=128|63&o):o<55296||o>=57344?(a[c++]=224|o>>>12,a[c++]=128|o>>>6&63,a[c++]=128|63&o):(o=65536+((1023&o)<<10|1023&t.charCodeAt(++n)),a[c++]=240|o>>>18,a[c++]=128|o>>>12&63,a[c++]=128|o>>>6&63,a[c++]=128|63&o);t=a}else{if("object"!==s)throw new Error(e);if(null===t)throw new Error(e);if(u&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||u&&ArrayBuffer.isView(t)))throw new Error(e)}t.length>64&&(t=new A(i,!0).update(t).array());var d=[],p=[];for(n=0;n<64;++n){var l=t[n]||0;d[n]=92^l,p[n]=54^l}A.call(this,i,r),this.update(p),this.oKeyPad=d,this.inner=!0,this.sharedMemory=r}A.prototype.update=function(t){if(!this.finalized){var i,r=typeof t;if("string"!==r){if("object"!==r)throw new Error(e);if(null===t)throw new Error(e);if(u&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||u&&ArrayBuffer.isView(t)))throw new Error(e);i=!0}for(var n,s,o=0,a=t.length,h=this.blocks;o<a;){if(this.hashed&&(this.hashed=!1,h[0]=this.block,this.block=h[16]=h[1]=h[2]=h[3]=h[4]=h[5]=h[6]=h[7]=h[8]=h[9]=h[10]=h[11]=h[12]=h[13]=h[14]=h[15]=0),i)for(s=this.start;o<a&&s<64;++o)h[s>>>2]|=t[o]<<l[3&s++];else for(s=this.start;o<a&&s<64;++o)(n=t.charCodeAt(o))<128?h[s>>>2]|=n<<l[3&s++]:n<2048?(h[s>>>2]|=(192|n>>>6)<<l[3&s++],h[s>>>2]|=(128|63&n)<<l[3&s++]):n<55296||n>=57344?(h[s>>>2]|=(224|n>>>12)<<l[3&s++],h[s>>>2]|=(128|n>>>6&63)<<l[3&s++],h[s>>>2]|=(128|63&n)<<l[3&s++]):(n=65536+((1023&n)<<10|1023&t.charCodeAt(++o)),h[s>>>2]|=(240|n>>>18)<<l[3&s++],h[s>>>2]|=(128|n>>>12&63)<<l[3&s++],h[s>>>2]|=(128|n>>>6&63)<<l[3&s++],h[s>>>2]|=(128|63&n)<<l[3&s++]);this.lastByteIndex=s,this.bytes+=s-this.start,s>=64?(this.block=h[16],this.start=s-64,this.hash(),this.hashed=!0):this.start=s}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}},A.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex;t[16]=this.block,t[e>>>2]|=p[3&e],this.block=t[16],e>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}},A.prototype.hash=function(){var t,e,i,r,n,s,o,a,h,c=this.h0,u=this.h1,d=this.h2,p=this.h3,l=this.h4,g=this.h5,y=this.h6,w=this.h7,m=this.blocks;for(t=16;t<64;++t)e=((n=m[t-15])>>>7|n<<25)^(n>>>18|n<<14)^n>>>3,i=((n=m[t-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,m[t]=m[t-16]+e+m[t-7]+i|0;for(h=u&d,t=0;t<64;t+=4)this.first?(this.is224?(s=300032,w=(n=m[0]-1413257819)-150054599|0,p=n+24177077|0):(s=704751109,w=(n=m[0]-210244248)-1521486534|0,p=n+143694565|0),this.first=!1):(e=(c>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),r=(s=c&u)^c&d^h,w=p+(n=w+(i=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7))+(l&g^~l&y)+f[t]+m[t])|0,p=n+(e+r)|0),e=(p>>>2|p<<30)^(p>>>13|p<<19)^(p>>>22|p<<10),r=(o=p&c)^p&u^s,y=d+(n=y+(i=(w>>>6|w<<26)^(w>>>11|w<<21)^(w>>>25|w<<7))+(w&l^~w&g)+f[t+1]+m[t+1])|0,e=((d=n+(e+r)|0)>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),r=(a=d&p)^d&c^o,g=u+(n=g+(i=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7))+(y&w^~y&l)+f[t+2]+m[t+2])|0,e=((u=n+(e+r)|0)>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),r=(h=u&d)^u&p^a,l=c+(n=l+(i=(g>>>6|g<<26)^(g>>>11|g<<21)^(g>>>25|g<<7))+(g&y^~g&w)+f[t+3]+m[t+3])|0,c=n+(e+r)|0,this.chromeBugWorkAround=!0;this.h0=this.h0+c|0,this.h1=this.h1+u|0,this.h2=this.h2+d|0,this.h3=this.h3+p|0,this.h4=this.h4+l|0,this.h5=this.h5+g|0,this.h6=this.h6+y|0,this.h7=this.h7+w|0},A.prototype.hex=function(){this.finalize();var t=this.h0,e=this.h1,i=this.h2,r=this.h3,n=this.h4,s=this.h5,o=this.h6,a=this.h7,h=d[t>>>28&15]+d[t>>>24&15]+d[t>>>20&15]+d[t>>>16&15]+d[t>>>12&15]+d[t>>>8&15]+d[t>>>4&15]+d[15&t]+d[e>>>28&15]+d[e>>>24&15]+d[e>>>20&15]+d[e>>>16&15]+d[e>>>12&15]+d[e>>>8&15]+d[e>>>4&15]+d[15&e]+d[i>>>28&15]+d[i>>>24&15]+d[i>>>20&15]+d[i>>>16&15]+d[i>>>12&15]+d[i>>>8&15]+d[i>>>4&15]+d[15&i]+d[r>>>28&15]+d[r>>>24&15]+d[r>>>20&15]+d[r>>>16&15]+d[r>>>12&15]+d[r>>>8&15]+d[r>>>4&15]+d[15&r]+d[n>>>28&15]+d[n>>>24&15]+d[n>>>20&15]+d[n>>>16&15]+d[n>>>12&15]+d[n>>>8&15]+d[n>>>4&15]+d[15&n]+d[s>>>28&15]+d[s>>>24&15]+d[s>>>20&15]+d[s>>>16&15]+d[s>>>12&15]+d[s>>>8&15]+d[s>>>4&15]+d[15&s]+d[o>>>28&15]+d[o>>>24&15]+d[o>>>20&15]+d[o>>>16&15]+d[o>>>12&15]+d[o>>>8&15]+d[o>>>4&15]+d[15&o];return this.is224||(h+=d[a>>>28&15]+d[a>>>24&15]+d[a>>>20&15]+d[a>>>16&15]+d[a>>>12&15]+d[a>>>8&15]+d[a>>>4&15]+d[15&a]),h},A.prototype.toString=A.prototype.hex,A.prototype.digest=function(){this.finalize();var t=this.h0,e=this.h1,i=this.h2,r=this.h3,n=this.h4,s=this.h5,o=this.h6,a=this.h7,h=[t>>>24&255,t>>>16&255,t>>>8&255,255&t,e>>>24&255,e>>>16&255,e>>>8&255,255&e,i>>>24&255,i>>>16&255,i>>>8&255,255&i,r>>>24&255,r>>>16&255,r>>>8&255,255&r,n>>>24&255,n>>>16&255,n>>>8&255,255&n,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o>>>24&255,o>>>16&255,o>>>8&255,255&o];return this.is224||h.push(a>>>24&255,a>>>16&255,a>>>8&255,255&a),h},A.prototype.array=A.prototype.digest,A.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(this.is224?28:32),e=new DataView(t);return e.setUint32(0,this.h0),e.setUint32(4,this.h1),e.setUint32(8,this.h2),e.setUint32(12,this.h3),e.setUint32(16,this.h4),e.setUint32(20,this.h5),e.setUint32(24,this.h6),this.is224||e.setUint32(28,this.h7),t},T.prototype=new A,T.prototype.finalize=function(){if(A.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();A.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(t),A.prototype.finalize.call(this)}};var C=m();C.sha256=C,C.sha224=m(!0),C.sha256.hmac=b(),C.sha224.hmac=b(!0),h?t.exports=C:(s.sha256=C.sha256,s.sha224=C.sha224,c&&(void 0===(r=function(){return C}.call(C,i,C,t))||(t.exports=r)))}()},903:()=>{},394:()=>{}},e={};function i(r){var n=e[r];if(void 0!==n)return n.exports;var s=e[r]={exports:{}};return t[r](s,s.exports,i),s.exports}i.amdO={},i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{"use strict";var t=i(396),e=i.n(t);const r=JSON.parse('{"r":"0.0.0-experimental"}'),n={insecure:!1,cookies:!0,initPassport:!0};async function s(t){const e=await a("/config",t,{method:"GET",headers:{Accept:"application/json"}});return new o(t).setSite(e),e}class o{constructor(t){this.Config=t,e()(this,"passportKey",void 0),e()(this,"targetingV1Key",void 0),e()(this,"targetingKey",void 0),e()(this,"siteKey",void 0);const i=btoa(function(t){const e=new Uint16Array(t.length);for(let i=0;i<e.length;i++)e[i]=t.charCodeAt(i);return String.fromCharCode(...new Uint8Array(e.buffer))}(`${this.Config.host}/${this.Config.site}`));this.targetingV1Key="OPTABLE_TGT_"+i,this.passportKey="OPTABLE_PASS_"+i,this.targetingKey="OPTABLE_V2_TGT_"+i,this.siteKey="OPTABLE_SITE_"+i}getPassport(){return window.localStorage.getItem(this.passportKey)}getV1Targeting(){const t=window.localStorage.getItem(this.targetingV1Key),e=t?JSON.parse(t):null;return e?{user:[],audience:Object.entries(e).map((t=>{let[e,i]=t;return{provider:"optable.co",keyspace:e,rtb_segtax:5001,ids:[].concat(i).map((t=>({id:String(t)})))}}))}:null}getTargeting(){const t=window.localStorage.getItem(this.targetingKey);return(t?JSON.parse(t):null)||this.getV1Targeting()}setPassport(t){t&&t.length>0&&window.localStorage.setItem(this.passportKey,t)}setTargeting(t){t&&window.localStorage.setItem(this.targetingKey,JSON.stringify(t))}setSite(t){t&&window.localStorage.setItem(this.siteKey,JSON.stringify(t))}getSite(){const t=window.localStorage.getItem(this.siteKey);return t?JSON.parse(t):null}clearPassport(){window.localStorage.removeItem(this.passportKey)}clearTargeting(){window.localStorage.removeItem(this.targetingKey)}clearSite(){window.localStorage.removeItem(this.siteKey)}}async function a(t,e,i){const n=await globalThis.fetch(function(t,e,i){const{site:n,host:s,insecure:a,cookies:h}=e,c=new URL(`${n}${t}`,`${a?"http":"https"}://${s}`);if(c.searchParams.set("osdk",`web-${r.r}`),h)c.searchParams.set("cookies","yes");else{const t=new o(e).getPassport();c.searchParams.set("cookies","no"),c.searchParams.set("passport",t||"")}const u={...i};return u.credentials="include",new Request(c.toString(),u)}(t,e,i)),s=n.headers.get("Content-Type"),a=s?.startsWith("application/json")?await n.json():await n.text();if(!n.ok)throw new Error(a.error);return a.passport&&(new o(e).setPassport(a.passport),delete a.passport),a}var h;function c(t){return{user:{data:(t?.audience??[]).map((t=>({name:t.provider,segment:t.ids,ext:{segtax:t.rtb_segtax}}))),ext:{eids:(t?.user??[]).map((t=>({source:t.provider,uids:t.ids.map((t=>{let{id:e}=t;return{id:e,atype:h.PersonID}}))})))}}}}function u(t){const e={};if(!t)return e;for(const i of t.audience??[])i.keyspace&&(i.keyspace in e||(e[i.keyspace]=[]),e[i.keyspace].push(...i.ids.map((t=>t.id))));return e}!function(t){t[t.DeviceID=1]="DeviceID",t[t.InAppImpression=2]="InAppImpression",t[t.PersonID=3]="PersonID"}(h||(h={}));var d=i(312);class p{constructor(t){var i;e()(this,"dcn",void 0),e()(this,"init",void 0),this.dcn=(i=t,{...n,...i});const r=()=>{};this.init=this.dcn.initPassport?s(this.dcn).then(r).catch(r):Promise.resolve()}async identify(){await this.init;for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return function(t,e){return a("/identify",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}(this.dcn,e.filter((t=>t)))}async uid2Token(t){return await this.init,function(t,e){return a("/uid2/token",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}(this.dcn,t)}async targeting(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"__passport__";return await this.init,async function(t,e){const i="/v2/targeting?"+new URLSearchParams({id:e}).toString(),r=await a(i,t,{method:"GET",headers:{Accept:"application/json"}});return r&&new o(t).setTargeting(r),r}(this.dcn,t)}targetingFromCache(){return t=this.dcn,new o(t).getTargeting();var t}async site(){return s(this.dcn)}siteFromCache(){return t=this.dcn,new o(t).getSite();var t}targetingClearCache(){var t;t=this.dcn,new o(t).clearTargeting()}async prebidORTB2(){return c(await this.targeting())}prebidORTB2FromCache(){return c(this.targetingFromCache())}async targetingKeyValues(){return u(await this.targeting())}targetingKeyValuesFromCache(){return u(this.targetingFromCache())}async witness(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return await this.init,function(t,e,i){const r={event:e,properties:i};return a("/witness",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}(this.dcn,t,e)}async profile(t){return await this.init,function(t,e){const i={traits:e};return a("/profile",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}(this.dcn,t)}async tokenize(t){return await this.init,function(t,e){let i={id:e};return a("/v1/tokenize",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}(this.dcn,t)}static eid(t){return t?"e:"+d.sha256.hex(t.toLowerCase().trim()):""}static sha256(t){return t?d.sha256.hex(t):""}static cid(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i="c:";if("string"!=typeof t)throw new Error("Invalid ppid");if("number"!=typeof e||isNaN(e)||e<0||e>9)throw new Error("Invalid variant");return e>0&&(i=`c${e}:`),t?i+t.trim():""}static TargetingKeyValues(t){return u(t)}static PrebidORTB2(t){return c(t)}}e()(p,"version",r.r);const l=p;function f(t){return{advertiserId:t.advertiserId?.toString(),campaignId:t.campaignId?.toString(),creativeId:t.creativeId?.toString(),isEmpty:t.isEmpty?.toString(),lineItemId:t.lineItemId?.toString(),serviceName:t.serviceName?.toString(),size:t.size?.toString(),slotElementId:t.slot?.getSlotElementId(),sourceAgnosticCreativeId:t.sourceAgnosticCreativeId?.toString(),sourceAgnosticLineItemId:t.sourceAgnosticLineItemId?.toString()}}l.prototype.installGPTEventListeners=function(){const t=this;t.installGPTEventListeners=function(){},window.googletag=window.googletag||{cmd:[]};const e=window.googletag;e.cmd.push((function(){e.pubads().addEventListener("slotRenderEnded",(function(e){t.witness("googletag.events.slotRenderEnded",f(e))})),e.pubads().addEventListener("impressionViewable",(function(e){t.witness("googletag.events.impressionViewable",f(e))}))}))},l.prototype.installGPTSecureSignals=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];window.googletag=window.googletag||{cmd:[]};const r=window.googletag;e&&e.length>0&&r.cmd.push((()=>{e.forEach((t=>{let{provider:e,id:i}=t;r.secureSignalProviders.push({id:e,collectorFunction:()=>Promise.resolve(i)})}))}))};const g=/^[a-f0-9]{64}$/i;l.prototype.tryIdentifyFromParams=function(t,e){const i=new RegExp(`^${t||"oeid"}$`,"i"),r=new URLSearchParams(window.location.search);let n="";for(const[t,e]of r)if(i.test(t)){n=e;break}""!=n&&(e||function(t){return g.test(t)}(n))&&this.identify((e||"e")+":"+n.toLowerCase())},l.prototype.auctionConfigFromCache=function(){const t=this.siteFromCache();return t?t.auctionConfig??null:null},l.prototype.installGPTAuctionConfigs=function(t){const e=this;e.installGPTAuctionConfigs=function(){},window.googletag=window.googletag||{cmd:[]};const i=window.googletag;i.cmd.push((function(){let r=i.pubads().getSlots();t&&(r=r.filter(t));const n=e.auctionConfigFromCache();if(n)for(const t of r){const e=t.getSizes(),i=[];for(const t of e)"fluid"!==t&&i.push({configKey:n.seller+"-"+t.getWidth()+"x"+t.getHeight(),auctionConfig:{...n,requestedSize:{width:t.getWidth()+"px",height:t.getHeight()+"px"}}});t.setConfig({componentAuction:i})}}))},l.prototype.runAdAuction=async function(t,e){if(!("runAdAuction"in navigator))throw"run-ad-auction not supported";const i=document.getElementById(t);if(!i)throw"spot not found";const r=function(t){const e=window.getComputedStyle(t,null);return{width:e.getPropertyValue("width"),height:e.getPropertyValue("height")}}(i),n=this.auctionConfigFromCache();if(!n)return!1;const s={...n,requestedSize:r,resolveToConfig:!0},o=e?.iframe??!1;o&&(s.resolveToConfig=!1);const a=await navigator.runAdAuction(s);if(!a)return i.replaceChildren(),!1;if(o){const t=document.createElement("iframe");t.src=a,t.style.border="none",t.style.width=r.width,t.style.height=r.height,i.replaceChildren(t)}else{const t=document.createElement("fencedframe");t.config=a,t.style.border="none",i.replaceChildren(t)}return!0},l.prototype.joinAdInterestGroups=async function(){if(!("joinAdInterestGroup"in navigator))throw"join-ad-interest-group not supported";const t=await this.site();if(!t.interestGroupPixel)throw"origin not enabled for protected audience apis";const e=new URL(t.interestGroupPixel),i=document.createElement("iframe");i.src=e.toString(),i.allow="join-ad-interest-group "+e.origin,i.style.display="none";const r=new Promise(((t,e)=>{window.addEventListener("message",(r=>{r.source===i.contentWindow&&("success"!==r.data.result?e():t())}))}));return document.body.appendChild(i),r},l.prototype.getTopics=async function(){if(!("browsingTopics"in document))throw"browsing-topics not supported";const t=await this.site();if(!t.getTopicsURL)throw"origin not enabled for topics api";const e=new URL(t.getTopicsURL),i=document.createElement("iframe");i.src=e.toString(),i.allow="browsing-topics "+e.origin,i.style.display="none";const r=new Promise(((t,e)=>{window.addEventListener("message",(r=>{r.source===i.contentWindow&&(r.data.error?e(new Error(r.data.error.toString())):t(r.data.result))}))}));return document.body.appendChild(i),r},l.prototype.ingestTopics=function(){this.getTopics().then((t=>{if(!t.length)return;const e=t.reduce(((t,e)=>{const i=`topics_v${e.taxonomyVersion}`;return t[i]?t[i]+=",":t[i]="",t[i]+=String(e.topic),t}),{});this.profile(e)})).catch((()=>{}))},window.optable=window.optable||{},window.optable.SDK=l,window.optable.cmd=new class{constructor(t){if(this.cmds=t,Array.isArray(this.cmds))for(const t of this.cmds)"function"==typeof t&&t()}push(t){t()}}(window.optable.cmd||[])})()})();
@@ -0,0 +1,7 @@
1
+ declare class Commands {
2
+ private cmds;
3
+ constructor(cmds: Commands | Function[]);
4
+ push(cmd: Function): void;
5
+ }
6
+ export { Commands };
7
+ export default Commands;
package/lib/dist/sdk.d.ts CHANGED
@@ -1,41 +1,16 @@
1
- import type { OptableConfig } from "./config";
2
- import type { WitnessProperties } from "./edge/witness";
3
- import type { ProfileTraits } from "./edge/profile";
4
- import { SiteResponse } from "./edge/site";
5
- import { TargetingKeyValues, TargetingResponse, PrebidORTB2 } from "./edge/targeting";
6
- import { TokenizeResponse } from "./edge/tokenize";
7
- declare class OptableSDK {
8
- static version: string;
9
- dcn: Required<OptableConfig>;
10
- private init;
11
- constructor(dcn: OptableConfig);
12
- identify(...ids: string[]): Promise<void>;
13
- uid2Token(id: string): Promise<{
14
- advertising_token: string;
15
- RefreshToken: string;
16
- IdentityExpires: number;
17
- RefreshFrom: number;
18
- RefreshExpires: number;
19
- RefreshResponseKey: string;
20
- }>;
21
- targeting(id?: string): Promise<TargetingResponse>;
22
- targetingFromCache(): TargetingResponse | null;
23
- site(): Promise<SiteResponse>;
24
- siteFromCache(): SiteResponse | null;
25
- targetingClearCache(): void;
26
- lmpidFromCache(): string | null;
27
- prebidORTB2(): Promise<PrebidORTB2>;
28
- prebidORTB2FromCache(): PrebidORTB2;
29
- targetingKeyValues(): Promise<TargetingKeyValues>;
30
- targetingKeyValuesFromCache(): TargetingKeyValues;
31
- witness(event: string, properties?: WitnessProperties): Promise<void>;
32
- profile(traits: ProfileTraits): Promise<void>;
33
- tokenize(id: string): Promise<TokenizeResponse>;
34
- static eid(email: string): string;
35
- static cid(ppid: string, variant?: number): string;
36
- static TargetingKeyValues(tdata: TargetingResponse): TargetingKeyValues;
37
- static PrebidORTB2(tdata: TargetingResponse): PrebidORTB2;
1
+ import Commands from "./commands";
2
+ import OptableSDK from "../lib/sdk";
3
+ import "../lib/addons/gpt";
4
+ import "../lib/addons/try-identify";
5
+ import "../lib/addons/paapi";
6
+ import "../lib/addons/topics-api";
7
+ type OptableGlobal = {
8
+ cmd: Commands | Function[];
9
+ SDK: OptableSDK["constructor"];
10
+ };
11
+ declare global {
12
+ interface Window {
13
+ optable?: Partial<OptableGlobal>;
14
+ }
38
15
  }
39
- export { OptableSDK };
40
- export type { OptableConfig };
41
- export default OptableSDK;
16
+ export {};
package/lib/dist/sdk.js CHANGED
@@ -1,123 +1,2 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { default as buildInfo } from "./build.json";
11
- import { getConfig } from "./config";
12
- import { Identify } from "./edge/identify";
13
- import { Uid2Token } from "./edge/uid2_token";
14
- import { Site, SiteFromCache } from "./edge/site";
15
- import { TargetingKeyValues, Targeting, TargetingFromCache, TargetingClearCache, PrebidORTB2, LmpidFromCache, } from "./edge/targeting";
16
- import { Witness } from "./edge/witness";
17
- import { Profile } from "./edge/profile";
18
- import { sha256 } from "js-sha256";
19
- import { Tokenize } from "./edge/tokenize";
20
- class OptableSDK {
21
- constructor(dcn) {
22
- this.dcn = getConfig(dcn);
23
- // If initPassport, prefetch site config and cache it, it assigns a passport as a side effect
24
- const noop = () => { };
25
- this.init = this.dcn.initPassport ? Site(this.dcn).then(noop).catch(noop) : Promise.resolve();
26
- }
27
- identify(...ids) {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- yield this.init;
30
- return Identify(this.dcn, ids.filter((id) => id));
31
- });
32
- }
33
- uid2Token(id) {
34
- return __awaiter(this, void 0, void 0, function* () {
35
- yield this.init;
36
- return Uid2Token(this.dcn, id);
37
- });
38
- }
39
- targeting(id = "__passport__") {
40
- return __awaiter(this, void 0, void 0, function* () {
41
- yield this.init;
42
- return Targeting(this.dcn, id);
43
- });
44
- }
45
- targetingFromCache() {
46
- return TargetingFromCache(this.dcn);
47
- }
48
- site() {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- return Site(this.dcn);
51
- });
52
- }
53
- siteFromCache() {
54
- return SiteFromCache(this.dcn);
55
- }
56
- targetingClearCache() {
57
- TargetingClearCache(this.dcn);
58
- }
59
- lmpidFromCache() {
60
- return LmpidFromCache(this.dcn);
61
- }
62
- prebidORTB2() {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- return PrebidORTB2(yield this.targeting());
65
- });
66
- }
67
- prebidORTB2FromCache() {
68
- const tdata = this.targetingFromCache();
69
- return PrebidORTB2(tdata);
70
- }
71
- targetingKeyValues() {
72
- return __awaiter(this, void 0, void 0, function* () {
73
- return TargetingKeyValues(yield this.targeting());
74
- });
75
- }
76
- targetingKeyValuesFromCache() {
77
- const tdata = this.targetingFromCache();
78
- return TargetingKeyValues(tdata);
79
- }
80
- witness(event, properties = {}) {
81
- return __awaiter(this, void 0, void 0, function* () {
82
- yield this.init;
83
- return Witness(this.dcn, event, properties);
84
- });
85
- }
86
- profile(traits) {
87
- return __awaiter(this, void 0, void 0, function* () {
88
- yield this.init;
89
- return Profile(this.dcn, traits);
90
- });
91
- }
92
- tokenize(id) {
93
- return __awaiter(this, void 0, void 0, function* () {
94
- yield this.init;
95
- return Tokenize(this.dcn, id);
96
- });
97
- }
98
- static eid(email) {
99
- return email ? "e:" + sha256.hex(email.toLowerCase().trim()) : "";
100
- }
101
- static cid(ppid, variant = 0) {
102
- let prefix = "c:";
103
- if (typeof ppid !== "string") {
104
- throw new Error("Invalid ppid");
105
- }
106
- if (typeof variant !== "number" || isNaN(variant) || variant < 0 || variant > 9) {
107
- throw new Error("Invalid variant");
108
- }
109
- if (variant > 0) {
110
- prefix = `c${variant}:`;
111
- }
112
- return ppid ? prefix + ppid.trim() : "";
113
- }
114
- static TargetingKeyValues(tdata) {
115
- return TargetingKeyValues(tdata);
116
- }
117
- static PrebidORTB2(tdata) {
118
- return PrebidORTB2(tdata);
119
- }
120
- }
121
- OptableSDK.version = buildInfo.version;
122
- export { OptableSDK };
123
- export default OptableSDK;
1
+ /*! For license information please see sdk.js.LICENSE.txt */
2
+ (()=>{var t={396:t=>{t.exports=function(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}},312:(t,e,i)=>{var r;!function(){"use strict";var e="input is invalid type",n="object"==typeof window,s=n?window:{};s.JS_SHA256_NO_WINDOW&&(n=!1);var o=!n&&"object"==typeof self,a=!s.JS_SHA256_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;a?s=i.g:o&&(s=self);var h=!s.JS_SHA256_NO_COMMON_JS&&t.exports,c=i.amdO,u=!s.JS_SHA256_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,d="0123456789abcdef".split(""),p=[-2147483648,8388608,32768,128],l=[24,16,8,0],f=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],g=["hex","array","digest","arrayBuffer"],y=[];!s.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),!u||!s.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});var w=function(t,e){return function(i){return new A(e,!0).update(i)[t]()}},m=function(t){var e=w("hex",t);a&&(e=v(e,t)),e.create=function(){return new A(t)},e.update=function(t){return e.create().update(t)};for(var i=0;i<g.length;++i){var r=g[i];e[r]=w(r,t)}return e},v=function(t,r){var n,o=i(394),a=i(903).Buffer,h=r?"sha224":"sha256";return n=a.from&&!s.JS_SHA256_NO_BUFFER_FROM?a.from:function(t){return new a(t)},function(i){if("string"==typeof i)return o.createHash(h).update(i,"utf8").digest("hex");if(null==i)throw new Error(e);return i.constructor===ArrayBuffer&&(i=new Uint8Array(i)),Array.isArray(i)||ArrayBuffer.isView(i)||i.constructor===a?o.createHash(h).update(n(i)).digest("hex"):t(i)}},S=function(t,e){return function(i,r){return new T(i,e,!0).update(r)[t]()}},b=function(t){var e=S("hex",t);e.create=function(e){return new T(e,t)},e.update=function(t,i){return e.create(t).update(i)};for(var i=0;i<g.length;++i){var r=g[i];e[r]=S(r,t)}return e};function A(t,e){e?(y[0]=y[16]=y[1]=y[2]=y[3]=y[4]=y[5]=y[6]=y[7]=y[8]=y[9]=y[10]=y[11]=y[12]=y[13]=y[14]=y[15]=0,this.blocks=y):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=t}function T(t,i,r){var n,s=typeof t;if("string"===s){var o,a=[],h=t.length,c=0;for(n=0;n<h;++n)(o=t.charCodeAt(n))<128?a[c++]=o:o<2048?(a[c++]=192|o>>>6,a[c++]=128|63&o):o<55296||o>=57344?(a[c++]=224|o>>>12,a[c++]=128|o>>>6&63,a[c++]=128|63&o):(o=65536+((1023&o)<<10|1023&t.charCodeAt(++n)),a[c++]=240|o>>>18,a[c++]=128|o>>>12&63,a[c++]=128|o>>>6&63,a[c++]=128|63&o);t=a}else{if("object"!==s)throw new Error(e);if(null===t)throw new Error(e);if(u&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||u&&ArrayBuffer.isView(t)))throw new Error(e)}t.length>64&&(t=new A(i,!0).update(t).array());var d=[],p=[];for(n=0;n<64;++n){var l=t[n]||0;d[n]=92^l,p[n]=54^l}A.call(this,i,r),this.update(p),this.oKeyPad=d,this.inner=!0,this.sharedMemory=r}A.prototype.update=function(t){if(!this.finalized){var i,r=typeof t;if("string"!==r){if("object"!==r)throw new Error(e);if(null===t)throw new Error(e);if(u&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||u&&ArrayBuffer.isView(t)))throw new Error(e);i=!0}for(var n,s,o=0,a=t.length,h=this.blocks;o<a;){if(this.hashed&&(this.hashed=!1,h[0]=this.block,this.block=h[16]=h[1]=h[2]=h[3]=h[4]=h[5]=h[6]=h[7]=h[8]=h[9]=h[10]=h[11]=h[12]=h[13]=h[14]=h[15]=0),i)for(s=this.start;o<a&&s<64;++o)h[s>>>2]|=t[o]<<l[3&s++];else for(s=this.start;o<a&&s<64;++o)(n=t.charCodeAt(o))<128?h[s>>>2]|=n<<l[3&s++]:n<2048?(h[s>>>2]|=(192|n>>>6)<<l[3&s++],h[s>>>2]|=(128|63&n)<<l[3&s++]):n<55296||n>=57344?(h[s>>>2]|=(224|n>>>12)<<l[3&s++],h[s>>>2]|=(128|n>>>6&63)<<l[3&s++],h[s>>>2]|=(128|63&n)<<l[3&s++]):(n=65536+((1023&n)<<10|1023&t.charCodeAt(++o)),h[s>>>2]|=(240|n>>>18)<<l[3&s++],h[s>>>2]|=(128|n>>>12&63)<<l[3&s++],h[s>>>2]|=(128|n>>>6&63)<<l[3&s++],h[s>>>2]|=(128|63&n)<<l[3&s++]);this.lastByteIndex=s,this.bytes+=s-this.start,s>=64?(this.block=h[16],this.start=s-64,this.hash(),this.hashed=!0):this.start=s}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}},A.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex;t[16]=this.block,t[e>>>2]|=p[3&e],this.block=t[16],e>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}},A.prototype.hash=function(){var t,e,i,r,n,s,o,a,h,c=this.h0,u=this.h1,d=this.h2,p=this.h3,l=this.h4,g=this.h5,y=this.h6,w=this.h7,m=this.blocks;for(t=16;t<64;++t)e=((n=m[t-15])>>>7|n<<25)^(n>>>18|n<<14)^n>>>3,i=((n=m[t-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,m[t]=m[t-16]+e+m[t-7]+i|0;for(h=u&d,t=0;t<64;t+=4)this.first?(this.is224?(s=300032,w=(n=m[0]-1413257819)-150054599|0,p=n+24177077|0):(s=704751109,w=(n=m[0]-210244248)-1521486534|0,p=n+143694565|0),this.first=!1):(e=(c>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),r=(s=c&u)^c&d^h,w=p+(n=w+(i=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7))+(l&g^~l&y)+f[t]+m[t])|0,p=n+(e+r)|0),e=(p>>>2|p<<30)^(p>>>13|p<<19)^(p>>>22|p<<10),r=(o=p&c)^p&u^s,y=d+(n=y+(i=(w>>>6|w<<26)^(w>>>11|w<<21)^(w>>>25|w<<7))+(w&l^~w&g)+f[t+1]+m[t+1])|0,e=((d=n+(e+r)|0)>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),r=(a=d&p)^d&c^o,g=u+(n=g+(i=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7))+(y&w^~y&l)+f[t+2]+m[t+2])|0,e=((u=n+(e+r)|0)>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),r=(h=u&d)^u&p^a,l=c+(n=l+(i=(g>>>6|g<<26)^(g>>>11|g<<21)^(g>>>25|g<<7))+(g&y^~g&w)+f[t+3]+m[t+3])|0,c=n+(e+r)|0,this.chromeBugWorkAround=!0;this.h0=this.h0+c|0,this.h1=this.h1+u|0,this.h2=this.h2+d|0,this.h3=this.h3+p|0,this.h4=this.h4+l|0,this.h5=this.h5+g|0,this.h6=this.h6+y|0,this.h7=this.h7+w|0},A.prototype.hex=function(){this.finalize();var t=this.h0,e=this.h1,i=this.h2,r=this.h3,n=this.h4,s=this.h5,o=this.h6,a=this.h7,h=d[t>>>28&15]+d[t>>>24&15]+d[t>>>20&15]+d[t>>>16&15]+d[t>>>12&15]+d[t>>>8&15]+d[t>>>4&15]+d[15&t]+d[e>>>28&15]+d[e>>>24&15]+d[e>>>20&15]+d[e>>>16&15]+d[e>>>12&15]+d[e>>>8&15]+d[e>>>4&15]+d[15&e]+d[i>>>28&15]+d[i>>>24&15]+d[i>>>20&15]+d[i>>>16&15]+d[i>>>12&15]+d[i>>>8&15]+d[i>>>4&15]+d[15&i]+d[r>>>28&15]+d[r>>>24&15]+d[r>>>20&15]+d[r>>>16&15]+d[r>>>12&15]+d[r>>>8&15]+d[r>>>4&15]+d[15&r]+d[n>>>28&15]+d[n>>>24&15]+d[n>>>20&15]+d[n>>>16&15]+d[n>>>12&15]+d[n>>>8&15]+d[n>>>4&15]+d[15&n]+d[s>>>28&15]+d[s>>>24&15]+d[s>>>20&15]+d[s>>>16&15]+d[s>>>12&15]+d[s>>>8&15]+d[s>>>4&15]+d[15&s]+d[o>>>28&15]+d[o>>>24&15]+d[o>>>20&15]+d[o>>>16&15]+d[o>>>12&15]+d[o>>>8&15]+d[o>>>4&15]+d[15&o];return this.is224||(h+=d[a>>>28&15]+d[a>>>24&15]+d[a>>>20&15]+d[a>>>16&15]+d[a>>>12&15]+d[a>>>8&15]+d[a>>>4&15]+d[15&a]),h},A.prototype.toString=A.prototype.hex,A.prototype.digest=function(){this.finalize();var t=this.h0,e=this.h1,i=this.h2,r=this.h3,n=this.h4,s=this.h5,o=this.h6,a=this.h7,h=[t>>>24&255,t>>>16&255,t>>>8&255,255&t,e>>>24&255,e>>>16&255,e>>>8&255,255&e,i>>>24&255,i>>>16&255,i>>>8&255,255&i,r>>>24&255,r>>>16&255,r>>>8&255,255&r,n>>>24&255,n>>>16&255,n>>>8&255,255&n,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o>>>24&255,o>>>16&255,o>>>8&255,255&o];return this.is224||h.push(a>>>24&255,a>>>16&255,a>>>8&255,255&a),h},A.prototype.array=A.prototype.digest,A.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(this.is224?28:32),e=new DataView(t);return e.setUint32(0,this.h0),e.setUint32(4,this.h1),e.setUint32(8,this.h2),e.setUint32(12,this.h3),e.setUint32(16,this.h4),e.setUint32(20,this.h5),e.setUint32(24,this.h6),this.is224||e.setUint32(28,this.h7),t},T.prototype=new A,T.prototype.finalize=function(){if(A.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();A.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(t),A.prototype.finalize.call(this)}};var C=m();C.sha256=C,C.sha224=m(!0),C.sha256.hmac=b(),C.sha224.hmac=b(!0),h?t.exports=C:(s.sha256=C.sha256,s.sha224=C.sha224,c&&(void 0===(r=function(){return C}.call(C,i,C,t))||(t.exports=r)))}()},903:()=>{},394:()=>{}},e={};function i(r){var n=e[r];if(void 0!==n)return n.exports;var s=e[r]={exports:{}};return t[r](s,s.exports,i),s.exports}i.amdO={},i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{"use strict";var t=i(396),e=i.n(t);const r=JSON.parse('{"r":"0.0.0-experimental"}'),n={insecure:!1,cookies:!0,initPassport:!0};async function s(t){const e=await a("/config",t,{method:"GET",headers:{Accept:"application/json"}});return new o(t).setSite(e),e}class o{constructor(t){this.Config=t,e()(this,"passportKey",void 0),e()(this,"targetingV1Key",void 0),e()(this,"targetingKey",void 0),e()(this,"siteKey",void 0);const i=btoa(function(t){const e=new Uint16Array(t.length);for(let i=0;i<e.length;i++)e[i]=t.charCodeAt(i);return String.fromCharCode(...new Uint8Array(e.buffer))}(`${this.Config.host}/${this.Config.site}`));this.targetingV1Key="OPTABLE_TGT_"+i,this.passportKey="OPTABLE_PASS_"+i,this.targetingKey="OPTABLE_V2_TGT_"+i,this.siteKey="OPTABLE_SITE_"+i}getPassport(){return window.localStorage.getItem(this.passportKey)}getV1Targeting(){const t=window.localStorage.getItem(this.targetingV1Key),e=t?JSON.parse(t):null;return e?{user:[],audience:Object.entries(e).map((t=>{let[e,i]=t;return{provider:"optable.co",keyspace:e,rtb_segtax:5001,ids:[].concat(i).map((t=>({id:String(t)})))}}))}:null}getTargeting(){const t=window.localStorage.getItem(this.targetingKey);return(t?JSON.parse(t):null)||this.getV1Targeting()}setPassport(t){t&&t.length>0&&window.localStorage.setItem(this.passportKey,t)}setTargeting(t){t&&window.localStorage.setItem(this.targetingKey,JSON.stringify(t))}setSite(t){t&&window.localStorage.setItem(this.siteKey,JSON.stringify(t))}getSite(){const t=window.localStorage.getItem(this.siteKey);return t?JSON.parse(t):null}clearPassport(){window.localStorage.removeItem(this.passportKey)}clearTargeting(){window.localStorage.removeItem(this.targetingKey)}clearSite(){window.localStorage.removeItem(this.siteKey)}}async function a(t,e,i){const n=await globalThis.fetch(function(t,e,i){const{site:n,host:s,insecure:a,cookies:h}=e,c=new URL(`${n}${t}`,`${a?"http":"https"}://${s}`);if(c.searchParams.set("osdk",`web-${r.r}`),h)c.searchParams.set("cookies","yes");else{const t=new o(e).getPassport();c.searchParams.set("cookies","no"),c.searchParams.set("passport",t||"")}const u={...i};return u.credentials="include",new Request(c.toString(),u)}(t,e,i)),s=n.headers.get("Content-Type"),a=s?.startsWith("application/json")?await n.json():await n.text();if(!n.ok)throw new Error(a.error);return a.passport&&(new o(e).setPassport(a.passport),delete a.passport),a}var h;function c(t){return{user:{data:(t?.audience??[]).map((t=>({name:t.provider,segment:t.ids,ext:{segtax:t.rtb_segtax}}))),ext:{eids:(t?.user??[]).map((t=>({source:t.provider,uids:t.ids.map((t=>{let{id:e}=t;return{id:e,atype:h.PersonID}}))})))}}}}function u(t){const e={};if(!t)return e;for(const i of t.audience??[])i.keyspace&&(i.keyspace in e||(e[i.keyspace]=[]),e[i.keyspace].push(...i.ids.map((t=>t.id))));return e}!function(t){t[t.DeviceID=1]="DeviceID",t[t.InAppImpression=2]="InAppImpression",t[t.PersonID=3]="PersonID"}(h||(h={}));var d=i(312);class p{constructor(t){var i;e()(this,"dcn",void 0),e()(this,"init",void 0),this.dcn=(i=t,{...n,...i});const r=()=>{};this.init=this.dcn.initPassport?s(this.dcn).then(r).catch(r):Promise.resolve()}async identify(){await this.init;for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return function(t,e){return a("/identify",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}(this.dcn,e.filter((t=>t)))}async uid2Token(t){return await this.init,function(t,e){return a("/uid2/token",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}(this.dcn,t)}async targeting(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"__passport__";return await this.init,async function(t,e){const i="/v2/targeting?"+new URLSearchParams({id:e}).toString(),r=await a(i,t,{method:"GET",headers:{Accept:"application/json"}});return r&&new o(t).setTargeting(r),r}(this.dcn,t)}targetingFromCache(){return t=this.dcn,new o(t).getTargeting();var t}async site(){return s(this.dcn)}siteFromCache(){return t=this.dcn,new o(t).getSite();var t}targetingClearCache(){var t;t=this.dcn,new o(t).clearTargeting()}async prebidORTB2(){return c(await this.targeting())}prebidORTB2FromCache(){return c(this.targetingFromCache())}async targetingKeyValues(){return u(await this.targeting())}targetingKeyValuesFromCache(){return u(this.targetingFromCache())}async witness(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return await this.init,function(t,e,i){const r={event:e,properties:i};return a("/witness",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}(this.dcn,t,e)}async profile(t){return await this.init,function(t,e){const i={traits:e};return a("/profile",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}(this.dcn,t)}async tokenize(t){return await this.init,function(t,e){let i={id:e};return a("/v1/tokenize",t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}(this.dcn,t)}static eid(t){return t?"e:"+d.sha256.hex(t.toLowerCase().trim()):""}static sha256(t){return t?d.sha256.hex(t):""}static cid(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i="c:";if("string"!=typeof t)throw new Error("Invalid ppid");if("number"!=typeof e||isNaN(e)||e<0||e>9)throw new Error("Invalid variant");return e>0&&(i=`c${e}:`),t?i+t.trim():""}static TargetingKeyValues(t){return u(t)}static PrebidORTB2(t){return c(t)}}e()(p,"version",r.r);const l=p;function f(t){return{advertiserId:t.advertiserId?.toString(),campaignId:t.campaignId?.toString(),creativeId:t.creativeId?.toString(),isEmpty:t.isEmpty?.toString(),lineItemId:t.lineItemId?.toString(),serviceName:t.serviceName?.toString(),size:t.size?.toString(),slotElementId:t.slot?.getSlotElementId(),sourceAgnosticCreativeId:t.sourceAgnosticCreativeId?.toString(),sourceAgnosticLineItemId:t.sourceAgnosticLineItemId?.toString()}}l.prototype.installGPTEventListeners=function(){const t=this;t.installGPTEventListeners=function(){},window.googletag=window.googletag||{cmd:[]};const e=window.googletag;e.cmd.push((function(){e.pubads().addEventListener("slotRenderEnded",(function(e){t.witness("googletag.events.slotRenderEnded",f(e))})),e.pubads().addEventListener("impressionViewable",(function(e){t.witness("googletag.events.impressionViewable",f(e))}))}))},l.prototype.installGPTSecureSignals=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];window.googletag=window.googletag||{cmd:[]};const r=window.googletag;e&&e.length>0&&r.cmd.push((()=>{e.forEach((t=>{let{provider:e,id:i}=t;r.secureSignalProviders.push({id:e,collectorFunction:()=>Promise.resolve(i)})}))}))};const g=/^[a-f0-9]{64}$/i;l.prototype.tryIdentifyFromParams=function(t,e){const i=new RegExp(`^${t||"oeid"}$`,"i"),r=new URLSearchParams(window.location.search);let n="";for(const[t,e]of r)if(i.test(t)){n=e;break}""!=n&&(e||function(t){return g.test(t)}(n))&&this.identify((e||"e")+":"+n.toLowerCase())},l.prototype.auctionConfigFromCache=function(){const t=this.siteFromCache();return t?t.auctionConfig??null:null},l.prototype.installGPTAuctionConfigs=function(t){const e=this;e.installGPTAuctionConfigs=function(){},window.googletag=window.googletag||{cmd:[]};const i=window.googletag;i.cmd.push((function(){let r=i.pubads().getSlots();t&&(r=r.filter(t));const n=e.auctionConfigFromCache();if(n)for(const t of r){const e=t.getSizes(),i=[];for(const t of e)"fluid"!==t&&i.push({configKey:n.seller+"-"+t.getWidth()+"x"+t.getHeight(),auctionConfig:{...n,requestedSize:{width:t.getWidth()+"px",height:t.getHeight()+"px"}}});t.setConfig({componentAuction:i})}}))},l.prototype.runAdAuction=async function(t,e){if(!("runAdAuction"in navigator))throw"run-ad-auction not supported";const i=document.getElementById(t);if(!i)throw"spot not found";const r=function(t){const e=window.getComputedStyle(t,null);return{width:e.getPropertyValue("width"),height:e.getPropertyValue("height")}}(i),n=this.auctionConfigFromCache();if(!n)return!1;const s={...n,requestedSize:r,resolveToConfig:!0},o=e?.iframe??!1;o&&(s.resolveToConfig=!1);const a=await navigator.runAdAuction(s);if(!a)return i.replaceChildren(),!1;if(o){const t=document.createElement("iframe");t.src=a,t.style.border="none",t.style.width=r.width,t.style.height=r.height,i.replaceChildren(t)}else{const t=document.createElement("fencedframe");t.config=a,t.style.border="none",i.replaceChildren(t)}return!0},l.prototype.joinAdInterestGroups=async function(){if(!("joinAdInterestGroup"in navigator))throw"join-ad-interest-group not supported";const t=await this.site();if(!t.interestGroupPixel)throw"origin not enabled for protected audience apis";const e=new URL(t.interestGroupPixel),i=document.createElement("iframe");i.src=e.toString(),i.allow="join-ad-interest-group "+e.origin,i.style.display="none";const r=new Promise(((t,e)=>{window.addEventListener("message",(r=>{r.source===i.contentWindow&&("success"!==r.data.result?e():t())}))}));return document.body.appendChild(i),r},l.prototype.getTopics=async function(){if(!("browsingTopics"in document))throw"browsing-topics not supported";const t=await this.site();if(!t.getTopicsURL)throw"origin not enabled for topics api";const e=new URL(t.getTopicsURL),i=document.createElement("iframe");i.src=e.toString(),i.allow="browsing-topics "+e.origin,i.style.display="none";const r=new Promise(((t,e)=>{window.addEventListener("message",(r=>{r.source===i.contentWindow&&(r.data.error?e(new Error(r.data.error.toString())):t(r.data.result))}))}));return document.body.appendChild(i),r},l.prototype.ingestTopics=function(){this.getTopics().then((t=>{if(!t.length)return;const e=t.reduce(((t,e)=>{const i=`topics_v${e.taxonomyVersion}`;return t[i]?t[i]+=",":t[i]="",t[i]+=String(e.topic),t}),{});this.profile(e)})).catch((()=>{}))},window.optable=window.optable||{},window.optable.SDK=l,window.optable.cmd=new class{constructor(t){if(this.cmds=t,Array.isArray(this.cmds))for(const t of this.cmds)"function"==typeof t&&t()}push(t){t()}}(window.optable.cmd||[])})()})();
package/package.json CHANGED
@@ -3,10 +3,13 @@
3
3
  "main": "./lib/dist/sdk.js",
4
4
  "types": "./lib/dist/sdk.d.ts",
5
5
  "browser": "./lib/dist/sdk.js",
6
- "repository": "https://github.com/optable/optable-web-sdk",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/optable/optable-web-sdk.git"
9
+ },
7
10
  "homepage": "https://optable.co",
8
11
  "license": "SEE LICENSE IN LICENSE",
9
- "version": "v0.20.0",
12
+ "version": "v0.21.0",
10
13
  "devDependencies": {
11
14
  "@babel/core": "^7.12.3",
12
15
  "@babel/plugin-proposal-class-properties": "^7.12.1",
@@ -20,6 +23,8 @@
20
23
  "core-js": "^3.7.0",
21
24
  "jest": "^29.7.0",
22
25
  "jest-environment-jsdom": "^29.7.0",
26
+ "prettier": "^3.3.3",
27
+ "shellcheck": "^3.0.0",
23
28
  "typescript": "^5.2.2",
24
29
  "webpack": "^5.94.0",
25
30
  "webpack-cli": "^4.7.2",
@@ -27,7 +32,7 @@
27
32
  },
28
33
  "dependencies": {
29
34
  "@babel/runtime": "^7.12.5",
30
- "js-sha256": "^0.9.0",
35
+ "js-sha256": "^0.11.0",
31
36
  "regenerator-runtime": "^0.13.7"
32
37
  },
33
38
  "files": [
@@ -42,6 +47,8 @@
42
47
  "start": "tsc -b browser --watch & webpack --config=./browser/webpack.config.js --mode=development --watch --devtool=source-map",
43
48
  "build-lib": "tsc -b lib",
44
49
  "build-web": "tsc -b browser && webpack --config=./browser/webpack.config.js",
45
- "test": "jest"
50
+ "test": "jest",
51
+ "format": "prettier . --write",
52
+ "lint-scripts": "npx shellcheck scripts/*.sh"
46
53
  }
47
54
  }
@@ -1,7 +0,0 @@
1
- declare module "../sdk" {
2
- interface OptableSDK {
3
- installGPTEventListeners: () => void;
4
- installGPTSecureSignals: () => void;
5
- }
6
- }
7
- export {};
@@ -1,57 +0,0 @@
1
- import { lmpidProvider } from "../edge/targeting";
2
- import OptableSDK from "../sdk";
3
- function toWitnessProperties(event) {
4
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
5
- return {
6
- advertiserId: (_a = event.advertiserId) === null || _a === void 0 ? void 0 : _a.toString(),
7
- campaignId: (_b = event.campaignId) === null || _b === void 0 ? void 0 : _b.toString(),
8
- creativeId: (_c = event.creativeId) === null || _c === void 0 ? void 0 : _c.toString(),
9
- isEmpty: (_d = event.isEmpty) === null || _d === void 0 ? void 0 : _d.toString(),
10
- lineItemId: (_e = event.lineItemId) === null || _e === void 0 ? void 0 : _e.toString(),
11
- serviceName: (_f = event.serviceName) === null || _f === void 0 ? void 0 : _f.toString(),
12
- size: (_g = event.size) === null || _g === void 0 ? void 0 : _g.toString(),
13
- slotElementId: (_h = event.slot) === null || _h === void 0 ? void 0 : _h.getSlotElementId(),
14
- sourceAgnosticCreativeId: (_j = event.sourceAgnosticCreativeId) === null || _j === void 0 ? void 0 : _j.toString(),
15
- sourceAgnosticLineItemId: (_k = event.sourceAgnosticLineItemId) === null || _k === void 0 ? void 0 : _k.toString(),
16
- };
17
- }
18
- /*
19
- * installGPTEventListeners() sets up event listeners on the Google Publisher Tag
20
- * "slotRenderEnded" and "impressionViewable" page events, and calls witness()
21
- * on the OptableSDK instance to send log data to a DCN.
22
- */
23
- OptableSDK.prototype.installGPTEventListeners = function () {
24
- // Next time we get called is a no-op:
25
- const sdk = this;
26
- sdk.installGPTEventListeners = function () { };
27
- window.googletag = window.googletag || { cmd: [] };
28
- const gpt = window.googletag;
29
- gpt.cmd.push(function () {
30
- gpt.pubads().addEventListener("slotRenderEnded", function (event) {
31
- sdk.witness("googletag.events.slotRenderEnded", toWitnessProperties(event));
32
- });
33
- gpt.pubads().addEventListener("impressionViewable", function (event) {
34
- sdk.witness("googletag.events.impressionViewable", toWitnessProperties(event));
35
- });
36
- });
37
- };
38
- /*
39
- * installGPTSecureSignals() sets up loblaw media private ID secure signals on GPT from targeting.
40
- */
41
- OptableSDK.prototype.installGPTSecureSignals = function () {
42
- const sdk = this;
43
- sdk.installGPTSecureSignals = function () { };
44
- window.googletag = window.googletag || { cmd: [], secureSignalProviders: [] };
45
- const gpt = window.googletag;
46
- const lmpid = sdk.lmpidFromCache();
47
- if (lmpid) {
48
- gpt.cmd.push(function () {
49
- gpt.secureSignalProviders.push({
50
- id: lmpidProvider,
51
- collectorFunction: function () {
52
- return Promise.resolve(lmpid);
53
- },
54
- });
55
- });
56
- }
57
- };
@@ -1,20 +0,0 @@
1
- /// <reference types="googletag" />
2
- import { AuctionConfig } from "../edge/site";
3
- declare global {
4
- interface Navigator {
5
- runAdAuction: (config: AuctionConfig) => Promise<any>;
6
- }
7
- }
8
- type GPTSlotFilter = (slot: googletag.Slot) => boolean;
9
- type RunAdAuctionOptions = {
10
- iframe?: boolean;
11
- };
12
- declare module "../sdk" {
13
- interface OptableSDK {
14
- joinAdInterestGroups: () => Promise<void>;
15
- auctionConfigFromCache: () => AuctionConfig | null;
16
- runAdAuction: (domID: string, options?: RunAdAuctionOptions) => Promise<boolean>;
17
- installGPTAuctionConfigs: (filter?: GPTSlotFilter) => void;
18
- }
19
- }
20
- export {};
@@ -1,143 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import OptableSDK from "../sdk";
11
- /*
12
- * auctionConfigFromCache obtains the cached auction configuration for the current origin
13
- */
14
- OptableSDK.prototype.auctionConfigFromCache = function () {
15
- var _a;
16
- const siteConfig = this.siteFromCache();
17
- if (!siteConfig) {
18
- return null;
19
- }
20
- return (_a = siteConfig.auctionConfig) !== null && _a !== void 0 ? _a : null;
21
- };
22
- function elementInnerSize(element) {
23
- const style = window.getComputedStyle(element, null);
24
- return {
25
- width: style.getPropertyValue("width"),
26
- height: style.getPropertyValue("height"),
27
- };
28
- }
29
- /*
30
- * installGPTAuctionConfigs obtains the auction configuration for the current origin
31
- * and installs it into the page GPT slots, optionally filtered.
32
- */
33
- OptableSDK.prototype.installGPTAuctionConfigs = function (filter) {
34
- const sdk = this;
35
- sdk.installGPTAuctionConfigs = function () { };
36
- window.googletag = window.googletag || { cmd: [] };
37
- const gpt = window.googletag;
38
- gpt.cmd.push(function () {
39
- let slots = gpt.pubads().getSlots();
40
- if (filter) {
41
- slots = slots.filter(filter);
42
- }
43
- const siteAuctionConfig = sdk.auctionConfigFromCache();
44
- if (!siteAuctionConfig) {
45
- return;
46
- }
47
- for (const slot of slots) {
48
- const sizes = slot.getSizes();
49
- const componentAuction = [];
50
- for (const size of sizes) {
51
- if (size === "fluid") {
52
- continue;
53
- }
54
- componentAuction.push({
55
- configKey: siteAuctionConfig.seller + "-" + size.getWidth() + "x" + size.getHeight(),
56
- auctionConfig: Object.assign(Object.assign({}, siteAuctionConfig), { requestedSize: { width: size.getWidth() + "px", height: size.getHeight() + "px" } }),
57
- });
58
- }
59
- // @ts-ignore // outdated typings for componentAuction expects some legacy field names
60
- slot.setConfig({ componentAuction });
61
- }
62
- });
63
- };
64
- /*
65
- * runAdAuction runs an ad auction locally for a given spot dom ID.
66
- */
67
- OptableSDK.prototype.runAdAuction = function (domID, options) {
68
- var _a;
69
- return __awaiter(this, void 0, void 0, function* () {
70
- const supported = "runAdAuction" in navigator;
71
- if (!supported) {
72
- throw "run-ad-auction not supported";
73
- }
74
- const spot = document.getElementById(domID);
75
- if (!spot) {
76
- throw "spot not found";
77
- }
78
- const requestedSize = elementInnerSize(spot);
79
- const siteAuctionConfig = this.auctionConfigFromCache();
80
- if (!siteAuctionConfig) {
81
- return false;
82
- }
83
- const auctionConfig = Object.assign(Object.assign({}, siteAuctionConfig), { requestedSize, resolveToConfig: true });
84
- const useIframe = (_a = options === null || options === void 0 ? void 0 : options.iframe) !== null && _a !== void 0 ? _a : false;
85
- if (useIframe) {
86
- auctionConfig.resolveToConfig = false;
87
- }
88
- const result = yield navigator.runAdAuction(auctionConfig);
89
- if (!result) {
90
- spot.replaceChildren();
91
- return false;
92
- }
93
- if (useIframe) {
94
- const iframe = document.createElement("iframe");
95
- iframe.src = result;
96
- iframe.style.border = "none";
97
- iframe.style.width = requestedSize.width;
98
- iframe.style.height = requestedSize.height;
99
- spot.replaceChildren(iframe);
100
- }
101
- else {
102
- const fencedFrame = document.createElement("fencedframe");
103
- fencedFrame.config = result;
104
- fencedFrame.style.border = "none";
105
- spot.replaceChildren(fencedFrame);
106
- }
107
- return true;
108
- });
109
- };
110
- /*
111
- * joinAdInterestGroups injects an iframe into the page that tags the device into the matching audiences interest group.
112
- */
113
- OptableSDK.prototype.joinAdInterestGroups = function () {
114
- return __awaiter(this, void 0, void 0, function* () {
115
- const supported = "joinAdInterestGroup" in navigator;
116
- if (!supported) {
117
- throw "join-ad-interest-group not supported";
118
- }
119
- const siteConfig = yield this.site();
120
- if (!siteConfig.interestGroupPixel) {
121
- throw "origin not enabled for protected audience apis";
122
- }
123
- const pixelURL = new URL(siteConfig.interestGroupPixel);
124
- const pixel = document.createElement("iframe");
125
- pixel.src = pixelURL.toString();
126
- pixel.allow = "join-ad-interest-group " + pixelURL.origin;
127
- pixel.style.display = "none";
128
- const joinPromise = new Promise((resolve, reject) => {
129
- window.addEventListener("message", (event) => {
130
- if (event.source !== pixel.contentWindow) {
131
- return;
132
- }
133
- if (event.data.result === "success") {
134
- resolve();
135
- return;
136
- }
137
- reject();
138
- });
139
- });
140
- document.body.appendChild(pixel);
141
- return joinPromise;
142
- });
143
- };
@@ -1,14 +0,0 @@
1
- interface BrowsingTopic {
2
- configVersion: string;
3
- modelVersion: string;
4
- taxonomyVersion: string;
5
- topic: number;
6
- version: string;
7
- }
8
- declare module "../sdk" {
9
- interface OptableSDK {
10
- getTopics: () => Promise<BrowsingTopic[]>;
11
- ingestTopics: () => void;
12
- }
13
- }
14
- export {};