UNPKG

@atlas-kitchen/adyen-web

Version:
3 lines (2 loc) 783 B
import{hasOwnProperty as e}from"./hasOwnProperty.js";const t=(t,a,r,n)=>r=>{var o;const s={};if((r.origin||(null===(o=r.originalEvent)||void 0===o?void 0:o.origin))!==t)return"Message was not sent from the expected domain";if("string"!=typeof r.data)return"Event data was not of type string";if(!r.data.length)return"Invalid event data string";try{const t=JSON.parse(r.data);if(!e(t,"type")||t.type!==n)return"Event data was not of expected type";a(t)}catch(e){return s.type=`${n}-JSON-parse-error`,s.comment="failed to JSON parse event.data",s.extraInfo=`event.data = ${r.data}`,s.eventDataRaw=r.data,console.debug("get-process-message-handler::CATCH::Un-parseable JSON:: parseErrorObj=",s),!1}return!0};export{t as default}; //# sourceMappingURL=get-process-message-handler.js.map