@optable/web-sdk 0.19.5 → 0.20.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__={713: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}},23:(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 s,n=[],a=t.length,h=0;for(r=0;r<a;++r)(s=t.charCodeAt(r))<128?n[h++]=s:s<2048?(n[h++]=192|s>>6,n[h++]=128|63&s):s<55296||s>=57344?(n[h++]=224|s>>12,n[h++]=128|s>>6&63,n[h++]=128|63&s):(s=65536+((1023&s)<<10|1023&t.charCodeAt(++r)),n[h++]=240|s>>18,n[h++]=128|s>>12&63,n[h++]=128|s>>6&63,n[h++]=128|63&s);t=n}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=[],u=[];for(r=0;r<64;++r){var d=t[r]||0;c[r]=92^d,u[r]=54^d}Sha256.call(this,e,i),this.update(u),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,s=0,n=t.length,a=this.blocks;s<n;){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;s<n&&o<64;++s)a[o>>2]|=t[s]<<SHIFT[3&o++];else for(o=this.start;s<n&&o<64;++s)(r=t.charCodeAt(s))<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(++s)),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,s,n,a,h,c=this.h0,u=this.h1,d=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=u&d,t=0;t<64;t+=4)this.first?(this.is224?(s=300032,g=(o=w[0]-1413257819)-150054599<<0,p=o+24177077<<0):(s=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=(s=c&u)^c&d^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=(n=p&c)^p&u^s,f=d+(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=((d=o+(e+r)<<0)>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),r=(a=d&p)^d&c^n,_=u+(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=((u=o+(e+r)<<0)>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),r=(h=u&d)^u&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+u<<0,this.h2=this.h2+d<<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,s=this.h5,n=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[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]+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];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,s=this.h5,n=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,s>>24&255,s>>16&255,s>>8&255,255&s,n>>24&255,n>>16&255,n>>8&255,255&n];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__(713),e=__webpack_require__.n(t);const i="v0.19.5",r={insecure:!1,cookies:!0,initPassport:!0};async function o(t){const e=await u("/config",t,{method:"GET",headers:{Accept:"application/json"}});return new c(t).setSite(e),e}var s;!function(t){t[t.DeviceID=1]="DeviceID",t[t.InAppImpression=2]="InAppImpression",t[t.PersonID=3]="PersonID"}(s||(s={}));const n="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:s.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===n));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 u(t,e,r){const o=await globalThis.fetch(function(t,e,r){const{site:o,host:s,insecure:n,cookies:a}=e,h=new URL(`${o}${t}`,`${n?"http":"https"}://${s}`);if(h.searchParams.set("osdk",`web-${i}`),a)h.searchParams.set("cookies","yes");else{const t=new c(e).getPassport();h.searchParams.set("cookies","no"),h.searchParams.set("passport",t||"")}const u={...r};return u.credentials="include",new Request(h.toString(),u)}(t,e,r)),s=o.headers.get("Content-Type")?.startsWith("application/json")?await o.json():await o.text();if(!o.ok)throw new Error(s.error);return s.passport&&(new c(e).setPassport(s.passport),delete s.passport),s}var d=__webpack_require__(23);class p{constructor(t){var i;e()(this,"dcn",void 0),e()(this,"init",void 0),this.dcn=(i=t,{...r,...i});const s=()=>{};this.init=this.dcn.initPassport?o(this.dcn).then(s).catch(s):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 u("/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 u("/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 u(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 u("/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 u("/profile",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 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);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:n,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){if(!("runAdAuction"in navigator))throw"run-ad-auction not supported";const e=document.getElementById(t);if(!e)throw"spot not found";const i=function(t){const e=window.getComputedStyle(t,null);return{width:e.getPropertyValue("width"),height:e.getPropertyValue("height")}}(e),r=this.auctionConfigFromCache();if(!r)return!1;const o={...r,requestedSize:i,resolveToConfig:!0},s=await navigator.runAdAuction(o);if(!s)return e.replaceChildren(),!1;const n=document.createElement("fencedframe");return n.config=s,n.style.border="none",e.replaceChildren(n),!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 __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||[])})()})();
@@ -6,11 +6,14 @@ declare global {
6
6
  }
7
7
  }
8
8
  type GPTSlotFilter = (slot: googletag.Slot) => boolean;
