@monerium/sdk 2.8.2 → 2.9.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 +14 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +141 -123
- package/dist/package.json +1 -1
- package/dist/types.d.ts +23 -11
- package/dist/utils.d.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.9.0](https://github.com/monerium/js-sdk/compare/sdk-v2.8.3...sdk-v2.9.0) (2023-12-15)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* use chainId instead of network and chain ([9d4f0dd](https://github.com/monerium/js-sdk/commit/9d4f0ddec29d68fe56a0c65074310d842168932e))
|
|
9
|
+
|
|
10
|
+
## [2.8.3](https://github.com/monerium/js-sdk/compare/sdk-v2.8.2...sdk-v2.8.3) (2023-12-11)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* timezone issues in unit tests, closes [#70](https://github.com/monerium/js-sdk/issues/70) ([fc10817](https://github.com/monerium/js-sdk/commit/fc10817ac5ad064c75a2c275feb070f2eafc7f6a))
|
|
16
|
+
|
|
3
17
|
## [2.8.2](https://github.com/monerium/js-sdk/compare/sdk-v2.8.1...sdk-v2.8.2) (2023-12-11)
|
|
4
18
|
|
|
5
19
|
|
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)),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)=>(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,n)=>{const u=`${(n==null?void 0:n.toUpperCase())||"EUR"}`;return r?`Send ${u} ${e} to ${t} on ${ee(r)} at ${Y(new Date)}`:`Send ${u} ${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",D="monerium.sdk.refresh_token",Ae={LINK_MESSAGE:xe,STORAGE_CODE_VERIFIER:M,STORAGE_REFRESH_TOKEN:D};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 $e={},Re=Object.freeze(Object.defineProperty({__proto__:null,default:$e},Symbol.toStringTag,{value:"Module"})),Oe=Ee(Re);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 W=0;W<j;W+=S)this._doProcessBlock(h,W);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],W=(U<<15|U>>>17)^(U<<13|U>>>19)^U>>>10;g[k]=j+g[k-7]+W+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,F,L,z,P,H,q,E,$,V,G,J;class Fe{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=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(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 B(this,E,$).call(this,"get","auth/context")}getProfile(t){return B(this,E,$).call(this,"get",`profiles/${t}`)}getBalances(t){return t?B(this,E,$).call(this,"get",`profiles/${t}/balances`):B(this,E,$).call(this,"get","balances")}getOrders(t){const r=Q(t);return B(this,E,$).call(this,"get",`orders?${r}`)}getOrder(t){return B(this,E,$).call(this,"get",`orders/${t}`)}getTokens(){return B(this,E,$).call(this,"get","tokens")}linkAddress(t,r){return B(this,E,$).call(this,"post",`profiles/${t}/addresses`,JSON.stringify(r))}placeOrder(t,r){const n={...t,kind:"redeem",currency:"eur"};return r?B(this,E,$).call(this,"post",`profiles/${r}/orders`,JSON.stringify(n)):B(this,E,$).call(this,"post","orders",JSON.stringify(n))}uploadSupportingDocument(t){const r=Q(t);return B(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||sessionStorage.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||sessionStorage.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,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,$).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.sessionStorage.setItem(D,((u=this.bearerProfile)==null?void 0:u.refresh_token)||"")}).catch(n=>{throw T||(sessionStorage.removeItem(M),sessionStorage.removeItem(D),se()),new Error(n==null?void 0:n.message)}),oe(t)&&se(),this.bearerProfile},E=new WeakSet,$=async function(t,r,n,u){return Ne(`${w(this,O).api}/${r}`,t,u?Q(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=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;
|
|
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 se;function me(){return se||(se=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 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||f).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 B=a[S>>>2]>>>24-S%4*8&255;o[h+S>>>2]|=B<<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={},f=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)))}},d=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,B=S*4,x=_/B;s?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);o=h.splice(0,N),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=d.extend({cfg:m.extend(),init:function(s){this.cfg=this.cfg.extend(s),this.reset()},reset:function(){d.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})}(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,s=i<<16|d<<8|A,o=0;o<4&&l+o*.75<g;o++)f.push(b.charAt(s>>>6*(3-o)&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 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,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],s=i[2],o=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&s^A&s,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=o+ne|0,o=s,s=A,A=d,d=ne+Be|0}i[0]=i[0]+d|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 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)),oe=(e,t)=>{const r=Le(),n=Ne(r);return sessionStorage.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=sessionStorage.getItem(M)||"";if(!c)throw new Error("Code verifier not found");return this.codeVerifier=c,sessionStorage.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=oe(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,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=oe(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(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||sessionStorage.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||sessionStorage.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.sessionStorage.setItem(D,((u=this.bearerProfile)==null?void 0:u.refresh_token)||"")}).catch(n=>{throw T||(sessionStorage.removeItem(M),sessionStorage.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;
|
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var
|
|
1
|
+
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) => (
|
|
5
|
+
var w = (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);
|
|
9
|
-
}, I = (e, t, r, n) => (
|
|
10
|
-
var k = (e, t, r) => (
|
|
11
|
-
var
|
|
12
|
-
const
|
|
9
|
+
}, I = (e, t, r, n) => (X(e, t, "write to private field"), n ? n.call(e, r) : t.set(e, r), r);
|
|
10
|
+
var k = (e, t, r) => (X(e, t, "access private method"), r);
|
|
11
|
+
var we = /* @__PURE__ */ ((e) => (e.eur = "eur", e))(we || {}), ye = /* @__PURE__ */ ((e) => (e.corporate = "corporate", e.personal = "personal", e))(ye || {}), me = /* @__PURE__ */ ((e) => (e.read = "read", e.write = "write", e))(me || {}), _e = /* @__PURE__ */ ((e) => (e.absent = "absent", e.submitted = "submitted", e.pending = "pending", e.confirmed = "confirmed", e))(_e || {}), be = /* @__PURE__ */ ((e) => (e.approved = "approved", e.rejected = "rejected", e.unknown = "unknown", e))(be || {}), Se = /* @__PURE__ */ ((e) => (e.requested = "requested", e.approved = "approved", e.pending = "pending", e))(Se || {}), Be = /* @__PURE__ */ ((e) => (e.iban = "iban", e.scan = "scan", e.chain = "chain", e))(Be || {}), ke = /* @__PURE__ */ ((e) => (e.redeem = "redeem", e.issue = "issue", e))(ke || {}), Ce = /* @__PURE__ */ ((e) => (e.placed = "placed", e.pending = "pending", e.processed = "processed", e.rejected = "rejected", e))(Ce || {});
|
|
12
|
+
const re = (e) => {
|
|
13
13
|
if (e.toString() === "Invalid Date")
|
|
14
14
|
throw e;
|
|
15
15
|
const t = (n) => n < 10 ? "0" + n : n, r = (n) => {
|
|
@@ -21,15 +21,15 @@ const ee = (e) => {
|
|
|
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
23
|
const u = `${(n == null ? void 0 : n.toUpperCase()) || "EUR"}`;
|
|
24
|
-
return r ? `Send ${u} ${e} to ${t} on ${
|
|
24
|
+
return r ? `Send ${u} ${e} to ${t} on ${ee(
|
|
25
25
|
r
|
|
26
|
-
)} at ${
|
|
27
|
-
},
|
|
26
|
+
)} at ${re(/* @__PURE__ */ new Date())}` : `Send ${u} ${e} to ${t} at ${re(/* @__PURE__ */ new Date())}`;
|
|
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(
|
|
30
30
|
([r, n]) => `${encodeURIComponent(r)}=${encodeURIComponent(n)}`
|
|
31
31
|
).join("&") : "";
|
|
32
|
-
},
|
|
32
|
+
}, ee = (e) => {
|
|
33
33
|
switch (e) {
|
|
34
34
|
case 1:
|
|
35
35
|
case 5:
|
|
@@ -43,7 +43,7 @@ const ee = (e) => {
|
|
|
43
43
|
default:
|
|
44
44
|
throw new Error(`Chain not supported: ${e}`);
|
|
45
45
|
}
|
|
46
|
-
},
|
|
46
|
+
}, ae = (e) => {
|
|
47
47
|
switch (e) {
|
|
48
48
|
case 1:
|
|
49
49
|
case 100:
|
|
@@ -58,7 +58,17 @@ const ee = (e) => {
|
|
|
58
58
|
default:
|
|
59
59
|
throw new Error(`Network not supported: ${e}`);
|
|
60
60
|
}
|
|
61
|
-
},
|
|
61
|
+
}, Q = (e) => {
|
|
62
|
+
if (e != null && e.chainId) {
|
|
63
|
+
const { chainId: t, ...r } = e;
|
|
64
|
+
return {
|
|
65
|
+
...r,
|
|
66
|
+
chain: ee(t),
|
|
67
|
+
network: ae(t)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return e;
|
|
71
|
+
}, K = {
|
|
62
72
|
environments: {
|
|
63
73
|
production: {
|
|
64
74
|
api: "https://api.monerium.app",
|
|
@@ -71,16 +81,16 @@ const ee = (e) => {
|
|
|
71
81
|
wss: "wss://api.monerium.dev"
|
|
72
82
|
}
|
|
73
83
|
}
|
|
74
|
-
},
|
|
75
|
-
LINK_MESSAGE:
|
|
84
|
+
}, xe = "I hereby declare that I am the address owner.", M = "monerium.sdk.code_verifier", D = "monerium.sdk.refresh_token", We = {
|
|
85
|
+
LINK_MESSAGE: xe,
|
|
76
86
|
STORAGE_CODE_VERIFIER: M,
|
|
77
87
|
STORAGE_REFRESH_TOKEN: D
|
|
78
88
|
};
|
|
79
|
-
var
|
|
80
|
-
function
|
|
89
|
+
var q = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
90
|
+
function ce(e) {
|
|
81
91
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
82
92
|
}
|
|
83
|
-
function
|
|
93
|
+
function Ae(e) {
|
|
84
94
|
if (e.__esModule)
|
|
85
95
|
return e;
|
|
86
96
|
var t = e.default;
|
|
@@ -101,26 +111,26 @@ function xe(e) {
|
|
|
101
111
|
});
|
|
102
112
|
}), r;
|
|
103
113
|
}
|
|
104
|
-
var
|
|
105
|
-
function
|
|
114
|
+
var ue = { exports: {} };
|
|
115
|
+
function Ee(e) {
|
|
106
116
|
throw new Error('Could not dynamically require "' + e + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
107
117
|
}
|
|
108
|
-
var
|
|
109
|
-
const
|
|
118
|
+
var Y = { exports: {} };
|
|
119
|
+
const Ie = {}, $e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
110
120
|
__proto__: null,
|
|
111
|
-
default:
|
|
112
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
113
|
-
var
|
|
114
|
-
function
|
|
115
|
-
return
|
|
121
|
+
default: Ie
|
|
122
|
+
}, Symbol.toStringTag, { value: "Module" })), Re = /* @__PURE__ */ Ae($e);
|
|
123
|
+
var ne;
|
|
124
|
+
function he() {
|
|
125
|
+
return ne || (ne = 1, function(e, t) {
|
|
116
126
|
(function(r, n) {
|
|
117
127
|
e.exports = n();
|
|
118
|
-
})(
|
|
128
|
+
})(q, function() {
|
|
119
129
|
var r = r || function(n, u) {
|
|
120
130
|
var c;
|
|
121
|
-
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
|
|
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")
|
|
122
132
|
try {
|
|
123
|
-
c =
|
|
133
|
+
c = Re;
|
|
124
134
|
} catch {
|
|
125
135
|
}
|
|
126
136
|
var v = function() {
|
|
@@ -259,7 +269,7 @@ function ce() {
|
|
|
259
269
|
* var string = wordArray.toString(CryptoJS.enc.Utf8);
|
|
260
270
|
*/
|
|
261
271
|
toString: function(s) {
|
|
262
|
-
return (s ||
|
|
272
|
+
return (s || f).stringify(this);
|
|
263
273
|
},
|
|
264
274
|
/**
|
|
265
275
|
* Concatenates a word array to this word array.
|
|
@@ -326,7 +336,7 @@ function ce() {
|
|
|
326
336
|
o.push(v());
|
|
327
337
|
return new g.init(o, s);
|
|
328
338
|
}
|
|
329
|
-
}), b = p.enc = {},
|
|
339
|
+
}), b = p.enc = {}, f = b.Hex = {
|
|
330
340
|
/**
|
|
331
341
|
* Converts a word array to a hex string.
|
|
332
342
|
*
|
|
@@ -441,7 +451,7 @@ function ce() {
|
|
|
441
451
|
parse: function(s) {
|
|
442
452
|
return l.parse(unescape(encodeURIComponent(s)));
|
|
443
453
|
}
|
|
444
|
-
},
|
|
454
|
+
}, d = y.BufferedBlockAlgorithm = m.extend({
|
|
445
455
|
/**
|
|
446
456
|
* Resets this block algorithm's data buffer to its initial state.
|
|
447
457
|
*
|
|
@@ -482,11 +492,11 @@ function ce() {
|
|
|
482
492
|
_process: function(s) {
|
|
483
493
|
var o, a = this._data, h = a.words, _ = a.sigBytes, S = this.blockSize, C = S * 4, x = _ / C;
|
|
484
494
|
s ? x = n.ceil(x) : x = n.max((x | 0) - this._minBufferSize, 0);
|
|
485
|
-
var
|
|
486
|
-
if (
|
|
487
|
-
for (var W = 0; W <
|
|
495
|
+
var N = x * S, P = n.min(N * 4, _);
|
|
496
|
+
if (N) {
|
|
497
|
+
for (var W = 0; W < N; W += S)
|
|
488
498
|
this._doProcessBlock(h, W);
|
|
489
|
-
o = h.splice(0,
|
|
499
|
+
o = h.splice(0, N), a.sigBytes -= P;
|
|
490
500
|
}
|
|
491
501
|
return new g.init(o, P);
|
|
492
502
|
},
|
|
@@ -505,7 +515,7 @@ function ce() {
|
|
|
505
515
|
},
|
|
506
516
|
_minBufferSize: 0
|
|
507
517
|
});
|
|
508
|
-
y.Hasher =
|
|
518
|
+
y.Hasher = d.extend({
|
|
509
519
|
/**
|
|
510
520
|
* Configuration options.
|
|
511
521
|
*/
|
|
@@ -530,7 +540,7 @@ function ce() {
|
|
|
530
540
|
* hasher.reset();
|
|
531
541
|
*/
|
|
532
542
|
reset: function() {
|
|
533
|
-
|
|
543
|
+
d.reset.call(this), this._doReset();
|
|
534
544
|
},
|
|
535
545
|
/**
|
|
536
546
|
* Updates this hasher with a message.
|
|
@@ -609,12 +619,12 @@ function ce() {
|
|
|
609
619
|
}(Math);
|
|
610
620
|
return r;
|
|
611
621
|
});
|
|
612
|
-
}(
|
|
622
|
+
}(Y)), Y.exports;
|
|
613
623
|
}
|
|
614
624
|
(function(e, t) {
|
|
615
625
|
(function(r, n) {
|
|
616
|
-
e.exports = n(
|
|
617
|
-
})(
|
|
626
|
+
e.exports = n(he());
|
|
627
|
+
})(q, function(r) {
|
|
618
628
|
return function() {
|
|
619
629
|
var n = r, u = n.lib, c = u.WordArray, v = n.enc;
|
|
620
630
|
v.Base64url = {
|
|
@@ -637,14 +647,14 @@ function ce() {
|
|
|
637
647
|
y === void 0 && (y = !0);
|
|
638
648
|
var m = p.words, g = p.sigBytes, b = y ? this._safe_map : this._map;
|
|
639
649
|
p.clamp();
|
|
640
|
-
for (var
|
|
641
|
-
for (var i = m[l >>> 2] >>> 24 - l % 4 * 8 & 255,
|
|
642
|
-
|
|
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, s = i << 16 | d << 8 | A, o = 0; o < 4 && l + o * 0.75 < g; o++)
|
|
652
|
+
f.push(b.charAt(s >>> 6 * (3 - o) & 63));
|
|
643
653
|
var a = b.charAt(64);
|
|
644
654
|
if (a)
|
|
645
|
-
for (;
|
|
646
|
-
|
|
647
|
-
return
|
|
655
|
+
for (; f.length % 4; )
|
|
656
|
+
f.push(a);
|
|
657
|
+
return f.join("");
|
|
648
658
|
},
|
|
649
659
|
/**
|
|
650
660
|
* Converts a Base64url string to a word array.
|
|
@@ -666,8 +676,8 @@ function ce() {
|
|
|
666
676
|
var m = p.length, g = y ? this._safe_map : this._map, b = this._reverseMap;
|
|
667
677
|
if (!b) {
|
|
668
678
|
b = this._reverseMap = [];
|
|
669
|
-
for (var
|
|
670
|
-
b[g.charCodeAt(
|
|
679
|
+
for (var f = 0; f < g.length; f++)
|
|
680
|
+
b[g.charCodeAt(f)] = f;
|
|
671
681
|
}
|
|
672
682
|
var l = g.charAt(64);
|
|
673
683
|
if (l) {
|
|
@@ -680,27 +690,27 @@ function ce() {
|
|
|
680
690
|
_safe_map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
|
|
681
691
|
};
|
|
682
692
|
function B(p, y, m) {
|
|
683
|
-
for (var g = [], b = 0,
|
|
684
|
-
if (
|
|
685
|
-
var l = m[p.charCodeAt(
|
|
686
|
-
g[b >>> 2] |=
|
|
693
|
+
for (var g = [], b = 0, f = 0; f < y; f++)
|
|
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;
|
|
696
|
+
g[b >>> 2] |= d << 24 - b % 4 * 8, b++;
|
|
687
697
|
}
|
|
688
698
|
return c.create(g, b);
|
|
689
699
|
}
|
|
690
700
|
}(), r.enc.Base64url;
|
|
691
701
|
});
|
|
692
|
-
})(
|
|
693
|
-
var
|
|
694
|
-
const
|
|
695
|
-
var
|
|
702
|
+
})(ue);
|
|
703
|
+
var ze = ue.exports;
|
|
704
|
+
const Ue = /* @__PURE__ */ ce(ze);
|
|
705
|
+
var fe = { exports: {} };
|
|
696
706
|
(function(e, t) {
|
|
697
707
|
(function(r, n) {
|
|
698
|
-
e.exports = n(
|
|
699
|
-
})(
|
|
708
|
+
e.exports = n(he());
|
|
709
|
+
})(q, function(r) {
|
|
700
710
|
return function(n) {
|
|
701
711
|
var u = r, c = u.lib, v = c.WordArray, B = c.Hasher, p = u.algo, y = [], m = [];
|
|
702
712
|
(function() {
|
|
703
|
-
function
|
|
713
|
+
function f(A) {
|
|
704
714
|
for (var s = n.sqrt(A), o = 2; o <= s; o++)
|
|
705
715
|
if (!(A % o))
|
|
706
716
|
return !1;
|
|
@@ -709,41 +719,41 @@ var ue = { exports: {} };
|
|
|
709
719
|
function l(A) {
|
|
710
720
|
return (A - (A | 0)) * 4294967296 | 0;
|
|
711
721
|
}
|
|
712
|
-
for (var i = 2,
|
|
713
|
-
|
|
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++;
|
|
714
724
|
})();
|
|
715
725
|
var g = [], b = p.SHA256 = B.extend({
|
|
716
726
|
_doReset: function() {
|
|
717
727
|
this._hash = new v.init(y.slice(0));
|
|
718
728
|
},
|
|
719
|
-
_doProcessBlock: function(
|
|
720
|
-
for (var i = this._hash.words,
|
|
729
|
+
_doProcessBlock: function(f, l) {
|
|
730
|
+
for (var i = this._hash.words, d = i[0], A = i[1], s = i[2], o = i[3], a = i[4], h = i[5], _ = i[6], S = i[7], C = 0; C < 64; C++) {
|
|
721
731
|
if (C < 16)
|
|
722
|
-
g[C] =
|
|
732
|
+
g[C] = f[l + C] | 0;
|
|
723
733
|
else {
|
|
724
|
-
var x = g[C - 15],
|
|
725
|
-
g[C] =
|
|
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;
|
|
735
|
+
g[C] = N + g[C - 7] + W + g[C - 16];
|
|
726
736
|
}
|
|
727
|
-
var
|
|
728
|
-
S = _, _ = h, h = a, a = o +
|
|
737
|
+
var de = a & h ^ ~a & _, le = d & A ^ d & s ^ A & s, 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;
|
|
738
|
+
S = _, _ = h, h = a, a = o + te | 0, o = s, s = A, A = d, d = te + ge | 0;
|
|
729
739
|
}
|
|
730
|
-
i[0] = i[0] +
|
|
740
|
+
i[0] = i[0] + d | 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;
|
|
731
741
|
},
|
|
732
742
|
_doFinalize: function() {
|
|
733
|
-
var
|
|
734
|
-
return l[
|
|
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;
|
|
735
745
|
},
|
|
736
746
|
clone: function() {
|
|
737
|
-
var
|
|
738
|
-
return
|
|
747
|
+
var f = B.clone.call(this);
|
|
748
|
+
return f._hash = this._hash.clone(), f;
|
|
739
749
|
}
|
|
740
750
|
});
|
|
741
751
|
u.SHA256 = B._createHelper(b), u.HmacSHA256 = B._createHmacHelper(b);
|
|
742
752
|
}(Math), r.SHA256;
|
|
743
753
|
});
|
|
744
|
-
})(
|
|
745
|
-
var
|
|
746
|
-
const
|
|
754
|
+
})(fe);
|
|
755
|
+
var He = fe.exports;
|
|
756
|
+
const Pe = /* @__PURE__ */ ce(He), Oe = (e, t) => {
|
|
747
757
|
const {
|
|
748
758
|
client_id: r,
|
|
749
759
|
redirect_uri: n,
|
|
@@ -757,10 +767,10 @@ const He = /* @__PURE__ */ ie(Ue), Pe = (e, t) => {
|
|
|
757
767
|
} = e, g = y ? {
|
|
758
768
|
address: y,
|
|
759
769
|
...m !== void 0 ? { signature: m } : {},
|
|
760
|
-
...v !== void 0 || B !== void 0 ? { chain: v ?
|
|
761
|
-
...v !== void 0 || p !== void 0 ? { network: v ?
|
|
770
|
+
...v !== void 0 || B !== void 0 ? { chain: v ? ee(v) : B } : {},
|
|
771
|
+
...v !== void 0 || p !== void 0 ? { network: v ? ae(v) : p } : {}
|
|
762
772
|
} : {};
|
|
763
|
-
return
|
|
773
|
+
return Z({
|
|
764
774
|
client_id: r,
|
|
765
775
|
redirect_uri: n,
|
|
766
776
|
...u !== void 0 ? { scope: u } : {},
|
|
@@ -770,23 +780,23 @@ const He = /* @__PURE__ */ ie(Ue), Pe = (e, t) => {
|
|
|
770
780
|
response_type: "code",
|
|
771
781
|
...g
|
|
772
782
|
});
|
|
773
|
-
},
|
|
783
|
+
}, Te = () => {
|
|
774
784
|
let e = "";
|
|
775
785
|
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", r = t.length;
|
|
776
786
|
let n = 0;
|
|
777
787
|
for (; n < 128; )
|
|
778
788
|
e += t.charAt(Math.floor(Math.random() * r)), n += 1;
|
|
779
789
|
return e;
|
|
780
|
-
},
|
|
781
|
-
const r =
|
|
782
|
-
return sessionStorage.setItem(M, r || ""), `${e}/auth?${
|
|
783
|
-
},
|
|
790
|
+
}, Me = (e) => Ue.stringify(Pe(e)), se = (e, t) => {
|
|
791
|
+
const r = Te(), n = Me(r);
|
|
792
|
+
return sessionStorage.setItem(M, r || ""), `${e}/auth?${Oe(t, n)}`;
|
|
793
|
+
}, oe = () => {
|
|
784
794
|
const e = window.location.href;
|
|
785
795
|
if (!e || !(e != null && e.includes("?")))
|
|
786
796
|
return;
|
|
787
797
|
const [t, r] = e.split("?");
|
|
788
798
|
r && window.history.replaceState(null, "", t);
|
|
789
|
-
},
|
|
799
|
+
}, ie = (e) => e.code != null, Le = (e) => e.refresh_token != null, Ne = (e) => e.client_secret != null, je = async (e, t, r, n) => {
|
|
790
800
|
const u = await fetch(`${e}`, {
|
|
791
801
|
method: t,
|
|
792
802
|
headers: n,
|
|
@@ -803,8 +813,8 @@ const He = /* @__PURE__ */ ie(Ue), Pe = (e, t) => {
|
|
|
803
813
|
throw c;
|
|
804
814
|
return c;
|
|
805
815
|
}, T = typeof window > "u";
|
|
806
|
-
var z,
|
|
807
|
-
class
|
|
816
|
+
var z, F, L, H, U, O, j, E, $, V, G, J;
|
|
817
|
+
class De {
|
|
808
818
|
constructor(t) {
|
|
809
819
|
/**
|
|
810
820
|
* {@link https://monerium.dev/api-docs#operation/auth-token}
|
|
@@ -813,7 +823,7 @@ class We {
|
|
|
813
823
|
// -- Helper Methods
|
|
814
824
|
R(this, E);
|
|
815
825
|
R(this, z, void 0);
|
|
816
|
-
R(this,
|
|
826
|
+
R(this, F, void 0);
|
|
817
827
|
/** The socket will be available after subscribing to an event */
|
|
818
828
|
R(this, L, void 0);
|
|
819
829
|
R(this, H, void 0);
|
|
@@ -857,15 +867,15 @@ class We {
|
|
|
857
867
|
console.info(`Socket connection closed: ${r}`);
|
|
858
868
|
}), n;
|
|
859
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) => {
|
|
860
|
-
const n =
|
|
870
|
+
const n = se(w(this, z).api, r);
|
|
861
871
|
return this.codeVerifier = sessionStorage.getItem(M), n;
|
|
862
872
|
}, this.pkceRequest = (r) => this.getAuthFlowURI(r), this.getEnvironment = () => w(this, z), !t) {
|
|
863
|
-
I(this, z,
|
|
873
|
+
I(this, z, K.environments.sandbox);
|
|
864
874
|
return;
|
|
865
875
|
}
|
|
866
876
|
if (typeof t == "string")
|
|
867
|
-
I(this, z,
|
|
868
|
-
else if (I(this, z,
|
|
877
|
+
I(this, z, K.environments[t]);
|
|
878
|
+
else if (I(this, z, K.environments[t.environment || "sandbox"]), T) {
|
|
869
879
|
const { clientId: r, clientSecret: n } = t;
|
|
870
880
|
I(this, U, {
|
|
871
881
|
clientId: r,
|
|
@@ -893,7 +903,7 @@ class We {
|
|
|
893
903
|
throw new Error("Missing ClientId");
|
|
894
904
|
if (!n)
|
|
895
905
|
throw new Error("Missing RedirectUrl");
|
|
896
|
-
const u =
|
|
906
|
+
const u = se(w(this, z).api, {
|
|
897
907
|
client_id: r,
|
|
898
908
|
redirect_uri: n,
|
|
899
909
|
address: t == null ? void 0 : t.address,
|
|
@@ -949,7 +959,7 @@ class We {
|
|
|
949
959
|
* {@link https://monerium.dev/api-docs#operation/orders}
|
|
950
960
|
*/
|
|
951
961
|
getOrders(t) {
|
|
952
|
-
const r =
|
|
962
|
+
const r = Z(t);
|
|
953
963
|
return k(this, E, $).call(this, "get", `orders?${r}`);
|
|
954
964
|
}
|
|
955
965
|
/**
|
|
@@ -969,20 +979,28 @@ class We {
|
|
|
969
979
|
* {@link https://monerium.dev/api-docs#operation/profile-addresses}
|
|
970
980
|
*/
|
|
971
981
|
linkAddress(t, r) {
|
|
972
|
-
return k(this, E, $).call(this, "post", `profiles/${t}/addresses`, JSON.stringify(r));
|
|
982
|
+
return r = Q(r), r.accounts = r.accounts.map((n) => Q(n)), k(this, E, $).call(this, "post", `profiles/${t}/addresses`, JSON.stringify(r));
|
|
973
983
|
}
|
|
974
984
|
/**
|
|
975
985
|
* {@link https://monerium.dev/api-docs#operation/post-orders}
|
|
976
986
|
*/
|
|
977
987
|
placeOrder(t, r) {
|
|
978
|
-
const n = {
|
|
988
|
+
const n = {
|
|
989
|
+
kind: "redeem",
|
|
990
|
+
currency: "eur",
|
|
991
|
+
...Q(t),
|
|
992
|
+
counterpart: {
|
|
993
|
+
...t.counterpart,
|
|
994
|
+
identifier: Q(t.counterpart.identifier)
|
|
995
|
+
}
|
|
996
|
+
};
|
|
979
997
|
return r ? k(this, E, $).call(this, "post", `profiles/${r}/orders`, JSON.stringify(n)) : k(this, E, $).call(this, "post", "orders", JSON.stringify(n));
|
|
980
998
|
}
|
|
981
999
|
/**
|
|
982
1000
|
* {@link https://monerium.dev/api-docs#operation/supporting-document}
|
|
983
1001
|
*/
|
|
984
1002
|
uploadSupportingDocument(t) {
|
|
985
|
-
const r =
|
|
1003
|
+
const r = Z(
|
|
986
1004
|
t
|
|
987
1005
|
);
|
|
988
1006
|
return k(this, E, $).call(this, "post", "files/supporting-document", r, !0);
|
|
@@ -997,7 +1015,7 @@ class We {
|
|
|
997
1015
|
*/
|
|
998
1016
|
async disconnect() {
|
|
999
1017
|
var t;
|
|
1000
|
-
T || sessionStorage.removeItem(M), w(this, H).clear(), (t = w(this, L)) == null || t.close(), I(this,
|
|
1018
|
+
T || sessionStorage.removeItem(M), w(this, H).clear(), (t = w(this, L)) == null || t.close(), I(this, F, void 0), this.bearerProfile = void 0;
|
|
1001
1019
|
}
|
|
1002
1020
|
/**
|
|
1003
1021
|
* Revokes access
|
|
@@ -1024,50 +1042,50 @@ class We {
|
|
|
1024
1042
|
w(this, H).delete(t), w(this, H).size === 0 && ((r = w(this, L)) == null || r.close(), I(this, L, void 0));
|
|
1025
1043
|
}
|
|
1026
1044
|
}
|
|
1027
|
-
z = new WeakMap(),
|
|
1045
|
+
z = new WeakMap(), F = new WeakMap(), L = new WeakMap(), H = new WeakMap(), U = new WeakMap(), O = new WeakSet(), j = async function(t) {
|
|
1028
1046
|
let r;
|
|
1029
|
-
if (
|
|
1047
|
+
if (ie(t))
|
|
1030
1048
|
r = { ...t, grant_type: "authorization_code" };
|
|
1031
|
-
else if (Me(t))
|
|
1032
|
-
r = { ...t, grant_type: "refresh_token" };
|
|
1033
1049
|
else if (Le(t))
|
|
1050
|
+
r = { ...t, grant_type: "refresh_token" };
|
|
1051
|
+
else if (Ne(t))
|
|
1034
1052
|
r = { ...t, grant_type: "client_credentials" };
|
|
1035
1053
|
else
|
|
1036
1054
|
throw new Error("Authorization grant type could not be detected.");
|
|
1037
1055
|
return await k(this, E, $).call(this, "post", "auth/token", r, !0).then((n) => {
|
|
1038
1056
|
var u;
|
|
1039
|
-
this.bearerProfile = n, this.isAuthorized = !!n, I(this,
|
|
1057
|
+
this.bearerProfile = n, this.isAuthorized = !!n, I(this, F, `Bearer ${n == null ? void 0 : n.access_token}`), T || window.sessionStorage.setItem(
|
|
1040
1058
|
D,
|
|
1041
1059
|
((u = this.bearerProfile) == null ? void 0 : u.refresh_token) || ""
|
|
1042
1060
|
);
|
|
1043
1061
|
}).catch((n) => {
|
|
1044
|
-
throw T || (sessionStorage.removeItem(M), sessionStorage.removeItem(D),
|
|
1045
|
-
}),
|
|
1062
|
+
throw T || (sessionStorage.removeItem(M), sessionStorage.removeItem(D), oe()), new Error(n == null ? void 0 : n.message);
|
|
1063
|
+
}), ie(t) && oe(), this.bearerProfile;
|
|
1046
1064
|
}, E = new WeakSet(), $ = async function(t, r, n, u) {
|
|
1047
|
-
return
|
|
1065
|
+
return je(
|
|
1048
1066
|
`${w(this, z).api}/${r}`,
|
|
1049
1067
|
t,
|
|
1050
|
-
u ?
|
|
1068
|
+
u ? Z(n) : n,
|
|
1051
1069
|
{
|
|
1052
|
-
Authorization: w(this,
|
|
1070
|
+
Authorization: w(this, F) || "",
|
|
1053
1071
|
"Content-Type": `application/${u ? "x-www-form-urlencoded" : "json"}`
|
|
1054
1072
|
}
|
|
1055
1073
|
);
|
|
1056
1074
|
}, V = new WeakMap(), G = new WeakMap(), J = new WeakMap();
|
|
1057
1075
|
export {
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1076
|
+
Se as AccountState,
|
|
1077
|
+
we as Currency,
|
|
1078
|
+
be as KYCOutcome,
|
|
1079
|
+
_e as KYCState,
|
|
1080
|
+
De as MoneriumClient,
|
|
1081
|
+
ke as OrderKind,
|
|
1082
|
+
Ce as OrderState,
|
|
1083
|
+
Be as PaymentStandard,
|
|
1084
|
+
me as Permission,
|
|
1085
|
+
ye as ProfileType,
|
|
1086
|
+
We as constants,
|
|
1087
|
+
ee as getChain,
|
|
1088
|
+
ae as getNetwork,
|
|
1071
1089
|
Fe as placeOrderMessage,
|
|
1072
|
-
|
|
1090
|
+
re as rfc3339
|
|
1073
1091
|
};
|
package/dist/package.json
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -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 = 1 | 5 | 100 | 137 | 10200 | 80001;
|
|
21
|
+
export type ChainId = number | 1 | 5 | 100 | 137 | 10200 | 80001;
|
|
22
22
|
export declare enum Currency {
|
|
23
23
|
eur = "eur"
|
|
24
24
|
}
|
|
@@ -89,12 +89,12 @@ export type PKCERequest = {
|
|
|
89
89
|
address?: string;
|
|
90
90
|
/** the signature of the wallet to automatically link */
|
|
91
91
|
signature?: string;
|
|
92
|
-
/** @deprecated - Use chainId
|
|
92
|
+
/** @deprecated - Use chainId */
|
|
93
93
|
network?: Network;
|
|
94
|
-
/** @deprecated - Use chainId
|
|
94
|
+
/** @deprecated - Use chainId */
|
|
95
95
|
chain?: Chain;
|
|
96
96
|
/** The network of the wallet to automatically link */
|
|
97
|
-
chainId?: ChainId
|
|
97
|
+
chainId?: ChainId;
|
|
98
98
|
};
|
|
99
99
|
declare enum Method {
|
|
100
100
|
password = "password",
|
|
@@ -207,8 +207,11 @@ export interface IBAN extends Identifier {
|
|
|
207
207
|
export interface CrossChain extends Identifier {
|
|
208
208
|
standard: PaymentStandard.chain;
|
|
209
209
|
address: string;
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
chainId: ChainId;
|
|
211
|
+
/** @deprecated - Use chainId */
|
|
212
|
+
chain?: Chain;
|
|
213
|
+
/** @deprecated - Use chainId */
|
|
214
|
+
network?: Network;
|
|
212
215
|
}
|
|
213
216
|
export interface SCAN extends Identifier {
|
|
214
217
|
standard: PaymentStandard.scan;
|
|
@@ -288,8 +291,11 @@ export interface NewOrderCommon {
|
|
|
288
291
|
}
|
|
289
292
|
export interface NewOrderByAddress extends NewOrderCommon {
|
|
290
293
|
address: string;
|
|
291
|
-
|
|
292
|
-
|
|
294
|
+
/** @deprecated - Use 'chainId' */
|
|
295
|
+
chain?: Chain;
|
|
296
|
+
/** @deprecated - Use 'chainId' */
|
|
297
|
+
network?: Network;
|
|
298
|
+
chainId: ChainId;
|
|
293
299
|
}
|
|
294
300
|
export interface NewOrderByAccountId extends NewOrderCommon {
|
|
295
301
|
accountId: string;
|
|
@@ -308,8 +314,11 @@ export interface SupportingDoc {
|
|
|
308
314
|
meta: SupportingDocMetadata;
|
|
309
315
|
}
|
|
310
316
|
export interface CurrencyAccounts {
|
|
311
|
-
|
|
312
|
-
|
|
317
|
+
/** @deprecated - Use 'chainId' */
|
|
318
|
+
network?: Network;
|
|
319
|
+
/** @deprecated - Use 'chainId' */
|
|
320
|
+
chain?: Chain;
|
|
321
|
+
chainId: ChainId;
|
|
313
322
|
currency: Currency;
|
|
314
323
|
}
|
|
315
324
|
export interface LinkAddress {
|
|
@@ -317,8 +326,11 @@ export interface LinkAddress {
|
|
|
317
326
|
message: string;
|
|
318
327
|
signature: string;
|
|
319
328
|
accounts: CurrencyAccounts[];
|
|
329
|
+
/** @deprecated - Use 'chainId' */
|
|
320
330
|
network?: Network;
|
|
331
|
+
/** @deprecated - Use 'chainId' */
|
|
321
332
|
chain?: Chain;
|
|
333
|
+
chainId?: ChainId;
|
|
322
334
|
}
|
|
323
335
|
export type OrderNotification = {
|
|
324
336
|
id: string;
|
|
@@ -346,7 +358,7 @@ export type AuthFlowOptions = {
|
|
|
346
358
|
redirectUrl?: string;
|
|
347
359
|
address?: string;
|
|
348
360
|
signature?: string;
|
|
349
|
-
chainId?:
|
|
361
|
+
chainId?: ChainId;
|
|
350
362
|
};
|
|
351
363
|
export type ClientCredentials = {
|
|
352
364
|
clientId: string;
|
package/dist/utils.d.ts
CHANGED
|
@@ -25,3 +25,4 @@ export declare const getChain: (chainId: number) => Chain;
|
|
|
25
25
|
export declare const getNetwork: (chainId: number) => Networks;
|
|
26
26
|
export declare const getIban: (profile: Profile, address: string, chainId: number) => string;
|
|
27
27
|
export declare const getAmount: (balances?: Balances[], address?: string, chainId?: ChainId) => string;
|
|
28
|
+
export declare const mapChainAndNetwork: (body: any) => any;
|