Embedded Wallets
SDK
Javascript
How to
Setup Authentication
Username
Login

Login with Custody Authentication

This method allows you to log in to your Xellar Embedded wallet account using custody authentication with the user's subId.

Parameters

  • subId (string, required): User's subId for custody authentication.
  • 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 subId = "user_sub_id_123";
const response = await sdk.auth.custody.login(subId);

With rampable option

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