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
Defined in
Properties
Property | Type | Description | Defined in |
---|---|---|---|
bearerProfile? | BearerProfile | The bearer profile will be available after authentication, it includes the access_token and refresh_token | client.ts:95 |
isAuthorized | boolean | The client is authorized if the bearer profile is available | client.ts:103 |
state | undefined | string | The state parameter is used to maintain state between the request and the callback. | client.ts:111 |
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
Defined in
disconnect()
disconnect():
Promise
<void
>
Cleanups the localstorage and websocket connections
Returns
Promise
<void
>
Defined in
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);
Defined in
revokeAccess()
revokeAccess():
Promise
<void
>
Revokes access
Returns
Promise
<void
>
Defined in
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
Defined in
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')
Defined in
getAddresses()
getAddresses(
params
?:AddressesQueryParams
):Promise
<AddressesResponse
>
Parameters
Parameter | Type | Description |
---|---|---|
params ? | AddressesQueryParams | No required parameters. |
Returns
Promise
<AddressesResponse
>
See
Defined in
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
Defined in
linkAddress()
linkAddress(
payload
:LinkAddress
):Promise
<LinkedAddress
>
Add a new address to the profile
Parameters
Parameter | Type |
---|---|
payload | LinkAddress |
Returns
Promise
<LinkedAddress
>
See
Defined in
Profiles
getProfile()
getProfile(
profile
:string
):Promise
<Profile
>
Parameters
Parameter | Type | Description |
---|---|---|
profile | string | the id of the profile to fetch. |
Returns
Promise
<Profile
>
See
Defined in
getProfiles()
getProfiles(
params
?:ProfilesQueryParams
):Promise
<ProfilesResponse
>
Parameters
Parameter | Type |
---|---|
params ? | ProfilesQueryParams |
Returns
Promise
<ProfilesResponse
>
See
Defined in
submitProfileDetails()
submitProfileDetails(
profile
:string
,body
:SubmitProfileDetailsPayload
):Promise
<ResponseStatus
>
Parameters
Parameter | Type |
---|---|
profile | string |
body | SubmitProfileDetailsPayload |
Returns
Promise
<ResponseStatus
>
See
Defined in
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
Defined in
getIbans()
getIbans(
queryParameters
?:IbansQueryParams
):Promise
<IBANsResponse
>
Fetch all IBANs for the profile
Parameters
Parameter | Type |
---|---|
queryParameters ? | IbansQueryParams |
Returns
Promise
<IBANsResponse
>
See
Defined in
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
Defined in
requestIban()
requestIban(
payload
:RequestIbanPayload
):Promise
<ResponseStatus
>
Parameters
Parameter | Type | Description |
---|---|---|
payload | RequestIbanPayload |
Returns
Promise
<ResponseStatus
>
See
Defined in
Orders
getOrder()
getOrder(
orderId
:string
):Promise
<Order
>
Parameters
Parameter | Type |
---|---|
orderId | string |
Returns
Promise
<Order
>
See
Defined in
getOrders()
getOrders(
filter
?:OrderFilter
):Promise
<OrdersResponse
>
Parameters
Parameter | Type |
---|---|
filter ? | OrderFilter |
Returns
Promise
<OrdersResponse
>
See
Defined in
placeOrder()
Parameters
Parameter | Type |
---|---|
order | NewOrder |
Returns
Promise
<Order
>
See
Defined in
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 ? | object | |
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
Defined in
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
Defined in
uploadSupportingDocument()
uploadSupportingDocument(
document
:File
):Promise
<SupportingDoc
>
Parameters
Parameter | Type |
---|---|
document | File |
Returns
Promise
<SupportingDoc
>
See
Defined in
Tokens
getTokens()
getTokens():
Promise
<Token
[]>
Returns
Promise
<Token
[]>