@monerium/sdk 2.8.0 → 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 +16 -0
- package/README.md +26 -28
- package/dist/index.js +1 -1
- package/dist/index.mjs +58 -55
- package/dist/package.json +2 -2
- package/dist/utils.d.ts +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
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
|
+
|
|
3
19
|
## [2.8.0](https://github.com/monerium/js-sdk/compare/sdk-v2.7.3...sdk-v2.8.0) (2023-11-22)
|
|
4
20
|
|
|
5
21
|
|
package/README.md
CHANGED
|
@@ -315,31 +315,31 @@ API documentation:
|
|
|
315
315
|
|
|
316
316
|
#### Subscribe to order events
|
|
317
317
|
|
|
318
|
-
|
|
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
|
-
|
|
327
|
-
setOrderState(notification.meta.state)
|
|
328
|
-
})
|
|
326
|
+
monerium.subscribeOrders(OrderState.placed, (notification) => {
|
|
327
|
+
setOrderState(notification.meta.state);
|
|
328
|
+
});
|
|
329
329
|
|
|
330
|
-
|
|
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
|
-
|
|
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
|
-
|
|
357
|
+
nx run sdk:init
|
|
358
358
|
|
|
359
359
|
# Run Vite to build a production release distributable
|
|
360
|
-
|
|
360
|
+
nx run sdk:build
|
|
361
361
|
|
|
362
362
|
# Run Vite in watch mode to detect changes to files during development
|
|
363
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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)),$=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},I=(e,t,r,n)=>(Z(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);var B=(e,t,r)=>(Z(e,t,"access private method"),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var ie=(e=>(e.eur="eur",e))(ie||{}),ae=(e=>(e.corporate="corporate",e.personal="personal",e))(ae||{}),ce=(e=>(e.read="read",e.write="write",e))(ce||{}),ue=(e=>(e.absent="absent",e.submitted="submitted",e.pending="pending",e.confirmed="confirmed",e))(ue||{}),he=(e=>(e.approved="approved",e.rejected="rejected",e.unknown="unknown",e))(he||{}),de=(e=>(e.requested="requested",e.approved="approved",e.pending="pending",e))(de||{}),fe=(e=>(e.iban="iban",e.scan="scan",e.chain="chain",e))(fe||{}),le=(e=>(e.redeem="redeem",e.issue="issue",e))(le||{}),pe=(e=>(e.placed="placed",e.pending="pending",e.processed="processed",e.rejected="rejected",e))(pe||{});const Y=e=>{if(e.toString()==="Invalid Date")throw e;const t=n=>n<10?"0"+n:n,r=n=>{if(n===0)return"Z";const u=n>0?"-":"+";return n=Math.abs(n),u+t(Math.floor(n/60))+":"+t(n%60)};return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+"T"+t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+r(e.getTimezoneOffset())},ke=(e,t,r)=>r?`Send EUR ${e} to ${t} on ${ee(r)} at ${Y(new Date)}`:`Send EUR ${e} to ${t} at ${Y(new Date)}`,Q=e=>{var t;return e&&((t=Object.entries(e))==null?void 0:t.length)>0?Object.entries(e).map(([r,n])=>`${encodeURIComponent(r)}=${encodeURIComponent(n)}`).join("&"):""},ee=e=>{switch(e){case 1:case 5:return"ethereum";case 100:case 10200:return"gnosis";case 137:case 80001:return"polygon";default:throw new Error(`Chain not supported: ${e}`)}},ve=e=>{switch(e){case 1:case 100:case 137:return"mainnet";case 5:return"goerli";case 10200:return"chiado";case 80001:return"mumbai";default:throw new Error(`Network not supported: ${e}`)}},K={environments:{production:{api:"https://api.monerium.app",web:"https://monerium.app",wss:"wss://api.monerium.app"},sandbox:{api:"https://api.monerium.dev",web:"https://sandbox.monerium.dev",wss:"wss://api.monerium.dev"}}},xe="I hereby declare that I am the address owner.",M="monerium.sdk.code_verifier",W="monerium.sdk.refresh_token",Ae={LINK_MESSAGE:xe,STORAGE_CODE_VERIFIER:M,STORAGE_REFRESH_TOKEN:W};var N=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ge(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Ee(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var u=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,u.get?u:{enumerable:!0,get:function(){return e[n]}})}),r}var we={exports:{}};function Ie(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var X={exports:{}};const Re={},$e=Object.freeze(Object.defineProperty({__proto__:null,default:Re},Symbol.toStringTag,{value:"Module"})),Oe=Ee($e);var re;function ye(){return re||(re=1,function(e,t){(function(r,n){e.exports=n()})(N,function(){var r=r||function(n,u){var c;if(typeof window<"u"&&window.crypto&&(c=window.crypto),typeof self<"u"&&self.crypto&&(c=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(c=globalThis.crypto),!c&&typeof window<"u"&&window.msCrypto&&(c=window.msCrypto),!c&&typeof N<"u"&&N.crypto&&(c=N.crypto),!c&&typeof Ie=="function")try{c=Oe}catch{}var v=function(){if(c){if(typeof c.getRandomValues=="function")try{return c.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof c.randomBytes=="function")try{return c.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},C=Object.create||function(){function s(){}return function(o){var a;return s.prototype=o,a=new s,s.prototype=null,a}}(),p={},y=p.lib={},m=y.Base=function(){return{extend:function(s){var o=C(this);return s&&o.mixIn(s),(!o.hasOwnProperty("init")||this.init===o.init)&&(o.init=function(){o.$super.init.apply(this,arguments)}),o.init.prototype=o,o.$super=this,o},create:function(){var s=this.extend();return s.init.apply(s,arguments),s},init:function(){},mixIn:function(s){for(var o in s)s.hasOwnProperty(o)&&(this[o]=s[o]);s.hasOwnProperty("toString")&&(this.toString=s.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),g=y.WordArray=m.extend({init:function(s,o){s=this.words=s||[],o!=u?this.sigBytes=o:this.sigBytes=s.length*4},toString:function(s){return(s||d).stringify(this)},concat:function(s){var o=this.words,a=s.words,h=this.sigBytes,_=s.sigBytes;if(this.clamp(),h%4)for(var S=0;S<_;S++){var k=a[S>>>2]>>>24-S%4*8&255;o[h+S>>>2]|=k<<24-(h+S)%4*8}else for(var x=0;x<_;x+=4)o[h+x>>>2]=a[x>>>2];return this.sigBytes+=_,this},clamp:function(){var s=this.words,o=this.sigBytes;s[o>>>2]&=4294967295<<32-o%4*8,s.length=n.ceil(o/4)},clone:function(){var s=m.clone.call(this);return s.words=this.words.slice(0),s},random:function(s){for(var o=[],a=0;a<s;a+=4)o.push(v());return new g.init(o,s)}}),b=p.enc={},d=b.Hex={stringify:function(s){for(var o=s.words,a=s.sigBytes,h=[],_=0;_<a;_++){var S=o[_>>>2]>>>24-_%4*8&255;h.push((S>>>4).toString(16)),h.push((S&15).toString(16))}return h.join("")},parse:function(s){for(var o=s.length,a=[],h=0;h<o;h+=2)a[h>>>3]|=parseInt(s.substr(h,2),16)<<24-h%8*4;return new g.init(a,o/2)}},l=b.Latin1={stringify:function(s){for(var o=s.words,a=s.sigBytes,h=[],_=0;_<a;_++){var S=o[_>>>2]>>>24-_%4*8&255;h.push(String.fromCharCode(S))}return h.join("")},parse:function(s){for(var o=s.length,a=[],h=0;h<o;h++)a[h>>>2]|=(s.charCodeAt(h)&255)<<24-h%4*8;return new g.init(a,o)}},i=b.Utf8={stringify:function(s){try{return decodeURIComponent(escape(l.stringify(s)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(s){return l.parse(unescape(encodeURIComponent(s)))}},f=y.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new g.init,this._nDataBytes=0},_append:function(s){typeof s=="string"&&(s=i.parse(s)),this._data.concat(s),this._nDataBytes+=s.sigBytes},_process:function(s){var o,a=this._data,h=a.words,_=a.sigBytes,S=this.blockSize,k=S*4,x=_/k;s?x=n.ceil(x):x=n.max((x|0)-this._minBufferSize,0);var j=x*S,U=n.min(j*4,_);if(j){for(var F=0;F<j;F+=S)this._doProcessBlock(h,F);o=h.splice(0,j),a.sigBytes-=U}return new g.init(o,U)},clone:function(){var s=m.clone.call(this);return s._data=this._data.clone(),s},_minBufferSize:0});y.Hasher=f.extend({cfg:m.extend(),init:function(s){this.cfg=this.cfg.extend(s),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(s){return this._append(s),this._process(),this},finalize:function(s){s&&this._append(s);var o=this._doFinalize();return o},blockSize:16,_createHelper:function(s){return function(o,a){return new s.init(a).finalize(o)}},_createHmacHelper:function(s){return function(o,a){return new A.HMAC.init(s,a).finalize(o)}}});var A=p.algo={};return p}(Math);return r})}(X)),X.exports}(function(e,t){(function(r,n){e.exports=n(ye())})(N,function(r){return function(){var n=r,u=n.lib,c=u.WordArray,v=n.enc;v.Base64url={stringify:function(p,y){y===void 0&&(y=!0);var m=p.words,g=p.sigBytes,b=y?this._safe_map:this._map;p.clamp();for(var d=[],l=0;l<g;l+=3)for(var i=m[l>>>2]>>>24-l%4*8&255,f=m[l+1>>>2]>>>24-(l+1)%4*8&255,A=m[l+2>>>2]>>>24-(l+2)%4*8&255,s=i<<16|f<<8|A,o=0;o<4&&l+o*.75<g;o++)d.push(b.charAt(s>>>6*(3-o)&63));var a=b.charAt(64);if(a)for(;d.length%4;)d.push(a);return d.join("")},parse:function(p,y){y===void 0&&(y=!0);var m=p.length,g=y?this._safe_map:this._map,b=this._reverseMap;if(!b){b=this._reverseMap=[];for(var d=0;d<g.length;d++)b[g.charCodeAt(d)]=d}var l=g.charAt(64);if(l){var i=p.indexOf(l);i!==-1&&(m=i)}return C(p,m,b)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"};function C(p,y,m){for(var g=[],b=0,d=0;d<y;d++)if(d%4){var l=m[p.charCodeAt(d-1)]<<d%4*2,i=m[p.charCodeAt(d)]>>>6-d%4*2,f=l|i;g[b>>>2]|=f<<24-b%4*8,b++}return c.create(g,b)}}(),r.enc.Base64url})})(we);var Pe=we.exports;const ze=ge(Pe);var me={exports:{}};(function(e,t){(function(r,n){e.exports=n(ye())})(N,function(r){return function(n){var u=r,c=u.lib,v=c.WordArray,C=c.Hasher,p=u.algo,y=[],m=[];(function(){function d(A){for(var s=n.sqrt(A),o=2;o<=s;o++)if(!(A%o))return!1;return!0}function l(A){return(A-(A|0))*4294967296|0}for(var i=2,f=0;f<64;)d(i)&&(f<8&&(y[f]=l(n.pow(i,1/2))),m[f]=l(n.pow(i,1/3)),f++),i++})();var g=[],b=p.SHA256=C.extend({_doReset:function(){this._hash=new v.init(y.slice(0))},_doProcessBlock:function(d,l){for(var i=this._hash.words,f=i[0],A=i[1],s=i[2],o=i[3],a=i[4],h=i[5],_=i[6],S=i[7],k=0;k<64;k++){if(k<16)g[k]=d[l+k]|0;else{var x=g[k-15],j=(x<<25|x>>>7)^(x<<14|x>>>18)^x>>>3,U=g[k-2],F=(U<<15|U>>>17)^(U<<13|U>>>19)^U>>>10;g[k]=j+g[k-7]+F+g[k-16]}var _e=a&h^~a&_,be=f&A^f&s^A&s,Se=(f<<30|f>>>2)^(f<<19|f>>>13)^(f<<10|f>>>22),Ce=(a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25),te=S+Ce+_e+m[k]+g[k],Be=Se+be;S=_,_=h,h=a,a=o+te|0,o=s,s=A,A=f,f=te+Be|0}i[0]=i[0]+f|0,i[1]=i[1]+A|0,i[2]=i[2]+s|0,i[3]=i[3]+o|0,i[4]=i[4]+a|0,i[5]=i[5]+h|0,i[6]=i[6]+_|0,i[7]=i[7]+S|0},_doFinalize:function(){var d=this._data,l=d.words,i=this._nDataBytes*8,f=d.sigBytes*8;return l[f>>>5]|=128<<24-f%32,l[(f+64>>>9<<4)+14]=n.floor(i/4294967296),l[(f+64>>>9<<4)+15]=i,d.sigBytes=l.length*4,this._process(),this._hash},clone:function(){var d=C.clone.call(this);return d._hash=this._hash.clone(),d}});u.SHA256=C._createHelper(b),u.HmacSHA256=C._createHmacHelper(b)}(Math),r.SHA256})})(me);var Ue=me.exports;const He=ge(Ue),Te=(e,t)=>{const{client_id:r,redirect_uri:n,scope:u,state:c,chainId:v,chain:C,network:p,address:y,signature:m}=e,g=y?{address:y,...m!==void 0?{signature:m}:{},...v!==void 0||C!==void 0?{chain:v?ee(v):C}:{},...v!==void 0||p!==void 0?{network:v?ve(v):p}:{}}:{};return Q({client_id:r,redirect_uri:n,...u!==void 0?{scope:u}:{},...c!==void 0?{state:c}:{},code_challenge:t,code_challenge_method:"S256",response_type:"code",...g})},Me=()=>{let e="";const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=t.length;let n=0;for(;n<128;)e+=t.charAt(Math.floor(Math.random()*r)),n+=1;return e},Le=e=>ze.stringify(He(e)),ne=(e,t)=>{const r=Me(),n=Le(r);return sessionStorage.setItem(M,r||""),`${e}/auth?${Te(t,n)}`},se=()=>{const e=window.location.href;if(!e||!(e!=null&&e.includes("?")))return;const[t,r]=e.split("?");r&&window.history.replaceState(null,"",t)},oe=e=>e.code!=null,je=e=>e.refresh_token!=null,qe=e=>e.client_secret!=null,Ne=async(e,t,r,n)=>{const u=await fetch(`${e}`,{method:t,headers:n,body:r});let c;const v=await u.text();try{c=JSON.parse(v)}catch{throw v}if(!u.ok)throw c;return c},T=typeof window>"u";var O,D,L,z,P,H,q,E,R,V,G,J;class Fe{constructor(t){$(this,H);$(this,E);$(this,O,void 0);$(this,D,void 0);$(this,L,void 0);$(this,z,void 0);$(this,P,void 0);$(this,V,void 0);$(this,G,void 0);$(this,J,void 0);if(I(this,z,new Map),this.isAuthorized=!!this.bearerProfile,I(this,V,async(r,n,u)=>{const c=sessionStorage.getItem(M)||"";if(!c)throw new Error("Code verifier not found");return this.codeVerifier=c,sessionStorage.removeItem(M),await B(this,H,q).call(this,{code:u,redirect_uri:n,client_id:r,code_verifier:c})}),I(this,G,async({clientId:r,clientSecret:n})=>await B(this,H,q).call(this,{client_id:r,client_secret:n})),I(this,J,async(r,n)=>await B(this,H,q).call(this,{refresh_token:n,client_id:r})),this.subscribeToOrderNotifications=()=>{var u,c;const r=`${w(this,O).wss}/profiles/${(u=this.bearerProfile)==null?void 0:u.profile}/orders?access_token=${(c=this.bearerProfile)==null?void 0:c.access_token}`,n=new WebSocket(r);return n.addEventListener("open",()=>{console.info(`Socket connected: ${r}`)}),n.addEventListener("error",v=>{throw console.error(v),new Error(`Socket error: ${r}`)}),n.addEventListener("message",v=>{var p;const C=JSON.parse(v.data);(p=w(this,z).get(C.meta.state))==null||p(C)}),n.addEventListener("close",()=>{console.info(`Socket connection closed: ${r}`)}),n},this.auth=async r=>await B(this,H,q).call(this,r),this.connect=async r=>await B(this,H,q).call(this,r),this.getAuthFlowURI=r=>{const n=ne(w(this,O).api,r);return this.codeVerifier=sessionStorage.getItem(M),n},this.pkceRequest=r=>this.getAuthFlowURI(r),this.getEnvironment=()=>w(this,O),!t){I(this,O,K.environments.sandbox);return}if(typeof t=="string")I(this,O,K.environments[t]);else if(I(this,O,K.environments[t.environment||"sandbox"]),T){const{clientId:r,clientSecret:n}=t;I(this,P,{clientId:r,clientSecret:n})}else{const{clientId:r,redirectUrl:n}=t;I(this,P,{clientId:r,redirectUrl:n})}}async authorize(t){var c,v;const r=(t==null?void 0:t.clientId)||((c=w(this,P))==null?void 0:c.clientId),n=(t==null?void 0:t.redirectUrl)||((v=w(this,P))==null?void 0:v.redirectUrl);if(!r)throw new Error("Missing ClientId");if(!n)throw new Error("Missing RedirectUrl");const u=ne(w(this,O).api,{client_id:r,redirect_uri:n,address:t==null?void 0:t.address,signature:t==null?void 0:t.signature,chainId:t==null?void 0:t.chainId});window.location.replace(u)}async getAccess(t){var C,p,y;const r=(t==null?void 0:t.clientId)||((C=w(this,P))==null?void 0:C.clientId);if((t==null?void 0:t.clientSecret)||((p=w(this,P))==null?void 0:p.clientSecret)){if(!T)throw new Error("Only use client credentials on server side");return await w(this,G).call(this,w(this,P)),!!this.bearerProfile}const u=(t==null?void 0:t.redirectUrl)||((y=w(this,P))==null?void 0:y.redirectUrl);if(!r)throw new Error("Missing ClientId");if(T)throw new Error("This only works client side");const c=new URLSearchParams(window.location.search).get("code")||void 0,v=sessionStorage.getItem(W)||void 0;return v?await w(this,J).call(this,r,v):c&&await w(this,V).call(this,r,u,c),!!this.bearerProfile}getAuthContext(){return B(this,E,R).call(this,"get","auth/context")}getProfile(t){return B(this,E,R).call(this,"get",`profiles/${t}`)}getBalances(t){return t?B(this,E,R).call(this,"get",`profiles/${t}/balances`):B(this,E,R).call(this,"get","balances")}getOrders(t){const r=Q(t);return B(this,E,R).call(this,"get",`orders?${r}`)}getOrder(t){return B(this,E,R).call(this,"get",`orders/${t}`)}getTokens(){return B(this,E,R).call(this,"get","tokens")}linkAddress(t,r){return B(this,E,R).call(this,"post",`profiles/${t}/addresses`,JSON.stringify(r))}placeOrder(t,r){const n={...t,kind:"redeem",currency:"eur"};return r?B(this,E,R).call(this,"post",`profiles/${r}/orders`,JSON.stringify(n)):B(this,E,R).call(this,"post","orders",JSON.stringify(n))}uploadSupportingDocument(t){const r=Q(t);return B(this,E,R).call(this,"post","files/supporting-document",r,!0)}async connectOrderSocket(){var t;(t=this.bearerProfile)!=null&&t.access_token&&w(this,z).size>0&&I(this,L,this.subscribeToOrderNotifications())}async disconnect(){var t;T||sessionStorage.removeItem(M),w(this,z).clear(),(t=w(this,L))==null||t.close()}async revokeAccess(){T||sessionStorage.removeItem(W),this.disconnect()}subscribeOrders(t,r){w(this,z).set(t,r)}unsubscribeOrders(t){var r;w(this,z).delete(t),w(this,z).size===0&&((r=w(this,L))==null||r.close(),I(this,L,void 0))}}O=new WeakMap,D=new WeakMap,L=new WeakMap,z=new WeakMap,P=new WeakMap,H=new WeakSet,q=async function(t){let r;if(oe(t))r={...t,grant_type:"authorization_code"};else if(je(t))r={...t,grant_type:"refresh_token"};else if(qe(t))r={...t,grant_type:"client_credentials"};else throw new Error("Authorization grant type could not be detected.");return await B(this,E,R).call(this,"post","auth/token",r,!0).then(n=>{var u;this.bearerProfile=n,this.isAuthorized=!!n,I(this,D,`Bearer ${n==null?void 0:n.access_token}`),T||window.sessionStorage.setItem(W,((u=this.bearerProfile)==null?void 0:u.refresh_token)||"")}).catch(n=>{throw T||(sessionStorage.removeItem(M),sessionStorage.removeItem(W),se()),new Error(n==null?void 0:n.message)}),oe(t)&&se(),this.bearerProfile},E=new WeakSet,R=async function(t,r,n,u){return Ne(`${w(this,O).api}/${r}`,t,u?Q(n):n,{Authorization:w(this,D)||"","Content-Type":`application/${u?"x-www-form-urlencoded":"json"}`})},V=new WeakMap,G=new WeakMap,J=new WeakMap;exports.AccountState=de;exports.Currency=ie;exports.KYCOutcome=he;exports.KYCState=ue;exports.MoneriumClient=Fe;exports.OrderKind=le;exports.OrderState=pe;exports.PaymentStandard=fe;exports.Permission=ce;exports.ProfileType=ae;exports.constants=Ae;exports.getChain=ee;exports.getNetwork=ve;exports.placeOrderMessage=ke;exports.rfc3339=Y;
|
|
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,7 +2,7 @@ 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)),
|
|
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);
|
|
@@ -19,9 +19,12 @@ const ee = (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, r) =>
|
|
23
|
-
|
|
24
|
-
|
|
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) => {
|
|
25
28
|
var t;
|
|
26
29
|
return e && ((t = Object.entries(e)) == null ? void 0 : t.length) > 0 ? Object.entries(e).map(
|
|
27
30
|
([r, n]) => `${encodeURIComponent(r)}=${encodeURIComponent(n)}`
|
|
@@ -68,10 +71,10 @@ const ee = (e) => {
|
|
|
68
71
|
wss: "wss://api.monerium.dev"
|
|
69
72
|
}
|
|
70
73
|
}
|
|
71
|
-
}, Ce = "I hereby declare that I am the address owner.", M = "monerium.sdk.code_verifier",
|
|
74
|
+
}, Ce = "I hereby declare that I am the address owner.", M = "monerium.sdk.code_verifier", D = "monerium.sdk.refresh_token", Ne = {
|
|
72
75
|
LINK_MESSAGE: Ce,
|
|
73
76
|
STORAGE_CODE_VERIFIER: M,
|
|
74
|
-
STORAGE_REFRESH_TOKEN:
|
|
77
|
+
STORAGE_REFRESH_TOKEN: D
|
|
75
78
|
};
|
|
76
79
|
var F = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
77
80
|
function ie(e) {
|
|
@@ -106,7 +109,7 @@ var K = { exports: {} };
|
|
|
106
109
|
const Ee = {}, Ie = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
107
110
|
__proto__: null,
|
|
108
111
|
default: Ee
|
|
109
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
112
|
+
}, Symbol.toStringTag, { value: "Module" })), $e = /* @__PURE__ */ xe(Ie);
|
|
110
113
|
var te;
|
|
111
114
|
function ce() {
|
|
112
115
|
return te || (te = 1, function(e, t) {
|
|
@@ -117,7 +120,7 @@ function ce() {
|
|
|
117
120
|
var c;
|
|
118
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")
|
|
119
122
|
try {
|
|
120
|
-
c =
|
|
123
|
+
c = $e;
|
|
121
124
|
} catch {
|
|
122
125
|
}
|
|
123
126
|
var v = function() {
|
|
@@ -479,13 +482,13 @@ function ce() {
|
|
|
479
482
|
_process: function(s) {
|
|
480
483
|
var o, a = this._data, h = a.words, _ = a.sigBytes, S = this.blockSize, C = S * 4, x = _ / C;
|
|
481
484
|
s ? x = n.ceil(x) : x = n.max((x | 0) - this._minBufferSize, 0);
|
|
482
|
-
var q = x * S,
|
|
485
|
+
var q = x * S, P = n.min(q * 4, _);
|
|
483
486
|
if (q) {
|
|
484
|
-
for (var
|
|
485
|
-
this._doProcessBlock(h,
|
|
486
|
-
o = h.splice(0, q), a.sigBytes -=
|
|
487
|
+
for (var W = 0; W < q; W += S)
|
|
488
|
+
this._doProcessBlock(h, W);
|
|
489
|
+
o = h.splice(0, q), a.sigBytes -= P;
|
|
487
490
|
}
|
|
488
|
-
return new g.init(o,
|
|
491
|
+
return new g.init(o, P);
|
|
489
492
|
},
|
|
490
493
|
/**
|
|
491
494
|
* Creates a copy of this object.
|
|
@@ -687,8 +690,8 @@ function ce() {
|
|
|
687
690
|
}(), r.enc.Base64url;
|
|
688
691
|
});
|
|
689
692
|
})(ae);
|
|
690
|
-
var
|
|
691
|
-
const ze = /* @__PURE__ */ ie(
|
|
693
|
+
var Re = ae.exports;
|
|
694
|
+
const ze = /* @__PURE__ */ ie(Re);
|
|
692
695
|
var ue = { exports: {} };
|
|
693
696
|
(function(e, t) {
|
|
694
697
|
(function(r, n) {
|
|
@@ -718,8 +721,8 @@ var ue = { exports: {} };
|
|
|
718
721
|
if (C < 16)
|
|
719
722
|
g[C] = d[l + C] | 0;
|
|
720
723
|
else {
|
|
721
|
-
var x = g[C - 15], q = (x << 25 | x >>> 7) ^ (x << 14 | x >>> 18) ^ x >>> 3,
|
|
722
|
-
g[C] = q + g[C - 7] +
|
|
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];
|
|
723
726
|
}
|
|
724
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;
|
|
725
728
|
S = _, _ = h, h = a, a = o + Y | 0, o = s, s = A, A = f, f = Y + pe | 0;
|
|
@@ -740,7 +743,7 @@ var ue = { exports: {} };
|
|
|
740
743
|
});
|
|
741
744
|
})(ue);
|
|
742
745
|
var Ue = ue.exports;
|
|
743
|
-
const He = /* @__PURE__ */ ie(Ue),
|
|
746
|
+
const He = /* @__PURE__ */ ie(Ue), Pe = (e, t) => {
|
|
744
747
|
const {
|
|
745
748
|
client_id: r,
|
|
746
749
|
redirect_uri: n,
|
|
@@ -767,7 +770,7 @@ const He = /* @__PURE__ */ ie(Ue), Oe = (e, t) => {
|
|
|
767
770
|
response_type: "code",
|
|
768
771
|
...g
|
|
769
772
|
});
|
|
770
|
-
},
|
|
773
|
+
}, Oe = () => {
|
|
771
774
|
let e = "";
|
|
772
775
|
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", r = t.length;
|
|
773
776
|
let n = 0;
|
|
@@ -775,8 +778,8 @@ const He = /* @__PURE__ */ ie(Ue), Oe = (e, t) => {
|
|
|
775
778
|
e += t.charAt(Math.floor(Math.random() * r)), n += 1;
|
|
776
779
|
return e;
|
|
777
780
|
}, Te = (e) => ze.stringify(He(e)), re = (e, t) => {
|
|
778
|
-
const r =
|
|
779
|
-
return sessionStorage.setItem(M, r || ""), `${e}/auth?${
|
|
781
|
+
const r = Oe(), n = Te(r);
|
|
782
|
+
return sessionStorage.setItem(M, r || ""), `${e}/auth?${Pe(t, n)}`;
|
|
780
783
|
}, ne = () => {
|
|
781
784
|
const e = window.location.href;
|
|
782
785
|
if (!e || !(e != null && e.includes("?")))
|
|
@@ -800,29 +803,29 @@ const He = /* @__PURE__ */ ie(Ue), Oe = (e, t) => {
|
|
|
800
803
|
throw c;
|
|
801
804
|
return c;
|
|
802
805
|
}, T = typeof window > "u";
|
|
803
|
-
var z,
|
|
806
|
+
var z, N, L, H, U, O, j, E, $, V, G, J;
|
|
804
807
|
class We {
|
|
805
808
|
constructor(t) {
|
|
806
809
|
/**
|
|
807
810
|
* {@link https://monerium.dev/api-docs#operation/auth-token}
|
|
808
811
|
*/
|
|
809
|
-
|
|
812
|
+
R(this, O);
|
|
810
813
|
// -- Helper Methods
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
+
R(this, E);
|
|
815
|
+
R(this, z, void 0);
|
|
816
|
+
R(this, N, void 0);
|
|
814
817
|
/** The socket will be available after subscribing to an event */
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
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);
|
|
821
824
|
if (I(this, H, /* @__PURE__ */ new Map()), this.isAuthorized = !!this.bearerProfile, I(this, V, async (r, n, u) => {
|
|
822
825
|
const c = sessionStorage.getItem(M) || "";
|
|
823
826
|
if (!c)
|
|
824
827
|
throw new Error("Code verifier not found");
|
|
825
|
-
return this.codeVerifier = c, sessionStorage.removeItem(M), await k(this,
|
|
828
|
+
return this.codeVerifier = c, sessionStorage.removeItem(M), await k(this, O, j).call(this, {
|
|
826
829
|
code: u,
|
|
827
830
|
redirect_uri: n,
|
|
828
831
|
client_id: r,
|
|
@@ -831,10 +834,10 @@ class We {
|
|
|
831
834
|
}), I(this, G, async ({
|
|
832
835
|
clientId: r,
|
|
833
836
|
clientSecret: n
|
|
834
|
-
}) => await k(this,
|
|
837
|
+
}) => await k(this, O, j).call(this, {
|
|
835
838
|
client_id: r,
|
|
836
839
|
client_secret: n
|
|
837
|
-
})), I(this, J, async (r, n) => await k(this,
|
|
840
|
+
})), I(this, J, async (r, n) => await k(this, O, j).call(this, {
|
|
838
841
|
refresh_token: n,
|
|
839
842
|
client_id: r
|
|
840
843
|
})), this.subscribeToOrderNotifications = () => {
|
|
@@ -853,7 +856,7 @@ class We {
|
|
|
853
856
|
}), n.addEventListener("close", () => {
|
|
854
857
|
console.info(`Socket connection closed: ${r}`);
|
|
855
858
|
}), n;
|
|
856
|
-
}, this.auth = async (r) => await k(this,
|
|
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) => {
|
|
857
860
|
const n = re(w(this, z).api, r);
|
|
858
861
|
return this.codeVerifier = sessionStorage.getItem(M), n;
|
|
859
862
|
}, this.pkceRequest = (r) => this.getAuthFlowURI(r), this.getEnvironment = () => w(this, z), !t) {
|
|
@@ -917,7 +920,7 @@ class We {
|
|
|
917
920
|
throw new Error("Missing ClientId");
|
|
918
921
|
if (T)
|
|
919
922
|
throw new Error("This only works client side");
|
|
920
|
-
const c = new URLSearchParams(window.location.search).get("code") || void 0, v = sessionStorage.getItem(
|
|
923
|
+
const c = new URLSearchParams(window.location.search).get("code") || void 0, v = sessionStorage.getItem(D) || void 0;
|
|
921
924
|
return v ? await w(this, J).call(this, r, v) : c && await w(this, V).call(this, r, u, c), !!this.bearerProfile;
|
|
922
925
|
}
|
|
923
926
|
// -- Read Methods
|
|
@@ -925,7 +928,7 @@ class We {
|
|
|
925
928
|
* {@link https://monerium.dev/api-docs#operation/auth-context}
|
|
926
929
|
*/
|
|
927
930
|
getAuthContext() {
|
|
928
|
-
return k(this, E,
|
|
931
|
+
return k(this, E, $).call(this, "get", "auth/context");
|
|
929
932
|
}
|
|
930
933
|
/**
|
|
931
934
|
* {@link https://monerium.dev/api-docs#operation/profile}
|
|
@@ -933,47 +936,47 @@ class We {
|
|
|
933
936
|
|
|
934
937
|
*/
|
|
935
938
|
getProfile(t) {
|
|
936
|
-
return k(this, E,
|
|
939
|
+
return k(this, E, $).call(this, "get", `profiles/${t}`);
|
|
937
940
|
}
|
|
938
941
|
/**
|
|
939
942
|
* {@link https://monerium.dev/api-docs#operation/profile-balances}
|
|
940
943
|
* @param {string=} profileId - the id of the profile to fetch balances.
|
|
941
944
|
*/
|
|
942
945
|
getBalances(t) {
|
|
943
|
-
return t ? k(this, E,
|
|
946
|
+
return t ? k(this, E, $).call(this, "get", `profiles/${t}/balances`) : k(this, E, $).call(this, "get", "balances");
|
|
944
947
|
}
|
|
945
948
|
/**
|
|
946
949
|
* {@link https://monerium.dev/api-docs#operation/orders}
|
|
947
950
|
*/
|
|
948
951
|
getOrders(t) {
|
|
949
952
|
const r = Q(t);
|
|
950
|
-
return k(this, E,
|
|
953
|
+
return k(this, E, $).call(this, "get", `orders?${r}`);
|
|
951
954
|
}
|
|
952
955
|
/**
|
|
953
956
|
* {@link https://monerium.dev/api-docs#operation/order}
|
|
954
957
|
*/
|
|
955
958
|
getOrder(t) {
|
|
956
|
-
return k(this, E,
|
|
959
|
+
return k(this, E, $).call(this, "get", `orders/${t}`);
|
|
957
960
|
}
|
|
958
961
|
/**
|
|
959
962
|
* {@link https://monerium.dev/api-docs#operation/tokens}
|
|
960
963
|
*/
|
|
961
964
|
getTokens() {
|
|
962
|
-
return k(this, E,
|
|
965
|
+
return k(this, E, $).call(this, "get", "tokens");
|
|
963
966
|
}
|
|
964
967
|
// -- Write Methods
|
|
965
968
|
/**
|
|
966
969
|
* {@link https://monerium.dev/api-docs#operation/profile-addresses}
|
|
967
970
|
*/
|
|
968
971
|
linkAddress(t, r) {
|
|
969
|
-
return k(this, E,
|
|
972
|
+
return k(this, E, $).call(this, "post", `profiles/${t}/addresses`, JSON.stringify(r));
|
|
970
973
|
}
|
|
971
974
|
/**
|
|
972
975
|
* {@link https://monerium.dev/api-docs#operation/post-orders}
|
|
973
976
|
*/
|
|
974
977
|
placeOrder(t, r) {
|
|
975
978
|
const n = { ...t, kind: "redeem", currency: "eur" };
|
|
976
|
-
return r ? k(this, E,
|
|
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));
|
|
977
980
|
}
|
|
978
981
|
/**
|
|
979
982
|
* {@link https://monerium.dev/api-docs#operation/supporting-document}
|
|
@@ -982,7 +985,7 @@ class We {
|
|
|
982
985
|
const r = Q(
|
|
983
986
|
t
|
|
984
987
|
);
|
|
985
|
-
return k(this, E,
|
|
988
|
+
return k(this, E, $).call(this, "post", "files/supporting-document", r, !0);
|
|
986
989
|
}
|
|
987
990
|
// -- Notifications
|
|
988
991
|
async connectOrderSocket() {
|
|
@@ -994,13 +997,13 @@ class We {
|
|
|
994
997
|
*/
|
|
995
998
|
async disconnect() {
|
|
996
999
|
var t;
|
|
997
|
-
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;
|
|
998
1001
|
}
|
|
999
1002
|
/**
|
|
1000
1003
|
* Revokes access
|
|
1001
1004
|
*/
|
|
1002
1005
|
async revokeAccess() {
|
|
1003
|
-
T || sessionStorage.removeItem(
|
|
1006
|
+
T || sessionStorage.removeItem(D), this.disconnect();
|
|
1004
1007
|
}
|
|
1005
1008
|
/**
|
|
1006
1009
|
* Subscribe to MoneriumEvent to receive notifications using the Monerium API (WebSocket)
|
|
@@ -1021,7 +1024,7 @@ class We {
|
|
|
1021
1024
|
w(this, H).delete(t), w(this, H).size === 0 && ((r = w(this, L)) == null || r.close(), I(this, L, void 0));
|
|
1022
1025
|
}
|
|
1023
1026
|
}
|
|
1024
|
-
z = new WeakMap(),
|
|
1027
|
+
z = new WeakMap(), N = new WeakMap(), L = new WeakMap(), H = new WeakMap(), U = new WeakMap(), O = new WeakSet(), j = async function(t) {
|
|
1025
1028
|
let r;
|
|
1026
1029
|
if (se(t))
|
|
1027
1030
|
r = { ...t, grant_type: "authorization_code" };
|
|
@@ -1031,22 +1034,22 @@ z = new WeakMap(), D = new WeakMap(), L = new WeakMap(), H = new WeakMap(), U =
|
|
|
1031
1034
|
r = { ...t, grant_type: "client_credentials" };
|
|
1032
1035
|
else
|
|
1033
1036
|
throw new Error("Authorization grant type could not be detected.");
|
|
1034
|
-
return await k(this, E,
|
|
1037
|
+
return await k(this, E, $).call(this, "post", "auth/token", r, !0).then((n) => {
|
|
1035
1038
|
var u;
|
|
1036
|
-
this.bearerProfile = n, this.isAuthorized = !!n, I(this,
|
|
1037
|
-
|
|
1039
|
+
this.bearerProfile = n, this.isAuthorized = !!n, I(this, N, `Bearer ${n == null ? void 0 : n.access_token}`), T || window.sessionStorage.setItem(
|
|
1040
|
+
D,
|
|
1038
1041
|
((u = this.bearerProfile) == null ? void 0 : u.refresh_token) || ""
|
|
1039
1042
|
);
|
|
1040
1043
|
}).catch((n) => {
|
|
1041
|
-
throw T || (sessionStorage.removeItem(M), sessionStorage.removeItem(
|
|
1044
|
+
throw T || (sessionStorage.removeItem(M), sessionStorage.removeItem(D), ne()), new Error(n == null ? void 0 : n.message);
|
|
1042
1045
|
}), se(t) && ne(), this.bearerProfile;
|
|
1043
|
-
}, E = new WeakSet(),
|
|
1046
|
+
}, E = new WeakSet(), $ = async function(t, r, n, u) {
|
|
1044
1047
|
return qe(
|
|
1045
1048
|
`${w(this, z).api}/${r}`,
|
|
1046
1049
|
t,
|
|
1047
1050
|
u ? Q(n) : n,
|
|
1048
1051
|
{
|
|
1049
|
-
Authorization: w(this,
|
|
1052
|
+
Authorization: w(this, N) || "",
|
|
1050
1053
|
"Content-Type": `application/${u ? "x-www-form-urlencoded" : "json"}`
|
|
1051
1054
|
}
|
|
1052
1055
|
);
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monerium/sdk",
|
|
3
|
-
"version": "2.8.
|
|
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": {
|
|
@@ -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/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, receiver: string, chainId?: number) => 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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monerium/sdk",
|
|
3
|
-
"version": "2.8.
|
|
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": {
|
|
@@ -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
|
}
|