New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@monerium/sdk

Package Overview
Dependencies
Maintainers
2
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@monerium/sdk - npm Package Compare versions

Comparing version 2.7.1 to 2.7.2

126

CHANGELOG.md
# Changelog
## [2.7.1](https://github.com/monerium/public-monorepo/compare/sdk-v2.7.0...sdk-v2.7.1) (2023-11-13)
## [2.7.2](https://github.com/monerium/public-monorepo/compare/sdk-v2.7.2...sdk-v2.7.2) (2023-11-17)

@@ -15,2 +15,3 @@

* add example, fix sdk for backwards compatibility and update README ([6992417](https://github.com/monerium/public-monorepo/commit/6992417e44b442a06b1d65f88d588d17e71b4562))
* add removal date to deprecated methods and add connect as deprecated ([c1e02e2](https://github.com/monerium/public-monorepo/commit/c1e02e273b08b091475757e0e68051098e20a5a0))
* add yarnrc to each lib ([6dc9f7a](https://github.com/monerium/public-monorepo/commit/6dc9f7a4a46e24596c862df83823f90be5dad803))

@@ -22,2 +23,3 @@ * continue on error gh-pages ([d033048](https://github.com/monerium/public-monorepo/commit/d033048a490390815ef17dad45b526b04898c2ae))

* dep ([0d9953b](https://github.com/monerium/public-monorepo/commit/0d9953b5a2e259851d05d422ecf7f2c1fa36c6ea))
* expose getChain and getNetwork + update docs ([085d9bd](https://github.com/monerium/public-monorepo/commit/085d9bd261342d14936a7f9f1d5cc1fdd859ec26))
* letsgo ([af653ce](https://github.com/monerium/public-monorepo/commit/af653ce744b333023892370b21ec28738c82910e))

@@ -30,2 +32,3 @@ * lol ([630cb9f](https://github.com/monerium/public-monorepo/commit/630cb9fa3f4d7efa363b7fd9079c4e5e4e26bdd3))

* releaseas ([db309d2](https://github.com/monerium/public-monorepo/commit/db309d2635196bac5df230e886d70c395c58b06b))
* remove packageManager from sdk packagejson ([f87d93d](https://github.com/monerium/public-monorepo/commit/f87d93d51c953fdc8c72a4458f19f11ad0fd0d58))
* rewrite the CHANGELOG after a lot messy testing ([fb1a3c9](https://github.com/monerium/public-monorepo/commit/fb1a3c9517c269c49bc6ad9e492c79481184afcd))

@@ -46,2 +49,3 @@ * sdk version ([27c479c](https://github.com/monerium/public-monorepo/commit/27c479c3b324a33ea7e44613601e4f32269e9082))

* testing affected ([a10f49a](https://github.com/monerium/public-monorepo/commit/a10f49a4840218c9f5fa76463b3132401d0a23f4))
* tests and release action ([a18438c](https://github.com/monerium/public-monorepo/commit/a18438c2974e79975722afe8f7f9679358f32da5))
* trigger both packages ([a8db647](https://github.com/monerium/public-monorepo/commit/a8db647e694abd753bdb06df352c1d72617d7e67))

@@ -54,2 +58,122 @@ * trigger sdk ([ee1b950](https://github.com/monerium/public-monorepo/commit/ee1b9502c61655e5f0771827fdd116b58c748834))

## [2.7.2](https://github.com/monerium/public-monorepo/compare/sdk-v2.7.2...sdk-v2.7.2) (2023-11-17)
### Features
* add docs ([f5ba19d](https://github.com/monerium/public-monorepo/commit/f5ba19d5600e01cd0c97467a0a1f2fe94a2f40fc))
* new functions added + arguments to class instance ([b5b8c5d](https://github.com/monerium/public-monorepo/commit/b5b8c5d3fbae6ce7a90569b74d887b81d9f3a336))
### Bug Fixes
* add example, fix sdk for backwards compatibility and update README ([6992417](https://github.com/monerium/public-monorepo/commit/6992417e44b442a06b1d65f88d588d17e71b4562))
* add removal date to deprecated methods and add connect as deprecated ([c1e02e2](https://github.com/monerium/public-monorepo/commit/c1e02e273b08b091475757e0e68051098e20a5a0))
* add yarnrc to each lib ([6dc9f7a](https://github.com/monerium/public-monorepo/commit/6dc9f7a4a46e24596c862df83823f90be5dad803))
* continue on error gh-pages ([d033048](https://github.com/monerium/public-monorepo/commit/d033048a490390815ef17dad45b526b04898c2ae))
* debug ([b2543eb](https://github.com/monerium/public-monorepo/commit/b2543eb222cbe74131377e164c28c3093b72be5f))
* debug ([ea1bd38](https://github.com/monerium/public-monorepo/commit/ea1bd38c8f8f98cf65a9bcab615faa540a8b7324))
* debug ([20e3ccb](https://github.com/monerium/public-monorepo/commit/20e3ccb3297e3bba02be86349a151b1bf0ed8f5c))
* dep ([0d9953b](https://github.com/monerium/public-monorepo/commit/0d9953b5a2e259851d05d422ecf7f2c1fa36c6ea))
* expose getChain and getNetwork + update docs ([085d9bd](https://github.com/monerium/public-monorepo/commit/085d9bd261342d14936a7f9f1d5cc1fdd859ec26))
* letsgo ([af653ce](https://github.com/monerium/public-monorepo/commit/af653ce744b333023892370b21ec28738c82910e))
* lol ([630cb9f](https://github.com/monerium/public-monorepo/commit/630cb9fa3f4d7efa363b7fd9079c4e5e4e26bdd3))
* perm ([3210011](https://github.com/monerium/public-monorepo/commit/32100114916d85b1b1982cd942c3181210943ee9))
* props to auto-link ([ce85efd](https://github.com/monerium/public-monorepo/commit/ce85efd534cfcac7fb9e7804b733641aeb752f4f))
* publish ([537b336](https://github.com/monerium/public-monorepo/commit/537b336180df288e0653b0db7230ae84758f8475))
* publish not working ([50a2a05](https://github.com/monerium/public-monorepo/commit/50a2a0583c03ef7a66a605c8215f72256192b8e2))
* releaseas ([db309d2](https://github.com/monerium/public-monorepo/commit/db309d2635196bac5df230e886d70c395c58b06b))
* rewrite the CHANGELOG after a lot messy testing ([fb1a3c9](https://github.com/monerium/public-monorepo/commit/fb1a3c9517c269c49bc6ad9e492c79481184afcd))
* sdk version ([27c479c](https://github.com/monerium/public-monorepo/commit/27c479c3b324a33ea7e44613601e4f32269e9082))
* static files not deployed ([a1131d7](https://github.com/monerium/public-monorepo/commit/a1131d7ab988a93e41b7f3b65429b5aa27ff588e))
* stuff ([6b06483](https://github.com/monerium/public-monorepo/commit/6b06483ad5ca8f3e00e8d88f2739cf2526ae2101))
* stuff ([1dadd44](https://github.com/monerium/public-monorepo/commit/1dadd44f07fb2234bf1fca1f1f20dbc4158cface))
* syntax ([f8cfbad](https://github.com/monerium/public-monorepo/commit/f8cfbad0fa536808ddc988cf9e6ca8aef5247ef7))
* test ([2c52f99](https://github.com/monerium/public-monorepo/commit/2c52f99e5c2fc19c502fae01e7ca105010df979f))
* test ([21c2cb8](https://github.com/monerium/public-monorepo/commit/21c2cb8c936410f6701a87313cb1bcb4dd9f281f))
* test ([2a612b1](https://github.com/monerium/public-monorepo/commit/2a612b1f93a59ec709c9f328c7ba4bc910971de9))
* test ([0dfd8e1](https://github.com/monerium/public-monorepo/commit/0dfd8e1489db8096f1cb66a3816e410ddb996d64))
* test deploy ([1a3e311](https://github.com/monerium/public-monorepo/commit/1a3e311fdc7bde2f17390e4cdb3f0a48859e5cf9))
* test: ([e122f61](https://github.com/monerium/public-monorepo/commit/e122f61e5f907785b6076bfda855c275bcfce1d6))
* testing ([24389c9](https://github.com/monerium/public-monorepo/commit/24389c9f243671c548d957dc499689e58e0bc3f6))
* testing affected ([60059eb](https://github.com/monerium/public-monorepo/commit/60059ebc035dccf1dcbb4eb64cf0eeb071020caf))
* testing affected ([a10f49a](https://github.com/monerium/public-monorepo/commit/a10f49a4840218c9f5fa76463b3132401d0a23f4))
* tests and release action ([a18438c](https://github.com/monerium/public-monorepo/commit/a18438c2974e79975722afe8f7f9679358f32da5))
* trigger both packages ([a8db647](https://github.com/monerium/public-monorepo/commit/a8db647e694abd753bdb06df352c1d72617d7e67))
* trigger sdk ([ee1b950](https://github.com/monerium/public-monorepo/commit/ee1b9502c61655e5f0771827fdd116b58c748834))
* typedoc deps ([0696536](https://github.com/monerium/public-monorepo/commit/0696536edd834b6bf2ca6bf6ea39914d37fcda9c))
* uff ([ae8e9e5](https://github.com/monerium/public-monorepo/commit/ae8e9e510b5fad9997addd31e1153e9ef66a9d5c))
* version ([f3a1b1d](https://github.com/monerium/public-monorepo/commit/f3a1b1d7750a2f743d84426e60ea368909dcf93d))
* yarn instead of npm ([5b86535](https://github.com/monerium/public-monorepo/commit/5b86535ed225effa0d13b6b60388bf05783ebe63))
## [2.7.2](https://github.com/monerium/public-monorepo/compare/sdk-v2.7.2...sdk-v2.7.2) (2023-11-17)
### Features
* add docs ([f5ba19d](https://github.com/monerium/public-monorepo/commit/f5ba19d5600e01cd0c97467a0a1f2fe94a2f40fc))
* new functions added + arguments to class instance ([b5b8c5d](https://github.com/monerium/public-monorepo/commit/b5b8c5d3fbae6ce7a90569b74d887b81d9f3a336))
### Bug Fixes
* add example, fix sdk for backwards compatibility and update README ([6992417](https://github.com/monerium/public-monorepo/commit/6992417e44b442a06b1d65f88d588d17e71b4562))
* add removal date to deprecated methods and add connect as deprecated ([c1e02e2](https://github.com/monerium/public-monorepo/commit/c1e02e273b08b091475757e0e68051098e20a5a0))
* add yarnrc to each lib ([6dc9f7a](https://github.com/monerium/public-monorepo/commit/6dc9f7a4a46e24596c862df83823f90be5dad803))
* continue on error gh-pages ([d033048](https://github.com/monerium/public-monorepo/commit/d033048a490390815ef17dad45b526b04898c2ae))
* debug ([b2543eb](https://github.com/monerium/public-monorepo/commit/b2543eb222cbe74131377e164c28c3093b72be5f))
* debug ([ea1bd38](https://github.com/monerium/public-monorepo/commit/ea1bd38c8f8f98cf65a9bcab615faa540a8b7324))
* debug ([20e3ccb](https://github.com/monerium/public-monorepo/commit/20e3ccb3297e3bba02be86349a151b1bf0ed8f5c))
* dep ([0d9953b](https://github.com/monerium/public-monorepo/commit/0d9953b5a2e259851d05d422ecf7f2c1fa36c6ea))
* expose getChain and getNetwork + update docs ([085d9bd](https://github.com/monerium/public-monorepo/commit/085d9bd261342d14936a7f9f1d5cc1fdd859ec26))
* letsgo ([af653ce](https://github.com/monerium/public-monorepo/commit/af653ce744b333023892370b21ec28738c82910e))
* lol ([630cb9f](https://github.com/monerium/public-monorepo/commit/630cb9fa3f4d7efa363b7fd9079c4e5e4e26bdd3))
* perm ([3210011](https://github.com/monerium/public-monorepo/commit/32100114916d85b1b1982cd942c3181210943ee9))
* props to auto-link ([ce85efd](https://github.com/monerium/public-monorepo/commit/ce85efd534cfcac7fb9e7804b733641aeb752f4f))
* publish ([537b336](https://github.com/monerium/public-monorepo/commit/537b336180df288e0653b0db7230ae84758f8475))
* publish not working ([50a2a05](https://github.com/monerium/public-monorepo/commit/50a2a0583c03ef7a66a605c8215f72256192b8e2))
* releaseas ([db309d2](https://github.com/monerium/public-monorepo/commit/db309d2635196bac5df230e886d70c395c58b06b))
* rewrite the CHANGELOG after a lot messy testing ([fb1a3c9](https://github.com/monerium/public-monorepo/commit/fb1a3c9517c269c49bc6ad9e492c79481184afcd))
* sdk version ([27c479c](https://github.com/monerium/public-monorepo/commit/27c479c3b324a33ea7e44613601e4f32269e9082))
* static files not deployed ([a1131d7](https://github.com/monerium/public-monorepo/commit/a1131d7ab988a93e41b7f3b65429b5aa27ff588e))
* stuff ([6b06483](https://github.com/monerium/public-monorepo/commit/6b06483ad5ca8f3e00e8d88f2739cf2526ae2101))
* stuff ([1dadd44](https://github.com/monerium/public-monorepo/commit/1dadd44f07fb2234bf1fca1f1f20dbc4158cface))
* syntax ([f8cfbad](https://github.com/monerium/public-monorepo/commit/f8cfbad0fa536808ddc988cf9e6ca8aef5247ef7))
* test ([2c52f99](https://github.com/monerium/public-monorepo/commit/2c52f99e5c2fc19c502fae01e7ca105010df979f))
* test ([21c2cb8](https://github.com/monerium/public-monorepo/commit/21c2cb8c936410f6701a87313cb1bcb4dd9f281f))
* test ([2a612b1](https://github.com/monerium/public-monorepo/commit/2a612b1f93a59ec709c9f328c7ba4bc910971de9))
* test ([0dfd8e1](https://github.com/monerium/public-monorepo/commit/0dfd8e1489db8096f1cb66a3816e410ddb996d64))
* test deploy ([1a3e311](https://github.com/monerium/public-monorepo/commit/1a3e311fdc7bde2f17390e4cdb3f0a48859e5cf9))
* test: ([e122f61](https://github.com/monerium/public-monorepo/commit/e122f61e5f907785b6076bfda855c275bcfce1d6))
* testing ([24389c9](https://github.com/monerium/public-monorepo/commit/24389c9f243671c548d957dc499689e58e0bc3f6))
* testing affected ([60059eb](https://github.com/monerium/public-monorepo/commit/60059ebc035dccf1dcbb4eb64cf0eeb071020caf))
* testing affected ([a10f49a](https://github.com/monerium/public-monorepo/commit/a10f49a4840218c9f5fa76463b3132401d0a23f4))
* trigger both packages ([a8db647](https://github.com/monerium/public-monorepo/commit/a8db647e694abd753bdb06df352c1d72617d7e67))
* trigger sdk ([ee1b950](https://github.com/monerium/public-monorepo/commit/ee1b9502c61655e5f0771827fdd116b58c748834))
* typedoc deps ([0696536](https://github.com/monerium/public-monorepo/commit/0696536edd834b6bf2ca6bf6ea39914d37fcda9c))
* uff ([ae8e9e5](https://github.com/monerium/public-monorepo/commit/ae8e9e510b5fad9997addd31e1153e9ef66a9d5c))
* version ([f3a1b1d](https://github.com/monerium/public-monorepo/commit/f3a1b1d7750a2f743d84426e60ea368909dcf93d))
* yarn instead of npm ([5b86535](https://github.com/monerium/public-monorepo/commit/5b86535ed225effa0d13b6b60388bf05783ebe63))
## [2.7.2](https://github.com/monerium/public-monorepo/compare/sdk-v2.7.2...sdk-v2.7.2) (2023-11-17)
### Bug Fixes
* add removal date to deprecated methods and add connect as deprecated ([c1e02e2](https://github.com/monerium/public-monorepo/commit/c1e02e273b08b091475757e0e68051098e20a5a0))
## [2.7.2](https://github.com/monerium/public-monorepo/compare/sdk-v2.7.2...sdk-v2.7.2) (2023-11-17)
### Bug Fixes
* add removal date to deprecated methods and add connect as deprecated ([c1e02e2](https://github.com/monerium/public-monorepo/commit/c1e02e273b08b091475757e0e68051098e20a5a0))
## [2.7.2](https://github.com/monerium/public-monorepo/compare/sdk-v2.7.1...sdk-v2.7.2) (2023-11-17)
### Bug Fixes
* expose getChain and getNetwork + update docs ([085d9bd](https://github.com/monerium/public-monorepo/commit/085d9bd261342d14936a7f9f1d5cc1fdd859ec26))
## [2.7.0](https://github.com/monerium/public-monorepo/compare/sdk-v2.7.0...sdk-v2.7.0) (2023-11-13)

@@ -56,0 +180,0 @@

24

dist/client.d.ts

@@ -26,7 +26,8 @@ import type { AuthArgs, AuthorizationCodeCredentials, AuthContext, Balances, BearerProfile, ClassOptions, ENV, Environment, LinkAddress, MoneriumEvent, MoneriumEventListener, NewOrder, AuthFlowOptions, Order, OrderFilter, PKCERequestArgs, Profile, SupportingDoc, Token, ClientCredentials } from './types';

authorize(client?: AuthFlowOptions): Promise<void>;
connect(client?: AuthorizationCodeCredentials | ClientCredentials): Promise<boolean>;
/**
* {@link https://monerium.dev/api-docs#operation/auth-token}
* Get access to the API
* @param {AuthorizationCodeCredentials | ClientCredentials} client - the client credentials
* @returns boolean to indicate if access has been granted
*/
getBearerToken(args: AuthArgs): Promise<BearerProfile>;
getAccess(client?: AuthorizationCodeCredentials | ClientCredentials): Promise<boolean>;
/**

@@ -73,4 +74,11 @@ * {@link https://monerium.dev/api-docs#operation/auth-context}

subscribeToOrderNotifications: () => WebSocket;
/**
* Cleanups the socket and the subscriptions
*/
disconnect(): Promise<void>;
/**
* Revokes access
*/
revokeAccess(): Promise<void>;
/**
* Subscribe to MoneriumEvent to receive notifications using the Monerium API (WebSocket)

@@ -89,11 +97,15 @@ * We are setting a subscription map because we need the user to have a token to start the WebSocket connection

/**
* @deprecated since v2.6.4, use {@link getBearerToken} instead.
* @deprecated since v2.6.4, will be removed in 2.7.2+, use {@link getAccess} instead.
*/
auth: (args: AuthArgs) => Promise<BearerProfile>;
/**
* @deprecated since v2.6.4, use {@link authorize} instead.
* @deprecated since v2.7.1, will be removed in 2.7.2+, use {@link getAccess} instead.
*/
connect: (args: AuthArgs) => Promise<BearerProfile>;
/**
* @deprecated since v2.6.4, will be removed in 2.7.2+, use {@link authorize} instead.
*/
getAuthFlowURI: (args: PKCERequestArgs) => string;
/**
* @deprecated since v2.0.7, use {@link getAuthFlowURI} instead.
* @deprecated since v2.0.7, will be removed in 2.7.2+, use {@link getAuthFlowURI} instead.
*/

@@ -100,0 +112,0 @@ pkceRequest: (args: PKCERequestArgs) => string;

export { MoneriumClient } from './client';
export { default as constants } from './constants';
export * from './types';
export { placeOrderMessage, rfc3339 } from './utils';
export { placeOrderMessage, rfc3339, getChain, getNetwork } from './utils';

@@ -1,1 +0,1 @@

"use strict";var G=(e,r,t)=>{if(!r.has(e))throw TypeError("Cannot "+t)};var w=(e,r,t)=>(G(e,r,"read from private field"),t?t.call(e):r.get(e)),T=(e,r,t)=>{if(r.has(e))throw TypeError("Cannot add the same private member more than once");r instanceof WeakSet?r.add(e):r.set(e,t)},A=(e,r,t,n)=>(G(e,r,"write to private field"),n?n.call(e,t):r.set(e,t),t);var I=(e,r,t)=>(G(e,r,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var re=(e=>(e.eur="eur",e))(re||{}),te=(e=>(e.corporate="corporate",e.personal="personal",e))(te||{}),ne=(e=>(e.read="read",e.write="write",e))(ne||{}),oe=(e=>(e.absent="absent",e.submitted="submitted",e.pending="pending",e.confirmed="confirmed",e))(oe||{}),se=(e=>(e.approved="approved",e.rejected="rejected",e.unknown="unknown",e))(se||{}),ie=(e=>(e.requested="requested",e.approved="approved",e.pending="pending",e))(ie||{}),ae=(e=>(e.iban="iban",e.scan="scan",e))(ae||{}),ce=(e=>(e.redeem="redeem",e.issue="issue",e))(ce||{}),ue=(e=>(e.placed="placed",e.pending="pending",e.processed="processed",e.rejected="rejected",e))(ue||{});const de=e=>{if(e.toString()==="Invalid Date")throw e;const r=n=>n<10?"0"+n:n,t=n=>{if(n===0)return"Z";const u=n>0?"-":"+";return n=Math.abs(n),u+r(Math.floor(n/60))+":"+r(n%60)};return e.getFullYear()+"-"+r(e.getMonth()+1)+"-"+r(e.getDate())+"T"+r(e.getHours())+":"+r(e.getMinutes())+":"+r(e.getSeconds())+t(e.getTimezoneOffset())},_e=(e,r)=>`Send EUR ${e} to ${r} at ${de(new Date)}`,D=e=>{var r;return e&&((r=Object.entries(e))==null?void 0:r.length)>0?Object.entries(e).map(([t,n])=>`${encodeURIComponent(t)}=${encodeURIComponent(n)}`).join("&"):""},be=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}`)}},Se=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}`)}},J={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"}}},Be="I hereby declare that I am the address owner.",U="monerium.sdk.code_verifier",V="monerium.sdk.refresh_token",ke={LINK_MESSAGE:Be,STORAGE_CODE_VERIFIER:U,STORAGE_REFRESH_TOKEN:V};var L=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function he(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Ce(e){if(e.__esModule)return e;var r=e.default;if(typeof r=="function"){var t=function n(){if(this instanceof n){var u=[null];u.push.apply(u,arguments);var i=Function.bind.apply(r,u);return new i}return r.apply(this,arguments)};t.prototype=r.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var u=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,u.get?u:{enumerable:!0,get:function(){return e[n]}})}),t}var fe={exports:{}};function xe(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 Q={exports:{}};const Ee={},Ae=Object.freeze(Object.defineProperty({__proto__:null,default:Ee},Symbol.toStringTag,{value:"Module"})),Ie=Ce(Ae);var X;function le(){return X||(X=1,function(e,r){(function(t,n){e.exports=n()})(L,function(){var t=t||function(n,u){var i;if(typeof window<"u"&&window.crypto&&(i=window.crypto),typeof self<"u"&&self.crypto&&(i=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(i=globalThis.crypto),!i&&typeof window<"u"&&window.msCrypto&&(i=window.msCrypto),!i&&typeof L<"u"&&L.crypto&&(i=L.crypto),!i&&typeof xe=="function")try{i=Ie}catch{}var v=function(){if(i){if(typeof i.getRandomValues=="function")try{return i.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof i.randomBytes=="function")try{return i.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},B=Object.create||function(){function o(){}return function(s){var c;return o.prototype=s,c=new o,o.prototype=null,c}}(),p={},y=p.lib={},m=y.Base=function(){return{extend:function(o){var s=B(this);return o&&s.mixIn(o),(!s.hasOwnProperty("init")||this.init===s.init)&&(s.init=function(){s.$super.init.apply(this,arguments)}),s.init.prototype=s,s.$super=this,s},create:function(){var o=this.extend();return o.init.apply(o,arguments),o},init:function(){},mixIn:function(o){for(var s in o)o.hasOwnProperty(s)&&(this[s]=o[s]);o.hasOwnProperty("toString")&&(this.toString=o.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),g=y.WordArray=m.extend({init:function(o,s){o=this.words=o||[],s!=u?this.sigBytes=s:this.sigBytes=o.length*4},toString:function(o){return(o||h).stringify(this)},concat:function(o){var s=this.words,c=o.words,d=this.sigBytes,_=o.sigBytes;if(this.clamp(),d%4)for(var S=0;S<_;S++){var k=c[S>>>2]>>>24-S%4*8&255;s[d+S>>>2]|=k<<24-(d+S)%4*8}else for(var C=0;C<_;C+=4)s[d+C>>>2]=c[C>>>2];return this.sigBytes+=_,this},clamp:function(){var o=this.words,s=this.sigBytes;o[s>>>2]&=4294967295<<32-s%4*8,o.length=n.ceil(s/4)},clone:function(){var o=m.clone.call(this);return o.words=this.words.slice(0),o},random:function(o){for(var s=[],c=0;c<o;c+=4)s.push(v());return new g.init(s,o)}}),b=p.enc={},h=b.Hex={stringify:function(o){for(var s=o.words,c=o.sigBytes,d=[],_=0;_<c;_++){var S=s[_>>>2]>>>24-_%4*8&255;d.push((S>>>4).toString(16)),d.push((S&15).toString(16))}return d.join("")},parse:function(o){for(var s=o.length,c=[],d=0;d<s;d+=2)c[d>>>3]|=parseInt(o.substr(d,2),16)<<24-d%8*4;return new g.init(c,s/2)}},l=b.Latin1={stringify:function(o){for(var s=o.words,c=o.sigBytes,d=[],_=0;_<c;_++){var S=s[_>>>2]>>>24-_%4*8&255;d.push(String.fromCharCode(S))}return d.join("")},parse:function(o){for(var s=o.length,c=[],d=0;d<s;d++)c[d>>>2]|=(o.charCodeAt(d)&255)<<24-d%4*8;return new g.init(c,s)}},a=b.Utf8={stringify:function(o){try{return decodeURIComponent(escape(l.stringify(o)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(o){return l.parse(unescape(encodeURIComponent(o)))}},f=y.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new g.init,this._nDataBytes=0},_append:function(o){typeof o=="string"&&(o=a.parse(o)),this._data.concat(o),this._nDataBytes+=o.sigBytes},_process:function(o){var s,c=this._data,d=c.words,_=c.sigBytes,S=this.blockSize,k=S*4,C=_/k;o?C=n.ceil(C):C=n.max((C|0)-this._minBufferSize,0);var M=C*S,z=n.min(M*4,_);if(M){for(var j=0;j<M;j+=S)this._doProcessBlock(d,j);s=d.splice(0,M),c.sigBytes-=z}return new g.init(s,z)},clone:function(){var o=m.clone.call(this);return o._data=this._data.clone(),o},_minBufferSize:0});y.Hasher=f.extend({cfg:m.extend(),init:function(o){this.cfg=this.cfg.extend(o),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(o){return this._append(o),this._process(),this},finalize:function(o){o&&this._append(o);var s=this._doFinalize();return s},blockSize:16,_createHelper:function(o){return function(s,c){return new o.init(c).finalize(s)}},_createHmacHelper:function(o){return function(s,c){return new x.HMAC.init(o,c).finalize(s)}}});var x=p.algo={};return p}(Math);return t})}(Q)),Q.exports}(function(e,r){(function(t,n){e.exports=n(le())})(L,function(t){return function(){var n=t,u=n.lib,i=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 a=m[l>>>2]>>>24-l%4*8&255,f=m[l+1>>>2]>>>24-(l+1)%4*8&255,x=m[l+2>>>2]>>>24-(l+2)%4*8&255,o=a<<16|f<<8|x,s=0;s<4&&l+s*.75<g;s++)h.push(b.charAt(o>>>6*(3-s)&63));var c=b.charAt(64);if(c)for(;h.length%4;)h.push(c);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 a=p.indexOf(l);a!==-1&&(m=a)}return B(p,m,b)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"};function B(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,a=m[p.charCodeAt(h)]>>>6-h%4*2,f=l|a;g[b>>>2]|=f<<24-b%4*8,b++}return i.create(g,b)}}(),t.enc.Base64url})})(fe);var Re=fe.exports;const Oe=he(Re);var pe={exports:{}};(function(e,r){(function(t,n){e.exports=n(le())})(L,function(t){return function(n){var u=t,i=u.lib,v=i.WordArray,B=i.Hasher,p=u.algo,y=[],m=[];(function(){function h(x){for(var o=n.sqrt(x),s=2;s<=o;s++)if(!(x%s))return!1;return!0}function l(x){return(x-(x|0))*4294967296|0}for(var a=2,f=0;f<64;)h(a)&&(f<8&&(y[f]=l(n.pow(a,1/2))),m[f]=l(n.pow(a,1/3)),f++),a++})();var g=[],b=p.SHA256=B.extend({_doReset:function(){this._hash=new v.init(y.slice(0))},_doProcessBlock:function(h,l){for(var a=this._hash.words,f=a[0],x=a[1],o=a[2],s=a[3],c=a[4],d=a[5],_=a[6],S=a[7],k=0;k<64;k++){if(k<16)g[k]=h[l+k]|0;else{var C=g[k-15],M=(C<<25|C>>>7)^(C<<14|C>>>18)^C>>>3,z=g[k-2],j=(z<<15|z>>>17)^(z<<13|z>>>19)^z>>>10;g[k]=M+g[k-7]+j+g[k-16]}var ve=c&d^~c&_,ge=f&x^f&o^x&o,we=(f<<30|f>>>2)^(f<<19|f>>>13)^(f<<10|f>>>22),ye=(c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25),K=S+ye+ve+m[k]+g[k],me=we+ge;S=_,_=d,d=c,c=s+K|0,s=o,o=x,x=f,f=K+me|0}a[0]=a[0]+f|0,a[1]=a[1]+x|0,a[2]=a[2]+o|0,a[3]=a[3]+s|0,a[4]=a[4]+c|0,a[5]=a[5]+d|0,a[6]=a[6]+_|0,a[7]=a[7]+S|0},_doFinalize:function(){var h=this._data,l=h.words,a=this._nDataBytes*8,f=h.sigBytes*8;return l[f>>>5]|=128<<24-f%32,l[(f+64>>>9<<4)+14]=n.floor(a/4294967296),l[(f+64>>>9<<4)+15]=a,h.sigBytes=l.length*4,this._process(),this._hash},clone:function(){var h=B.clone.call(this);return h._hash=this._hash.clone(),h}});u.SHA256=B._createHelper(b),u.HmacSHA256=B._createHmacHelper(b)}(Math),t.SHA256})})(pe);var Pe=pe.exports;const Te=he(Pe),$e=(e,r)=>{const{client_id:t,redirect_uri:n,scope:u,state:i,chainId:v,chain:B,network:p,address:y,signature:m}=e,g=y?{address:y,...m!==void 0?{signature:m}:{},...v!==void 0||B!==void 0?{chain:v?be(v):B}:{},...v!==void 0||p!==void 0?{network:v?Se(v):p}:{}}:{};return D({client_id:t,redirect_uri:n,...u!==void 0?{scope:u}:{},...i!==void 0?{state:i}:{},code_challenge:r,code_challenge_method:"S256",response_type:"code",...g})},ze=()=>{let e="";const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=r.length;let n=0;for(;n<128;)e+=r.charAt(Math.floor(Math.random()*t)),n+=1;return e},Ue=e=>Oe.stringify(Te(e)),Y=(e,r)=>{const t=ze(),n=Ue(t);return sessionStorage.setItem(U,t||""),`${e}/auth?${$e(r,n)}`},He=()=>{const e=window.location.href,[r,t]=e.split("?");t&&window.history.replaceState(null,"",r)},ee=e=>e.code!=null,Me=e=>e.refresh_token!=null,Le=e=>e.client_secret!=null,je=async(e,r,t,n)=>{const u=await fetch(`${e}`,{method:r,headers:n,body:t});let i;const v=await u.text();try{i=JSON.parse(v)}catch{throw v}if(!u.ok)throw i;return i},Z=typeof window>"u";var O,q,H,$,P,E,R,F,N,W;class qe{constructor(r){T(this,E);T(this,O,void 0);T(this,q,void 0);T(this,H,void 0);T(this,$,void 0);T(this,P,void 0);T(this,F,void 0);T(this,N,void 0);T(this,W,void 0);if(A(this,$,new Map),this.isAuthorized=!!this.bearerProfile,A(this,F,async(t,n,u)=>{const i=sessionStorage.getItem(U)||"";if(!i)throw new Error("Code verifier not found");return this.codeVerifier=i,sessionStorage.removeItem(U),await this.getBearerToken({code:u,redirect_uri:n,client_id:t,code_verifier:i})}),A(this,N,async({clientId:t,clientSecret:n})=>await this.getBearerToken({client_id:t,client_secret:n})),A(this,W,async(t,n)=>await this.getBearerToken({refresh_token:n,client_id:t})),this.subscribeToOrderNotifications=()=>{var u,i;const t=`${w(this,O).wss}/profiles/${(u=this.bearerProfile)==null?void 0:u.profile}/orders?access_token=${(i=this.bearerProfile)==null?void 0:i.access_token}`,n=new WebSocket(t);return n.addEventListener("open",()=>{console.info(`Socket connected: ${t}`)}),n.addEventListener("error",v=>{throw console.error(v),new Error(`Socket error: ${t}`)}),n.addEventListener("message",v=>{var p;const B=JSON.parse(v.data);(p=w(this,$).get(B.meta.state))==null||p(B)}),n.addEventListener("close",()=>{console.info(`Socket connection closed: ${t}`)}),n},this.auth=async t=>await this.getBearerToken(t),this.getAuthFlowURI=t=>{const n=Y(w(this,O).api,t);return this.codeVerifier=sessionStorage.getItem(U),n},this.pkceRequest=t=>this.getAuthFlowURI(t),this.getEnvironment=()=>w(this,O),!r){A(this,O,J.environments.sandbox);return}if(typeof r=="string")A(this,O,J.environments[r]);else if(A(this,O,J.environments[r.environment||"sandbox"]),Z){const{clientId:t,clientSecret:n}=r;A(this,P,{clientId:t,clientSecret:n})}else{const{clientId:t,redirectUrl:n}=r;A(this,P,{clientId:t,redirectUrl:n})}}async authorize(r){var i,v;const t=(r==null?void 0:r.clientId)||((i=w(this,P))==null?void 0:i.clientId),n=(r==null?void 0:r.redirectUrl)||((v=w(this,P))==null?void 0:v.redirectUrl);if(!t)throw new Error("Missing ClientId");if(!n)throw new Error("Missing RedirectUrl");const u=Y(w(this,O).api,{client_id:t,redirect_uri:n,address:r==null?void 0:r.address,signature:r==null?void 0:r.signature,chainId:r==null?void 0:r.chainId});window.location.replace(u)}async connect(r){var B,p,y;const t=(r==null?void 0:r.clientId)||((B=w(this,P))==null?void 0:B.clientId);if((r==null?void 0:r.clientSecret)||((p=w(this,P))==null?void 0:p.clientSecret)){if(!Z)throw new Error("Only use client credentials on server side");return await w(this,N).call(this,w(this,P)),!!this.bearerProfile}const u=(r==null?void 0:r.redirectUrl)||((y=w(this,P))==null?void 0:y.redirectUrl);if(!t)throw new Error("Missing ClientId");if(Z)throw new Error("This only works on client side");const i=new URLSearchParams(window.location.search).get("code")||void 0,v=sessionStorage.getItem(V)||void 0;return i?await w(this,F).call(this,t,u,i):v&&await w(this,W).call(this,t,v),!!this.bearerProfile}async getBearerToken(r){let t;if(ee(r))t={...r,grant_type:"authorization_code"};else if(Me(r))t={...r,grant_type:"refresh_token"};else if(Le(r))t={...r,grant_type:"client_credentials"};else throw new Error("Authentication method could not be detected.");return await I(this,E,R).call(this,"post","auth/token",t,!0).then(n=>{var u;this.bearerProfile=n,this.isAuthorized=!!n,A(this,q,`Bearer ${n==null?void 0:n.access_token}`),window.sessionStorage.setItem(V,((u=this.bearerProfile)==null?void 0:u.refresh_token)||"")}).catch(n=>{throw sessionStorage.removeItem(U),sessionStorage.removeItem(V),new Error(n==null?void 0:n.message)}),ee(r)&&He(),this.bearerProfile}getAuthContext(){return I(this,E,R).call(this,"get","auth/context")}getProfile(r){return I(this,E,R).call(this,"get",`profiles/${r}`)}getBalances(r){return r?I(this,E,R).call(this,"get",`profiles/${r}/balances`):I(this,E,R).call(this,"get","balances")}getOrders(r){const t=D(r);return I(this,E,R).call(this,"get",`orders?${t}`)}getOrder(r){return I(this,E,R).call(this,"get",`orders/${r}`)}getTokens(){return I(this,E,R).call(this,"get","tokens")}linkAddress(r,t){return I(this,E,R).call(this,"post",`profiles/${r}/addresses`,JSON.stringify(t))}placeOrder(r,t){const n={...r,kind:"redeem",currency:"eur"};return t?I(this,E,R).call(this,"post",`profiles/${t}/orders`,JSON.stringify(n)):I(this,E,R).call(this,"post","orders",JSON.stringify(n))}uploadSupportingDocument(r){const t=D(r);return I(this,E,R).call(this,"post","files/supporting-document",t,!0)}async connectOrderSocket(){var r;(r=this.bearerProfile)!=null&&r.access_token&&w(this,$).size>0&&A(this,H,this.subscribeToOrderNotifications())}async disconnect(){var r;sessionStorage.removeItem(U),w(this,$).clear(),(r=w(this,H))==null||r.close()}subscribeOrders(r,t){w(this,$).set(r,t)}unsubscribeOrders(r){var t;w(this,$).delete(r),w(this,$).size===0&&((t=w(this,H))==null||t.close(),A(this,H,void 0))}}O=new WeakMap,q=new WeakMap,H=new WeakMap,$=new WeakMap,P=new WeakMap,E=new WeakSet,R=async function(r,t,n,u){return je(`${w(this,O).api}/${t}`,r,u?D(n):n,{Authorization:w(this,q)||"","Content-Type":`application/${u?"x-www-form-urlencoded":"json"}`})},F=new WeakMap,N=new WeakMap,W=new WeakMap;exports.AccountState=ie;exports.Currency=re;exports.KYCOutcome=se;exports.KYCState=oe;exports.MoneriumClient=qe;exports.OrderKind=ce;exports.OrderState=ue;exports.PaymentStandard=ae;exports.Permission=ne;exports.ProfileType=te;exports.constants=ke;exports.placeOrderMessage=_e;exports.rfc3339=de;
"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 ne=(e=>(e.eur="eur",e))(ne||{}),se=(e=>(e.corporate="corporate",e.personal="personal",e))(se||{}),oe=(e=>(e.read="read",e.write="write",e))(oe||{}),ie=(e=>(e.absent="absent",e.submitted="submitted",e.pending="pending",e.confirmed="confirmed",e))(ie||{}),ae=(e=>(e.approved="approved",e.rejected="rejected",e.unknown="unknown",e))(ae||{}),ce=(e=>(e.requested="requested",e.approved="approved",e.pending="pending",e))(ce||{}),ue=(e=>(e.iban="iban",e.scan="scan",e))(ue||{}),de=(e=>(e.redeem="redeem",e.issue="issue",e))(de||{}),he=(e=>(e.placed="placed",e.pending="pending",e.processed="processed",e.rejected="rejected",e))(he||{});const fe=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())},Be=(e,t)=>`Send EUR ${e} to ${t} at ${fe(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("&"):""},le=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}`)}},pe=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"}}},ke="I hereby declare that I am the address owner.",M="monerium.sdk.code_verifier",W="monerium.sdk.refresh_token",xe={LINK_MESSAGE:ke,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 ve(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Ae(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 ge={exports:{}};function Ee(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 Ie={},Re=Object.freeze(Object.defineProperty({__proto__:null,default:Ie},Symbol.toStringTag,{value:"Module"})),Oe=Ae(Re);var ee;function we(){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 Ee=="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||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(we())})(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})})(ge);var Pe=ge.exports;const $e=ve(Pe);var ye={exports:{}};(function(e,t){(function(r,n){e.exports=n(we())})(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 me=a&d^~a&_,_e=f&A^f&s^A&s,be=(f<<30|f>>>2)^(f<<19|f>>>13)^(f<<10|f>>>22),Se=(a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25),Y=S+Se+me+m[k]+g[k],Ce=be+_e;S=_,_=d,d=a,a=o+Y|0,o=s,s=A,A=f,f=Y+Ce|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})})(ye);var ze=ye.exports;const Ue=ve(ze),He=(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?le(v):C}:{},...v!==void 0||p!==void 0?{network:v?pe(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})},Te=()=>{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},Me=e=>$e.stringify(Ue(e)),te=(e,t)=>{const r=Te(),n=Me(r);return sessionStorage.setItem(M,r||""),`${e}/auth?${He(t,n)}`},Le=()=>{const e=window.location.href,[t,r]=e.split("?");r&&window.history.replaceState(null,"",t)},re=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(re(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)),new Error(n==null?void 0:n.message)}),re(t)&&Le(),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=ce;exports.Currency=ne;exports.KYCOutcome=ae;exports.KYCState=ie;exports.MoneriumClient=Fe;exports.OrderKind=de;exports.OrderState=he;exports.PaymentStandard=ue;exports.Permission=oe;exports.ProfileType=se;exports.constants=xe;exports.getChain=le;exports.getNetwork=pe;exports.placeOrderMessage=Be;exports.rfc3339=fe;
{
"name": "@monerium/sdk",
"version": "2.7.1",
"version": "2.7.2",
"description": "Everything you need to interact with the Monerium API - an electronic money issuer.",

@@ -28,3 +28,2 @@ "license": "MIT",

},
"packageManager": "yarn@3.5.0",
"dependencies": {

@@ -31,0 +30,0 @@ "crypto-js": "^4.2.0"

@@ -272,2 +272,3 @@ export type Environment = {

signature: string;
currency?: Currency /** Not needed right now, only EUR */;
counterpart: Counterpart;

@@ -274,0 +275,0 @@ message: string;

{
"name": "@monerium/sdk",
"version": "2.7.1",
"version": "2.7.2",
"description": "Everything you need to interact with the Monerium API - an electronic money issuer.",

@@ -28,3 +28,2 @@ "license": "MIT",

},
"packageManager": "yarn@3.5.0",
"dependencies": {

@@ -31,0 +30,0 @@ "crypto-js": "^4.2.0"

@@ -67,2 +67,4 @@ # Monerium SDK Documentation

await monerium.getAccess();
// Retrieve authentication data after successful authentication.

@@ -111,3 +113,3 @@ await monerium.getAuthContext();

if (monerium) {
setIsAuthorized(await monerium.connect());
setIsAuthorized(await monerium.getAccess());
}

@@ -316,2 +318,31 @@ };

#### Subscribe to order events
````ts
import { OrderState } from '@monerium/sdk';
const [orderState, setOrderState] = useState<OrderState>();
// Subscribe to order events
monerium.subscribeOrders(OrderState.pending, (notification) => {
setOrderState(notification.meta.state)
})
monerium.subscribeOrders(OrderState.placed, (notification) => {
setOrderState(notification.meta.state)
})
monerium.subscribeOrders(OrderState.rejected, (notification) => {
setOrderState(notification.meta.state)
setTimeout(() => {
setOrderState(undefined)
}, 5000)
})
monerium.subscribeOrders(OrderState.processed, (notification) => {
setOrderState(notification.meta.state)
setTimeout(() => {
setOrderState(undefined)
}, 5000)
})
```
## API Reference

@@ -340,3 +371,3 @@

yarn docs:watch
```
````

@@ -343,0 +374,0 @@ 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.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc