Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@moneyhash/js-sdk

Package Overview
Dependencies
Maintainers
0
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@moneyhash/js-sdk - npm Package Compare versions

Comparing version 1.0.0-beta.2 to 1.0.0-beta.3

dist/sdkEmbed-c8c76cbd.js

2

dist/headless.cjs.js

@@ -1,1 +0,1 @@

"use strict";var B=Object.defineProperty,O=Object.defineProperties;var Y=Object.getOwnPropertyDescriptors;var M=Object.getOwnPropertySymbols;var J=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var _=(a,e,t)=>e in a?B(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,k=(a,e)=>{for(var t in e||(e={}))J.call(e,t)&&_(a,t,e[t]);if(M)for(var t of M(e))z.call(e,t)&&_(a,t,e[t]);return a},F=(a,e)=>O(a,Y(e));var p=(a,e,t)=>(_(a,typeof e!="symbol"?e+"":e,t),t),K=(a,e,t)=>{if(!e.has(a))throw TypeError("Cannot "+t)};var u=(a,e,t)=>{if(e.has(a))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(a):e.set(a,t)};var y=(a,e,t)=>(K(a,e,"access private method"),t);var w=(a,e,t)=>new Promise((r,s)=>{var d=o=>{try{n(t.next(o))}catch(l){s(l)}},i=o=>{try{n(t.throw(o))}catch(l){s(l)}},n=o=>o.done?r(o.value):Promise.resolve(o.value).then(d,i);n((t=t.apply(a,e)).next())});const g=require("./sdkEmbed-b6ce67bb.cjs");function G(){return typeof window!="undefined"}const m=class{constructor(){G()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=g.getIframeUrl(),t=new URL(`${e}/embed/headless-sdk`);t.searchParams.set("sdk","true"),t.searchParams.set("parent",window.location.origin),t.searchParams.set("version","js@1.0.0-beta.2");const r=document.createElement("iframe");r.id="moneyhash-headless-sdk",r.src=t.toString(),r.hidden=!0,document.body.appendChild(r),m.messagingService=new g.MessagingService({target:r.contentWindow,targetOrigin:e}),m.isCommunicationReady=new Promise(s=>{var i;const d=n=>{var o;n.data.type==="headlessSDK:init"&&(s(),(o=m.messagingService)==null||o.removeListener(d))};(i=m.messagingService)==null||i.onReceive(d)})}request(r){return w(this,arguments,function*({api:e,payload:t}){return yield m.isCommunicationReady,new Promise((s,d)=>{var n,o;(n=m.messagingService)==null||n.send({type:e,data:t});const i=l=>{var b;const{type:c,data:h}=l.data;c===e&&(h.status==="resolved"?s(h.payload):d(h.payload),(b=m.messagingService)==null||b.removeListener(i))};(o=m.messagingService)==null||o.onReceive(i)})})}};let P=m;p(P,"messagingService",null),p(P,"isCommunicationReady");class Q{constructor(){p(this,"promise");p(this,"resolve");p(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function X(){return"https://vault-staging.moneyhash.io"}function T(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault.moneyhash.io"}function Z(a){return(Array.isArray(a)?a.length:Object.keys(a).length)===0}function ee(a,e){return new Promise((t,r)=>{if(document.getElementById(e)){t(void 0);return}const d=document.createElement("script");d.src=a,d.id=e,d.addEventListener("load",()=>{t(void 0)}),d.addEventListener("error",()=>{r(new Error("Script failed to load"))}),document.body.appendChild(d)})}function $(){var e;return(e=window.API_URL)!=null?e:"https://web.moneyhash.io"}const j=new Set(["method","customerBalance","savedCard"]);var S,q,I,V,A,N,E,H,L,W,U,D,R,x;class te{constructor(e){u(this,S);u(this,I);u(this,A);u(this,E);u(this,L);u(this,U);u(this,R);p(this,"options");p(this,"sdkApiHandler",new P);p(this,"sdkEmbed");p(this,"vaultSubmitListener",{current:null});this.options=e,this.sdkEmbed=new g.SDKEmbed(F(k({},e),{headless:!0})),y(this,L,W).call(this,this.vaultSubmitListener)}getIntentDetails(e){return this.sdkApiHandler.request({api:"sdk:getIntentDetails",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}getIntentMethods(e){return this.sdkApiHandler.request({api:"sdk:getIntentMethods",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}proceedWith({intentId:e,type:t,id:r,metaData:s}){return g.throwIf(!j.has(t),`type must be a valid one (${[...j].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:r,lang:this.sdkEmbed.lang,metaData:s}})}resetSelectedMethod(e){return this.sdkApiHandler.request({api:"sdk:resetSelectedMethod",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}deleteCard({cardId:e,intentSecret:t}){return g.throwIf(this.options.type==="payout","deleteCard is allowed only for payment intent!"),this.sdkApiHandler.request({api:"sdk:deleteCard",payload:{cardId:e,intentSecret:t,lang:this.sdkEmbed.lang}})}payWithApplePay(l){return w(this,arguments,function*({intentId:e,currency:t,amount:r,countryCode:s,onCancel:d=()=>{},onError:i,onComplete:n,billingData:o={}}){if(yield ee("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)return;const c=new ApplePaySession(3,{countryCode:s,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${r}`}}),{__providerId__:h,state:b,intent:C}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(b==="INTENT_FORM"){if(Z(o))throw new Error("Billing data is missing while calling payWithApplePay");yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"APPLE_PAY",providerId:h,lang:this.sdkEmbed.lang,billingData:o}})}}catch(v){throw yield this.resetSelectedMethod(e),v}c.onvalidatemerchant=v=>{fetch(`${$()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:C.secret,validation_url:v.validationURL})}).then(f=>f.ok?f.json():Promise.reject()).then(f=>c.completeMerchantValidation(f)).catch(i)},c.onpaymentauthorized=v=>{fetch(`${$()}/api/v1/providers/applepay/token/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({token_data:v.payment.token,secret:C.secret})}).then(f=>f.ok?f.json():Promise.reject()).then(()=>{c.completePayment(ApplePaySession.STATUS_SUCCESS),n()}).catch(()=>{c.completePayment(ApplePaySession.STATUS_FAILURE),i()})},c.oncancel=d,c.begin()})}renderForm({selector:e,intentId:t}){return g.throwIf(!e,"selector is required for renderForm"),g.throwIf(!t,"intentId is required for renderForm"),this.sdkEmbed.render({selector:e,intentId:t})}setLocale(e){return this.sdkEmbed.setLocale(e)}removeEventListeners(){return this.sdkEmbed.abortService()}elements({styles:e}){const t=[];return y(this,E,H).call(this,t),{create:({elementType:r,elementOptions:s})=>{const d=new Map,i=document.querySelector(s.selector);return g.throwIf(!i,`Couldn't find an element with selector ${s.selector}!`),i.classList.add("moneyhash-element"),t.push(n=>{var l,c;const{type:o}=n.data;o===`${r}@focus`&&(i.classList.add("moneyhash-element_focus"),(l=d.get(`${r}@focus`))==null||l()),o===`${r}@blur`&&(i.classList.remove("moneyhash-element_focus"),(c=d.get(`${r}@blur`))==null||c())}),{mount:()=>y(this,U,D).call(this,{container:i,elementType:r,elementOptions:s,styles:k(k({},e),s.styles)}),on:(n,o)=>{d.set(`${r}@${n}`,o)}}}}}submitForm(d){return w(this,arguments,function*({intentId:e,accessToken:t,billingData:r,shippingData:s}){const i=new Q;let n,o;t&&(this.vaultSubmitListener.current=l=>{const{type:c,data:h}=l.data;c==="vaultSubmit:success"&&i.resolve(h),c==="vaultSubmit:error"&&i.reject(h)},o=y(this,R,x).call(this,t),n=yield i.promise),yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"CARD",lang:this.sdkEmbed.lang,billingData:r,shippingData:s,cardEmbed:n}}),o&&o.remove()})}submitCvv(r){return w(this,arguments,function*({intentId:e,cvv:t}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,lang:this.sdkEmbed.lang}})})}renderUrl(e,t){switch(t){case"IFRAME":return y(this,S,q).call(this,e);case"POPUP_IFRAME":return y(this,I,V).call(this,e);case"REDIRECT":return y(this,A,N).call(this,e);default:return null}}}S=new WeakSet,q=function(e){const t=document.querySelector("#rendered-url-iframe-container"),r=document.createElement("iframe");return r.src=e,r.style.setProperty("border","0","important"),r.style.setProperty("width","100vw","important"),r.style.setProperty("height","100vh","important"),t==null||t.replaceChildren(r),r},I=new WeakSet,V=function(e){return window.open(`${e}`,"","width=600,height=400,left=200,top=200")},A=new WeakSet,N=function(e){return window.open(e,"_blank")},E=new WeakSet,H=function(e){const t=r=>{e.forEach(s=>{s(r)})};window.addEventListener("message",t)},L=new WeakSet,W=function(e){const t=r=>{e.current&&e.current(r)};window.addEventListener("message",t)},U=new WeakSet,D=function({container:e,elementType:t,elementOptions:r,styles:s}){var o,l;const d=T(),i=new URL(`${d}/vaultField/vaultField.html`);i.searchParams.set("parent",window.location.origin),i.searchParams.set("type",t),i.searchParams.set("placeholder",(o=r.placeholder)!=null?o:""),i.searchParams.set("color",(s==null?void 0:s.color)||"#000"),i.searchParams.set("placeholderColor",(s==null?void 0:s.placeholderColor)||"#ccc"),i.searchParams.set("backgroundColor",(s==null?void 0:s.backgroundColor)||"transparent");const n=document.createElement("iframe");n.src=i.toString(),n.style.height=(l=r.height)!=null?l:"40px",n.style.setProperty("overflow","hidden","important"),n.style.setProperty("display","block","important"),n.style.setProperty("width","100%","important"),n.style.setProperty("maxWidth","100%","important"),n.style.setProperty("border","0","important"),n.style.setProperty("margin","0","important"),n.style.setProperty("padding","0","important"),n.style.setProperty("userSelect","none","important"),n.style.setProperty("colorScheme","light only","important"),e.replaceChildren(n)},R=new WeakSet,x=function(e){const t=T(),r=X(),s=new URL(`${t}/vaultSubmit/vaultSubmit.html`);s.searchParams.set("parent",window.location.origin),s.searchParams.set("vault_api_url",`${r}/api/v1/tokens/`),s.searchParams.set("access_token",e);const d=document.createElement("iframe");return d.id="moneyhash-submit-iframe",d.src=s.toString(),d.hidden=!0,document.body.appendChild(d),d};module.exports=te;
"use strict";var B=Object.defineProperty,O=Object.defineProperties;var Y=Object.getOwnPropertyDescriptors;var M=Object.getOwnPropertySymbols;var J=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var _=(n,e,t)=>e in n?B(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,E=(n,e)=>{for(var t in e||(e={}))J.call(e,t)&&_(n,t,e[t]);if(M)for(var t of M(e))z.call(e,t)&&_(n,t,e[t]);return n},F=(n,e)=>O(n,Y(e));var m=(n,e,t)=>(_(n,typeof e!="symbol"?e+"":e,t),t),K=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var u=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)};var y=(n,e,t)=>(K(n,e,"access private method"),t);var P=(n,e,t)=>new Promise((r,s)=>{var d=i=>{try{a(t.next(i))}catch(l){s(l)}},o=i=>{try{a(t.throw(i))}catch(l){s(l)}},a=i=>i.done?r(i.value):Promise.resolve(i.value).then(d,o);a((t=t.apply(n,e)).next())});const g=require("./sdkEmbed-daf42004.cjs");function G(){return typeof window!="undefined"}const h=class{constructor(){G()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=g.getIframeUrl(),t=new URL(`${e}/embed/headless-sdk`);t.searchParams.set("sdk","true"),t.searchParams.set("parent",window.location.origin),t.searchParams.set("version","js@1.0.0-beta.3");const r=document.createElement("iframe");r.id="moneyhash-headless-sdk",r.src=t.toString(),r.hidden=!0,document.body.appendChild(r),h.messagingService=new g.MessagingService({target:r.contentWindow,targetOrigin:e}),h.isCommunicationReady=new Promise(s=>{var o;const d=a=>{var i;a.data.type==="headlessSDK:init"&&(s(),(i=h.messagingService)==null||i.removeListener(d))};(o=h.messagingService)==null||o.onReceive(d)})}request(r){return P(this,arguments,function*({api:e,payload:t}){return yield h.isCommunicationReady,new Promise((s,d)=>{var a,i;(a=h.messagingService)==null||a.send({type:e,data:t});const o=l=>{var f;const{type:c,data:p}=l.data;c===e&&(p.status==="resolved"?s(p.payload):d(p.payload),(f=h.messagingService)==null||f.removeListener(o))};(i=h.messagingService)==null||i.onReceive(o)})})}};let b=h;m(b,"messagingService",null),m(b,"isCommunicationReady");class Q{constructor(){m(this,"promise");m(this,"resolve");m(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function X(){return"https://vault-staging.moneyhash.io"}function T(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault.moneyhash.io"}function Z(n){return(Array.isArray(n)?n.length:Object.keys(n).length)===0}function ee(n,e){return new Promise((t,r)=>{if(document.getElementById(e)){t(void 0);return}const d=document.createElement("script");d.src=n,d.id=e,d.addEventListener("load",()=>{t(void 0)}),d.addEventListener("error",()=>{r(new Error("Script failed to load"))}),document.body.appendChild(d)})}function $(){var e;return(e=window.API_URL)!=null?e:"https://web.moneyhash.io"}const j=new Set(["method","customerBalance","savedCard"]);var I,q,k,H,S,V,A,N,L,W,U,D,R,x;class te{constructor(e){u(this,I);u(this,k);u(this,S);u(this,A);u(this,L);u(this,U);u(this,R);m(this,"options");m(this,"sdkApiHandler",new b);m(this,"sdkEmbed");m(this,"vaultSubmitListener",{current:null});this.options=e,this.sdkEmbed=new g.SDKEmbed(F(E({},e),{headless:!0})),y(this,L,W).call(this,this.vaultSubmitListener)}getIntentDetails(e){return this.sdkApiHandler.request({api:"sdk:getIntentDetails",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}getIntentMethods(e){return this.sdkApiHandler.request({api:"sdk:getIntentMethods",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}proceedWith({intentId:e,type:t,id:r,metaData:s}){return g.throwIf(!j.has(t),`type must be a valid one (${[...j].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:r,lang:this.sdkEmbed.lang,metaData:s}})}resetSelectedMethod(e){return this.sdkApiHandler.request({api:"sdk:resetSelectedMethod",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}deleteCard({cardId:e,intentSecret:t}){return g.throwIf(this.options.type==="payout","deleteCard is allowed only for payment intent!"),this.sdkApiHandler.request({api:"sdk:deleteCard",payload:{cardId:e,intentSecret:t,lang:this.sdkEmbed.lang}})}payWithApplePay(l){return P(this,arguments,function*({intentId:e,currency:t,amount:r,countryCode:s,onCancel:d=()=>{},onError:o,onComplete:a,billingData:i={}}){if(yield ee("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)return;const c=new ApplePaySession(3,{countryCode:s,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${r}`}}),{__providerId__:p,state:f,intent:C}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(f==="INTENT_FORM"){if(Z(i))throw new Error("Billing data is missing while calling payWithApplePay");yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"APPLE_PAY",providerId:p,lang:this.sdkEmbed.lang,billingData:i}})}}catch(w){throw yield this.resetSelectedMethod(e),w}c.onvalidatemerchant=w=>{fetch(`${$()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:C.secret,validation_url:w.validationURL})}).then(v=>v.ok?v.json():Promise.reject()).then(v=>c.completeMerchantValidation(v)).catch(o)},c.onpaymentauthorized=w=>{fetch(`${$()}/api/v1/providers/applepay/token/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({token_data:w.payment.token,secret:C.secret})}).then(v=>v.ok?v.json():Promise.reject()).then(()=>{c.completePayment(ApplePaySession.STATUS_SUCCESS),a()}).catch(()=>{c.completePayment(ApplePaySession.STATUS_FAILURE),o()})},c.oncancel=d,c.begin()})}renderForm({selector:e,intentId:t}){return g.throwIf(!e,"selector is required for renderForm"),g.throwIf(!t,"intentId is required for renderForm"),this.sdkEmbed.render({selector:e,intentId:t})}setLocale(e){return this.sdkEmbed.setLocale(e)}removeEventListeners(){return this.sdkEmbed.abortService()}elements({styles:e}){const t=[];return y(this,A,N).call(this,t),{create:({elementType:r,elementOptions:s})=>{const d=new Map,o=document.querySelector(s.selector);return g.throwIf(!o,`Couldn't find an element with selector ${s.selector}!`),o.classList.add("MoneyHashElement"),t.push(a=>{var l,c,p;const{type:i}=a.data;i===`${r}@focus`&&(o.classList.add("MoneyHashElement--focus"),(l=d.get(`${r}@focus`))==null||l()),i===`${r}@blur`&&(o.classList.remove("MoneyHashElement--focus"),(c=d.get(`${r}@blur`))==null||c()),i===`${r}@changeInput`&&((p=d.get(`${r}@changeInput`))==null||p())}),{mount:()=>y(this,U,D).call(this,{container:o,elementType:r,elementOptions:s,styles:E(E({},e),s.styles)}),on:(a,i)=>{d.set(`${r}@${a}`,i)}}}}}submitForm(d){return P(this,arguments,function*({intentId:e,accessToken:t,billingData:r,shippingData:s}){const o=new Q;let a,i;t&&(this.vaultSubmitListener.current=c=>{const{type:p,data:f}=c.data;p==="vaultSubmit:success"&&o.resolve(f),p==="vaultSubmit:error"&&o.reject(f)},i=y(this,R,x).call(this,t),a=yield o.promise);const l=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"CARD",lang:this.sdkEmbed.lang,billingData:r,shippingData:s,cardEmbed:a}});return i&&i.remove(),l})}submitCvv(r){return P(this,arguments,function*({intentId:e,cvv:t}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,lang:this.sdkEmbed.lang}})})}renderUrl(e,t){switch(t){case"IFRAME":return y(this,I,q).call(this,e);case"POPUP_IFRAME":return y(this,k,H).call(this,e);case"REDIRECT":return y(this,S,V).call(this,e);default:return null}}}I=new WeakSet,q=function(e){const t=document.querySelector("#rendered-url-iframe-container"),r=document.createElement("iframe");return r.src=e,r.style.setProperty("border","0","important"),r.style.setProperty("width","100vw","important"),r.style.setProperty("height","100vh","important"),t==null||t.replaceChildren(r),r},k=new WeakSet,H=function(e){return window.open(`${e}`,"","width=600,height=400,left=200,top=200")},S=new WeakSet,V=function(e){return window.open(e,"_blank")},A=new WeakSet,N=function(e){const t=r=>{e.forEach(s=>{s(r)})};window.addEventListener("message",t)},L=new WeakSet,W=function(e){const t=r=>{e.current&&e.current(r)};window.addEventListener("message",t)},U=new WeakSet,D=function({container:e,elementType:t,elementOptions:r,styles:s}){var i,l;const d=T(),o=new URL(`${d}/vaultField/vaultField.html`);o.searchParams.set("parent",window.location.origin),o.searchParams.set("type",t),o.searchParams.set("placeholder",(i=r.placeholder)!=null?i:""),o.searchParams.set("color",(s==null?void 0:s.color)||"#000"),o.searchParams.set("placeholderColor",(s==null?void 0:s.placeholderColor)||"#ccc"),o.searchParams.set("backgroundColor",(s==null?void 0:s.backgroundColor)||"transparent");const a=document.createElement("iframe");a.src=o.toString(),a.style.height=(l=r.height)!=null?l:"40px",a.style.setProperty("overflow","hidden","important"),a.style.setProperty("display","block","important"),a.style.setProperty("width","100%","important"),a.style.setProperty("maxWidth","100%","important"),a.style.setProperty("border","0","important"),a.style.setProperty("margin","0","important"),a.style.setProperty("padding","0","important"),a.style.setProperty("userSelect","none","important"),a.style.setProperty("colorScheme","light only","important"),e.replaceChildren(a)},R=new WeakSet,x=function(e){const t=T(),r=X(),s=new URL(`${t}/vaultSubmit/vaultSubmit.html`);s.searchParams.set("parent",window.location.origin),s.searchParams.set("vault_api_url",`${r}/api/v1/tokens/`),s.searchParams.set("access_token",e);const d=document.createElement("iframe");return d.id="moneyhash-submit-iframe",d.src=s.toString(),d.hidden=!0,document.body.appendChild(d),d};module.exports=te;

@@ -62,3 +62,3 @@ export declare interface AbstractIntent {

declare type ElementEvents = "focus" | "blur";
declare type ElementEvents = "focus" | "blur" | "changeInput";

@@ -436,3 +436,3 @@ declare type ElementProps = {

shippingData?: Record<string, unknown>;
}): Promise<void>;
}): Promise<IntentDetails<TType>>;
submitCvv({ intentId, cvv }: {

@@ -439,0 +439,0 @@ intentId: string;

@@ -13,3 +13,3 @@ var B = Object.defineProperty, O = Object.defineProperties;

}, F = (a, e) => O(a, Y(e));
var p = (a, e, t) => (_(a, typeof e != "symbol" ? e + "" : e, t), t), K = (a, e, t) => {
var m = (a, e, t) => (_(a, typeof e != "symbol" ? e + "" : e, t), t), K = (a, e, t) => {
if (!e.has(a))

@@ -24,23 +24,23 @@ throw TypeError("Cannot " + t);

var y = (a, e, t) => (K(a, e, "access private method"), t);
var v = (a, e, t) => new Promise((r, s) => {
var d = (o) => {
var P = (a, e, t) => new Promise((r, s) => {
var d = (i) => {
try {
n(t.next(o));
n(t.next(i));
} catch (l) {
s(l);
}
}, i = (o) => {
}, o = (i) => {
try {
n(t.throw(o));
n(t.throw(i));
} catch (l) {
s(l);
}
}, n = (o) => o.done ? r(o.value) : Promise.resolve(o.value).then(d, i);
}, n = (i) => i.done ? r(i.value) : Promise.resolve(i.value).then(d, o);
n((t = t.apply(a, e)).next());
});
import { M as G, g as Q, S as X, t as P } from "./sdkEmbed-7e9def06.js";
import { M as G, g as Q, S as X, t as w } from "./sdkEmbed-c8c76cbd.js";
function Z() {
return typeof window != "undefined";
}
const m = class {
const h = class {
constructor() {

@@ -53,33 +53,33 @@ Z() && this.initSDKCommunicationIframe();

const e = Q(), t = new URL(`${e}/embed/headless-sdk`);
t.searchParams.set("sdk", "true"), t.searchParams.set("parent", window.location.origin), t.searchParams.set("version", "js@1.0.0-beta.2");
t.searchParams.set("sdk", "true"), t.searchParams.set("parent", window.location.origin), t.searchParams.set("version", "js@1.0.0-beta.3");
const r = document.createElement("iframe");
r.id = "moneyhash-headless-sdk", r.src = t.toString(), r.hidden = !0, document.body.appendChild(r), m.messagingService = new G({
r.id = "moneyhash-headless-sdk", r.src = t.toString(), r.hidden = !0, document.body.appendChild(r), h.messagingService = new G({
target: r.contentWindow,
targetOrigin: e
}), m.isCommunicationReady = new Promise((s) => {
var i;
}), h.isCommunicationReady = new Promise((s) => {
var o;
const d = (n) => {
var o;
n.data.type === "headlessSDK:init" && (s(), (o = m.messagingService) == null || o.removeListener(d));
var i;
n.data.type === "headlessSDK:init" && (s(), (i = h.messagingService) == null || i.removeListener(d));
};
(i = m.messagingService) == null || i.onReceive(d);
(o = h.messagingService) == null || o.onReceive(d);
});
}
request(r) {
return v(this, arguments, function* ({
return P(this, arguments, function* ({
api: e,
payload: t
}) {
return yield m.isCommunicationReady, new Promise((s, d) => {
var n, o;
(n = m.messagingService) == null || n.send({
return yield h.isCommunicationReady, new Promise((s, d) => {
var n, i;
(n = h.messagingService) == null || n.send({
type: e,
data: t
});
const i = (l) => {
var b;
const { type: c, data: h } = l.data;
c === e && (h.status === "resolved" ? s(h.payload) : d(h.payload), (b = m.messagingService) == null || b.removeListener(i));
const o = (l) => {
var g;
const { type: c, data: p } = l.data;
c === e && (p.status === "resolved" ? s(p.payload) : d(p.payload), (g = h.messagingService) == null || g.removeListener(o));
};
(o = m.messagingService) == null || o.onReceive(i);
(i = h.messagingService) == null || i.onReceive(o);
});

@@ -89,9 +89,9 @@ });

};
let w = m;
p(w, "messagingService", null), p(w, "isCommunicationReady");
let b = h;
m(b, "messagingService", null), m(b, "isCommunicationReady");
class ee {
constructor() {
p(this, "promise");
p(this, "resolve");
p(this, "reject");
m(this, "promise");
m(this, "resolve");
m(this, "reject");
this.promise = new Promise((e, t) => {

@@ -135,19 +135,19 @@ this.resolve = e, this.reject = t;

]);
var k, V, A, q, E, N, L, H, I, W, U, D, R, x;
var E, H, k, V, A, q, I, N, L, W, U, D, R, x;
class ie {
constructor(e) {
u(this, E);
u(this, k);
u(this, A);
u(this, E);
u(this, I);
u(this, L);
u(this, I);
u(this, U);
u(this, R);
p(this, "options");
p(this, "sdkApiHandler", new w());
p(this, "sdkEmbed");
p(this, "vaultSubmitListener", {
m(this, "options");
m(this, "sdkApiHandler", new b());
m(this, "sdkEmbed");
m(this, "vaultSubmitListener", {
current: null
});
this.options = e, this.sdkEmbed = new X(F(S({}, e), { headless: !0 })), y(this, I, W).call(this, this.vaultSubmitListener);
this.options = e, this.sdkEmbed = new X(F(S({}, e), { headless: !0 })), y(this, L, W).call(this, this.vaultSubmitListener);
}

@@ -246,3 +246,3 @@ /**

}) {
return P(
return w(
!j.has(t),

@@ -306,3 +306,3 @@ `type must be a valid one (${[...j].join(

}) {
return P(
return w(
this.options.type === "payout",

@@ -358,3 +358,3 @@ "deleteCard is allowed only for payment intent!"

payWithApplePay(l) {
return v(this, arguments, function* ({
return P(this, arguments, function* ({
intentId: e,

@@ -366,5 +366,5 @@ currency: t,

},
onError: i,
onError: o,
onComplete: n,
billingData: o = {}
billingData: i = {}
}) {

@@ -387,4 +387,4 @@ if (yield se(

}), {
__providerId__: h,
state: b,
__providerId__: p,
state: g,
intent: C

@@ -397,4 +397,4 @@ } = yield this.proceedWith({

try {
if (b === "INTENT_FORM") {
if (re(o))
if (g === "INTENT_FORM") {
if (re(i))
throw new Error(

@@ -408,12 +408,12 @@ "Billing data is missing while calling payWithApplePay"

paymentMethod: "APPLE_PAY",
providerId: h,
providerId: p,
lang: this.sdkEmbed.lang,
billingData: o
billingData: i
}
});
}
} catch (f) {
throw yield this.resetSelectedMethod(e), f;
} catch (v) {
throw yield this.resetSelectedMethod(e), v;
}
c.onvalidatemerchant = (f) => {
c.onvalidatemerchant = (v) => {
fetch(`${$()}/api/v1/providers/applepay/session/`, {

@@ -426,8 +426,8 @@ method: "post",

secret: C.secret,
validation_url: f.validationURL
validation_url: v.validationURL
})
}).then((g) => g.ok ? g.json() : Promise.reject()).then(
(g) => c.completeMerchantValidation(g)
).catch(i);
}, c.onpaymentauthorized = (f) => {
}).then((f) => f.ok ? f.json() : Promise.reject()).then(
(f) => c.completeMerchantValidation(f)
).catch(o);
}, c.onpaymentauthorized = (v) => {
fetch(`${$()}/api/v1/providers/applepay/token/`, {

@@ -439,9 +439,9 @@ method: "post",

body: JSON.stringify({
token_data: f.payment.token,
token_data: v.payment.token,
secret: C.secret
})
}).then((g) => g.ok ? g.json() : Promise.reject()).then(() => {
}).then((f) => f.ok ? f.json() : Promise.reject()).then(() => {
c.completePayment(ApplePaySession.STATUS_SUCCESS), n();
}).catch(() => {
c.completePayment(ApplePaySession.STATUS_FAILURE), i();
c.completePayment(ApplePaySession.STATUS_FAILURE), o();
});

@@ -468,3 +468,3 @@ }, c.oncancel = d, c.begin();

renderForm({ selector: e, intentId: t }) {
return P(!e, "selector is required for renderForm"), P(!t, "intentId is required for renderForm"), this.sdkEmbed.render({ selector: e, intentId: t });
return w(!e, "selector is required for renderForm"), w(!t, "intentId is required for renderForm"), this.sdkEmbed.render({ selector: e, intentId: t });
}

@@ -495,17 +495,17 @@ /**

const t = [];
return y(this, L, H).call(this, t), {
return y(this, I, N).call(this, t), {
create: ({ elementType: r, elementOptions: s }) => {
const d = /* @__PURE__ */ new Map(), i = document.querySelector(
const d = /* @__PURE__ */ new Map(), o = document.querySelector(
s.selector
);
return P(
!i,
return w(
!o,
`Couldn't find an element with selector ${s.selector}!`
), i.classList.add("moneyhash-element"), t.push((n) => {
var l, c;
const { type: o } = n.data;
o === `${r}@focus` && (i.classList.add("moneyhash-element_focus"), (l = d.get(`${r}@focus`)) == null || l()), o === `${r}@blur` && (i.classList.remove("moneyhash-element_focus"), (c = d.get(`${r}@blur`)) == null || c());
), o.classList.add("MoneyHashElement"), t.push((n) => {
var l, c, p;
const { type: i } = n.data;
i === `${r}@focus` && (o.classList.add("MoneyHashElement--focus"), (l = d.get(`${r}@focus`)) == null || l()), i === `${r}@blur` && (o.classList.remove("MoneyHashElement--focus"), (c = d.get(`${r}@blur`)) == null || c()), i === `${r}@changeInput` && ((p = d.get(`${r}@changeInput`)) == null || p());
}), {
mount: () => y(this, U, D).call(this, {
container: i,
container: o,
elementType: r,

@@ -515,4 +515,4 @@ elementOptions: s,

}),
on: (n, o) => {
d.set(`${r}@${n}`, o);
on: (n, i) => {
d.set(`${r}@${n}`, i);
}

@@ -524,3 +524,3 @@ };

submitForm(d) {
return v(this, arguments, function* ({
return P(this, arguments, function* ({
intentId: e,

@@ -531,8 +531,9 @@ accessToken: t,

}) {
const i = new ee();
let n, o;
t && (this.vaultSubmitListener.current = (l) => {
const { type: c, data: h } = l.data;
c === "vaultSubmit:success" && i.resolve(h), c === "vaultSubmit:error" && i.reject(h);
}, o = y(this, R, x).call(this, t), n = yield i.promise), yield this.sdkApiHandler.request({
const o = new ee();
let n, i;
t && (this.vaultSubmitListener.current = (c) => {
const { type: p, data: g } = c.data;
p === "vaultSubmit:success" && o.resolve(g), p === "vaultSubmit:error" && o.reject(g);
}, i = y(this, R, x).call(this, t), n = yield o.promise);
const l = yield this.sdkApiHandler.request({
api: "sdk:submitNativeForm",

@@ -547,7 +548,8 @@ payload: {

}
}), o && o.remove();
});
return i && i.remove(), l;
});
}
submitCvv(r) {
return v(this, arguments, function* ({ intentId: e, cvv: t }) {
return P(this, arguments, function* ({ intentId: e, cvv: t }) {
return this.sdkApiHandler.request({

@@ -566,7 +568,7 @@ api: "sdk:submitCardCvv",

case "IFRAME":
return y(this, E, H).call(this, e);
case "POPUP_IFRAME":
return y(this, k, V).call(this, e);
case "POPUP_IFRAME":
case "REDIRECT":
return y(this, A, q).call(this, e);
case "REDIRECT":
return y(this, E, N).call(this, e);
default:

@@ -577,10 +579,10 @@ return null;

}
k = new WeakSet(), V = function(e) {
E = new WeakSet(), H = function(e) {
const t = document.querySelector("#rendered-url-iframe-container"), r = document.createElement("iframe");
return r.src = e, r.style.setProperty("border", "0", "important"), r.style.setProperty("width", "100vw", "important"), r.style.setProperty("height", "100vh", "important"), t == null || t.replaceChildren(r), r;
}, k = new WeakSet(), V = function(e) {
return window.open(`${e}`, "", "width=600,height=400,left=200,top=200");
}, A = new WeakSet(), q = function(e) {
return window.open(`${e}`, "", "width=600,height=400,left=200,top=200");
}, E = new WeakSet(), N = function(e) {
return window.open(e, "_blank");
}, L = new WeakSet(), H = function(e) {
}, I = new WeakSet(), N = function(e) {
const t = (r) => {

@@ -592,3 +594,3 @@ e.forEach((s) => {

window.addEventListener("message", t);
}, I = new WeakSet(), W = function(e) {
}, L = new WeakSet(), W = function(e) {
const t = (r) => {

@@ -604,8 +606,8 @@ e.current && e.current(r);

}) {
var o, l;
const d = T(), i = new URL(`${d}/vaultField/vaultField.html`);
i.searchParams.set("parent", window.location.origin), i.searchParams.set("type", t), i.searchParams.set("placeholder", (o = r.placeholder) != null ? o : ""), i.searchParams.set("color", (s == null ? void 0 : s.color) || "#000"), i.searchParams.set(
var i, l;
const d = T(), o = new URL(`${d}/vaultField/vaultField.html`);
o.searchParams.set("parent", window.location.origin), o.searchParams.set("type", t), o.searchParams.set("placeholder", (i = r.placeholder) != null ? i : ""), o.searchParams.set("color", (s == null ? void 0 : s.color) || "#000"), o.searchParams.set(
"placeholderColor",
(s == null ? void 0 : s.placeholderColor) || "#ccc"
), i.searchParams.set(
), o.searchParams.set(
"backgroundColor",

@@ -615,3 +617,3 @@ (s == null ? void 0 : s.backgroundColor) || "transparent"

const n = document.createElement("iframe");
n.src = i.toString(), n.style.height = (l = r.height) != null ? l : "40px", n.style.setProperty("overflow", "hidden", "important"), n.style.setProperty("display", "block", "important"), n.style.setProperty("width", "100%", "important"), n.style.setProperty("maxWidth", "100%", "important"), n.style.setProperty("border", "0", "important"), n.style.setProperty("margin", "0", "important"), n.style.setProperty("padding", "0", "important"), n.style.setProperty("userSelect", "none", "important"), n.style.setProperty("colorScheme", "light only", "important"), e.replaceChildren(n);
n.src = o.toString(), n.style.height = (l = r.height) != null ? l : "40px", n.style.setProperty("overflow", "hidden", "important"), n.style.setProperty("display", "block", "important"), n.style.setProperty("width", "100%", "important"), n.style.setProperty("maxWidth", "100%", "important"), n.style.setProperty("border", "0", "important"), n.style.setProperty("margin", "0", "important"), n.style.setProperty("padding", "0", "important"), n.style.setProperty("userSelect", "none", "important"), n.style.setProperty("colorScheme", "light only", "important"), e.replaceChildren(n);
}, R = new WeakSet(), x = function(e) {

@@ -618,0 +620,0 @@ const t = T(), r = te(), s = new URL(

@@ -1,1 +0,1 @@

(function(o,n){typeof exports=="object"&&typeof module!="undefined"?module.exports=n():typeof define=="function"&&define.amd?define(n):(o=typeof globalThis!="undefined"?globalThis:o||self,o.MoneyHash=n())})(this,function(){var _,Y,M,J,F,z,T,K,$,G,j,Q,H,X;"use strict";var ie=Object.defineProperty,ne=Object.defineProperties;var re=Object.getOwnPropertyDescriptors;var D=Object.getOwnPropertySymbols;var ae=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable;var N=(o,n,c)=>n in o?ie(o,n,{enumerable:!0,configurable:!0,writable:!0,value:c}):o[n]=c,A=(o,n)=>{for(var c in n||(n={}))ae.call(n,c)&&N(o,c,n[c]);if(D)for(var c of D(n))oe.call(n,c)&&N(o,c,n[c]);return o},x=(o,n)=>ne(o,re(n));var m=(o,n,c)=>(N(o,typeof n!="symbol"?n+"":n,c),c),de=(o,n,c)=>{if(!n.has(o))throw TypeError("Cannot "+c)};var L=(o,n,c)=>{if(n.has(o))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(o):n.set(o,c)};var E=(o,n,c)=>(de(o,n,"access private method"),c);var k=(o,n,c)=>new Promise((R,y)=>{var q=w=>{try{I(c.next(w))}catch(U){y(U)}},C=w=>{try{I(c.throw(w))}catch(U){y(U)}},I=w=>w.done?R(w.value):Promise.resolve(w.value).then(q,C);I((c=c.apply(o,n)).next())});class o{constructor(e){m(this,"target");m(this,"targetOrigin");m(this,"listeners");m(this,"onIncomingMessageBind",this.onIncomingMessage.bind(this));this.target=e.target,this.targetOrigin=e.targetOrigin,this.listeners=[],window.addEventListener("message",this.onIncomingMessageBind)}send(e){this.target.postMessage(e,this.targetOrigin)}onReceive(e){this.listeners.push(e)}removeListener(e){this.listeners=this.listeners.filter(t=>t!==e)}onIncomingMessage(e){e.origin===this.targetOrigin&&this.listeners.forEach(t=>{t(e,this.send.bind(this))})}abortService(){window.removeEventListener("message",this.onIncomingMessageBind)}}function n(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}function c(){return typeof window!="undefined"}const f=class{constructor(){c()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=n(),t=new URL(`${e}/embed/headless-sdk`);t.searchParams.set("sdk","true"),t.searchParams.set("parent",window.location.origin),t.searchParams.set("version","js@1.0.0-beta.2");const s=document.createElement("iframe");s.id="moneyhash-headless-sdk",s.src=t.toString(),s.hidden=!0,document.body.appendChild(s),f.messagingService=new o({target:s.contentWindow,targetOrigin:e}),f.isCommunicationReady=new Promise(i=>{var r;const d=a=>{var l;a.data.type==="headlessSDK:init"&&(i(),(l=f.messagingService)==null||l.removeListener(d))};(r=f.messagingService)==null||r.onReceive(d)})}request(s){return k(this,arguments,function*({api:e,payload:t}){return yield f.isCommunicationReady,new Promise((i,d)=>{var a,l;(a=f.messagingService)==null||a.send({type:e,data:t});const r=u=>{var b;const{type:h,data:g}=u.data;h===e&&(g.status==="resolved"?i(g.payload):d(g.payload),(b=f.messagingService)==null||b.removeListener(r))};(l=f.messagingService)==null||l.onReceive(r)})})}};let R=f;m(R,"messagingService",null),m(R,"isCommunicationReady");function y(p,e){if(p)throw new Error(e)}function q(p,e){p&&console.warn(e)}const C=new Set(["payment","payout"]),I=new Set(["en","fr","ar"]);class w{constructor(e){m(this,"options");m(this,"messagingService",null);m(this,"iframe",null);m(this,"isCommunicationReady",null);y(!C.has(e.type),`MoneyHash constructor must be called with valid type (${[...C].join(" | ")})!`),this.options=e}get lang(){var t;const e=(t=this.options.locale)==null?void 0:t.split("-")[0];return q(!!e&&!I.has(e),`Supported languages (${[...I].join(" | ")})`),e||"en"}render({selector:e,intentId:t}){var a,l;(a=this.messagingService)==null||a.abortService();const s=n(),i=new URL(`${s}/embed/${this.options.type}/${t}`);i.searchParams.set("sdk","true"),i.searchParams.set("parent",window.location.origin),i.searchParams.set("version","js@1.0.0-beta.2");const d=(l=this.options.locale)==null?void 0:l.split("-")[0];d&&i.searchParams.set("lang",d),this.iframe=document.createElement("iframe"),this.iframe.src=i.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0";const r=document.querySelector(e);return y(!r,`Couldn't find an element with selector ${e}!`),r.replaceChildren(this.iframe),this.messagingService=new o({target:this.iframe.contentWindow,targetOrigin:s}),this.isCommunicationReady=new Promise(u=>{var g;const h=b=>{var P;b.data.type==="sdk:init"&&(u(),(P=this.messagingService)==null||P.removeListener(h))};(g=this.messagingService)==null||g.onReceive(h)}),this.messagingService.onReceive((u,h)=>{var P,S,v,B;const{type:g,data:b}=u.data;switch(g){case"sdk:init":{h({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(S=(P=this.options).onComplete)==null||S.call(P,A({type:this.options.type},b)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(B=(v=this.options).onFail)==null||B.call(v,A({type:this.options.type},b)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}}}),this.isCommunicationReady}setLocale(e){return k(this,null,function*(){var t;yield this==null?void 0:this.isCommunicationReady,this.options.locale=e,(t=this.messagingService)==null||t.send({type:"changeLanguage",data:{locale:e}})})}abortService(){return k(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}class U{constructor(){m(this,"promise");m(this,"resolve");m(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function Z(){return"https://vault-staging.moneyhash.io"}function V(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault.moneyhash.io"}function ee(p){return(Array.isArray(p)?p.length:Object.keys(p).length)===0}function te(p,e){return new Promise((t,s)=>{if(document.getElementById(e)){t(void 0);return}const d=document.createElement("script");d.src=p,d.id=e,d.addEventListener("load",()=>{t(void 0)}),d.addEventListener("error",()=>{s(new Error("Script failed to load"))}),document.body.appendChild(d)})}function O(){var e;return(e=window.API_URL)!=null?e:"https://web.moneyhash.io"}const W=new Set(["method","customerBalance","savedCard"]);class se{constructor(e){L(this,_);L(this,M);L(this,F);L(this,T);L(this,$);L(this,j);L(this,H);m(this,"options");m(this,"sdkApiHandler",new R);m(this,"sdkEmbed");m(this,"vaultSubmitListener",{current:null});this.options=e,this.sdkEmbed=new w(x(A({},e),{headless:!0})),E(this,$,G).call(this,this.vaultSubmitListener)}getIntentDetails(e){return this.sdkApiHandler.request({api:"sdk:getIntentDetails",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}getIntentMethods(e){return this.sdkApiHandler.request({api:"sdk:getIntentMethods",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}proceedWith({intentId:e,type:t,id:s,metaData:i}){return y(!W.has(t),`type must be a valid one (${[...W].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:s,lang:this.sdkEmbed.lang,metaData:i}})}resetSelectedMethod(e){return this.sdkApiHandler.request({api:"sdk:resetSelectedMethod",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}deleteCard({cardId:e,intentSecret:t}){return y(this.options.type==="payout","deleteCard is allowed only for payment intent!"),this.sdkApiHandler.request({api:"sdk:deleteCard",payload:{cardId:e,intentSecret:t,lang:this.sdkEmbed.lang}})}payWithApplePay(u){return k(this,arguments,function*({intentId:e,currency:t,amount:s,countryCode:i,onCancel:d=()=>{},onError:r,onComplete:a,billingData:l={}}){if(yield te("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)return;const h=new ApplePaySession(3,{countryCode:i,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${s}`}}),{__providerId__:g,state:b,intent:P}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(b==="INTENT_FORM"){if(ee(l))throw new Error("Billing data is missing while calling payWithApplePay");yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"APPLE_PAY",providerId:g,lang:this.sdkEmbed.lang,billingData:l}})}}catch(S){throw yield this.resetSelectedMethod(e),S}h.onvalidatemerchant=S=>{fetch(`${O()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:P.secret,validation_url:S.validationURL})}).then(v=>v.ok?v.json():Promise.reject()).then(v=>h.completeMerchantValidation(v)).catch(r)},h.onpaymentauthorized=S=>{fetch(`${O()}/api/v1/providers/applepay/token/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({token_data:S.payment.token,secret:P.secret})}).then(v=>v.ok?v.json():Promise.reject()).then(()=>{h.completePayment(ApplePaySession.STATUS_SUCCESS),a()}).catch(()=>{h.completePayment(ApplePaySession.STATUS_FAILURE),r()})},h.oncancel=d,h.begin()})}renderForm({selector:e,intentId:t}){return y(!e,"selector is required for renderForm"),y(!t,"intentId is required for renderForm"),this.sdkEmbed.render({selector:e,intentId:t})}setLocale(e){return this.sdkEmbed.setLocale(e)}removeEventListeners(){return this.sdkEmbed.abortService()}elements({styles:e}){const t=[];return E(this,T,K).call(this,t),{create:({elementType:s,elementOptions:i})=>{const d=new Map,r=document.querySelector(i.selector);return y(!r,`Couldn't find an element with selector ${i.selector}!`),r.classList.add("moneyhash-element"),t.push(a=>{var u,h;const{type:l}=a.data;l===`${s}@focus`&&(r.classList.add("moneyhash-element_focus"),(u=d.get(`${s}@focus`))==null||u()),l===`${s}@blur`&&(r.classList.remove("moneyhash-element_focus"),(h=d.get(`${s}@blur`))==null||h())}),{mount:()=>E(this,j,Q).call(this,{container:r,elementType:s,elementOptions:i,styles:A(A({},e),i.styles)}),on:(a,l)=>{d.set(`${s}@${a}`,l)}}}}}submitForm(d){return k(this,arguments,function*({intentId:e,accessToken:t,billingData:s,shippingData:i}){const r=new U;let a,l;t&&(this.vaultSubmitListener.current=u=>{const{type:h,data:g}=u.data;h==="vaultSubmit:success"&&r.resolve(g),h==="vaultSubmit:error"&&r.reject(g)},l=E(this,H,X).call(this,t),a=yield r.promise),yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"CARD",lang:this.sdkEmbed.lang,billingData:s,shippingData:i,cardEmbed:a}}),l&&l.remove()})}submitCvv(s){return k(this,arguments,function*({intentId:e,cvv:t}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,lang:this.sdkEmbed.lang}})})}renderUrl(e,t){switch(t){case"IFRAME":return E(this,_,Y).call(this,e);case"POPUP_IFRAME":return E(this,M,J).call(this,e);case"REDIRECT":return E(this,F,z).call(this,e);default:return null}}}return _=new WeakSet,Y=function(e){const t=document.querySelector("#rendered-url-iframe-container"),s=document.createElement("iframe");return s.src=e,s.style.setProperty("border","0","important"),s.style.setProperty("width","100vw","important"),s.style.setProperty("height","100vh","important"),t==null||t.replaceChildren(s),s},M=new WeakSet,J=function(e){return window.open(`${e}`,"","width=600,height=400,left=200,top=200")},F=new WeakSet,z=function(e){return window.open(e,"_blank")},T=new WeakSet,K=function(e){const t=s=>{e.forEach(i=>{i(s)})};window.addEventListener("message",t)},$=new WeakSet,G=function(e){const t=s=>{e.current&&e.current(s)};window.addEventListener("message",t)},j=new WeakSet,Q=function({container:e,elementType:t,elementOptions:s,styles:i}){var l,u;const d=V(),r=new URL(`${d}/vaultField/vaultField.html`);r.searchParams.set("parent",window.location.origin),r.searchParams.set("type",t),r.searchParams.set("placeholder",(l=s.placeholder)!=null?l:""),r.searchParams.set("color",(i==null?void 0:i.color)||"#000"),r.searchParams.set("placeholderColor",(i==null?void 0:i.placeholderColor)||"#ccc"),r.searchParams.set("backgroundColor",(i==null?void 0:i.backgroundColor)||"transparent");const a=document.createElement("iframe");a.src=r.toString(),a.style.height=(u=s.height)!=null?u:"40px",a.style.setProperty("overflow","hidden","important"),a.style.setProperty("display","block","important"),a.style.setProperty("width","100%","important"),a.style.setProperty("maxWidth","100%","important"),a.style.setProperty("border","0","important"),a.style.setProperty("margin","0","important"),a.style.setProperty("padding","0","important"),a.style.setProperty("userSelect","none","important"),a.style.setProperty("colorScheme","light only","important"),e.replaceChildren(a)},H=new WeakSet,X=function(e){const t=V(),s=Z(),i=new URL(`${t}/vaultSubmit/vaultSubmit.html`);i.searchParams.set("parent",window.location.origin),i.searchParams.set("vault_api_url",`${s}/api/v1/tokens/`),i.searchParams.set("access_token",e);const d=document.createElement("iframe");return d.id="moneyhash-submit-iframe",d.src=i.toString(),d.hidden=!0,document.body.appendChild(d),d},se});
(function(o,n){typeof exports=="object"&&typeof module!="undefined"?module.exports=n():typeof define=="function"&&define.amd?define(n):(o=typeof globalThis!="undefined"?globalThis:o||self,o.MoneyHash=n())})(this,function(){var M,Y,_,J,F,z,$,K,T,G,j,Q,H,X;"use strict";var ie=Object.defineProperty,ne=Object.defineProperties;var re=Object.getOwnPropertyDescriptors;var D=Object.getOwnPropertySymbols;var ae=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable;var N=(o,n,c)=>n in o?ie(o,n,{enumerable:!0,configurable:!0,writable:!0,value:c}):o[n]=c,A=(o,n)=>{for(var c in n||(n={}))ae.call(n,c)&&N(o,c,n[c]);if(D)for(var c of D(n))oe.call(n,c)&&N(o,c,n[c]);return o},x=(o,n)=>ne(o,re(n));var m=(o,n,c)=>(N(o,typeof n!="symbol"?n+"":n,c),c),de=(o,n,c)=>{if(!n.has(o))throw TypeError("Cannot "+c)};var E=(o,n,c)=>{if(n.has(o))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(o):n.set(o,c)};var L=(o,n,c)=>(de(o,n,"access private method"),c);var I=(o,n,c)=>new Promise((R,f)=>{var q=b=>{try{k(c.next(b))}catch(U){f(U)}},C=b=>{try{k(c.throw(b))}catch(U){f(U)}},k=b=>b.done?R(b.value):Promise.resolve(b.value).then(q,C);k((c=c.apply(o,n)).next())});class o{constructor(e){m(this,"target");m(this,"targetOrigin");m(this,"listeners");m(this,"onIncomingMessageBind",this.onIncomingMessage.bind(this));this.target=e.target,this.targetOrigin=e.targetOrigin,this.listeners=[],window.addEventListener("message",this.onIncomingMessageBind)}send(e){this.target.postMessage(e,this.targetOrigin)}onReceive(e){this.listeners.push(e)}removeListener(e){this.listeners=this.listeners.filter(t=>t!==e)}onIncomingMessage(e){e.origin===this.targetOrigin&&this.listeners.forEach(t=>{t(e,this.send.bind(this))})}abortService(){window.removeEventListener("message",this.onIncomingMessageBind)}}function n(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}function c(){return typeof window!="undefined"}const v=class{constructor(){c()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=n(),t=new URL(`${e}/embed/headless-sdk`);t.searchParams.set("sdk","true"),t.searchParams.set("parent",window.location.origin),t.searchParams.set("version","js@1.0.0-beta.3");const s=document.createElement("iframe");s.id="moneyhash-headless-sdk",s.src=t.toString(),s.hidden=!0,document.body.appendChild(s),v.messagingService=new o({target:s.contentWindow,targetOrigin:e}),v.isCommunicationReady=new Promise(i=>{var r;const d=a=>{var l;a.data.type==="headlessSDK:init"&&(i(),(l=v.messagingService)==null||l.removeListener(d))};(r=v.messagingService)==null||r.onReceive(d)})}request(s){return I(this,arguments,function*({api:e,payload:t}){return yield v.isCommunicationReady,new Promise((i,d)=>{var a,l;(a=v.messagingService)==null||a.send({type:e,data:t});const r=g=>{var y;const{type:h,data:u}=g.data;h===e&&(u.status==="resolved"?i(u.payload):d(u.payload),(y=v.messagingService)==null||y.removeListener(r))};(l=v.messagingService)==null||l.onReceive(r)})})}};let R=v;m(R,"messagingService",null),m(R,"isCommunicationReady");function f(p,e){if(p)throw new Error(e)}function q(p,e){p&&console.warn(e)}const C=new Set(["payment","payout"]),k=new Set(["en","fr","ar"]);class b{constructor(e){m(this,"options");m(this,"messagingService",null);m(this,"iframe",null);m(this,"isCommunicationReady",null);f(!C.has(e.type),`MoneyHash constructor must be called with valid type (${[...C].join(" | ")})!`),this.options=e}get lang(){var t;const e=(t=this.options.locale)==null?void 0:t.split("-")[0];return q(!!e&&!k.has(e),`Supported languages (${[...k].join(" | ")})`),e||"en"}render({selector:e,intentId:t}){var a,l;(a=this.messagingService)==null||a.abortService();const s=n(),i=new URL(`${s}/embed/${this.options.type}/${t}`);i.searchParams.set("sdk","true"),i.searchParams.set("parent",window.location.origin),i.searchParams.set("version","js@1.0.0-beta.3");const d=(l=this.options.locale)==null?void 0:l.split("-")[0];d&&i.searchParams.set("lang",d),this.iframe=document.createElement("iframe"),this.iframe.src=i.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0";const r=document.querySelector(e);return f(!r,`Couldn't find an element with selector ${e}!`),r.replaceChildren(this.iframe),this.messagingService=new o({target:this.iframe.contentWindow,targetOrigin:s}),this.isCommunicationReady=new Promise(g=>{var u;const h=y=>{var P;y.data.type==="sdk:init"&&(g(),(P=this.messagingService)==null||P.removeListener(h))};(u=this.messagingService)==null||u.onReceive(h)}),this.messagingService.onReceive((g,h)=>{var P,S,w,B;const{type:u,data:y}=g.data;switch(u){case"sdk:init":{h({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(S=(P=this.options).onComplete)==null||S.call(P,A({type:this.options.type},y)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(B=(w=this.options).onFail)==null||B.call(w,A({type:this.options.type},y)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}}}),this.isCommunicationReady}setLocale(e){return I(this,null,function*(){var t;yield this==null?void 0:this.isCommunicationReady,this.options.locale=e,(t=this.messagingService)==null||t.send({type:"changeLanguage",data:{locale:e}})})}abortService(){return I(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}class U{constructor(){m(this,"promise");m(this,"resolve");m(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function Z(){return"https://vault-staging.moneyhash.io"}function V(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault.moneyhash.io"}function ee(p){return(Array.isArray(p)?p.length:Object.keys(p).length)===0}function te(p,e){return new Promise((t,s)=>{if(document.getElementById(e)){t(void 0);return}const d=document.createElement("script");d.src=p,d.id=e,d.addEventListener("load",()=>{t(void 0)}),d.addEventListener("error",()=>{s(new Error("Script failed to load"))}),document.body.appendChild(d)})}function O(){var e;return(e=window.API_URL)!=null?e:"https://web.moneyhash.io"}const W=new Set(["method","customerBalance","savedCard"]);class se{constructor(e){E(this,M);E(this,_);E(this,F);E(this,$);E(this,T);E(this,j);E(this,H);m(this,"options");m(this,"sdkApiHandler",new R);m(this,"sdkEmbed");m(this,"vaultSubmitListener",{current:null});this.options=e,this.sdkEmbed=new b(x(A({},e),{headless:!0})),L(this,T,G).call(this,this.vaultSubmitListener)}getIntentDetails(e){return this.sdkApiHandler.request({api:"sdk:getIntentDetails",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}getIntentMethods(e){return this.sdkApiHandler.request({api:"sdk:getIntentMethods",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}proceedWith({intentId:e,type:t,id:s,metaData:i}){return f(!W.has(t),`type must be a valid one (${[...W].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:s,lang:this.sdkEmbed.lang,metaData:i}})}resetSelectedMethod(e){return this.sdkApiHandler.request({api:"sdk:resetSelectedMethod",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}deleteCard({cardId:e,intentSecret:t}){return f(this.options.type==="payout","deleteCard is allowed only for payment intent!"),this.sdkApiHandler.request({api:"sdk:deleteCard",payload:{cardId:e,intentSecret:t,lang:this.sdkEmbed.lang}})}payWithApplePay(g){return I(this,arguments,function*({intentId:e,currency:t,amount:s,countryCode:i,onCancel:d=()=>{},onError:r,onComplete:a,billingData:l={}}){if(yield te("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)return;const h=new ApplePaySession(3,{countryCode:i,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${s}`}}),{__providerId__:u,state:y,intent:P}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(y==="INTENT_FORM"){if(ee(l))throw new Error("Billing data is missing while calling payWithApplePay");yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"APPLE_PAY",providerId:u,lang:this.sdkEmbed.lang,billingData:l}})}}catch(S){throw yield this.resetSelectedMethod(e),S}h.onvalidatemerchant=S=>{fetch(`${O()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:P.secret,validation_url:S.validationURL})}).then(w=>w.ok?w.json():Promise.reject()).then(w=>h.completeMerchantValidation(w)).catch(r)},h.onpaymentauthorized=S=>{fetch(`${O()}/api/v1/providers/applepay/token/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({token_data:S.payment.token,secret:P.secret})}).then(w=>w.ok?w.json():Promise.reject()).then(()=>{h.completePayment(ApplePaySession.STATUS_SUCCESS),a()}).catch(()=>{h.completePayment(ApplePaySession.STATUS_FAILURE),r()})},h.oncancel=d,h.begin()})}renderForm({selector:e,intentId:t}){return f(!e,"selector is required for renderForm"),f(!t,"intentId is required for renderForm"),this.sdkEmbed.render({selector:e,intentId:t})}setLocale(e){return this.sdkEmbed.setLocale(e)}removeEventListeners(){return this.sdkEmbed.abortService()}elements({styles:e}){const t=[];return L(this,$,K).call(this,t),{create:({elementType:s,elementOptions:i})=>{const d=new Map,r=document.querySelector(i.selector);return f(!r,`Couldn't find an element with selector ${i.selector}!`),r.classList.add("MoneyHashElement"),t.push(a=>{var g,h,u;const{type:l}=a.data;l===`${s}@focus`&&(r.classList.add("MoneyHashElement--focus"),(g=d.get(`${s}@focus`))==null||g()),l===`${s}@blur`&&(r.classList.remove("MoneyHashElement--focus"),(h=d.get(`${s}@blur`))==null||h()),l===`${s}@changeInput`&&((u=d.get(`${s}@changeInput`))==null||u())}),{mount:()=>L(this,j,Q).call(this,{container:r,elementType:s,elementOptions:i,styles:A(A({},e),i.styles)}),on:(a,l)=>{d.set(`${s}@${a}`,l)}}}}}submitForm(d){return I(this,arguments,function*({intentId:e,accessToken:t,billingData:s,shippingData:i}){const r=new U;let a,l;t&&(this.vaultSubmitListener.current=h=>{const{type:u,data:y}=h.data;u==="vaultSubmit:success"&&r.resolve(y),u==="vaultSubmit:error"&&r.reject(y)},l=L(this,H,X).call(this,t),a=yield r.promise);const g=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"CARD",lang:this.sdkEmbed.lang,billingData:s,shippingData:i,cardEmbed:a}});return l&&l.remove(),g})}submitCvv(s){return I(this,arguments,function*({intentId:e,cvv:t}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,lang:this.sdkEmbed.lang}})})}renderUrl(e,t){switch(t){case"IFRAME":return L(this,M,Y).call(this,e);case"POPUP_IFRAME":return L(this,_,J).call(this,e);case"REDIRECT":return L(this,F,z).call(this,e);default:return null}}}return M=new WeakSet,Y=function(e){const t=document.querySelector("#rendered-url-iframe-container"),s=document.createElement("iframe");return s.src=e,s.style.setProperty("border","0","important"),s.style.setProperty("width","100vw","important"),s.style.setProperty("height","100vh","important"),t==null||t.replaceChildren(s),s},_=new WeakSet,J=function(e){return window.open(`${e}`,"","width=600,height=400,left=200,top=200")},F=new WeakSet,z=function(e){return window.open(e,"_blank")},$=new WeakSet,K=function(e){const t=s=>{e.forEach(i=>{i(s)})};window.addEventListener("message",t)},T=new WeakSet,G=function(e){const t=s=>{e.current&&e.current(s)};window.addEventListener("message",t)},j=new WeakSet,Q=function({container:e,elementType:t,elementOptions:s,styles:i}){var l,g;const d=V(),r=new URL(`${d}/vaultField/vaultField.html`);r.searchParams.set("parent",window.location.origin),r.searchParams.set("type",t),r.searchParams.set("placeholder",(l=s.placeholder)!=null?l:""),r.searchParams.set("color",(i==null?void 0:i.color)||"#000"),r.searchParams.set("placeholderColor",(i==null?void 0:i.placeholderColor)||"#ccc"),r.searchParams.set("backgroundColor",(i==null?void 0:i.backgroundColor)||"transparent");const a=document.createElement("iframe");a.src=r.toString(),a.style.height=(g=s.height)!=null?g:"40px",a.style.setProperty("overflow","hidden","important"),a.style.setProperty("display","block","important"),a.style.setProperty("width","100%","important"),a.style.setProperty("maxWidth","100%","important"),a.style.setProperty("border","0","important"),a.style.setProperty("margin","0","important"),a.style.setProperty("padding","0","important"),a.style.setProperty("userSelect","none","important"),a.style.setProperty("colorScheme","light only","important"),e.replaceChildren(a)},H=new WeakSet,X=function(e){const t=V(),s=Z(),i=new URL(`${t}/vaultSubmit/vaultSubmit.html`);i.searchParams.set("parent",window.location.origin),i.searchParams.set("vault_api_url",`${s}/api/v1/tokens/`),i.searchParams.set("access_token",e);const d=document.createElement("iframe");return d.id="moneyhash-submit-iframe",d.src=i.toString(),d.hidden=!0,document.body.appendChild(d),d},se});

@@ -1,1 +0,1 @@

"use strict";var o=Object.defineProperty;var i=(s,e,r)=>e in s?o(s,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[e]=r;var t=(s,e,r)=>(i(s,typeof e!="symbol"?e+"":e,r),r);const d=require("./sdkEmbed-b6ce67bb.cjs");class n{constructor(e){t(this,"options");t(this,"sdkEmbed");this.options=e,this.sdkEmbed=new d.SDKEmbed(e)}start({selector:e,intentId:r}){return d.throwIf(!e,"selector is required for start"),d.throwIf(!r,"intentId is required for start"),this.sdkEmbed.render({selector:e,intentId:r})}setLocale(e){return this.sdkEmbed.setLocale(e)}removeEventListeners(){return this.sdkEmbed.abortService()}}module.exports=n;
"use strict";var o=Object.defineProperty;var i=(s,e,r)=>e in s?o(s,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[e]=r;var t=(s,e,r)=>(i(s,typeof e!="symbol"?e+"":e,r),r);const d=require("./sdkEmbed-daf42004.cjs");class n{constructor(e){t(this,"options");t(this,"sdkEmbed");this.options=e,this.sdkEmbed=new d.SDKEmbed(e)}start({selector:e,intentId:r}){return d.throwIf(!e,"selector is required for start"),d.throwIf(!r,"intentId is required for start"),this.sdkEmbed.render({selector:e,intentId:r})}setLocale(e){return this.sdkEmbed.setLocale(e)}removeEventListeners(){return this.sdkEmbed.abortService()}}module.exports=n;
var o = Object.defineProperty;
var i = (s, e, r) => e in s ? o(s, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : s[e] = r;
var t = (s, e, r) => (i(s, typeof e != "symbol" ? e + "" : e, r), r);
import { S as a, t as d } from "./sdkEmbed-7e9def06.js";
import { S as a, t as d } from "./sdkEmbed-c8c76cbd.js";
class b {

@@ -6,0 +6,0 @@ constructor(e) {

@@ -1,1 +0,1 @@

(function(i,t){typeof exports=="object"&&typeof module!="undefined"?module.exports=t():typeof define=="function"&&define.amd?define(t):(i=typeof globalThis!="undefined"?globalThis:i||self,i.MoneyHash=t())})(this,function(){"use strict";var F=Object.defineProperty;var O=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var v=(i,t,s)=>t in i?F(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s,w=(i,t)=>{for(var s in t||(t={}))U.call(t,s)&&v(i,s,t[s]);if(O)for(var s of O(t))$.call(t,s)&&v(i,s,t[s]);return i};var a=(i,t,s)=>(v(i,typeof t!="symbol"?t+"":t,s),s);var b=(i,t,s)=>new Promise((p,o)=>{var m=n=>{try{h(s.next(n))}catch(e){o(e)}},f=n=>{try{h(s.throw(n))}catch(e){o(e)}},h=n=>n.done?p(n.value):Promise.resolve(n.value).then(m,f);h((s=s.apply(i,t)).next())});class i{constructor(e){a(this,"target");a(this,"targetOrigin");a(this,"listeners");a(this,"onIncomingMessageBind",this.onIncomingMessage.bind(this));this.target=e.target,this.targetOrigin=e.targetOrigin,this.listeners=[],window.addEventListener("message",this.onIncomingMessageBind)}send(e){this.target.postMessage(e,this.targetOrigin)}onReceive(e){this.listeners.push(e)}removeListener(e){this.listeners=this.listeners.filter(r=>r!==e)}onIncomingMessage(e){e.origin===this.targetOrigin&&this.listeners.forEach(r=>{r(e,this.send.bind(this))})}abortService(){window.removeEventListener("message",this.onIncomingMessageBind)}}function t(n,e){if(n)throw new Error(e)}function s(n,e){n&&console.warn(e)}function p(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}const o=new Set(["payment","payout"]),m=new Set(["en","fr","ar"]);class f{constructor(e){a(this,"options");a(this,"messagingService",null);a(this,"iframe",null);a(this,"isCommunicationReady",null);t(!o.has(e.type),`MoneyHash constructor must be called with valid type (${[...o].join(" | ")})!`),this.options=e}get lang(){var r;const e=(r=this.options.locale)==null?void 0:r.split("-")[0];return s(!!e&&!m.has(e),`Supported languages (${[...m].join(" | ")})`),e||"en"}render({selector:e,intentId:r}){var L,M;(L=this.messagingService)==null||L.abortService();const S=p(),c=new URL(`${S}/embed/${this.options.type}/${r}`);c.searchParams.set("sdk","true"),c.searchParams.set("parent",window.location.origin),c.searchParams.set("version","js@1.0.0-beta.2");const R=(M=this.options.locale)==null?void 0:M.split("-")[0];R&&c.searchParams.set("lang",R),this.iframe=document.createElement("iframe"),this.iframe.src=c.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0";const E=document.querySelector(e);return t(!E,`Couldn't find an element with selector ${e}!`),E.replaceChildren(this.iframe),this.messagingService=new i({target:this.iframe.contentWindow,targetOrigin:S}),this.isCommunicationReady=new Promise(y=>{var l;const g=u=>{var d;u.data.type==="sdk:init"&&(y(),(d=this.messagingService)==null||d.removeListener(g))};(l=this.messagingService)==null||l.onReceive(g)}),this.messagingService.onReceive((y,g)=>{var d,k,I,C;const{type:l,data:u}=y.data;switch(l){case"sdk:init":{g({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(k=(d=this.options).onComplete)==null||k.call(d,w({type:this.options.type},u)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(C=(I=this.options).onFail)==null||C.call(I,w({type:this.options.type},u)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}}}),this.isCommunicationReady}setLocale(e){return b(this,null,function*(){var r;yield this==null?void 0:this.isCommunicationReady,this.options.locale=e,(r=this.messagingService)==null||r.send({type:"changeLanguage",data:{locale:e}})})}abortService(){return b(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}class h{constructor(e){a(this,"options");a(this,"sdkEmbed");this.options=e,this.sdkEmbed=new f(e)}start({selector:e,intentId:r}){return t(!e,"selector is required for start"),t(!r,"intentId is required for start"),this.sdkEmbed.render({selector:e,intentId:r})}setLocale(e){return this.sdkEmbed.setLocale(e)}removeEventListeners(){return this.sdkEmbed.abortService()}}return h});
(function(i,t){typeof exports=="object"&&typeof module!="undefined"?module.exports=t():typeof define=="function"&&define.amd?define(t):(i=typeof globalThis!="undefined"?globalThis:i||self,i.MoneyHash=t())})(this,function(){"use strict";var F=Object.defineProperty;var O=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var v=(i,t,s)=>t in i?F(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s,w=(i,t)=>{for(var s in t||(t={}))U.call(t,s)&&v(i,s,t[s]);if(O)for(var s of O(t))$.call(t,s)&&v(i,s,t[s]);return i};var a=(i,t,s)=>(v(i,typeof t!="symbol"?t+"":t,s),s);var b=(i,t,s)=>new Promise((p,o)=>{var m=n=>{try{h(s.next(n))}catch(e){o(e)}},f=n=>{try{h(s.throw(n))}catch(e){o(e)}},h=n=>n.done?p(n.value):Promise.resolve(n.value).then(m,f);h((s=s.apply(i,t)).next())});class i{constructor(e){a(this,"target");a(this,"targetOrigin");a(this,"listeners");a(this,"onIncomingMessageBind",this.onIncomingMessage.bind(this));this.target=e.target,this.targetOrigin=e.targetOrigin,this.listeners=[],window.addEventListener("message",this.onIncomingMessageBind)}send(e){this.target.postMessage(e,this.targetOrigin)}onReceive(e){this.listeners.push(e)}removeListener(e){this.listeners=this.listeners.filter(r=>r!==e)}onIncomingMessage(e){e.origin===this.targetOrigin&&this.listeners.forEach(r=>{r(e,this.send.bind(this))})}abortService(){window.removeEventListener("message",this.onIncomingMessageBind)}}function t(n,e){if(n)throw new Error(e)}function s(n,e){n&&console.warn(e)}function p(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}const o=new Set(["payment","payout"]),m=new Set(["en","fr","ar"]);class f{constructor(e){a(this,"options");a(this,"messagingService",null);a(this,"iframe",null);a(this,"isCommunicationReady",null);t(!o.has(e.type),`MoneyHash constructor must be called with valid type (${[...o].join(" | ")})!`),this.options=e}get lang(){var r;const e=(r=this.options.locale)==null?void 0:r.split("-")[0];return s(!!e&&!m.has(e),`Supported languages (${[...m].join(" | ")})`),e||"en"}render({selector:e,intentId:r}){var L,M;(L=this.messagingService)==null||L.abortService();const S=p(),c=new URL(`${S}/embed/${this.options.type}/${r}`);c.searchParams.set("sdk","true"),c.searchParams.set("parent",window.location.origin),c.searchParams.set("version","js@1.0.0-beta.3");const R=(M=this.options.locale)==null?void 0:M.split("-")[0];R&&c.searchParams.set("lang",R),this.iframe=document.createElement("iframe"),this.iframe.src=c.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0";const E=document.querySelector(e);return t(!E,`Couldn't find an element with selector ${e}!`),E.replaceChildren(this.iframe),this.messagingService=new i({target:this.iframe.contentWindow,targetOrigin:S}),this.isCommunicationReady=new Promise(y=>{var l;const g=u=>{var d;u.data.type==="sdk:init"&&(y(),(d=this.messagingService)==null||d.removeListener(g))};(l=this.messagingService)==null||l.onReceive(g)}),this.messagingService.onReceive((y,g)=>{var d,k,I,C;const{type:l,data:u}=y.data;switch(l){case"sdk:init":{g({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(k=(d=this.options).onComplete)==null||k.call(d,w({type:this.options.type},u)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(C=(I=this.options).onFail)==null||C.call(I,w({type:this.options.type},u)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}}}),this.isCommunicationReady}setLocale(e){return b(this,null,function*(){var r;yield this==null?void 0:this.isCommunicationReady,this.options.locale=e,(r=this.messagingService)==null||r.send({type:"changeLanguage",data:{locale:e}})})}abortService(){return b(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}class h{constructor(e){a(this,"options");a(this,"sdkEmbed");this.options=e,this.sdkEmbed=new f(e)}start({selector:e,intentId:r}){return t(!e,"selector is required for start"),t(!r,"intentId is required for start"),this.sdkEmbed.render({selector:e,intentId:r})}setLocale(e){return this.sdkEmbed.setLocale(e)}removeEventListeners(){return this.sdkEmbed.abortService()}}return h});
{
"name": "@moneyhash/js-sdk",
"version": "1.0.0-beta.2",
"version": "1.0.0-beta.3",
"description": "MoneyHash JavaScript SDK",

@@ -5,0 +5,0 @@ "type": "module",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc