@moneyhash/js-sdk
Advanced tools
Comparing version 1.0.0-beta.5 to 1.0.0-beta.6
@@ -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 _=(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-bae6b7db.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.5");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(){var e;return(e=window.MONEYHASH_VAULT_API_URL)!=null?e:"https://vault.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 H=new Set(["method","customerBalance","savedCard"]);var I,V,A,j,S,q,k,N,L,W,U,D,R,x;class te{constructor(e){u(this,I);u(this,A);u(this,S);u(this,k);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(!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: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,k,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,V).call(this,e);case"POPUP_IFRAME":return y(this,A,j).call(this,e);case"REDIRECT":return y(this,S,q).call(this,e);default:return null}}}I=new WeakSet,V=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},A=new WeakSet,j=function(e){return window.open(`${e}`,"","width=600,height=400,left=200,top=200")},S=new WeakSet,q=function(e){return window.open(e,"_blank")},k=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; | ||
"use strict";var Y=Object.defineProperty,J=Object.defineProperties;var z=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var K=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var C=(a,e,t)=>e in a?Y(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,w=(a,e)=>{for(var t in e||(e={}))K.call(e,t)&&C(a,t,e[t]);if(F)for(var t of F(e))G.call(e,t)&&C(a,t,e[t]);return a},T=(a,e)=>J(a,z(e));var m=(a,e,t)=>(C(a,typeof e!="symbol"?e+"":e,t),t),Q=(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)=>(Q(a,e,"access private method"),t);var b=(a,e,t)=>new Promise((r,s)=>{var d=i=>{try{n(t.next(i))}catch(c){s(c)}},o=i=>{try{n(t.throw(i))}catch(c){s(c)}},n=i=>i.done?r(i.value):Promise.resolve(i.value).then(d,o);n((t=t.apply(a,e)).next())});const g=require("./sdkEmbed-7ee9ea3f.cjs");function X(){return typeof window!="undefined"}const h=class{constructor(){X()&&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.6");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=n=>{var i;n.data.type==="headlessSDK:init"&&(s(),(i=h.messagingService)==null||i.removeListener(d))};(o=h.messagingService)==null||o.onReceive(d)})}request(r){return b(this,arguments,function*({api:e,payload:t}){return yield h.isCommunicationReady,new Promise((s,d)=>{var n,i;(n=h.messagingService)==null||n.send({type:e,data:t});const o=c=>{var v;const{type:l,data:p}=c.data;l===e&&(p.status==="resolved"?s(p.payload):d(p.payload),(v=h.messagingService)==null||v.removeListener(o))};(i=h.messagingService)==null||i.onReceive(o)})})}};let E=h;m(E,"messagingService",null),m(E,"isCommunicationReady");class Z{constructor(){m(this,"promise");m(this,"resolve");m(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function ee(){var e;return(e=window.MONEYHASH_VAULT_API_URL)!=null?e:"https://vault.moneyhash.io"}function $(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault.moneyhash.io"}function te(a){return(Array.isArray(a)?a.length:Object.keys(a).length)===0}function re(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 H(){var e;return(e=window.API_URL)!=null?e:"https://web.moneyhash.io"}const V=new Set(["method","customerBalance","savedCard"]);var I,j,k,q,L,N,A,W,S,D,U,x,R,B,_,O;class se{constructor(e){u(this,I);u(this,k);u(this,L);u(this,A);u(this,S);u(this,U);u(this,R);u(this,_);m(this,"options");m(this,"sdkApiHandler",new E);m(this,"sdkEmbed");m(this,"vaultSubmitListener",{current:null});this.options=e,this.sdkEmbed=new g.SDKEmbed(T(w({},e),{headless:!0})),y(this,U,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:r,metaData:s}){return g.throwIf(!V.has(t),`type must be a valid one (${[...V].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(c){return b(this,arguments,function*({intentId:e,currency:t,amount:r,countryCode:s,onCancel:d=()=>{},onError:o,onComplete:n,billingData:i={}}){if(yield re("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:`${r}`}}),{__providerId__:p,state:v,intent:M}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(v==="INTENT_FORM"){if(te(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(P){throw yield this.resetSelectedMethod(e),P}l.onvalidatemerchant=P=>{fetch(`${H()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:M.secret,validation_url:P.validationURL})}).then(f=>f.ok?f.json():Promise.reject()).then(f=>l.completeMerchantValidation(f)).catch(o)},l.onpaymentauthorized=P=>{fetch(`${H()}/api/v1/providers/applepay/token/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({token_data:P.payment.token,secret:M.secret})}).then(f=>f.ok?f.json():Promise.reject()).then(()=>{l.completePayment(ApplePaySession.STATUS_SUCCESS),n()}).catch(()=>{l.completePayment(ApplePaySession.STATUS_FAILURE),o()})},l.oncancel=d,l.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,S,D).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(n=>{var c,l,p;const{type:i}=n.data;i===`${r}@focus`&&(o.classList.add("MoneyHashElement--focus"),(c=d.get(`${r}@focus`))==null||c()),i===`${r}@blur`&&(o.classList.remove("MoneyHashElement--focus"),(l=d.get(`${r}@blur`))==null||l()),i===`${r}@changeInput`&&((p=d.get(`${r}@changeInput`))==null||p())}),{mount:()=>y(this,R,B).call(this,{container:o,elementType:r,elementOptions:s,styles:w(w({},e),s.styles)}),on:(n,i)=>{d.set(`${r}@${n}`,i)}}}}}submitForm(d){return b(this,arguments,function*({intentId:e,accessToken:t,billingData:r,shippingData:s}){const o=new Z;let n,i;t&&(this.vaultSubmitListener.current=l=>{const{type:p,data:v}=l.data;p==="vaultSubmit:success"&&o.resolve(v),p==="vaultSubmit:error"&&o.reject(v)},i=y(this,_,O).call(this,t),n=yield o.promise);const c=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"CARD",lang:this.sdkEmbed.lang,billingData:r,shippingData:s,cardEmbed:n}});return i&&i.remove(),c})}submitCvv(r){return b(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,j).call(this,e);case"POPUP_IFRAME":return y(this,L,N).call(this,e);case"REDIRECT":return y(this,A,W).call(this,e);default:return null}}}I=new WeakSet,j=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","100%","important"),r.style.setProperty("height","100%","important"),t==null||t.replaceChildren(r),y(this,k,q).call(this,r),r},k=new WeakSet,q=function(e){const t=r=>{var o,n,i,c;const{type:s,data:d}=r.data;switch(s){case"onComplete":(n=(o=this.options).onComplete)==null||n.call(o,w({type:this.options.type},d)),e.remove(),window.removeEventListener("message",t);break;case"onFail":(c=(i=this.options).onFail)==null||c.call(i,w({type:this.options.type},d)),e.remove(),window.removeEventListener("message",t);break}};window.addEventListener("message",t)},L=new WeakSet,N=function(e){return window.open(`${e}`,"","width=600,height=400,left=200,top=200")},A=new WeakSet,W=function(e){return window.open(e,"_blank")},S=new WeakSet,D=function(e){const t=r=>{e.forEach(s=>{s(r)})};window.addEventListener("message",t)},U=new WeakSet,x=function(e){const t=r=>{e.current&&e.current(r)};window.addEventListener("message",t)},R=new WeakSet,B=function({container:e,elementType:t,elementOptions:r,styles:s}){var i,c;const d=$(),o=new URL(`${d}/vaultField/vaultField.html`);o.searchParams.set("host",btoa(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 n=document.createElement("iframe");n.src=o.toString(),n.style.height=(c=r.height)!=null?c:"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)},_=new WeakSet,O=function(e){const t=$(),r=ee(),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=se; |
@@ -71,2 +71,7 @@ export declare interface AbstractIntent { | ||
declare type Element_2 = { | ||
mount: () => void; | ||
on: (event: ElementEvents, callback: () => void) => void; | ||
}; | ||
declare type ElementEvents = "focus" | "blur" | "changeInput"; | ||
@@ -84,2 +89,6 @@ | ||
declare type Elements = { | ||
create: (elementProps: ElementProps) => Element_2; | ||
}; | ||
declare type ElementsProps = { | ||
@@ -193,3 +202,3 @@ styles?: ElementStyles; | ||
state: IntentState; | ||
stateDetails: IntentStateDetails; | ||
stateDetails: IntentStateDetails<IntentState>; | ||
shippingData: Shipping | null; | ||
@@ -207,3 +216,3 @@ productItems: ProductItem[] | null; | ||
state: IntentState; | ||
stateDetails: IntentStateDetails; | ||
stateDetails: IntentStateDetails<IntentState>; | ||
__providerId__: never; | ||
@@ -223,3 +232,5 @@ }; | ||
export declare type IntentStateDetails<TType extends IntentState = IntentState> = TType extends "FORM_FIELDS" ? FormFields : TType extends "URL_TO_RENDER" ? { | ||
export declare type IntentStateDetails<TType extends IntentState> = TType extends "FORM_FIELDS" ? { | ||
formFields: FormFields; | ||
} : TType extends "URL_TO_RENDER" ? { | ||
url: string; | ||
@@ -454,8 +465,29 @@ renderStrategy: UrlRenderStrategy; | ||
removeEventListeners(): Promise<void>; | ||
elements({ styles }: ElementsProps): { | ||
create: ({ elementType, elementOptions }: ElementProps) => { | ||
mount: () => void; | ||
on: (eventName: ElementEvents, callback: () => void) => void; | ||
}; | ||
}; | ||
/** | ||
* Creates Elements context used to render each card field | ||
* @description Elements context is used to create and manage card fields | ||
* such as card number, card holder name, card expiry month, card expiry year and card cvv. | ||
* | ||
* @example | ||
* ``` | ||
* const elements = moneyHash.elements({ styles: ElementsStyles }); | ||
* ``` | ||
* | ||
* @returns { Elements } | ||
*/ | ||
elements({ styles }: ElementsProps): Elements; | ||
/** | ||
* Submits the form with the form fields data (card, billing, shipping) | ||
* @example | ||
* ``` | ||
* await moneyHash.submitForm({ | ||
* intentId: '<intent-id>', | ||
* accessToken : '<access-token>', | ||
* billingData: {}, | ||
* shippingData: {}, | ||
* }); | ||
* ``` | ||
* | ||
* @returns { Promise<IntentDetails<TType>> } | ||
*/ | ||
submitForm({ intentId, accessToken, billingData, shippingData, }: { | ||
@@ -467,6 +499,25 @@ intentId: string; | ||
}): Promise<IntentDetails<TType>>; | ||
submitCvv({ intentId, cvv }: { | ||
/** | ||
* Submits the CVV for the tokenized card | ||
* | ||
* @example | ||
* ``` | ||
* await moneyHash.submitCvv({ intentId: '<intent-id>', cvv: '<cvv>' }); | ||
* ``` | ||
* | ||
* @returns { Promise<IntentDetails<TType>> } | ||
*/ | ||
submitCvv({ intentId, cvv, }: { | ||
intentId: string; | ||
cvv: string; | ||
}): Promise<IntentDetails<TType>>; | ||
/** | ||
* Render the received url in an iframe, popup iframe or redirect | ||
* | ||
* @example | ||
* ``` | ||
* moneyHash.renderUrl('<url>', 'IFRAME'); | ||
* ``` | ||
* | ||
*/ | ||
renderUrl(url: string, renderStrategy: "IFRAME" | "POPUP_IFRAME" | "REDIRECT"): HTMLIFrameElement | Window | null; | ||
@@ -490,5 +541,5 @@ } | ||
transaction: PaymentTransaction; | ||
redirect: Redirect | null; | ||
selectedMethod: PaymentMethodSlugs | null; | ||
state: IntentState; | ||
stateDetails: IntentStateDetails<IntentState>; | ||
shippingData: Shipping | null; | ||
@@ -521,2 +572,3 @@ productItems: ProductItem[] | null; | ||
state: IntentState; | ||
stateDetails: IntentStateDetails<IntentState>; | ||
}; | ||
@@ -546,6 +598,2 @@ | ||
export declare interface Redirect { | ||
redirectUrl: string; | ||
} | ||
export declare type RefundOperationStatus = "pending" | "failed" | "successful"; | ||
@@ -552,0 +600,0 @@ |
@@ -1,41 +0,41 @@ | ||
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, S = (a, e) => { | ||
var Y = Object.defineProperty, J = Object.defineProperties; | ||
var z = Object.getOwnPropertyDescriptors; | ||
var F = Object.getOwnPropertySymbols; | ||
var K = Object.prototype.hasOwnProperty, G = Object.prototype.propertyIsEnumerable; | ||
var C = (n, e, t) => e in n ? Y(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, f = (n, 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 m = (a, e, t) => (_(a, typeof e != "symbol" ? e + "" : e, t), t), K = (a, e, t) => { | ||
if (!e.has(a)) | ||
K.call(e, t) && C(n, t, e[t]); | ||
if (F) | ||
for (var t of F(e)) | ||
G.call(e, t) && C(n, t, e[t]); | ||
return n; | ||
}, T = (n, e) => J(n, z(e)); | ||
var m = (n, e, t) => (C(n, typeof e != "symbol" ? e + "" : e, t), t), Q = (n, e, t) => { | ||
if (!e.has(n)) | ||
throw TypeError("Cannot " + t); | ||
}; | ||
var u = (a, e, t) => { | ||
if (e.has(a)) | ||
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(a) : e.set(a, t); | ||
e instanceof WeakSet ? e.add(n) : e.set(n, t); | ||
}; | ||
var y = (a, e, t) => (K(a, e, "access private method"), t); | ||
var P = (a, e, t) => new Promise((r, s) => { | ||
var y = (n, e, t) => (Q(n, e, "access private method"), t); | ||
var P = (n, e, t) => new Promise((r, s) => { | ||
var d = (i) => { | ||
try { | ||
n(t.next(i)); | ||
} catch (l) { | ||
s(l); | ||
a(t.next(i)); | ||
} catch (c) { | ||
s(c); | ||
} | ||
}, o = (i) => { | ||
try { | ||
n(t.throw(i)); | ||
} catch (l) { | ||
s(l); | ||
a(t.throw(i)); | ||
} catch (c) { | ||
s(c); | ||
} | ||
}, n = (i) => i.done ? r(i.value) : Promise.resolve(i.value).then(d, o); | ||
n((t = t.apply(a, e)).next()); | ||
}, a = (i) => i.done ? r(i.value) : Promise.resolve(i.value).then(d, o); | ||
a((t = t.apply(n, e)).next()); | ||
}); | ||
import { M as G, g as Q, S as X, t as w } from "./sdkEmbed-ea26512a.js"; | ||
function Z() { | ||
import { M as X, g as Z, S as ee, t as b } from "./sdkEmbed-51e0e822.js"; | ||
function te() { | ||
return typeof window != "undefined"; | ||
@@ -45,3 +45,3 @@ } | ||
constructor() { | ||
Z() && this.initSDKCommunicationIframe(); | ||
te() && this.initSDKCommunicationIframe(); | ||
} | ||
@@ -51,6 +51,6 @@ initSDKCommunicationIframe() { | ||
return; | ||
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.5"); | ||
const e = Z(), 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.6"); | ||
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({ | ||
r.id = "moneyhash-headless-sdk", r.src = t.toString(), r.hidden = !0, document.body.appendChild(r), h.messagingService = new X({ | ||
target: r.contentWindow, | ||
@@ -60,5 +60,5 @@ targetOrigin: e | ||
var o; | ||
const d = (n) => { | ||
const d = (a) => { | ||
var i; | ||
n.data.type === "headlessSDK:init" && (s(), (i = h.messagingService) == null || i.removeListener(d)); | ||
a.data.type === "headlessSDK:init" && (s(), (i = h.messagingService) == null || i.removeListener(d)); | ||
}; | ||
@@ -74,11 +74,11 @@ (o = h.messagingService) == null || o.onReceive(d); | ||
return yield h.isCommunicationReady, new Promise((s, d) => { | ||
var n, i; | ||
(n = h.messagingService) == null || n.send({ | ||
var a, i; | ||
(a = h.messagingService) == null || a.send({ | ||
type: e, | ||
data: t | ||
}); | ||
const o = (l) => { | ||
const o = (c) => { | ||
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)); | ||
const { type: l, data: p } = c.data; | ||
l === e && (p.status === "resolved" ? s(p.payload) : d(p.payload), (g = h.messagingService) == null || g.removeListener(o)); | ||
}; | ||
@@ -90,5 +90,5 @@ (i = h.messagingService) == null || i.onReceive(o); | ||
}; | ||
let b = h; | ||
m(b, "messagingService", null), m(b, "isCommunicationReady"); | ||
class ee { | ||
let E = h; | ||
m(E, "messagingService", null), m(E, "isCommunicationReady"); | ||
class re { | ||
constructor() { | ||
@@ -103,14 +103,14 @@ m(this, "promise"); | ||
} | ||
function te() { | ||
function se() { | ||
var e; | ||
return (e = window.MONEYHASH_VAULT_API_URL) != null ? e : "https://vault.moneyhash.io"; | ||
} | ||
function T() { | ||
function $() { | ||
var e; | ||
return (e = window.MONEYHASH_VAULT_INPUT_IFRAME_URL) != null ? e : "https://vault.moneyhash.io"; | ||
} | ||
function re(a) { | ||
return (Array.isArray(a) ? a.length : Object.keys(a).length) === 0; | ||
function ae(n) { | ||
return (Array.isArray(n) ? n.length : Object.keys(n).length) === 0; | ||
} | ||
function se(a, e) { | ||
function ne(n, e) { | ||
return new Promise((t, r) => { | ||
@@ -122,3 +122,3 @@ if (document.getElementById(e)) { | ||
const d = document.createElement("script"); | ||
d.src = a, d.id = e, d.addEventListener("load", () => { | ||
d.src = n, d.id = e, d.addEventListener("load", () => { | ||
t(void 0); | ||
@@ -130,7 +130,7 @@ }), d.addEventListener("error", () => { | ||
} | ||
function $() { | ||
function H() { | ||
var e; | ||
return (e = window.API_URL) != null ? e : "https://web.moneyhash.io"; | ||
} | ||
const H = /* @__PURE__ */ new Set([ | ||
const V = /* @__PURE__ */ new Set([ | ||
"method", | ||
@@ -140,14 +140,15 @@ "customerBalance", | ||
]); | ||
var A, V, E, j, k, N, I, q, L, W, U, D, R, x; | ||
class ie { | ||
var L, j, S, N, k, q, A, W, I, D, U, x, R, B, _, O; | ||
class de { | ||
constructor(e) { | ||
u(this, L); | ||
u(this, S); | ||
u(this, k); | ||
u(this, A); | ||
u(this, E); | ||
u(this, k); | ||
u(this, I); | ||
u(this, L); | ||
u(this, U); | ||
u(this, R); | ||
u(this, _); | ||
m(this, "options"); | ||
m(this, "sdkApiHandler", new b()); | ||
m(this, "sdkApiHandler", new E()); | ||
m(this, "sdkEmbed"); | ||
@@ -157,3 +158,3 @@ m(this, "vaultSubmitListener", { | ||
}); | ||
this.options = e, this.sdkEmbed = new X(F(S({}, e), { headless: !0 })), y(this, L, W).call(this, this.vaultSubmitListener); | ||
this.options = e, this.sdkEmbed = new ee(T(f({}, e), { headless: !0 })), y(this, U, x).call(this, this.vaultSubmitListener); | ||
} | ||
@@ -252,5 +253,5 @@ /** | ||
}) { | ||
return w( | ||
!H.has(t), | ||
`type must be a valid one (${[...H].join( | ||
return b( | ||
!V.has(t), | ||
`type must be a valid one (${[...V].join( | ||
" | " | ||
@@ -312,3 +313,3 @@ )})` | ||
}) { | ||
return w( | ||
return b( | ||
this.options.type === "payout", | ||
@@ -363,3 +364,3 @@ "deleteCard is allowed only for payment intent!" | ||
*/ | ||
payWithApplePay(l) { | ||
payWithApplePay(c) { | ||
return P(this, arguments, function* ({ | ||
@@ -373,6 +374,6 @@ intentId: e, | ||
onError: o, | ||
onComplete: n, | ||
onComplete: a, | ||
billingData: i = {} | ||
}) { | ||
if (yield se( | ||
if (yield ne( | ||
"https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js", | ||
@@ -382,3 +383,3 @@ "moneyHash-apple-pay-sdk" | ||
return; | ||
const c = new ApplePaySession(3, { | ||
const l = new ApplePaySession(3, { | ||
countryCode: s, | ||
@@ -396,3 +397,3 @@ currencyCode: t, | ||
state: g, | ||
intent: C | ||
intent: M | ||
} = yield this.proceedWith({ | ||
@@ -405,3 +406,3 @@ intentId: e, | ||
if (g === "INTENT_FORM") { | ||
if (re(i)) | ||
if (ae(i)) | ||
throw new Error( | ||
@@ -421,7 +422,7 @@ "Billing data is missing while calling payWithApplePay" | ||
} | ||
} catch (v) { | ||
throw yield this.resetSelectedMethod(e), v; | ||
} catch (w) { | ||
throw yield this.resetSelectedMethod(e), w; | ||
} | ||
c.onvalidatemerchant = (v) => { | ||
fetch(`${$()}/api/v1/providers/applepay/session/`, { | ||
l.onvalidatemerchant = (w) => { | ||
fetch(`${H()}/api/v1/providers/applepay/session/`, { | ||
method: "post", | ||
@@ -432,10 +433,10 @@ headers: { | ||
body: JSON.stringify({ | ||
secret: C.secret, | ||
validation_url: v.validationURL | ||
secret: M.secret, | ||
validation_url: w.validationURL | ||
}) | ||
}).then((f) => f.ok ? f.json() : Promise.reject()).then( | ||
(f) => c.completeMerchantValidation(f) | ||
}).then((v) => v.ok ? v.json() : Promise.reject()).then( | ||
(v) => l.completeMerchantValidation(v) | ||
).catch(o); | ||
}, c.onpaymentauthorized = (v) => { | ||
fetch(`${$()}/api/v1/providers/applepay/token/`, { | ||
}, l.onpaymentauthorized = (w) => { | ||
fetch(`${H()}/api/v1/providers/applepay/token/`, { | ||
method: "post", | ||
@@ -446,11 +447,11 @@ headers: { | ||
body: JSON.stringify({ | ||
token_data: v.payment.token, | ||
secret: C.secret | ||
token_data: w.payment.token, | ||
secret: M.secret | ||
}) | ||
}).then((f) => f.ok ? f.json() : Promise.reject()).then(() => { | ||
c.completePayment(ApplePaySession.STATUS_SUCCESS), n(); | ||
}).then((v) => v.ok ? v.json() : Promise.reject()).then(() => { | ||
l.completePayment(ApplePaySession.STATUS_SUCCESS), a(); | ||
}).catch(() => { | ||
c.completePayment(ApplePaySession.STATUS_FAILURE), o(); | ||
l.completePayment(ApplePaySession.STATUS_FAILURE), o(); | ||
}); | ||
}, c.oncancel = d, c.begin(); | ||
}, l.oncancel = d, l.begin(); | ||
}); | ||
@@ -475,3 +476,3 @@ } | ||
renderForm({ 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 }); | ||
return b(!e, "selector is required for renderForm"), b(!t, "intentId is required for renderForm"), this.sdkEmbed.render({ selector: e, intentId: t }); | ||
} | ||
@@ -500,5 +501,38 @@ /** | ||
} | ||
/** | ||
* Creates Elements context used to render each card field | ||
* @description Elements context is used to create and manage card fields | ||
* such as card number, card holder name, card expiry month, card expiry year and card cvv. | ||
* | ||
* @example | ||
* ``` | ||
* const elements = moneyHash.elements({ styles: ElementsStyles }); | ||
* ``` | ||
* | ||
* @returns { Elements } | ||
*/ | ||
elements({ styles: e }) { | ||
const t = []; | ||
return y(this, I, q).call(this, t), { | ||
return y(this, I, D).call(this, t), { | ||
/** | ||
* Creates card field element | ||
* @description | ||
* | ||
* @example | ||
* ``` | ||
* const cardField = elements.create({ | ||
* elementType: "<element-type>", | ||
* elementOptions: { | ||
* selector: "<css-selector>", | ||
* height: "<height>", | ||
* placeholder: "<placeholder>", | ||
* styles: { color: "<color>", | ||
* backgroundColor: "<background-color>", | ||
* placeholderColor: "<placeholder-color>" | ||
* } | ||
* }); | ||
* ``` | ||
* | ||
* @returns { Elements } | ||
*/ | ||
create: ({ elementType: r, elementOptions: s }) => { | ||
@@ -508,18 +542,18 @@ const d = /* @__PURE__ */ new Map(), o = document.querySelector( | ||
); | ||
return w( | ||
return b( | ||
!o, | ||
`Couldn't find an element with selector ${s.selector}!` | ||
), 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()); | ||
), o.classList.add("MoneyHashElement"), t.push((a) => { | ||
var c, l, p; | ||
const { type: i } = a.data; | ||
i === `${r}@focus` && (o.classList.add("MoneyHashElement--focus"), (c = d.get(`${r}@focus`)) == null || c()), i === `${r}@blur` && (o.classList.remove("MoneyHashElement--focus"), (l = d.get(`${r}@blur`)) == null || l()), i === `${r}@changeInput` && ((p = d.get(`${r}@changeInput`)) == null || p()); | ||
}), { | ||
mount: () => y(this, U, D).call(this, { | ||
mount: () => y(this, R, B).call(this, { | ||
container: o, | ||
elementType: r, | ||
elementOptions: s, | ||
styles: S(S({}, e), s.styles) | ||
styles: f(f({}, e), s.styles) | ||
}), | ||
on: (n, i) => { | ||
d.set(`${r}@${n}`, i); | ||
on: (a, i) => { | ||
d.set(`${r}@${a}`, i); | ||
} | ||
@@ -530,2 +564,16 @@ }; | ||
} | ||
/** | ||
* Submits the form with the form fields data (card, billing, shipping) | ||
* @example | ||
* ``` | ||
* await moneyHash.submitForm({ | ||
* intentId: '<intent-id>', | ||
* accessToken : '<access-token>', | ||
* billingData: {}, | ||
* shippingData: {}, | ||
* }); | ||
* ``` | ||
* | ||
* @returns { Promise<IntentDetails<TType>> } | ||
*/ | ||
submitForm(d) { | ||
@@ -538,9 +586,9 @@ return P(this, arguments, function* ({ | ||
}) { | ||
const o = new ee(); | ||
let n, i; | ||
t && (this.vaultSubmitListener.current = (c) => { | ||
const { type: p, data: g } = c.data; | ||
const o = new re(); | ||
let a, i; | ||
t && (this.vaultSubmitListener.current = (l) => { | ||
const { type: p, data: g } = l.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({ | ||
}, i = y(this, _, O).call(this, t), a = yield o.promise); | ||
const c = yield this.sdkApiHandler.request({ | ||
api: "sdk:submitNativeForm", | ||
@@ -553,10 +601,23 @@ payload: { | ||
shippingData: s, | ||
cardEmbed: n | ||
cardEmbed: a | ||
} | ||
}); | ||
return i && i.remove(), l; | ||
return i && i.remove(), c; | ||
}); | ||
} | ||
/** | ||
* Submits the CVV for the tokenized card | ||
* | ||
* @example | ||
* ``` | ||
* await moneyHash.submitCvv({ intentId: '<intent-id>', cvv: '<cvv>' }); | ||
* ``` | ||
* | ||
* @returns { Promise<IntentDetails<TType>> } | ||
*/ | ||
submitCvv(r) { | ||
return P(this, arguments, function* ({ intentId: e, cvv: t }) { | ||
return P(this, arguments, function* ({ | ||
intentId: e, | ||
cvv: t | ||
}) { | ||
return this.sdkApiHandler.request({ | ||
@@ -572,10 +633,19 @@ api: "sdk:submitCardCvv", | ||
} | ||
/** | ||
* Render the received url in an iframe, popup iframe or redirect | ||
* | ||
* @example | ||
* ``` | ||
* moneyHash.renderUrl('<url>', 'IFRAME'); | ||
* ``` | ||
* | ||
*/ | ||
renderUrl(e, t) { | ||
switch (t) { | ||
case "IFRAME": | ||
return y(this, A, V).call(this, e); | ||
return y(this, L, j).call(this, e); | ||
case "POPUP_IFRAME": | ||
return y(this, E, j).call(this, e); | ||
return y(this, k, q).call(this, e); | ||
case "REDIRECT": | ||
return y(this, k, N).call(this, e); | ||
return y(this, A, W).call(this, e); | ||
default: | ||
@@ -586,10 +656,28 @@ return null; | ||
} | ||
A = new WeakSet(), V = function(e) { | ||
L = new WeakSet(), j = 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; | ||
}, E = new WeakSet(), j = function(e) { | ||
return r.src = e, r.style.setProperty("border", "0", "important"), r.style.setProperty("width", "100%", "important"), r.style.setProperty("height", "100%", "important"), t == null || t.replaceChildren(r), y(this, S, N).call(this, r), r; | ||
}, S = new WeakSet(), N = function(e) { | ||
const t = (r) => { | ||
var o, a, i, c; | ||
const { type: s, data: d } = r.data; | ||
switch (s) { | ||
case "onComplete": | ||
(a = (o = this.options).onComplete) == null || a.call(o, f({ | ||
type: this.options.type | ||
}, d)), e.remove(), window.removeEventListener("message", t); | ||
break; | ||
case "onFail": | ||
(c = (i = this.options).onFail) == null || c.call(i, f({ | ||
type: this.options.type | ||
}, d)), e.remove(), window.removeEventListener("message", t); | ||
break; | ||
} | ||
}; | ||
window.addEventListener("message", t); | ||
}, k = new WeakSet(), q = function(e) { | ||
return window.open(`${e}`, "", "width=600,height=400,left=200,top=200"); | ||
}, k = new WeakSet(), N = function(e) { | ||
}, A = new WeakSet(), W = function(e) { | ||
return window.open(e, "_blank"); | ||
}, I = new WeakSet(), q = function(e) { | ||
}, I = new WeakSet(), D = function(e) { | ||
const t = (r) => { | ||
@@ -601,3 +689,3 @@ e.forEach((s) => { | ||
window.addEventListener("message", t); | ||
}, L = new WeakSet(), W = function(e) { | ||
}, U = new WeakSet(), x = function(e) { | ||
const t = (r) => { | ||
@@ -607,3 +695,3 @@ e.current && e.current(r); | ||
window.addEventListener("message", t); | ||
}, U = new WeakSet(), D = function({ | ||
}, R = new WeakSet(), B = function({ | ||
container: e, | ||
@@ -614,5 +702,5 @@ elementType: t, | ||
}) { | ||
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( | ||
var i, c; | ||
const d = $(), o = new URL(`${d}/vaultField/vaultField.html`); | ||
o.searchParams.set("host", btoa(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", | ||
@@ -624,6 +712,6 @@ (s == null ? void 0 : s.placeholderColor) || "#ccc" | ||
); | ||
const n = document.createElement("iframe"); | ||
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) { | ||
const t = T(), r = te(), s = new URL( | ||
const a = document.createElement("iframe"); | ||
a.src = o.toString(), a.style.height = (c = r.height) != null ? c : "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); | ||
}, _ = new WeakSet(), O = function(e) { | ||
const t = $(), r = se(), s = new URL( | ||
`${t}/vaultSubmit/vaultSubmit.html` | ||
@@ -636,3 +724,3 @@ ); | ||
export { | ||
ie as default | ||
de as default | ||
}; |
@@ -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 C,Y,M,J,F,z,$,K,T,G,H,Q,j,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 V=(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)&&V(o,c,n[c]);if(D)for(var c of D(n))oe.call(n,c)&&V(o,c,n[c]);return o},x=(o,n)=>ne(o,re(n));var m=(o,n,c)=>(V(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 N=b=>{try{k(c.next(b))}catch(U){f(U)}},_=b=>{try{k(c.throw(b))}catch(U){f(U)}},k=b=>b.done?R(b.value):Promise.resolve(b.value).then(N,_);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.5");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 N(p,e){p&&console.warn(e)}const _=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(!_.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 N(!!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.5");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(){var e;return(e=window.MONEYHASH_VAULT_API_URL)!=null?e:"https://vault.moneyhash.io"}function q(){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,C);E(this,M);E(this,F);E(this,$);E(this,T);E(this,H);E(this,j);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,H,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,j,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,C,Y).call(this,e);case"POPUP_IFRAME":return L(this,M,J).call(this,e);case"REDIRECT":return L(this,F,z).call(this,e);default:return null}}}return C=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")},$=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)},H=new WeakSet,Q=function({container:e,elementType:t,elementOptions:s,styles:i}){var l,g;const d=q(),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)},j=new WeakSet,X=function(e){const t=q(),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(d,n){typeof exports=="object"&&typeof module!="undefined"?module.exports=n():typeof define=="function"&&define.amd?define(n):(d=typeof globalThis!="undefined"?globalThis:d||self,d.MoneyHash=n())})(this,function(){var _,J,M,z,F,K,$,G,T,Q,H,X,j,Z,N,ee;"use strict";var re=Object.defineProperty,ae=Object.defineProperties;var oe=Object.getOwnPropertyDescriptors;var x=Object.getOwnPropertySymbols;var de=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable;var q=(d,n,l)=>n in d?re(d,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):d[n]=l,R=(d,n)=>{for(var l in n||(n={}))de.call(n,l)&&q(d,l,n[l]);if(x)for(var l of x(n))ce.call(n,l)&&q(d,l,n[l]);return d},Y=(d,n)=>ae(d,oe(n));var m=(d,n,l)=>(q(d,typeof n!="symbol"?n+"":n,l),l),le=(d,n,l)=>{if(!n.has(d))throw TypeError("Cannot "+l)};var P=(d,n,l)=>{if(n.has(d))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(d):n.set(d,l)};var S=(d,n,l)=>(le(d,n,"access private method"),l);var k=(d,n,l)=>new Promise((I,f)=>{var V=b=>{try{A(l.next(b))}catch(U){f(U)}},C=b=>{try{A(l.throw(b))}catch(U){f(U)}},A=b=>b.done?I(b.value):Promise.resolve(b.value).then(V,C);A((l=l.apply(d,n)).next())});class d{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 l(){return typeof window!="undefined"}const v=class{constructor(){l()&&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.6");const s=document.createElement("iframe");s.id="moneyhash-headless-sdk",s.src=t.toString(),s.hidden=!0,document.body.appendChild(s),v.messagingService=new d({target:s.contentWindow,targetOrigin:e}),v.isCommunicationReady=new Promise(i=>{var r;const o=a=>{var c;a.data.type==="headlessSDK:init"&&(i(),(c=v.messagingService)==null||c.removeListener(o))};(r=v.messagingService)==null||r.onReceive(o)})}request(s){return k(this,arguments,function*({api:e,payload:t}){return yield v.isCommunicationReady,new Promise((i,o)=>{var a,c;(a=v.messagingService)==null||a.send({type:e,data:t});const r=u=>{var y;const{type:h,data:g}=u.data;h===e&&(g.status==="resolved"?i(g.payload):o(g.payload),(y=v.messagingService)==null||y.removeListener(r))};(c=v.messagingService)==null||c.onReceive(r)})})}};let I=v;m(I,"messagingService",null),m(I,"isCommunicationReady");function f(p,e){if(p)throw new Error(e)}function V(p,e){p&&console.warn(e)}const C=new Set(["payment","payout"]),A=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 V(!!e&&!A.has(e),`Supported languages (${[...A].join(" | ")})`),e||"en"}render({selector:e,intentId:t}){var a,c;(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.6");const o=(c=this.options.locale)==null?void 0:c.split("-")[0];o&&i.searchParams.set("lang",o),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 d({target:this.iframe.contentWindow,targetOrigin:s}),this.isCommunicationReady=new Promise(u=>{var g;const h=y=>{var E;y.data.type==="sdk:init"&&(u(),(E=this.messagingService)==null||E.removeListener(h))};(g=this.messagingService)==null||g.onReceive(h)}),this.messagingService.onReceive((u,h)=>{var E,L,w,D;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":{(L=(E=this.options).onComplete)==null||L.call(E,R({type:this.options.type},y)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(D=(w=this.options).onFail)==null||D.call(w,R({type:this.options.type},y)),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 te(){var e;return(e=window.MONEYHASH_VAULT_API_URL)!=null?e:"https://vault.moneyhash.io"}function O(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault.moneyhash.io"}function se(p){return(Array.isArray(p)?p.length:Object.keys(p).length)===0}function ie(p,e){return new Promise((t,s)=>{if(document.getElementById(e)){t(void 0);return}const o=document.createElement("script");o.src=p,o.id=e,o.addEventListener("load",()=>{t(void 0)}),o.addEventListener("error",()=>{s(new Error("Script failed to load"))}),document.body.appendChild(o)})}function W(){var e;return(e=window.API_URL)!=null?e:"https://web.moneyhash.io"}const B=new Set(["method","customerBalance","savedCard"]);class ne{constructor(e){P(this,_);P(this,M);P(this,F);P(this,$);P(this,T);P(this,H);P(this,j);P(this,N);m(this,"options");m(this,"sdkApiHandler",new I);m(this,"sdkEmbed");m(this,"vaultSubmitListener",{current:null});this.options=e,this.sdkEmbed=new b(Y(R({},e),{headless:!0})),S(this,H,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:s,metaData:i}){return f(!B.has(t),`type must be a valid one (${[...B].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(u){return k(this,arguments,function*({intentId:e,currency:t,amount:s,countryCode:i,onCancel:o=()=>{},onError:r,onComplete:a,billingData:c={}}){if(yield ie("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:y,intent:E}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(y==="INTENT_FORM"){if(se(c))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:c}})}}catch(L){throw yield this.resetSelectedMethod(e),L}h.onvalidatemerchant=L=>{fetch(`${W()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:E.secret,validation_url:L.validationURL})}).then(w=>w.ok?w.json():Promise.reject()).then(w=>h.completeMerchantValidation(w)).catch(r)},h.onpaymentauthorized=L=>{fetch(`${W()}/api/v1/providers/applepay/token/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({token_data:L.payment.token,secret:E.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=o,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 S(this,T,Q).call(this,t),{create:({elementType:s,elementOptions:i})=>{const o=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 u,h,g;const{type:c}=a.data;c===`${s}@focus`&&(r.classList.add("MoneyHashElement--focus"),(u=o.get(`${s}@focus`))==null||u()),c===`${s}@blur`&&(r.classList.remove("MoneyHashElement--focus"),(h=o.get(`${s}@blur`))==null||h()),c===`${s}@changeInput`&&((g=o.get(`${s}@changeInput`))==null||g())}),{mount:()=>S(this,j,Z).call(this,{container:r,elementType:s,elementOptions:i,styles:R(R({},e),i.styles)}),on:(a,c)=>{o.set(`${s}@${a}`,c)}}}}}submitForm(o){return k(this,arguments,function*({intentId:e,accessToken:t,billingData:s,shippingData:i}){const r=new U;let a,c;t&&(this.vaultSubmitListener.current=h=>{const{type:g,data:y}=h.data;g==="vaultSubmit:success"&&r.resolve(y),g==="vaultSubmit:error"&&r.reject(y)},c=S(this,N,ee).call(this,t),a=yield r.promise);const u=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"CARD",lang:this.sdkEmbed.lang,billingData:s,shippingData:i,cardEmbed:a}});return c&&c.remove(),u})}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 S(this,_,J).call(this,e);case"POPUP_IFRAME":return S(this,F,K).call(this,e);case"REDIRECT":return S(this,$,G).call(this,e);default:return null}}}return _=new WeakSet,J=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","100%","important"),s.style.setProperty("height","100%","important"),t==null||t.replaceChildren(s),S(this,M,z).call(this,s),s},M=new WeakSet,z=function(e){const t=s=>{var r,a,c,u;const{type:i,data:o}=s.data;switch(i){case"onComplete":(a=(r=this.options).onComplete)==null||a.call(r,R({type:this.options.type},o)),e.remove(),window.removeEventListener("message",t);break;case"onFail":(u=(c=this.options).onFail)==null||u.call(c,R({type:this.options.type},o)),e.remove(),window.removeEventListener("message",t);break}};window.addEventListener("message",t)},F=new WeakSet,K=function(e){return window.open(`${e}`,"","width=600,height=400,left=200,top=200")},$=new WeakSet,G=function(e){return window.open(e,"_blank")},T=new WeakSet,Q=function(e){const t=s=>{e.forEach(i=>{i(s)})};window.addEventListener("message",t)},H=new WeakSet,X=function(e){const t=s=>{e.current&&e.current(s)};window.addEventListener("message",t)},j=new WeakSet,Z=function({container:e,elementType:t,elementOptions:s,styles:i}){var c,u;const o=O(),r=new URL(`${o}/vaultField/vaultField.html`);r.searchParams.set("host",btoa(window.location.origin)),r.searchParams.set("type",t),r.searchParams.set("placeholder",(c=s.placeholder)!=null?c:""),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)},N=new WeakSet,ee=function(e){const t=O(),s=te(),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 o=document.createElement("iframe");return o.id="moneyhash-submit-iframe",o.src=i.toString(),o.hidden=!0,document.body.appendChild(o),o},ne}); |
@@ -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-bae6b7db.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-7ee9ea3f.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; |
@@ -115,3 +115,5 @@ export declare interface AbstractIntent { | ||
export declare type IntentStateDetails<TType extends IntentState = IntentState> = TType extends "FORM_FIELDS" ? FormFields : TType extends "URL_TO_RENDER" ? { | ||
export declare type IntentStateDetails<TType extends IntentState> = TType extends "FORM_FIELDS" ? { | ||
formFields: FormFields; | ||
} : TType extends "URL_TO_RENDER" ? { | ||
url: string; | ||
@@ -191,5 +193,5 @@ renderStrategy: UrlRenderStrategy; | ||
transaction: PaymentTransaction; | ||
redirect: Redirect | null; | ||
selectedMethod: PaymentMethodSlugs | null; | ||
state: IntentState; | ||
stateDetails: IntentStateDetails<IntentState>; | ||
shippingData: Shipping | null; | ||
@@ -222,2 +224,3 @@ productItems: ProductItem[] | null; | ||
state: IntentState; | ||
stateDetails: IntentStateDetails<IntentState>; | ||
}; | ||
@@ -247,6 +250,2 @@ | ||
export declare interface Redirect { | ||
redirectUrl: string; | ||
} | ||
export declare type RefundOperationStatus = "pending" | "failed" | "successful"; | ||
@@ -253,0 +252,0 @@ |
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-ea26512a.js"; | ||
import { S as a, t as d } from "./sdkEmbed-51e0e822.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.5");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.6");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.5", | ||
"version": "1.0.0-beta.6", | ||
"description": "MoneyHash JavaScript SDK", | ||
@@ -5,0 +5,0 @@ "type": "module", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
355991
2036