Class: MoneriumClient
Constructors
new MoneriumClient()
new MoneriumClient(
envOrOptions
?):MoneriumClient
Parameters
• envOrOptions?: ENV
| ClassOptions
Returns
Default Value
sandbox
Example
new MoneriumClient() // defaults to `sandbox`
new MoneriumClient('production')
new MoneriumClient({
environment: 'sandbox',
clientId: 'your-client-id',
redirectUri: 'your-redirect-url'
})
Defined in
Properties
bearerProfile?
optional
bearerProfile:BearerProfile
The bearer profile will be available after authentication, it includes the access_token
and refresh_token
Defined in
isAuthorized
isAuthorized:
boolean
=!!this.bearerProfile
Defined in
state
state:
undefined
|string
The state parameter is used to maintain state between the request and the callback.
Defined in
Methods
Auth
authorize()
authorize(
client
?):Promise
<void
>
Construct 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
Parameters
• client?: AuthFlowOptions
Returns
Promise
<void
>
string https://monerium.dev/api-docs#operation/auth
Defined in
disconnect()
disconnect():
Promise
<void
>
Cleanups the socket and the subscriptions
Returns
Promise
<void
>
Defined in
getAccess()
getAccess(
client
?):Promise
<boolean
>
Will redirect to the authorization code flow and store the code verifier in the local storage
Parameters
• client?: ClientCredentials
| AuthorizationCodeCredentials
| DeprecatedAuthorizationCodeCredentials
the client credentials
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();
Defined in
getAuthContext()
getAuthContext():
Promise
<AuthContext
>
https://monerium.dev/api-docs#operation/auth-context
Returns
Promise
<AuthContext
>
Defined in
revokeAccess()
revokeAccess():
Promise
<void
>
Revokes access
Returns
Promise
<void
>
Defined in
Accounts
getBalances()
getBalances(
profileId
?):Promise
<Balances
[]>
https://monerium.dev/api-docs#operation/profile-balances
Parameters
• profileId?: string
the id of the profile to fetch balances.
Returns
Promise
<Balances
[]>
Defined in
linkAddress()
linkAddress(
profileId
,body
):Promise
<LinkedAddress
>
https://monerium.dev/api-docs#operation/profile-addresses
Parameters
• profileId: string
• body: LinkAddress
Returns
Promise
<LinkedAddress
>
Defined in
Profiles
getProfile()
getProfile(
profileId
):Promise
<Profile
>
https://monerium.dev/api-docs#operation/profile
Parameters
• profileId: string
the id of the profile to fetch.
Returns
Promise
<Profile
>
Defined in
getProfiles()
getProfiles():
Promise
<Profile
[]>
https://monerium.dev/api-docs#operation/profiles
Returns
Promise
<Profile
[]>
Defined in
Orders
connectOrderSocket()
connectOrderSocket():
Promise
<void
>
Connects to the order notifications socket
Returns
Promise
<void
>
Defined in
getOrder()
getOrder(
orderId
):Promise
<Order
>
https://monerium.dev/api-docs#operation/order
Parameters
• orderId: string
Returns
Promise
<Order
>
Defined in
getOrders()
getOrders(
filter
?):Promise
<Order
[]>
https://monerium.dev/api-docs#operation/orders
Parameters
• filter?: OrderFilter
Returns
Promise
<Order
[]>
Defined in
placeOrder()
placeOrder(
order
):Promise
<Order
>
https://monerium.dev/api-docs#operation/post-orders
Parameters
• order: NewOrder
Returns
Promise
<Order
>
Defined in
subscribeOrders()
subscribeOrders(
event
,handler
):void
Subscribe to MoneriumEvent to receive notifications using the Monerium API (WebSocket) We are setting a subscription map because we need the user to have a token to start the WebSocket connection https://monerium.dev/api-docs#operation/profile-orders-notifications
Parameters
• event: OrderState
The event to subscribe to
• handler: MoneriumEventListener
The handler to be called when the event is triggered
Returns
void
Defined in
subscribeToOrderNotifications()
subscribeToOrderNotifications():
WebSocket
Subscribes to the order notifications socket
Returns
WebSocket
Defined in
unsubscribeOrders()
unsubscribeOrders(
event
):void
Unsubscribe from MoneriumEvent and close the socket if there are no more subscriptions
Parameters
• event: OrderState
The event to unsubscribe from
Returns
void
Defined in
uploadSupportingDocument()
uploadSupportingDocument(
document
):Promise
<SupportingDoc
>
https://monerium.dev/api-docs#operation/supporting-document
Parameters
• document: File
Returns
Promise
<SupportingDoc
>
Defined in
Tokens
getTokens()
getTokens():
Promise
<Token
[]>
https://monerium.dev/api-docs#operation/tokens
Returns
Promise
<Token
[]>