Embedded Wallets
SDK
Javascript
How to
Setup Authentication
Username
Login

Login with Username

This method allows you to log in to your Xellar Embedded wallet account using the user's username and password.

Parameters

  • username (string, required): User's chosen username.
  • password (string, required): User's password.
  • options (object, optional): Configuration object.
    • rampable (object, optional): Rampable account configuration.
      • username (string): The username for the rampable account.
      • fullName (string): The full name for the rampable account.
      • password (string): The password for the rampable account.
ℹ️

The rampable option is used to create a new rampable account for users who are already registered with Xellar but have not yet registered for rampable. This allows existing Xellar users to set up their rampable account credentials during the login process.

Returns

An AuthSuccessResponse object, potentially including a rampableAccessToken if the rampable option was provided.

If a wallet is created, the response will include a walletToken.

{
  "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "isWalletCreated": true,
  "walletToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
}

If a wallet is not created, the response will include an accessToken.

{
  "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "isWalletCreated": false,
  "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

If the rampable option was provided, the response will include a rampableAccessToken.

{
  "isWalletCreated": false,
  "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "rampableAccessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Example Usage

Basic usage

const username = "user123";
const password = "securePassword";
const response = await sdk.auth.username.login(username, password);

With rampable option

const username = "user123";
const password = "securePassword";
const options = {
  rampable: {
    username: "rampableUser",
    fullName: "John Doe",
    password: "rampablePassword"
  }
};
 
const response = await sdk.auth.username.login(username, password, options);