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

@moneyhash/js-sdk

Package Overview
Dependencies
Maintainers
5
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.1.2 to 0.1.3

dist/sdkEmbed-63f0e6d5.cjs

2

dist/headless.cjs.js

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

"use strict";var S=Object.defineProperty,I=Object.defineProperties;var C=Object.getOwnPropertyDescriptors;var k=Object.getOwnPropertySymbols;var R=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var g=(s,e,t)=>e in s?S(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,v=(s,e)=>{for(var t in e||(e={}))R.call(e,t)&&g(s,t,e[t]);if(k)for(var t of k(e))q.call(e,t)&&g(s,t,e[t]);return s},f=(s,e)=>I(s,C(e));var l=(s,e,t)=>(g(s,typeof e!="symbol"?e+"":e,t),t);var w=(s,e,t)=>new Promise((r,a)=>{var m=n=>{try{d(t.next(n))}catch(h){a(h)}},o=n=>{try{d(t.throw(n))}catch(h){a(h)}},d=n=>n.done?r(n.value):Promise.resolve(n.value).then(m,o);d((t=t.apply(s,e)).next())});const c=require("./sdkEmbed-3db7ea8f.cjs");function L(){return typeof window!="undefined"}const i=class{constructor(){L()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=c.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.1.1");const r=document.createElement("iframe");r.id="moneyhash-headless-sdk",r.src=t.toString(),r.hidden=!0,document.body.appendChild(r),i.messagingService=new c.MessagingService({target:r.contentWindow,targetOrigin:e}),i.isCommunicationReady=new Promise(a=>{var o;const m=d=>{var n;d.data.type==="headlessSDK:init"&&(a(),(n=i.messagingService)==null||n.removeListener(m))};(o=i.messagingService)==null||o.onReceive(m)})}request(r){return w(this,arguments,function*({api:e,payload:t}){return yield i.isCommunicationReady,new Promise((a,m)=>{var d,n;(d=i.messagingService)==null||d.send({type:e,data:t});const o=h=>{var y;const{type:E,data:u}=h.data;E===e&&(u.status==="resolved"?a(u.payload):m(u.payload),(y=i.messagingService)==null||y.removeListener(o))};(n=i.messagingService)==null||n.onReceive(o)})})}};let p=i;l(p,"messagingService",null),l(p,"isCommunicationReady");const b=new Set(["method","customerBalance","savedCard"]);class M{constructor(e){l(this,"options");l(this,"sdkApiHandler",new p);l(this,"sdkEmbed");this.options=e,this.sdkEmbed=new c.SDKEmbed(f(v({},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:r,metaData:a}){return c.throwIf(!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:r,lang:this.sdkEmbed.lang,metaData:a}})}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 c.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}})}renderForm({selector:e,intentId:t}){return c.throwIf(!e,"selector is required for renderForm"),c.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=M;
"use strict";var S=Object.defineProperty,I=Object.defineProperties;var C=Object.getOwnPropertyDescriptors;var k=Object.getOwnPropertySymbols;var R=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var g=(s,e,t)=>e in s?S(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,v=(s,e)=>{for(var t in e||(e={}))R.call(e,t)&&g(s,t,e[t]);if(k)for(var t of k(e))q.call(e,t)&&g(s,t,e[t]);return s},f=(s,e)=>I(s,C(e));var l=(s,e,t)=>(g(s,typeof e!="symbol"?e+"":e,t),t);var w=(s,e,t)=>new Promise((r,a)=>{var m=n=>{try{d(t.next(n))}catch(h){a(h)}},o=n=>{try{d(t.throw(n))}catch(h){a(h)}},d=n=>n.done?r(n.value):Promise.resolve(n.value).then(m,o);d((t=t.apply(s,e)).next())});const c=require("./sdkEmbed-63f0e6d5.cjs");function L(){return typeof window!="undefined"}const i=class{constructor(){L()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=c.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.1.2");const r=document.createElement("iframe");r.id="moneyhash-headless-sdk",r.src=t.toString(),r.hidden=!0,document.body.appendChild(r),i.messagingService=new c.MessagingService({target:r.contentWindow,targetOrigin:e}),i.isCommunicationReady=new Promise(a=>{var o;const m=d=>{var n;d.data.type==="headlessSDK:init"&&(a(),(n=i.messagingService)==null||n.removeListener(m))};(o=i.messagingService)==null||o.onReceive(m)})}request(r){return w(this,arguments,function*({api:e,payload:t}){return yield i.isCommunicationReady,new Promise((a,m)=>{var d,n;(d=i.messagingService)==null||d.send({type:e,data:t});const o=h=>{var y;const{type:E,data:u}=h.data;E===e&&(u.status==="resolved"?a(u.payload):m(u.payload),(y=i.messagingService)==null||y.removeListener(o))};(n=i.messagingService)==null||n.onReceive(o)})})}};let p=i;l(p,"messagingService",null),l(p,"isCommunicationReady");const b=new Set(["method","customerBalance","savedCard"]);class M{constructor(e){l(this,"options");l(this,"sdkApiHandler",new p);l(this,"sdkEmbed");this.options=e,this.sdkEmbed=new c.SDKEmbed(f(v({},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:r,metaData:a}){return c.throwIf(!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:r,lang:this.sdkEmbed.lang,metaData:a}})}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 c.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}})}renderForm({selector:e,intentId:t}){return c.throwIf(!e,"selector is required for renderForm"),c.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=M;

@@ -118,2 +118,7 @@ export declare interface AbstractIntent {

export declare interface LoaderStyle {
backgroundColor: string;
color: string;
}
export declare interface Method {

@@ -388,2 +393,3 @@ id: PaymentMethodSlugs;

input?: InputStyle;
loader?: LoaderStyle;
};

@@ -390,0 +396,0 @@ }

@@ -30,3 +30,3 @@ var S = Object.defineProperty, C = Object.defineProperties;

});
import { M, g as L, S as P, t as p } from "./sdkEmbed-995d6e0d.js";
import { M, g as L, S as P, t as p } from "./sdkEmbed-adf5d163.js";
function H() {

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

const e = L(), 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.1.1");
t.searchParams.set("sdk", "true"), t.searchParams.set("parent", window.location.origin), t.searchParams.set("version", "js@0.1.2");
const r = document.createElement("iframe");

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

@@ -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 T=Object.defineProperty,U=Object.defineProperties;var $=Object.getOwnPropertyDescriptors;var A=Object.getOwnPropertySymbols;var B=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var L=(i,s,n)=>s in i?T(i,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[s]=n,I=(i,s)=>{for(var n in s||(s={}))B.call(s,n)&&L(i,n,s[n]);if(A)for(var n of A(s))j.call(s,n)&&L(i,n,s[n]);return i},H=(i,s)=>U(i,$(s));var a=(i,s,n)=>(L(i,typeof s!="symbol"?s+"":s,n),n);var M=(i,s,n)=>new Promise((p,h)=>{var C=c=>{try{w(n.next(c))}catch(k){h(k)}},E=c=>{try{w(n.throw(c))}catch(k){h(k)}},w=c=>c.done?p(c.value):Promise.resolve(c.value).then(C,E);w((n=n.apply(i,s)).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(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 o=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.1.1");const d=document.createElement("iframe");d.id="moneyhash-headless-sdk",d.src=t.toString(),d.hidden=!0,document.body.appendChild(d),o.messagingService=new i({target:d.contentWindow,targetOrigin:e}),o.isCommunicationReady=new Promise(r=>{var m;const y=f=>{var l;f.data.type==="headlessSDK:init"&&(r(),(l=o.messagingService)==null||l.removeListener(y))};(m=o.messagingService)==null||m.onReceive(y)})}request(d){return M(this,arguments,function*({api:e,payload:t}){return yield o.isCommunicationReady,new Promise((r,y)=>{var f,l;(f=o.messagingService)==null||f.send({type:e,data:t});const m=b=>{var v;const{type:S,data:g}=b.data;S===e&&(g.status==="resolved"?r(g.payload):y(g.payload),(v=o.messagingService)==null||v.removeListener(m))};(l=o.messagingService)==null||l.onReceive(m)})})}};let p=o;a(p,"messagingService",null),a(p,"isCommunicationReady");function h(u,e){if(u)throw new Error(e)}function C(u,e){u&&console.warn(e)}const E=new Set(["payment","payout"]),w=new Set(["en","fr","ar"]);class c{constructor(e){a(this,"options");a(this,"messagingService",null);a(this,"iframe",null);a(this,"isCommunicationReady",null);h(!E.has(e.type),`MoneyHash constructor must be called with valid type (${[...E].join(" | ")})!`),this.options=e}get lang(){var t;const e=(t=this.options.locale)==null?void 0:t.split("-")[0];return C(!!e&&!w.has(e),`Supported languages (${[...w].join(" | ")})`),e||"en"}render({selector:e,intentId:t}){var f,l;(f=this.messagingService)==null||f.abortService();const d=s(),r=new URL(`${d}/embed/${this.options.type}/${t}`);r.searchParams.set("sdk","true"),r.searchParams.set("parent",window.location.origin),r.searchParams.set("version","js@0.1.1");const y=(l=this.options.locale)==null?void 0:l.split("-")[0];y&&r.searchParams.set("lang",y),this.iframe=document.createElement("iframe"),this.iframe.src=r.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0";const m=document.querySelector(e);return h(!m,`Couldn't find an element with selector ${e}!`),m.replaceChildren(this.iframe),this.messagingService=new i({target:this.iframe.contentWindow,targetOrigin:d}),this.isCommunicationReady=new Promise(b=>{var g;const S=v=>{var R;v.data.type==="sdk:init"&&(b(),(R=this.messagingService)==null||R.removeListener(S))};(g=this.messagingService)==null||g.onReceive(S)}),this.messagingService.onReceive((b,S)=>{var R,P,F,q;const{type:g,data:v}=b.data;switch(g){case"sdk:init":{S({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(P=(R=this.options).onComplete)==null||P.call(R,I({type:this.options.type},v)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(q=(F=this.options).onFail)==null||q.call(F,I({type:this.options.type},v)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}}}),this.isCommunicationReady}setLocale(e){return M(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 M(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}const k=new Set(["method","customerBalance","savedCard"]);class O{constructor(e){a(this,"options");a(this,"sdkApiHandler",new p);a(this,"sdkEmbed");this.options=e,this.sdkEmbed=new c(H(I({},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:d,metaData:r}){return h(!k.has(t),`type must be a valid one (${[...k].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:d,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(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}})}renderForm({selector:e,intentId:t}){return h(!e,"selector is required for renderForm"),h(!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 O});
(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 T=Object.defineProperty,U=Object.defineProperties;var $=Object.getOwnPropertyDescriptors;var A=Object.getOwnPropertySymbols;var B=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var L=(i,s,n)=>s in i?T(i,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[s]=n,I=(i,s)=>{for(var n in s||(s={}))B.call(s,n)&&L(i,n,s[n]);if(A)for(var n of A(s))j.call(s,n)&&L(i,n,s[n]);return i},H=(i,s)=>U(i,$(s));var a=(i,s,n)=>(L(i,typeof s!="symbol"?s+"":s,n),n);var M=(i,s,n)=>new Promise((p,h)=>{var C=c=>{try{w(n.next(c))}catch(k){h(k)}},E=c=>{try{w(n.throw(c))}catch(k){h(k)}},w=c=>c.done?p(c.value):Promise.resolve(c.value).then(C,E);w((n=n.apply(i,s)).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(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 o=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.1.2");const d=document.createElement("iframe");d.id="moneyhash-headless-sdk",d.src=t.toString(),d.hidden=!0,document.body.appendChild(d),o.messagingService=new i({target:d.contentWindow,targetOrigin:e}),o.isCommunicationReady=new Promise(r=>{var m;const y=f=>{var l;f.data.type==="headlessSDK:init"&&(r(),(l=o.messagingService)==null||l.removeListener(y))};(m=o.messagingService)==null||m.onReceive(y)})}request(d){return M(this,arguments,function*({api:e,payload:t}){return yield o.isCommunicationReady,new Promise((r,y)=>{var f,l;(f=o.messagingService)==null||f.send({type:e,data:t});const m=b=>{var v;const{type:S,data:g}=b.data;S===e&&(g.status==="resolved"?r(g.payload):y(g.payload),(v=o.messagingService)==null||v.removeListener(m))};(l=o.messagingService)==null||l.onReceive(m)})})}};let p=o;a(p,"messagingService",null),a(p,"isCommunicationReady");function h(u,e){if(u)throw new Error(e)}function C(u,e){u&&console.warn(e)}const E=new Set(["payment","payout"]),w=new Set(["en","fr","ar"]);class c{constructor(e){a(this,"options");a(this,"messagingService",null);a(this,"iframe",null);a(this,"isCommunicationReady",null);h(!E.has(e.type),`MoneyHash constructor must be called with valid type (${[...E].join(" | ")})!`),this.options=e}get lang(){var t;const e=(t=this.options.locale)==null?void 0:t.split("-")[0];return C(!!e&&!w.has(e),`Supported languages (${[...w].join(" | ")})`),e||"en"}render({selector:e,intentId:t}){var f,l;(f=this.messagingService)==null||f.abortService();const d=s(),r=new URL(`${d}/embed/${this.options.type}/${t}`);r.searchParams.set("sdk","true"),r.searchParams.set("parent",window.location.origin),r.searchParams.set("version","js@0.1.2");const y=(l=this.options.locale)==null?void 0:l.split("-")[0];y&&r.searchParams.set("lang",y),this.iframe=document.createElement("iframe"),this.iframe.src=r.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0";const m=document.querySelector(e);return h(!m,`Couldn't find an element with selector ${e}!`),m.replaceChildren(this.iframe),this.messagingService=new i({target:this.iframe.contentWindow,targetOrigin:d}),this.isCommunicationReady=new Promise(b=>{var g;const S=v=>{var R;v.data.type==="sdk:init"&&(b(),(R=this.messagingService)==null||R.removeListener(S))};(g=this.messagingService)==null||g.onReceive(S)}),this.messagingService.onReceive((b,S)=>{var R,P,F,q;const{type:g,data:v}=b.data;switch(g){case"sdk:init":{S({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(P=(R=this.options).onComplete)==null||P.call(R,I({type:this.options.type},v)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(q=(F=this.options).onFail)==null||q.call(F,I({type:this.options.type},v)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}}}),this.isCommunicationReady}setLocale(e){return M(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 M(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}const k=new Set(["method","customerBalance","savedCard"]);class O{constructor(e){a(this,"options");a(this,"sdkApiHandler",new p);a(this,"sdkEmbed");this.options=e,this.sdkEmbed=new c(H(I({},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:d,metaData:r}){return h(!k.has(t),`type must be a valid one (${[...k].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:d,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(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}})}renderForm({selector:e,intentId:t}){return h(!e,"selector is required for renderForm"),h(!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 O});

@@ -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-3db7ea8f.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-63f0e6d5.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;

@@ -63,2 +63,7 @@ export declare interface AbstractIntent {

export declare interface LoaderStyle {
backgroundColor: string;
color: string;
}
declare class MoneyHash<TType extends IntentType> {

@@ -212,2 +217,3 @@ options: MoneyHashOptions<TType>;

input?: InputStyle;
loader?: LoaderStyle;
};

@@ -214,0 +220,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-995d6e0d.js";
import { S as a, t as d } from "./sdkEmbed-adf5d163.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.1.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@0.1.2");const R=(M=this.options.locale)==null?void 0:M.split("-")[0];R&&c.searchParams.set("lang",R),this.iframe=document.createElement("iframe"),this.iframe.src=c.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0";const E=document.querySelector(e);return t(!E,`Couldn't find an element with selector ${e}!`),E.replaceChildren(this.iframe),this.messagingService=new i({target:this.iframe.contentWindow,targetOrigin:S}),this.isCommunicationReady=new Promise(y=>{var l;const g=u=>{var d;u.data.type==="sdk:init"&&(y(),(d=this.messagingService)==null||d.removeListener(g))};(l=this.messagingService)==null||l.onReceive(g)}),this.messagingService.onReceive((y,g)=>{var d,k,I,C;const{type:l,data:u}=y.data;switch(l){case"sdk:init":{g({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(k=(d=this.options).onComplete)==null||k.call(d,w({type:this.options.type},u)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(C=(I=this.options).onFail)==null||C.call(I,w({type:this.options.type},u)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}}}),this.isCommunicationReady}setLocale(e){return b(this,null,function*(){var r;yield this==null?void 0:this.isCommunicationReady,this.options.locale=e,(r=this.messagingService)==null||r.send({type:"changeLanguage",data:{locale:e}})})}abortService(){return b(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}class h{constructor(e){a(this,"options");a(this,"sdkEmbed");this.options=e,this.sdkEmbed=new f(e)}start({selector:e,intentId:r}){return t(!e,"selector is required for start"),t(!r,"intentId is required for start"),this.sdkEmbed.render({selector:e,intentId:r})}setLocale(e){return this.sdkEmbed.setLocale(e)}removeEventListeners(){return this.sdkEmbed.abortService()}}return h});
{
"name": "@moneyhash/js-sdk",
"version": "0.1.2",
"version": "0.1.3",
"description": "MoneyHash JavaScript SDK",

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc