@optable/web-sdk 0.19.3 → 0.19.5

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 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=[],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,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,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?(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&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=(s=p&c)^p&u^n,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^s,_=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,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__(713),e=__webpack_require__.n(t);const i="v0.19.3",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 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 u(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}`);if(a)h.search=new URLSearchParams({cookies:"yes",osdk:`web-${i}`}).toString();else{const t=new c(e).getPassport();h.search=new URLSearchParams({cookies:"no",passport:t||"",osdk:`web-${i}`}).toString()}const u={...r};return u.credentials="include",new Request(h.toString(),u)}(t,e,r)),n=o.headers.get("Content-Type")?.startsWith("application/json")?await o.json():await o.text();if(!o.ok)throw new Error(n.error);return n.passport&&(new c(e).setPassport(n.passport),delete n.passport),n}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 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 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: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){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},n=await navigator.runAdAuction(o);if(!n)return e.replaceChildren(),!1;const s=document.createElement("fencedframe");return s.config=n,s.style.border="none",e.replaceChildren(s),!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__={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||[])})()})();
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "v0.19.3"
2
+ "version": "v0.19.5"
3
3
  }
@@ -1,4 +1,5 @@
1
1
  import type { OptableConfig } from "../config";
2
+ declare function buildRequest(path: string, config: Required<OptableConfig>, init?: RequestInit): Request;
2
3
  declare function fetch<T>(path: string, config: Required<OptableConfig>, init?: RequestInit): Promise<T>;
3
- export { fetch };
4
+ export { fetch, buildRequest };
4
5
  export default fetch;
@@ -13,20 +13,15 @@ function buildRequest(path, config, init) {
13
13
  const { site, host, insecure, cookies } = config;
14
14
  const proto = insecure ? "http" : "https";
15
15
  const url = new URL(`${site}${path}`, `${proto}://${host}`);
16
+ url.searchParams.set("osdk", `web-${buildInfo.version}`);
16
17
  if (cookies) {
17
- url.search = new URLSearchParams({
18
- cookies: "yes",
19
- osdk: `web-${buildInfo.version}`,
20
- }).toString();
18
+ url.searchParams.set("cookies", "yes");
21
19
  }
22
20
  else {
23
21
  const ls = new LocalStorage(config);
24
22
  const pass = ls.getPassport();
25
- url.search = new URLSearchParams({
26
- cookies: "no",
27
- passport: pass ? pass : "",
28
- osdk: `web-${buildInfo.version}`,
29
- }).toString();
23
+ url.searchParams.set("cookies", "no");
24
+ url.searchParams.set("passport", pass ? pass : "");
30
25
  }
31
26
  const requestInit = Object.assign({}, init);
32
27
  requestInit.credentials = "include";
@@ -54,5 +49,5 @@ function fetch(path, config, init) {
54
49
  return data;
55
50
  });
56
51
  }
57
- export { fetch };
52
+ export { fetch, buildRequest };
58
53
  export default fetch;
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.3",
9
+ "version": "v0.19.5",
10
10
  "devDependencies": {
11
11
  "@babel/core": "^7.12.3",
12
12
  "@babel/plugin-proposal-class-properties": "^7.12.1",
@@ -22,7 +22,8 @@
22
22
  "jest-environment-jsdom": "^29.7.0",
23
23
  "typescript": "^5.2.2",
24
24
  "webpack": "^5.76.0",
25
- "webpack-cli": "^4.7.2"
25
+ "webpack-cli": "^4.7.2",
26
+ "whatwg-fetch": "^3.6.20"
26
27
  },
27
28
  "dependencies": {
28
29
  "@babel/runtime": "^7.12.5",