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.0 to 1.0.0-beta.1

dist/sdkEmbed-1f18cb9b.js

2

dist/headless.cjs.js

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

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

@@ -39,3 +39,3 @@ var N = Object.defineProperty, q = Object.defineProperties;

});
import { M as B, g as Y, S as J, t as w } from "./sdkEmbed-924184f8.js";
import { M as B, g as Y, S as J, t as w } from "./sdkEmbed-1f18cb9b.js";
function O() {

@@ -52,3 +52,3 @@ return typeof window != "undefined";

const e = Y(), 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.0");
t.searchParams.set("sdk", "true"), t.searchParams.set("parent", window.location.origin), t.searchParams.set("version", "js@1.0.0-beta.1");
const i = document.createElement("iframe");

@@ -55,0 +55,0 @@ i.id = "moneyhash-headless-sdk", i.src = t.toString(), i.hidden = !0, document.body.appendChild(i), h.messagingService = new B({

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

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

@@ -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-b6768228.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-4faaafcd.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-924184f8.js";
import { S as a, t as d } from "./sdkEmbed-1f18cb9b.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.0");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.1");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.0",
"version": "1.0.0-beta.1",
"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