79698904

Date: 2025-07-11 23:19:17
Score: 1
Natty:
Report link

(()=>{"use strict";var e={d:(t,r)=>{for(var s in r)e.o(r,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:r[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>i});const r="SHARED_STORAGE_RESPONSE",s={SET_ITEM:"setItem",GET_ITEM:"getItem",REMOVE_ITEM:"removeItem"},o={LOCAL_STORAGE:"localStorage",SESSION_STORAGE:"sessionStorage"},i=new class SharedStorage{constructor(){this.messageListener=e=>{if(!this.isAllowedOrigin(e.origin))return void console.warn("unknown origin",e.origin);let t;try{t=JSON.parse(e.data)}catch(e){return void console.warn("Unable to parse message",e)}if(!t.id)return void console.warn("unknown request id");if(!t.payload)return void console.warn("no payload in the message");if("SHARED_STORAGE_REQUEST"!==t.type)return console.warn("Unknown message type ",e.type),void this.sendError(e,t.id,"unexpected message type");const{payload:r={}}=t;if(!this.isSupportedMethod(r.method))return console.warn("Unsupported method",r.method),void this.sendError(e,t.id,"Unsupported method");if(!r.param)return console.warn("Missing params"),void this.sendError(e,t.id,"Missing params");try{const s=this.persistToLocalStorage(r);this.sendResult(e,t.id,s)}catch(r){this.sendError(e,t.id,r.message)}},this.persistToLocalStorage=e=>{const{method:t,storage:r=o.LOCAL_STORAGE,param:i={}}=e||{},{key:n}=i;if(!this.isSupportedStorage(r))throw new Error("Unsupported storage");const a=window[r];switch(t){case s.SET_ITEM:return a.setItem(n,i.value);case s.GET_ITEM:return a.getItem(n);case s.REMOVE_ITEM:return a.removeItem(n);default:return console.warn("Unsupported method"),null}},this.sendResult=(e,t,s)=>{const o={type:r,id:t,payload:{status:"SUCCESS",value:s}};e.source.postMessage(JSON.stringify(o),e.origin)},this.sendError=(e,t,s)=>{const o={type:r,id:t,payload:{status:"ERROR",value:s}};e.source.postMessage(JSON.stringify(o),e.origin)},this.getAllowedOrigins=()=>{const e=document.querySelector('meta[name="adotcom_uri"]'),t=e&&e.getAttribute("content");t&&(this.allowedOrigins=t.split(",").map((e=>e.trim())))},this.isSupportedMethod=e=>-1!==Object.keys(s).map((e=>s[e])).indexOf(e),this.isSupportedStorage=e=>-1!==Object.keys(o).map((e=>o[e])).indexOf(e),this.isAllowedOrigin=e=>{if(-1!==this.allowedOrigins.indexOf(e))return!0;const t=e&&e.replace(/:443/,"");if(-1!==this.allowedOrigins.indexOf(t))return!0;try{const t=new URL(e);if(t.port&&443!==t.port&&80!==t.port)return!0}catch(e){return!1}return!1},this.allowedOrigins=[],this.getAllowedOrigins(),window.addEventListener("message",this.messageListener)}};window.adobe_dc_sdk=t})();

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Single line (0.5):
  • Low reputation (1):
Posted by: marcelo genchi