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

dist/sdkEmbed-924184f8.js

2

dist/headless.cjs.js

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

"use strict";var C=Object.defineProperty,L=Object.defineProperties;var R=Object.getOwnPropertyDescriptors;var E=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var w=(s,e,t)=>e in s?C(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,P=(s,e)=>{for(var t in e||(e={}))T.call(e,t)&&w(s,t,e[t]);if(E)for(var t of E(e))U.call(e,t)&&w(s,t,e[t]);return s},b=(s,e)=>L(s,R(e));var m=(s,e,t)=>(w(s,typeof e!="symbol"?e+"":e,t),t);var f=(s,e,t)=>new Promise((a,r)=>{var i=n=>{try{d(t.next(n))}catch(y){r(y)}},o=n=>{try{d(t.throw(n))}catch(y){r(y)}},d=n=>n.done?a(n.value):Promise.resolve(n.value).then(i,o);d((t=t.apply(s,e)).next())});const h=require("./sdkEmbed-192adfda.cjs");function j(){return typeof window!="undefined"}const p=class{constructor(){j()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=h.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@0.2.1");const a=document.createElement("iframe");a.id="moneyhash-headless-sdk",a.src=t.toString(),a.hidden=!0,document.body.appendChild(a),p.messagingService=new h.MessagingService({target:a.contentWindow,targetOrigin:e}),p.isCommunicationReady=new Promise(r=>{var o;const i=d=>{var n;d.data.type==="headlessSDK:init"&&(r(),(n=p.messagingService)==null||n.removeListener(i))};(o=p.messagingService)==null||o.onReceive(i)})}request(a){return f(this,arguments,function*({api:e,payload:t}){return yield p.isCommunicationReady,new Promise((r,i)=>{var d,n;(d=p.messagingService)==null||d.send({type:e,data:t});const o=y=>{var v;const{type:c,data:u}=y.data;c===e&&(u.status==="resolved"?r(u.payload):i(u.payload),(v=p.messagingService)==null||v.removeListener(o))};(n=p.messagingService)==null||n.onReceive(o)})})}};let k=p;m(k,"messagingService",null),m(k,"isCommunicationReady");function M(s){return(Array.isArray(s)?s.length:Object.keys(s).length)===0}function q(s,e){return new Promise((t,a)=>{if(document.getElementById(e)){t(void 0);return}const i=document.createElement("script");i.src=s,i.id=e,i.addEventListener("load",()=>{t(void 0)}),i.addEventListener("error",()=>{a(new Error("Script failed to load"))}),document.body.appendChild(i)})}function A(){var e;return(e=window.API_URL)!=null?e:"https://web.moneyhash.io"}const I=new Set(["method","customerBalance","savedCard"]);class W{constructor(e){m(this,"options");m(this,"sdkApiHandler",new k);m(this,"sdkEmbed");this.options=e,this.sdkEmbed=new h.SDKEmbed(b(P({},e),{headless:!0}))}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:a,metaData:r}){return h.throwIf(!I.has(t),`type must be a valid one (${[...I].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:a,lang:this.sdkEmbed.lang,metaData:r}})}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 h.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(y){return f(this,arguments,function*({intentId:e,currency:t,amount:a,countryCode:r,onCancel:i=()=>{},onError:o,onComplete:d,billingData:n={}}){if(yield q("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)return;const c=new ApplePaySession(3,{countryCode:r,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${a}`}}),{__providerId__:u,state:v,intent:S}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(v==="INTENT_FORM"){if(M(n))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:n}})}}catch(g){throw yield this.resetSelectedMethod(e),g}c.onvalidatemerchant=g=>{fetch(`${A()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:S.secret,validation_url:g.validationURL})}).then(l=>l.ok?l.json():Promise.reject()).then(l=>c.completeMerchantValidation(l)).catch(o)},c.onpaymentauthorized=g=>{fetch(`${A()}/api/v1/providers/applepay/token/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({token_data:g.payment.token,secret:S.secret})}).then(l=>l.ok?l.json():Promise.reject()).then(()=>{c.completePayment(ApplePaySession.STATUS_SUCCESS),d()}).catch(()=>{c.completePayment(ApplePaySession.STATUS_FAILURE),o()})},c.oncancel=i,c.begin()})}renderForm({selector:e,intentId:t}){return h.throwIf(!e,"selector is required for renderForm"),h.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()}}module.exports=W;
"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;

@@ -62,2 +62,26 @@ export declare interface AbstractIntent {

declare type ElementEvents = "focus" | "blur";
declare type ElementProps = {
elementType: ElementType;
elementOptions: {
selector: string;
height?: string;
placeholder?: string;
styles?: ElementStyles;
};
};
declare type ElementsProps = {
styles?: ElementStyles;
};
declare type ElementStyles = {
color?: string;
backgroundColor?: string;
placeholderColor?: string;
};
declare type ElementType = "cardHolderName" | "cardNumber" | "cardCvv" | "cardExpiryMonth" | "cardExpiryYear";
export declare type ErrorResponse = {

@@ -68,2 +92,23 @@ code: number;

export declare type Field<TType extends FieldType = FieldType> = {
type: FieldType;
name: string;
label: string;
hint: string;
value: string;
readOnly: boolean;
validation: {
required: boolean;
minLength: number | null;
maxLength: number | null;
};
options: TType extends "select" ? {
label: string;
value: string;
}[] : never;
dependsOn?: string;
};
export declare type FieldType = "text" | "number" | "email" | "date" | "phoneNumber" | "select" | "depSelect";
export declare type FormField = {

@@ -90,2 +135,10 @@ choices?: Record<string, string> | null;

export declare type FormFields = {
billing: Array<Field> | null;
shipping: Array<Field> | null;
card: {
accessToken: string;
} | null;
};
declare interface InputAllowedStyle {

@@ -120,2 +173,3 @@ height?: number;

selectedMethod: PaymentMethodSlugs | null;
formFields: FormFields;
/**

@@ -133,2 +187,3 @@ * Intent state to guide you through different actions required. check [README](https://docs.moneyhash.io/docs/javascript-sdk#integrating)

selectedMethod: PaymentMethodSlugs | null;
formFields: FormFields;
/**

@@ -171,5 +226,7 @@ * Intent state to guide you through different actions required. check [README](https://docs.moneyhash.io/docs/javascript-sdk#integrating)

declare class MoneyHashHeadless<TType extends IntentType> {
#private;
private options;
private sdkApiHandler;
private sdkEmbed;
private vaultSubmitListener;
constructor(options: MoneyHashHeadlessOptions<TType>);

@@ -373,2 +430,15 @@ /**

removeEventListeners(): Promise<void>;
elements({ styles }: ElementsProps): Promise<{
create: ({ elementType, elementOptions }: ElementProps) => {
mount: () => void;
on: (eventName: ElementEvents, callback: () => void) => void;
};
}>;
submitForm({ intentId, accessToken, providerId, billingData, shippingData, }: {
intentId: string;
accessToken?: string | null;
providerId: string | null;
billingData?: Record<string, unknown>;
shippingData?: Record<string, unknown>;
}): Promise<void>;
}

@@ -375,0 +445,0 @@ export default MoneyHashHeadless;

@@ -1,37 +0,46 @@

var L = Object.defineProperty, I = Object.defineProperties;
var R = Object.getOwnPropertyDescriptors;
var E = Object.getOwnPropertySymbols;
var T = Object.prototype.hasOwnProperty, M = Object.prototype.propertyIsEnumerable;
var S = (s, e, t) => e in s ? L(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, P = (s, e) => {
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 = {}))
T.call(e, t) && S(s, t, e[t]);
if (E)
for (var t of E(e))
M.call(e, t) && S(s, t, e[t]);
return s;
}, A = (s, e) => I(s, R(e));
var m = (s, e, t) => (S(s, typeof e != "symbol" ? e + "" : e, t), t);
var f = (s, e, t) => new Promise((a, r) => {
var i = (n) => {
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 f = (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 v = (a, e, t) => (x(a, e, "access private method"), t);
var P = (a, e, t) => new Promise((i, s) => {
var n = (o) => {
try {
d(t.next(n));
} catch (h) {
r(h);
r(t.next(o));
} catch (c) {
s(c);
}
}, o = (n) => {
}, d = (o) => {
try {
d(t.throw(n));
} catch (h) {
r(h);
r(t.throw(o));
} catch (c) {
s(c);
}
}, d = (n) => n.done ? a(n.value) : Promise.resolve(n.value).then(i, o);
d((t = t.apply(s, e)).next());
}, r = (o) => o.done ? i(o.value) : Promise.resolve(o.value).then(n, d);
r((t = t.apply(a, e)).next());
});
import { M as U, g as j, S as q, t as v } from "./sdkEmbed-c076f4e7.js";
function W() {
import { M as B, g as Y, S as J, t as w } from "./sdkEmbed-924184f8.js";
function O() {
return typeof window != "undefined";
}
const p = class {
const h = class {
constructor() {
W() && this.initSDKCommunicationIframe();
O() && this.initSDKCommunicationIframe();
}

@@ -41,34 +50,34 @@ initSDKCommunicationIframe() {

return;
const e = j(), t = new URL(`${e}/embed/headless-sdk`);
t.searchParams.set("sdk", "true"), t.searchParams.set("parent", window.location.origin), t.searchParams.set("version", "js@0.2.1");
const a = document.createElement("iframe");
a.id = "moneyhash-headless-sdk", a.src = t.toString(), a.hidden = !0, document.body.appendChild(a), p.messagingService = new U({
target: a.contentWindow,
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");
const i = document.createElement("iframe");
i.id = "moneyhash-headless-sdk", i.src = t.toString(), i.hidden = !0, document.body.appendChild(i), h.messagingService = new B({
target: i.contentWindow,
targetOrigin: e
}), p.isCommunicationReady = new Promise((r) => {
var o;
const i = (d) => {
var n;
d.data.type === "headlessSDK:init" && (r(), (n = p.messagingService) == null || n.removeListener(i));
}), 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));
};
(o = p.messagingService) == null || o.onReceive(i);
(d = h.messagingService) == null || d.onReceive(n);
});
}
request(a) {
return f(this, arguments, function* ({
request(i) {
return P(this, arguments, function* ({
api: e,
payload: t
}) {
return yield p.isCommunicationReady, new Promise((r, i) => {
var d, n;
(d = p.messagingService) == null || d.send({
return yield h.isCommunicationReady, new Promise((s, n) => {
var r, o;
(r = h.messagingService) == null || r.send({
type: e,
data: t
});
const o = (h) => {
var k;
const { type: c, data: y } = h.data;
c === e && (y.status === "resolved" ? r(y.payload) : i(y.payload), (k = p.messagingService) == null || k.removeListener(o));
const d = (c) => {
var u;
const { type: l, data: p } = c.data;
l === e && (p.status === "resolved" ? s(p.payload) : n(p.payload), (u = h.messagingService) == null || u.removeListener(d));
};
(n = p.messagingService) == null || n.onReceive(o);
(o = h.messagingService) == null || o.onReceive(d);
});

@@ -78,9 +87,26 @@ });

};
let g = p;
m(g, "messagingService", null), m(g, "isCommunicationReady");
function F(s) {
return (Array.isArray(s) ? s.length : Object.keys(s).length) === 0;
let b = h;
m(b, "messagingService", null), m(b, "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 H(s, e) {
return new Promise((t, a) => {
function K() {
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 G(a) {
return (Array.isArray(a) ? a.length : Object.keys(a).length) === 0;
}
function Q(a, e) {
return new Promise((t, i) => {
if (document.getElementById(e)) {

@@ -90,15 +116,15 @@ t(void 0);

}
const i = document.createElement("script");
i.src = s, i.id = e, i.addEventListener("load", () => {
const n = document.createElement("script");
n.src = a, n.id = e, n.addEventListener("load", () => {
t(void 0);
}), i.addEventListener("error", () => {
a(new Error("Script failed to load"));
}), document.body.appendChild(i);
}), n.addEventListener("error", () => {
i(new Error("Script failed to load"));
}), document.body.appendChild(n);
});
}
function b() {
function M() {
var e;
return (e = window.API_URL) != null ? e : "https://web.moneyhash.io";
}
const C = /* @__PURE__ */ new Set([
const T = /* @__PURE__ */ new Set([
"method",

@@ -108,8 +134,16 @@ "customerBalance",

]);
class B {
var L, F, A, V, k, $, E, j;
class ee {
constructor(e) {
f(this, L);
f(this, A);
f(this, k);
f(this, E);
m(this, "options");
m(this, "sdkApiHandler", new g());
m(this, "sdkApiHandler", new b());
m(this, "sdkEmbed");
this.options = e, this.sdkEmbed = new q(A(P({}, e), { headless: !0 }));
m(this, "vaultSubmitListener", {
current: null
});
this.options = e, this.sdkEmbed = new J(_(S({}, e), { headless: !0 })), v(this, A, V).call(this, this.vaultSubmitListener);
}

@@ -205,8 +239,8 @@ /**

type: t,
id: a,
metaData: r
id: i,
metaData: s
}) {
return v(
!C.has(t),
`type must be a valid one (${[...C].join(
return w(
!T.has(t),
`type must be a valid one (${[...T].join(
" | "

@@ -220,5 +254,5 @@ )})`

intentId: e,
id: a,
id: i,
lang: this.sdkEmbed.lang,
metaData: r
metaData: s
}

@@ -269,3 +303,3 @@ });

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

@@ -320,15 +354,15 @@ "deleteCard is allowed only for payment intent!"

*/
payWithApplePay(h) {
return f(this, arguments, function* ({
payWithApplePay(c) {
return P(this, arguments, function* ({
intentId: e,
currency: t,
amount: a,
countryCode: r,
onCancel: i = () => {
amount: i,
countryCode: s,
onCancel: n = () => {
},
onError: o,
onComplete: d,
billingData: n = {}
onError: d,
onComplete: r,
billingData: o = {}
}) {
if (yield H(
if (yield Q(
"https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js",

@@ -338,4 +372,4 @@ "moneyHash-apple-pay-sdk"

return;
const c = new ApplePaySession(3, {
countryCode: r,
const l = new ApplePaySession(3, {
countryCode: s,
currencyCode: t,

@@ -347,8 +381,8 @@ supportedNetworks: ["visa", "masterCard", "amex", "discover", "mada"],

type: "final",
amount: `${a}`
amount: `${i}`
}
}), {
__providerId__: y,
state: k,
intent: w
__providerId__: p,
state: u,
intent: U
} = yield this.proceedWith({

@@ -360,4 +394,4 @@ intentId: e,

try {
if (k === "INTENT_FORM") {
if (F(n))
if (u === "INTENT_FORM") {
if (G(o))
throw new Error(

@@ -371,13 +405,13 @@ "Billing data is missing while calling payWithApplePay"

paymentMethod: "APPLE_PAY",
providerId: y,
providerId: p,
lang: this.sdkEmbed.lang,
billingData: n
billingData: o
}
});
}
} catch (u) {
throw yield this.resetSelectedMethod(e), u;
} catch (g) {
throw yield this.resetSelectedMethod(e), g;
}
c.onvalidatemerchant = (u) => {
fetch(`${b()}/api/v1/providers/applepay/session/`, {
l.onvalidatemerchant = (g) => {
fetch(`${M()}/api/v1/providers/applepay/session/`, {
method: "post",

@@ -388,10 +422,10 @@ headers: {

body: JSON.stringify({
secret: w.secret,
validation_url: u.validationURL
secret: U.secret,
validation_url: g.validationURL
})
}).then((l) => l.ok ? l.json() : Promise.reject()).then(
(l) => c.completeMerchantValidation(l)
).catch(o);
}, c.onpaymentauthorized = (u) => {
fetch(`${b()}/api/v1/providers/applepay/token/`, {
}).then((y) => y.ok ? y.json() : Promise.reject()).then(
(y) => l.completeMerchantValidation(y)
).catch(d);
}, l.onpaymentauthorized = (g) => {
fetch(`${M()}/api/v1/providers/applepay/token/`, {
method: "post",

@@ -402,11 +436,11 @@ headers: {

body: JSON.stringify({
token_data: u.payment.token,
secret: w.secret
token_data: g.payment.token,
secret: U.secret
})
}).then((l) => l.ok ? l.json() : Promise.reject()).then(() => {
c.completePayment(ApplePaySession.STATUS_SUCCESS), d();
}).then((y) => y.ok ? y.json() : Promise.reject()).then(() => {
l.completePayment(ApplePaySession.STATUS_SUCCESS), r();
}).catch(() => {
c.completePayment(ApplePaySession.STATUS_FAILURE), o();
l.completePayment(ApplePaySession.STATUS_FAILURE), d();
});
}, c.oncancel = i, c.begin();
}, l.oncancel = n, l.begin();
});

@@ -431,3 +465,3 @@ }

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

@@ -456,5 +490,99 @@ /**

}
elements(t) {
return P(this, arguments, function* ({ styles: e }) {
const i = [];
return v(this, L, F).call(this, i), {
create: ({ elementType: s, elementOptions: n }) => {
const d = /* @__PURE__ */ new Map(), r = document.querySelector(
n.selector
);
return w(
!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: () => v(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 P(this, arguments, function* ({
intentId: e,
accessToken: t,
providerId: i,
billingData: s,
shippingData: n
}) {
const r = new z();
let o, c;
t && (this.vaultSubmitListener.current = (l) => {
const { type: p, data: u } = l.data;
p === "vaultSubmit:success" && r.resolve(u), p === "vaultSubmit:error" && r.reject(u);
}, c = v(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 = K(), 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;
};
export {
B as default
ee as default
};

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

(function(i,s){typeof exports=="object"&&typeof module!="undefined"?module.exports=s():typeof define=="function"&&define.amd?define(s):(i=typeof globalThis!="undefined"?globalThis:i||self,i.MoneyHash=s())})(this,function(){"use strict";var $=Object.defineProperty,q=Object.defineProperties;var B=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable;var M=(i,s,n)=>s in i?$(i,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[s]=n,C=(i,s)=>{for(var n in s||(s={}))W.call(s,n)&&M(i,n,s[n]);if(F)for(var n of F(s))N.call(s,n)&&M(i,n,s[n]);return i},O=(i,s)=>q(i,B(s));var h=(i,s,n)=>(M(i,typeof s!="symbol"?s+"":s,n),n);var A=(i,s,n)=>new Promise((b,y)=>{var I=f=>{try{E(n.next(f))}catch(R){y(R)}},L=f=>{try{E(n.throw(f))}catch(R){y(R)}},E=f=>f.done?b(f.value):Promise.resolve(f.value).then(I,L);E((n=n.apply(i,s)).next())});class i{constructor(e){h(this,"target");h(this,"targetOrigin");h(this,"listeners");h(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 s(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}function n(){return typeof window!="undefined"}const m=class{constructor(){n()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=s(),t=new URL(`${e}/embed/headless-sdk`);t.searchParams.set("sdk","true"),t.searchParams.set("parent",window.location.origin),t.searchParams.set("version","js@0.2.1");const o=document.createElement("iframe");o.id="moneyhash-headless-sdk",o.src=t.toString(),o.hidden=!0,document.body.appendChild(o),m.messagingService=new i({target:o.contentWindow,targetOrigin:e}),m.isCommunicationReady=new Promise(d=>{var p;const a=v=>{var l;v.data.type==="headlessSDK:init"&&(d(),(l=m.messagingService)==null||l.removeListener(a))};(p=m.messagingService)==null||p.onReceive(a)})}request(o){return A(this,arguments,function*({api:e,payload:t}){return yield m.isCommunicationReady,new Promise((d,a)=>{var v,l;(v=m.messagingService)==null||v.send({type:e,data:t});const p=P=>{var w;const{type:c,data:g}=P.data;c===e&&(g.status==="resolved"?d(g.payload):a(g.payload),(w=m.messagingService)==null||w.removeListener(p))};(l=m.messagingService)==null||l.onReceive(p)})})}};let b=m;h(b,"messagingService",null),h(b,"isCommunicationReady");function y(r,e){if(r)throw new Error(e)}function I(r,e){r&&console.warn(e)}const L=new Set(["payment","payout"]),E=new Set(["en","fr","ar"]);class f{constructor(e){h(this,"options");h(this,"messagingService",null);h(this,"iframe",null);h(this,"isCommunicationReady",null);y(!L.has(e.type),`MoneyHash constructor must be called with valid type (${[...L].join(" | ")})!`),this.options=e}get lang(){var t;const e=(t=this.options.locale)==null?void 0:t.split("-")[0];return I(!!e&&!E.has(e),`Supported languages (${[...E].join(" | ")})`),e||"en"}render({selector:e,intentId:t}){var v,l;(v=this.messagingService)==null||v.abortService();const o=s(),d=new URL(`${o}/embed/${this.options.type}/${t}`);d.searchParams.set("sdk","true"),d.searchParams.set("parent",window.location.origin),d.searchParams.set("version","js@0.2.1");const a=(l=this.options.locale)==null?void 0:l.split("-")[0];a&&d.searchParams.set("lang",a),this.iframe=document.createElement("iframe"),this.iframe.src=d.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0";const p=document.querySelector(e);return y(!p,`Couldn't find an element with selector ${e}!`),p.replaceChildren(this.iframe),this.messagingService=new i({target:this.iframe.contentWindow,targetOrigin:o}),this.isCommunicationReady=new Promise(P=>{var g;const c=w=>{var S;w.data.type==="sdk:init"&&(P(),(S=this.messagingService)==null||S.removeListener(c))};(g=this.messagingService)==null||g.onReceive(c)}),this.messagingService.onReceive((P,c)=>{var S,k,u,j;const{type:g,data:w}=P.data;switch(g){case"sdk:init":{c({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(k=(S=this.options).onComplete)==null||k.call(S,C({type:this.options.type},w)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(j=(u=this.options).onFail)==null||j.call(u,C({type:this.options.type},w)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}}}),this.isCommunicationReady}setLocale(e){return A(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 A(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}function R(r){return(Array.isArray(r)?r.length:Object.keys(r).length)===0}function _(r,e){return new Promise((t,o)=>{if(document.getElementById(e)){t(void 0);return}const a=document.createElement("script");a.src=r,a.id=e,a.addEventListener("load",()=>{t(void 0)}),a.addEventListener("error",()=>{o(new Error("Script failed to load"))}),document.body.appendChild(a)})}function U(){var e;return(e=window.API_URL)!=null?e:"https://web.moneyhash.io"}const T=new Set(["method","customerBalance","savedCard"]);class H{constructor(e){h(this,"options");h(this,"sdkApiHandler",new b);h(this,"sdkEmbed");this.options=e,this.sdkEmbed=new f(O(C({},e),{headless:!0}))}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:d}){return y(!T.has(t),`type must be a valid one (${[...T].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:o,lang:this.sdkEmbed.lang,metaData:d}})}resetSelectedMethod(e){return this.sdkApiHandler.request({api:"sdk:resetSelectedMethod",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}deleteCard({cardId:e,intentSecret:t}){return y(this.options.type==="payout","deleteCard is allowed only for payment intent!"),this.sdkApiHandler.request({api:"sdk:deleteCard",payload:{cardId:e,intentSecret:t,lang:this.sdkEmbed.lang}})}payWithApplePay(P){return A(this,arguments,function*({intentId:e,currency:t,amount:o,countryCode:d,onCancel:a=()=>{},onError:p,onComplete:v,billingData:l={}}){if(yield _("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)return;const c=new ApplePaySession(3,{countryCode:d,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${o}`}}),{__providerId__:g,state:w,intent:S}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(w==="INTENT_FORM"){if(R(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(k){throw yield this.resetSelectedMethod(e),k}c.onvalidatemerchant=k=>{fetch(`${U()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:S.secret,validation_url:k.validationURL})}).then(u=>u.ok?u.json():Promise.reject()).then(u=>c.completeMerchantValidation(u)).catch(p)},c.onpaymentauthorized=k=>{fetch(`${U()}/api/v1/providers/applepay/token/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({token_data:k.payment.token,secret:S.secret})}).then(u=>u.ok?u.json():Promise.reject()).then(()=>{c.completePayment(ApplePaySession.STATUS_SUCCESS),v()}).catch(()=>{c.completePayment(ApplePaySession.STATUS_FAILURE),p()})},c.oncancel=a,c.begin()})}renderForm({selector:e,intentId:t}){return y(!e,"selector is required for renderForm"),y(!t,"intentId is required for renderForm"),this.sdkEmbed.render({selector:e,intentId:t})}setLocale(e){return this.sdkEmbed.setLocale(e)}removeEventListeners(){return this.sdkEmbed.abortService()}}return H});
(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});

@@ -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-192adfda.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-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;

@@ -42,2 +42,31 @@ export declare interface AbstractIntent {

export declare type Field<TType extends FieldType = FieldType> = {
type: FieldType;
name: string;
label: string;
hint: string;
value: string;
readOnly: boolean;
validation: {
required: boolean;
minLength: number | null;
maxLength: number | null;
};
options: TType extends "select" ? {
label: string;
value: string;
}[] : never;
dependsOn?: string;
};
export declare type FieldType = "text" | "number" | "email" | "date" | "phoneNumber" | "select" | "depSelect";
export declare type FormFields = {
billing: Array<Field> | null;
shipping: Array<Field> | null;
card: {
accessToken: string;
} | null;
};
declare interface InputAllowedStyle {

@@ -44,0 +73,0 @@ height?: number;

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-c076f4e7.js";
import { S as a, t as d } from "./sdkEmbed-924184f8.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@0.2.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});
(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});
{
"name": "@moneyhash/js-sdk",
"version": "0.2.2",
"version": "1.0.0-beta.0",
"description": "MoneyHash JavaScript SDK",

@@ -98,2 +98,3 @@ "type": "module",

"prettier": "2.5.1",
"release-it": "^17.6.0",
"typescript": "^4.9.3",

@@ -100,0 +101,0 @@ "vite": "^4.1.0",

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