@monerium/sdk 2.7.2 → 2.7.3

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,65 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.7.3](https://github.com/monerium/public-monorepo/compare/sdk-v2.7.3...sdk-v2.7.3) (2023-11-17)
4
+
5
+
6
+ ### Features
7
+
8
+ * add docs ([f5ba19d](https://github.com/monerium/public-monorepo/commit/f5ba19d5600e01cd0c97467a0a1f2fe94a2f40fc))
9
+ * new functions added + arguments to class instance ([b5b8c5d](https://github.com/monerium/public-monorepo/commit/b5b8c5d3fbae6ce7a90569b74d887b81d9f3a336))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * add example, fix sdk for backwards compatibility and update README ([6992417](https://github.com/monerium/public-monorepo/commit/6992417e44b442a06b1d65f88d588d17e71b4562))
15
+ * add removal date to deprecated methods and add connect as deprecated ([c1e02e2](https://github.com/monerium/public-monorepo/commit/c1e02e273b08b091475757e0e68051098e20a5a0))
16
+ * add yarnrc to each lib ([6dc9f7a](https://github.com/monerium/public-monorepo/commit/6dc9f7a4a46e24596c862df83823f90be5dad803))
17
+ * broken test ([6cfdd57](https://github.com/monerium/public-monorepo/commit/6cfdd57f041eba99312f5dc32fb40b7b2c2406a9))
18
+ * clean query on error ([2620322](https://github.com/monerium/public-monorepo/commit/26203224cdfb09d5f1a8be34f0fb27ed6c95b800))
19
+ * continue on error gh-pages ([d033048](https://github.com/monerium/public-monorepo/commit/d033048a490390815ef17dad45b526b04898c2ae))
20
+ * debug ([b2543eb](https://github.com/monerium/public-monorepo/commit/b2543eb222cbe74131377e164c28c3093b72be5f))
21
+ * debug ([ea1bd38](https://github.com/monerium/public-monorepo/commit/ea1bd38c8f8f98cf65a9bcab615faa540a8b7324))
22
+ * debug ([20e3ccb](https://github.com/monerium/public-monorepo/commit/20e3ccb3297e3bba02be86349a151b1bf0ed8f5c))
23
+ * dep ([0d9953b](https://github.com/monerium/public-monorepo/commit/0d9953b5a2e259851d05d422ecf7f2c1fa36c6ea))
24
+ * expose getChain and getNetwork + update docs ([085d9bd](https://github.com/monerium/public-monorepo/commit/085d9bd261342d14936a7f9f1d5cc1fdd859ec26))
25
+ * letsgo ([af653ce](https://github.com/monerium/public-monorepo/commit/af653ce744b333023892370b21ec28738c82910e))
26
+ * lol ([630cb9f](https://github.com/monerium/public-monorepo/commit/630cb9fa3f4d7efa363b7fd9079c4e5e4e26bdd3))
27
+ * perm ([3210011](https://github.com/monerium/public-monorepo/commit/32100114916d85b1b1982cd942c3181210943ee9))
28
+ * props to auto-link ([ce85efd](https://github.com/monerium/public-monorepo/commit/ce85efd534cfcac7fb9e7804b733641aeb752f4f))
29
+ * publish ([537b336](https://github.com/monerium/public-monorepo/commit/537b336180df288e0653b0db7230ae84758f8475))
30
+ * publish not working ([50a2a05](https://github.com/monerium/public-monorepo/commit/50a2a0583c03ef7a66a605c8215f72256192b8e2))
31
+ * releaseas ([db309d2](https://github.com/monerium/public-monorepo/commit/db309d2635196bac5df230e886d70c395c58b06b))
32
+ * remove packageManager from sdk packagejson ([f87d93d](https://github.com/monerium/public-monorepo/commit/f87d93d51c953fdc8c72a4458f19f11ad0fd0d58))
33
+ * rewrite the CHANGELOG after a lot messy testing ([fb1a3c9](https://github.com/monerium/public-monorepo/commit/fb1a3c9517c269c49bc6ad9e492c79481184afcd))
34
+ * sdk version ([27c479c](https://github.com/monerium/public-monorepo/commit/27c479c3b324a33ea7e44613601e4f32269e9082))
35
+ * static files not deployed ([a1131d7](https://github.com/monerium/public-monorepo/commit/a1131d7ab988a93e41b7f3b65429b5aa27ff588e))
36
+ * stuff ([6b06483](https://github.com/monerium/public-monorepo/commit/6b06483ad5ca8f3e00e8d88f2739cf2526ae2101))
37
+ * stuff ([1dadd44](https://github.com/monerium/public-monorepo/commit/1dadd44f07fb2234bf1fca1f1f20dbc4158cface))
38
+ * syntax ([f8cfbad](https://github.com/monerium/public-monorepo/commit/f8cfbad0fa536808ddc988cf9e6ca8aef5247ef7))
39
+ * test ([2c52f99](https://github.com/monerium/public-monorepo/commit/2c52f99e5c2fc19c502fae01e7ca105010df979f))
40
+ * test ([21c2cb8](https://github.com/monerium/public-monorepo/commit/21c2cb8c936410f6701a87313cb1bcb4dd9f281f))
41
+ * test ([2a612b1](https://github.com/monerium/public-monorepo/commit/2a612b1f93a59ec709c9f328c7ba4bc910971de9))
42
+ * test ([0dfd8e1](https://github.com/monerium/public-monorepo/commit/0dfd8e1489db8096f1cb66a3816e410ddb996d64))
43
+ * test deploy ([1a3e311](https://github.com/monerium/public-monorepo/commit/1a3e311fdc7bde2f17390e4cdb3f0a48859e5cf9))
44
+ * test: ([e122f61](https://github.com/monerium/public-monorepo/commit/e122f61e5f907785b6076bfda855c275bcfce1d6))
45
+ * testing ([24389c9](https://github.com/monerium/public-monorepo/commit/24389c9f243671c548d957dc499689e58e0bc3f6))
46
+ * testing affected ([60059eb](https://github.com/monerium/public-monorepo/commit/60059ebc035dccf1dcbb4eb64cf0eeb071020caf))
47
+ * testing affected ([a10f49a](https://github.com/monerium/public-monorepo/commit/a10f49a4840218c9f5fa76463b3132401d0a23f4))
48
+ * tests and release action ([a18438c](https://github.com/monerium/public-monorepo/commit/a18438c2974e79975722afe8f7f9679358f32da5))
49
+ * trigger both packages ([a8db647](https://github.com/monerium/public-monorepo/commit/a8db647e694abd753bdb06df352c1d72617d7e67))
50
+ * trigger sdk ([ee1b950](https://github.com/monerium/public-monorepo/commit/ee1b9502c61655e5f0771827fdd116b58c748834))
51
+ * typedoc deps ([0696536](https://github.com/monerium/public-monorepo/commit/0696536edd834b6bf2ca6bf6ea39914d37fcda9c))
52
+ * uff ([ae8e9e5](https://github.com/monerium/public-monorepo/commit/ae8e9e510b5fad9997addd31e1153e9ef66a9d5c))
53
+ * version ([f3a1b1d](https://github.com/monerium/public-monorepo/commit/f3a1b1d7750a2f743d84426e60ea368909dcf93d))
54
+ * yarn instead of npm ([5b86535](https://github.com/monerium/public-monorepo/commit/5b86535ed225effa0d13b6b60388bf05783ebe63))
55
+
56
+ ## [2.7.3](https://github.com/monerium/public-monorepo/compare/sdk-v2.7.2...sdk-v2.7.3) (2023-11-17)
57
+
58
+
59
+ ### Bug Fixes
60
+
61
+ * clean query on error ([2620322](https://github.com/monerium/public-monorepo/commit/26203224cdfb09d5f1a8be34f0fb27ed6c95b800))
62
+
3
63
  ## [2.7.2](https://github.com/monerium/public-monorepo/compare/sdk-v2.7.2...sdk-v2.7.2) (2023-11-17)
4
64
 
5
65
 
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var Z=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var w=(e,t,r)=>(Z(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)},I=(e,t,r,n)=>(Z(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);var B=(e,t,r)=>(Z(e,t,"access private method"),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var ne=(e=>(e.eur="eur",e))(ne||{}),se=(e=>(e.corporate="corporate",e.personal="personal",e))(se||{}),oe=(e=>(e.read="read",e.write="write",e))(oe||{}),ie=(e=>(e.absent="absent",e.submitted="submitted",e.pending="pending",e.confirmed="confirmed",e))(ie||{}),ae=(e=>(e.approved="approved",e.rejected="rejected",e.unknown="unknown",e))(ae||{}),ce=(e=>(e.requested="requested",e.approved="approved",e.pending="pending",e))(ce||{}),ue=(e=>(e.iban="iban",e.scan="scan",e))(ue||{}),de=(e=>(e.redeem="redeem",e.issue="issue",e))(de||{}),he=(e=>(e.placed="placed",e.pending="pending",e.processed="processed",e.rejected="rejected",e))(he||{});const fe=e=>{if(e.toString()==="Invalid Date")throw e;const t=n=>n<10?"0"+n:n,r=n=>{if(n===0)return"Z";const u=n>0?"-":"+";return n=Math.abs(n),u+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())},Be=(e,t)=>`Send EUR ${e} to ${t} at ${fe(new Date)}`,Q=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("&"):""},le=e=>{switch(e){case 1:case 5:return"ethereum";case 100:case 10200:return"gnosis";case 137:case 80001:return"polygon";default:throw new Error(`Chain not supported: ${e}`)}},pe=e=>{switch(e){case 1:case 100:case 137:return"mainnet";case 5:return"goerli";case 10200:return"chiado";case 80001:return"mumbai";default:throw new Error(`Network not supported: ${e}`)}},K={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"}}},ke="I hereby declare that I am the address owner.",M="monerium.sdk.code_verifier",W="monerium.sdk.refresh_token",xe={LINK_MESSAGE:ke,STORAGE_CODE_VERIFIER:M,STORAGE_REFRESH_TOKEN:W};var N=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ve(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Ae(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 u=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,u.get?u:{enumerable:!0,get:function(){return e[n]}})}),r}var ge={exports:{}};function Ee(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 X={exports:{}};const Ie={},Re=Object.freeze(Object.defineProperty({__proto__:null,default:Ie},Symbol.toStringTag,{value:"Module"})),Oe=Ae(Re);var ee;function we(){return ee||(ee=1,function(e,t){(function(r,n){e.exports=n()})(N,function(){var r=r||function(n,u){var c;if(typeof window<"u"&&window.crypto&&(c=window.crypto),typeof self<"u"&&self.crypto&&(c=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(c=globalThis.crypto),!c&&typeof window<"u"&&window.msCrypto&&(c=window.msCrypto),!c&&typeof N<"u"&&N.crypto&&(c=N.crypto),!c&&typeof Ee=="function")try{c=Oe}catch{}var v=function(){if(c){if(typeof c.getRandomValues=="function")try{return c.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof c.randomBytes=="function")try{return c.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},C=Object.create||function(){function s(){}return function(o){var a;return s.prototype=o,a=new s,s.prototype=null,a}}(),p={},y=p.lib={},m=y.Base=function(){return{extend:function(s){var o=C(this);return s&&o.mixIn(s),(!o.hasOwnProperty("init")||this.init===o.init)&&(o.init=function(){o.$super.init.apply(this,arguments)}),o.init.prototype=o,o.$super=this,o},create:function(){var s=this.extend();return s.init.apply(s,arguments),s},init:function(){},mixIn:function(s){for(var o in s)s.hasOwnProperty(o)&&(this[o]=s[o]);s.hasOwnProperty("toString")&&(this.toString=s.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),g=y.WordArray=m.extend({init:function(s,o){s=this.words=s||[],o!=u?this.sigBytes=o:this.sigBytes=s.length*4},toString:function(s){return(s||h).stringify(this)},concat:function(s){var o=this.words,a=s.words,d=this.sigBytes,_=s.sigBytes;if(this.clamp(),d%4)for(var S=0;S<_;S++){var k=a[S>>>2]>>>24-S%4*8&255;o[d+S>>>2]|=k<<24-(d+S)%4*8}else for(var x=0;x<_;x+=4)o[d+x>>>2]=a[x>>>2];return this.sigBytes+=_,this},clamp:function(){var s=this.words,o=this.sigBytes;s[o>>>2]&=4294967295<<32-o%4*8,s.length=n.ceil(o/4)},clone:function(){var s=m.clone.call(this);return s.words=this.words.slice(0),s},random:function(s){for(var o=[],a=0;a<s;a+=4)o.push(v());return new g.init(o,s)}}),b=p.enc={},h=b.Hex={stringify:function(s){for(var o=s.words,a=s.sigBytes,d=[],_=0;_<a;_++){var S=o[_>>>2]>>>24-_%4*8&255;d.push((S>>>4).toString(16)),d.push((S&15).toString(16))}return d.join("")},parse:function(s){for(var o=s.length,a=[],d=0;d<o;d+=2)a[d>>>3]|=parseInt(s.substr(d,2),16)<<24-d%8*4;return new g.init(a,o/2)}},l=b.Latin1={stringify:function(s){for(var o=s.words,a=s.sigBytes,d=[],_=0;_<a;_++){var S=o[_>>>2]>>>24-_%4*8&255;d.push(String.fromCharCode(S))}return d.join("")},parse:function(s){for(var o=s.length,a=[],d=0;d<o;d++)a[d>>>2]|=(s.charCodeAt(d)&255)<<24-d%4*8;return new g.init(a,o)}},i=b.Utf8={stringify:function(s){try{return decodeURIComponent(escape(l.stringify(s)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(s){return l.parse(unescape(encodeURIComponent(s)))}},f=y.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new g.init,this._nDataBytes=0},_append:function(s){typeof s=="string"&&(s=i.parse(s)),this._data.concat(s),this._nDataBytes+=s.sigBytes},_process:function(s){var o,a=this._data,d=a.words,_=a.sigBytes,S=this.blockSize,k=S*4,x=_/k;s?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 F=0;F<j;F+=S)this._doProcessBlock(d,F);o=d.splice(0,j),a.sigBytes-=U}return new g.init(o,U)},clone:function(){var s=m.clone.call(this);return s._data=this._data.clone(),s},_minBufferSize:0});y.Hasher=f.extend({cfg:m.extend(),init:function(s){this.cfg=this.cfg.extend(s),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(s){return this._append(s),this._process(),this},finalize:function(s){s&&this._append(s);var o=this._doFinalize();return o},blockSize:16,_createHelper:function(s){return function(o,a){return new s.init(a).finalize(o)}},_createHmacHelper:function(s){return function(o,a){return new A.HMAC.init(s,a).finalize(o)}}});var A=p.algo={};return p}(Math);return r})}(X)),X.exports}(function(e,t){(function(r,n){e.exports=n(we())})(N,function(r){return function(){var n=r,u=n.lib,c=u.WordArray,v=n.enc;v.Base64url={stringify:function(p,y){y===void 0&&(y=!0);var m=p.words,g=p.sigBytes,b=y?this._safe_map:this._map;p.clamp();for(var h=[],l=0;l<g;l+=3)for(var i=m[l>>>2]>>>24-l%4*8&255,f=m[l+1>>>2]>>>24-(l+1)%4*8&255,A=m[l+2>>>2]>>>24-(l+2)%4*8&255,s=i<<16|f<<8|A,o=0;o<4&&l+o*.75<g;o++)h.push(b.charAt(s>>>6*(3-o)&63));var a=b.charAt(64);if(a)for(;h.length%4;)h.push(a);return h.join("")},parse:function(p,y){y===void 0&&(y=!0);var m=p.length,g=y?this._safe_map:this._map,b=this._reverseMap;if(!b){b=this._reverseMap=[];for(var h=0;h<g.length;h++)b[g.charCodeAt(h)]=h}var l=g.charAt(64);if(l){var i=p.indexOf(l);i!==-1&&(m=i)}return C(p,m,b)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"};function C(p,y,m){for(var g=[],b=0,h=0;h<y;h++)if(h%4){var l=m[p.charCodeAt(h-1)]<<h%4*2,i=m[p.charCodeAt(h)]>>>6-h%4*2,f=l|i;g[b>>>2]|=f<<24-b%4*8,b++}return c.create(g,b)}}(),r.enc.Base64url})})(ge);var Pe=ge.exports;const $e=ve(Pe);var ye={exports:{}};(function(e,t){(function(r,n){e.exports=n(we())})(N,function(r){return function(n){var u=r,c=u.lib,v=c.WordArray,C=c.Hasher,p=u.algo,y=[],m=[];(function(){function h(A){for(var s=n.sqrt(A),o=2;o<=s;o++)if(!(A%o))return!1;return!0}function l(A){return(A-(A|0))*4294967296|0}for(var i=2,f=0;f<64;)h(i)&&(f<8&&(y[f]=l(n.pow(i,1/2))),m[f]=l(n.pow(i,1/3)),f++),i++})();var g=[],b=p.SHA256=C.extend({_doReset:function(){this._hash=new v.init(y.slice(0))},_doProcessBlock:function(h,l){for(var i=this._hash.words,f=i[0],A=i[1],s=i[2],o=i[3],a=i[4],d=i[5],_=i[6],S=i[7],k=0;k<64;k++){if(k<16)g[k]=h[l+k]|0;else{var x=g[k-15],j=(x<<25|x>>>7)^(x<<14|x>>>18)^x>>>3,U=g[k-2],F=(U<<15|U>>>17)^(U<<13|U>>>19)^U>>>10;g[k]=j+g[k-7]+F+g[k-16]}var me=a&d^~a&_,_e=f&A^f&s^A&s,be=(f<<30|f>>>2)^(f<<19|f>>>13)^(f<<10|f>>>22),Se=(a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25),Y=S+Se+me+m[k]+g[k],Ce=be+_e;S=_,_=d,d=a,a=o+Y|0,o=s,s=A,A=f,f=Y+Ce|0}i[0]=i[0]+f|0,i[1]=i[1]+A|0,i[2]=i[2]+s|0,i[3]=i[3]+o|0,i[4]=i[4]+a|0,i[5]=i[5]+d|0,i[6]=i[6]+_|0,i[7]=i[7]+S|0},_doFinalize:function(){var h=this._data,l=h.words,i=this._nDataBytes*8,f=h.sigBytes*8;return l[f>>>5]|=128<<24-f%32,l[(f+64>>>9<<4)+14]=n.floor(i/4294967296),l[(f+64>>>9<<4)+15]=i,h.sigBytes=l.length*4,this._process(),this._hash},clone:function(){var h=C.clone.call(this);return h._hash=this._hash.clone(),h}});u.SHA256=C._createHelper(b),u.HmacSHA256=C._createHmacHelper(b)}(Math),r.SHA256})})(ye);var ze=ye.exports;const Ue=ve(ze),He=(e,t)=>{const{client_id:r,redirect_uri:n,scope:u,state:c,chainId:v,chain:C,network:p,address:y,signature:m}=e,g=y?{address:y,...m!==void 0?{signature:m}:{},...v!==void 0||C!==void 0?{chain:v?le(v):C}:{},...v!==void 0||p!==void 0?{network:v?pe(v):p}:{}}:{};return Q({client_id:r,redirect_uri:n,...u!==void 0?{scope:u}:{},...c!==void 0?{state:c}:{},code_challenge:t,code_challenge_method:"S256",response_type:"code",...g})},Te=()=>{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},Me=e=>$e.stringify(Ue(e)),te=(e,t)=>{const r=Te(),n=Me(r);return sessionStorage.setItem(M,r||""),`${e}/auth?${He(t,n)}`},Le=()=>{const e=window.location.href,[t,r]=e.split("?");r&&window.history.replaceState(null,"",t)},re=e=>e.code!=null,je=e=>e.refresh_token!=null,qe=e=>e.client_secret!=null,Ne=async(e,t,r,n)=>{const u=await fetch(`${e}`,{method:t,headers:n,body:r});let c;const v=await u.text();try{c=JSON.parse(v)}catch{throw v}if(!u.ok)throw c;return c},T=typeof window>"u";var P,D,L,z,$,H,q,E,R,V,G,J;class Fe{constructor(t){O(this,H);O(this,E);O(this,P,void 0);O(this,D,void 0);O(this,L,void 0);O(this,z,void 0);O(this,$,void 0);O(this,V,void 0);O(this,G,void 0);O(this,J,void 0);if(I(this,z,new Map),this.isAuthorized=!!this.bearerProfile,I(this,V,async(r,n,u)=>{const c=sessionStorage.getItem(M)||"";if(!c)throw new Error("Code verifier not found");return this.codeVerifier=c,sessionStorage.removeItem(M),await B(this,H,q).call(this,{code:u,redirect_uri:n,client_id:r,code_verifier:c})}),I(this,G,async({clientId:r,clientSecret:n})=>await B(this,H,q).call(this,{client_id:r,client_secret:n})),I(this,J,async(r,n)=>await B(this,H,q).call(this,{refresh_token:n,client_id:r})),this.subscribeToOrderNotifications=()=>{var u,c;const r=`${w(this,P).wss}/profiles/${(u=this.bearerProfile)==null?void 0:u.profile}/orders?access_token=${(c=this.bearerProfile)==null?void 0:c.access_token}`,n=new WebSocket(r);return n.addEventListener("open",()=>{console.info(`Socket connected: ${r}`)}),n.addEventListener("error",v=>{throw console.error(v),new Error(`Socket error: ${r}`)}),n.addEventListener("message",v=>{var p;const C=JSON.parse(v.data);(p=w(this,z).get(C.meta.state))==null||p(C)}),n.addEventListener("close",()=>{console.info(`Socket connection closed: ${r}`)}),n},this.auth=async r=>await B(this,H,q).call(this,r),this.connect=async r=>await B(this,H,q).call(this,r),this.getAuthFlowURI=r=>{const n=te(w(this,P).api,r);return this.codeVerifier=sessionStorage.getItem(M),n},this.pkceRequest=r=>this.getAuthFlowURI(r),this.getEnvironment=()=>w(this,P),!t){I(this,P,K.environments.sandbox);return}if(typeof t=="string")I(this,P,K.environments[t]);else if(I(this,P,K.environments[t.environment||"sandbox"]),T){const{clientId:r,clientSecret:n}=t;I(this,$,{clientId:r,clientSecret:n})}else{const{clientId:r,redirectUrl:n}=t;I(this,$,{clientId:r,redirectUrl:n})}}async authorize(t){var c,v;const r=(t==null?void 0:t.clientId)||((c=w(this,$))==null?void 0:c.clientId),n=(t==null?void 0:t.redirectUrl)||((v=w(this,$))==null?void 0:v.redirectUrl);if(!r)throw new Error("Missing ClientId");if(!n)throw new Error("Missing RedirectUrl");const u=te(w(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});window.location.replace(u)}async getAccess(t){var C,p,y;const r=(t==null?void 0:t.clientId)||((C=w(this,$))==null?void 0:C.clientId);if((t==null?void 0:t.clientSecret)||((p=w(this,$))==null?void 0:p.clientSecret)){if(!T)throw new Error("Only use client credentials on server side");return await w(this,G).call(this,w(this,$)),!!this.bearerProfile}const u=(t==null?void 0:t.redirectUrl)||((y=w(this,$))==null?void 0:y.redirectUrl);if(!r)throw new Error("Missing ClientId");if(T)throw new Error("This only works client side");const c=new URLSearchParams(window.location.search).get("code")||void 0,v=sessionStorage.getItem(W)||void 0;return v?await w(this,J).call(this,r,v):c&&await w(this,V).call(this,r,u,c),!!this.bearerProfile}getAuthContext(){return B(this,E,R).call(this,"get","auth/context")}getProfile(t){return B(this,E,R).call(this,"get",`profiles/${t}`)}getBalances(t){return t?B(this,E,R).call(this,"get",`profiles/${t}/balances`):B(this,E,R).call(this,"get","balances")}getOrders(t){const r=Q(t);return B(this,E,R).call(this,"get",`orders?${r}`)}getOrder(t){return B(this,E,R).call(this,"get",`orders/${t}`)}getTokens(){return B(this,E,R).call(this,"get","tokens")}linkAddress(t,r){return B(this,E,R).call(this,"post",`profiles/${t}/addresses`,JSON.stringify(r))}placeOrder(t,r){const n={...t,kind:"redeem",currency:"eur"};return r?B(this,E,R).call(this,"post",`profiles/${r}/orders`,JSON.stringify(n)):B(this,E,R).call(this,"post","orders",JSON.stringify(n))}uploadSupportingDocument(t){const r=Q(t);return B(this,E,R).call(this,"post","files/supporting-document",r,!0)}async connectOrderSocket(){var t;(t=this.bearerProfile)!=null&&t.access_token&&w(this,z).size>0&&I(this,L,this.subscribeToOrderNotifications())}async disconnect(){var t;T||sessionStorage.removeItem(M),w(this,z).clear(),(t=w(this,L))==null||t.close()}async revokeAccess(){T||sessionStorage.removeItem(W),this.disconnect()}subscribeOrders(t,r){w(this,z).set(t,r)}unsubscribeOrders(t){var r;w(this,z).delete(t),w(this,z).size===0&&((r=w(this,L))==null||r.close(),I(this,L,void 0))}}P=new WeakMap,D=new WeakMap,L=new WeakMap,z=new WeakMap,$=new WeakMap,H=new WeakSet,q=async function(t){let r;if(re(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 B(this,E,R).call(this,"post","auth/token",r,!0).then(n=>{var u;this.bearerProfile=n,this.isAuthorized=!!n,I(this,D,`Bearer ${n==null?void 0:n.access_token}`),T||window.sessionStorage.setItem(W,((u=this.bearerProfile)==null?void 0:u.refresh_token)||"")}).catch(n=>{throw T||(sessionStorage.removeItem(M),sessionStorage.removeItem(W)),new Error(n==null?void 0:n.message)}),re(t)&&Le(),this.bearerProfile},E=new WeakSet,R=async function(t,r,n,u){return Ne(`${w(this,P).api}/${r}`,t,u?Q(n):n,{Authorization:w(this,D)||"","Content-Type":`application/${u?"x-www-form-urlencoded":"json"}`})},V=new WeakMap,G=new WeakMap,J=new WeakMap;exports.AccountState=ce;exports.Currency=ne;exports.KYCOutcome=ae;exports.KYCState=ie;exports.MoneriumClient=Fe;exports.OrderKind=de;exports.OrderState=he;exports.PaymentStandard=ue;exports.Permission=oe;exports.ProfileType=se;exports.constants=xe;exports.getChain=le;exports.getNetwork=pe;exports.placeOrderMessage=Be;exports.rfc3339=fe;
1
+ "use strict";var Z=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var w=(e,t,r)=>(Z(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)},I=(e,t,r,n)=>(Z(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);var B=(e,t,r)=>(Z(e,t,"access private method"),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var se=(e=>(e.eur="eur",e))(se||{}),oe=(e=>(e.corporate="corporate",e.personal="personal",e))(oe||{}),ie=(e=>(e.read="read",e.write="write",e))(ie||{}),ae=(e=>(e.absent="absent",e.submitted="submitted",e.pending="pending",e.confirmed="confirmed",e))(ae||{}),ce=(e=>(e.approved="approved",e.rejected="rejected",e.unknown="unknown",e))(ce||{}),ue=(e=>(e.requested="requested",e.approved="approved",e.pending="pending",e))(ue||{}),de=(e=>(e.iban="iban",e.scan="scan",e))(de||{}),he=(e=>(e.redeem="redeem",e.issue="issue",e))(he||{}),fe=(e=>(e.placed="placed",e.pending="pending",e.processed="processed",e.rejected="rejected",e))(fe||{});const le=e=>{if(e.toString()==="Invalid Date")throw e;const t=n=>n<10?"0"+n:n,r=n=>{if(n===0)return"Z";const u=n>0?"-":"+";return n=Math.abs(n),u+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())},ke=(e,t)=>`Send EUR ${e} to ${t} at ${le(new Date)}`,Q=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("&"):""},pe=e=>{switch(e){case 1:case 5:return"ethereum";case 100:case 10200:return"gnosis";case 137:case 80001:return"polygon";default:throw new Error(`Chain not supported: ${e}`)}},ve=e=>{switch(e){case 1:case 100:case 137:return"mainnet";case 5:return"goerli";case 10200:return"chiado";case 80001:return"mumbai";default:throw new Error(`Network not supported: ${e}`)}},K={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"}}},xe="I hereby declare that I am the address owner.",M="monerium.sdk.code_verifier",W="monerium.sdk.refresh_token",Ae={LINK_MESSAGE:xe,STORAGE_CODE_VERIFIER:M,STORAGE_REFRESH_TOKEN:W};var N=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ge(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Ee(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 u=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,u.get?u:{enumerable:!0,get:function(){return e[n]}})}),r}var we={exports:{}};function Ie(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 X={exports:{}};const Re={},Oe=Object.freeze(Object.defineProperty({__proto__:null,default:Re},Symbol.toStringTag,{value:"Module"})),Pe=Ee(Oe);var ee;function ye(){return ee||(ee=1,function(e,t){(function(r,n){e.exports=n()})(N,function(){var r=r||function(n,u){var c;if(typeof window<"u"&&window.crypto&&(c=window.crypto),typeof self<"u"&&self.crypto&&(c=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(c=globalThis.crypto),!c&&typeof window<"u"&&window.msCrypto&&(c=window.msCrypto),!c&&typeof N<"u"&&N.crypto&&(c=N.crypto),!c&&typeof Ie=="function")try{c=Pe}catch{}var v=function(){if(c){if(typeof c.getRandomValues=="function")try{return c.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof c.randomBytes=="function")try{return c.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},C=Object.create||function(){function s(){}return function(o){var a;return s.prototype=o,a=new s,s.prototype=null,a}}(),p={},y=p.lib={},m=y.Base=function(){return{extend:function(s){var o=C(this);return s&&o.mixIn(s),(!o.hasOwnProperty("init")||this.init===o.init)&&(o.init=function(){o.$super.init.apply(this,arguments)}),o.init.prototype=o,o.$super=this,o},create:function(){var s=this.extend();return s.init.apply(s,arguments),s},init:function(){},mixIn:function(s){for(var o in s)s.hasOwnProperty(o)&&(this[o]=s[o]);s.hasOwnProperty("toString")&&(this.toString=s.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),g=y.WordArray=m.extend({init:function(s,o){s=this.words=s||[],o!=u?this.sigBytes=o:this.sigBytes=s.length*4},toString:function(s){return(s||h).stringify(this)},concat:function(s){var o=this.words,a=s.words,d=this.sigBytes,_=s.sigBytes;if(this.clamp(),d%4)for(var S=0;S<_;S++){var k=a[S>>>2]>>>24-S%4*8&255;o[d+S>>>2]|=k<<24-(d+S)%4*8}else for(var x=0;x<_;x+=4)o[d+x>>>2]=a[x>>>2];return this.sigBytes+=_,this},clamp:function(){var s=this.words,o=this.sigBytes;s[o>>>2]&=4294967295<<32-o%4*8,s.length=n.ceil(o/4)},clone:function(){var s=m.clone.call(this);return s.words=this.words.slice(0),s},random:function(s){for(var o=[],a=0;a<s;a+=4)o.push(v());return new g.init(o,s)}}),b=p.enc={},h=b.Hex={stringify:function(s){for(var o=s.words,a=s.sigBytes,d=[],_=0;_<a;_++){var S=o[_>>>2]>>>24-_%4*8&255;d.push((S>>>4).toString(16)),d.push((S&15).toString(16))}return d.join("")},parse:function(s){for(var o=s.length,a=[],d=0;d<o;d+=2)a[d>>>3]|=parseInt(s.substr(d,2),16)<<24-d%8*4;return new g.init(a,o/2)}},l=b.Latin1={stringify:function(s){for(var o=s.words,a=s.sigBytes,d=[],_=0;_<a;_++){var S=o[_>>>2]>>>24-_%4*8&255;d.push(String.fromCharCode(S))}return d.join("")},parse:function(s){for(var o=s.length,a=[],d=0;d<o;d++)a[d>>>2]|=(s.charCodeAt(d)&255)<<24-d%4*8;return new g.init(a,o)}},i=b.Utf8={stringify:function(s){try{return decodeURIComponent(escape(l.stringify(s)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(s){return l.parse(unescape(encodeURIComponent(s)))}},f=y.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new g.init,this._nDataBytes=0},_append:function(s){typeof s=="string"&&(s=i.parse(s)),this._data.concat(s),this._nDataBytes+=s.sigBytes},_process:function(s){var o,a=this._data,d=a.words,_=a.sigBytes,S=this.blockSize,k=S*4,x=_/k;s?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 F=0;F<j;F+=S)this._doProcessBlock(d,F);o=d.splice(0,j),a.sigBytes-=U}return new g.init(o,U)},clone:function(){var s=m.clone.call(this);return s._data=this._data.clone(),s},_minBufferSize:0});y.Hasher=f.extend({cfg:m.extend(),init:function(s){this.cfg=this.cfg.extend(s),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(s){return this._append(s),this._process(),this},finalize:function(s){s&&this._append(s);var o=this._doFinalize();return o},blockSize:16,_createHelper:function(s){return function(o,a){return new s.init(a).finalize(o)}},_createHmacHelper:function(s){return function(o,a){return new A.HMAC.init(s,a).finalize(o)}}});var A=p.algo={};return p}(Math);return r})}(X)),X.exports}(function(e,t){(function(r,n){e.exports=n(ye())})(N,function(r){return function(){var n=r,u=n.lib,c=u.WordArray,v=n.enc;v.Base64url={stringify:function(p,y){y===void 0&&(y=!0);var m=p.words,g=p.sigBytes,b=y?this._safe_map:this._map;p.clamp();for(var h=[],l=0;l<g;l+=3)for(var i=m[l>>>2]>>>24-l%4*8&255,f=m[l+1>>>2]>>>24-(l+1)%4*8&255,A=m[l+2>>>2]>>>24-(l+2)%4*8&255,s=i<<16|f<<8|A,o=0;o<4&&l+o*.75<g;o++)h.push(b.charAt(s>>>6*(3-o)&63));var a=b.charAt(64);if(a)for(;h.length%4;)h.push(a);return h.join("")},parse:function(p,y){y===void 0&&(y=!0);var m=p.length,g=y?this._safe_map:this._map,b=this._reverseMap;if(!b){b=this._reverseMap=[];for(var h=0;h<g.length;h++)b[g.charCodeAt(h)]=h}var l=g.charAt(64);if(l){var i=p.indexOf(l);i!==-1&&(m=i)}return C(p,m,b)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"};function C(p,y,m){for(var g=[],b=0,h=0;h<y;h++)if(h%4){var l=m[p.charCodeAt(h-1)]<<h%4*2,i=m[p.charCodeAt(h)]>>>6-h%4*2,f=l|i;g[b>>>2]|=f<<24-b%4*8,b++}return c.create(g,b)}}(),r.enc.Base64url})})(we);var $e=we.exports;const ze=ge($e);var me={exports:{}};(function(e,t){(function(r,n){e.exports=n(ye())})(N,function(r){return function(n){var u=r,c=u.lib,v=c.WordArray,C=c.Hasher,p=u.algo,y=[],m=[];(function(){function h(A){for(var s=n.sqrt(A),o=2;o<=s;o++)if(!(A%o))return!1;return!0}function l(A){return(A-(A|0))*4294967296|0}for(var i=2,f=0;f<64;)h(i)&&(f<8&&(y[f]=l(n.pow(i,1/2))),m[f]=l(n.pow(i,1/3)),f++),i++})();var g=[],b=p.SHA256=C.extend({_doReset:function(){this._hash=new v.init(y.slice(0))},_doProcessBlock:function(h,l){for(var i=this._hash.words,f=i[0],A=i[1],s=i[2],o=i[3],a=i[4],d=i[5],_=i[6],S=i[7],k=0;k<64;k++){if(k<16)g[k]=h[l+k]|0;else{var x=g[k-15],j=(x<<25|x>>>7)^(x<<14|x>>>18)^x>>>3,U=g[k-2],F=(U<<15|U>>>17)^(U<<13|U>>>19)^U>>>10;g[k]=j+g[k-7]+F+g[k-16]}var _e=a&d^~a&_,be=f&A^f&s^A&s,Se=(f<<30|f>>>2)^(f<<19|f>>>13)^(f<<10|f>>>22),Ce=(a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25),Y=S+Ce+_e+m[k]+g[k],Be=Se+be;S=_,_=d,d=a,a=o+Y|0,o=s,s=A,A=f,f=Y+Be|0}i[0]=i[0]+f|0,i[1]=i[1]+A|0,i[2]=i[2]+s|0,i[3]=i[3]+o|0,i[4]=i[4]+a|0,i[5]=i[5]+d|0,i[6]=i[6]+_|0,i[7]=i[7]+S|0},_doFinalize:function(){var h=this._data,l=h.words,i=this._nDataBytes*8,f=h.sigBytes*8;return l[f>>>5]|=128<<24-f%32,l[(f+64>>>9<<4)+14]=n.floor(i/4294967296),l[(f+64>>>9<<4)+15]=i,h.sigBytes=l.length*4,this._process(),this._hash},clone:function(){var h=C.clone.call(this);return h._hash=this._hash.clone(),h}});u.SHA256=C._createHelper(b),u.HmacSHA256=C._createHmacHelper(b)}(Math),r.SHA256})})(me);var Ue=me.exports;const He=ge(Ue),Te=(e,t)=>{const{client_id:r,redirect_uri:n,scope:u,state:c,chainId:v,chain:C,network:p,address:y,signature:m}=e,g=y?{address:y,...m!==void 0?{signature:m}:{},...v!==void 0||C!==void 0?{chain:v?pe(v):C}:{},...v!==void 0||p!==void 0?{network:v?ve(v):p}:{}}:{};return Q({client_id:r,redirect_uri:n,...u!==void 0?{scope:u}:{},...c!==void 0?{state:c}:{},code_challenge:t,code_challenge_method:"S256",response_type:"code",...g})},Me=()=>{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},Le=e=>ze.stringify(He(e)),te=(e,t)=>{const r=Me(),n=Le(r);return sessionStorage.setItem(M,r||""),`${e}/auth?${Te(t,n)}`},re=()=>{const e=window.location.href;if(!e||!(e!=null&&e.includes("?")))return;const[t,r]=e.split("?");r&&window.history.replaceState(null,"",t)},ne=e=>e.code!=null,je=e=>e.refresh_token!=null,qe=e=>e.client_secret!=null,Ne=async(e,t,r,n)=>{const u=await fetch(`${e}`,{method:t,headers:n,body:r});let c;const v=await u.text();try{c=JSON.parse(v)}catch{throw v}if(!u.ok)throw c;return c},T=typeof window>"u";var P,D,L,z,$,H,q,E,R,V,G,J;class Fe{constructor(t){O(this,H);O(this,E);O(this,P,void 0);O(this,D,void 0);O(this,L,void 0);O(this,z,void 0);O(this,$,void 0);O(this,V,void 0);O(this,G,void 0);O(this,J,void 0);if(I(this,z,new Map),this.isAuthorized=!!this.bearerProfile,I(this,V,async(r,n,u)=>{const c=sessionStorage.getItem(M)||"";if(!c)throw new Error("Code verifier not found");return this.codeVerifier=c,sessionStorage.removeItem(M),await B(this,H,q).call(this,{code:u,redirect_uri:n,client_id:r,code_verifier:c})}),I(this,G,async({clientId:r,clientSecret:n})=>await B(this,H,q).call(this,{client_id:r,client_secret:n})),I(this,J,async(r,n)=>await B(this,H,q).call(this,{refresh_token:n,client_id:r})),this.subscribeToOrderNotifications=()=>{var u,c;const r=`${w(this,P).wss}/profiles/${(u=this.bearerProfile)==null?void 0:u.profile}/orders?access_token=${(c=this.bearerProfile)==null?void 0:c.access_token}`,n=new WebSocket(r);return n.addEventListener("open",()=>{console.info(`Socket connected: ${r}`)}),n.addEventListener("error",v=>{throw console.error(v),new Error(`Socket error: ${r}`)}),n.addEventListener("message",v=>{var p;const C=JSON.parse(v.data);(p=w(this,z).get(C.meta.state))==null||p(C)}),n.addEventListener("close",()=>{console.info(`Socket connection closed: ${r}`)}),n},this.auth=async r=>await B(this,H,q).call(this,r),this.connect=async r=>await B(this,H,q).call(this,r),this.getAuthFlowURI=r=>{const n=te(w(this,P).api,r);return this.codeVerifier=sessionStorage.getItem(M),n},this.pkceRequest=r=>this.getAuthFlowURI(r),this.getEnvironment=()=>w(this,P),!t){I(this,P,K.environments.sandbox);return}if(typeof t=="string")I(this,P,K.environments[t]);else if(I(this,P,K.environments[t.environment||"sandbox"]),T){const{clientId:r,clientSecret:n}=t;I(this,$,{clientId:r,clientSecret:n})}else{const{clientId:r,redirectUrl:n}=t;I(this,$,{clientId:r,redirectUrl:n})}}async authorize(t){var c,v;const r=(t==null?void 0:t.clientId)||((c=w(this,$))==null?void 0:c.clientId),n=(t==null?void 0:t.redirectUrl)||((v=w(this,$))==null?void 0:v.redirectUrl);if(!r)throw new Error("Missing ClientId");if(!n)throw new Error("Missing RedirectUrl");const u=te(w(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});window.location.replace(u)}async getAccess(t){var C,p,y;const r=(t==null?void 0:t.clientId)||((C=w(this,$))==null?void 0:C.clientId);if((t==null?void 0:t.clientSecret)||((p=w(this,$))==null?void 0:p.clientSecret)){if(!T)throw new Error("Only use client credentials on server side");return await w(this,G).call(this,w(this,$)),!!this.bearerProfile}const u=(t==null?void 0:t.redirectUrl)||((y=w(this,$))==null?void 0:y.redirectUrl);if(!r)throw new Error("Missing ClientId");if(T)throw new Error("This only works client side");const c=new URLSearchParams(window.location.search).get("code")||void 0,v=sessionStorage.getItem(W)||void 0;return v?await w(this,J).call(this,r,v):c&&await w(this,V).call(this,r,u,c),!!this.bearerProfile}getAuthContext(){return B(this,E,R).call(this,"get","auth/context")}getProfile(t){return B(this,E,R).call(this,"get",`profiles/${t}`)}getBalances(t){return t?B(this,E,R).call(this,"get",`profiles/${t}/balances`):B(this,E,R).call(this,"get","balances")}getOrders(t){const r=Q(t);return B(this,E,R).call(this,"get",`orders?${r}`)}getOrder(t){return B(this,E,R).call(this,"get",`orders/${t}`)}getTokens(){return B(this,E,R).call(this,"get","tokens")}linkAddress(t,r){return B(this,E,R).call(this,"post",`profiles/${t}/addresses`,JSON.stringify(r))}placeOrder(t,r){const n={...t,kind:"redeem",currency:"eur"};return r?B(this,E,R).call(this,"post",`profiles/${r}/orders`,JSON.stringify(n)):B(this,E,R).call(this,"post","orders",JSON.stringify(n))}uploadSupportingDocument(t){const r=Q(t);return B(this,E,R).call(this,"post","files/supporting-document",r,!0)}async connectOrderSocket(){var t;(t=this.bearerProfile)!=null&&t.access_token&&w(this,z).size>0&&I(this,L,this.subscribeToOrderNotifications())}async disconnect(){var t;T||sessionStorage.removeItem(M),w(this,z).clear(),(t=w(this,L))==null||t.close()}async revokeAccess(){T||sessionStorage.removeItem(W),this.disconnect()}subscribeOrders(t,r){w(this,z).set(t,r)}unsubscribeOrders(t){var r;w(this,z).delete(t),w(this,z).size===0&&((r=w(this,L))==null||r.close(),I(this,L,void 0))}}P=new WeakMap,D=new WeakMap,L=new WeakMap,z=new WeakMap,$=new WeakMap,H=new WeakSet,q=async function(t){let r;if(ne(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 B(this,E,R).call(this,"post","auth/token",r,!0).then(n=>{var u;this.bearerProfile=n,this.isAuthorized=!!n,I(this,D,`Bearer ${n==null?void 0:n.access_token}`),T||window.sessionStorage.setItem(W,((u=this.bearerProfile)==null?void 0:u.refresh_token)||"")}).catch(n=>{throw T||(sessionStorage.removeItem(M),sessionStorage.removeItem(W),re()),new Error(n==null?void 0:n.message)}),ne(t)&&re(),this.bearerProfile},E=new WeakSet,R=async function(t,r,n,u){return Ne(`${w(this,P).api}/${r}`,t,u?Q(n):n,{Authorization:w(this,D)||"","Content-Type":`application/${u?"x-www-form-urlencoded":"json"}`})},V=new WeakMap,G=new WeakMap,J=new WeakMap;exports.AccountState=ue;exports.Currency=se;exports.KYCOutcome=ce;exports.KYCState=ae;exports.MoneriumClient=Fe;exports.OrderKind=he;exports.OrderState=fe;exports.PaymentStandard=de;exports.Permission=ie;exports.ProfileType=oe;exports.constants=Ae;exports.getChain=pe;exports.getNetwork=ve;exports.placeOrderMessage=ke;exports.rfc3339=le;
package/dist/index.mjs CHANGED
@@ -1,30 +1,30 @@
1
- var Z = (e, r, t) => {
2
- if (!r.has(e))
3
- throw TypeError("Cannot " + t);
1
+ var Z = (e, t, r) => {
2
+ if (!t.has(e))
3
+ throw TypeError("Cannot " + r);
4
4
  };
5
- var w = (e, r, t) => (Z(e, r, "read from private field"), t ? t.call(e) : r.get(e)), $ = (e, r, t) => {
6
- if (r.has(e))
5
+ var w = (e, t, r) => (Z(e, t, "read from private field"), r ? r.call(e) : t.get(e)), $ = (e, t, r) => {
6
+ if (t.has(e))
7
7
  throw TypeError("Cannot add the same private member more than once");
8
- r instanceof WeakSet ? r.add(e) : r.set(e, t);
9
- }, I = (e, r, t, n) => (Z(e, r, "write to private field"), n ? n.call(e, t) : r.set(e, t), t);
10
- var k = (e, r, t) => (Z(e, r, "access private method"), t);
11
- var fe = /* @__PURE__ */ ((e) => (e.eur = "eur", e))(fe || {}), le = /* @__PURE__ */ ((e) => (e.corporate = "corporate", e.personal = "personal", e))(le || {}), pe = /* @__PURE__ */ ((e) => (e.read = "read", e.write = "write", e))(pe || {}), ve = /* @__PURE__ */ ((e) => (e.absent = "absent", e.submitted = "submitted", e.pending = "pending", e.confirmed = "confirmed", e))(ve || {}), ge = /* @__PURE__ */ ((e) => (e.approved = "approved", e.rejected = "rejected", e.unknown = "unknown", e))(ge || {}), we = /* @__PURE__ */ ((e) => (e.requested = "requested", e.approved = "approved", e.pending = "pending", e))(we || {}), ye = /* @__PURE__ */ ((e) => (e.iban = "iban", e.scan = "scan", e))(ye || {}), me = /* @__PURE__ */ ((e) => (e.redeem = "redeem", e.issue = "issue", e))(me || {}), _e = /* @__PURE__ */ ((e) => (e.placed = "placed", e.pending = "pending", e.processed = "processed", e.rejected = "rejected", e))(_e || {});
12
- const be = (e) => {
8
+ t instanceof WeakSet ? t.add(e) : t.set(e, r);
9
+ }, I = (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 le = /* @__PURE__ */ ((e) => (e.eur = "eur", e))(le || {}), pe = /* @__PURE__ */ ((e) => (e.corporate = "corporate", e.personal = "personal", e))(pe || {}), ve = /* @__PURE__ */ ((e) => (e.read = "read", e.write = "write", e))(ve || {}), ge = /* @__PURE__ */ ((e) => (e.absent = "absent", e.submitted = "submitted", e.pending = "pending", e.confirmed = "confirmed", e))(ge || {}), we = /* @__PURE__ */ ((e) => (e.approved = "approved", e.rejected = "rejected", e.unknown = "unknown", e))(we || {}), ye = /* @__PURE__ */ ((e) => (e.requested = "requested", e.approved = "approved", e.pending = "pending", e))(ye || {}), me = /* @__PURE__ */ ((e) => (e.iban = "iban", e.scan = "scan", e))(me || {}), _e = /* @__PURE__ */ ((e) => (e.redeem = "redeem", e.issue = "issue", e))(_e || {}), be = /* @__PURE__ */ ((e) => (e.placed = "placed", e.pending = "pending", e.processed = "processed", e.rejected = "rejected", e))(be || {});
12
+ const Se = (e) => {
13
13
  if (e.toString() === "Invalid Date")
14
14
  throw e;
15
- const r = (n) => n < 10 ? "0" + n : n, t = (n) => {
15
+ const t = (n) => n < 10 ? "0" + n : n, r = (n) => {
16
16
  if (n === 0)
17
17
  return "Z";
18
18
  const u = n > 0 ? "-" : "+";
19
- return n = Math.abs(n), u + r(Math.floor(n / 60)) + ":" + r(n % 60);
19
+ return n = Math.abs(n), u + t(Math.floor(n / 60)) + ":" + t(n % 60);
20
20
  };
21
- return e.getFullYear() + "-" + r(e.getMonth() + 1) + "-" + r(e.getDate()) + "T" + r(e.getHours()) + ":" + r(e.getMinutes()) + ":" + r(e.getSeconds()) + t(e.getTimezoneOffset());
22
- }, Fe = (e, r) => `Send EUR ${e} to ${r} at ${be(/* @__PURE__ */ new Date())}`, Q = (e) => {
23
- var r;
24
- return e && ((r = Object.entries(e)) == null ? void 0 : r.length) > 0 ? Object.entries(e).map(
25
- ([t, n]) => `${encodeURIComponent(t)}=${encodeURIComponent(n)}`
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) => `Send EUR ${e} to ${t} at ${Se(/* @__PURE__ */ new Date())}`, Q = (e) => {
23
+ var t;
24
+ return e && ((t = Object.entries(e)) == null ? void 0 : t.length) > 0 ? Object.entries(e).map(
25
+ ([r, n]) => `${encodeURIComponent(r)}=${encodeURIComponent(n)}`
26
26
  ).join("&") : "";
27
- }, Se = (e) => {
27
+ }, Be = (e) => {
28
28
  switch (e) {
29
29
  case 1:
30
30
  case 5:
@@ -38,7 +38,7 @@ const be = (e) => {
38
38
  default:
39
39
  throw new Error(`Chain not supported: ${e}`);
40
40
  }
41
- }, Be = (e) => {
41
+ }, ke = (e) => {
42
42
  switch (e) {
43
43
  case 1:
44
44
  case 100:
@@ -66,56 +66,56 @@ const be = (e) => {
66
66
  wss: "wss://api.monerium.dev"
67
67
  }
68
68
  }
69
- }, ke = "I hereby declare that I am the address owner.", M = "monerium.sdk.code_verifier", W = "monerium.sdk.refresh_token", Ne = {
70
- LINK_MESSAGE: ke,
69
+ }, Ce = "I hereby declare that I am the address owner.", M = "monerium.sdk.code_verifier", W = "monerium.sdk.refresh_token", Ne = {
70
+ LINK_MESSAGE: Ce,
71
71
  STORAGE_CODE_VERIFIER: M,
72
72
  STORAGE_REFRESH_TOKEN: W
73
73
  };
74
74
  var F = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
75
- function ne(e) {
75
+ function se(e) {
76
76
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
77
77
  }
78
- function Ce(e) {
78
+ function xe(e) {
79
79
  if (e.__esModule)
80
80
  return e;
81
- var r = e.default;
82
- if (typeof r == "function") {
83
- var t = function n() {
84
- return this instanceof n ? Reflect.construct(r, arguments, this.constructor) : r.apply(this, arguments);
81
+ var t = e.default;
82
+ if (typeof t == "function") {
83
+ var r = function n() {
84
+ return this instanceof n ? Reflect.construct(t, arguments, this.constructor) : t.apply(this, arguments);
85
85
  };
86
- t.prototype = r.prototype;
86
+ r.prototype = t.prototype;
87
87
  } else
88
- t = {};
89
- return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(e).forEach(function(n) {
88
+ r = {};
89
+ return Object.defineProperty(r, "__esModule", { value: !0 }), Object.keys(e).forEach(function(n) {
90
90
  var u = Object.getOwnPropertyDescriptor(e, n);
91
- Object.defineProperty(t, n, u.get ? u : {
91
+ Object.defineProperty(r, n, u.get ? u : {
92
92
  enumerable: !0,
93
93
  get: function() {
94
94
  return e[n];
95
95
  }
96
96
  });
97
- }), t;
97
+ }), r;
98
98
  }
99
- var se = { exports: {} };
100
- function xe(e) {
99
+ var oe = { exports: {} };
100
+ function Ae(e) {
101
101
  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.');
102
102
  }
103
103
  var K = { exports: {} };
104
- const Ae = {}, Ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
104
+ const Ee = {}, Ie = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
105
105
  __proto__: null,
106
- default: Ae
107
- }, Symbol.toStringTag, { value: "Module" })), Ie = /* @__PURE__ */ Ce(Ee);
106
+ default: Ee
107
+ }, Symbol.toStringTag, { value: "Module" })), Re = /* @__PURE__ */ xe(Ie);
108
108
  var ee;
109
- function oe() {
110
- return ee || (ee = 1, function(e, r) {
111
- (function(t, n) {
109
+ function ie() {
110
+ return ee || (ee = 1, function(e, t) {
111
+ (function(r, n) {
112
112
  e.exports = n();
113
113
  })(F, function() {
114
- var t = t || function(n, u) {
114
+ var r = r || function(n, u) {
115
115
  var c;
116
- if (typeof window < "u" && window.crypto && (c = window.crypto), typeof self < "u" && self.crypto && (c = self.crypto), typeof globalThis < "u" && globalThis.crypto && (c = globalThis.crypto), !c && typeof window < "u" && window.msCrypto && (c = window.msCrypto), !c && typeof F < "u" && F.crypto && (c = F.crypto), !c && typeof xe == "function")
116
+ if (typeof window < "u" && window.crypto && (c = window.crypto), typeof self < "u" && self.crypto && (c = self.crypto), typeof globalThis < "u" && globalThis.crypto && (c = globalThis.crypto), !c && typeof window < "u" && window.msCrypto && (c = window.msCrypto), !c && typeof F < "u" && F.crypto && (c = F.crypto), !c && typeof Ae == "function")
117
117
  try {
118
- c = Ie;
118
+ c = Re;
119
119
  } catch {
120
120
  }
121
121
  var v = function() {
@@ -602,16 +602,16 @@ function oe() {
602
602
  var A = p.algo = {};
603
603
  return p;
604
604
  }(Math);
605
- return t;
605
+ return r;
606
606
  });
607
607
  }(K)), K.exports;
608
608
  }
609
- (function(e, r) {
610
- (function(t, n) {
611
- e.exports = n(oe());
612
- })(F, function(t) {
609
+ (function(e, t) {
610
+ (function(r, n) {
611
+ e.exports = n(ie());
612
+ })(F, function(r) {
613
613
  return function() {
614
- var n = t, u = n.lib, c = u.WordArray, v = n.enc;
614
+ var n = r, u = n.lib, c = u.WordArray, v = n.enc;
615
615
  v.Base64url = {
616
616
  /**
617
617
  * Converts a word array to a Base64url string.
@@ -682,18 +682,18 @@ function oe() {
682
682
  }
683
683
  return c.create(g, b);
684
684
  }
685
- }(), t.enc.Base64url;
685
+ }(), r.enc.Base64url;
686
686
  });
687
- })(se);
688
- var Re = se.exports;
689
- const $e = /* @__PURE__ */ ne(Re);
690
- var ie = { exports: {} };
691
- (function(e, r) {
692
- (function(t, n) {
693
- e.exports = n(oe());
694
- })(F, function(t) {
687
+ })(oe);
688
+ var $e = oe.exports;
689
+ const ze = /* @__PURE__ */ se($e);
690
+ var ae = { exports: {} };
691
+ (function(e, t) {
692
+ (function(r, n) {
693
+ e.exports = n(ie());
694
+ })(F, function(r) {
695
695
  return function(n) {
696
- var u = t, c = u.lib, v = c.WordArray, B = c.Hasher, p = u.algo, y = [], m = [];
696
+ var u = r, c = u.lib, v = c.WordArray, B = c.Hasher, p = u.algo, y = [], m = [];
697
697
  (function() {
698
698
  function d(A) {
699
699
  for (var s = n.sqrt(A), o = 2; o <= s; o++)
@@ -719,8 +719,8 @@ var ie = { exports: {} };
719
719
  var x = g[C - 15], q = (x << 25 | x >>> 7) ^ (x << 14 | x >>> 18) ^ x >>> 3, P = g[C - 2], N = (P << 15 | P >>> 17) ^ (P << 13 | P >>> 19) ^ P >>> 10;
720
720
  g[C] = q + g[C - 7] + N + g[C - 16];
721
721
  }
722
- var ae = a & h ^ ~a & _, ce = f & A ^ f & s ^ A & s, ue = (f << 30 | f >>> 2) ^ (f << 19 | f >>> 13) ^ (f << 10 | f >>> 22), he = (a << 26 | a >>> 6) ^ (a << 21 | a >>> 11) ^ (a << 7 | a >>> 25), Y = S + he + ae + m[C] + g[C], de = ue + ce;
723
- S = _, _ = h, h = a, a = o + Y | 0, o = s, s = A, A = f, f = Y + de | 0;
722
+ var ce = a & h ^ ~a & _, ue = f & A ^ f & s ^ A & s, he = (f << 30 | f >>> 2) ^ (f << 19 | f >>> 13) ^ (f << 10 | f >>> 22), de = (a << 26 | a >>> 6) ^ (a << 21 | a >>> 11) ^ (a << 7 | a >>> 25), Y = S + de + ce + m[C] + g[C], fe = he + ue;
723
+ S = _, _ = h, h = a, a = o + Y | 0, o = s, s = A, A = f, f = Y + fe | 0;
724
724
  }
725
725
  i[0] = i[0] + f | 0, i[1] = i[1] + A | 0, i[2] = i[2] + s | 0, i[3] = i[3] + o | 0, i[4] = i[4] + a | 0, i[5] = i[5] + h | 0, i[6] = i[6] + _ | 0, i[7] = i[7] + S | 0;
726
726
  },
@@ -734,13 +734,13 @@ var ie = { exports: {} };
734
734
  }
735
735
  });
736
736
  u.SHA256 = B._createHelper(b), u.HmacSHA256 = B._createHmacHelper(b);
737
- }(Math), t.SHA256;
737
+ }(Math), r.SHA256;
738
738
  });
739
- })(ie);
740
- var ze = ie.exports;
741
- const Ue = /* @__PURE__ */ ne(ze), He = (e, r) => {
739
+ })(ae);
740
+ var Ue = ae.exports;
741
+ const He = /* @__PURE__ */ se(Ue), Pe = (e, t) => {
742
742
  const {
743
- client_id: t,
743
+ client_id: r,
744
744
  redirect_uri: n,
745
745
  scope: u,
746
746
  state: c,
@@ -752,37 +752,40 @@ const Ue = /* @__PURE__ */ ne(ze), He = (e, r) => {
752
752
  } = e, g = y ? {
753
753
  address: y,
754
754
  ...m !== void 0 ? { signature: m } : {},
755
- ...v !== void 0 || B !== void 0 ? { chain: v ? Se(v) : B } : {},
756
- ...v !== void 0 || p !== void 0 ? { network: v ? Be(v) : p } : {}
755
+ ...v !== void 0 || B !== void 0 ? { chain: v ? Be(v) : B } : {},
756
+ ...v !== void 0 || p !== void 0 ? { network: v ? ke(v) : p } : {}
757
757
  } : {};
758
758
  return Q({
759
- client_id: t,
759
+ client_id: r,
760
760
  redirect_uri: n,
761
761
  ...u !== void 0 ? { scope: u } : {},
762
762
  ...c !== void 0 ? { state: c } : {},
763
- code_challenge: r,
763
+ code_challenge: t,
764
764
  code_challenge_method: "S256",
765
765
  response_type: "code",
766
766
  ...g
767
767
  });
768
- }, Pe = () => {
768
+ }, Oe = () => {
769
769
  let e = "";
770
- const r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", t = r.length;
770
+ const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", r = t.length;
771
771
  let n = 0;
772
772
  for (; n < 128; )
773
- e += r.charAt(Math.floor(Math.random() * t)), n += 1;
773
+ e += t.charAt(Math.floor(Math.random() * r)), n += 1;
774
774
  return e;
775
- }, Oe = (e) => $e.stringify(Ue(e)), re = (e, r) => {
776
- const t = Pe(), n = Oe(t);
777
- return sessionStorage.setItem(M, t || ""), `${e}/auth?${He(r, n)}`;
778
- }, Te = () => {
779
- const e = window.location.href, [r, t] = e.split("?");
780
- t && window.history.replaceState(null, "", r);
781
- }, te = (e) => e.code != null, Me = (e) => e.refresh_token != null, Le = (e) => e.client_secret != null, qe = async (e, r, t, n) => {
775
+ }, Te = (e) => ze.stringify(He(e)), te = (e, t) => {
776
+ const r = Oe(), n = Te(r);
777
+ return sessionStorage.setItem(M, r || ""), `${e}/auth?${Pe(t, n)}`;
778
+ }, re = () => {
779
+ const e = window.location.href;
780
+ if (!e || !(e != null && e.includes("?")))
781
+ return;
782
+ const [t, r] = e.split("?");
783
+ r && window.history.replaceState(null, "", t);
784
+ }, ne = (e) => e.code != null, Me = (e) => e.refresh_token != null, Le = (e) => e.client_secret != null, qe = async (e, t, r, n) => {
782
785
  const u = await fetch(`${e}`, {
783
- method: r,
786
+ method: t,
784
787
  headers: n,
785
- body: t
788
+ body: r
786
789
  });
787
790
  let c;
788
791
  const v = await u.text();
@@ -797,7 +800,7 @@ const Ue = /* @__PURE__ */ ne(ze), He = (e, r) => {
797
800
  }, T = typeof window > "u";
798
801
  var z, D, L, H, U, O, j, E, R, V, G, J;
799
802
  class We {
800
- constructor(r) {
803
+ constructor(t) {
801
804
  /**
802
805
  * {@link https://monerium.dev/api-docs#operation/auth-token}
803
806
  */
@@ -813,32 +816,32 @@ class We {
813
816
  $(this, V, void 0);
814
817
  $(this, G, void 0);
815
818
  $(this, J, void 0);
816
- if (I(this, H, /* @__PURE__ */ new Map()), this.isAuthorized = !!this.bearerProfile, I(this, V, async (t, n, u) => {
819
+ if (I(this, H, /* @__PURE__ */ new Map()), this.isAuthorized = !!this.bearerProfile, I(this, V, async (r, n, u) => {
817
820
  const c = sessionStorage.getItem(M) || "";
818
821
  if (!c)
819
822
  throw new Error("Code verifier not found");
820
823
  return this.codeVerifier = c, sessionStorage.removeItem(M), await k(this, O, j).call(this, {
821
824
  code: u,
822
825
  redirect_uri: n,
823
- client_id: t,
826
+ client_id: r,
824
827
  code_verifier: c
825
828
  });
826
829
  }), I(this, G, async ({
827
- clientId: t,
830
+ clientId: r,
828
831
  clientSecret: n
829
832
  }) => await k(this, O, j).call(this, {
830
- client_id: t,
833
+ client_id: r,
831
834
  client_secret: n
832
- })), I(this, J, async (t, n) => await k(this, O, j).call(this, {
835
+ })), I(this, J, async (r, n) => await k(this, O, j).call(this, {
833
836
  refresh_token: n,
834
- client_id: t
837
+ client_id: r
835
838
  })), this.subscribeToOrderNotifications = () => {
836
839
  var u, c;
837
- const t = `${w(this, z).wss}/profiles/${(u = this.bearerProfile) == null ? void 0 : u.profile}/orders?access_token=${(c = this.bearerProfile) == null ? void 0 : c.access_token}`, n = new WebSocket(t);
840
+ const r = `${w(this, z).wss}/profiles/${(u = this.bearerProfile) == null ? void 0 : u.profile}/orders?access_token=${(c = this.bearerProfile) == null ? void 0 : c.access_token}`, n = new WebSocket(r);
838
841
  return n.addEventListener("open", () => {
839
- console.info(`Socket connected: ${t}`);
842
+ console.info(`Socket connected: ${r}`);
840
843
  }), n.addEventListener("error", (v) => {
841
- throw console.error(v), new Error(`Socket error: ${t}`);
844
+ throw console.error(v), new Error(`Socket error: ${r}`);
842
845
  }), n.addEventListener("message", (v) => {
843
846
  var p;
844
847
  const B = JSON.parse(v.data);
@@ -846,27 +849,27 @@ class We {
846
849
  B
847
850
  );
848
851
  }), n.addEventListener("close", () => {
849
- console.info(`Socket connection closed: ${t}`);
852
+ console.info(`Socket connection closed: ${r}`);
850
853
  }), n;
851
- }, this.auth = async (t) => await k(this, O, j).call(this, t), this.connect = async (t) => await k(this, O, j).call(this, t), this.getAuthFlowURI = (t) => {
852
- const n = re(w(this, z).api, t);
854
+ }, 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) => {
855
+ const n = te(w(this, z).api, r);
853
856
  return this.codeVerifier = sessionStorage.getItem(M), n;
854
- }, this.pkceRequest = (t) => this.getAuthFlowURI(t), this.getEnvironment = () => w(this, z), !r) {
857
+ }, this.pkceRequest = (r) => this.getAuthFlowURI(r), this.getEnvironment = () => w(this, z), !t) {
855
858
  I(this, z, X.environments.sandbox);
856
859
  return;
857
860
  }
858
- if (typeof r == "string")
859
- I(this, z, X.environments[r]);
860
- else if (I(this, z, X.environments[r.environment || "sandbox"]), T) {
861
- const { clientId: t, clientSecret: n } = r;
861
+ if (typeof t == "string")
862
+ I(this, z, X.environments[t]);
863
+ else if (I(this, z, X.environments[t.environment || "sandbox"]), T) {
864
+ const { clientId: r, clientSecret: n } = t;
862
865
  I(this, U, {
863
- clientId: t,
866
+ clientId: r,
864
867
  clientSecret: n
865
868
  });
866
869
  } else {
867
- const { clientId: t, redirectUrl: n } = r;
870
+ const { clientId: r, redirectUrl: n } = t;
868
871
  I(this, U, {
869
- clientId: t,
872
+ clientId: r,
870
873
  redirectUrl: n
871
874
  });
872
875
  }
@@ -878,19 +881,19 @@ class We {
878
881
  * @returns string
879
882
  * {@link https://monerium.dev/api-docs#operation/auth}
880
883
  */
881
- async authorize(r) {
884
+ async authorize(t) {
882
885
  var c, v;
883
- const t = (r == null ? void 0 : r.clientId) || ((c = w(this, U)) == null ? void 0 : c.clientId), n = (r == null ? void 0 : r.redirectUrl) || ((v = w(this, U)) == null ? void 0 : v.redirectUrl);
884
- if (!t)
886
+ const r = (t == null ? void 0 : t.clientId) || ((c = w(this, U)) == null ? void 0 : c.clientId), n = (t == null ? void 0 : t.redirectUrl) || ((v = w(this, U)) == null ? void 0 : v.redirectUrl);
887
+ if (!r)
885
888
  throw new Error("Missing ClientId");
886
889
  if (!n)
887
890
  throw new Error("Missing RedirectUrl");
888
- const u = re(w(this, z).api, {
889
- client_id: t,
891
+ const u = te(w(this, z).api, {
892
+ client_id: r,
890
893
  redirect_uri: n,
891
- address: r == null ? void 0 : r.address,
892
- signature: r == null ? void 0 : r.signature,
893
- chainId: r == null ? void 0 : r.chainId
894
+ address: t == null ? void 0 : t.address,
895
+ signature: t == null ? void 0 : t.signature,
896
+ chainId: t == null ? void 0 : t.chainId
894
897
  });
895
898
  window.location.replace(u);
896
899
  }
@@ -899,21 +902,21 @@ class We {
899
902
  * @param {AuthorizationCodeCredentials | ClientCredentials} client - the client credentials
900
903
  * @returns boolean to indicate if access has been granted
901
904
  */
902
- async getAccess(r) {
905
+ async getAccess(t) {
903
906
  var B, p, y;
904
- const t = (r == null ? void 0 : r.clientId) || ((B = w(this, U)) == null ? void 0 : B.clientId);
905
- if ((r == null ? void 0 : r.clientSecret) || ((p = w(this, U)) == null ? void 0 : p.clientSecret)) {
907
+ const r = (t == null ? void 0 : t.clientId) || ((B = w(this, U)) == null ? void 0 : B.clientId);
908
+ if ((t == null ? void 0 : t.clientSecret) || ((p = w(this, U)) == null ? void 0 : p.clientSecret)) {
906
909
  if (!T)
907
910
  throw new Error("Only use client credentials on server side");
908
911
  return await w(this, G).call(this, w(this, U)), !!this.bearerProfile;
909
912
  }
910
- const u = (r == null ? void 0 : r.redirectUrl) || ((y = w(this, U)) == null ? void 0 : y.redirectUrl);
911
- if (!t)
913
+ const u = (t == null ? void 0 : t.redirectUrl) || ((y = w(this, U)) == null ? void 0 : y.redirectUrl);
914
+ if (!r)
912
915
  throw new Error("Missing ClientId");
913
916
  if (T)
914
917
  throw new Error("This only works client side");
915
918
  const c = new URLSearchParams(window.location.search).get("code") || void 0, v = sessionStorage.getItem(W) || void 0;
916
- return v ? await w(this, J).call(this, t, v) : c && await w(this, V).call(this, t, u, c), !!this.bearerProfile;
919
+ return v ? await w(this, J).call(this, r, v) : c && await w(this, V).call(this, r, u, c), !!this.bearerProfile;
917
920
  }
918
921
  // -- Read Methods
919
922
  /**
@@ -927,28 +930,28 @@ class We {
927
930
  * @param {string} profileId - the id of the profile to fetch.
928
931
 
929
932
  */
930
- getProfile(r) {
931
- return k(this, E, R).call(this, "get", `profiles/${r}`);
933
+ getProfile(t) {
934
+ return k(this, E, R).call(this, "get", `profiles/${t}`);
932
935
  }
933
936
  /**
934
937
  * {@link https://monerium.dev/api-docs#operation/profile-balances}
935
938
  * @param {string=} profileId - the id of the profile to fetch balances.
936
939
  */
937
- getBalances(r) {
938
- return r ? k(this, E, R).call(this, "get", `profiles/${r}/balances`) : k(this, E, R).call(this, "get", "balances");
940
+ getBalances(t) {
941
+ return t ? k(this, E, R).call(this, "get", `profiles/${t}/balances`) : k(this, E, R).call(this, "get", "balances");
939
942
  }
940
943
  /**
941
944
  * {@link https://monerium.dev/api-docs#operation/orders}
942
945
  */
943
- getOrders(r) {
944
- const t = Q(r);
945
- return k(this, E, R).call(this, "get", `orders?${t}`);
946
+ getOrders(t) {
947
+ const r = Q(t);
948
+ return k(this, E, R).call(this, "get", `orders?${r}`);
946
949
  }
947
950
  /**
948
951
  * {@link https://monerium.dev/api-docs#operation/order}
949
952
  */
950
- getOrder(r) {
951
- return k(this, E, R).call(this, "get", `orders/${r}`);
953
+ getOrder(t) {
954
+ return k(this, E, R).call(this, "get", `orders/${t}`);
952
955
  }
953
956
  /**
954
957
  * {@link https://monerium.dev/api-docs#operation/tokens}
@@ -960,36 +963,36 @@ class We {
960
963
  /**
961
964
  * {@link https://monerium.dev/api-docs#operation/profile-addresses}
962
965
  */
963
- linkAddress(r, t) {
964
- return k(this, E, R).call(this, "post", `profiles/${r}/addresses`, JSON.stringify(t));
966
+ linkAddress(t, r) {
967
+ return k(this, E, R).call(this, "post", `profiles/${t}/addresses`, JSON.stringify(r));
965
968
  }
966
969
  /**
967
970
  * {@link https://monerium.dev/api-docs#operation/post-orders}
968
971
  */
969
- placeOrder(r, t) {
970
- const n = { ...r, kind: "redeem", currency: "eur" };
971
- return t ? k(this, E, R).call(this, "post", `profiles/${t}/orders`, JSON.stringify(n)) : k(this, E, R).call(this, "post", "orders", JSON.stringify(n));
972
+ placeOrder(t, r) {
973
+ const n = { ...t, kind: "redeem", currency: "eur" };
974
+ return r ? k(this, E, R).call(this, "post", `profiles/${r}/orders`, JSON.stringify(n)) : k(this, E, R).call(this, "post", "orders", JSON.stringify(n));
972
975
  }
973
976
  /**
974
977
  * {@link https://monerium.dev/api-docs#operation/supporting-document}
975
978
  */
976
- uploadSupportingDocument(r) {
977
- const t = Q(
978
- r
979
+ uploadSupportingDocument(t) {
980
+ const r = Q(
981
+ t
979
982
  );
980
- return k(this, E, R).call(this, "post", "files/supporting-document", t, !0);
983
+ return k(this, E, R).call(this, "post", "files/supporting-document", r, !0);
981
984
  }
982
985
  // -- Notifications
983
986
  async connectOrderSocket() {
984
- var r;
985
- (r = this.bearerProfile) != null && r.access_token && w(this, H).size > 0 && I(this, L, this.subscribeToOrderNotifications());
987
+ var t;
988
+ (t = this.bearerProfile) != null && t.access_token && w(this, H).size > 0 && I(this, L, this.subscribeToOrderNotifications());
986
989
  }
987
990
  /**
988
991
  * Cleanups the socket and the subscriptions
989
992
  */
990
993
  async disconnect() {
991
- var r;
992
- T || sessionStorage.removeItem(M), w(this, H).clear(), (r = w(this, L)) == null || r.close();
994
+ var t;
995
+ T || sessionStorage.removeItem(M), w(this, H).clear(), (t = w(this, L)) == null || t.close();
993
996
  }
994
997
  /**
995
998
  * Revokes access
@@ -1004,41 +1007,41 @@ class We {
1004
1007
  * @param event The event to subscribe to
1005
1008
  * @param handler The handler to be called when the event is triggered
1006
1009
  */
1007
- subscribeOrders(r, t) {
1008
- w(this, H).set(r, t);
1010
+ subscribeOrders(t, r) {
1011
+ w(this, H).set(t, r);
1009
1012
  }
1010
1013
  /**
1011
1014
  * Unsubscribe from MoneriumEvent and close the socket if there are no more subscriptions
1012
1015
  * @param event The event to unsubscribe from
1013
1016
  */
1014
- unsubscribeOrders(r) {
1015
- var t;
1016
- w(this, H).delete(r), w(this, H).size === 0 && ((t = w(this, L)) == null || t.close(), I(this, L, void 0));
1017
+ unsubscribeOrders(t) {
1018
+ var r;
1019
+ w(this, H).delete(t), w(this, H).size === 0 && ((r = w(this, L)) == null || r.close(), I(this, L, void 0));
1017
1020
  }
1018
1021
  }
1019
- z = new WeakMap(), D = new WeakMap(), L = new WeakMap(), H = new WeakMap(), U = new WeakMap(), O = new WeakSet(), j = async function(r) {
1020
- let t;
1021
- if (te(r))
1022
- t = { ...r, grant_type: "authorization_code" };
1023
- else if (Me(r))
1024
- t = { ...r, grant_type: "refresh_token" };
1025
- else if (Le(r))
1026
- t = { ...r, grant_type: "client_credentials" };
1022
+ z = new WeakMap(), D = new WeakMap(), L = new WeakMap(), H = new WeakMap(), U = new WeakMap(), O = new WeakSet(), j = async function(t) {
1023
+ let r;
1024
+ if (ne(t))
1025
+ r = { ...t, grant_type: "authorization_code" };
1026
+ else if (Me(t))
1027
+ r = { ...t, grant_type: "refresh_token" };
1028
+ else if (Le(t))
1029
+ r = { ...t, grant_type: "client_credentials" };
1027
1030
  else
1028
1031
  throw new Error("Authorization grant type could not be detected.");
1029
- return await k(this, E, R).call(this, "post", "auth/token", t, !0).then((n) => {
1032
+ return await k(this, E, R).call(this, "post", "auth/token", r, !0).then((n) => {
1030
1033
  var u;
1031
1034
  this.bearerProfile = n, this.isAuthorized = !!n, I(this, D, `Bearer ${n == null ? void 0 : n.access_token}`), T || window.sessionStorage.setItem(
1032
1035
  W,
1033
1036
  ((u = this.bearerProfile) == null ? void 0 : u.refresh_token) || ""
1034
1037
  );
1035
1038
  }).catch((n) => {
1036
- throw T || (sessionStorage.removeItem(M), sessionStorage.removeItem(W)), new Error(n == null ? void 0 : n.message);
1037
- }), te(r) && Te(), this.bearerProfile;
1038
- }, E = new WeakSet(), R = async function(r, t, n, u) {
1039
+ throw T || (sessionStorage.removeItem(M), sessionStorage.removeItem(W), re()), new Error(n == null ? void 0 : n.message);
1040
+ }), ne(t) && re(), this.bearerProfile;
1041
+ }, E = new WeakSet(), R = async function(t, r, n, u) {
1039
1042
  return qe(
1040
- `${w(this, z).api}/${t}`,
1041
- r,
1043
+ `${w(this, z).api}/${r}`,
1044
+ t,
1042
1045
  u ? Q(n) : n,
1043
1046
  {
1044
1047
  Authorization: w(this, D) || "",
@@ -1047,19 +1050,19 @@ z = new WeakMap(), D = new WeakMap(), L = new WeakMap(), H = new WeakMap(), U =
1047
1050
  );
1048
1051
  }, V = new WeakMap(), G = new WeakMap(), J = new WeakMap();
1049
1052
  export {
1050
- we as AccountState,
1051
- fe as Currency,
1052
- ge as KYCOutcome,
1053
- ve as KYCState,
1053
+ ye as AccountState,
1054
+ le as Currency,
1055
+ we as KYCOutcome,
1056
+ ge as KYCState,
1054
1057
  We as MoneriumClient,
1055
- me as OrderKind,
1056
- _e as OrderState,
1057
- ye as PaymentStandard,
1058
- pe as Permission,
1059
- le as ProfileType,
1058
+ _e as OrderKind,
1059
+ be as OrderState,
1060
+ me as PaymentStandard,
1061
+ ve as Permission,
1062
+ pe as ProfileType,
1060
1063
  Ne as constants,
1061
- Se as getChain,
1062
- Be as getNetwork,
1064
+ Be as getChain,
1065
+ ke as getNetwork,
1063
1066
  Fe as placeOrderMessage,
1064
- be as rfc3339
1067
+ Se as rfc3339
1065
1068
  };
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monerium/sdk",
3
- "version": "2.7.2",
3
+ "version": "2.7.3",
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.7.2",
3
+ "version": "2.7.3",
4
4
  "description": "Everything you need to interact with the Monerium API - an electronic money issuer.",
5
5
  "license": "MIT",
6
6
  "repository": {