@monerium/sdk 2.10.0 → 2.11.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,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.11.0](https://github.com/monerium/js-sdk/compare/sdk-v2.10.0...sdk-v2.11.0) (2024-02-05)
4
+
5
+
6
+ ### Features
7
+
8
+ * sepolia ([6de28cd](https://github.com/monerium/js-sdk/commit/6de28cd23be3a9130f2ecc08b47b4cdcf79991f5))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * sepolia ([b5fbf28](https://github.com/monerium/js-sdk/commit/b5fbf2833bf460368c11c2ab8dccad0fde92339c))
14
+ * sepolia ([a744ebc](https://github.com/monerium/js-sdk/commit/a744ebcc95a96765e54928116945b9bb2bc4f2a6))
15
+ * sepolia instead of goerli ([030b172](https://github.com/monerium/js-sdk/commit/030b17259aad5d6c4576911ea328420b8d2cfd63))
16
+
3
17
  ## [2.10.0](https://github.com/monerium/js-sdk/compare/sdk-v2.9.0...sdk-v2.10.0) (2023-12-20)
4
18
 
5
19
 
package/README.md CHANGED
@@ -40,7 +40,7 @@ yarn add @monerium/sdk
40
40
 
41
41
  | Environment | Chain | Network |
42
42
  | ----------- | -------- | ------- |
43
- | sandbox | ethereum | goerli |
43
+ | sandbox | ethereum | sepolia |
44
44
  | | polygon | mumbai |
45
45
  | | gnosis | chiado |
46
46
  | production | ethereum | mainnet |
@@ -222,7 +222,7 @@ await monerium.linkAddress(profileId, {
222
222
  message: LINK_MESSAGE
223
223
  signature,
224
224
  accounts: [
225
- {"currency":"eur","chain":"ethereum","network":"goerli"},
225
+ {"currency":"eur","chain":"ethereum","network":"sepolia"},
226
226
  {"currency":"eur","chain":"gnosis","network":"chiado"}
227
227
  ],
228
228
  } as LinkAddress);
@@ -281,7 +281,7 @@ const order = await monerium.placeOrder({
281
281
  message,
282
282
  memo: 'Powered by Monerium SDK',
283
283
  chain: 'ethereum',
284
- network: 'goerli',
284
+ network: 'sepolia',
285
285
  // supportingDocumentId, see below
286
286
  });
287
287
  ```
package/dist/client.d.ts CHANGED
@@ -9,6 +9,7 @@ export declare class MoneriumClient {
9
9
  /** The bearer profile will be available after authentication, it includes the access_token and refresh_token */
10
10
  bearerProfile?: BearerProfile;
11
11
  isAuthorized: boolean;
12
+ state: string | undefined;
12
13
  /** Constructor for no arguments, defaults to sandbox */
13
14
  constructor();
14
15
  /** Constructor with only env as an argument*/
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var X=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var w=(e,t,r)=>(X(e,t,"read from private field"),r?r.call(e):t.get(e)),R=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},I=(e,t,r,n)=>(X(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);var k=(e,t,r)=>(X(e,t,"access private method"),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var ce=(e=>(e.eur="eur",e))(ce||{}),ue=(e=>(e.corporate="corporate",e.personal="personal",e))(ue||{}),he=(e=>(e.read="read",e.write="write",e))(he||{}),fe=(e=>(e.absent="absent",e.submitted="submitted",e.pending="pending",e.confirmed="confirmed",e))(fe||{}),de=(e=>(e.approved="approved",e.rejected="rejected",e.unknown="unknown",e))(de||{}),le=(e=>(e.requested="requested",e.approved="approved",e.pending="pending",e))(le||{}),pe=(e=>(e.iban="iban",e.scan="scan",e.chain="chain",e))(pe||{}),ve=(e=>(e.redeem="redeem",e.issue="issue",e))(ve||{}),ge=(e=>(e.placed="placed",e.pending="pending",e.processed="processed",e.rejected="rejected",e))(ge||{});const te=e=>{if(e.toString()==="Invalid Date")throw e;const t=n=>n<10?"0"+n:n,r=n=>{if(n===0)return"Z";const 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())},xe=(e,t,r,n)=>{const u=`${(n==null?void 0:n.toUpperCase())||"EUR"}`;return r?`Send ${u} ${e} to ${t} on ${K(r)} at ${te(new Date)}`:`Send ${u} ${e} to ${t} at ${te(new Date)}`},Z=e=>{var t;return e&&((t=Object.entries(e))==null?void 0:t.length)>0?Object.entries(e).map(([r,n])=>`${encodeURIComponent(r)}=${encodeURIComponent(n)}`).join("&"):""},K=e=>{switch(e){case 1:case 5:return"ethereum";case 100:case 10200:return"gnosis";case 137:case 80001:return"polygon";default:throw new Error(`Chain not supported: ${e}`)}},re=e=>{switch(e){case 1:case 100:case 137:return"mainnet";case 5:return"goerli";case 10200:return"chiado";case 80001:return"mumbai";default:throw new Error(`Network not supported: ${e}`)}},Q=e=>{if(e!=null&&e.chainId){const{chainId:t,...r}=e;return{...r,chain:K(t),network:re(t)}}return e},Y={environments:{production:{api:"https://api.monerium.app",web:"https://monerium.app",wss:"wss://api.monerium.app"},sandbox:{api:"https://api.monerium.dev",web:"https://sandbox.monerium.dev",wss:"wss://api.monerium.dev"}}},Ae="I hereby declare that I am the address owner.",M="monerium.sdk.code_verifier",D="monerium.sdk.refresh_token",Ee={LINK_MESSAGE:Ae,STORAGE_CODE_VERIFIER:M,STORAGE_REFRESH_TOKEN:D};var q=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function we(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Ie(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var u=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,u.get?u:{enumerable:!0,get:function(){return e[n]}})}),r}var ye={exports:{}};function $e(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ee={exports:{}};const Re={},Oe=Object.freeze(Object.defineProperty({__proto__:null,default:Re},Symbol.toStringTag,{value:"Module"})),Pe=Ie(Oe);var oe;function me(){return oe||(oe=1,function(e,t){(function(r,n){e.exports=n()})(q,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 q<"u"&&q.crypto&&(c=q.crypto),!c&&typeof $e=="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 o(){}return function(s){var a;return o.prototype=s,a=new o,o.prototype=null,a}}(),p={},y=p.lib={},m=y.Base=function(){return{extend:function(o){var s=C(this);return o&&s.mixIn(o),(!s.hasOwnProperty("init")||this.init===s.init)&&(s.init=function(){s.$super.init.apply(this,arguments)}),s.init.prototype=s,s.$super=this,s},create:function(){var o=this.extend();return o.init.apply(o,arguments),o},init:function(){},mixIn:function(o){for(var s in o)o.hasOwnProperty(s)&&(this[s]=o[s]);o.hasOwnProperty("toString")&&(this.toString=o.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),g=y.WordArray=m.extend({init:function(o,s){o=this.words=o||[],s!=u?this.sigBytes=s:this.sigBytes=o.length*4},toString:function(o){return(o||f).stringify(this)},concat:function(o){var s=this.words,a=o.words,h=this.sigBytes,_=o.sigBytes;if(this.clamp(),h%4)for(var S=0;S<_;S++){var B=a[S>>>2]>>>24-S%4*8&255;s[h+S>>>2]|=B<<24-(h+S)%4*8}else for(var x=0;x<_;x+=4)s[h+x>>>2]=a[x>>>2];return this.sigBytes+=_,this},clamp:function(){var o=this.words,s=this.sigBytes;o[s>>>2]&=4294967295<<32-s%4*8,o.length=n.ceil(s/4)},clone:function(){var o=m.clone.call(this);return o.words=this.words.slice(0),o},random:function(o){for(var s=[],a=0;a<o;a+=4)s.push(v());return new g.init(s,o)}}),b=p.enc={},f=b.Hex={stringify:function(o){for(var s=o.words,a=o.sigBytes,h=[],_=0;_<a;_++){var S=s[_>>>2]>>>24-_%4*8&255;h.push((S>>>4).toString(16)),h.push((S&15).toString(16))}return h.join("")},parse:function(o){for(var s=o.length,a=[],h=0;h<s;h+=2)a[h>>>3]|=parseInt(o.substr(h,2),16)<<24-h%8*4;return new g.init(a,s/2)}},l=b.Latin1={stringify:function(o){for(var s=o.words,a=o.sigBytes,h=[],_=0;_<a;_++){var S=s[_>>>2]>>>24-_%4*8&255;h.push(String.fromCharCode(S))}return h.join("")},parse:function(o){for(var s=o.length,a=[],h=0;h<s;h++)a[h>>>2]|=(o.charCodeAt(h)&255)<<24-h%4*8;return new g.init(a,s)}},i=b.Utf8={stringify:function(o){try{return decodeURIComponent(escape(l.stringify(o)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(o){return l.parse(unescape(encodeURIComponent(o)))}},d=y.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new g.init,this._nDataBytes=0},_append:function(o){typeof o=="string"&&(o=i.parse(o)),this._data.concat(o),this._nDataBytes+=o.sigBytes},_process:function(o){var s,a=this._data,h=a.words,_=a.sigBytes,S=this.blockSize,B=S*4,x=_/B;o?x=n.ceil(x):x=n.max((x|0)-this._minBufferSize,0);var N=x*S,U=n.min(N*4,_);if(N){for(var W=0;W<N;W+=S)this._doProcessBlock(h,W);s=h.splice(0,N),a.sigBytes-=U}return new g.init(s,U)},clone:function(){var o=m.clone.call(this);return o._data=this._data.clone(),o},_minBufferSize:0});y.Hasher=d.extend({cfg:m.extend(),init:function(o){this.cfg=this.cfg.extend(o),this.reset()},reset:function(){d.reset.call(this),this._doReset()},update:function(o){return this._append(o),this._process(),this},finalize:function(o){o&&this._append(o);var s=this._doFinalize();return s},blockSize:16,_createHelper:function(o){return function(s,a){return new o.init(a).finalize(s)}},_createHmacHelper:function(o){return function(s,a){return new A.HMAC.init(o,a).finalize(s)}}});var A=p.algo={};return p}(Math);return r})}(ee)),ee.exports}(function(e,t){(function(r,n){e.exports=n(me())})(q,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 f=[],l=0;l<g;l+=3)for(var i=m[l>>>2]>>>24-l%4*8&255,d=m[l+1>>>2]>>>24-(l+1)%4*8&255,A=m[l+2>>>2]>>>24-(l+2)%4*8&255,o=i<<16|d<<8|A,s=0;s<4&&l+s*.75<g;s++)f.push(b.charAt(o>>>6*(3-s)&63));var a=b.charAt(64);if(a)for(;f.length%4;)f.push(a);return f.join("")},parse:function(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 f=0;f<g.length;f++)b[g.charCodeAt(f)]=f}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,f=0;f<y;f++)if(f%4){var l=m[p.charCodeAt(f-1)]<<f%4*2,i=m[p.charCodeAt(f)]>>>6-f%4*2,d=l|i;g[b>>>2]|=d<<24-b%4*8,b++}return c.create(g,b)}}(),r.enc.Base64url})})(ye);var ze=ye.exports;const Ue=we(ze);var _e={exports:{}};(function(e,t){(function(r,n){e.exports=n(me())})(q,function(r){return function(n){var u=r,c=u.lib,v=c.WordArray,C=c.Hasher,p=u.algo,y=[],m=[];(function(){function f(A){for(var o=n.sqrt(A),s=2;s<=o;s++)if(!(A%s))return!1;return!0}function l(A){return(A-(A|0))*4294967296|0}for(var i=2,d=0;d<64;)f(i)&&(d<8&&(y[d]=l(n.pow(i,1/2))),m[d]=l(n.pow(i,1/3)),d++),i++})();var g=[],b=p.SHA256=C.extend({_doReset:function(){this._hash=new v.init(y.slice(0))},_doProcessBlock:function(f,l){for(var i=this._hash.words,d=i[0],A=i[1],o=i[2],s=i[3],a=i[4],h=i[5],_=i[6],S=i[7],B=0;B<64;B++){if(B<16)g[B]=f[l+B]|0;else{var x=g[B-15],N=(x<<25|x>>>7)^(x<<14|x>>>18)^x>>>3,U=g[B-2],W=(U<<15|U>>>17)^(U<<13|U>>>19)^U>>>10;g[B]=N+g[B-7]+W+g[B-16]}var be=a&h^~a&_,Se=d&A^d&o^A&o,Ce=(d<<30|d>>>2)^(d<<19|d>>>13)^(d<<10|d>>>22),ke=(a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25),ne=S+ke+be+m[B]+g[B],Be=Ce+Se;S=_,_=h,h=a,a=s+ne|0,s=o,o=A,A=d,d=ne+Be|0}i[0]=i[0]+d|0,i[1]=i[1]+A|0,i[2]=i[2]+o|0,i[3]=i[3]+s|0,i[4]=i[4]+a|0,i[5]=i[5]+h|0,i[6]=i[6]+_|0,i[7]=i[7]+S|0},_doFinalize:function(){var f=this._data,l=f.words,i=this._nDataBytes*8,d=f.sigBytes*8;return l[d>>>5]|=128<<24-d%32,l[(d+64>>>9<<4)+14]=n.floor(i/4294967296),l[(d+64>>>9<<4)+15]=i,f.sigBytes=l.length*4,this._process(),this._hash},clone:function(){var f=C.clone.call(this);return f._hash=this._hash.clone(),f}});u.SHA256=C._createHelper(b),u.HmacSHA256=C._createHmacHelper(b)}(Math),r.SHA256})})(_e);var He=_e.exports;const Te=we(He),Me=(e,t)=>{const{client_id:r,redirect_uri:n,scope: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?K(v):C}:{},...v!==void 0||p!==void 0?{network:v?re(v):p}:{}}:{};return Z({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})},Le=()=>{let e="";const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=t.length;let n=0;for(;n<128;)e+=t.charAt(Math.floor(Math.random()*r)),n+=1;return e},Ne=e=>Ue.stringify(Te(e)),se=(e,t)=>{const r=Le(),n=Ne(r);return localStorage.setItem(M,r||""),`${e}/auth?${Me(t,n)}`},ie=()=>{const e=window.location.href;if(!e||!(e!=null&&e.includes("?")))return;const[t,r]=e.split("?");r&&window.history.replaceState(null,"",t)},ae=e=>e.code!=null,je=e=>e.refresh_token!=null,qe=e=>e.client_secret!=null,Fe=async(e,t,r,n)=>{const 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,F,L,z,P,H,j,E,$,V,G,J;class We{constructor(t){R(this,H);R(this,E);R(this,O,void 0);R(this,F,void 0);R(this,L,void 0);R(this,z,void 0);R(this,P,void 0);R(this,V,void 0);R(this,G,void 0);R(this,J,void 0);if(I(this,z,new Map),this.isAuthorized=!!this.bearerProfile,I(this,V,async(r,n,u)=>{const c=localStorage.getItem(M)||"";if(!c)throw new Error("Code verifier not found");return this.codeVerifier=c,localStorage.removeItem(M),await k(this,H,j).call(this,{code:u,redirect_uri:n,client_id:r,code_verifier:c})}),I(this,G,async({clientId:r,clientSecret:n})=>await k(this,H,j).call(this,{client_id:r,client_secret:n})),I(this,J,async(r,n)=>await k(this,H,j).call(this,{refresh_token:n,client_id:r})),this.subscribeToOrderNotifications=()=>{var 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 k(this,H,j).call(this,r),this.connect=async r=>await k(this,H,j).call(this,r),this.getAuthFlowURI=r=>{const n=se(w(this,O).api,r);return this.codeVerifier=localStorage.getItem(M),n},this.pkceRequest=r=>this.getAuthFlowURI(r),this.getEnvironment=()=>w(this,O),!t){I(this,O,Y.environments.sandbox);return}if(typeof t=="string")I(this,O,Y.environments[t]);else if(I(this,O,Y.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=se(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=localStorage.getItem(D)||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 k(this,E,$).call(this,"get","auth/context")}getProfile(t){return k(this,E,$).call(this,"get",`profiles/${t}`)}getBalances(t){return t?k(this,E,$).call(this,"get",`profiles/${t}/balances`):k(this,E,$).call(this,"get","balances")}getOrders(t){const r=Z(t);return k(this,E,$).call(this,"get",`orders?${r}`)}getOrder(t){return k(this,E,$).call(this,"get",`orders/${t}`)}getTokens(){return k(this,E,$).call(this,"get","tokens")}linkAddress(t,r){return r=Q(r),r.accounts=r.accounts.map(n=>Q(n)),k(this,E,$).call(this,"post",`profiles/${t}/addresses`,JSON.stringify(r))}placeOrder(t,r){const n={kind:"redeem",currency:"eur",...Q(t),counterpart:{...t.counterpart,identifier:Q(t.counterpart.identifier)}};return r?k(this,E,$).call(this,"post",`profiles/${r}/orders`,JSON.stringify(n)):k(this,E,$).call(this,"post","orders",JSON.stringify(n))}uploadSupportingDocument(t){const r=Z(t);return k(this,E,$).call(this,"post","files/supporting-document",r,!0)}async connectOrderSocket(){var t;(t=this.bearerProfile)!=null&&t.access_token&&w(this,z).size>0&&I(this,L,this.subscribeToOrderNotifications())}async disconnect(){var t;T||localStorage.removeItem(M),w(this,z).clear(),(t=w(this,L))==null||t.close(),I(this,F,void 0),this.bearerProfile=void 0}async revokeAccess(){T||localStorage.removeItem(D),this.disconnect()}subscribeOrders(t,r){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,F=new WeakMap,L=new WeakMap,z=new WeakMap,P=new WeakMap,H=new WeakSet,j=async function(t){let r;if(ae(t))r={...t,grant_type:"authorization_code"};else if(je(t))r={...t,grant_type:"refresh_token"};else if(qe(t))r={...t,grant_type:"client_credentials"};else throw new Error("Authorization grant type could not be detected.");return await k(this,E,$).call(this,"post","auth/token",r,!0).then(n=>{var u;this.bearerProfile=n,this.isAuthorized=!!n,I(this,F,`Bearer ${n==null?void 0:n.access_token}`),T||window.localStorage.setItem(D,((u=this.bearerProfile)==null?void 0:u.refresh_token)||"")}).catch(n=>{throw T||(localStorage.removeItem(M),localStorage.removeItem(D),ie()),new Error(n==null?void 0:n.message)}),ae(t)&&ie(),this.bearerProfile},E=new WeakSet,$=async function(t,r,n,u){return Fe(`${w(this,O).api}/${r}`,t,u?Z(n):n,{Authorization:w(this,F)||"","Content-Type":`application/${u?"x-www-form-urlencoded":"json"}`})},V=new WeakMap,G=new WeakMap,J=new WeakMap;exports.AccountState=le;exports.Currency=ce;exports.KYCOutcome=de;exports.KYCState=fe;exports.MoneriumClient=We;exports.OrderKind=ve;exports.OrderState=ge;exports.PaymentStandard=pe;exports.Permission=he;exports.ProfileType=ue;exports.constants=Ee;exports.getChain=K;exports.getNetwork=re;exports.placeOrderMessage=xe;exports.rfc3339=te;
1
+ "use strict";var X=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var y=(e,t,r)=>(X(e,t,"read from private field"),r?r.call(e):t.get(e)),R=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},I=(e,t,r,n)=>(X(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);var k=(e,t,r)=>(X(e,t,"access private method"),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var ce=(e=>(e.eur="eur",e))(ce||{}),ue=(e=>(e.corporate="corporate",e.personal="personal",e))(ue||{}),he=(e=>(e.read="read",e.write="write",e))(he||{}),de=(e=>(e.absent="absent",e.submitted="submitted",e.pending="pending",e.confirmed="confirmed",e))(de||{}),fe=(e=>(e.approved="approved",e.rejected="rejected",e.unknown="unknown",e))(fe||{}),le=(e=>(e.requested="requested",e.approved="approved",e.pending="pending",e))(le||{}),pe=(e=>(e.iban="iban",e.scan="scan",e.chain="chain",e))(pe||{}),ve=(e=>(e.redeem="redeem",e.issue="issue",e))(ve||{}),ge=(e=>(e.placed="placed",e.pending="pending",e.processed="processed",e.rejected="rejected",e))(ge||{});const te=e=>{if(e.toString()==="Invalid Date")throw e;const t=n=>n<10?"0"+n:n,r=n=>{if(n===0)return"Z";const c=n>0?"-":"+";return n=Math.abs(n),c+t(Math.floor(n/60))+":"+t(n%60)};return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+"T"+t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+r(e.getTimezoneOffset())},xe=(e,t,r,n)=>{const c=`${(n==null?void 0:n.toUpperCase())||"EUR"}`;return r?`Send ${c} ${e} to ${t} on ${K(r)} at ${te(new Date)}`:`Send ${c} ${e} to ${t} at ${te(new Date)}`},Z=e=>{var t;return e&&((t=Object.entries(e))==null?void 0:t.length)>0?Object.entries(e).map(([r,n])=>`${encodeURIComponent(r)}=${encodeURIComponent(n)}`).join("&"):""},K=e=>{switch(e){case 1:case 11155111:return"ethereum";case 100:case 10200:return"gnosis";case 137:case 80001:return"polygon";default:throw new Error(`Chain not supported: ${e}`)}},re=e=>{switch(e){case 1:case 100:case 137:return"mainnet";case 11155111:return"sepolia";case 10200:return"chiado";case 80001:return"mumbai";default:throw new Error(`Network not supported: ${e}`)}},Q=e=>{if(e!=null&&e.chainId){const{chainId:t,...r}=e;return{...r,chain:K(t),network:re(t)}}return e},Y={environments:{production:{api:"https://api.monerium.app",web:"https://monerium.app",wss:"wss://api.monerium.app"},sandbox:{api:"https://api.monerium.dev",web:"https://sandbox.monerium.dev",wss:"wss://api.monerium.dev"}}},Ae="I hereby declare that I am the address owner.",M="monerium.sdk.code_verifier",D="monerium.sdk.refresh_token",Ee={LINK_MESSAGE:Ae,STORAGE_CODE_VERIFIER:M,STORAGE_REFRESH_TOKEN:D};var q=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function we(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Ie(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var c=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,c.get?c:{enumerable:!0,get:function(){return e[n]}})}),r}var ye={exports:{}};function $e(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ee={exports:{}};const Re={},Pe=Object.freeze(Object.defineProperty({__proto__:null,default:Re},Symbol.toStringTag,{value:"Module"})),Oe=Ie(Pe);var oe;function me(){return oe||(oe=1,function(e,t){(function(r,n){e.exports=n()})(q,function(){var r=r||function(n,c){var u;if(typeof window<"u"&&window.crypto&&(u=window.crypto),typeof self<"u"&&self.crypto&&(u=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(u=globalThis.crypto),!u&&typeof window<"u"&&window.msCrypto&&(u=window.msCrypto),!u&&typeof q<"u"&&q.crypto&&(u=q.crypto),!u&&typeof $e=="function")try{u=Oe}catch{}var l=function(){if(u){if(typeof u.getRandomValues=="function")try{return u.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof u.randomBytes=="function")try{return u.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},C=Object.create||function(){function o(){}return function(s){var a;return o.prototype=s,a=new o,o.prototype=null,a}}(),v={},m=v.lib={},w=m.Base=function(){return{extend:function(o){var s=C(this);return o&&s.mixIn(o),(!s.hasOwnProperty("init")||this.init===s.init)&&(s.init=function(){s.$super.init.apply(this,arguments)}),s.init.prototype=s,s.$super=this,s},create:function(){var o=this.extend();return o.init.apply(o,arguments),o},init:function(){},mixIn:function(o){for(var s in o)o.hasOwnProperty(s)&&(this[s]=o[s]);o.hasOwnProperty("toString")&&(this.toString=o.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),g=m.WordArray=w.extend({init:function(o,s){o=this.words=o||[],s!=c?this.sigBytes=s:this.sigBytes=o.length*4},toString:function(o){return(o||d).stringify(this)},concat:function(o){var s=this.words,a=o.words,h=this.sigBytes,_=o.sigBytes;if(this.clamp(),h%4)for(var S=0;S<_;S++){var B=a[S>>>2]>>>24-S%4*8&255;s[h+S>>>2]|=B<<24-(h+S)%4*8}else for(var x=0;x<_;x+=4)s[h+x>>>2]=a[x>>>2];return this.sigBytes+=_,this},clamp:function(){var o=this.words,s=this.sigBytes;o[s>>>2]&=4294967295<<32-s%4*8,o.length=n.ceil(s/4)},clone:function(){var o=w.clone.call(this);return o.words=this.words.slice(0),o},random:function(o){for(var s=[],a=0;a<o;a+=4)s.push(l());return new g.init(s,o)}}),b=v.enc={},d=b.Hex={stringify:function(o){for(var s=o.words,a=o.sigBytes,h=[],_=0;_<a;_++){var S=s[_>>>2]>>>24-_%4*8&255;h.push((S>>>4).toString(16)),h.push((S&15).toString(16))}return h.join("")},parse:function(o){for(var s=o.length,a=[],h=0;h<s;h+=2)a[h>>>3]|=parseInt(o.substr(h,2),16)<<24-h%8*4;return new g.init(a,s/2)}},p=b.Latin1={stringify:function(o){for(var s=o.words,a=o.sigBytes,h=[],_=0;_<a;_++){var S=s[_>>>2]>>>24-_%4*8&255;h.push(String.fromCharCode(S))}return h.join("")},parse:function(o){for(var s=o.length,a=[],h=0;h<s;h++)a[h>>>2]|=(o.charCodeAt(h)&255)<<24-h%4*8;return new g.init(a,s)}},i=b.Utf8={stringify:function(o){try{return decodeURIComponent(escape(p.stringify(o)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(o){return p.parse(unescape(encodeURIComponent(o)))}},f=m.BufferedBlockAlgorithm=w.extend({reset:function(){this._data=new g.init,this._nDataBytes=0},_append:function(o){typeof o=="string"&&(o=i.parse(o)),this._data.concat(o),this._nDataBytes+=o.sigBytes},_process:function(o){var s,a=this._data,h=a.words,_=a.sigBytes,S=this.blockSize,B=S*4,x=_/B;o?x=n.ceil(x):x=n.max((x|0)-this._minBufferSize,0);var N=x*S,z=n.min(N*4,_);if(N){for(var W=0;W<N;W+=S)this._doProcessBlock(h,W);s=h.splice(0,N),a.sigBytes-=z}return new g.init(s,z)},clone:function(){var o=w.clone.call(this);return o._data=this._data.clone(),o},_minBufferSize:0});m.Hasher=f.extend({cfg:w.extend(),init:function(o){this.cfg=this.cfg.extend(o),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(o){return this._append(o),this._process(),this},finalize:function(o){o&&this._append(o);var s=this._doFinalize();return s},blockSize:16,_createHelper:function(o){return function(s,a){return new o.init(a).finalize(s)}},_createHmacHelper:function(o){return function(s,a){return new A.HMAC.init(o,a).finalize(s)}}});var A=v.algo={};return v}(Math);return r})}(ee)),ee.exports}(function(e,t){(function(r,n){e.exports=n(me())})(q,function(r){return function(){var n=r,c=n.lib,u=c.WordArray,l=n.enc;l.Base64url={stringify:function(v,m){m===void 0&&(m=!0);var w=v.words,g=v.sigBytes,b=m?this._safe_map:this._map;v.clamp();for(var d=[],p=0;p<g;p+=3)for(var i=w[p>>>2]>>>24-p%4*8&255,f=w[p+1>>>2]>>>24-(p+1)%4*8&255,A=w[p+2>>>2]>>>24-(p+2)%4*8&255,o=i<<16|f<<8|A,s=0;s<4&&p+s*.75<g;s++)d.push(b.charAt(o>>>6*(3-s)&63));var a=b.charAt(64);if(a)for(;d.length%4;)d.push(a);return d.join("")},parse:function(v,m){m===void 0&&(m=!0);var w=v.length,g=m?this._safe_map:this._map,b=this._reverseMap;if(!b){b=this._reverseMap=[];for(var d=0;d<g.length;d++)b[g.charCodeAt(d)]=d}var p=g.charAt(64);if(p){var i=v.indexOf(p);i!==-1&&(w=i)}return C(v,w,b)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"};function C(v,m,w){for(var g=[],b=0,d=0;d<m;d++)if(d%4){var p=w[v.charCodeAt(d-1)]<<d%4*2,i=w[v.charCodeAt(d)]>>>6-d%4*2,f=p|i;g[b>>>2]|=f<<24-b%4*8,b++}return u.create(g,b)}}(),r.enc.Base64url})})(ye);var Ue=ye.exports;const ze=we(Ue);var _e={exports:{}};(function(e,t){(function(r,n){e.exports=n(me())})(q,function(r){return function(n){var c=r,u=c.lib,l=u.WordArray,C=u.Hasher,v=c.algo,m=[],w=[];(function(){function d(A){for(var o=n.sqrt(A),s=2;s<=o;s++)if(!(A%s))return!1;return!0}function p(A){return(A-(A|0))*4294967296|0}for(var i=2,f=0;f<64;)d(i)&&(f<8&&(m[f]=p(n.pow(i,1/2))),w[f]=p(n.pow(i,1/3)),f++),i++})();var g=[],b=v.SHA256=C.extend({_doReset:function(){this._hash=new l.init(m.slice(0))},_doProcessBlock:function(d,p){for(var i=this._hash.words,f=i[0],A=i[1],o=i[2],s=i[3],a=i[4],h=i[5],_=i[6],S=i[7],B=0;B<64;B++){if(B<16)g[B]=d[p+B]|0;else{var x=g[B-15],N=(x<<25|x>>>7)^(x<<14|x>>>18)^x>>>3,z=g[B-2],W=(z<<15|z>>>17)^(z<<13|z>>>19)^z>>>10;g[B]=N+g[B-7]+W+g[B-16]}var be=a&h^~a&_,Se=f&A^f&o^A&o,Ce=(f<<30|f>>>2)^(f<<19|f>>>13)^(f<<10|f>>>22),ke=(a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25),ne=S+ke+be+w[B]+g[B],Be=Ce+Se;S=_,_=h,h=a,a=s+ne|0,s=o,o=A,A=f,f=ne+Be|0}i[0]=i[0]+f|0,i[1]=i[1]+A|0,i[2]=i[2]+o|0,i[3]=i[3]+s|0,i[4]=i[4]+a|0,i[5]=i[5]+h|0,i[6]=i[6]+_|0,i[7]=i[7]+S|0},_doFinalize:function(){var d=this._data,p=d.words,i=this._nDataBytes*8,f=d.sigBytes*8;return p[f>>>5]|=128<<24-f%32,p[(f+64>>>9<<4)+14]=n.floor(i/4294967296),p[(f+64>>>9<<4)+15]=i,d.sigBytes=p.length*4,this._process(),this._hash},clone:function(){var d=C.clone.call(this);return d._hash=this._hash.clone(),d}});c.SHA256=C._createHelper(b),c.HmacSHA256=C._createHmacHelper(b)}(Math),r.SHA256})})(_e);var He=_e.exports;const Te=we(He),Me=(e,t)=>{const{client_id:r,redirect_uri:n,scope:c,state:u,chainId:l,chain:C,network:v,address:m,signature:w}=e,g=m?{address:m,...w!==void 0?{signature:w}:{},...l!==void 0||C!==void 0?{chain:l?K(l):C}:{},...l!==void 0||v!==void 0?{network:l?re(l):v}:{}}:{};return Z({client_id:r,redirect_uri:n,...c!==void 0?{scope:c}:{},...u!==void 0?{state:u}:{},code_challenge:t,code_challenge_method:"S256",response_type:"code",...g})},Le=()=>{let e="";const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=t.length;let n=0;for(;n<128;)e+=t.charAt(Math.floor(Math.random()*r)),n+=1;return e},Ne=e=>ze.stringify(Te(e)),se=(e,t)=>{const r=Le(),n=Ne(r);return localStorage.setItem(M,r||""),`${e}/auth?${Me(t,n)}`},ie=()=>{const e=window.location.href;if(!e||!(e!=null&&e.includes("?")))return;const[t,r]=e.split("?");r&&window.history.replaceState(null,"",t)},ae=e=>e.code!=null,je=e=>e.refresh_token!=null,qe=e=>e.client_secret!=null,Fe=async(e,t,r,n)=>{const c=await fetch(`${e}`,{method:t,headers:n,body:r});let u;const l=await c.text();try{u=JSON.parse(l)}catch{throw l}if(!c.ok)throw u;return u},T=typeof window>"u";var P,F,L,U,O,H,j,E,$,V,G,J;class We{constructor(t){R(this,H);R(this,E);R(this,P,void 0);R(this,F,void 0);R(this,L,void 0);R(this,U,void 0);R(this,O,void 0);R(this,V,void 0);R(this,G,void 0);R(this,J,void 0);if(I(this,U,new Map),this.isAuthorized=!!this.bearerProfile,I(this,V,async(r,n,c,u)=>{const l=localStorage.getItem(M)||"";if(!l)throw new Error("Code verifier not found");return this.codeVerifier=l,this.state=u,localStorage.removeItem(M),await k(this,H,j).call(this,{code:c,redirect_uri:n,client_id:r,code_verifier:l})}),I(this,G,async({clientId:r,clientSecret:n})=>await k(this,H,j).call(this,{client_id:r,client_secret:n})),I(this,J,async(r,n)=>await k(this,H,j).call(this,{refresh_token:n,client_id:r})),this.subscribeToOrderNotifications=()=>{var c,u;const r=`${y(this,P).wss}/profiles/${(c=this.bearerProfile)==null?void 0:c.profile}/orders?access_token=${(u=this.bearerProfile)==null?void 0:u.access_token}`,n=new WebSocket(r);return n.addEventListener("open",()=>{console.info(`Socket connected: ${r}`)}),n.addEventListener("error",l=>{throw console.error(l),new Error(`Socket error: ${r}`)}),n.addEventListener("message",l=>{var v;const C=JSON.parse(l.data);(v=y(this,U).get(C.meta.state))==null||v(C)}),n.addEventListener("close",()=>{console.info(`Socket connection closed: ${r}`)}),n},this.auth=async r=>await k(this,H,j).call(this,r),this.connect=async r=>await k(this,H,j).call(this,r),this.getAuthFlowURI=r=>{const n=se(y(this,P).api,r);return this.codeVerifier=localStorage.getItem(M),n},this.pkceRequest=r=>this.getAuthFlowURI(r),this.getEnvironment=()=>y(this,P),!t){I(this,P,Y.environments.sandbox);return}if(typeof t=="string")I(this,P,Y.environments[t]);else if(I(this,P,Y.environments[t.environment||"sandbox"]),T){const{clientId:r,clientSecret:n}=t;I(this,O,{clientId:r,clientSecret:n})}else{const{clientId:r,redirectUrl:n}=t;I(this,O,{clientId:r,redirectUrl:n})}}async authorize(t){var u,l;const r=(t==null?void 0:t.clientId)||((u=y(this,O))==null?void 0:u.clientId),n=(t==null?void 0:t.redirectUrl)||((l=y(this,O))==null?void 0:l.redirectUrl);if(!r)throw new Error("Missing ClientId");if(!n)throw new Error("Missing RedirectUrl");const c=se(y(this,P).api,{client_id:r,redirect_uri:n,address:t==null?void 0:t.address,signature:t==null?void 0:t.signature,chainId:t==null?void 0:t.chainId,state:t==null?void 0:t.state});window.location.replace(c)}async getAccess(t){var v,m,w;const r=(t==null?void 0:t.clientId)||((v=y(this,O))==null?void 0:v.clientId);if((t==null?void 0:t.clientSecret)||((m=y(this,O))==null?void 0:m.clientSecret)){if(!T)throw new Error("Only use client credentials on server side");return await y(this,G).call(this,y(this,O)),!!this.bearerProfile}const c=(t==null?void 0:t.redirectUrl)||((w=y(this,O))==null?void 0:w.redirectUrl);if(!r)throw new Error("Missing ClientId");if(T)throw new Error("This only works client side");const u=new URLSearchParams(window.location.search).get("code")||void 0,l=new URLSearchParams(window.location.search).get("state")||void 0,C=localStorage.getItem(D)||void 0;return C?await y(this,J).call(this,r,C):u&&await y(this,V).call(this,r,c,u,l),!!this.bearerProfile}getAuthContext(){return k(this,E,$).call(this,"get","auth/context")}getProfile(t){return k(this,E,$).call(this,"get",`profiles/${t}`)}getBalances(t){return t?k(this,E,$).call(this,"get",`profiles/${t}/balances`):k(this,E,$).call(this,"get","balances")}getOrders(t){const r=Z(t);return k(this,E,$).call(this,"get",`orders?${r}`)}getOrder(t){return k(this,E,$).call(this,"get",`orders/${t}`)}getTokens(){return k(this,E,$).call(this,"get","tokens")}linkAddress(t,r){return r=Q(r),r.accounts=r.accounts.map(n=>Q(n)),k(this,E,$).call(this,"post",`profiles/${t}/addresses`,JSON.stringify(r))}placeOrder(t,r){const n={kind:"redeem",currency:"eur",...Q(t),counterpart:{...t.counterpart,identifier:Q(t.counterpart.identifier)}};return r?k(this,E,$).call(this,"post",`profiles/${r}/orders`,JSON.stringify(n)):k(this,E,$).call(this,"post","orders",JSON.stringify(n))}uploadSupportingDocument(t){const r=Z(t);return k(this,E,$).call(this,"post","files/supporting-document",r,!0)}async connectOrderSocket(){var t;(t=this.bearerProfile)!=null&&t.access_token&&y(this,U).size>0&&I(this,L,this.subscribeToOrderNotifications())}async disconnect(){var t;T||localStorage.removeItem(M),y(this,U).clear(),(t=y(this,L))==null||t.close(),I(this,F,void 0),this.bearerProfile=void 0}async revokeAccess(){T||localStorage.removeItem(D),this.disconnect()}subscribeOrders(t,r){y(this,U).set(t,r)}unsubscribeOrders(t){var r;y(this,U).delete(t),y(this,U).size===0&&((r=y(this,L))==null||r.close(),I(this,L,void 0))}}P=new WeakMap,F=new WeakMap,L=new WeakMap,U=new WeakMap,O=new WeakMap,H=new WeakSet,j=async function(t){let r;if(ae(t))r={...t,grant_type:"authorization_code"};else if(je(t))r={...t,grant_type:"refresh_token"};else if(qe(t))r={...t,grant_type:"client_credentials"};else throw new Error("Authorization grant type could not be detected.");return await k(this,E,$).call(this,"post","auth/token",r,!0).then(n=>{var c;this.bearerProfile=n,this.isAuthorized=!!n,I(this,F,`Bearer ${n==null?void 0:n.access_token}`),T||window.localStorage.setItem(D,((c=this.bearerProfile)==null?void 0:c.refresh_token)||"")}).catch(n=>{throw T||(localStorage.removeItem(M),localStorage.removeItem(D),ie()),new Error(n==null?void 0:n.message)}),ae(t)&&ie(),this.bearerProfile},E=new WeakSet,$=async function(t,r,n,c){return Fe(`${y(this,P).api}/${r}`,t,c?Z(n):n,{Authorization:y(this,F)||"","Content-Type":`application/${c?"x-www-form-urlencoded":"json"}`})},V=new WeakMap,G=new WeakMap,J=new WeakMap;exports.AccountState=le;exports.Currency=ce;exports.KYCOutcome=fe;exports.KYCState=de;exports.MoneriumClient=We;exports.OrderKind=ve;exports.OrderState=ge;exports.PaymentStandard=pe;exports.Permission=he;exports.ProfileType=ue;exports.constants=Ee;exports.getChain=K;exports.getNetwork=re;exports.placeOrderMessage=xe;exports.rfc3339=te;
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ var X = (e, t, r) => {
2
2
  if (!t.has(e))
3
3
  throw TypeError("Cannot " + r);
4
4
  };
5
- var w = (e, t, r) => (X(e, t, "read from private field"), r ? r.call(e) : t.get(e)), R = (e, t, r) => {
5
+ var y = (e, t, r) => (X(e, t, "read from private field"), r ? r.call(e) : t.get(e)), R = (e, t, r) => {
6
6
  if (t.has(e))
7
7
  throw TypeError("Cannot add the same private member more than once");
8
8
  t instanceof WeakSet ? t.add(e) : t.set(e, r);
@@ -15,15 +15,15 @@ const re = (e) => {
15
15
  const t = (n) => n < 10 ? "0" + n : n, r = (n) => {
16
16
  if (n === 0)
17
17
  return "Z";
18
- const u = n > 0 ? "-" : "+";
19
- return n = Math.abs(n), u + t(Math.floor(n / 60)) + ":" + t(n % 60);
18
+ const c = n > 0 ? "-" : "+";
19
+ return n = Math.abs(n), c + t(Math.floor(n / 60)) + ":" + t(n % 60);
20
20
  };
21
21
  return e.getFullYear() + "-" + t(e.getMonth() + 1) + "-" + t(e.getDate()) + "T" + t(e.getHours()) + ":" + t(e.getMinutes()) + ":" + t(e.getSeconds()) + r(e.getTimezoneOffset());
22
22
  }, Fe = (e, t, r, n) => {
23
- const u = `${(n == null ? void 0 : n.toUpperCase()) || "EUR"}`;
24
- return r ? `Send ${u} ${e} to ${t} on ${ee(
23
+ const c = `${(n == null ? void 0 : n.toUpperCase()) || "EUR"}`;
24
+ return r ? `Send ${c} ${e} to ${t} on ${ee(
25
25
  r
26
- )} at ${re(/* @__PURE__ */ new Date())}` : `Send ${u} ${e} to ${t} at ${re(/* @__PURE__ */ new Date())}`;
26
+ )} at ${re(/* @__PURE__ */ new Date())}` : `Send ${c} ${e} to ${t} at ${re(/* @__PURE__ */ new Date())}`;
27
27
  }, Z = (e) => {
28
28
  var t;
29
29
  return e && ((t = Object.entries(e)) == null ? void 0 : t.length) > 0 ? Object.entries(e).map(
@@ -32,7 +32,7 @@ const re = (e) => {
32
32
  }, ee = (e) => {
33
33
  switch (e) {
34
34
  case 1:
35
- case 5:
35
+ case 11155111:
36
36
  return "ethereum";
37
37
  case 100:
38
38
  case 10200:
@@ -49,8 +49,8 @@ const re = (e) => {
49
49
  case 100:
50
50
  case 137:
51
51
  return "mainnet";
52
- case 5:
53
- return "goerli";
52
+ case 11155111:
53
+ return "sepolia";
54
54
  case 10200:
55
55
  return "chiado";
56
56
  case 80001:
@@ -102,8 +102,8 @@ function Ae(e) {
102
102
  } else
103
103
  r = {};
104
104
  return Object.defineProperty(r, "__esModule", { value: !0 }), Object.keys(e).forEach(function(n) {
105
- var u = Object.getOwnPropertyDescriptor(e, n);
106
- Object.defineProperty(r, n, u.get ? u : {
105
+ var c = Object.getOwnPropertyDescriptor(e, n);
106
+ Object.defineProperty(r, n, c.get ? c : {
107
107
  enumerable: !0,
108
108
  get: function() {
109
109
  return e[n];
@@ -126,23 +126,23 @@ function he() {
126
126
  (function(r, n) {
127
127
  e.exports = n();
128
128
  })(q, function() {
129
- var r = r || function(n, u) {
130
- var c;
131
- 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 q < "u" && q.crypto && (c = q.crypto), !c && typeof Ee == "function")
129
+ var r = r || function(n, c) {
130
+ var u;
131
+ if (typeof window < "u" && window.crypto && (u = window.crypto), typeof self < "u" && self.crypto && (u = self.crypto), typeof globalThis < "u" && globalThis.crypto && (u = globalThis.crypto), !u && typeof window < "u" && window.msCrypto && (u = window.msCrypto), !u && typeof q < "u" && q.crypto && (u = q.crypto), !u && typeof Ee == "function")
132
132
  try {
133
- c = Re;
133
+ u = Re;
134
134
  } catch {
135
135
  }
136
- var v = function() {
137
- if (c) {
138
- if (typeof c.getRandomValues == "function")
136
+ var l = function() {
137
+ if (u) {
138
+ if (typeof u.getRandomValues == "function")
139
139
  try {
140
- return c.getRandomValues(new Uint32Array(1))[0];
140
+ return u.getRandomValues(new Uint32Array(1))[0];
141
141
  } catch {
142
142
  }
143
- if (typeof c.randomBytes == "function")
143
+ if (typeof u.randomBytes == "function")
144
144
  try {
145
- return c.randomBytes(4).readInt32LE();
145
+ return u.randomBytes(4).readInt32LE();
146
146
  } catch {
147
147
  }
148
148
  }
@@ -154,7 +154,7 @@ function he() {
154
154
  var a;
155
155
  return o.prototype = s, a = new o(), o.prototype = null, a;
156
156
  };
157
- }(), p = {}, y = p.lib = {}, m = y.Base = function() {
157
+ }(), v = {}, m = v.lib = {}, w = m.Base = function() {
158
158
  return {
159
159
  /**
160
160
  * Creates a new object that inherits from this object.
@@ -239,7 +239,7 @@ function he() {
239
239
  return this.init.prototype.extend(this);
240
240
  }
241
241
  };
242
- }(), g = y.WordArray = m.extend({
242
+ }(), g = m.WordArray = w.extend({
243
243
  /**
244
244
  * Initializes a newly created word array.
245
245
  *
@@ -253,7 +253,7 @@ function he() {
253
253
  * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
254
254
  */
255
255
  init: function(o, s) {
256
- o = this.words = o || [], s != u ? this.sigBytes = s : this.sigBytes = o.length * 4;
256
+ o = this.words = o || [], s != c ? this.sigBytes = s : this.sigBytes = o.length * 4;
257
257
  },
258
258
  /**
259
259
  * Converts this word array to a string.
@@ -315,7 +315,7 @@ function he() {
315
315
  * var clone = wordArray.clone();
316
316
  */
317
317
  clone: function() {
318
- var o = m.clone.call(this);
318
+ var o = w.clone.call(this);
319
319
  return o.words = this.words.slice(0), o;
320
320
  },
321
321
  /**
@@ -333,10 +333,10 @@ function he() {
333
333
  */
334
334
  random: function(o) {
335
335
  for (var s = [], a = 0; a < o; a += 4)
336
- s.push(v());
336
+ s.push(l());
337
337
  return new g.init(s, o);
338
338
  }
339
- }), b = p.enc = {}, f = b.Hex = {
339
+ }), b = v.enc = {}, f = b.Hex = {
340
340
  /**
341
341
  * Converts a word array to a hex string.
342
342
  *
@@ -375,7 +375,7 @@ function he() {
375
375
  a[h >>> 3] |= parseInt(o.substr(h, 2), 16) << 24 - h % 8 * 4;
376
376
  return new g.init(a, s / 2);
377
377
  }
378
- }, l = b.Latin1 = {
378
+ }, p = b.Latin1 = {
379
379
  /**
380
380
  * Converts a word array to a Latin1 string.
381
381
  *
@@ -430,7 +430,7 @@ function he() {
430
430
  */
431
431
  stringify: function(o) {
432
432
  try {
433
- return decodeURIComponent(escape(l.stringify(o)));
433
+ return decodeURIComponent(escape(p.stringify(o)));
434
434
  } catch {
435
435
  throw new Error("Malformed UTF-8 data");
436
436
  }
@@ -449,9 +449,9 @@ function he() {
449
449
  * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
450
450
  */
451
451
  parse: function(o) {
452
- return l.parse(unescape(encodeURIComponent(o)));
452
+ return p.parse(unescape(encodeURIComponent(o)));
453
453
  }
454
- }, d = y.BufferedBlockAlgorithm = m.extend({
454
+ }, d = m.BufferedBlockAlgorithm = w.extend({
455
455
  /**
456
456
  * Resets this block algorithm's data buffer to its initial state.
457
457
  *
@@ -492,13 +492,13 @@ function he() {
492
492
  _process: function(o) {
493
493
  var s, a = this._data, h = a.words, _ = a.sigBytes, S = this.blockSize, C = S * 4, x = _ / C;
494
494
  o ? x = n.ceil(x) : x = n.max((x | 0) - this._minBufferSize, 0);
495
- var N = x * S, P = n.min(N * 4, _);
495
+ var N = x * S, H = n.min(N * 4, _);
496
496
  if (N) {
497
497
  for (var W = 0; W < N; W += S)
498
498
  this._doProcessBlock(h, W);
499
- s = h.splice(0, N), a.sigBytes -= P;
499
+ s = h.splice(0, N), a.sigBytes -= H;
500
500
  }
501
- return new g.init(s, P);
501
+ return new g.init(s, H);
502
502
  },
503
503
  /**
504
504
  * Creates a copy of this object.
@@ -510,16 +510,16 @@ function he() {
510
510
  * var clone = bufferedBlockAlgorithm.clone();
511
511
  */
512
512
  clone: function() {
513
- var o = m.clone.call(this);
513
+ var o = w.clone.call(this);
514
514
  return o._data = this._data.clone(), o;
515
515
  },
516
516
  _minBufferSize: 0
517
517
  });
518
- y.Hasher = d.extend({
518
+ m.Hasher = d.extend({
519
519
  /**
520
520
  * Configuration options.
521
521
  */
522
- cfg: m.extend(),
522
+ cfg: w.extend(),
523
523
  /**
524
524
  * Initializes a newly created hasher.
525
525
  *
@@ -614,8 +614,8 @@ function he() {
614
614
  };
615
615
  }
616
616
  });
617
- var A = p.algo = {};
618
- return p;
617
+ var A = v.algo = {};
618
+ return v;
619
619
  }(Math);
620
620
  return r;
621
621
  });
@@ -626,8 +626,8 @@ function he() {
626
626
  e.exports = n(he());
627
627
  })(q, function(r) {
628
628
  return function() {
629
- var n = r, u = n.lib, c = u.WordArray, v = n.enc;
630
- v.Base64url = {
629
+ var n = r, c = n.lib, u = c.WordArray, l = n.enc;
630
+ l.Base64url = {
631
631
  /**
632
632
  * Converts a word array to a Base64url string.
633
633
  *
@@ -643,12 +643,12 @@ function he() {
643
643
  *
644
644
  * var base64String = CryptoJS.enc.Base64url.stringify(wordArray);
645
645
  */
646
- stringify: function(p, y) {
647
- y === void 0 && (y = !0);
648
- var m = p.words, g = p.sigBytes, b = y ? this._safe_map : this._map;
649
- p.clamp();
650
- for (var f = [], l = 0; l < g; l += 3)
651
- for (var i = m[l >>> 2] >>> 24 - l % 4 * 8 & 255, d = m[l + 1 >>> 2] >>> 24 - (l + 1) % 4 * 8 & 255, A = m[l + 2 >>> 2] >>> 24 - (l + 2) % 4 * 8 & 255, o = i << 16 | d << 8 | A, s = 0; s < 4 && l + s * 0.75 < g; s++)
646
+ stringify: function(v, m) {
647
+ m === void 0 && (m = !0);
648
+ var w = v.words, g = v.sigBytes, b = m ? this._safe_map : this._map;
649
+ v.clamp();
650
+ for (var f = [], p = 0; p < g; p += 3)
651
+ for (var i = w[p >>> 2] >>> 24 - p % 4 * 8 & 255, d = w[p + 1 >>> 2] >>> 24 - (p + 1) % 4 * 8 & 255, A = w[p + 2 >>> 2] >>> 24 - (p + 2) % 4 * 8 & 255, o = i << 16 | d << 8 | A, s = 0; s < 4 && p + s * 0.75 < g; s++)
652
652
  f.push(b.charAt(o >>> 6 * (3 - s) & 63));
653
653
  var a = b.charAt(64);
654
654
  if (a)
@@ -671,44 +671,44 @@ function he() {
671
671
  *
672
672
  * var wordArray = CryptoJS.enc.Base64url.parse(base64String);
673
673
  */
674
- parse: function(p, y) {
675
- y === void 0 && (y = !0);
676
- var m = p.length, g = y ? this._safe_map : this._map, b = this._reverseMap;
674
+ parse: function(v, m) {
675
+ m === void 0 && (m = !0);
676
+ var w = v.length, g = m ? this._safe_map : this._map, b = this._reverseMap;
677
677
  if (!b) {
678
678
  b = this._reverseMap = [];
679
679
  for (var f = 0; f < g.length; f++)
680
680
  b[g.charCodeAt(f)] = f;
681
681
  }
682
- var l = g.charAt(64);
683
- if (l) {
684
- var i = p.indexOf(l);
685
- i !== -1 && (m = i);
682
+ var p = g.charAt(64);
683
+ if (p) {
684
+ var i = v.indexOf(p);
685
+ i !== -1 && (w = i);
686
686
  }
687
- return B(p, m, b);
687
+ return B(v, w, b);
688
688
  },
689
689
  _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
690
690
  _safe_map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
691
691
  };
692
- function B(p, y, m) {
693
- for (var g = [], b = 0, f = 0; f < y; f++)
692
+ function B(v, m, w) {
693
+ for (var g = [], b = 0, f = 0; f < m; f++)
694
694
  if (f % 4) {
695
- var l = m[p.charCodeAt(f - 1)] << f % 4 * 2, i = m[p.charCodeAt(f)] >>> 6 - f % 4 * 2, d = l | i;
695
+ var p = w[v.charCodeAt(f - 1)] << f % 4 * 2, i = w[v.charCodeAt(f)] >>> 6 - f % 4 * 2, d = p | i;
696
696
  g[b >>> 2] |= d << 24 - b % 4 * 8, b++;
697
697
  }
698
- return c.create(g, b);
698
+ return u.create(g, b);
699
699
  }
700
700
  }(), r.enc.Base64url;
701
701
  });
702
702
  })(ue);
703
- var ze = ue.exports;
704
- const Ue = /* @__PURE__ */ ce(ze);
703
+ var Ue = ue.exports;
704
+ const ze = /* @__PURE__ */ ce(Ue);
705
705
  var fe = { exports: {} };
706
706
  (function(e, t) {
707
707
  (function(r, n) {
708
708
  e.exports = n(he());
709
709
  })(q, function(r) {
710
710
  return function(n) {
711
- var u = r, c = u.lib, v = c.WordArray, B = c.Hasher, p = u.algo, y = [], m = [];
711
+ var c = r, u = c.lib, l = u.WordArray, B = u.Hasher, v = c.algo, m = [], w = [];
712
712
  (function() {
713
713
  function f(A) {
714
714
  for (var o = n.sqrt(A), s = 2; s <= o; s++)
@@ -716,65 +716,65 @@ var fe = { exports: {} };
716
716
  return !1;
717
717
  return !0;
718
718
  }
719
- function l(A) {
719
+ function p(A) {
720
720
  return (A - (A | 0)) * 4294967296 | 0;
721
721
  }
722
722
  for (var i = 2, d = 0; d < 64; )
723
- f(i) && (d < 8 && (y[d] = l(n.pow(i, 1 / 2))), m[d] = l(n.pow(i, 1 / 3)), d++), i++;
723
+ f(i) && (d < 8 && (m[d] = p(n.pow(i, 1 / 2))), w[d] = p(n.pow(i, 1 / 3)), d++), i++;
724
724
  })();
725
- var g = [], b = p.SHA256 = B.extend({
725
+ var g = [], b = v.SHA256 = B.extend({
726
726
  _doReset: function() {
727
- this._hash = new v.init(y.slice(0));
727
+ this._hash = new l.init(m.slice(0));
728
728
  },
729
- _doProcessBlock: function(f, l) {
729
+ _doProcessBlock: function(f, p) {
730
730
  for (var i = this._hash.words, d = i[0], A = i[1], o = i[2], s = i[3], a = i[4], h = i[5], _ = i[6], S = i[7], C = 0; C < 64; C++) {
731
731
  if (C < 16)
732
- g[C] = f[l + C] | 0;
732
+ g[C] = f[p + C] | 0;
733
733
  else {
734
- var x = g[C - 15], N = (x << 25 | x >>> 7) ^ (x << 14 | x >>> 18) ^ x >>> 3, P = g[C - 2], W = (P << 15 | P >>> 17) ^ (P << 13 | P >>> 19) ^ P >>> 10;
734
+ var x = g[C - 15], N = (x << 25 | x >>> 7) ^ (x << 14 | x >>> 18) ^ x >>> 3, H = g[C - 2], W = (H << 15 | H >>> 17) ^ (H << 13 | H >>> 19) ^ H >>> 10;
735
735
  g[C] = N + g[C - 7] + W + g[C - 16];
736
736
  }
737
- var de = a & h ^ ~a & _, le = d & A ^ d & o ^ A & o, pe = (d << 30 | d >>> 2) ^ (d << 19 | d >>> 13) ^ (d << 10 | d >>> 22), ve = (a << 26 | a >>> 6) ^ (a << 21 | a >>> 11) ^ (a << 7 | a >>> 25), te = S + ve + de + m[C] + g[C], ge = pe + le;
737
+ var de = a & h ^ ~a & _, le = d & A ^ d & o ^ A & o, pe = (d << 30 | d >>> 2) ^ (d << 19 | d >>> 13) ^ (d << 10 | d >>> 22), ve = (a << 26 | a >>> 6) ^ (a << 21 | a >>> 11) ^ (a << 7 | a >>> 25), te = S + ve + de + w[C] + g[C], ge = pe + le;
738
738
  S = _, _ = h, h = a, a = s + te | 0, s = o, o = A, A = d, d = te + ge | 0;
739
739
  }
740
740
  i[0] = i[0] + d | 0, i[1] = i[1] + A | 0, i[2] = i[2] + o | 0, i[3] = i[3] + s | 0, i[4] = i[4] + a | 0, i[5] = i[5] + h | 0, i[6] = i[6] + _ | 0, i[7] = i[7] + S | 0;
741
741
  },
742
742
  _doFinalize: function() {
743
- var f = this._data, l = f.words, i = this._nDataBytes * 8, d = f.sigBytes * 8;
744
- return l[d >>> 5] |= 128 << 24 - d % 32, l[(d + 64 >>> 9 << 4) + 14] = n.floor(i / 4294967296), l[(d + 64 >>> 9 << 4) + 15] = i, f.sigBytes = l.length * 4, this._process(), this._hash;
743
+ var f = this._data, p = f.words, i = this._nDataBytes * 8, d = f.sigBytes * 8;
744
+ return p[d >>> 5] |= 128 << 24 - d % 32, p[(d + 64 >>> 9 << 4) + 14] = n.floor(i / 4294967296), p[(d + 64 >>> 9 << 4) + 15] = i, f.sigBytes = p.length * 4, this._process(), this._hash;
745
745
  },
746
746
  clone: function() {
747
747
  var f = B.clone.call(this);
748
748
  return f._hash = this._hash.clone(), f;
749
749
  }
750
750
  });
751
- u.SHA256 = B._createHelper(b), u.HmacSHA256 = B._createHmacHelper(b);
751
+ c.SHA256 = B._createHelper(b), c.HmacSHA256 = B._createHmacHelper(b);
752
752
  }(Math), r.SHA256;
753
753
  });
754
754
  })(fe);
755
- var He = fe.exports;
756
- const Pe = /* @__PURE__ */ ce(He), Oe = (e, t) => {
755
+ var Pe = fe.exports;
756
+ const He = /* @__PURE__ */ ce(Pe), Oe = (e, t) => {
757
757
  const {
758
758
  client_id: r,
759
759
  redirect_uri: n,
760
- scope: u,
761
- state: c,
762
- chainId: v,
760
+ scope: c,
761
+ state: u,
762
+ chainId: l,
763
763
  chain: B,
764
- network: p,
765
- address: y,
766
- signature: m
767
- } = e, g = y ? {
768
- address: y,
769
- ...m !== void 0 ? { signature: m } : {},
770
- ...v !== void 0 || B !== void 0 ? { chain: v ? ee(v) : B } : {},
771
- ...v !== void 0 || p !== void 0 ? { network: v ? ae(v) : p } : {}
764
+ network: v,
765
+ address: m,
766
+ signature: w
767
+ } = e, g = m ? {
768
+ address: m,
769
+ ...w !== void 0 ? { signature: w } : {},
770
+ ...l !== void 0 || B !== void 0 ? { chain: l ? ee(l) : B } : {},
771
+ ...l !== void 0 || v !== void 0 ? { network: l ? ae(l) : v } : {}
772
772
  } : {};
773
773
  return Z({
774
774
  client_id: r,
775
775
  redirect_uri: n,
776
- ...u !== void 0 ? { scope: u } : {},
777
- ...c !== void 0 ? { state: c } : {},
776
+ ...c !== void 0 ? { scope: c } : {},
777
+ ...u !== void 0 ? { state: u } : {},
778
778
  code_challenge: t,
779
779
  code_challenge_method: "S256",
780
780
  response_type: "code",
@@ -787,7 +787,7 @@ const Pe = /* @__PURE__ */ ce(He), Oe = (e, t) => {
787
787
  for (; n < 128; )
788
788
  e += t.charAt(Math.floor(Math.random() * r)), n += 1;
789
789
  return e;
790
- }, Me = (e) => Ue.stringify(Pe(e)), oe = (e, t) => {
790
+ }, Me = (e) => ze.stringify(He(e)), oe = (e, t) => {
791
791
  const r = Te(), n = Me(r);
792
792
  return localStorage.setItem(M, r || ""), `${e}/auth?${Oe(t, n)}`;
793
793
  }, se = () => {
@@ -797,23 +797,23 @@ const Pe = /* @__PURE__ */ ce(He), Oe = (e, t) => {
797
797
  const [t, r] = e.split("?");
798
798
  r && window.history.replaceState(null, "", t);
799
799
  }, ie = (e) => e.code != null, Le = (e) => e.refresh_token != null, Ne = (e) => e.client_secret != null, je = async (e, t, r, n) => {
800
- const u = await fetch(`${e}`, {
800
+ const c = await fetch(`${e}`, {
801
801
  method: t,
802
802
  headers: n,
803
803
  body: r
804
804
  });
805
- let c;
806
- const v = await u.text();
805
+ let u;
806
+ const l = await c.text();
807
807
  try {
808
- c = JSON.parse(v);
808
+ u = JSON.parse(l);
809
809
  } catch {
810
- throw v;
810
+ throw l;
811
811
  }
812
- if (!u.ok)
813
- throw c;
814
- return c;
812
+ if (!c.ok)
813
+ throw u;
814
+ return u;
815
815
  }, T = typeof window > "u";
816
- var z, F, L, H, U, O, j, E, $, V, G, J;
816
+ var U, F, L, P, z, O, j, E, $, V, G, J;
817
817
  class De {
818
818
  constructor(t) {
819
819
  /**
@@ -822,24 +822,24 @@ class De {
822
822
  R(this, O);
823
823
  // -- Helper Methods
824
824
  R(this, E);
825
- R(this, z, void 0);
825
+ R(this, U, void 0);
826
826
  R(this, F, void 0);
827
827
  /** The socket will be available after subscribing to an event */
828
828
  R(this, L, void 0);
829
- R(this, H, void 0);
830
- R(this, U, void 0);
829
+ R(this, P, void 0);
830
+ R(this, z, void 0);
831
831
  R(this, V, void 0);
832
832
  R(this, G, void 0);
833
833
  R(this, J, void 0);
834
- if (I(this, H, /* @__PURE__ */ new Map()), this.isAuthorized = !!this.bearerProfile, I(this, V, async (r, n, u) => {
835
- const c = localStorage.getItem(M) || "";
836
- if (!c)
834
+ if (I(this, P, /* @__PURE__ */ new Map()), this.isAuthorized = !!this.bearerProfile, I(this, V, async (r, n, c, u) => {
835
+ const l = localStorage.getItem(M) || "";
836
+ if (!l)
837
837
  throw new Error("Code verifier not found");
838
- return this.codeVerifier = c, localStorage.removeItem(M), await k(this, O, j).call(this, {
839
- code: u,
838
+ return this.codeVerifier = l, this.state = u, localStorage.removeItem(M), await k(this, O, j).call(this, {
839
+ code: c,
840
840
  redirect_uri: n,
841
841
  client_id: r,
842
- code_verifier: c
842
+ code_verifier: l
843
843
  });
844
844
  }), I(this, G, async ({
845
845
  clientId: r,
@@ -851,39 +851,39 @@ class De {
851
851
  refresh_token: n,
852
852
  client_id: r
853
853
  })), this.subscribeToOrderNotifications = () => {
854
- var u, c;
855
- 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);
854
+ var c, u;
855
+ const r = `${y(this, U).wss}/profiles/${(c = this.bearerProfile) == null ? void 0 : c.profile}/orders?access_token=${(u = this.bearerProfile) == null ? void 0 : u.access_token}`, n = new WebSocket(r);
856
856
  return n.addEventListener("open", () => {
857
857
  console.info(`Socket connected: ${r}`);
858
- }), n.addEventListener("error", (v) => {
859
- throw console.error(v), new Error(`Socket error: ${r}`);
860
- }), n.addEventListener("message", (v) => {
861
- var p;
862
- const B = JSON.parse(v.data);
863
- (p = w(this, H).get(B.meta.state)) == null || p(
858
+ }), n.addEventListener("error", (l) => {
859
+ throw console.error(l), new Error(`Socket error: ${r}`);
860
+ }), n.addEventListener("message", (l) => {
861
+ var v;
862
+ const B = JSON.parse(l.data);
863
+ (v = y(this, P).get(B.meta.state)) == null || v(
864
864
  B
865
865
  );
866
866
  }), n.addEventListener("close", () => {
867
867
  console.info(`Socket connection closed: ${r}`);
868
868
  }), n;
869
869
  }, this.auth = async (r) => await k(this, O, j).call(this, r), this.connect = async (r) => await k(this, O, j).call(this, r), this.getAuthFlowURI = (r) => {
870
- const n = oe(w(this, z).api, r);
870
+ const n = oe(y(this, U).api, r);
871
871
  return this.codeVerifier = localStorage.getItem(M), n;
872
- }, this.pkceRequest = (r) => this.getAuthFlowURI(r), this.getEnvironment = () => w(this, z), !t) {
873
- I(this, z, K.environments.sandbox);
872
+ }, this.pkceRequest = (r) => this.getAuthFlowURI(r), this.getEnvironment = () => y(this, U), !t) {
873
+ I(this, U, K.environments.sandbox);
874
874
  return;
875
875
  }
876
876
  if (typeof t == "string")
877
- I(this, z, K.environments[t]);
878
- else if (I(this, z, K.environments[t.environment || "sandbox"]), T) {
877
+ I(this, U, K.environments[t]);
878
+ else if (I(this, U, K.environments[t.environment || "sandbox"]), T) {
879
879
  const { clientId: r, clientSecret: n } = t;
880
- I(this, U, {
880
+ I(this, z, {
881
881
  clientId: r,
882
882
  clientSecret: n
883
883
  });
884
884
  } else {
885
885
  const { clientId: r, redirectUrl: n } = t;
886
- I(this, U, {
886
+ I(this, z, {
887
887
  clientId: r,
888
888
  redirectUrl: n
889
889
  });
@@ -897,20 +897,21 @@ class De {
897
897
  * {@link https://monerium.dev/api-docs#operation/auth}
898
898
  */
899
899
  async authorize(t) {
900
- var c, v;
901
- 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);
900
+ var u, l;
901
+ const r = (t == null ? void 0 : t.clientId) || ((u = y(this, z)) == null ? void 0 : u.clientId), n = (t == null ? void 0 : t.redirectUrl) || ((l = y(this, z)) == null ? void 0 : l.redirectUrl);
902
902
  if (!r)
903
903
  throw new Error("Missing ClientId");
904
904
  if (!n)
905
905
  throw new Error("Missing RedirectUrl");
906
- const u = oe(w(this, z).api, {
906
+ const c = oe(y(this, U).api, {
907
907
  client_id: r,
908
908
  redirect_uri: n,
909
909
  address: t == null ? void 0 : t.address,
910
910
  signature: t == null ? void 0 : t.signature,
911
- chainId: t == null ? void 0 : t.chainId
911
+ chainId: t == null ? void 0 : t.chainId,
912
+ state: t == null ? void 0 : t.state
912
913
  });
913
- window.location.replace(u);
914
+ window.location.replace(c);
914
915
  }
915
916
  /**
916
917
  * Get access to the API
@@ -918,20 +919,20 @@ class De {
918
919
  * @returns boolean to indicate if access has been granted
919
920
  */
920
921
  async getAccess(t) {
921
- var B, p, y;
922
- const r = (t == null ? void 0 : t.clientId) || ((B = w(this, U)) == null ? void 0 : B.clientId);
923
- if ((t == null ? void 0 : t.clientSecret) || ((p = w(this, U)) == null ? void 0 : p.clientSecret)) {
922
+ var v, m, w;
923
+ const r = (t == null ? void 0 : t.clientId) || ((v = y(this, z)) == null ? void 0 : v.clientId);
924
+ if ((t == null ? void 0 : t.clientSecret) || ((m = y(this, z)) == null ? void 0 : m.clientSecret)) {
924
925
  if (!T)
925
926
  throw new Error("Only use client credentials on server side");
926
- return await w(this, G).call(this, w(this, U)), !!this.bearerProfile;
927
+ return await y(this, G).call(this, y(this, z)), !!this.bearerProfile;
927
928
  }
928
- const u = (t == null ? void 0 : t.redirectUrl) || ((y = w(this, U)) == null ? void 0 : y.redirectUrl);
929
+ const c = (t == null ? void 0 : t.redirectUrl) || ((w = y(this, z)) == null ? void 0 : w.redirectUrl);
929
930
  if (!r)
930
931
  throw new Error("Missing ClientId");
931
932
  if (T)
932
933
  throw new Error("This only works client side");
933
- const c = new URLSearchParams(window.location.search).get("code") || void 0, v = localStorage.getItem(D) || void 0;
934
- return v ? await w(this, J).call(this, r, v) : c && await w(this, V).call(this, r, u, c), !!this.bearerProfile;
934
+ const u = new URLSearchParams(window.location.search).get("code") || void 0, l = new URLSearchParams(window.location.search).get("state") || void 0, B = localStorage.getItem(D) || void 0;
935
+ return B ? await y(this, J).call(this, r, B) : u && await y(this, V).call(this, r, c, u, l), !!this.bearerProfile;
935
936
  }
936
937
  // -- Read Methods
937
938
  /**
@@ -1008,14 +1009,14 @@ class De {
1008
1009
  // -- Notifications
1009
1010
  async connectOrderSocket() {
1010
1011
  var t;
1011
- (t = this.bearerProfile) != null && t.access_token && w(this, H).size > 0 && I(this, L, this.subscribeToOrderNotifications());
1012
+ (t = this.bearerProfile) != null && t.access_token && y(this, P).size > 0 && I(this, L, this.subscribeToOrderNotifications());
1012
1013
  }
1013
1014
  /**
1014
1015
  * Cleanups the socket and the subscriptions
1015
1016
  */
1016
1017
  async disconnect() {
1017
1018
  var t;
1018
- T || localStorage.removeItem(M), w(this, H).clear(), (t = w(this, L)) == null || t.close(), I(this, F, void 0), this.bearerProfile = void 0;
1019
+ T || localStorage.removeItem(M), y(this, P).clear(), (t = y(this, L)) == null || t.close(), I(this, F, void 0), this.bearerProfile = void 0;
1019
1020
  }
1020
1021
  /**
1021
1022
  * Revokes access
@@ -1031,7 +1032,7 @@ class De {
1031
1032
  * @param handler The handler to be called when the event is triggered
1032
1033
  */
1033
1034
  subscribeOrders(t, r) {
1034
- w(this, H).set(t, r);
1035
+ y(this, P).set(t, r);
1035
1036
  }
1036
1037
  /**
1037
1038
  * Unsubscribe from MoneriumEvent and close the socket if there are no more subscriptions
@@ -1039,10 +1040,10 @@ class De {
1039
1040
  */
1040
1041
  unsubscribeOrders(t) {
1041
1042
  var r;
1042
- w(this, H).delete(t), w(this, H).size === 0 && ((r = w(this, L)) == null || r.close(), I(this, L, void 0));
1043
+ y(this, P).delete(t), y(this, P).size === 0 && ((r = y(this, L)) == null || r.close(), I(this, L, void 0));
1043
1044
  }
1044
1045
  }
1045
- z = new WeakMap(), F = new WeakMap(), L = new WeakMap(), H = new WeakMap(), U = new WeakMap(), O = new WeakSet(), j = async function(t) {
1046
+ U = new WeakMap(), F = new WeakMap(), L = new WeakMap(), P = new WeakMap(), z = new WeakMap(), O = new WeakSet(), j = async function(t) {
1046
1047
  let r;
1047
1048
  if (ie(t))
1048
1049
  r = { ...t, grant_type: "authorization_code" };
@@ -1053,22 +1054,22 @@ z = new WeakMap(), F = new WeakMap(), L = new WeakMap(), H = new WeakMap(), U =
1053
1054
  else
1054
1055
  throw new Error("Authorization grant type could not be detected.");
1055
1056
  return await k(this, E, $).call(this, "post", "auth/token", r, !0).then((n) => {
1056
- var u;
1057
+ var c;
1057
1058
  this.bearerProfile = n, this.isAuthorized = !!n, I(this, F, `Bearer ${n == null ? void 0 : n.access_token}`), T || window.localStorage.setItem(
1058
1059
  D,
1059
- ((u = this.bearerProfile) == null ? void 0 : u.refresh_token) || ""
1060
+ ((c = this.bearerProfile) == null ? void 0 : c.refresh_token) || ""
1060
1061
  );
1061
1062
  }).catch((n) => {
1062
1063
  throw T || (localStorage.removeItem(M), localStorage.removeItem(D), se()), new Error(n == null ? void 0 : n.message);
1063
1064
  }), ie(t) && se(), this.bearerProfile;
1064
- }, E = new WeakSet(), $ = async function(t, r, n, u) {
1065
+ }, E = new WeakSet(), $ = async function(t, r, n, c) {
1065
1066
  return je(
1066
- `${w(this, z).api}/${r}`,
1067
+ `${y(this, U).api}/${r}`,
1067
1068
  t,
1068
- u ? Z(n) : n,
1069
+ c ? Z(n) : n,
1069
1070
  {
1070
- Authorization: w(this, F) || "",
1071
- "Content-Type": `application/${u ? "x-www-form-urlencoded" : "json"}`
1071
+ Authorization: y(this, F) || "",
1072
+ "Content-Type": `application/${c ? "x-www-form-urlencoded" : "json"}`
1072
1073
  }
1073
1074
  );
1074
1075
  }, V = new WeakMap(), G = new WeakMap(), J = new WeakMap();
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monerium/sdk",
3
- "version": "2.10.0",
3
+ "version": "2.11.0",
4
4
  "description": "Everything you need to interact with the Monerium API - an electronic money issuer.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/dist/types.d.ts CHANGED
@@ -10,7 +10,7 @@ export type Config = {
10
10
  };
11
11
  };
12
12
  export type ENV = 'sandbox' | 'production';
13
- export type EthereumTestnet = 'goerli';
13
+ export type EthereumTestnet = 'sepolia';
14
14
  export type GnosisTestnet = 'chiado';
15
15
  export type PolygonTestnet = 'mumbai';
16
16
  export type Chain = 'ethereum' | 'gnosis' | 'polygon';
@@ -18,7 +18,7 @@ export type Networks = EthereumTestnet | GnosisTestnet | PolygonTestnet | 'mainn
18
18
  export type NetworkSemiStrict<C extends Chain> = C extends 'ethereum' ? EthereumTestnet | 'mainnet' : C extends 'gnosis' ? GnosisTestnet | 'mainnet' : C extends 'polygon' ? PolygonTestnet | 'mainnet' : never;
19
19
  export type NetworkStrict<C extends Chain, E extends ENV> = E extends 'production' ? 'mainnet' : E extends 'sandbox' ? C extends 'ethereum' ? EthereumTestnet : C extends 'gnosis' ? GnosisTestnet : C extends 'polygon' ? PolygonTestnet : never : never;
20
20
  export type Network<C extends Chain = Chain, E extends ENV = ENV> = C extends Chain ? E extends ENV ? NetworkStrict<C, E> & NetworkSemiStrict<C> : never : never;
21
- export type ChainId = number | 1 | 5 | 100 | 137 | 10200 | 80001;
21
+ export type ChainId = number | 1 | 11155111 | 100 | 137 | 10200 | 80001;
22
22
  export declare enum Currency {
23
23
  eur = "eur"
24
24
  }
@@ -359,6 +359,7 @@ export type AuthFlowOptions = {
359
359
  address?: string;
360
360
  signature?: string;
361
361
  chainId?: ChainId;
362
+ state?: string;
362
363
  };
363
364
  export type ClientCredentials = {
364
365
  clientId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monerium/sdk",
3
- "version": "2.10.0",
3
+ "version": "2.11.0",
4
4
  "description": "Everything you need to interact with the Monerium API - an electronic money issuer.",
5
5
  "license": "MIT",
6
6
  "repository": {