@monerium/sdk 2.7.3 → 2.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.8.2](https://github.com/monerium/js-sdk/compare/sdk-v2.8.1...sdk-v2.8.2) (2023-12-11)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * remove authentication info on disconnect ([26e38c4](https://github.com/monerium/js-sdk/commit/26e38c46ee562deff8f04f38221ce091e24f53b2))
9
+ * test ([9c01345](https://github.com/monerium/js-sdk/commit/9c0134559b628f3abf377400c7250cecca9e41d8))
10
+
11
+ ## [2.8.1](https://github.com/monerium/js-sdk/compare/sdk-v2.8.0...sdk-v2.8.1) (2023-12-02)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * added currency to placeOrderMessage [#66](https://github.com/monerium/js-sdk/issues/66) ([496df35](https://github.com/monerium/js-sdk/commit/496df35f268330ac7158785534d11f3ffece4777))
17
+ * docs:watch task + docs update ([b42d6d8](https://github.com/monerium/js-sdk/commit/b42d6d804eb45869fd5a1ac39bf81b832e56bd2a))
18
+
19
+ ## [2.8.0](https://github.com/monerium/js-sdk/compare/sdk-v2.7.3...sdk-v2.8.0) (2023-11-22)
20
+
21
+
22
+ ### Features
23
+
24
+ * add cross-chain typings ([f3b6583](https://github.com/monerium/js-sdk/commit/f3b6583a268e3aeaf31f143ce5fddbb30cb2f32e))
25
+
3
26
  ## [2.7.3](https://github.com/monerium/public-monorepo/compare/sdk-v2.7.3...sdk-v2.7.3) (2023-11-17)
4
27
 
5
28
 
package/README.md CHANGED
@@ -315,31 +315,31 @@ API documentation:
315
315
 
316
316
  #### Subscribe to order events
317
317
 
318
- ````ts
318
+ ```ts
319
319
  import { OrderState } from '@monerium/sdk';
320
320
  const [orderState, setOrderState] = useState<OrderState>();
321
321
  // Subscribe to order events
322
322
  monerium.subscribeOrders(OrderState.pending, (notification) => {
323
- setOrderState(notification.meta.state)
324
- })
323
+ setOrderState(notification.meta.state);
324
+ });
325
325
 
326
- monerium.subscribeOrders(OrderState.placed, (notification) => {
327
- setOrderState(notification.meta.state)
328
- })
326
+ monerium.subscribeOrders(OrderState.placed, (notification) => {
327
+ setOrderState(notification.meta.state);
328
+ });
329
329
 
330
- monerium.subscribeOrders(OrderState.rejected, (notification) => {
331
- setOrderState(notification.meta.state)
330
+ monerium.subscribeOrders(OrderState.rejected, (notification) => {
331
+ setOrderState(notification.meta.state);
332
332
  setTimeout(() => {
333
- setOrderState(undefined)
334
- }, 5000)
335
- })
333
+ setOrderState(undefined);
334
+ }, 5000);
335
+ });
336
336
 
337
- monerium.subscribeOrders(OrderState.processed, (notification) => {
338
- setOrderState(notification.meta.state)
337
+ monerium.subscribeOrders(OrderState.processed, (notification) => {
338
+ setOrderState(notification.meta.state);
339
339
  setTimeout(() => {
340
- setOrderState(undefined)
341
- }, 5000)
342
- })
340
+ setOrderState(undefined);
341
+ }, 5000);
342
+ });
343
343
  ```
344
344
 
345
345
  ## API Reference
@@ -354,25 +354,21 @@ We are using Yarn as a package manager.
354
354
 
355
355
  ```sh
356
356
  # Install dependencies
357
- yarn
357
+ nx run sdk:init
358
358
 
359
359
  # Run Vite to build a production release distributable
360
- yarn build
360
+ nx run sdk:build
361
361
 
362
362
  # Run Vite in watch mode to detect changes to files during development
363
- yarn watch
363
+ nx run sdk:build --watch
364
364
 
365
365
  # Update the docs. This will run the build and update the docs in the static folder.
366
366
  # Open static/index.html in your browser to view the docs. Refresh the page to see changes.
367
- yarn docs:watch
368
- ````
369
-
370
- Smart IDEs (such as VSCode) require [special configuration](https://yarnpkg.com/getting-started/editor-sdks) for TypeScript to work when using Yarn Plug'n'Play installs.
371
-
372
- ```sh
373
- yarn dlx @yarnpkg/sdks vscode
367
+ nx run sdk:docs:watch
374
368
  ```
375
369
 
370
+ ## Linking
371
+
376
372
  For development, a package can be linked into another project. This is often useful to test out new features or when trying to debug an issue in a package that manifests itself in another project. run yarn link inside of the sdk project.
377
373
 
378
374
  ```sh
@@ -388,9 +384,11 @@ yarn link "@monerium/sdk"
388
384
 
389
385
  If you get an error that there is already a package called '@monerium/sdk' registered, but you can't find it and unlinking does nothing, remove it manually with `rm -rf ~/.config/yarn/link/@monerium` and try again.
390
386
 
391
- #### Documentation
387
+ ### Documentation
388
+
389
+ Refer to [Typedocs](https://typedoc.org/) syntaxes to use for this [documentation](https://monerium.github.io/js-sdk/).
392
390
 
393
- Refer to [Typedocs](https://typedoc.org/) syntaxes to use for this [documentation](https://monerium.github.io/sdk/).
391
+ There is a Github action that will automatically run on the successful release of the SDK. It will generate a static output of the documentation and push it to the `gh-pages` branch. The documentation is then available at https://monerium.github.io/js-sdk/.
394
392
 
395
393
  #### Publishing
396
394
 
@@ -404,8 +402,8 @@ Common questions developers have regarding the SDK.
404
402
 
405
403
  [Support](https://monerium.app/help)
406
404
  [Telegram](https://t.me/+lGtM1gY9zWthNGE8)
407
- [Github Issues](https://github.com/monerium/sdk/issues)
405
+ [Github Issues](https://github.com/monerium/js-sdk/issues)
408
406
 
409
407
  ## Release Notes
410
408
 
411
- https://github.com/monerium/sdk/releases
409
+ https://github.com/monerium/js-sdk/releases
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var Z=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var w=(e,t,r)=>(Z(e,t,"read from private field"),r?r.call(e):t.get(e)),O=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},I=(e,t,r,n)=>(Z(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);var B=(e,t,r)=>(Z(e,t,"access private method"),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var se=(e=>(e.eur="eur",e))(se||{}),oe=(e=>(e.corporate="corporate",e.personal="personal",e))(oe||{}),ie=(e=>(e.read="read",e.write="write",e))(ie||{}),ae=(e=>(e.absent="absent",e.submitted="submitted",e.pending="pending",e.confirmed="confirmed",e))(ae||{}),ce=(e=>(e.approved="approved",e.rejected="rejected",e.unknown="unknown",e))(ce||{}),ue=(e=>(e.requested="requested",e.approved="approved",e.pending="pending",e))(ue||{}),de=(e=>(e.iban="iban",e.scan="scan",e))(de||{}),he=(e=>(e.redeem="redeem",e.issue="issue",e))(he||{}),fe=(e=>(e.placed="placed",e.pending="pending",e.processed="processed",e.rejected="rejected",e))(fe||{});const le=e=>{if(e.toString()==="Invalid Date")throw e;const t=n=>n<10?"0"+n:n,r=n=>{if(n===0)return"Z";const u=n>0?"-":"+";return n=Math.abs(n),u+t(Math.floor(n/60))+":"+t(n%60)};return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+"T"+t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+r(e.getTimezoneOffset())},ke=(e,t)=>`Send EUR ${e} to ${t} at ${le(new Date)}`,Q=e=>{var t;return e&&((t=Object.entries(e))==null?void 0:t.length)>0?Object.entries(e).map(([r,n])=>`${encodeURIComponent(r)}=${encodeURIComponent(n)}`).join("&"):""},pe=e=>{switch(e){case 1:case 5:return"ethereum";case 100:case 10200:return"gnosis";case 137:case 80001:return"polygon";default:throw new Error(`Chain not supported: ${e}`)}},ve=e=>{switch(e){case 1:case 100:case 137:return"mainnet";case 5:return"goerli";case 10200:return"chiado";case 80001:return"mumbai";default:throw new Error(`Network not supported: ${e}`)}},K={environments:{production:{api:"https://api.monerium.app",web:"https://monerium.app",wss:"wss://api.monerium.app"},sandbox:{api:"https://api.monerium.dev",web:"https://sandbox.monerium.dev",wss:"wss://api.monerium.dev"}}},xe="I hereby declare that I am the address owner.",M="monerium.sdk.code_verifier",W="monerium.sdk.refresh_token",Ae={LINK_MESSAGE:xe,STORAGE_CODE_VERIFIER:M,STORAGE_REFRESH_TOKEN:W};var N=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ge(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Ee(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var u=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,u.get?u:{enumerable:!0,get:function(){return e[n]}})}),r}var we={exports:{}};function Ie(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var X={exports:{}};const Re={},Oe=Object.freeze(Object.defineProperty({__proto__:null,default:Re},Symbol.toStringTag,{value:"Module"})),Pe=Ee(Oe);var ee;function ye(){return ee||(ee=1,function(e,t){(function(r,n){e.exports=n()})(N,function(){var r=r||function(n,u){var c;if(typeof window<"u"&&window.crypto&&(c=window.crypto),typeof self<"u"&&self.crypto&&(c=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(c=globalThis.crypto),!c&&typeof window<"u"&&window.msCrypto&&(c=window.msCrypto),!c&&typeof N<"u"&&N.crypto&&(c=N.crypto),!c&&typeof Ie=="function")try{c=Pe}catch{}var v=function(){if(c){if(typeof c.getRandomValues=="function")try{return c.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof c.randomBytes=="function")try{return c.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},C=Object.create||function(){function s(){}return function(o){var a;return s.prototype=o,a=new s,s.prototype=null,a}}(),p={},y=p.lib={},m=y.Base=function(){return{extend:function(s){var o=C(this);return s&&o.mixIn(s),(!o.hasOwnProperty("init")||this.init===o.init)&&(o.init=function(){o.$super.init.apply(this,arguments)}),o.init.prototype=o,o.$super=this,o},create:function(){var s=this.extend();return s.init.apply(s,arguments),s},init:function(){},mixIn:function(s){for(var o in s)s.hasOwnProperty(o)&&(this[o]=s[o]);s.hasOwnProperty("toString")&&(this.toString=s.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),g=y.WordArray=m.extend({init:function(s,o){s=this.words=s||[],o!=u?this.sigBytes=o:this.sigBytes=s.length*4},toString:function(s){return(s||h).stringify(this)},concat:function(s){var o=this.words,a=s.words,d=this.sigBytes,_=s.sigBytes;if(this.clamp(),d%4)for(var S=0;S<_;S++){var k=a[S>>>2]>>>24-S%4*8&255;o[d+S>>>2]|=k<<24-(d+S)%4*8}else for(var x=0;x<_;x+=4)o[d+x>>>2]=a[x>>>2];return this.sigBytes+=_,this},clamp:function(){var s=this.words,o=this.sigBytes;s[o>>>2]&=4294967295<<32-o%4*8,s.length=n.ceil(o/4)},clone:function(){var s=m.clone.call(this);return s.words=this.words.slice(0),s},random:function(s){for(var o=[],a=0;a<s;a+=4)o.push(v());return new g.init(o,s)}}),b=p.enc={},h=b.Hex={stringify:function(s){for(var o=s.words,a=s.sigBytes,d=[],_=0;_<a;_++){var S=o[_>>>2]>>>24-_%4*8&255;d.push((S>>>4).toString(16)),d.push((S&15).toString(16))}return d.join("")},parse:function(s){for(var o=s.length,a=[],d=0;d<o;d+=2)a[d>>>3]|=parseInt(s.substr(d,2),16)<<24-d%8*4;return new g.init(a,o/2)}},l=b.Latin1={stringify:function(s){for(var o=s.words,a=s.sigBytes,d=[],_=0;_<a;_++){var S=o[_>>>2]>>>24-_%4*8&255;d.push(String.fromCharCode(S))}return d.join("")},parse:function(s){for(var o=s.length,a=[],d=0;d<o;d++)a[d>>>2]|=(s.charCodeAt(d)&255)<<24-d%4*8;return new g.init(a,o)}},i=b.Utf8={stringify:function(s){try{return decodeURIComponent(escape(l.stringify(s)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(s){return l.parse(unescape(encodeURIComponent(s)))}},f=y.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new g.init,this._nDataBytes=0},_append:function(s){typeof s=="string"&&(s=i.parse(s)),this._data.concat(s),this._nDataBytes+=s.sigBytes},_process:function(s){var o,a=this._data,d=a.words,_=a.sigBytes,S=this.blockSize,k=S*4,x=_/k;s?x=n.ceil(x):x=n.max((x|0)-this._minBufferSize,0);var j=x*S,U=n.min(j*4,_);if(j){for(var F=0;F<j;F+=S)this._doProcessBlock(d,F);o=d.splice(0,j),a.sigBytes-=U}return new g.init(o,U)},clone:function(){var s=m.clone.call(this);return s._data=this._data.clone(),s},_minBufferSize:0});y.Hasher=f.extend({cfg:m.extend(),init:function(s){this.cfg=this.cfg.extend(s),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(s){return this._append(s),this._process(),this},finalize:function(s){s&&this._append(s);var o=this._doFinalize();return o},blockSize:16,_createHelper:function(s){return function(o,a){return new s.init(a).finalize(o)}},_createHmacHelper:function(s){return function(o,a){return new A.HMAC.init(s,a).finalize(o)}}});var A=p.algo={};return p}(Math);return r})}(X)),X.exports}(function(e,t){(function(r,n){e.exports=n(ye())})(N,function(r){return function(){var n=r,u=n.lib,c=u.WordArray,v=n.enc;v.Base64url={stringify:function(p,y){y===void 0&&(y=!0);var m=p.words,g=p.sigBytes,b=y?this._safe_map:this._map;p.clamp();for(var h=[],l=0;l<g;l+=3)for(var i=m[l>>>2]>>>24-l%4*8&255,f=m[l+1>>>2]>>>24-(l+1)%4*8&255,A=m[l+2>>>2]>>>24-(l+2)%4*8&255,s=i<<16|f<<8|A,o=0;o<4&&l+o*.75<g;o++)h.push(b.charAt(s>>>6*(3-o)&63));var a=b.charAt(64);if(a)for(;h.length%4;)h.push(a);return h.join("")},parse:function(p,y){y===void 0&&(y=!0);var m=p.length,g=y?this._safe_map:this._map,b=this._reverseMap;if(!b){b=this._reverseMap=[];for(var h=0;h<g.length;h++)b[g.charCodeAt(h)]=h}var l=g.charAt(64);if(l){var i=p.indexOf(l);i!==-1&&(m=i)}return C(p,m,b)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"};function C(p,y,m){for(var g=[],b=0,h=0;h<y;h++)if(h%4){var l=m[p.charCodeAt(h-1)]<<h%4*2,i=m[p.charCodeAt(h)]>>>6-h%4*2,f=l|i;g[b>>>2]|=f<<24-b%4*8,b++}return c.create(g,b)}}(),r.enc.Base64url})})(we);var $e=we.exports;const ze=ge($e);var me={exports:{}};(function(e,t){(function(r,n){e.exports=n(ye())})(N,function(r){return function(n){var u=r,c=u.lib,v=c.WordArray,C=c.Hasher,p=u.algo,y=[],m=[];(function(){function h(A){for(var s=n.sqrt(A),o=2;o<=s;o++)if(!(A%o))return!1;return!0}function l(A){return(A-(A|0))*4294967296|0}for(var i=2,f=0;f<64;)h(i)&&(f<8&&(y[f]=l(n.pow(i,1/2))),m[f]=l(n.pow(i,1/3)),f++),i++})();var g=[],b=p.SHA256=C.extend({_doReset:function(){this._hash=new v.init(y.slice(0))},_doProcessBlock:function(h,l){for(var i=this._hash.words,f=i[0],A=i[1],s=i[2],o=i[3],a=i[4],d=i[5],_=i[6],S=i[7],k=0;k<64;k++){if(k<16)g[k]=h[l+k]|0;else{var x=g[k-15],j=(x<<25|x>>>7)^(x<<14|x>>>18)^x>>>3,U=g[k-2],F=(U<<15|U>>>17)^(U<<13|U>>>19)^U>>>10;g[k]=j+g[k-7]+F+g[k-16]}var _e=a&d^~a&_,be=f&A^f&s^A&s,Se=(f<<30|f>>>2)^(f<<19|f>>>13)^(f<<10|f>>>22),Ce=(a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25),Y=S+Ce+_e+m[k]+g[k],Be=Se+be;S=_,_=d,d=a,a=o+Y|0,o=s,s=A,A=f,f=Y+Be|0}i[0]=i[0]+f|0,i[1]=i[1]+A|0,i[2]=i[2]+s|0,i[3]=i[3]+o|0,i[4]=i[4]+a|0,i[5]=i[5]+d|0,i[6]=i[6]+_|0,i[7]=i[7]+S|0},_doFinalize:function(){var h=this._data,l=h.words,i=this._nDataBytes*8,f=h.sigBytes*8;return l[f>>>5]|=128<<24-f%32,l[(f+64>>>9<<4)+14]=n.floor(i/4294967296),l[(f+64>>>9<<4)+15]=i,h.sigBytes=l.length*4,this._process(),this._hash},clone:function(){var h=C.clone.call(this);return h._hash=this._hash.clone(),h}});u.SHA256=C._createHelper(b),u.HmacSHA256=C._createHmacHelper(b)}(Math),r.SHA256})})(me);var Ue=me.exports;const He=ge(Ue),Te=(e,t)=>{const{client_id:r,redirect_uri:n,scope:u,state:c,chainId:v,chain:C,network:p,address:y,signature:m}=e,g=y?{address:y,...m!==void 0?{signature:m}:{},...v!==void 0||C!==void 0?{chain:v?pe(v):C}:{},...v!==void 0||p!==void 0?{network:v?ve(v):p}:{}}:{};return Q({client_id:r,redirect_uri:n,...u!==void 0?{scope:u}:{},...c!==void 0?{state:c}:{},code_challenge:t,code_challenge_method:"S256",response_type:"code",...g})},Me=()=>{let e="";const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=t.length;let n=0;for(;n<128;)e+=t.charAt(Math.floor(Math.random()*r)),n+=1;return e},Le=e=>ze.stringify(He(e)),te=(e,t)=>{const r=Me(),n=Le(r);return sessionStorage.setItem(M,r||""),`${e}/auth?${Te(t,n)}`},re=()=>{const e=window.location.href;if(!e||!(e!=null&&e.includes("?")))return;const[t,r]=e.split("?");r&&window.history.replaceState(null,"",t)},ne=e=>e.code!=null,je=e=>e.refresh_token!=null,qe=e=>e.client_secret!=null,Ne=async(e,t,r,n)=>{const u=await fetch(`${e}`,{method:t,headers:n,body:r});let c;const v=await u.text();try{c=JSON.parse(v)}catch{throw v}if(!u.ok)throw c;return c},T=typeof window>"u";var P,D,L,z,$,H,q,E,R,V,G,J;class Fe{constructor(t){O(this,H);O(this,E);O(this,P,void 0);O(this,D,void 0);O(this,L,void 0);O(this,z,void 0);O(this,$,void 0);O(this,V,void 0);O(this,G,void 0);O(this,J,void 0);if(I(this,z,new Map),this.isAuthorized=!!this.bearerProfile,I(this,V,async(r,n,u)=>{const c=sessionStorage.getItem(M)||"";if(!c)throw new Error("Code verifier not found");return this.codeVerifier=c,sessionStorage.removeItem(M),await B(this,H,q).call(this,{code:u,redirect_uri:n,client_id:r,code_verifier:c})}),I(this,G,async({clientId:r,clientSecret:n})=>await B(this,H,q).call(this,{client_id:r,client_secret:n})),I(this,J,async(r,n)=>await B(this,H,q).call(this,{refresh_token:n,client_id:r})),this.subscribeToOrderNotifications=()=>{var u,c;const r=`${w(this,P).wss}/profiles/${(u=this.bearerProfile)==null?void 0:u.profile}/orders?access_token=${(c=this.bearerProfile)==null?void 0:c.access_token}`,n=new WebSocket(r);return n.addEventListener("open",()=>{console.info(`Socket connected: ${r}`)}),n.addEventListener("error",v=>{throw console.error(v),new Error(`Socket error: ${r}`)}),n.addEventListener("message",v=>{var p;const C=JSON.parse(v.data);(p=w(this,z).get(C.meta.state))==null||p(C)}),n.addEventListener("close",()=>{console.info(`Socket connection closed: ${r}`)}),n},this.auth=async r=>await B(this,H,q).call(this,r),this.connect=async r=>await B(this,H,q).call(this,r),this.getAuthFlowURI=r=>{const n=te(w(this,P).api,r);return this.codeVerifier=sessionStorage.getItem(M),n},this.pkceRequest=r=>this.getAuthFlowURI(r),this.getEnvironment=()=>w(this,P),!t){I(this,P,K.environments.sandbox);return}if(typeof t=="string")I(this,P,K.environments[t]);else if(I(this,P,K.environments[t.environment||"sandbox"]),T){const{clientId:r,clientSecret:n}=t;I(this,$,{clientId:r,clientSecret:n})}else{const{clientId:r,redirectUrl:n}=t;I(this,$,{clientId:r,redirectUrl:n})}}async authorize(t){var c,v;const r=(t==null?void 0:t.clientId)||((c=w(this,$))==null?void 0:c.clientId),n=(t==null?void 0:t.redirectUrl)||((v=w(this,$))==null?void 0:v.redirectUrl);if(!r)throw new Error("Missing ClientId");if(!n)throw new Error("Missing RedirectUrl");const u=te(w(this,P).api,{client_id:r,redirect_uri:n,address:t==null?void 0:t.address,signature:t==null?void 0:t.signature,chainId:t==null?void 0:t.chainId});window.location.replace(u)}async getAccess(t){var C,p,y;const r=(t==null?void 0:t.clientId)||((C=w(this,$))==null?void 0:C.clientId);if((t==null?void 0:t.clientSecret)||((p=w(this,$))==null?void 0:p.clientSecret)){if(!T)throw new Error("Only use client credentials on server side");return await w(this,G).call(this,w(this,$)),!!this.bearerProfile}const u=(t==null?void 0:t.redirectUrl)||((y=w(this,$))==null?void 0:y.redirectUrl);if(!r)throw new Error("Missing ClientId");if(T)throw new Error("This only works client side");const c=new URLSearchParams(window.location.search).get("code")||void 0,v=sessionStorage.getItem(W)||void 0;return v?await w(this,J).call(this,r,v):c&&await w(this,V).call(this,r,u,c),!!this.bearerProfile}getAuthContext(){return B(this,E,R).call(this,"get","auth/context")}getProfile(t){return B(this,E,R).call(this,"get",`profiles/${t}`)}getBalances(t){return t?B(this,E,R).call(this,"get",`profiles/${t}/balances`):B(this,E,R).call(this,"get","balances")}getOrders(t){const r=Q(t);return B(this,E,R).call(this,"get",`orders?${r}`)}getOrder(t){return B(this,E,R).call(this,"get",`orders/${t}`)}getTokens(){return B(this,E,R).call(this,"get","tokens")}linkAddress(t,r){return B(this,E,R).call(this,"post",`profiles/${t}/addresses`,JSON.stringify(r))}placeOrder(t,r){const n={...t,kind:"redeem",currency:"eur"};return r?B(this,E,R).call(this,"post",`profiles/${r}/orders`,JSON.stringify(n)):B(this,E,R).call(this,"post","orders",JSON.stringify(n))}uploadSupportingDocument(t){const r=Q(t);return B(this,E,R).call(this,"post","files/supporting-document",r,!0)}async connectOrderSocket(){var t;(t=this.bearerProfile)!=null&&t.access_token&&w(this,z).size>0&&I(this,L,this.subscribeToOrderNotifications())}async disconnect(){var t;T||sessionStorage.removeItem(M),w(this,z).clear(),(t=w(this,L))==null||t.close()}async revokeAccess(){T||sessionStorage.removeItem(W),this.disconnect()}subscribeOrders(t,r){w(this,z).set(t,r)}unsubscribeOrders(t){var r;w(this,z).delete(t),w(this,z).size===0&&((r=w(this,L))==null||r.close(),I(this,L,void 0))}}P=new WeakMap,D=new WeakMap,L=new WeakMap,z=new WeakMap,$=new WeakMap,H=new WeakSet,q=async function(t){let r;if(ne(t))r={...t,grant_type:"authorization_code"};else if(je(t))r={...t,grant_type:"refresh_token"};else if(qe(t))r={...t,grant_type:"client_credentials"};else throw new Error("Authorization grant type could not be detected.");return await B(this,E,R).call(this,"post","auth/token",r,!0).then(n=>{var u;this.bearerProfile=n,this.isAuthorized=!!n,I(this,D,`Bearer ${n==null?void 0:n.access_token}`),T||window.sessionStorage.setItem(W,((u=this.bearerProfile)==null?void 0:u.refresh_token)||"")}).catch(n=>{throw T||(sessionStorage.removeItem(M),sessionStorage.removeItem(W),re()),new Error(n==null?void 0:n.message)}),ne(t)&&re(),this.bearerProfile},E=new WeakSet,R=async function(t,r,n,u){return Ne(`${w(this,P).api}/${r}`,t,u?Q(n):n,{Authorization:w(this,D)||"","Content-Type":`application/${u?"x-www-form-urlencoded":"json"}`})},V=new WeakMap,G=new WeakMap,J=new WeakMap;exports.AccountState=ue;exports.Currency=se;exports.KYCOutcome=ce;exports.KYCState=ae;exports.MoneriumClient=Fe;exports.OrderKind=he;exports.OrderState=fe;exports.PaymentStandard=de;exports.Permission=ie;exports.ProfileType=oe;exports.constants=Ae;exports.getChain=pe;exports.getNetwork=ve;exports.placeOrderMessage=ke;exports.rfc3339=le;
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;
package/dist/index.mjs CHANGED
@@ -2,14 +2,14 @@ var Z = (e, t, r) => {
2
2
  if (!t.has(e))
3
3
  throw TypeError("Cannot " + r);
4
4
  };
5
- var w = (e, t, r) => (Z(e, t, "read from private field"), r ? r.call(e) : t.get(e)), $ = (e, t, r) => {
5
+ var w = (e, t, r) => (Z(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
9
  }, I = (e, t, r, n) => (Z(e, t, "write to private field"), n ? n.call(e, r) : t.set(e, r), r);
10
10
  var k = (e, t, r) => (Z(e, t, "access private method"), r);
11
- var le = /* @__PURE__ */ ((e) => (e.eur = "eur", e))(le || {}), pe = /* @__PURE__ */ ((e) => (e.corporate = "corporate", e.personal = "personal", e))(pe || {}), ve = /* @__PURE__ */ ((e) => (e.read = "read", e.write = "write", e))(ve || {}), ge = /* @__PURE__ */ ((e) => (e.absent = "absent", e.submitted = "submitted", e.pending = "pending", e.confirmed = "confirmed", e))(ge || {}), we = /* @__PURE__ */ ((e) => (e.approved = "approved", e.rejected = "rejected", e.unknown = "unknown", e))(we || {}), ye = /* @__PURE__ */ ((e) => (e.requested = "requested", e.approved = "approved", e.pending = "pending", e))(ye || {}), me = /* @__PURE__ */ ((e) => (e.iban = "iban", e.scan = "scan", e))(me || {}), _e = /* @__PURE__ */ ((e) => (e.redeem = "redeem", e.issue = "issue", e))(_e || {}), be = /* @__PURE__ */ ((e) => (e.placed = "placed", e.pending = "pending", e.processed = "processed", e.rejected = "rejected", e))(be || {});
12
- const Se = (e) => {
11
+ var ve = /* @__PURE__ */ ((e) => (e.eur = "eur", e))(ve || {}), ge = /* @__PURE__ */ ((e) => (e.corporate = "corporate", e.personal = "personal", e))(ge || {}), we = /* @__PURE__ */ ((e) => (e.read = "read", e.write = "write", e))(we || {}), ye = /* @__PURE__ */ ((e) => (e.absent = "absent", e.submitted = "submitted", e.pending = "pending", e.confirmed = "confirmed", e))(ye || {}), me = /* @__PURE__ */ ((e) => (e.approved = "approved", e.rejected = "rejected", e.unknown = "unknown", e))(me || {}), _e = /* @__PURE__ */ ((e) => (e.requested = "requested", e.approved = "approved", e.pending = "pending", e))(_e || {}), be = /* @__PURE__ */ ((e) => (e.iban = "iban", e.scan = "scan", e.chain = "chain", e))(be || {}), Se = /* @__PURE__ */ ((e) => (e.redeem = "redeem", e.issue = "issue", e))(Se || {}), Be = /* @__PURE__ */ ((e) => (e.placed = "placed", e.pending = "pending", e.processed = "processed", e.rejected = "rejected", e))(Be || {});
12
+ const ee = (e) => {
13
13
  if (e.toString() === "Invalid Date")
14
14
  throw e;
15
15
  const t = (n) => n < 10 ? "0" + n : n, r = (n) => {
@@ -19,12 +19,17 @@ const Se = (e) => {
19
19
  return n = Math.abs(n), u + t(Math.floor(n / 60)) + ":" + t(n % 60);
20
20
  };
21
21
  return e.getFullYear() + "-" + t(e.getMonth() + 1) + "-" + t(e.getDate()) + "T" + t(e.getHours()) + ":" + t(e.getMinutes()) + ":" + t(e.getSeconds()) + r(e.getTimezoneOffset());
22
- }, Fe = (e, t) => `Send EUR ${e} to ${t} at ${Se(/* @__PURE__ */ new Date())}`, Q = (e) => {
22
+ }, Fe = (e, t, r, n) => {
23
+ const u = `${(n == null ? void 0 : n.toUpperCase()) || "EUR"}`;
24
+ return r ? `Send ${u} ${e} to ${t} on ${oe(
25
+ r
26
+ )} at ${ee(/* @__PURE__ */ new Date())}` : `Send ${u} ${e} to ${t} at ${ee(/* @__PURE__ */ new Date())}`;
27
+ }, Q = (e) => {
23
28
  var t;
24
29
  return e && ((t = Object.entries(e)) == null ? void 0 : t.length) > 0 ? Object.entries(e).map(
25
30
  ([r, n]) => `${encodeURIComponent(r)}=${encodeURIComponent(n)}`
26
31
  ).join("&") : "";
27
- }, Be = (e) => {
32
+ }, oe = (e) => {
28
33
  switch (e) {
29
34
  case 1:
30
35
  case 5:
@@ -66,13 +71,13 @@ const Se = (e) => {
66
71
  wss: "wss://api.monerium.dev"
67
72
  }
68
73
  }
69
- }, Ce = "I hereby declare that I am the address owner.", M = "monerium.sdk.code_verifier", W = "monerium.sdk.refresh_token", Ne = {
74
+ }, Ce = "I hereby declare that I am the address owner.", M = "monerium.sdk.code_verifier", D = "monerium.sdk.refresh_token", Ne = {
70
75
  LINK_MESSAGE: Ce,
71
76
  STORAGE_CODE_VERIFIER: M,
72
- STORAGE_REFRESH_TOKEN: W
77
+ STORAGE_REFRESH_TOKEN: D
73
78
  };
74
79
  var F = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
75
- function se(e) {
80
+ function ie(e) {
76
81
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
77
82
  }
78
83
  function xe(e) {
@@ -96,7 +101,7 @@ function xe(e) {
96
101
  });
97
102
  }), r;
98
103
  }
99
- var oe = { exports: {} };
104
+ var ae = { exports: {} };
100
105
  function Ae(e) {
101
106
  throw new Error('Could not dynamically require "' + e + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
102
107
  }
@@ -104,10 +109,10 @@ var K = { exports: {} };
104
109
  const Ee = {}, Ie = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
105
110
  __proto__: null,
106
111
  default: Ee
107
- }, Symbol.toStringTag, { value: "Module" })), Re = /* @__PURE__ */ xe(Ie);
108
- var ee;
109
- function ie() {
110
- return ee || (ee = 1, function(e, t) {
112
+ }, Symbol.toStringTag, { value: "Module" })), $e = /* @__PURE__ */ xe(Ie);
113
+ var te;
114
+ function ce() {
115
+ return te || (te = 1, function(e, t) {
111
116
  (function(r, n) {
112
117
  e.exports = n();
113
118
  })(F, function() {
@@ -115,7 +120,7 @@ function ie() {
115
120
  var c;
116
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 F < "u" && F.crypto && (c = F.crypto), !c && typeof Ae == "function")
117
122
  try {
118
- c = Re;
123
+ c = $e;
119
124
  } catch {
120
125
  }
121
126
  var v = function() {
@@ -479,8 +484,8 @@ function ie() {
479
484
  s ? x = n.ceil(x) : x = n.max((x | 0) - this._minBufferSize, 0);
480
485
  var q = x * S, P = n.min(q * 4, _);
481
486
  if (q) {
482
- for (var N = 0; N < q; N += S)
483
- this._doProcessBlock(h, N);
487
+ for (var W = 0; W < q; W += S)
488
+ this._doProcessBlock(h, W);
484
489
  o = h.splice(0, q), a.sigBytes -= P;
485
490
  }
486
491
  return new g.init(o, P);
@@ -608,7 +613,7 @@ function ie() {
608
613
  }
609
614
  (function(e, t) {
610
615
  (function(r, n) {
611
- e.exports = n(ie());
616
+ e.exports = n(ce());
612
617
  })(F, function(r) {
613
618
  return function() {
614
619
  var n = r, u = n.lib, c = u.WordArray, v = n.enc;
@@ -684,13 +689,13 @@ function ie() {
684
689
  }
685
690
  }(), r.enc.Base64url;
686
691
  });
687
- })(oe);
688
- var $e = oe.exports;
689
- const ze = /* @__PURE__ */ se($e);
690
- var ae = { exports: {} };
692
+ })(ae);
693
+ var Re = ae.exports;
694
+ const ze = /* @__PURE__ */ ie(Re);
695
+ var ue = { exports: {} };
691
696
  (function(e, t) {
692
697
  (function(r, n) {
693
- e.exports = n(ie());
698
+ e.exports = n(ce());
694
699
  })(F, function(r) {
695
700
  return function(n) {
696
701
  var u = r, c = u.lib, v = c.WordArray, B = c.Hasher, p = u.algo, y = [], m = [];
@@ -716,11 +721,11 @@ var ae = { exports: {} };
716
721
  if (C < 16)
717
722
  g[C] = d[l + C] | 0;
718
723
  else {
719
- var x = g[C - 15], q = (x << 25 | x >>> 7) ^ (x << 14 | x >>> 18) ^ x >>> 3, P = g[C - 2], N = (P << 15 | P >>> 17) ^ (P << 13 | P >>> 19) ^ P >>> 10;
720
- g[C] = q + g[C - 7] + N + g[C - 16];
724
+ var x = g[C - 15], q = (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;
725
+ g[C] = q + g[C - 7] + W + g[C - 16];
721
726
  }
722
- var ce = a & h ^ ~a & _, ue = f & A ^ f & s ^ A & s, he = (f << 30 | f >>> 2) ^ (f << 19 | f >>> 13) ^ (f << 10 | f >>> 22), de = (a << 26 | a >>> 6) ^ (a << 21 | a >>> 11) ^ (a << 7 | a >>> 25), Y = S + de + ce + m[C] + g[C], fe = he + ue;
723
- S = _, _ = h, h = a, a = o + Y | 0, o = s, s = A, A = f, f = Y + fe | 0;
727
+ var he = a & h ^ ~a & _, de = f & A ^ f & s ^ A & s, fe = (f << 30 | f >>> 2) ^ (f << 19 | f >>> 13) ^ (f << 10 | f >>> 22), le = (a << 26 | a >>> 6) ^ (a << 21 | a >>> 11) ^ (a << 7 | a >>> 25), Y = S + le + he + m[C] + g[C], pe = fe + de;
728
+ S = _, _ = h, h = a, a = o + Y | 0, o = s, s = A, A = f, f = Y + pe | 0;
724
729
  }
725
730
  i[0] = i[0] + f | 0, i[1] = i[1] + A | 0, i[2] = i[2] + s | 0, i[3] = i[3] + o | 0, i[4] = i[4] + a | 0, i[5] = i[5] + h | 0, i[6] = i[6] + _ | 0, i[7] = i[7] + S | 0;
726
731
  },
@@ -736,9 +741,9 @@ var ae = { exports: {} };
736
741
  u.SHA256 = B._createHelper(b), u.HmacSHA256 = B._createHmacHelper(b);
737
742
  }(Math), r.SHA256;
738
743
  });
739
- })(ae);
740
- var Ue = ae.exports;
741
- const He = /* @__PURE__ */ se(Ue), Pe = (e, t) => {
744
+ })(ue);
745
+ var Ue = ue.exports;
746
+ const He = /* @__PURE__ */ ie(Ue), Pe = (e, t) => {
742
747
  const {
743
748
  client_id: r,
744
749
  redirect_uri: n,
@@ -752,7 +757,7 @@ const He = /* @__PURE__ */ se(Ue), Pe = (e, t) => {
752
757
  } = e, g = y ? {
753
758
  address: y,
754
759
  ...m !== void 0 ? { signature: m } : {},
755
- ...v !== void 0 || B !== void 0 ? { chain: v ? Be(v) : B } : {},
760
+ ...v !== void 0 || B !== void 0 ? { chain: v ? oe(v) : B } : {},
756
761
  ...v !== void 0 || p !== void 0 ? { network: v ? ke(v) : p } : {}
757
762
  } : {};
758
763
  return Q({
@@ -772,16 +777,16 @@ const He = /* @__PURE__ */ se(Ue), Pe = (e, t) => {
772
777
  for (; n < 128; )
773
778
  e += t.charAt(Math.floor(Math.random() * r)), n += 1;
774
779
  return e;
775
- }, Te = (e) => ze.stringify(He(e)), te = (e, t) => {
780
+ }, Te = (e) => ze.stringify(He(e)), re = (e, t) => {
776
781
  const r = Oe(), n = Te(r);
777
782
  return sessionStorage.setItem(M, r || ""), `${e}/auth?${Pe(t, n)}`;
778
- }, re = () => {
783
+ }, ne = () => {
779
784
  const e = window.location.href;
780
785
  if (!e || !(e != null && e.includes("?")))
781
786
  return;
782
787
  const [t, r] = e.split("?");
783
788
  r && window.history.replaceState(null, "", t);
784
- }, ne = (e) => e.code != null, Me = (e) => e.refresh_token != null, Le = (e) => e.client_secret != null, qe = async (e, t, r, n) => {
789
+ }, se = (e) => e.code != null, Me = (e) => e.refresh_token != null, Le = (e) => e.client_secret != null, qe = async (e, t, r, n) => {
785
790
  const u = await fetch(`${e}`, {
786
791
  method: t,
787
792
  headers: n,
@@ -798,24 +803,24 @@ const He = /* @__PURE__ */ se(Ue), Pe = (e, t) => {
798
803
  throw c;
799
804
  return c;
800
805
  }, T = typeof window > "u";
801
- var z, D, L, H, U, O, j, E, R, V, G, J;
806
+ var z, N, L, H, U, O, j, E, $, V, G, J;
802
807
  class We {
803
808
  constructor(t) {
804
809
  /**
805
810
  * {@link https://monerium.dev/api-docs#operation/auth-token}
806
811
  */
807
- $(this, O);
812
+ R(this, O);
808
813
  // -- Helper Methods
809
- $(this, E);
810
- $(this, z, void 0);
811
- $(this, D, void 0);
814
+ R(this, E);
815
+ R(this, z, void 0);
816
+ R(this, N, void 0);
812
817
  /** The socket will be available after subscribing to an event */
813
- $(this, L, void 0);
814
- $(this, H, void 0);
815
- $(this, U, void 0);
816
- $(this, V, void 0);
817
- $(this, G, void 0);
818
- $(this, J, void 0);
818
+ R(this, L, void 0);
819
+ R(this, H, void 0);
820
+ R(this, U, void 0);
821
+ R(this, V, void 0);
822
+ R(this, G, void 0);
823
+ R(this, J, void 0);
819
824
  if (I(this, H, /* @__PURE__ */ new Map()), this.isAuthorized = !!this.bearerProfile, I(this, V, async (r, n, u) => {
820
825
  const c = sessionStorage.getItem(M) || "";
821
826
  if (!c)
@@ -852,7 +857,7 @@ class We {
852
857
  console.info(`Socket connection closed: ${r}`);
853
858
  }), n;
854
859
  }, this.auth = async (r) => await k(this, O, j).call(this, r), this.connect = async (r) => await k(this, O, j).call(this, r), this.getAuthFlowURI = (r) => {
855
- const n = te(w(this, z).api, r);
860
+ const n = re(w(this, z).api, r);
856
861
  return this.codeVerifier = sessionStorage.getItem(M), n;
857
862
  }, this.pkceRequest = (r) => this.getAuthFlowURI(r), this.getEnvironment = () => w(this, z), !t) {
858
863
  I(this, z, X.environments.sandbox);
@@ -888,7 +893,7 @@ class We {
888
893
  throw new Error("Missing ClientId");
889
894
  if (!n)
890
895
  throw new Error("Missing RedirectUrl");
891
- const u = te(w(this, z).api, {
896
+ const u = re(w(this, z).api, {
892
897
  client_id: r,
893
898
  redirect_uri: n,
894
899
  address: t == null ? void 0 : t.address,
@@ -915,7 +920,7 @@ class We {
915
920
  throw new Error("Missing ClientId");
916
921
  if (T)
917
922
  throw new Error("This only works client side");
918
- const c = new URLSearchParams(window.location.search).get("code") || void 0, v = sessionStorage.getItem(W) || void 0;
923
+ const c = new URLSearchParams(window.location.search).get("code") || void 0, v = sessionStorage.getItem(D) || void 0;
919
924
  return v ? await w(this, J).call(this, r, v) : c && await w(this, V).call(this, r, u, c), !!this.bearerProfile;
920
925
  }
921
926
  // -- Read Methods
@@ -923,7 +928,7 @@ class We {
923
928
  * {@link https://monerium.dev/api-docs#operation/auth-context}
924
929
  */
925
930
  getAuthContext() {
926
- return k(this, E, R).call(this, "get", "auth/context");
931
+ return k(this, E, $).call(this, "get", "auth/context");
927
932
  }
928
933
  /**
929
934
  * {@link https://monerium.dev/api-docs#operation/profile}
@@ -931,47 +936,47 @@ class We {
931
936
 
932
937
  */
933
938
  getProfile(t) {
934
- return k(this, E, R).call(this, "get", `profiles/${t}`);
939
+ return k(this, E, $).call(this, "get", `profiles/${t}`);
935
940
  }
936
941
  /**
937
942
  * {@link https://monerium.dev/api-docs#operation/profile-balances}
938
943
  * @param {string=} profileId - the id of the profile to fetch balances.
939
944
  */
940
945
  getBalances(t) {
941
- return t ? k(this, E, R).call(this, "get", `profiles/${t}/balances`) : k(this, E, R).call(this, "get", "balances");
946
+ return t ? k(this, E, $).call(this, "get", `profiles/${t}/balances`) : k(this, E, $).call(this, "get", "balances");
942
947
  }
943
948
  /**
944
949
  * {@link https://monerium.dev/api-docs#operation/orders}
945
950
  */
946
951
  getOrders(t) {
947
952
  const r = Q(t);
948
- return k(this, E, R).call(this, "get", `orders?${r}`);
953
+ return k(this, E, $).call(this, "get", `orders?${r}`);
949
954
  }
950
955
  /**
951
956
  * {@link https://monerium.dev/api-docs#operation/order}
952
957
  */
953
958
  getOrder(t) {
954
- return k(this, E, R).call(this, "get", `orders/${t}`);
959
+ return k(this, E, $).call(this, "get", `orders/${t}`);
955
960
  }
956
961
  /**
957
962
  * {@link https://monerium.dev/api-docs#operation/tokens}
958
963
  */
959
964
  getTokens() {
960
- return k(this, E, R).call(this, "get", "tokens");
965
+ return k(this, E, $).call(this, "get", "tokens");
961
966
  }
962
967
  // -- Write Methods
963
968
  /**
964
969
  * {@link https://monerium.dev/api-docs#operation/profile-addresses}
965
970
  */
966
971
  linkAddress(t, r) {
967
- return k(this, E, R).call(this, "post", `profiles/${t}/addresses`, JSON.stringify(r));
972
+ return k(this, E, $).call(this, "post", `profiles/${t}/addresses`, JSON.stringify(r));
968
973
  }
969
974
  /**
970
975
  * {@link https://monerium.dev/api-docs#operation/post-orders}
971
976
  */
972
977
  placeOrder(t, r) {
973
978
  const n = { ...t, kind: "redeem", currency: "eur" };
974
- return r ? k(this, E, R).call(this, "post", `profiles/${r}/orders`, JSON.stringify(n)) : k(this, E, R).call(this, "post", "orders", JSON.stringify(n));
979
+ return r ? k(this, E, $).call(this, "post", `profiles/${r}/orders`, JSON.stringify(n)) : k(this, E, $).call(this, "post", "orders", JSON.stringify(n));
975
980
  }
976
981
  /**
977
982
  * {@link https://monerium.dev/api-docs#operation/supporting-document}
@@ -980,7 +985,7 @@ class We {
980
985
  const r = Q(
981
986
  t
982
987
  );
983
- return k(this, E, R).call(this, "post", "files/supporting-document", r, !0);
988
+ return k(this, E, $).call(this, "post", "files/supporting-document", r, !0);
984
989
  }
985
990
  // -- Notifications
986
991
  async connectOrderSocket() {
@@ -992,13 +997,13 @@ class We {
992
997
  */
993
998
  async disconnect() {
994
999
  var t;
995
- T || sessionStorage.removeItem(M), w(this, H).clear(), (t = w(this, L)) == null || t.close();
1000
+ T || sessionStorage.removeItem(M), w(this, H).clear(), (t = w(this, L)) == null || t.close(), I(this, N, void 0), this.bearerProfile = void 0;
996
1001
  }
997
1002
  /**
998
1003
  * Revokes access
999
1004
  */
1000
1005
  async revokeAccess() {
1001
- T || sessionStorage.removeItem(W), this.disconnect();
1006
+ T || sessionStorage.removeItem(D), this.disconnect();
1002
1007
  }
1003
1008
  /**
1004
1009
  * Subscribe to MoneriumEvent to receive notifications using the Monerium API (WebSocket)
@@ -1019,9 +1024,9 @@ class We {
1019
1024
  w(this, H).delete(t), w(this, H).size === 0 && ((r = w(this, L)) == null || r.close(), I(this, L, void 0));
1020
1025
  }
1021
1026
  }
1022
- z = new WeakMap(), D = new WeakMap(), L = new WeakMap(), H = new WeakMap(), U = new WeakMap(), O = new WeakSet(), j = async function(t) {
1027
+ z = new WeakMap(), N = new WeakMap(), L = new WeakMap(), H = new WeakMap(), U = new WeakMap(), O = new WeakSet(), j = async function(t) {
1023
1028
  let r;
1024
- if (ne(t))
1029
+ if (se(t))
1025
1030
  r = { ...t, grant_type: "authorization_code" };
1026
1031
  else if (Me(t))
1027
1032
  r = { ...t, grant_type: "refresh_token" };
@@ -1029,40 +1034,40 @@ z = new WeakMap(), D = new WeakMap(), L = new WeakMap(), H = new WeakMap(), U =
1029
1034
  r = { ...t, grant_type: "client_credentials" };
1030
1035
  else
1031
1036
  throw new Error("Authorization grant type could not be detected.");
1032
- return await k(this, E, R).call(this, "post", "auth/token", r, !0).then((n) => {
1037
+ return await k(this, E, $).call(this, "post", "auth/token", r, !0).then((n) => {
1033
1038
  var u;
1034
- this.bearerProfile = n, this.isAuthorized = !!n, I(this, D, `Bearer ${n == null ? void 0 : n.access_token}`), T || window.sessionStorage.setItem(
1035
- W,
1039
+ this.bearerProfile = n, this.isAuthorized = !!n, I(this, N, `Bearer ${n == null ? void 0 : n.access_token}`), T || window.sessionStorage.setItem(
1040
+ D,
1036
1041
  ((u = this.bearerProfile) == null ? void 0 : u.refresh_token) || ""
1037
1042
  );
1038
1043
  }).catch((n) => {
1039
- throw T || (sessionStorage.removeItem(M), sessionStorage.removeItem(W), re()), new Error(n == null ? void 0 : n.message);
1040
- }), ne(t) && re(), this.bearerProfile;
1041
- }, E = new WeakSet(), R = async function(t, r, n, u) {
1044
+ throw T || (sessionStorage.removeItem(M), sessionStorage.removeItem(D), ne()), new Error(n == null ? void 0 : n.message);
1045
+ }), se(t) && ne(), this.bearerProfile;
1046
+ }, E = new WeakSet(), $ = async function(t, r, n, u) {
1042
1047
  return qe(
1043
1048
  `${w(this, z).api}/${r}`,
1044
1049
  t,
1045
1050
  u ? Q(n) : n,
1046
1051
  {
1047
- Authorization: w(this, D) || "",
1052
+ Authorization: w(this, N) || "",
1048
1053
  "Content-Type": `application/${u ? "x-www-form-urlencoded" : "json"}`
1049
1054
  }
1050
1055
  );
1051
1056
  }, V = new WeakMap(), G = new WeakMap(), J = new WeakMap();
1052
1057
  export {
1053
- ye as AccountState,
1054
- le as Currency,
1055
- we as KYCOutcome,
1056
- ge as KYCState,
1058
+ _e as AccountState,
1059
+ ve as Currency,
1060
+ me as KYCOutcome,
1061
+ ye as KYCState,
1057
1062
  We as MoneriumClient,
1058
- _e as OrderKind,
1059
- be as OrderState,
1060
- me as PaymentStandard,
1061
- ve as Permission,
1062
- pe as ProfileType,
1063
+ Se as OrderKind,
1064
+ Be as OrderState,
1065
+ be as PaymentStandard,
1066
+ we as Permission,
1067
+ ge as ProfileType,
1063
1068
  Ne as constants,
1064
- Be as getChain,
1069
+ oe as getChain,
1065
1070
  ke as getNetwork,
1066
1071
  Fe as placeOrderMessage,
1067
- Se as rfc3339
1072
+ ee as rfc3339
1068
1073
  };
package/dist/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@monerium/sdk",
3
- "version": "2.7.3",
3
+ "version": "2.8.2",
4
4
  "description": "Everything you need to interact with the Monerium API - an electronic money issuer.",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "git+https://github.com/monerium/sdk.git"
8
+ "url": "git+https://github.com/monerium/js-sdk.git"
9
9
  },
10
10
  "bugs": {
11
- "url": "https://github.com/monerium/sdk/issues"
11
+ "url": "https://github.com/monerium/js-sdk/issues"
12
12
  },
13
13
  "main": "./dist/index.js",
14
14
  "module": "./dist/index.mjs",
@@ -29,11 +29,11 @@
29
29
  "crypto-js": "^4.2.0"
30
30
  },
31
31
  "scripts": {
32
- "build:watch": "yarn build:main --watch",
33
32
  "docs": "yarn typedoc --options docs/typedoc.json && node docs/editStatic.js",
34
33
  "docs:watch": "nodemon --watch . --ignore static -e ts,css,md --exec 'typedoc --options docs/typedoc.json && node docs/editStatic.js'"
35
34
  },
36
35
  "devDependencies": {
36
+ "nodemon": "3.0.1",
37
37
  "typedoc": "0.23.23",
38
38
  "typedoc-theme-hierarchy": "^3.2.1"
39
39
  }
package/dist/types.d.ts CHANGED
@@ -151,7 +151,12 @@ export interface KYC {
151
151
  }
152
152
  export declare enum PaymentStandard {
153
153
  iban = "iban",
154
- scan = "scan"
154
+ scan = "scan",
155
+ chain = "chain"
156
+ }
157
+ export interface Identifier {
158
+ standard: PaymentStandard;
159
+ bic?: string;
155
160
  }
156
161
  export interface Account {
157
162
  address: string;
@@ -195,11 +200,17 @@ export interface Fee {
195
200
  currency: Currency;
196
201
  amount: string;
197
202
  }
198
- export interface IBAN {
203
+ export interface IBAN extends Identifier {
199
204
  standard: PaymentStandard.iban;
200
205
  iban: string;
201
206
  }
202
- export interface SCAN {
207
+ export interface CrossChain extends Identifier {
208
+ standard: PaymentStandard.chain;
209
+ address: string;
210
+ chain: string;
211
+ network: string;
212
+ }
213
+ export interface SCAN extends Identifier {
203
214
  standard: PaymentStandard.scan;
204
215
  sortCode: string;
205
216
  accountNumber: string;
@@ -214,7 +225,7 @@ export interface Corporation {
214
225
  country: string;
215
226
  }
216
227
  export interface Counterpart {
217
- identifier: IBAN | SCAN;
228
+ identifier: IBAN | SCAN | CrossChain;
218
229
  details: Individual | Corporation;
219
230
  }
220
231
  export interface OrderMetadata {
package/dist/utils.d.ts CHANGED
@@ -5,7 +5,7 @@ export declare const rfc3339: (d: Date) => string;
5
5
  *
6
6
  * @returns string
7
7
  */
8
- export declare const placeOrderMessage: (amount: string | number, iban: string) => string;
8
+ export declare const placeOrderMessage: (amount: string | number, receiver: string, chainId?: number, currency?: 'eur' | 'gbp' | 'usd' | 'isk') => string;
9
9
  /**
10
10
  * Replacement for URLSearchParams, Metamask snaps do not include node globals.
11
11
  * It will not handle all special characters the same way as URLSearchParams, but it will be good enough for our use case.
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@monerium/sdk",
3
- "version": "2.7.3",
3
+ "version": "2.8.2",
4
4
  "description": "Everything you need to interact with the Monerium API - an electronic money issuer.",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "git+https://github.com/monerium/sdk.git"
8
+ "url": "git+https://github.com/monerium/js-sdk.git"
9
9
  },
10
10
  "bugs": {
11
- "url": "https://github.com/monerium/sdk/issues"
11
+ "url": "https://github.com/monerium/js-sdk/issues"
12
12
  },
13
13
  "main": "./dist/index.js",
14
14
  "module": "./dist/index.mjs",
@@ -29,11 +29,11 @@
29
29
  "crypto-js": "^4.2.0"
30
30
  },
31
31
  "scripts": {
32
- "build:watch": "yarn build:main --watch",
33
32
  "docs": "yarn typedoc --options docs/typedoc.json && node docs/editStatic.js",
34
33
  "docs:watch": "nodemon --watch . --ignore static -e ts,css,md --exec 'typedoc --options docs/typedoc.json && node docs/editStatic.js'"
35
34
  },
36
35
  "devDependencies": {
36
+ "nodemon": "3.0.1",
37
37
  "typedoc": "0.23.23",
38
38
  "typedoc-theme-hierarchy": "^3.2.1"
39
39
  }