@monerium/sdk 2.9.0 → 2.10.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 +7 -0
- package/dist/client.d.ts +2 -2
- package/dist/helpers/auth.helpers.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +94 -94
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.10.0](https://github.com/monerium/js-sdk/compare/sdk-v2.9.0...sdk-v2.10.0) (2023-12-20)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* use localStorage instead of sessionStorage to persists session between tabs ([8b5bc8b](https://github.com/monerium/js-sdk/commit/8b5bc8bfe0d773d14e13c020b75744b751375cb9))
|
|
9
|
+
|
|
3
10
|
## [2.9.0](https://github.com/monerium/js-sdk/compare/sdk-v2.8.3...sdk-v2.9.0) (2023-12-15)
|
|
4
11
|
|
|
5
12
|
|
package/dist/client.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { AuthArgs, AuthorizationCodeCredentials, AuthContext, Balances, Bea
|
|
|
2
2
|
export declare class MoneriumClient {
|
|
3
3
|
#private;
|
|
4
4
|
/**
|
|
5
|
-
* @deprecated, use
|
|
5
|
+
* @deprecated, use localStorage, will be removed in v3
|
|
6
6
|
* The PKCE code verifier
|
|
7
7
|
* */
|
|
8
8
|
codeVerifier?: string;
|
|
@@ -17,7 +17,7 @@ export declare class MoneriumClient {
|
|
|
17
17
|
constructor(options: ClassOptions);
|
|
18
18
|
/**
|
|
19
19
|
* Construct the url to the authorization code flow,
|
|
20
|
-
* Code Verifier needed for the code challenge is stored in
|
|
20
|
+
* Code Verifier needed for the code challenge is stored in local storage
|
|
21
21
|
* For automatic wallet link, add the following properties: `address`, `signature` & `chainId`
|
|
22
22
|
* @returns string
|
|
23
23
|
* {@link https://monerium.dev/api-docs#operation/auth}
|
|
@@ -11,7 +11,7 @@ export declare const generateRandomString: () => string;
|
|
|
11
11
|
/** Generate the PKCE code challenge */
|
|
12
12
|
export declare const generateCodeChallenge: (codeVerifier: string) => string;
|
|
13
13
|
/**
|
|
14
|
-
* Constructs the Auth Flow URL and stores the code verifier in the
|
|
14
|
+
* Constructs the Auth Flow URL and stores the code verifier in the local storage
|
|
15
15
|
*/
|
|
16
16
|
export declare const getAuthFlowUrlAndStoreCodeVerifier: (baseUrl: string, args: PKCERequestArgs) => string;
|
|
17
17
|
/**
|
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 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;
|
|
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;
|
package/dist/index.mjs
CHANGED
|
@@ -148,11 +148,11 @@ function he() {
|
|
|
148
148
|
}
|
|
149
149
|
throw new Error("Native crypto module could not be used to get secure random number.");
|
|
150
150
|
}, B = Object.create || function() {
|
|
151
|
-
function
|
|
151
|
+
function o() {
|
|
152
152
|
}
|
|
153
|
-
return function(
|
|
153
|
+
return function(s) {
|
|
154
154
|
var a;
|
|
155
|
-
return
|
|
155
|
+
return o.prototype = s, a = new o(), o.prototype = null, a;
|
|
156
156
|
};
|
|
157
157
|
}(), p = {}, y = p.lib = {}, m = y.Base = function() {
|
|
158
158
|
return {
|
|
@@ -174,11 +174,11 @@ function he() {
|
|
|
174
174
|
* }
|
|
175
175
|
* });
|
|
176
176
|
*/
|
|
177
|
-
extend: function(
|
|
178
|
-
var
|
|
179
|
-
return
|
|
180
|
-
|
|
181
|
-
}),
|
|
177
|
+
extend: function(o) {
|
|
178
|
+
var s = B(this);
|
|
179
|
+
return o && s.mixIn(o), (!s.hasOwnProperty("init") || this.init === s.init) && (s.init = function() {
|
|
180
|
+
s.$super.init.apply(this, arguments);
|
|
181
|
+
}), s.init.prototype = s, s.$super = this, s;
|
|
182
182
|
},
|
|
183
183
|
/**
|
|
184
184
|
* Extends this object and runs the init method.
|
|
@@ -193,8 +193,8 @@ function he() {
|
|
|
193
193
|
* var instance = MyType.create();
|
|
194
194
|
*/
|
|
195
195
|
create: function() {
|
|
196
|
-
var
|
|
197
|
-
return
|
|
196
|
+
var o = this.extend();
|
|
197
|
+
return o.init.apply(o, arguments), o;
|
|
198
198
|
},
|
|
199
199
|
/**
|
|
200
200
|
* Initializes a newly created object.
|
|
@@ -221,10 +221,10 @@ function he() {
|
|
|
221
221
|
* field: 'value'
|
|
222
222
|
* });
|
|
223
223
|
*/
|
|
224
|
-
mixIn: function(
|
|
225
|
-
for (var
|
|
226
|
-
|
|
227
|
-
|
|
224
|
+
mixIn: function(o) {
|
|
225
|
+
for (var s in o)
|
|
226
|
+
o.hasOwnProperty(s) && (this[s] = o[s]);
|
|
227
|
+
o.hasOwnProperty("toString") && (this.toString = o.toString);
|
|
228
228
|
},
|
|
229
229
|
/**
|
|
230
230
|
* Creates a copy of this object.
|
|
@@ -252,8 +252,8 @@ function he() {
|
|
|
252
252
|
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
|
|
253
253
|
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
|
|
254
254
|
*/
|
|
255
|
-
init: function(
|
|
256
|
-
|
|
255
|
+
init: function(o, s) {
|
|
256
|
+
o = this.words = o || [], s != u ? this.sigBytes = s : this.sigBytes = o.length * 4;
|
|
257
257
|
},
|
|
258
258
|
/**
|
|
259
259
|
* Converts this word array to a string.
|
|
@@ -268,8 +268,8 @@ function he() {
|
|
|
268
268
|
* var string = wordArray.toString();
|
|
269
269
|
* var string = wordArray.toString(CryptoJS.enc.Utf8);
|
|
270
270
|
*/
|
|
271
|
-
toString: function(
|
|
272
|
-
return (
|
|
271
|
+
toString: function(o) {
|
|
272
|
+
return (o || f).stringify(this);
|
|
273
273
|
},
|
|
274
274
|
/**
|
|
275
275
|
* Concatenates a word array to this word array.
|
|
@@ -282,16 +282,16 @@ function he() {
|
|
|
282
282
|
*
|
|
283
283
|
* wordArray1.concat(wordArray2);
|
|
284
284
|
*/
|
|
285
|
-
concat: function(
|
|
286
|
-
var
|
|
285
|
+
concat: function(o) {
|
|
286
|
+
var s = this.words, a = o.words, h = this.sigBytes, _ = o.sigBytes;
|
|
287
287
|
if (this.clamp(), h % 4)
|
|
288
288
|
for (var S = 0; S < _; S++) {
|
|
289
289
|
var C = a[S >>> 2] >>> 24 - S % 4 * 8 & 255;
|
|
290
|
-
|
|
290
|
+
s[h + S >>> 2] |= C << 24 - (h + S) % 4 * 8;
|
|
291
291
|
}
|
|
292
292
|
else
|
|
293
293
|
for (var x = 0; x < _; x += 4)
|
|
294
|
-
|
|
294
|
+
s[h + x >>> 2] = a[x >>> 2];
|
|
295
295
|
return this.sigBytes += _, this;
|
|
296
296
|
},
|
|
297
297
|
/**
|
|
@@ -302,8 +302,8 @@ function he() {
|
|
|
302
302
|
* wordArray.clamp();
|
|
303
303
|
*/
|
|
304
304
|
clamp: function() {
|
|
305
|
-
var
|
|
306
|
-
s
|
|
305
|
+
var o = this.words, s = this.sigBytes;
|
|
306
|
+
o[s >>> 2] &= 4294967295 << 32 - s % 4 * 8, o.length = n.ceil(s / 4);
|
|
307
307
|
},
|
|
308
308
|
/**
|
|
309
309
|
* Creates a copy of this word array.
|
|
@@ -315,8 +315,8 @@ function he() {
|
|
|
315
315
|
* var clone = wordArray.clone();
|
|
316
316
|
*/
|
|
317
317
|
clone: function() {
|
|
318
|
-
var
|
|
319
|
-
return
|
|
318
|
+
var o = m.clone.call(this);
|
|
319
|
+
return o.words = this.words.slice(0), o;
|
|
320
320
|
},
|
|
321
321
|
/**
|
|
322
322
|
* Creates a word array filled with random bytes.
|
|
@@ -331,10 +331,10 @@ function he() {
|
|
|
331
331
|
*
|
|
332
332
|
* var wordArray = CryptoJS.lib.WordArray.random(16);
|
|
333
333
|
*/
|
|
334
|
-
random: function(
|
|
335
|
-
for (var
|
|
336
|
-
|
|
337
|
-
return new g.init(
|
|
334
|
+
random: function(o) {
|
|
335
|
+
for (var s = [], a = 0; a < o; a += 4)
|
|
336
|
+
s.push(v());
|
|
337
|
+
return new g.init(s, o);
|
|
338
338
|
}
|
|
339
339
|
}), b = p.enc = {}, f = b.Hex = {
|
|
340
340
|
/**
|
|
@@ -350,9 +350,9 @@ function he() {
|
|
|
350
350
|
*
|
|
351
351
|
* var hexString = CryptoJS.enc.Hex.stringify(wordArray);
|
|
352
352
|
*/
|
|
353
|
-
stringify: function(
|
|
354
|
-
for (var
|
|
355
|
-
var S =
|
|
353
|
+
stringify: function(o) {
|
|
354
|
+
for (var s = o.words, a = o.sigBytes, h = [], _ = 0; _ < a; _++) {
|
|
355
|
+
var S = s[_ >>> 2] >>> 24 - _ % 4 * 8 & 255;
|
|
356
356
|
h.push((S >>> 4).toString(16)), h.push((S & 15).toString(16));
|
|
357
357
|
}
|
|
358
358
|
return h.join("");
|
|
@@ -370,10 +370,10 @@ function he() {
|
|
|
370
370
|
*
|
|
371
371
|
* var wordArray = CryptoJS.enc.Hex.parse(hexString);
|
|
372
372
|
*/
|
|
373
|
-
parse: function(
|
|
374
|
-
for (var
|
|
375
|
-
a[h >>> 3] |= parseInt(
|
|
376
|
-
return new g.init(a,
|
|
373
|
+
parse: function(o) {
|
|
374
|
+
for (var s = o.length, a = [], h = 0; h < s; h += 2)
|
|
375
|
+
a[h >>> 3] |= parseInt(o.substr(h, 2), 16) << 24 - h % 8 * 4;
|
|
376
|
+
return new g.init(a, s / 2);
|
|
377
377
|
}
|
|
378
378
|
}, l = b.Latin1 = {
|
|
379
379
|
/**
|
|
@@ -389,9 +389,9 @@ function he() {
|
|
|
389
389
|
*
|
|
390
390
|
* var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
|
|
391
391
|
*/
|
|
392
|
-
stringify: function(
|
|
393
|
-
for (var
|
|
394
|
-
var S =
|
|
392
|
+
stringify: function(o) {
|
|
393
|
+
for (var s = o.words, a = o.sigBytes, h = [], _ = 0; _ < a; _++) {
|
|
394
|
+
var S = s[_ >>> 2] >>> 24 - _ % 4 * 8 & 255;
|
|
395
395
|
h.push(String.fromCharCode(S));
|
|
396
396
|
}
|
|
397
397
|
return h.join("");
|
|
@@ -409,10 +409,10 @@ function he() {
|
|
|
409
409
|
*
|
|
410
410
|
* var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
|
|
411
411
|
*/
|
|
412
|
-
parse: function(
|
|
413
|
-
for (var
|
|
414
|
-
a[h >>> 2] |= (
|
|
415
|
-
return new g.init(a,
|
|
412
|
+
parse: function(o) {
|
|
413
|
+
for (var s = o.length, a = [], h = 0; h < s; h++)
|
|
414
|
+
a[h >>> 2] |= (o.charCodeAt(h) & 255) << 24 - h % 4 * 8;
|
|
415
|
+
return new g.init(a, s);
|
|
416
416
|
}
|
|
417
417
|
}, i = b.Utf8 = {
|
|
418
418
|
/**
|
|
@@ -428,9 +428,9 @@ function he() {
|
|
|
428
428
|
*
|
|
429
429
|
* var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
|
|
430
430
|
*/
|
|
431
|
-
stringify: function(
|
|
431
|
+
stringify: function(o) {
|
|
432
432
|
try {
|
|
433
|
-
return decodeURIComponent(escape(l.stringify(
|
|
433
|
+
return decodeURIComponent(escape(l.stringify(o)));
|
|
434
434
|
} catch {
|
|
435
435
|
throw new Error("Malformed UTF-8 data");
|
|
436
436
|
}
|
|
@@ -448,8 +448,8 @@ function he() {
|
|
|
448
448
|
*
|
|
449
449
|
* var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
|
|
450
450
|
*/
|
|
451
|
-
parse: function(
|
|
452
|
-
return l.parse(unescape(encodeURIComponent(
|
|
451
|
+
parse: function(o) {
|
|
452
|
+
return l.parse(unescape(encodeURIComponent(o)));
|
|
453
453
|
}
|
|
454
454
|
}, d = y.BufferedBlockAlgorithm = m.extend({
|
|
455
455
|
/**
|
|
@@ -472,8 +472,8 @@ function he() {
|
|
|
472
472
|
* bufferedBlockAlgorithm._append('data');
|
|
473
473
|
* bufferedBlockAlgorithm._append(wordArray);
|
|
474
474
|
*/
|
|
475
|
-
_append: function(
|
|
476
|
-
typeof
|
|
475
|
+
_append: function(o) {
|
|
476
|
+
typeof o == "string" && (o = i.parse(o)), this._data.concat(o), this._nDataBytes += o.sigBytes;
|
|
477
477
|
},
|
|
478
478
|
/**
|
|
479
479
|
* Processes available data blocks.
|
|
@@ -489,16 +489,16 @@ function he() {
|
|
|
489
489
|
* var processedData = bufferedBlockAlgorithm._process();
|
|
490
490
|
* var processedData = bufferedBlockAlgorithm._process(!!'flush');
|
|
491
491
|
*/
|
|
492
|
-
_process: function(
|
|
493
|
-
var
|
|
494
|
-
|
|
492
|
+
_process: function(o) {
|
|
493
|
+
var s, a = this._data, h = a.words, _ = a.sigBytes, S = this.blockSize, C = S * 4, x = _ / C;
|
|
494
|
+
o ? x = n.ceil(x) : x = n.max((x | 0) - this._minBufferSize, 0);
|
|
495
495
|
var N = x * S, P = 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
|
-
|
|
499
|
+
s = h.splice(0, N), a.sigBytes -= P;
|
|
500
500
|
}
|
|
501
|
-
return new g.init(
|
|
501
|
+
return new g.init(s, P);
|
|
502
502
|
},
|
|
503
503
|
/**
|
|
504
504
|
* Creates a copy of this object.
|
|
@@ -510,8 +510,8 @@ function he() {
|
|
|
510
510
|
* var clone = bufferedBlockAlgorithm.clone();
|
|
511
511
|
*/
|
|
512
512
|
clone: function() {
|
|
513
|
-
var
|
|
514
|
-
return
|
|
513
|
+
var o = m.clone.call(this);
|
|
514
|
+
return o._data = this._data.clone(), o;
|
|
515
515
|
},
|
|
516
516
|
_minBufferSize: 0
|
|
517
517
|
});
|
|
@@ -529,8 +529,8 @@ function he() {
|
|
|
529
529
|
*
|
|
530
530
|
* var hasher = CryptoJS.algo.SHA256.create();
|
|
531
531
|
*/
|
|
532
|
-
init: function(
|
|
533
|
-
this.cfg = this.cfg.extend(
|
|
532
|
+
init: function(o) {
|
|
533
|
+
this.cfg = this.cfg.extend(o), this.reset();
|
|
534
534
|
},
|
|
535
535
|
/**
|
|
536
536
|
* Resets this hasher to its initial state.
|
|
@@ -554,8 +554,8 @@ function he() {
|
|
|
554
554
|
* hasher.update('message');
|
|
555
555
|
* hasher.update(wordArray);
|
|
556
556
|
*/
|
|
557
|
-
update: function(
|
|
558
|
-
return this._append(
|
|
557
|
+
update: function(o) {
|
|
558
|
+
return this._append(o), this._process(), this;
|
|
559
559
|
},
|
|
560
560
|
/**
|
|
561
561
|
* Finalizes the hash computation.
|
|
@@ -571,10 +571,10 @@ function he() {
|
|
|
571
571
|
* var hash = hasher.finalize('message');
|
|
572
572
|
* var hash = hasher.finalize(wordArray);
|
|
573
573
|
*/
|
|
574
|
-
finalize: function(
|
|
575
|
-
|
|
576
|
-
var
|
|
577
|
-
return
|
|
574
|
+
finalize: function(o) {
|
|
575
|
+
o && this._append(o);
|
|
576
|
+
var s = this._doFinalize();
|
|
577
|
+
return s;
|
|
578
578
|
},
|
|
579
579
|
blockSize: 16,
|
|
580
580
|
/**
|
|
@@ -590,9 +590,9 @@ function he() {
|
|
|
590
590
|
*
|
|
591
591
|
* var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
|
|
592
592
|
*/
|
|
593
|
-
_createHelper: function(
|
|
594
|
-
return function(
|
|
595
|
-
return new
|
|
593
|
+
_createHelper: function(o) {
|
|
594
|
+
return function(s, a) {
|
|
595
|
+
return new o.init(a).finalize(s);
|
|
596
596
|
};
|
|
597
597
|
},
|
|
598
598
|
/**
|
|
@@ -608,9 +608,9 @@ function he() {
|
|
|
608
608
|
*
|
|
609
609
|
* var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
|
|
610
610
|
*/
|
|
611
|
-
_createHmacHelper: function(
|
|
612
|
-
return function(
|
|
613
|
-
return new A.HMAC.init(
|
|
611
|
+
_createHmacHelper: function(o) {
|
|
612
|
+
return function(s, a) {
|
|
613
|
+
return new A.HMAC.init(o, a).finalize(s);
|
|
614
614
|
};
|
|
615
615
|
}
|
|
616
616
|
});
|
|
@@ -648,8 +648,8 @@ function he() {
|
|
|
648
648
|
var m = p.words, g = p.sigBytes, b = y ? this._safe_map : this._map;
|
|
649
649
|
p.clamp();
|
|
650
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,
|
|
652
|
-
f.push(b.charAt(
|
|
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++)
|
|
652
|
+
f.push(b.charAt(o >>> 6 * (3 - s) & 63));
|
|
653
653
|
var a = b.charAt(64);
|
|
654
654
|
if (a)
|
|
655
655
|
for (; f.length % 4; )
|
|
@@ -711,8 +711,8 @@ var fe = { exports: {} };
|
|
|
711
711
|
var u = r, c = u.lib, v = c.WordArray, B = c.Hasher, p = u.algo, y = [], m = [];
|
|
712
712
|
(function() {
|
|
713
713
|
function f(A) {
|
|
714
|
-
for (var
|
|
715
|
-
if (!(A %
|
|
714
|
+
for (var o = n.sqrt(A), s = 2; s <= o; s++)
|
|
715
|
+
if (!(A % s))
|
|
716
716
|
return !1;
|
|
717
717
|
return !0;
|
|
718
718
|
}
|
|
@@ -727,17 +727,17 @@ var fe = { exports: {} };
|
|
|
727
727
|
this._hash = new v.init(y.slice(0));
|
|
728
728
|
},
|
|
729
729
|
_doProcessBlock: function(f, l) {
|
|
730
|
-
for (var i = this._hash.words, d = i[0], A = i[1],
|
|
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
732
|
g[C] = f[l + C] | 0;
|
|
733
733
|
else {
|
|
734
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
735
|
g[C] = N + g[C - 7] + W + g[C - 16];
|
|
736
736
|
}
|
|
737
|
-
var de = a & h ^ ~a & _, le = d & A ^ d &
|
|
738
|
-
S = _, _ = h, h = a, a =
|
|
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;
|
|
738
|
+
S = _, _ = h, h = a, a = s + te | 0, s = o, o = A, A = d, d = te + ge | 0;
|
|
739
739
|
}
|
|
740
|
-
i[0] = i[0] + d | 0, i[1] = i[1] + A | 0, i[2] = i[2] +
|
|
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
743
|
var f = this._data, l = f.words, i = this._nDataBytes * 8, d = f.sigBytes * 8;
|
|
@@ -787,10 +787,10 @@ 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)),
|
|
790
|
+
}, Me = (e) => Ue.stringify(Pe(e)), oe = (e, t) => {
|
|
791
791
|
const r = Te(), n = Me(r);
|
|
792
|
-
return
|
|
793
|
-
},
|
|
792
|
+
return localStorage.setItem(M, r || ""), `${e}/auth?${Oe(t, n)}`;
|
|
793
|
+
}, se = () => {
|
|
794
794
|
const e = window.location.href;
|
|
795
795
|
if (!e || !(e != null && e.includes("?")))
|
|
796
796
|
return;
|
|
@@ -832,10 +832,10 @@ class De {
|
|
|
832
832
|
R(this, G, void 0);
|
|
833
833
|
R(this, J, void 0);
|
|
834
834
|
if (I(this, H, /* @__PURE__ */ new Map()), this.isAuthorized = !!this.bearerProfile, I(this, V, async (r, n, u) => {
|
|
835
|
-
const c =
|
|
835
|
+
const c = localStorage.getItem(M) || "";
|
|
836
836
|
if (!c)
|
|
837
837
|
throw new Error("Code verifier not found");
|
|
838
|
-
return this.codeVerifier = c,
|
|
838
|
+
return this.codeVerifier = c, localStorage.removeItem(M), await k(this, O, j).call(this, {
|
|
839
839
|
code: u,
|
|
840
840
|
redirect_uri: n,
|
|
841
841
|
client_id: r,
|
|
@@ -867,8 +867,8 @@ class De {
|
|
|
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 =
|
|
871
|
-
return this.codeVerifier =
|
|
870
|
+
const n = oe(w(this, z).api, r);
|
|
871
|
+
return this.codeVerifier = localStorage.getItem(M), n;
|
|
872
872
|
}, this.pkceRequest = (r) => this.getAuthFlowURI(r), this.getEnvironment = () => w(this, z), !t) {
|
|
873
873
|
I(this, z, K.environments.sandbox);
|
|
874
874
|
return;
|
|
@@ -891,7 +891,7 @@ class De {
|
|
|
891
891
|
}
|
|
892
892
|
/**
|
|
893
893
|
* Construct the url to the authorization code flow,
|
|
894
|
-
* Code Verifier needed for the code challenge is stored in
|
|
894
|
+
* Code Verifier needed for the code challenge is stored in local storage
|
|
895
895
|
* For automatic wallet link, add the following properties: `address`, `signature` & `chainId`
|
|
896
896
|
* @returns string
|
|
897
897
|
* {@link https://monerium.dev/api-docs#operation/auth}
|
|
@@ -903,7 +903,7 @@ class De {
|
|
|
903
903
|
throw new Error("Missing ClientId");
|
|
904
904
|
if (!n)
|
|
905
905
|
throw new Error("Missing RedirectUrl");
|
|
906
|
-
const u =
|
|
906
|
+
const u = oe(w(this, z).api, {
|
|
907
907
|
client_id: r,
|
|
908
908
|
redirect_uri: n,
|
|
909
909
|
address: t == null ? void 0 : t.address,
|
|
@@ -930,7 +930,7 @@ class De {
|
|
|
930
930
|
throw new Error("Missing ClientId");
|
|
931
931
|
if (T)
|
|
932
932
|
throw new Error("This only works client side");
|
|
933
|
-
const c = new URLSearchParams(window.location.search).get("code") || void 0, v =
|
|
933
|
+
const c = new URLSearchParams(window.location.search).get("code") || void 0, v = localStorage.getItem(D) || void 0;
|
|
934
934
|
return v ? await w(this, J).call(this, r, v) : c && await w(this, V).call(this, r, u, c), !!this.bearerProfile;
|
|
935
935
|
}
|
|
936
936
|
// -- Read Methods
|
|
@@ -1015,13 +1015,13 @@ class De {
|
|
|
1015
1015
|
*/
|
|
1016
1016
|
async disconnect() {
|
|
1017
1017
|
var t;
|
|
1018
|
-
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
1019
|
}
|
|
1020
1020
|
/**
|
|
1021
1021
|
* Revokes access
|
|
1022
1022
|
*/
|
|
1023
1023
|
async revokeAccess() {
|
|
1024
|
-
T ||
|
|
1024
|
+
T || localStorage.removeItem(D), this.disconnect();
|
|
1025
1025
|
}
|
|
1026
1026
|
/**
|
|
1027
1027
|
* Subscribe to MoneriumEvent to receive notifications using the Monerium API (WebSocket)
|
|
@@ -1054,13 +1054,13 @@ z = new WeakMap(), F = new WeakMap(), L = new WeakMap(), H = new WeakMap(), U =
|
|
|
1054
1054
|
throw new Error("Authorization grant type could not be detected.");
|
|
1055
1055
|
return await k(this, E, $).call(this, "post", "auth/token", r, !0).then((n) => {
|
|
1056
1056
|
var u;
|
|
1057
|
-
this.bearerProfile = n, this.isAuthorized = !!n, I(this, F, `Bearer ${n == null ? void 0 : n.access_token}`), T || window.
|
|
1057
|
+
this.bearerProfile = n, this.isAuthorized = !!n, I(this, F, `Bearer ${n == null ? void 0 : n.access_token}`), T || window.localStorage.setItem(
|
|
1058
1058
|
D,
|
|
1059
1059
|
((u = this.bearerProfile) == null ? void 0 : u.refresh_token) || ""
|
|
1060
1060
|
);
|
|
1061
1061
|
}).catch((n) => {
|
|
1062
|
-
throw T || (
|
|
1063
|
-
}), ie(t) &&
|
|
1062
|
+
throw T || (localStorage.removeItem(M), localStorage.removeItem(D), se()), new Error(n == null ? void 0 : n.message);
|
|
1063
|
+
}), ie(t) && se(), this.bearerProfile;
|
|
1064
1064
|
}, E = new WeakSet(), $ = async function(t, r, n, u) {
|
|
1065
1065
|
return je(
|
|
1066
1066
|
`${w(this, z).api}/${r}`,
|
package/dist/package.json
CHANGED