@monerium/sdk 2.11.0 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.12.0](https://github.com/monerium/js-sdk/compare/sdk-v2.11.1...sdk-v2.12.0) (2024-03-12)
4
+
5
+ ### Bug Fixes
6
+
7
+ * upload document ([0f6d49d](https://github.com/monerium/js-sdk/commit/0f6d49d821afa72c4a61e94e7a3a1377357dc727))
8
+
9
+ ## [2.11.1](https://github.com/monerium/js-sdk/compare/sdk-v2.11.0...sdk-v2.11.1) (2024-03-12)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * upload document ([0f6d49d](https://github.com/monerium/js-sdk/commit/0f6d49d821afa72c4a61e94e7a3a1377357dc727))
15
+
3
16
  ## [2.11.0](https://github.com/monerium/js-sdk/compare/sdk-v2.10.0...sdk-v2.11.0) (2024-02-05)
4
17
 
5
18
 
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var X=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var y=(e,t,r)=>(X(e,t,"read from private field"),r?r.call(e):t.get(e)),R=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},I=(e,t,r,n)=>(X(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);var k=(e,t,r)=>(X(e,t,"access private method"),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var ce=(e=>(e.eur="eur",e))(ce||{}),ue=(e=>(e.corporate="corporate",e.personal="personal",e))(ue||{}),he=(e=>(e.read="read",e.write="write",e))(he||{}),de=(e=>(e.absent="absent",e.submitted="submitted",e.pending="pending",e.confirmed="confirmed",e))(de||{}),fe=(e=>(e.approved="approved",e.rejected="rejected",e.unknown="unknown",e))(fe||{}),le=(e=>(e.requested="requested",e.approved="approved",e.pending="pending",e))(le||{}),pe=(e=>(e.iban="iban",e.scan="scan",e.chain="chain",e))(pe||{}),ve=(e=>(e.redeem="redeem",e.issue="issue",e))(ve||{}),ge=(e=>(e.placed="placed",e.pending="pending",e.processed="processed",e.rejected="rejected",e))(ge||{});const te=e=>{if(e.toString()==="Invalid Date")throw e;const t=n=>n<10?"0"+n:n,r=n=>{if(n===0)return"Z";const c=n>0?"-":"+";return n=Math.abs(n),c+t(Math.floor(n/60))+":"+t(n%60)};return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+"T"+t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+r(e.getTimezoneOffset())},xe=(e,t,r,n)=>{const c=`${(n==null?void 0:n.toUpperCase())||"EUR"}`;return r?`Send ${c} ${e} to ${t} on ${K(r)} at ${te(new Date)}`:`Send ${c} ${e} to ${t} at ${te(new Date)}`},Z=e=>{var t;return e&&((t=Object.entries(e))==null?void 0:t.length)>0?Object.entries(e).map(([r,n])=>`${encodeURIComponent(r)}=${encodeURIComponent(n)}`).join("&"):""},K=e=>{switch(e){case 1:case 11155111:return"ethereum";case 100:case 10200:return"gnosis";case 137:case 80001:return"polygon";default:throw new Error(`Chain not supported: ${e}`)}},re=e=>{switch(e){case 1:case 100:case 137:return"mainnet";case 11155111:return"sepolia";case 10200:return"chiado";case 80001:return"mumbai";default:throw new Error(`Network not supported: ${e}`)}},Q=e=>{if(e!=null&&e.chainId){const{chainId:t,...r}=e;return{...r,chain:K(t),network:re(t)}}return e},Y={environments:{production:{api:"https://api.monerium.app",web:"https://monerium.app",wss:"wss://api.monerium.app"},sandbox:{api:"https://api.monerium.dev",web:"https://sandbox.monerium.dev",wss:"wss://api.monerium.dev"}}},Ae="I hereby declare that I am the address owner.",M="monerium.sdk.code_verifier",D="monerium.sdk.refresh_token",Ee={LINK_MESSAGE:Ae,STORAGE_CODE_VERIFIER:M,STORAGE_REFRESH_TOKEN:D};var q=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function we(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Ie(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var c=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,c.get?c:{enumerable:!0,get:function(){return e[n]}})}),r}var ye={exports:{}};function $e(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ee={exports:{}};const Re={},Pe=Object.freeze(Object.defineProperty({__proto__:null,default:Re},Symbol.toStringTag,{value:"Module"})),Oe=Ie(Pe);var oe;function me(){return oe||(oe=1,function(e,t){(function(r,n){e.exports=n()})(q,function(){var r=r||function(n,c){var u;if(typeof window<"u"&&window.crypto&&(u=window.crypto),typeof self<"u"&&self.crypto&&(u=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(u=globalThis.crypto),!u&&typeof window<"u"&&window.msCrypto&&(u=window.msCrypto),!u&&typeof q<"u"&&q.crypto&&(u=q.crypto),!u&&typeof $e=="function")try{u=Oe}catch{}var l=function(){if(u){if(typeof u.getRandomValues=="function")try{return u.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof u.randomBytes=="function")try{return u.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},C=Object.create||function(){function o(){}return function(s){var a;return o.prototype=s,a=new o,o.prototype=null,a}}(),v={},m=v.lib={},w=m.Base=function(){return{extend:function(o){var s=C(this);return o&&s.mixIn(o),(!s.hasOwnProperty("init")||this.init===s.init)&&(s.init=function(){s.$super.init.apply(this,arguments)}),s.init.prototype=s,s.$super=this,s},create:function(){var o=this.extend();return o.init.apply(o,arguments),o},init:function(){},mixIn:function(o){for(var s in o)o.hasOwnProperty(s)&&(this[s]=o[s]);o.hasOwnProperty("toString")&&(this.toString=o.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),g=m.WordArray=w.extend({init:function(o,s){o=this.words=o||[],s!=c?this.sigBytes=s:this.sigBytes=o.length*4},toString:function(o){return(o||d).stringify(this)},concat:function(o){var s=this.words,a=o.words,h=this.sigBytes,_=o.sigBytes;if(this.clamp(),h%4)for(var S=0;S<_;S++){var B=a[S>>>2]>>>24-S%4*8&255;s[h+S>>>2]|=B<<24-(h+S)%4*8}else for(var x=0;x<_;x+=4)s[h+x>>>2]=a[x>>>2];return this.sigBytes+=_,this},clamp:function(){var o=this.words,s=this.sigBytes;o[s>>>2]&=4294967295<<32-s%4*8,o.length=n.ceil(s/4)},clone:function(){var o=w.clone.call(this);return o.words=this.words.slice(0),o},random:function(o){for(var s=[],a=0;a<o;a+=4)s.push(l());return new g.init(s,o)}}),b=v.enc={},d=b.Hex={stringify:function(o){for(var s=o.words,a=o.sigBytes,h=[],_=0;_<a;_++){var S=s[_>>>2]>>>24-_%4*8&255;h.push((S>>>4).toString(16)),h.push((S&15).toString(16))}return h.join("")},parse:function(o){for(var s=o.length,a=[],h=0;h<s;h+=2)a[h>>>3]|=parseInt(o.substr(h,2),16)<<24-h%8*4;return new g.init(a,s/2)}},p=b.Latin1={stringify:function(o){for(var s=o.words,a=o.sigBytes,h=[],_=0;_<a;_++){var S=s[_>>>2]>>>24-_%4*8&255;h.push(String.fromCharCode(S))}return h.join("")},parse:function(o){for(var s=o.length,a=[],h=0;h<s;h++)a[h>>>2]|=(o.charCodeAt(h)&255)<<24-h%4*8;return new g.init(a,s)}},i=b.Utf8={stringify:function(o){try{return decodeURIComponent(escape(p.stringify(o)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(o){return p.parse(unescape(encodeURIComponent(o)))}},f=m.BufferedBlockAlgorithm=w.extend({reset:function(){this._data=new g.init,this._nDataBytes=0},_append:function(o){typeof o=="string"&&(o=i.parse(o)),this._data.concat(o),this._nDataBytes+=o.sigBytes},_process:function(o){var s,a=this._data,h=a.words,_=a.sigBytes,S=this.blockSize,B=S*4,x=_/B;o?x=n.ceil(x):x=n.max((x|0)-this._minBufferSize,0);var N=x*S,z=n.min(N*4,_);if(N){for(var W=0;W<N;W+=S)this._doProcessBlock(h,W);s=h.splice(0,N),a.sigBytes-=z}return new g.init(s,z)},clone:function(){var o=w.clone.call(this);return o._data=this._data.clone(),o},_minBufferSize:0});m.Hasher=f.extend({cfg:w.extend(),init:function(o){this.cfg=this.cfg.extend(o),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(o){return this._append(o),this._process(),this},finalize:function(o){o&&this._append(o);var s=this._doFinalize();return s},blockSize:16,_createHelper:function(o){return function(s,a){return new o.init(a).finalize(s)}},_createHmacHelper:function(o){return function(s,a){return new A.HMAC.init(o,a).finalize(s)}}});var A=v.algo={};return v}(Math);return r})}(ee)),ee.exports}(function(e,t){(function(r,n){e.exports=n(me())})(q,function(r){return function(){var n=r,c=n.lib,u=c.WordArray,l=n.enc;l.Base64url={stringify:function(v,m){m===void 0&&(m=!0);var w=v.words,g=v.sigBytes,b=m?this._safe_map:this._map;v.clamp();for(var d=[],p=0;p<g;p+=3)for(var i=w[p>>>2]>>>24-p%4*8&255,f=w[p+1>>>2]>>>24-(p+1)%4*8&255,A=w[p+2>>>2]>>>24-(p+2)%4*8&255,o=i<<16|f<<8|A,s=0;s<4&&p+s*.75<g;s++)d.push(b.charAt(o>>>6*(3-s)&63));var a=b.charAt(64);if(a)for(;d.length%4;)d.push(a);return d.join("")},parse:function(v,m){m===void 0&&(m=!0);var w=v.length,g=m?this._safe_map:this._map,b=this._reverseMap;if(!b){b=this._reverseMap=[];for(var d=0;d<g.length;d++)b[g.charCodeAt(d)]=d}var p=g.charAt(64);if(p){var i=v.indexOf(p);i!==-1&&(w=i)}return C(v,w,b)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"};function C(v,m,w){for(var g=[],b=0,d=0;d<m;d++)if(d%4){var p=w[v.charCodeAt(d-1)]<<d%4*2,i=w[v.charCodeAt(d)]>>>6-d%4*2,f=p|i;g[b>>>2]|=f<<24-b%4*8,b++}return u.create(g,b)}}(),r.enc.Base64url})})(ye);var Ue=ye.exports;const ze=we(Ue);var _e={exports:{}};(function(e,t){(function(r,n){e.exports=n(me())})(q,function(r){return function(n){var c=r,u=c.lib,l=u.WordArray,C=u.Hasher,v=c.algo,m=[],w=[];(function(){function d(A){for(var o=n.sqrt(A),s=2;s<=o;s++)if(!(A%s))return!1;return!0}function p(A){return(A-(A|0))*4294967296|0}for(var i=2,f=0;f<64;)d(i)&&(f<8&&(m[f]=p(n.pow(i,1/2))),w[f]=p(n.pow(i,1/3)),f++),i++})();var g=[],b=v.SHA256=C.extend({_doReset:function(){this._hash=new l.init(m.slice(0))},_doProcessBlock:function(d,p){for(var i=this._hash.words,f=i[0],A=i[1],o=i[2],s=i[3],a=i[4],h=i[5],_=i[6],S=i[7],B=0;B<64;B++){if(B<16)g[B]=d[p+B]|0;else{var x=g[B-15],N=(x<<25|x>>>7)^(x<<14|x>>>18)^x>>>3,z=g[B-2],W=(z<<15|z>>>17)^(z<<13|z>>>19)^z>>>10;g[B]=N+g[B-7]+W+g[B-16]}var be=a&h^~a&_,Se=f&A^f&o^A&o,Ce=(f<<30|f>>>2)^(f<<19|f>>>13)^(f<<10|f>>>22),ke=(a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25),ne=S+ke+be+w[B]+g[B],Be=Ce+Se;S=_,_=h,h=a,a=s+ne|0,s=o,o=A,A=f,f=ne+Be|0}i[0]=i[0]+f|0,i[1]=i[1]+A|0,i[2]=i[2]+o|0,i[3]=i[3]+s|0,i[4]=i[4]+a|0,i[5]=i[5]+h|0,i[6]=i[6]+_|0,i[7]=i[7]+S|0},_doFinalize:function(){var d=this._data,p=d.words,i=this._nDataBytes*8,f=d.sigBytes*8;return p[f>>>5]|=128<<24-f%32,p[(f+64>>>9<<4)+14]=n.floor(i/4294967296),p[(f+64>>>9<<4)+15]=i,d.sigBytes=p.length*4,this._process(),this._hash},clone:function(){var d=C.clone.call(this);return d._hash=this._hash.clone(),d}});c.SHA256=C._createHelper(b),c.HmacSHA256=C._createHmacHelper(b)}(Math),r.SHA256})})(_e);var He=_e.exports;const Te=we(He),Me=(e,t)=>{const{client_id:r,redirect_uri:n,scope:c,state:u,chainId:l,chain:C,network:v,address:m,signature:w}=e,g=m?{address:m,...w!==void 0?{signature:w}:{},...l!==void 0||C!==void 0?{chain:l?K(l):C}:{},...l!==void 0||v!==void 0?{network:l?re(l):v}:{}}:{};return Z({client_id:r,redirect_uri:n,...c!==void 0?{scope:c}:{},...u!==void 0?{state:u}:{},code_challenge:t,code_challenge_method:"S256",response_type:"code",...g})},Le=()=>{let e="";const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=t.length;let n=0;for(;n<128;)e+=t.charAt(Math.floor(Math.random()*r)),n+=1;return e},Ne=e=>ze.stringify(Te(e)),se=(e,t)=>{const r=Le(),n=Ne(r);return localStorage.setItem(M,r||""),`${e}/auth?${Me(t,n)}`},ie=()=>{const e=window.location.href;if(!e||!(e!=null&&e.includes("?")))return;const[t,r]=e.split("?");r&&window.history.replaceState(null,"",t)},ae=e=>e.code!=null,je=e=>e.refresh_token!=null,qe=e=>e.client_secret!=null,Fe=async(e,t,r,n)=>{const c=await fetch(`${e}`,{method:t,headers:n,body:r});let u;const l=await c.text();try{u=JSON.parse(l)}catch{throw l}if(!c.ok)throw u;return u},T=typeof window>"u";var P,F,L,U,O,H,j,E,$,V,G,J;class We{constructor(t){R(this,H);R(this,E);R(this,P,void 0);R(this,F,void 0);R(this,L,void 0);R(this,U,void 0);R(this,O,void 0);R(this,V,void 0);R(this,G,void 0);R(this,J,void 0);if(I(this,U,new Map),this.isAuthorized=!!this.bearerProfile,I(this,V,async(r,n,c,u)=>{const l=localStorage.getItem(M)||"";if(!l)throw new Error("Code verifier not found");return this.codeVerifier=l,this.state=u,localStorage.removeItem(M),await k(this,H,j).call(this,{code:c,redirect_uri:n,client_id:r,code_verifier:l})}),I(this,G,async({clientId:r,clientSecret:n})=>await k(this,H,j).call(this,{client_id:r,client_secret:n})),I(this,J,async(r,n)=>await k(this,H,j).call(this,{refresh_token:n,client_id:r})),this.subscribeToOrderNotifications=()=>{var c,u;const r=`${y(this,P).wss}/profiles/${(c=this.bearerProfile)==null?void 0:c.profile}/orders?access_token=${(u=this.bearerProfile)==null?void 0:u.access_token}`,n=new WebSocket(r);return n.addEventListener("open",()=>{console.info(`Socket connected: ${r}`)}),n.addEventListener("error",l=>{throw console.error(l),new Error(`Socket error: ${r}`)}),n.addEventListener("message",l=>{var v;const C=JSON.parse(l.data);(v=y(this,U).get(C.meta.state))==null||v(C)}),n.addEventListener("close",()=>{console.info(`Socket connection closed: ${r}`)}),n},this.auth=async r=>await k(this,H,j).call(this,r),this.connect=async r=>await k(this,H,j).call(this,r),this.getAuthFlowURI=r=>{const n=se(y(this,P).api,r);return this.codeVerifier=localStorage.getItem(M),n},this.pkceRequest=r=>this.getAuthFlowURI(r),this.getEnvironment=()=>y(this,P),!t){I(this,P,Y.environments.sandbox);return}if(typeof t=="string")I(this,P,Y.environments[t]);else if(I(this,P,Y.environments[t.environment||"sandbox"]),T){const{clientId:r,clientSecret:n}=t;I(this,O,{clientId:r,clientSecret:n})}else{const{clientId:r,redirectUrl:n}=t;I(this,O,{clientId:r,redirectUrl:n})}}async authorize(t){var u,l;const r=(t==null?void 0:t.clientId)||((u=y(this,O))==null?void 0:u.clientId),n=(t==null?void 0:t.redirectUrl)||((l=y(this,O))==null?void 0:l.redirectUrl);if(!r)throw new Error("Missing ClientId");if(!n)throw new Error("Missing RedirectUrl");const c=se(y(this,P).api,{client_id:r,redirect_uri:n,address:t==null?void 0:t.address,signature:t==null?void 0:t.signature,chainId:t==null?void 0:t.chainId,state:t==null?void 0:t.state});window.location.replace(c)}async getAccess(t){var v,m,w;const r=(t==null?void 0:t.clientId)||((v=y(this,O))==null?void 0:v.clientId);if((t==null?void 0:t.clientSecret)||((m=y(this,O))==null?void 0:m.clientSecret)){if(!T)throw new Error("Only use client credentials on server side");return await y(this,G).call(this,y(this,O)),!!this.bearerProfile}const c=(t==null?void 0:t.redirectUrl)||((w=y(this,O))==null?void 0:w.redirectUrl);if(!r)throw new Error("Missing ClientId");if(T)throw new Error("This only works client side");const u=new URLSearchParams(window.location.search).get("code")||void 0,l=new URLSearchParams(window.location.search).get("state")||void 0,C=localStorage.getItem(D)||void 0;return C?await y(this,J).call(this,r,C):u&&await y(this,V).call(this,r,c,u,l),!!this.bearerProfile}getAuthContext(){return k(this,E,$).call(this,"get","auth/context")}getProfile(t){return k(this,E,$).call(this,"get",`profiles/${t}`)}getBalances(t){return t?k(this,E,$).call(this,"get",`profiles/${t}/balances`):k(this,E,$).call(this,"get","balances")}getOrders(t){const r=Z(t);return k(this,E,$).call(this,"get",`orders?${r}`)}getOrder(t){return k(this,E,$).call(this,"get",`orders/${t}`)}getTokens(){return k(this,E,$).call(this,"get","tokens")}linkAddress(t,r){return r=Q(r),r.accounts=r.accounts.map(n=>Q(n)),k(this,E,$).call(this,"post",`profiles/${t}/addresses`,JSON.stringify(r))}placeOrder(t,r){const n={kind:"redeem",currency:"eur",...Q(t),counterpart:{...t.counterpart,identifier:Q(t.counterpart.identifier)}};return r?k(this,E,$).call(this,"post",`profiles/${r}/orders`,JSON.stringify(n)):k(this,E,$).call(this,"post","orders",JSON.stringify(n))}uploadSupportingDocument(t){const r=Z(t);return k(this,E,$).call(this,"post","files/supporting-document",r,!0)}async connectOrderSocket(){var t;(t=this.bearerProfile)!=null&&t.access_token&&y(this,U).size>0&&I(this,L,this.subscribeToOrderNotifications())}async disconnect(){var t;T||localStorage.removeItem(M),y(this,U).clear(),(t=y(this,L))==null||t.close(),I(this,F,void 0),this.bearerProfile=void 0}async revokeAccess(){T||localStorage.removeItem(D),this.disconnect()}subscribeOrders(t,r){y(this,U).set(t,r)}unsubscribeOrders(t){var r;y(this,U).delete(t),y(this,U).size===0&&((r=y(this,L))==null||r.close(),I(this,L,void 0))}}P=new WeakMap,F=new WeakMap,L=new WeakMap,U=new WeakMap,O=new WeakMap,H=new WeakSet,j=async function(t){let r;if(ae(t))r={...t,grant_type:"authorization_code"};else if(je(t))r={...t,grant_type:"refresh_token"};else if(qe(t))r={...t,grant_type:"client_credentials"};else throw new Error("Authorization grant type could not be detected.");return await k(this,E,$).call(this,"post","auth/token",r,!0).then(n=>{var c;this.bearerProfile=n,this.isAuthorized=!!n,I(this,F,`Bearer ${n==null?void 0:n.access_token}`),T||window.localStorage.setItem(D,((c=this.bearerProfile)==null?void 0:c.refresh_token)||"")}).catch(n=>{throw T||(localStorage.removeItem(M),localStorage.removeItem(D),ie()),new Error(n==null?void 0:n.message)}),ae(t)&&ie(),this.bearerProfile},E=new WeakSet,$=async function(t,r,n,c){return Fe(`${y(this,P).api}/${r}`,t,c?Z(n):n,{Authorization:y(this,F)||"","Content-Type":`application/${c?"x-www-form-urlencoded":"json"}`})},V=new WeakMap,G=new WeakMap,J=new WeakMap;exports.AccountState=le;exports.Currency=ce;exports.KYCOutcome=fe;exports.KYCState=de;exports.MoneriumClient=We;exports.OrderKind=ve;exports.OrderState=ge;exports.PaymentStandard=pe;exports.Permission=he;exports.ProfileType=ue;exports.constants=Ee;exports.getChain=K;exports.getNetwork=re;exports.placeOrderMessage=xe;exports.rfc3339=te;
1
+ "use strict";var K=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var g=(e,t,r)=>(K(e,t,"read from private field"),r?r.call(e):t.get(e)),O=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},E=(e,t,r,n)=>(K(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);var k=(e,t,r)=>(K(e,t,"access private method"),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var ue=(e=>(e.eur="eur",e))(ue||{}),he=(e=>(e.corporate="corporate",e.personal="personal",e))(he||{}),fe=(e=>(e.read="read",e.write="write",e))(fe||{}),de=(e=>(e.absent="absent",e.submitted="submitted",e.pending="pending",e.confirmed="confirmed",e))(de||{}),le=(e=>(e.approved="approved",e.rejected="rejected",e.unknown="unknown",e))(le||{}),pe=(e=>(e.requested="requested",e.approved="approved",e.pending="pending",e))(pe||{}),ve=(e=>(e.iban="iban",e.scan="scan",e.chain="chain",e))(ve||{}),ge=(e=>(e.redeem="redeem",e.issue="issue",e))(ge||{}),we=(e=>(e.placed="placed",e.pending="pending",e.processed="processed",e.rejected="rejected",e))(we||{});const ee=e=>{if(e.toString()==="Invalid Date")throw e;const t=n=>n<10?"0"+n:n,r=n=>{if(n===0)return"Z";const c=n>0?"-":"+";return n=Math.abs(n),c+t(Math.floor(n/60))+":"+t(n%60)};return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+"T"+t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+r(e.getTimezoneOffset())},Ae=(e,t,r,n)=>{const c=`${(n==null?void 0:n.toUpperCase())||"EUR"}`;return r?`Send ${c} ${e} to ${t} on ${Z(r)} at ${ee(new Date)}`:`Send ${c} ${e} to ${t} at ${ee(new Date)}`},te=e=>{var t;return e&&((t=Object.entries(e))==null?void 0:t.length)>0?Object.entries(e).map(([r,n])=>`${encodeURIComponent(r)}=${encodeURIComponent(n)}`).join("&"):""},Z=e=>{switch(e){case 1:case 11155111:return"ethereum";case 100:case 10200:return"gnosis";case 137:case 80001:return"polygon";default:throw new Error(`Chain not supported: ${e}`)}},re=e=>{switch(e){case 1:case 100:case 137:return"mainnet";case 11155111:return"sepolia";case 10200:return"chiado";case 80001:return"mumbai";default:throw new Error(`Network not supported: ${e}`)}},Q=e=>{if(e!=null&&e.chainId){const{chainId:t,...r}=e;return{...r,chain:Z(t),network:re(t)}}return e},X={environments:{production:{api:"https://api.monerium.app",web:"https://monerium.app",wss:"wss://api.monerium.app"},sandbox:{api:"https://api.monerium.dev",web:"https://sandbox.monerium.dev",wss:"wss://api.monerium.dev"}}},Ee="I hereby declare that I am the address owner.",M="monerium.sdk.code_verifier",W="monerium.sdk.refresh_token",Ie={LINK_MESSAGE:Ee,STORAGE_CODE_VERIFIER:M,STORAGE_REFRESH_TOKEN:W};var q=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ye(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function $e(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var c=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,c.get?c:{enumerable:!0,get:function(){return e[n]}})}),r}var me={exports:{}};function Re(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Y={exports:{}};const Oe={},Pe=Object.freeze(Object.defineProperty({__proto__:null,default:Oe},Symbol.toStringTag,{value:"Module"})),ze=$e(Pe);var oe;function _e(){return oe||(oe=1,function(e,t){(function(r,n){e.exports=n()})(q,function(){var r=r||function(n,c){var u;if(typeof window<"u"&&window.crypto&&(u=window.crypto),typeof self<"u"&&self.crypto&&(u=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(u=globalThis.crypto),!u&&typeof window<"u"&&window.msCrypto&&(u=window.msCrypto),!u&&typeof q<"u"&&q.crypto&&(u=q.crypto),!u&&typeof Re=="function")try{u=ze}catch{}var l=function(){if(u){if(typeof u.getRandomValues=="function")try{return u.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof u.randomBytes=="function")try{return u.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},C=Object.create||function(){function o(){}return function(s){var a;return o.prototype=s,a=new o,o.prototype=null,a}}(),v={},m=v.lib={},y=m.Base=function(){return{extend:function(o){var s=C(this);return o&&s.mixIn(o),(!s.hasOwnProperty("init")||this.init===s.init)&&(s.init=function(){s.$super.init.apply(this,arguments)}),s.init.prototype=s,s.$super=this,s},create:function(){var o=this.extend();return o.init.apply(o,arguments),o},init:function(){},mixIn:function(o){for(var s in o)o.hasOwnProperty(s)&&(this[s]=o[s]);o.hasOwnProperty("toString")&&(this.toString=o.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),w=m.WordArray=y.extend({init:function(o,s){o=this.words=o||[],s!=c?this.sigBytes=s:this.sigBytes=o.length*4},toString:function(o){return(o||f).stringify(this)},concat:function(o){var s=this.words,a=o.words,h=this.sigBytes,_=o.sigBytes;if(this.clamp(),h%4)for(var S=0;S<_;S++){var B=a[S>>>2]>>>24-S%4*8&255;s[h+S>>>2]|=B<<24-(h+S)%4*8}else for(var x=0;x<_;x+=4)s[h+x>>>2]=a[x>>>2];return this.sigBytes+=_,this},clamp:function(){var o=this.words,s=this.sigBytes;o[s>>>2]&=4294967295<<32-s%4*8,o.length=n.ceil(s/4)},clone:function(){var o=y.clone.call(this);return o.words=this.words.slice(0),o},random:function(o){for(var s=[],a=0;a<o;a+=4)s.push(l());return new w.init(s,o)}}),b=v.enc={},f=b.Hex={stringify:function(o){for(var s=o.words,a=o.sigBytes,h=[],_=0;_<a;_++){var S=s[_>>>2]>>>24-_%4*8&255;h.push((S>>>4).toString(16)),h.push((S&15).toString(16))}return h.join("")},parse:function(o){for(var s=o.length,a=[],h=0;h<s;h+=2)a[h>>>3]|=parseInt(o.substr(h,2),16)<<24-h%8*4;return new w.init(a,s/2)}},p=b.Latin1={stringify:function(o){for(var s=o.words,a=o.sigBytes,h=[],_=0;_<a;_++){var S=s[_>>>2]>>>24-_%4*8&255;h.push(String.fromCharCode(S))}return h.join("")},parse:function(o){for(var s=o.length,a=[],h=0;h<s;h++)a[h>>>2]|=(o.charCodeAt(h)&255)<<24-h%4*8;return new w.init(a,s)}},i=b.Utf8={stringify:function(o){try{return decodeURIComponent(escape(p.stringify(o)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(o){return p.parse(unescape(encodeURIComponent(o)))}},d=m.BufferedBlockAlgorithm=y.extend({reset:function(){this._data=new w.init,this._nDataBytes=0},_append:function(o){typeof o=="string"&&(o=i.parse(o)),this._data.concat(o),this._nDataBytes+=o.sigBytes},_process:function(o){var s,a=this._data,h=a.words,_=a.sigBytes,S=this.blockSize,B=S*4,x=_/B;o?x=n.ceil(x):x=n.max((x|0)-this._minBufferSize,0);var j=x*S,U=n.min(j*4,_);if(j){for(var D=0;D<j;D+=S)this._doProcessBlock(h,D);s=h.splice(0,j),a.sigBytes-=U}return new w.init(s,U)},clone:function(){var o=y.clone.call(this);return o._data=this._data.clone(),o},_minBufferSize:0});m.Hasher=d.extend({cfg:y.extend(),init:function(o){this.cfg=this.cfg.extend(o),this.reset()},reset:function(){d.reset.call(this),this._doReset()},update:function(o){return this._append(o),this._process(),this},finalize:function(o){o&&this._append(o);var s=this._doFinalize();return s},blockSize:16,_createHelper:function(o){return function(s,a){return new o.init(a).finalize(s)}},_createHmacHelper:function(o){return function(s,a){return new A.HMAC.init(o,a).finalize(s)}}});var A=v.algo={};return v}(Math);return r})}(Y)),Y.exports}(function(e,t){(function(r,n){e.exports=n(_e())})(q,function(r){return function(){var n=r,c=n.lib,u=c.WordArray,l=n.enc;l.Base64url={stringify:function(v,m){m===void 0&&(m=!0);var y=v.words,w=v.sigBytes,b=m?this._safe_map:this._map;v.clamp();for(var f=[],p=0;p<w;p+=3)for(var i=y[p>>>2]>>>24-p%4*8&255,d=y[p+1>>>2]>>>24-(p+1)%4*8&255,A=y[p+2>>>2]>>>24-(p+2)%4*8&255,o=i<<16|d<<8|A,s=0;s<4&&p+s*.75<w;s++)f.push(b.charAt(o>>>6*(3-s)&63));var a=b.charAt(64);if(a)for(;f.length%4;)f.push(a);return f.join("")},parse:function(v,m){m===void 0&&(m=!0);var y=v.length,w=m?this._safe_map:this._map,b=this._reverseMap;if(!b){b=this._reverseMap=[];for(var f=0;f<w.length;f++)b[w.charCodeAt(f)]=f}var p=w.charAt(64);if(p){var i=v.indexOf(p);i!==-1&&(y=i)}return C(v,y,b)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"};function C(v,m,y){for(var w=[],b=0,f=0;f<m;f++)if(f%4){var p=y[v.charCodeAt(f-1)]<<f%4*2,i=y[v.charCodeAt(f)]>>>6-f%4*2,d=p|i;w[b>>>2]|=d<<24-b%4*8,b++}return u.create(w,b)}}(),r.enc.Base64url})})(me);var Ue=me.exports;const He=ye(Ue);var be={exports:{}};(function(e,t){(function(r,n){e.exports=n(_e())})(q,function(r){return function(n){var c=r,u=c.lib,l=u.WordArray,C=u.Hasher,v=c.algo,m=[],y=[];(function(){function f(A){for(var o=n.sqrt(A),s=2;s<=o;s++)if(!(A%s))return!1;return!0}function p(A){return(A-(A|0))*4294967296|0}for(var i=2,d=0;d<64;)f(i)&&(d<8&&(m[d]=p(n.pow(i,1/2))),y[d]=p(n.pow(i,1/3)),d++),i++})();var w=[],b=v.SHA256=C.extend({_doReset:function(){this._hash=new l.init(m.slice(0))},_doProcessBlock:function(f,p){for(var i=this._hash.words,d=i[0],A=i[1],o=i[2],s=i[3],a=i[4],h=i[5],_=i[6],S=i[7],B=0;B<64;B++){if(B<16)w[B]=f[p+B]|0;else{var x=w[B-15],j=(x<<25|x>>>7)^(x<<14|x>>>18)^x>>>3,U=w[B-2],D=(U<<15|U>>>17)^(U<<13|U>>>19)^U>>>10;w[B]=j+w[B-7]+D+w[B-16]}var Se=a&h^~a&_,Ce=d&A^d&o^A&o,ke=(d<<30|d>>>2)^(d<<19|d>>>13)^(d<<10|d>>>22),Be=(a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25),ne=S+Be+Se+y[B]+w[B],xe=ke+Ce;S=_,_=h,h=a,a=s+ne|0,s=o,o=A,A=d,d=ne+xe|0}i[0]=i[0]+d|0,i[1]=i[1]+A|0,i[2]=i[2]+o|0,i[3]=i[3]+s|0,i[4]=i[4]+a|0,i[5]=i[5]+h|0,i[6]=i[6]+_|0,i[7]=i[7]+S|0},_doFinalize:function(){var f=this._data,p=f.words,i=this._nDataBytes*8,d=f.sigBytes*8;return p[d>>>5]|=128<<24-d%32,p[(d+64>>>9<<4)+14]=n.floor(i/4294967296),p[(d+64>>>9<<4)+15]=i,f.sigBytes=p.length*4,this._process(),this._hash},clone:function(){var f=C.clone.call(this);return f._hash=this._hash.clone(),f}});c.SHA256=C._createHelper(b),c.HmacSHA256=C._createHmacHelper(b)}(Math),r.SHA256})})(be);var Te=be.exports;const Me=ye(Te),Le=(e,t)=>{const{client_id:r,redirect_uri:n,scope:c,state:u,chainId:l,chain:C,network:v,address:m,signature:y}=e,w=m?{address:m,...y!==void 0?{signature:y}:{},...l!==void 0||C!==void 0?{chain:l?Z(l):C}:{},...l!==void 0||v!==void 0?{network:l?re(l):v}:{}}:{};return te({client_id:r,redirect_uri:n,...c!==void 0?{scope:c}:{},...u!==void 0?{state:u}:{},code_challenge:t,code_challenge_method:"S256",response_type:"code",...w})},Ne=()=>{let e="";const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=t.length;let n=0;for(;n<128;)e+=t.charAt(Math.floor(Math.random()*r)),n+=1;return e},je=e=>He.stringify(Me(e)),se=(e,t)=>{const r=Ne(),n=je(r);return localStorage.setItem(M,r||""),`${e}/auth?${Le(t,n)}`},ie=()=>{const e=window.location.href;if(!e||!(e!=null&&e.includes("?")))return;const[t,r]=e.split("?");r&&window.history.replaceState(null,"",t)},ae=e=>e.code!=null,Fe=e=>e.refresh_token!=null,qe=e=>e.client_secret!=null,ce=async(e,t,r,n)=>{const c=await fetch(`${e}`,{method:t,headers:n,body:r});let u;const l=await c.text();try{u=JSON.parse(l)}catch{throw l}if(!c.ok)throw u;return u},T=typeof window>"u";var R,L,N,z,P,H,F,I,$,V,G,J;class De{constructor(t){O(this,H);O(this,I);O(this,R,void 0);O(this,L,void 0);O(this,N,void 0);O(this,z,void 0);O(this,P,void 0);O(this,V,void 0);O(this,G,void 0);O(this,J,void 0);if(E(this,z,new Map),this.isAuthorized=!!this.bearerProfile,E(this,V,async(r,n,c,u)=>{const l=localStorage.getItem(M)||"";if(!l)throw new Error("Code verifier not found");return this.codeVerifier=l,this.state=u,localStorage.removeItem(M),await k(this,H,F).call(this,{code:c,redirect_uri:n,client_id:r,code_verifier:l})}),E(this,G,async({clientId:r,clientSecret:n})=>await k(this,H,F).call(this,{client_id:r,client_secret:n})),E(this,J,async(r,n)=>await k(this,H,F).call(this,{refresh_token:n,client_id:r})),this.subscribeToOrderNotifications=()=>{var c,u;const r=`${g(this,R).wss}/profiles/${(c=this.bearerProfile)==null?void 0:c.profile}/orders?access_token=${(u=this.bearerProfile)==null?void 0:u.access_token}`,n=new WebSocket(r);return n.addEventListener("open",()=>{console.info(`Socket connected: ${r}`)}),n.addEventListener("error",l=>{throw console.error(l),new Error(`Socket error: ${r}`)}),n.addEventListener("message",l=>{var v;const C=JSON.parse(l.data);(v=g(this,z).get(C.meta.state))==null||v(C)}),n.addEventListener("close",()=>{console.info(`Socket connection closed: ${r}`)}),n},this.auth=async r=>await k(this,H,F).call(this,r),this.connect=async r=>await k(this,H,F).call(this,r),this.getAuthFlowURI=r=>{const n=se(g(this,R).api,r);return this.codeVerifier=localStorage.getItem(M),n},this.pkceRequest=r=>this.getAuthFlowURI(r),this.getEnvironment=()=>g(this,R),!t){E(this,R,X.environments.sandbox);return}if(typeof t=="string")E(this,R,X.environments[t]);else if(E(this,R,X.environments[t.environment||"sandbox"]),T){const{clientId:r,clientSecret:n}=t;E(this,P,{clientId:r,clientSecret:n})}else{const{clientId:r,redirectUrl:n}=t;E(this,P,{clientId:r,redirectUrl:n})}}async authorize(t){var u,l;const r=(t==null?void 0:t.clientId)||((u=g(this,P))==null?void 0:u.clientId),n=(t==null?void 0:t.redirectUrl)||((l=g(this,P))==null?void 0:l.redirectUrl);if(!r)throw new Error("Missing ClientId");if(!n)throw new Error("Missing RedirectUrl");const c=se(g(this,R).api,{client_id:r,redirect_uri:n,address:t==null?void 0:t.address,signature:t==null?void 0:t.signature,chainId:t==null?void 0:t.chainId,state:t==null?void 0:t.state});window.location.replace(c)}async getAccess(t){var v,m,y;const r=(t==null?void 0:t.clientId)||((v=g(this,P))==null?void 0:v.clientId);if((t==null?void 0:t.clientSecret)||((m=g(this,P))==null?void 0:m.clientSecret)){if(!T)throw new Error("Only use client credentials on server side");return await g(this,G).call(this,g(this,P)),!!this.bearerProfile}const c=(t==null?void 0:t.redirectUrl)||((y=g(this,P))==null?void 0:y.redirectUrl);if(!r)throw new Error("Missing ClientId");if(T)throw new Error("This only works client side");const u=new URLSearchParams(window.location.search).get("code")||void 0,l=new URLSearchParams(window.location.search).get("state")||void 0,C=localStorage.getItem(W)||void 0;return C?await g(this,J).call(this,r,C):u&&await g(this,V).call(this,r,c,u,l),!!this.bearerProfile}getAuthContext(){return k(this,I,$).call(this,"get","auth/context")}getProfile(t){return k(this,I,$).call(this,"get",`profiles/${t}`)}getBalances(t){return t?k(this,I,$).call(this,"get",`profiles/${t}/balances`):k(this,I,$).call(this,"get","balances")}getOrders(t){const r=te(t);return k(this,I,$).call(this,"get",`orders?${r}`)}getOrder(t){return k(this,I,$).call(this,"get",`orders/${t}`)}getTokens(){return k(this,I,$).call(this,"get","tokens")}linkAddress(t,r){return r=Q(r),r.accounts=r.accounts.map(n=>Q(n)),k(this,I,$).call(this,"post",`profiles/${t}/addresses`,JSON.stringify(r))}placeOrder(t,r){const n={kind:"redeem",currency:"eur",...Q(t),counterpart:{...t.counterpart,identifier:Q(t.counterpart.identifier)}};return r?k(this,I,$).call(this,"post",`profiles/${r}/orders`,JSON.stringify(n)):k(this,I,$).call(this,"post","orders",JSON.stringify(n))}uploadSupportingDocument(t){const r=new FormData;return r.append("file",t),ce(`${g(this,R).api}/files`,"post",r,{Authorization:g(this,L)||""})}async connectOrderSocket(){var t;(t=this.bearerProfile)!=null&&t.access_token&&g(this,z).size>0&&E(this,N,this.subscribeToOrderNotifications())}async disconnect(){var t;T||localStorage.removeItem(M),g(this,z).clear(),(t=g(this,N))==null||t.close(),E(this,L,void 0),this.bearerProfile=void 0}async revokeAccess(){T||localStorage.removeItem(W),this.disconnect()}subscribeOrders(t,r){g(this,z).set(t,r)}unsubscribeOrders(t){var r;g(this,z).delete(t),g(this,z).size===0&&((r=g(this,N))==null||r.close(),E(this,N,void 0))}}R=new WeakMap,L=new WeakMap,N=new WeakMap,z=new WeakMap,P=new WeakMap,H=new WeakSet,F=async function(t){let r;if(ae(t))r={...t,grant_type:"authorization_code"};else if(Fe(t))r={...t,grant_type:"refresh_token"};else if(qe(t))r={...t,grant_type:"client_credentials"};else throw new Error("Authorization grant type could not be detected.");return await k(this,I,$).call(this,"post","auth/token",r,!0).then(n=>{var c;this.bearerProfile=n,this.isAuthorized=!!n,E(this,L,`Bearer ${n==null?void 0:n.access_token}`),T||window.localStorage.setItem(W,((c=this.bearerProfile)==null?void 0:c.refresh_token)||"")}).catch(n=>{throw T||(localStorage.removeItem(M),localStorage.removeItem(W),ie()),new Error(n==null?void 0:n.message)}),ae(t)&&ie(),this.bearerProfile},I=new WeakSet,$=async function(t,r,n,c){return ce(`${g(this,R).api}/${r}`,t,c?te(n):n,{Authorization:g(this,L)||"","Content-Type":`application/${c?"x-www-form-urlencoded":"json"}`})},V=new WeakMap,G=new WeakMap,J=new WeakMap;exports.AccountState=pe;exports.Currency=ue;exports.KYCOutcome=le;exports.KYCState=de;exports.MoneriumClient=De;exports.OrderKind=ge;exports.OrderState=we;exports.PaymentStandard=ve;exports.Permission=fe;exports.ProfileType=he;exports.constants=Ie;exports.getChain=Z;exports.getNetwork=re;exports.placeOrderMessage=Ae;exports.rfc3339=ee;
package/dist/index.mjs CHANGED
@@ -1,14 +1,14 @@
1
- var X = (e, t, r) => {
1
+ var Z = (e, t, r) => {
2
2
  if (!t.has(e))
3
3
  throw TypeError("Cannot " + r);
4
4
  };
5
- var y = (e, t, r) => (X(e, t, "read from private field"), r ? r.call(e) : t.get(e)), R = (e, t, r) => {
5
+ var g = (e, t, r) => (Z(e, t, "read from private field"), r ? r.call(e) : t.get(e)), z = (e, t, r) => {
6
6
  if (t.has(e))
7
7
  throw TypeError("Cannot add the same private member more than once");
8
8
  t instanceof WeakSet ? t.add(e) : t.set(e, r);
9
- }, I = (e, t, r, n) => (X(e, t, "write to private field"), n ? n.call(e, r) : t.set(e, r), r);
10
- var k = (e, t, r) => (X(e, t, "access private method"), r);
11
- var we = /* @__PURE__ */ ((e) => (e.eur = "eur", e))(we || {}), ye = /* @__PURE__ */ ((e) => (e.corporate = "corporate", e.personal = "personal", e))(ye || {}), me = /* @__PURE__ */ ((e) => (e.read = "read", e.write = "write", e))(me || {}), _e = /* @__PURE__ */ ((e) => (e.absent = "absent", e.submitted = "submitted", e.pending = "pending", e.confirmed = "confirmed", e))(_e || {}), be = /* @__PURE__ */ ((e) => (e.approved = "approved", e.rejected = "rejected", e.unknown = "unknown", e))(be || {}), Se = /* @__PURE__ */ ((e) => (e.requested = "requested", e.approved = "approved", e.pending = "pending", e))(Se || {}), Be = /* @__PURE__ */ ((e) => (e.iban = "iban", e.scan = "scan", e.chain = "chain", e))(Be || {}), ke = /* @__PURE__ */ ((e) => (e.redeem = "redeem", e.issue = "issue", e))(ke || {}), Ce = /* @__PURE__ */ ((e) => (e.placed = "placed", e.pending = "pending", e.processed = "processed", e.rejected = "rejected", e))(Ce || {});
9
+ }, E = (e, t, r, n) => (Z(e, t, "write to private field"), n ? n.call(e, r) : t.set(e, r), r);
10
+ var k = (e, t, r) => (Z(e, t, "access private method"), r);
11
+ var ye = /* @__PURE__ */ ((e) => (e.eur = "eur", e))(ye || {}), me = /* @__PURE__ */ ((e) => (e.corporate = "corporate", e.personal = "personal", e))(me || {}), _e = /* @__PURE__ */ ((e) => (e.read = "read", e.write = "write", e))(_e || {}), be = /* @__PURE__ */ ((e) => (e.absent = "absent", e.submitted = "submitted", e.pending = "pending", e.confirmed = "confirmed", e))(be || {}), Se = /* @__PURE__ */ ((e) => (e.approved = "approved", e.rejected = "rejected", e.unknown = "unknown", e))(Se || {}), Be = /* @__PURE__ */ ((e) => (e.requested = "requested", e.approved = "approved", e.pending = "pending", e))(Be || {}), ke = /* @__PURE__ */ ((e) => (e.iban = "iban", e.scan = "scan", e.chain = "chain", e))(ke || {}), Ce = /* @__PURE__ */ ((e) => (e.redeem = "redeem", e.issue = "issue", e))(Ce || {}), xe = /* @__PURE__ */ ((e) => (e.placed = "placed", e.pending = "pending", e.processed = "processed", e.rejected = "rejected", e))(xe || {});
12
12
  const re = (e) => {
13
13
  if (e.toString() === "Invalid Date")
14
14
  throw e;
@@ -19,12 +19,12 @@ const re = (e) => {
19
19
  return n = Math.abs(n), c + t(Math.floor(n / 60)) + ":" + t(n % 60);
20
20
  };
21
21
  return e.getFullYear() + "-" + t(e.getMonth() + 1) + "-" + t(e.getDate()) + "T" + t(e.getHours()) + ":" + t(e.getMinutes()) + ":" + t(e.getSeconds()) + r(e.getTimezoneOffset());
22
- }, Fe = (e, t, r, n) => {
22
+ }, qe = (e, t, r, n) => {
23
23
  const c = `${(n == null ? void 0 : n.toUpperCase()) || "EUR"}`;
24
24
  return r ? `Send ${c} ${e} to ${t} on ${ee(
25
25
  r
26
26
  )} at ${re(/* @__PURE__ */ new Date())}` : `Send ${c} ${e} to ${t} at ${re(/* @__PURE__ */ new Date())}`;
27
- }, Z = (e) => {
27
+ }, Y = (e) => {
28
28
  var t;
29
29
  return e && ((t = Object.entries(e)) == null ? void 0 : t.length) > 0 ? Object.entries(e).map(
30
30
  ([r, n]) => `${encodeURIComponent(r)}=${encodeURIComponent(n)}`
@@ -43,7 +43,7 @@ const re = (e) => {
43
43
  default:
44
44
  throw new Error(`Chain not supported: ${e}`);
45
45
  }
46
- }, ae = (e) => {
46
+ }, ce = (e) => {
47
47
  switch (e) {
48
48
  case 1:
49
49
  case 100:
@@ -64,11 +64,11 @@ const re = (e) => {
64
64
  return {
65
65
  ...r,
66
66
  chain: ee(t),
67
- network: ae(t)
67
+ network: ce(t)
68
68
  };
69
69
  }
70
70
  return e;
71
- }, K = {
71
+ }, X = {
72
72
  environments: {
73
73
  production: {
74
74
  api: "https://api.monerium.app",
@@ -81,16 +81,16 @@ const re = (e) => {
81
81
  wss: "wss://api.monerium.dev"
82
82
  }
83
83
  }
84
- }, xe = "I hereby declare that I am the address owner.", M = "monerium.sdk.code_verifier", D = "monerium.sdk.refresh_token", We = {
85
- LINK_MESSAGE: xe,
84
+ }, Ae = "I hereby declare that I am the address owner.", M = "monerium.sdk.code_verifier", W = "monerium.sdk.refresh_token", De = {
85
+ LINK_MESSAGE: Ae,
86
86
  STORAGE_CODE_VERIFIER: M,
87
- STORAGE_REFRESH_TOKEN: D
87
+ STORAGE_REFRESH_TOKEN: W
88
88
  };
89
89
  var q = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
90
- function ce(e) {
90
+ function ue(e) {
91
91
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
92
92
  }
93
- function Ae(e) {
93
+ function Ee(e) {
94
94
  if (e.__esModule)
95
95
  return e;
96
96
  var t = e.default;
@@ -111,26 +111,26 @@ function Ae(e) {
111
111
  });
112
112
  }), r;
113
113
  }
114
- var ue = { exports: {} };
115
- function Ee(e) {
114
+ var he = { exports: {} };
115
+ function Ie(e) {
116
116
  throw new Error('Could not dynamically require "' + e + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
117
117
  }
118
- var Y = { exports: {} };
119
- const Ie = {}, $e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
118
+ var K = { exports: {} };
119
+ const $e = {}, Re = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
120
120
  __proto__: null,
121
- default: Ie
122
- }, Symbol.toStringTag, { value: "Module" })), Re = /* @__PURE__ */ Ae($e);
121
+ default: $e
122
+ }, Symbol.toStringTag, { value: "Module" })), ze = /* @__PURE__ */ Ee(Re);
123
123
  var ne;
124
- function he() {
124
+ function fe() {
125
125
  return ne || (ne = 1, function(e, t) {
126
126
  (function(r, n) {
127
127
  e.exports = n();
128
128
  })(q, function() {
129
129
  var r = r || function(n, c) {
130
130
  var u;
131
- if (typeof window < "u" && window.crypto && (u = window.crypto), typeof self < "u" && self.crypto && (u = self.crypto), typeof globalThis < "u" && globalThis.crypto && (u = globalThis.crypto), !u && typeof window < "u" && window.msCrypto && (u = window.msCrypto), !u && typeof q < "u" && q.crypto && (u = q.crypto), !u && typeof Ee == "function")
131
+ if (typeof window < "u" && window.crypto && (u = window.crypto), typeof self < "u" && self.crypto && (u = self.crypto), typeof globalThis < "u" && globalThis.crypto && (u = globalThis.crypto), !u && typeof window < "u" && window.msCrypto && (u = window.msCrypto), !u && typeof q < "u" && q.crypto && (u = q.crypto), !u && typeof Ie == "function")
132
132
  try {
133
- u = Re;
133
+ u = ze;
134
134
  } catch {
135
135
  }
136
136
  var l = function() {
@@ -154,7 +154,7 @@ function he() {
154
154
  var a;
155
155
  return o.prototype = s, a = new o(), o.prototype = null, a;
156
156
  };
157
- }(), v = {}, m = v.lib = {}, w = m.Base = function() {
157
+ }(), v = {}, m = v.lib = {}, y = m.Base = function() {
158
158
  return {
159
159
  /**
160
160
  * Creates a new object that inherits from this object.
@@ -239,7 +239,7 @@ function he() {
239
239
  return this.init.prototype.extend(this);
240
240
  }
241
241
  };
242
- }(), g = m.WordArray = w.extend({
242
+ }(), w = m.WordArray = y.extend({
243
243
  /**
244
244
  * Initializes a newly created word array.
245
245
  *
@@ -315,7 +315,7 @@ function he() {
315
315
  * var clone = wordArray.clone();
316
316
  */
317
317
  clone: function() {
318
- var o = w.clone.call(this);
318
+ var o = y.clone.call(this);
319
319
  return o.words = this.words.slice(0), o;
320
320
  },
321
321
  /**
@@ -334,7 +334,7 @@ function he() {
334
334
  random: function(o) {
335
335
  for (var s = [], a = 0; a < o; a += 4)
336
336
  s.push(l());
337
- return new g.init(s, o);
337
+ return new w.init(s, o);
338
338
  }
339
339
  }), b = v.enc = {}, f = b.Hex = {
340
340
  /**
@@ -373,7 +373,7 @@ function he() {
373
373
  parse: function(o) {
374
374
  for (var s = o.length, a = [], h = 0; h < s; h += 2)
375
375
  a[h >>> 3] |= parseInt(o.substr(h, 2), 16) << 24 - h % 8 * 4;
376
- return new g.init(a, s / 2);
376
+ return new w.init(a, s / 2);
377
377
  }
378
378
  }, p = b.Latin1 = {
379
379
  /**
@@ -412,7 +412,7 @@ function he() {
412
412
  parse: function(o) {
413
413
  for (var s = o.length, a = [], h = 0; h < s; h++)
414
414
  a[h >>> 2] |= (o.charCodeAt(h) & 255) << 24 - h % 4 * 8;
415
- return new g.init(a, s);
415
+ return new w.init(a, s);
416
416
  }
417
417
  }, i = b.Utf8 = {
418
418
  /**
@@ -451,7 +451,7 @@ function he() {
451
451
  parse: function(o) {
452
452
  return p.parse(unescape(encodeURIComponent(o)));
453
453
  }
454
- }, d = m.BufferedBlockAlgorithm = w.extend({
454
+ }, d = m.BufferedBlockAlgorithm = y.extend({
455
455
  /**
456
456
  * Resets this block algorithm's data buffer to its initial state.
457
457
  *
@@ -460,7 +460,7 @@ function he() {
460
460
  * bufferedBlockAlgorithm.reset();
461
461
  */
462
462
  reset: function() {
463
- this._data = new g.init(), this._nDataBytes = 0;
463
+ this._data = new w.init(), this._nDataBytes = 0;
464
464
  },
465
465
  /**
466
466
  * Adds new data to this block algorithm's buffer.
@@ -492,13 +492,13 @@ function he() {
492
492
  _process: function(o) {
493
493
  var s, a = this._data, h = a.words, _ = a.sigBytes, S = this.blockSize, C = S * 4, x = _ / C;
494
494
  o ? x = n.ceil(x) : x = n.max((x | 0) - this._minBufferSize, 0);
495
- var N = x * S, H = n.min(N * 4, _);
495
+ var N = x * S, P = n.min(N * 4, _);
496
496
  if (N) {
497
- for (var W = 0; W < N; W += S)
498
- this._doProcessBlock(h, W);
499
- s = h.splice(0, N), a.sigBytes -= H;
497
+ for (var D = 0; D < N; D += S)
498
+ this._doProcessBlock(h, D);
499
+ s = h.splice(0, N), a.sigBytes -= P;
500
500
  }
501
- return new g.init(s, H);
501
+ return new w.init(s, P);
502
502
  },
503
503
  /**
504
504
  * Creates a copy of this object.
@@ -510,7 +510,7 @@ function he() {
510
510
  * var clone = bufferedBlockAlgorithm.clone();
511
511
  */
512
512
  clone: function() {
513
- var o = w.clone.call(this);
513
+ var o = y.clone.call(this);
514
514
  return o._data = this._data.clone(), o;
515
515
  },
516
516
  _minBufferSize: 0
@@ -519,7 +519,7 @@ function he() {
519
519
  /**
520
520
  * Configuration options.
521
521
  */
522
- cfg: w.extend(),
522
+ cfg: y.extend(),
523
523
  /**
524
524
  * Initializes a newly created hasher.
525
525
  *
@@ -619,11 +619,11 @@ function he() {
619
619
  }(Math);
620
620
  return r;
621
621
  });
622
- }(Y)), Y.exports;
622
+ }(K)), K.exports;
623
623
  }
624
624
  (function(e, t) {
625
625
  (function(r, n) {
626
- e.exports = n(he());
626
+ e.exports = n(fe());
627
627
  })(q, function(r) {
628
628
  return function() {
629
629
  var n = r, c = n.lib, u = c.WordArray, l = n.enc;
@@ -645,10 +645,10 @@ function he() {
645
645
  */
646
646
  stringify: function(v, m) {
647
647
  m === void 0 && (m = !0);
648
- var w = v.words, g = v.sigBytes, b = m ? this._safe_map : this._map;
648
+ var y = v.words, w = v.sigBytes, b = m ? this._safe_map : this._map;
649
649
  v.clamp();
650
- for (var f = [], p = 0; p < g; p += 3)
651
- for (var i = w[p >>> 2] >>> 24 - p % 4 * 8 & 255, d = w[p + 1 >>> 2] >>> 24 - (p + 1) % 4 * 8 & 255, A = w[p + 2 >>> 2] >>> 24 - (p + 2) % 4 * 8 & 255, o = i << 16 | d << 8 | A, s = 0; s < 4 && p + s * 0.75 < g; s++)
650
+ for (var f = [], p = 0; p < w; p += 3)
651
+ for (var i = y[p >>> 2] >>> 24 - p % 4 * 8 & 255, d = y[p + 1 >>> 2] >>> 24 - (p + 1) % 4 * 8 & 255, A = y[p + 2 >>> 2] >>> 24 - (p + 2) % 4 * 8 & 255, o = i << 16 | d << 8 | A, s = 0; s < 4 && p + s * 0.75 < w; s++)
652
652
  f.push(b.charAt(o >>> 6 * (3 - s) & 63));
653
653
  var a = b.charAt(64);
654
654
  if (a)
@@ -673,42 +673,42 @@ function he() {
673
673
  */
674
674
  parse: function(v, m) {
675
675
  m === void 0 && (m = !0);
676
- var w = v.length, g = m ? this._safe_map : this._map, b = this._reverseMap;
676
+ var y = v.length, w = m ? this._safe_map : this._map, b = this._reverseMap;
677
677
  if (!b) {
678
678
  b = this._reverseMap = [];
679
- for (var f = 0; f < g.length; f++)
680
- b[g.charCodeAt(f)] = f;
679
+ for (var f = 0; f < w.length; f++)
680
+ b[w.charCodeAt(f)] = f;
681
681
  }
682
- var p = g.charAt(64);
682
+ var p = w.charAt(64);
683
683
  if (p) {
684
684
  var i = v.indexOf(p);
685
- i !== -1 && (w = i);
685
+ i !== -1 && (y = i);
686
686
  }
687
- return B(v, w, b);
687
+ return B(v, y, b);
688
688
  },
689
689
  _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
690
690
  _safe_map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
691
691
  };
692
- function B(v, m, w) {
693
- for (var g = [], b = 0, f = 0; f < m; f++)
692
+ function B(v, m, y) {
693
+ for (var w = [], b = 0, f = 0; f < m; f++)
694
694
  if (f % 4) {
695
- var p = w[v.charCodeAt(f - 1)] << f % 4 * 2, i = w[v.charCodeAt(f)] >>> 6 - f % 4 * 2, d = p | i;
696
- g[b >>> 2] |= d << 24 - b % 4 * 8, b++;
695
+ var p = y[v.charCodeAt(f - 1)] << f % 4 * 2, i = y[v.charCodeAt(f)] >>> 6 - f % 4 * 2, d = p | i;
696
+ w[b >>> 2] |= d << 24 - b % 4 * 8, b++;
697
697
  }
698
- return u.create(g, b);
698
+ return u.create(w, b);
699
699
  }
700
700
  }(), r.enc.Base64url;
701
701
  });
702
- })(ue);
703
- var Ue = ue.exports;
704
- const ze = /* @__PURE__ */ ce(Ue);
705
- var fe = { exports: {} };
702
+ })(he);
703
+ var Ue = he.exports;
704
+ const He = /* @__PURE__ */ ue(Ue);
705
+ var de = { exports: {} };
706
706
  (function(e, t) {
707
707
  (function(r, n) {
708
- e.exports = n(he());
708
+ e.exports = n(fe());
709
709
  })(q, function(r) {
710
710
  return function(n) {
711
- var c = r, u = c.lib, l = u.WordArray, B = u.Hasher, v = c.algo, m = [], w = [];
711
+ var c = r, u = c.lib, l = u.WordArray, B = u.Hasher, v = c.algo, m = [], y = [];
712
712
  (function() {
713
713
  function f(A) {
714
714
  for (var o = n.sqrt(A), s = 2; s <= o; s++)
@@ -720,22 +720,22 @@ var fe = { exports: {} };
720
720
  return (A - (A | 0)) * 4294967296 | 0;
721
721
  }
722
722
  for (var i = 2, d = 0; d < 64; )
723
- f(i) && (d < 8 && (m[d] = p(n.pow(i, 1 / 2))), w[d] = p(n.pow(i, 1 / 3)), d++), i++;
723
+ f(i) && (d < 8 && (m[d] = p(n.pow(i, 1 / 2))), y[d] = p(n.pow(i, 1 / 3)), d++), i++;
724
724
  })();
725
- var g = [], b = v.SHA256 = B.extend({
725
+ var w = [], b = v.SHA256 = B.extend({
726
726
  _doReset: function() {
727
727
  this._hash = new l.init(m.slice(0));
728
728
  },
729
729
  _doProcessBlock: function(f, p) {
730
730
  for (var i = this._hash.words, d = i[0], A = i[1], o = i[2], s = i[3], a = i[4], h = i[5], _ = i[6], S = i[7], C = 0; C < 64; C++) {
731
731
  if (C < 16)
732
- g[C] = f[p + C] | 0;
732
+ w[C] = f[p + C] | 0;
733
733
  else {
734
- var x = g[C - 15], N = (x << 25 | x >>> 7) ^ (x << 14 | x >>> 18) ^ x >>> 3, H = g[C - 2], W = (H << 15 | H >>> 17) ^ (H << 13 | H >>> 19) ^ H >>> 10;
735
- g[C] = N + g[C - 7] + W + g[C - 16];
734
+ var x = w[C - 15], N = (x << 25 | x >>> 7) ^ (x << 14 | x >>> 18) ^ x >>> 3, P = w[C - 2], D = (P << 15 | P >>> 17) ^ (P << 13 | P >>> 19) ^ P >>> 10;
735
+ w[C] = N + w[C - 7] + D + w[C - 16];
736
736
  }
737
- var de = a & h ^ ~a & _, le = d & A ^ d & o ^ A & o, pe = (d << 30 | d >>> 2) ^ (d << 19 | d >>> 13) ^ (d << 10 | d >>> 22), ve = (a << 26 | a >>> 6) ^ (a << 21 | a >>> 11) ^ (a << 7 | a >>> 25), te = S + ve + de + w[C] + g[C], ge = pe + le;
738
- S = _, _ = h, h = a, a = s + te | 0, s = o, o = A, A = d, d = te + ge | 0;
737
+ var le = a & h ^ ~a & _, pe = d & A ^ d & o ^ A & o, ve = (d << 30 | d >>> 2) ^ (d << 19 | d >>> 13) ^ (d << 10 | d >>> 22), ge = (a << 26 | a >>> 6) ^ (a << 21 | a >>> 11) ^ (a << 7 | a >>> 25), te = S + ge + le + y[C] + w[C], we = ve + pe;
738
+ S = _, _ = h, h = a, a = s + te | 0, s = o, o = A, A = d, d = te + we | 0;
739
739
  }
740
740
  i[0] = i[0] + d | 0, i[1] = i[1] + A | 0, i[2] = i[2] + o | 0, i[3] = i[3] + s | 0, i[4] = i[4] + a | 0, i[5] = i[5] + h | 0, i[6] = i[6] + _ | 0, i[7] = i[7] + S | 0;
741
741
  },
@@ -751,9 +751,9 @@ var fe = { exports: {} };
751
751
  c.SHA256 = B._createHelper(b), c.HmacSHA256 = B._createHmacHelper(b);
752
752
  }(Math), r.SHA256;
753
753
  });
754
- })(fe);
755
- var Pe = fe.exports;
756
- const He = /* @__PURE__ */ ce(Pe), Oe = (e, t) => {
754
+ })(de);
755
+ var Pe = de.exports;
756
+ const Oe = /* @__PURE__ */ ue(Pe), Te = (e, t) => {
757
757
  const {
758
758
  client_id: r,
759
759
  redirect_uri: n,
@@ -763,14 +763,14 @@ const He = /* @__PURE__ */ ce(Pe), Oe = (e, t) => {
763
763
  chain: B,
764
764
  network: v,
765
765
  address: m,
766
- signature: w
767
- } = e, g = m ? {
766
+ signature: y
767
+ } = e, w = m ? {
768
768
  address: m,
769
- ...w !== void 0 ? { signature: w } : {},
769
+ ...y !== void 0 ? { signature: y } : {},
770
770
  ...l !== void 0 || B !== void 0 ? { chain: l ? ee(l) : B } : {},
771
- ...l !== void 0 || v !== void 0 ? { network: l ? ae(l) : v } : {}
771
+ ...l !== void 0 || v !== void 0 ? { network: l ? ce(l) : v } : {}
772
772
  } : {};
773
- return Z({
773
+ return Y({
774
774
  client_id: r,
775
775
  redirect_uri: n,
776
776
  ...c !== void 0 ? { scope: c } : {},
@@ -778,25 +778,25 @@ const He = /* @__PURE__ */ ce(Pe), Oe = (e, t) => {
778
778
  code_challenge: t,
779
779
  code_challenge_method: "S256",
780
780
  response_type: "code",
781
- ...g
781
+ ...w
782
782
  });
783
- }, Te = () => {
783
+ }, Me = () => {
784
784
  let e = "";
785
785
  const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", r = t.length;
786
786
  let n = 0;
787
787
  for (; n < 128; )
788
788
  e += t.charAt(Math.floor(Math.random() * r)), n += 1;
789
789
  return e;
790
- }, Me = (e) => ze.stringify(He(e)), oe = (e, t) => {
791
- const r = Te(), n = Me(r);
792
- return localStorage.setItem(M, r || ""), `${e}/auth?${Oe(t, n)}`;
790
+ }, Le = (e) => He.stringify(Oe(e)), oe = (e, t) => {
791
+ const r = Me(), n = Le(r);
792
+ return localStorage.setItem(M, r || ""), `${e}/auth?${Te(t, n)}`;
793
793
  }, se = () => {
794
794
  const e = window.location.href;
795
795
  if (!e || !(e != null && e.includes("?")))
796
796
  return;
797
797
  const [t, r] = e.split("?");
798
798
  r && window.history.replaceState(null, "", t);
799
- }, ie = (e) => e.code != null, Le = (e) => e.refresh_token != null, Ne = (e) => e.client_secret != null, je = async (e, t, r, n) => {
799
+ }, ie = (e) => e.code != null, Fe = (e) => e.refresh_token != null, Ne = (e) => e.client_secret != null, ae = async (e, t, r, n) => {
800
800
  const c = await fetch(`${e}`, {
801
801
  method: t,
802
802
  headers: n,
@@ -813,25 +813,25 @@ const He = /* @__PURE__ */ ce(Pe), Oe = (e, t) => {
813
813
  throw u;
814
814
  return u;
815
815
  }, T = typeof window > "u";
816
- var U, F, L, P, z, O, j, E, $, V, G, J;
817
- class De {
816
+ var R, L, F, H, U, O, j, I, $, V, G, J;
817
+ class We {
818
818
  constructor(t) {
819
819
  /**
820
820
  * {@link https://monerium.dev/api-docs#operation/auth-token}
821
821
  */
822
- R(this, O);
822
+ z(this, O);
823
823
  // -- Helper Methods
824
- R(this, E);
825
- R(this, U, void 0);
826
- R(this, F, void 0);
824
+ z(this, I);
825
+ z(this, R, void 0);
826
+ z(this, L, void 0);
827
827
  /** The socket will be available after subscribing to an event */
828
- R(this, L, void 0);
829
- R(this, P, void 0);
830
- R(this, z, void 0);
831
- R(this, V, void 0);
832
- R(this, G, void 0);
833
- R(this, J, void 0);
834
- if (I(this, P, /* @__PURE__ */ new Map()), this.isAuthorized = !!this.bearerProfile, I(this, V, async (r, n, c, u) => {
828
+ z(this, F, void 0);
829
+ z(this, H, void 0);
830
+ z(this, U, void 0);
831
+ z(this, V, void 0);
832
+ z(this, G, void 0);
833
+ z(this, J, void 0);
834
+ if (E(this, H, /* @__PURE__ */ new Map()), this.isAuthorized = !!this.bearerProfile, E(this, V, async (r, n, c, u) => {
835
835
  const l = localStorage.getItem(M) || "";
836
836
  if (!l)
837
837
  throw new Error("Code verifier not found");
@@ -841,18 +841,18 @@ class De {
841
841
  client_id: r,
842
842
  code_verifier: l
843
843
  });
844
- }), I(this, G, async ({
844
+ }), E(this, G, async ({
845
845
  clientId: r,
846
846
  clientSecret: n
847
847
  }) => await k(this, O, j).call(this, {
848
848
  client_id: r,
849
849
  client_secret: n
850
- })), I(this, J, async (r, n) => await k(this, O, j).call(this, {
850
+ })), E(this, J, async (r, n) => await k(this, O, j).call(this, {
851
851
  refresh_token: n,
852
852
  client_id: r
853
853
  })), this.subscribeToOrderNotifications = () => {
854
854
  var c, u;
855
- const r = `${y(this, U).wss}/profiles/${(c = this.bearerProfile) == null ? void 0 : c.profile}/orders?access_token=${(u = this.bearerProfile) == null ? void 0 : u.access_token}`, n = new WebSocket(r);
855
+ const r = `${g(this, R).wss}/profiles/${(c = this.bearerProfile) == null ? void 0 : c.profile}/orders?access_token=${(u = this.bearerProfile) == null ? void 0 : u.access_token}`, n = new WebSocket(r);
856
856
  return n.addEventListener("open", () => {
857
857
  console.info(`Socket connected: ${r}`);
858
858
  }), n.addEventListener("error", (l) => {
@@ -860,30 +860,30 @@ class De {
860
860
  }), n.addEventListener("message", (l) => {
861
861
  var v;
862
862
  const B = JSON.parse(l.data);
863
- (v = y(this, P).get(B.meta.state)) == null || v(
863
+ (v = g(this, H).get(B.meta.state)) == null || v(
864
864
  B
865
865
  );
866
866
  }), n.addEventListener("close", () => {
867
867
  console.info(`Socket connection closed: ${r}`);
868
868
  }), n;
869
869
  }, this.auth = async (r) => await k(this, O, j).call(this, r), this.connect = async (r) => await k(this, O, j).call(this, r), this.getAuthFlowURI = (r) => {
870
- const n = oe(y(this, U).api, r);
870
+ const n = oe(g(this, R).api, r);
871
871
  return this.codeVerifier = localStorage.getItem(M), n;
872
- }, this.pkceRequest = (r) => this.getAuthFlowURI(r), this.getEnvironment = () => y(this, U), !t) {
873
- I(this, U, K.environments.sandbox);
872
+ }, this.pkceRequest = (r) => this.getAuthFlowURI(r), this.getEnvironment = () => g(this, R), !t) {
873
+ E(this, R, X.environments.sandbox);
874
874
  return;
875
875
  }
876
876
  if (typeof t == "string")
877
- I(this, U, K.environments[t]);
878
- else if (I(this, U, K.environments[t.environment || "sandbox"]), T) {
877
+ E(this, R, X.environments[t]);
878
+ else if (E(this, R, X.environments[t.environment || "sandbox"]), T) {
879
879
  const { clientId: r, clientSecret: n } = t;
880
- I(this, z, {
880
+ E(this, U, {
881
881
  clientId: r,
882
882
  clientSecret: n
883
883
  });
884
884
  } else {
885
885
  const { clientId: r, redirectUrl: n } = t;
886
- I(this, z, {
886
+ E(this, U, {
887
887
  clientId: r,
888
888
  redirectUrl: n
889
889
  });
@@ -898,12 +898,12 @@ class De {
898
898
  */
899
899
  async authorize(t) {
900
900
  var u, l;
901
- const r = (t == null ? void 0 : t.clientId) || ((u = y(this, z)) == null ? void 0 : u.clientId), n = (t == null ? void 0 : t.redirectUrl) || ((l = y(this, z)) == null ? void 0 : l.redirectUrl);
901
+ const r = (t == null ? void 0 : t.clientId) || ((u = g(this, U)) == null ? void 0 : u.clientId), n = (t == null ? void 0 : t.redirectUrl) || ((l = g(this, U)) == null ? void 0 : l.redirectUrl);
902
902
  if (!r)
903
903
  throw new Error("Missing ClientId");
904
904
  if (!n)
905
905
  throw new Error("Missing RedirectUrl");
906
- const c = oe(y(this, U).api, {
906
+ const c = oe(g(this, R).api, {
907
907
  client_id: r,
908
908
  redirect_uri: n,
909
909
  address: t == null ? void 0 : t.address,
@@ -919,27 +919,27 @@ class De {
919
919
  * @returns boolean to indicate if access has been granted
920
920
  */
921
921
  async getAccess(t) {
922
- var v, m, w;
923
- const r = (t == null ? void 0 : t.clientId) || ((v = y(this, z)) == null ? void 0 : v.clientId);
924
- if ((t == null ? void 0 : t.clientSecret) || ((m = y(this, z)) == null ? void 0 : m.clientSecret)) {
922
+ var v, m, y;
923
+ const r = (t == null ? void 0 : t.clientId) || ((v = g(this, U)) == null ? void 0 : v.clientId);
924
+ if ((t == null ? void 0 : t.clientSecret) || ((m = g(this, U)) == null ? void 0 : m.clientSecret)) {
925
925
  if (!T)
926
926
  throw new Error("Only use client credentials on server side");
927
- return await y(this, G).call(this, y(this, z)), !!this.bearerProfile;
927
+ return await g(this, G).call(this, g(this, U)), !!this.bearerProfile;
928
928
  }
929
- const c = (t == null ? void 0 : t.redirectUrl) || ((w = y(this, z)) == null ? void 0 : w.redirectUrl);
929
+ const c = (t == null ? void 0 : t.redirectUrl) || ((y = g(this, U)) == null ? void 0 : y.redirectUrl);
930
930
  if (!r)
931
931
  throw new Error("Missing ClientId");
932
932
  if (T)
933
933
  throw new Error("This only works client side");
934
- const u = new URLSearchParams(window.location.search).get("code") || void 0, l = new URLSearchParams(window.location.search).get("state") || void 0, B = localStorage.getItem(D) || void 0;
935
- return B ? await y(this, J).call(this, r, B) : u && await y(this, V).call(this, r, c, u, l), !!this.bearerProfile;
934
+ const u = new URLSearchParams(window.location.search).get("code") || void 0, l = new URLSearchParams(window.location.search).get("state") || void 0, B = localStorage.getItem(W) || void 0;
935
+ return B ? await g(this, J).call(this, r, B) : u && await g(this, V).call(this, r, c, u, l), !!this.bearerProfile;
936
936
  }
937
937
  // -- Read Methods
938
938
  /**
939
939
  * {@link https://monerium.dev/api-docs#operation/auth-context}
940
940
  */
941
941
  getAuthContext() {
942
- return k(this, E, $).call(this, "get", "auth/context");
942
+ return k(this, I, $).call(this, "get", "auth/context");
943
943
  }
944
944
  /**
945
945
  * {@link https://monerium.dev/api-docs#operation/profile}
@@ -947,40 +947,40 @@ class De {
947
947
 
948
948
  */
949
949
  getProfile(t) {
950
- return k(this, E, $).call(this, "get", `profiles/${t}`);
950
+ return k(this, I, $).call(this, "get", `profiles/${t}`);
951
951
  }
952
952
  /**
953
953
  * {@link https://monerium.dev/api-docs#operation/profile-balances}
954
954
  * @param {string=} profileId - the id of the profile to fetch balances.
955
955
  */
956
956
  getBalances(t) {
957
- return t ? k(this, E, $).call(this, "get", `profiles/${t}/balances`) : k(this, E, $).call(this, "get", "balances");
957
+ return t ? k(this, I, $).call(this, "get", `profiles/${t}/balances`) : k(this, I, $).call(this, "get", "balances");
958
958
  }
959
959
  /**
960
960
  * {@link https://monerium.dev/api-docs#operation/orders}
961
961
  */
962
962
  getOrders(t) {
963
- const r = Z(t);
964
- return k(this, E, $).call(this, "get", `orders?${r}`);
963
+ const r = Y(t);
964
+ return k(this, I, $).call(this, "get", `orders?${r}`);
965
965
  }
966
966
  /**
967
967
  * {@link https://monerium.dev/api-docs#operation/order}
968
968
  */
969
969
  getOrder(t) {
970
- return k(this, E, $).call(this, "get", `orders/${t}`);
970
+ return k(this, I, $).call(this, "get", `orders/${t}`);
971
971
  }
972
972
  /**
973
973
  * {@link https://monerium.dev/api-docs#operation/tokens}
974
974
  */
975
975
  getTokens() {
976
- return k(this, E, $).call(this, "get", "tokens");
976
+ return k(this, I, $).call(this, "get", "tokens");
977
977
  }
978
978
  // -- Write Methods
979
979
  /**
980
980
  * {@link https://monerium.dev/api-docs#operation/profile-addresses}
981
981
  */
982
982
  linkAddress(t, r) {
983
- return r = Q(r), r.accounts = r.accounts.map((n) => Q(n)), k(this, E, $).call(this, "post", `profiles/${t}/addresses`, JSON.stringify(r));
983
+ return r = Q(r), r.accounts = r.accounts.map((n) => Q(n)), k(this, I, $).call(this, "post", `profiles/${t}/addresses`, JSON.stringify(r));
984
984
  }
985
985
  /**
986
986
  * {@link https://monerium.dev/api-docs#operation/post-orders}
@@ -995,34 +995,34 @@ class De {
995
995
  identifier: Q(t.counterpart.identifier)
996
996
  }
997
997
  };
998
- return r ? k(this, E, $).call(this, "post", `profiles/${r}/orders`, JSON.stringify(n)) : k(this, E, $).call(this, "post", "orders", JSON.stringify(n));
998
+ return r ? k(this, I, $).call(this, "post", `profiles/${r}/orders`, JSON.stringify(n)) : k(this, I, $).call(this, "post", "orders", JSON.stringify(n));
999
999
  }
1000
1000
  /**
1001
1001
  * {@link https://monerium.dev/api-docs#operation/supporting-document}
1002
1002
  */
1003
1003
  uploadSupportingDocument(t) {
1004
- const r = Z(
1005
- t
1006
- );
1007
- return k(this, E, $).call(this, "post", "files/supporting-document", r, !0);
1004
+ const r = new FormData();
1005
+ return r.append("file", t), ae(`${g(this, R).api}/files`, "post", r, {
1006
+ Authorization: g(this, L) || ""
1007
+ });
1008
1008
  }
1009
1009
  // -- Notifications
1010
1010
  async connectOrderSocket() {
1011
1011
  var t;
1012
- (t = this.bearerProfile) != null && t.access_token && y(this, P).size > 0 && I(this, L, this.subscribeToOrderNotifications());
1012
+ (t = this.bearerProfile) != null && t.access_token && g(this, H).size > 0 && E(this, F, this.subscribeToOrderNotifications());
1013
1013
  }
1014
1014
  /**
1015
1015
  * Cleanups the socket and the subscriptions
1016
1016
  */
1017
1017
  async disconnect() {
1018
1018
  var t;
1019
- T || localStorage.removeItem(M), y(this, P).clear(), (t = y(this, L)) == null || t.close(), I(this, F, void 0), this.bearerProfile = void 0;
1019
+ T || localStorage.removeItem(M), g(this, H).clear(), (t = g(this, F)) == null || t.close(), E(this, L, void 0), this.bearerProfile = void 0;
1020
1020
  }
1021
1021
  /**
1022
1022
  * Revokes access
1023
1023
  */
1024
1024
  async revokeAccess() {
1025
- T || localStorage.removeItem(D), this.disconnect();
1025
+ T || localStorage.removeItem(W), this.disconnect();
1026
1026
  }
1027
1027
  /**
1028
1028
  * Subscribe to MoneriumEvent to receive notifications using the Monerium API (WebSocket)
@@ -1032,7 +1032,7 @@ class De {
1032
1032
  * @param handler The handler to be called when the event is triggered
1033
1033
  */
1034
1034
  subscribeOrders(t, r) {
1035
- y(this, P).set(t, r);
1035
+ g(this, H).set(t, r);
1036
1036
  }
1037
1037
  /**
1038
1038
  * Unsubscribe from MoneriumEvent and close the socket if there are no more subscriptions
@@ -1040,53 +1040,53 @@ class De {
1040
1040
  */
1041
1041
  unsubscribeOrders(t) {
1042
1042
  var r;
1043
- y(this, P).delete(t), y(this, P).size === 0 && ((r = y(this, L)) == null || r.close(), I(this, L, void 0));
1043
+ g(this, H).delete(t), g(this, H).size === 0 && ((r = g(this, F)) == null || r.close(), E(this, F, void 0));
1044
1044
  }
1045
1045
  }
1046
- U = new WeakMap(), F = new WeakMap(), L = new WeakMap(), P = new WeakMap(), z = new WeakMap(), O = new WeakSet(), j = async function(t) {
1046
+ R = new WeakMap(), L = new WeakMap(), F = new WeakMap(), H = new WeakMap(), U = new WeakMap(), O = new WeakSet(), j = async function(t) {
1047
1047
  let r;
1048
1048
  if (ie(t))
1049
1049
  r = { ...t, grant_type: "authorization_code" };
1050
- else if (Le(t))
1050
+ else if (Fe(t))
1051
1051
  r = { ...t, grant_type: "refresh_token" };
1052
1052
  else if (Ne(t))
1053
1053
  r = { ...t, grant_type: "client_credentials" };
1054
1054
  else
1055
1055
  throw new Error("Authorization grant type could not be detected.");
1056
- return await k(this, E, $).call(this, "post", "auth/token", r, !0).then((n) => {
1056
+ return await k(this, I, $).call(this, "post", "auth/token", r, !0).then((n) => {
1057
1057
  var c;
1058
- this.bearerProfile = n, this.isAuthorized = !!n, I(this, F, `Bearer ${n == null ? void 0 : n.access_token}`), T || window.localStorage.setItem(
1059
- D,
1058
+ this.bearerProfile = n, this.isAuthorized = !!n, E(this, L, `Bearer ${n == null ? void 0 : n.access_token}`), T || window.localStorage.setItem(
1059
+ W,
1060
1060
  ((c = this.bearerProfile) == null ? void 0 : c.refresh_token) || ""
1061
1061
  );
1062
1062
  }).catch((n) => {
1063
- throw T || (localStorage.removeItem(M), localStorage.removeItem(D), se()), new Error(n == null ? void 0 : n.message);
1063
+ throw T || (localStorage.removeItem(M), localStorage.removeItem(W), se()), new Error(n == null ? void 0 : n.message);
1064
1064
  }), ie(t) && se(), this.bearerProfile;
1065
- }, E = new WeakSet(), $ = async function(t, r, n, c) {
1066
- return je(
1067
- `${y(this, U).api}/${r}`,
1065
+ }, I = new WeakSet(), $ = async function(t, r, n, c) {
1066
+ return ae(
1067
+ `${g(this, R).api}/${r}`,
1068
1068
  t,
1069
- c ? Z(n) : n,
1069
+ c ? Y(n) : n,
1070
1070
  {
1071
- Authorization: y(this, F) || "",
1071
+ Authorization: g(this, L) || "",
1072
1072
  "Content-Type": `application/${c ? "x-www-form-urlencoded" : "json"}`
1073
1073
  }
1074
1074
  );
1075
1075
  }, V = new WeakMap(), G = new WeakMap(), J = new WeakMap();
1076
1076
  export {
1077
- Se as AccountState,
1078
- we as Currency,
1079
- be as KYCOutcome,
1080
- _e as KYCState,
1081
- De as MoneriumClient,
1082
- ke as OrderKind,
1083
- Ce as OrderState,
1084
- Be as PaymentStandard,
1085
- me as Permission,
1086
- ye as ProfileType,
1087
- We as constants,
1077
+ Be as AccountState,
1078
+ ye as Currency,
1079
+ Se as KYCOutcome,
1080
+ be as KYCState,
1081
+ We as MoneriumClient,
1082
+ Ce as OrderKind,
1083
+ xe as OrderState,
1084
+ ke as PaymentStandard,
1085
+ _e as Permission,
1086
+ me as ProfileType,
1087
+ De as constants,
1088
1088
  ee as getChain,
1089
- ae as getNetwork,
1090
- Fe as placeOrderMessage,
1089
+ ce as getNetwork,
1090
+ qe as placeOrderMessage,
1091
1091
  re as rfc3339
1092
1092
  };
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monerium/sdk",
3
- "version": "2.11.0",
3
+ "version": "2.12.0",
4
4
  "description": "Everything you need to interact with the Monerium API - an electronic money issuer.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monerium/sdk",
3
- "version": "2.11.0",
3
+ "version": "2.12.0",
4
4
  "description": "Everything you need to interact with the Monerium API - an electronic money issuer.",
5
5
  "license": "MIT",
6
6
  "repository": {