Skip to content

nuclei-js-common/api/auth#

clearTokens#

const clearTokens: () => void;

Returns#

void


login#

const login: (creds) => Promise<LoginResult>;

Log in with username/password. Returns either the logged-in user (tokens stored), or { totp_required: true, totp_token } when the account has 2FA enabled β€” in which case the caller must collect a code and call verifyTotp(totp_token, code).

Parameters#

Parameter Type
creds Credentials

Returns#

Promise<LoginResult>


logout#

const logout: () => Promise<void>;

Returns#

Promise<void>


setInitialPassword#

const setInitialPassword: (newPassword) => Promise<void>;

Set a permanent password on first login (for admin-invited accounts that logged in with a temporary password). Requires an authenticated session.

Parameters#

Parameter Type
newPassword string

Returns#

Promise<void>


verifyTotp#

const verifyTotp: (totpToken, code) => Promise<UserInfo>;

Second step of 2FA login: exchange the pending token + TOTP/recovery code for tokens.

Parameters#

Parameter Type
totpToken string
code string

Returns#

Promise<UserInfo>


Credentials#

Properties#

password#

password: string;

username#

username: string;

LoginSuccess#

Properties#

totp_required#

totp_required: false;

user#

user: UserInfo;

TotpRequired#

Server signalled the account has 2FA enabled β€” exchange totp_token via verifyTotp.

Properties#

totp_required#

totp_required: true;

totp_token#

totp_token: string;

LoginResult#

type LoginResult = TotpRequired | LoginSuccess;