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