Auth

Use Auth module to handle authentication.

import { Auth } from "@akord/akord-js";
  • By default Auth is using SRP authentication

  • Auth stores tokens in Storage implementation

  • Storage defaults to localStorage on web & memoryStorage on nodeJs

  • Storage implementation can be configured with Auth.configure({ storage: window.sessionStorage })

  • Auth is automatically refreshing tokens in SRP mode

  • On server side it is recommended to use API keys: Auth.configure({ apiKey: 'your_api_key' })

  • API key: can be generated over web app & over CLI

Short-lived token with refresh

import { Auth } from "@akord/akord-js";
Auth.configure({ storage: window.sessionStorage }); // optionally - configure tokens store

API key

import { Auth } from "@akord/akord-js";
Auth.configure({ apiKey: "api_key" });

Self-managed auth token

import { Akord, Auth } from "@akord/akord-js";
Auth.configure({ authToken: "auth_token" });

signIn(email, password)

  • email (string, required)

  • password (string, required)

  • returns Promise<{ wallet, jwt }> - Promise with JWT token & Akord Wallet

example
const { wallet } = await Auth.signIn("winston@gmail.com", "1984");

signUp(email, password)

  • email (string, required)

  • password (string, required)

  • clientMetadata (any, optional) - JSON client metadata, ex: { clientType: "CLI" }

  • returns Promise<AkordWallet> - Promise with Akord Wallet

example
const { wallet } = await Auth.signUp("winston@gmail.com", "1984");

verifyAccount(email, code)

  • email (string, required)

  • code (string, required)

  • returns Promise<void>

example
await Auth.verifyAccount("winston@gmail.com", 123456);

Last updated