9
+ type RunAdAuctionOptions = {
10
+ iframe?: boolean;
11
+ };
9
12
  declare module "../sdk" {
10
13
  interface OptableSDK {
11
14
  joinAdInterestGroups: () => Promise<void>;
12
15
  auctionConfigFromCache: () => AuctionConfig | null;
13
- runAdAuction: (domID: string) => Promise<boolean>;
16
+ runAdAuction: (domID: string, options?: RunAdAuctionOptions) => Promise<boolean>;
14
17
  installGPTAuctionConfigs: (filter?: GPTSlotFilter) => void;
15
18
  }
16
19
  }
@@ -64,7 +64,8 @@ OptableSDK.prototype.installGPTAuctionConfigs = function (filter) {
64
64
  /*
65
65
  * runAdAuction runs an ad auction locally for a given spot dom ID.
66
66
  */
67
- OptableSDK.prototype.runAdAuction = function (domID) {
67
+ OptableSDK.prototype.runAdAuction = function (domID, options) {
68
+ var _a;
68
69
  return __awaiter(this, void 0, void 0, function* () {
69
70
  const supported = "runAdAuction" in navigator;
70
71
  if (!supported) {
@@ -80,15 +81,29 @@ OptableSDK.prototype.runAdAuction = function (domID) {
80
81
  return false;
81
82
  }
82
83
  const auctionConfig = Object.assign(Object.assign({}, siteAuctionConfig), { requestedSize, resolveToConfig: true });
83
- const fencedFrameConfig = yield navigator.runAdAuction(auctionConfig);
84
- if (!fencedFrameConfig) {
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) {
85
90
  spot.replaceChildren();
86
91
  return false;
87
92
  }
88
- const fencedFrame = document.createElement("fencedframe");
89
- fencedFrame.config = fencedFrameConfig;
90
- fencedFrame.style.border = "none";
91
- spot.replaceChildren(fencedFrame);
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
+ }
92
107
  return true;
93
108
  });
94
109
  };
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "v0.19.5"
2
+ "version": "v0.20.0"
3
3
  }
@@ -4,6 +4,7 @@ type OptableConfig = {
4
4
  insecure?: boolean;
5
5
  cookies?: boolean;
6
6
  initPassport?: boolean;
7
+ identityHeaderName?: string;
7
8
  };
8
9
  declare function getConfig(config: OptableConfig): Required<OptableConfig>;
9
10
  export { OptableConfig, getConfig };
@@ -2,6 +2,7 @@ const DCN_DEFAULTS = {
2
2
  insecure: false,
3
3
  cookies: true,
4
4
  initPassport: true,
5
+ identityHeaderName: "X-Optable-Visitor",
5
6
  };
6
7
  function getConfig(config) {
7
8
  return Object.assign(Object.assign({}, DCN_DEFAULTS), config);
@@ -14,19 +14,19 @@ function buildRequest(path, config, init) {
14
14
  const proto = insecure ? "http" : "https";
15
15
  const url = new URL(`${site}${path}`, `${proto}://${host}`);
16
16
  url.searchParams.set("osdk", `web-${buildInfo.version}`);
17
+ const requestInit = Object.assign({}, init);
17
18
  if (cookies) {
19
+ requestInit.credentials = "include";
18
20
  url.searchParams.set("cookies", "yes");
19
21
  }
20
22
  else {
21
23
  const ls = new LocalStorage(config);
22
24
  const pass = ls.getPassport();
23
25
  url.searchParams.set("cookies", "no");
24
- url.searchParams.set("passport", pass ? pass : "");
26
+ requestInit.headers = new Headers();
27
+ pass && requestInit.headers.set(config.identityHeaderName, pass);
25
28
  }
26
- const requestInit = Object.assign({}, init);
27
- requestInit.credentials = "include";
28
- const request = new Request(url.toString(), requestInit);
29
- return request;
29
+ return new Request(url.toString(), requestInit);
30
30
  }
31
31
  function fetch(path, config, init) {
32
32
  return __awaiter(this, void 0, void 0, function* () {
@@ -36,15 +36,9 @@ function fetch(path, config, init) {
36
36
  if (!response.ok) {
37
37
  throw new Error(data.error);
38
38
  }
39
- if (data.passport) {
39
+ if (response.headers.has(config.identityHeaderName)) {
40
40
  const ls = new LocalStorage(config);
41
- ls.setPassport(data.passport);
42
- // We delete the passport attribute from the returned payload. This is because
43
- // the targeting edge handler was initially made to return targeting data directly
44
- // in the form of 'key values' on the returned JSON payload -- if we don't delete
45
- // the `passport` attribute here, it may end up sent as targeting data to ad servers.
46
- // Not the end of the world, but something we want to avoid due to passport size.
47
- delete data.passport;
41
+ ls.setPassport(response.headers.get(config.identityHeaderName) || "");
48
42
  }
49
43
  return data;
50
44
  });
@@ -0,0 +1,11 @@
1
+ import type { OptableConfig } from "../config";
2
+ import { User } from "./rtb2";
3
+ type TokenizeResponse = {
4
+ User: User;
5
+ };
6
+ type TokenizeRequest = {
7
+ id: string;
8
+ };
9
+ declare function Tokenize(config: Required<OptableConfig>, id: string): Promise<TokenizeResponse>;
10
+ export { Tokenize, TokenizeRequest, TokenizeResponse };
11
+ export default Tokenize;
@@ -0,0 +1,15 @@
1
+ import { fetch } from "../core/network";
2
+ function Tokenize(config, id) {
3
+ let request = {
4
+ id: id,
5
+ };
6
+ return fetch("/v1/tokenize", config, {
7
+ method: "POST",
8
+ headers: {
9
+ "Content-Type": "application/json",
10
+ },
11
+ body: JSON.stringify(request),
12
+ });
13
+ }
14
+ export { Tokenize };
15
+ export default Tokenize;
package/lib/dist/sdk.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { WitnessProperties } from "./edge/witness";
3
3
  import type { ProfileTraits } from "./edge/profile";
4
4
  import { SiteResponse } from "./edge/site";
5
5
  import { TargetingKeyValues, TargetingResponse, PrebidORTB2 } from "./edge/targeting";
6
+ import { TokenizeResponse } from "./edge/tokenize";
6
7
  declare class OptableSDK {
7
8
  static version: string;
8
9
  dcn: Required<OptableConfig>;
@@ -29,6 +30,7 @@ declare class OptableSDK {
29
30
  targetingKeyValuesFromCache(): TargetingKeyValues;
30
31
  witness(event: string, properties?: WitnessProperties): Promise<void>;
31
32
  profile(traits: ProfileTraits): Promise<void>;
33
+ tokenize(id: string): Promise<TokenizeResponse>;
32
34
  static eid(email: string): string;
33
35
  static cid(ppid: string, variant?: number): string;
34
36
  static TargetingKeyValues(tdata: TargetingResponse): TargetingKeyValues;
package/lib/dist/sdk.js CHANGED
@@ -16,6 +16,7 @@ import { TargetingKeyValues, Targeting, TargetingFromCache, TargetingClearCache,
16
16
  import { Witness } from "./edge/witness";
17
17
  import { Profile } from "./edge/profile";
18
18
  import { sha256 } from "js-sha256";
19
+ import { Tokenize } from "./edge/tokenize";
19
20
  class OptableSDK {
20
21
  constructor(dcn) {
21
22
  this.dcn = getConfig(dcn);
@@ -88,6 +89,12 @@ class OptableSDK {
88
89
  return Profile(this.dcn, traits);
89
90
  });
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
+ }
91
98
  static eid(email) {
92
99
  return email ? "e:" + sha256.hex(email.toLowerCase().trim()) : "";
93
100
  }
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "repository": "https://github.com/optable/optable-web-sdk",
7
7
  "homepage": "https://optable.co",
8
8
  "license": "SEE LICENSE IN LICENSE",
9
- "version": "v0.19.5",
9
+ "version": "v0.20.0",
10
10
  "devDependencies": {
11
11
  "@babel/core": "^7.12.3",
12
12
  "@babel/plugin-proposal-class-properties": "^7.12.1",
@@ -21,7 +21,7 @@
21
21
  "jest": "^29.7.0",
22
22
  "jest-environment-jsdom": "^29.7.0",
23
23
  "typescript": "^5.2.2",
24
- "webpack": "^5.76.0",
24
+ "webpack": "^5.94.0",
25
25
  "webpack-cli": "^4.7.2",
26
26
  "whatwg-fetch": "^3.6.20"
27
27
  },