@transak/transak-sdk
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -1,2 +0,2 @@ | ||
import N from"events";var i=(o=>(o.STAGING="STAGING",o.PRODUCTION="PRODUCTION",o))(i||{});var s=(n=>(n.TRANSAK_WIDGET_INITIALISED="TRANSAK_WIDGET_INITIALISED",n.TRANSAK_ORDER_CREATED="TRANSAK_ORDER_CREATED",n.TRANSAK_ORDER_SUCCESSFUL="TRANSAK_ORDER_SUCCESSFUL",n.TRANSAK_ORDER_CANCELLED="TRANSAK_ORDER_CANCELLED",n.TRANSAK_ORDER_FAILED="TRANSAK_ORDER_FAILED",n.TRANSAK_WALLET_REDIRECTION="TRANSAK_WALLET_REDIRECTION",n.TRANSAK_WIDGET_CLOSE_REQUEST="TRANSAK_WIDGET_CLOSE_REQUEST",n.TRANSAK_WIDGET_CLOSE="TRANSAK_WIDGET_CLOSE",n))(s||{});function A(t,a,o){return` | ||
import N from"events";var i=(o=>(o.STAGING="STAGING",o.PRODUCTION="PRODUCTION",o))(i||{});var s=(n=>(n.TRANSAK_WIDGET_INITIALISED="TRANSAK_WIDGET_INITIALISED",n.TRANSAK_ORDER_CREATED="TRANSAK_ORDER_CREATED",n.TRANSAK_ORDER_SUCCESSFUL="TRANSAK_ORDER_SUCCESSFUL",n.TRANSAK_ORDER_CANCELLED="TRANSAK_ORDER_CANCELLED",n.TRANSAK_ORDER_FAILED="TRANSAK_ORDER_FAILED",n.TRANSAK_WALLET_REDIRECTION="TRANSAK_WALLET_REDIRECTION",n.TRANSAK_WIDGET_CLOSE_REQUEST="TRANSAK_WIDGET_CLOSE_REQUEST",n.TRANSAK_WIDGET_CLOSE="TRANSAK_WIDGET_CLOSE",n))(s||{});function d(e,a,o){return` | ||
#transakRoot { | ||
@@ -31,3 +31,3 @@ z-index: 9997; | ||
transition: 0.5s; | ||
color: #${t}; | ||
color: #${e}; | ||
background: white; | ||
@@ -40,3 +40,3 @@ border-radius: 50%; | ||
color: white; | ||
background: #${t}; | ||
background: #${e}; | ||
cursor: pointer; | ||
@@ -63,3 +63,3 @@ } | ||
} | ||
`}function T(t){let{themeColor:a="1461db",widgetWidth:o="480px",widgetHeight:e="650px"}=t,r=document.createElement("style");return r.innerHTML=A(a,o,e),document.getElementsByTagName("head")[0]?.appendChild(r),r}var d=` | ||
`}function A(e){let{themeColor:a="1461db",widgetWidth:o="480px",widgetHeight:t="650px"}=e,r=document.createElement("style");return r.innerHTML=d(a,o,t),document.getElementsByTagName("head")[0]?.appendChild(r),r}var T=` | ||
<svg id="transakCloseIcon" viewBox="0 0 612 612" fill="currentColor" xmlns="http://www.w3.org/2000/svg"> | ||
@@ -72,8 +72,8 @@ <path d="M306,0C136.992,0,0,136.992,0,306s136.992,306,306,306c168.988,0,306-137.012,306-306S475.008,0,306,0z M414.19,387.147 | ||
</svg> | ||
`;import I from"query-string";import p from"pako";var l={STAGING:"https://global-stg.transak.com",PRODUCTION:"https://global.transak.com"};function R(t){let{environment:a="STAGING"}=t,o={},e="";return Object.keys(t).forEach(r=>{if(!["environment","widgetWidth","widgetHeight"].includes(r)){if(["walletAddressesData","userData"].includes(r)){try{o[r]=JSON.stringify(t[r])}catch{}return}if(["nftData"].includes(r)){try{o[r]=btoa(JSON.stringify(t[r]))}catch{}return}if(["calldata"].includes(r)){try{o[r]=btoa(String.fromCharCode.apply(null,p.deflate(t[r])))}catch{}return}o[r]=t[r]}}),e=I.stringify(o,{arrayFormat:"comma"}),`${l[a]}?${e}`}function S(t,a){let o=R(t),e=document.createElement("div");return e.id="transakRoot",e.innerHTML=` | ||
`;import I from"query-string";import p from"pako";var l={STAGING:"https://global-stg.transak.com",PRODUCTION:"https://global.transak.com"};function R(e){let{environment:a="STAGING"}=e,o={},t="";return Object.keys(e).forEach(r=>{if(!["environment","widgetWidth","widgetHeight"].includes(r)){if(["walletAddressesData","userData"].includes(r)){try{o[r]=JSON.stringify(e[r])}catch{}return}if(["nftData"].includes(r)){try{o[r]=btoa(JSON.stringify(e[r]))}catch{}return}if(["calldata"].includes(r)){try{o[r]=btoa(String.fromCharCode.apply(null,p.deflate(e[r])))}catch{}return}o[r]=e[r]}}),t=I.stringify(o,{arrayFormat:"comma"}),`${l[a]}?${t}`}function S(e,a){let o=R(e),t=document.createElement("div");return t.id="transakRoot",t.innerHTML=` | ||
<div class="transak-modal"> | ||
${d} | ||
${T} | ||
<iframe id="transakIframe" allow="camera;microphone;payment" src="${o}"></iframe> | ||
</div> | ||
`,e.onclick=()=>a(),document.getElementsByTagName("body")[0].appendChild(e),document.getElementById("transakCloseIcon")?.addEventListener("click",()=>a()),e}function _(t,a){return function(e){if(e?.data?.event_id)switch(e.data.event_id){case"TRANSAK_WIDGET_INITIALISED":{t.emit("TRANSAK_WIDGET_INITIALISED",{eventName:"TRANSAK_WIDGET_INITIALISED",status:!0});break}case"TRANSAK_ORDER_CREATED":{t.emit("TRANSAK_ORDER_CREATED",{eventName:"TRANSAK_ORDER_CREATED",status:e.data.data});break}case"TRANSAK_ORDER_SUCCESSFUL":{t.emit("TRANSAK_ORDER_SUCCESSFUL",{eventName:"TRANSAK_ORDER_SUCCESSFUL",status:e.data.data});break}case"TRANSAK_ORDER_CANCELLED":{t.emit("TRANSAK_ORDER_CANCELLED",{eventName:"TRANSAK_ORDER_CANCELLED",status:e.data.data});break}case"TRANSAK_ORDER_FAILED":{t.emit("TRANSAK_ORDER_FAILED",{eventName:"TRANSAK_ORDER_FAILED",status:e.data.data});break}case"TRANSAK_WALLET_REDIRECTION":{t.emit("TRANSAK_WALLET_REDIRECTION",{eventName:"TRANSAK_WALLET_REDIRECTION",status:e.data.data});break}case"TRANSAK_WIDGET_CLOSE":{t.emit("TRANSAK_WIDGET_CLOSE",{eventName:"TRANSAK_WIDGET_CLOSE",status:!0}),a();break}}}}var c=new N.EventEmitter,m=class{#t;#o;#a;#r;#e=!1;static ENVIRONMENTS=i;static EVENTS=s;constructor(a){if(!a?.apiKey)throw new Error("[Transak SDK] => Please enter your API Key");this.#t=a}static on=(a,o)=>{a==="*"?Object.keys(s).forEach(e=>{c.on(s[e],o)}):s[a]&&c.on(a,o)};init=()=>{this.#e||(this.openModal(),this.#e=!0)};openModal=()=>{window.addEventListener("message",_(c,this.close)),this.#o=T(this.#t),this.#a=S(this.#t,this.#n),this.#r=document.getElementById("transakIframe")};close=()=>{this.#o?.remove(),this.#a?.remove(),this.#e=!1};#n=()=>{this.#r?.contentWindow?.postMessage({event_id:"TRANSAK_WIDGET_CLOSE_REQUEST",data:!0},"*")}};export{m as Transak}; | ||
`,t.onclick=()=>a(),document.getElementsByTagName("body")[0].appendChild(t),document.getElementById("transakCloseIcon")?.addEventListener("click",()=>a()),t}function _(e,a){return function(t){if(t?.data?.event_id)switch(t.data.event_id){case"TRANSAK_WIDGET_INITIALISED":{e.emit("TRANSAK_WIDGET_INITIALISED",{eventName:"TRANSAK_WIDGET_INITIALISED",status:!0});break}case"TRANSAK_ORDER_CREATED":{e.emit("TRANSAK_ORDER_CREATED",{eventName:"TRANSAK_ORDER_CREATED",status:t.data.data});break}case"TRANSAK_ORDER_SUCCESSFUL":{e.emit("TRANSAK_ORDER_SUCCESSFUL",{eventName:"TRANSAK_ORDER_SUCCESSFUL",status:t.data.data});break}case"TRANSAK_ORDER_CANCELLED":{e.emit("TRANSAK_ORDER_CANCELLED",{eventName:"TRANSAK_ORDER_CANCELLED",status:t.data.data});break}case"TRANSAK_ORDER_FAILED":{e.emit("TRANSAK_ORDER_FAILED",{eventName:"TRANSAK_ORDER_FAILED",status:t.data.data});break}case"TRANSAK_WALLET_REDIRECTION":{e.emit("TRANSAK_WALLET_REDIRECTION",{eventName:"TRANSAK_WALLET_REDIRECTION",status:t.data.data});break}case"TRANSAK_WIDGET_CLOSE":{e.emit("TRANSAK_WIDGET_CLOSE",{eventName:"TRANSAK_WIDGET_CLOSE",status:!0}),a();break}}}}var E=new N.EventEmitter,c=class{#e;#a;#r;#n;#t;#o=!1;static ENVIRONMENTS=i;static EVENTS=s;constructor(a){if(!a?.apiKey)throw new Error("[Transak SDK] => Please enter your API Key");this.#e=a,this.#t=_(E,this.close)}static on=(a,o)=>{a==="*"?Object.keys(s).forEach(t=>{E.on(s[t],o)}):s[a]&&E.on(a,o)};init=()=>{this.#o||(this.openModal(),this.#o=!0)};openModal=()=>{window.addEventListener("message",this.#t),this.#a=A(this.#e),this.#r=S(this.#e,this.#s),this.#n=document.getElementById("transakIframe")};close=()=>{this.#a?.remove(),this.#r?.remove(),this.#i(),this.#o=!1};#s=()=>{this.#n?.contentWindow?.postMessage({event_id:"TRANSAK_WIDGET_CLOSE_REQUEST",data:!0},"*")};#i=()=>{E.removeAllListeners(),window.removeEventListener("message",this.#t)}};export{c as Transak}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@transak/transak-sdk", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Transak SDK that allows you to easily integrate fiat on/off ramp", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
52688
267