Before you start, make sure you have a fresh version of Node.js installed. The current Long Term Support (LTS) release is an ideal starting point.
# Run this command in your project root folder.
# yarn
yarn add dun-js
# npm
npm install --save dun-jsThen you can simply import or require the module.
// ES module
import { AuthClient } from 'dun-js';
const authClient = new AuthClient(/* configOptions */);// CommonJS
var AuthClient = require('dun-js').AuthClient;
var authClient = new AuthClient(/* configOptions */);const config = {
mode: 'development',
brandUrl: 'jframework.io',
};
const authClient = new AuthClient(config);Type definitions are provided implicitly through the types entry in package.json. Types can also be referenced explicitly by importing them.
import { AuthClient, DunConfig } from 'dun-js';
const config: DunConfig = {
mode: 'development',
brandUrl: 'jframework.io',
};
const authClient: AuthClient = new AuthClient(config);You can easily utilize the API by importing it and then invoking its methods.
Example:
import { ISignInPayload, signInAPI } from 'dun-js';
const payload: ISignInPayload = {
username: formValues.username,
password: formValues.password,
};
const response = await signInAPI(payload);These options can be included when instantiating DUN Auth JS (new AuthClient(config)).
⚠️ This option is required
The url for your DUN brand.
The default environment for your application is set to 'production'. To switch to a development environment, set the environment to 'development'.
Upon logging in, you will receive an authKey from the server. Use the following method to set the authKey in the request header.
Example:
authClient.setAuthKey(authKey);If you want to set headers for all APIs, use this method.
Example:
const userHeaders = {
UrlRequest: window.location.href,
};
authClient.setHeaders(userHeaders);- auth
- brand
- cdn
- currency
- [getListCurrenciesAPI]
- [getListExchangeRatesAPI]
- device
- integration
- invoice
- issue
- language
- license
- notification
- organization
- [getListOrganizationsAPI]
- getOrganizationDetailAPI
- [getListOrganizationsByViewerAPI]
- [createOrganizationUserAPI]
- updateOrganizationUserAPI
- deleteOrganizationUserAPI
- getListUsersOfOrganizationAPI
- package
- payment-provider
- [getListPaymentProvidersAPI]
- price
- role
- timezone
- user
- getUserInfoAPI
- [getListUsersByIdsAPI]
- getUserInfoByIdAPI
- updateUserAPI
- signUpAPI
- forgotPasswordAPI
- [resetPasswordAPI]
- changePasswordAPI
- getRefereesAPI
- [checkCodeValidAPI]
- applyCodeAPI
- [getListUserConfigurationsAPI]
- [createUserConfigurationsAPI]
- [updateUserConfigurationsAPI]
- wallet
- getWalletAPI
- getWalletHistoriesAPI
- createWalletAPI
- exchangeWalletAPI
- addMoneyAPI
- closeWalletAPI
- [getListEarnEventsAPI]
- applyRedeemAPI