Class: MoneriumClient
In the Monerium UI, create an application to get the clientId
and register your redirectUri
.
import { MoneriumClient } from '@monerium/sdk';
const monerium = new MoneriumClient() // defaults to `sandbox`
// or
new MoneriumClient('production')
// or
new MoneriumClient({
environment: 'sandbox',
clientId: 'your-client-id',
redirectUri: 'http://your-redirect-url.com/monerium'
});
Constructors
new MoneriumClient()
new MoneriumClient(
envOrOptions
?:ENV
|ClassOptions
):MoneriumClient
Parameters
Parameter | Type |
---|---|
envOrOptions ? | ENV | ClassOptions |
Returns
Default Value
sandbox
Properties
Property | Type | Description |
---|---|---|
bearerProfile? | BearerProfile | The bearer profile will be available after authentication, it includes the access_token and refresh_token |
isAuthorized | boolean | The client is authorized if the bearer profile is available |
state | undefined | string | The state parameter is used to maintain state between the request and the callback. |
Authentication
authorize()
authorize(
params
?:AuthFlowOptions
):Promise
<void
>
Constructs the url to the authorization code flow and redirects,
Code Verifier needed for the code challenge is stored in local storage
For automatic wallet link, add the following properties: address
, signature
& chain
This authorization code is then used to request an access token via the token endpoint. (https://monerium.dev/api-docs#operation/auth-token)
Parameters
Parameter | Type | Description |
---|---|---|
params ? | AuthFlowOptions | the auth flow params |
Returns
Promise
<void
>
void
See
disconnect()
disconnect():
Promise
<void
>
Cleanups the localstorage and websocket connections
Returns
Promise
<void
>
getAccess()
getAccess(
refreshToken
?:string
):Promise
<boolean
>
Will use the authorization code flow code to get access token
Parameters
Parameter | Type | Description |
---|---|---|
refreshToken ? | string | provide the refresh token to get a new access token |
Returns
Promise
<boolean
>
boolean to indicate if access has been granted
Example
import { MoneriumClient } from '@monerium/sdk';
// Initialize the client with credentials
const monerium = new MoneriumClient({
environment: 'sandbox',
clientId: 'your_client_credentials_uuid', // replace with your client ID
clientSecret: 'your_client_secret', // replace with your client secret
});
await monerium.getAccess();
const refreshToken = monerium.bearerProfile?.refresh_token;
// TODO: store the refresh token securely
// reconnect...
await monerium.getAccess(refreshToken);
getAuthContext()
getAuthContext():
Promise
<AuthContext
>
Returns
Promise
<AuthContext
>
See
revokeAccess()
revokeAccess():
Promise
<void
>
Revokes access
Returns
Promise
<void
>
siwe()
siwe(
params
?:AuthFlowSIWEOptions
):Promise
<void
>
Constructs the url to the authorization code flow and redirects, Code Verifier needed for the code challenge is stored in local storage
"Sign in with Ethereum" (SIWE) flow can be used for existing Monerium customers. In this case the payload must include a valid EIP-4361 (https://eips.ethereum.org/EIPS/eip-4361) message and signature. On successful authorization the authorization code is returned at once.
This authorization code is then used to request an access token via the token endpoint.
Parameters
Parameter | Type | Description |
---|---|---|
params ? | AuthFlowSIWEOptions | the auth flow SIWE params |
Returns
Promise
<void
>
void
See
Addresses
getAddress()
getAddress(
address
:string
):Promise
<Address
>
Get details for a single address by using the address public key after the address has been successfully linked to Monerium.
Parameters
Parameter | Type | Description |
---|---|---|
address | string | The public key of the blockchain account. |
Returns
Promise
<Address
>
See
Example
monerium.getAddress('0x1234567890abcdef1234567890abcdef12345678')
getAddresses()
getAddresses(
params
?:AddressesQueryParams
):Promise
<AddressesResponse
>
Parameters
Parameter | Type | Description |
---|---|---|
params ? | AddressesQueryParams | No required parameters. |
Returns
Promise
<AddressesResponse
>
See
getBalances()
getBalances(
address
:string
,chain
:string
|number
,currencies
?:Currency
|Currency
[]):Promise
<Balances
>
Parameters
Parameter | Type |
---|---|
address | string |
chain | string | number |
currencies ? | Currency | Currency [] |
Returns
Promise
<Balances
>
See
linkAddress()
linkAddress(
payload
:LinkAddress
):Promise
<LinkedAddress
>
Add a new address to the profile
Parameters
Parameter | Type |
---|---|
payload | LinkAddress |
Returns
Promise
<LinkedAddress
>
See
Profiles
getProfile()
getProfile(
profile
:string
):Promise
<Profile
>
Parameters
Parameter | Type | Description |
---|---|---|
profile | string | the id of the profile to fetch. |
Returns
Promise
<Profile
>
See
getProfiles()
getProfiles(
params
?:ProfilesQueryParams
):Promise
<ProfilesResponse
>
Parameters
Parameter | Type |
---|---|
params ? | ProfilesQueryParams |
Returns
Promise
<ProfilesResponse
>
See
submitProfileDetails()
submitProfileDetails(
profile
:string
,body
:SubmitProfileDetailsPayload
):Promise
<ResponseStatus
>
Parameters
Parameter | Type |
---|---|
profile | string |
body | SubmitProfileDetailsPayload |
Returns
Promise
<ResponseStatus
>
See
IBANs
getIban()
getIban(
iban
:string
):Promise
<IBAN
>
Fetch details about a single IBAN
Parameters
Parameter | Type | Description |
---|---|---|
iban | string | the IBAN to fetch. |
Returns
Promise
<IBAN
>
See
getIbans()
getIbans(
queryParameters
?:IbansQueryParams
):Promise
<IBANsResponse
>
Fetch all IBANs for the profile
Parameters
Parameter | Type |
---|---|
queryParameters ? | IbansQueryParams |
Returns
Promise
<IBANsResponse
>
See
moveIban()
moveIban(
iban
:string
,payload
:MoveIbanPayload
):Promise
<ResponseStatus
>
Parameters
Parameter | Type | Description |
---|---|---|
iban | string | the IBAN to move. |
payload | MoveIbanPayload | the payload to move the IBAN. |
Returns
Promise
<ResponseStatus
>
See
requestIban()
requestIban(
payload
:RequestIbanPayload
):Promise
<ResponseStatus
>
Parameters
Parameter | Type | Description |
---|---|---|
payload | RequestIbanPayload |
Returns
Promise
<ResponseStatus
>
See
Orders
getOrder()
getOrder(
orderId
:string
):Promise
<Order
>
Parameters
Parameter | Type |
---|---|
orderId | string |
Returns
Promise
<Order
>
See
getOrders()
getOrders(
filter
?:OrderFilter
):Promise
<OrdersResponse
>
Parameters
Parameter | Type |
---|---|
filter ? | OrderFilter |
Returns
Promise
<OrdersResponse
>
See
placeOrder()
Parameters
Parameter | Type |
---|---|
order | NewOrder |
Returns
Promise
<Order
>
See
subscribeOrderNotifications()
subscribeOrderNotifications(
params
?: {filter
:OrderNotificationQueryParams
;onError
: (err
:Event
) =>void
;onMessage
: (data
:Order
) =>void
; }):undefined
|WebSocket
Connects to the order notifications socket
Parameters
Parameter | Type | Description |
---|---|---|
params ? | { filter : OrderNotificationQueryParams ; onError : (err : Event ) => void ; onMessage : (data : Order ) => void ; } | |
params.filter ? | OrderNotificationQueryParams | specify which type of orders to listen to |
params.onError ? | (err : Event ) => void | - |
params.onMessage ? | (data : Order ) => void | - |
Returns
undefined
| WebSocket
See
unsubscribeOrderNotifications()
unsubscribeOrderNotifications(
params
?:OrderNotificationQueryParams
):void
Closes the order notifications sockets
Parameters
Parameter | Type | Description |
---|---|---|
params ? | OrderNotificationQueryParams | specify which socket to close or close all if not provided |
Returns
void
See
uploadSupportingDocument()
uploadSupportingDocument(
document
:File
):Promise
<SupportingDoc
>
Parameters
Parameter | Type |
---|---|
document | File |
Returns
Promise
<SupportingDoc
>
See
Tokens
getTokens()
getTokens():
Promise
<Token
[]>
Returns
Promise
<Token
[]>