leapcat-auth

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

LeapCat Authentication Skill

LeapCat 认证 Skill

Manage user authentication for the leapcat. Handles login, logout, session management, token refresh, re-authentication, and trade password operations.
为Leapcat管理用户认证,可处理登录、登出、会话管理、token刷新、重新认证以及交易密码相关操作。

Prerequisites

前置条件

  • Node.js 18+ is required (commands use
    npx leapcat@latest
    which auto-downloads the CLI)
  • A valid email address registered with LeapCat
  • 需要Node.js 18及以上版本(命令使用
    npx leapcat@latest
    会自动下载CLI)
  • 已在LeapCat注册的有效邮箱地址

Commands

命令

auth login (non-interactive, two-step flow)

auth login(非交互式,两步流程)

Step 1 — Send OTP to email:
bash
npx leapcat@latest auth login --email <email> --send-only --json
Response:
json
{ "otp_id": "<otp-id-string>" }
Step 2 — Verify OTP and complete login:
bash
npx leapcat@latest auth login --email <email> --otp-id <otp-id> --otp-code <code> --json
Parameters:
  • --email <email>
    — User email address (required)
  • --send-only
    — Only send the OTP, do not attempt verification
  • --otp-id <id>
    — OTP identifier returned from step 1
  • --otp-code <code>
    — 6-digit code the user received via email
  • --json
    — Output in JSON format (always use for agent consumption)
步骤1 — 向邮箱发送OTP:
bash
npx leapcat@latest auth login --email <email> --send-only --json
响应:
json
{ "otp_id": "<otp-id-string>" }
步骤2 — 验证OTP并完成登录:
bash
npx leapcat@latest auth login --email <email> --otp-id <otp-id> --otp-code <code> --json
参数:
  • --email <email>
    — 用户邮箱地址(必填)
  • --send-only
    — 仅发送OTP,不执行验证
  • --otp-id <id>
    — 步骤1返回的OTP标识符
  • --otp-code <code>
    — 用户通过邮箱收到的6位验证码
  • --json
    — 以JSON格式输出(供Agent调用时请始终使用该参数)

auth logout

auth logout

End the current session and clear stored credentials.
bash
npx leapcat@latest auth logout --json
结束当前会话并清除存储的凭证。
bash
npx leapcat@latest auth logout --json

auth status

auth status

Check if the user is currently authenticated and whether the token is still valid.
bash
npx leapcat@latest auth status --json
检查用户当前是否已认证,以及token是否仍有效。
bash
npx leapcat@latest auth status --json

auth refresh

auth refresh

Refresh the current authentication token before it expires.
bash
npx leapcat@latest auth refresh --json
在当前认证token过期前进行刷新。
bash
npx leapcat@latest auth refresh --json

auth reauth

auth reauth

Perform a re-authentication to obtain an elevated session (e.g., for withdrawal operations that require a Turnkey session).
bash
npx leapcat@latest auth reauth --json
执行重新认证以获取更高权限的会话(例如需要Turnkey会话的提现操作场景)。
bash
npx leapcat@latest auth reauth --json

auth trade-password set

auth trade-password set

Set the trade password for the first time. Required before placing orders or subscribing to IPOs.
bash
npx leapcat@latest auth trade-password set --json
首次设置交易密码,下单或申购IPO前必须完成该操作。
bash
npx leapcat@latest auth trade-password set --json

auth trade-password verify

auth trade-password verify

Verify the trade password.
bash
npx leapcat@latest auth trade-password verify --json
验证交易密码。
bash
npx leapcat@latest auth trade-password verify --json

auth trade-password reset

auth trade-password reset

Reset a forgotten trade password.
bash
npx leapcat@latest auth trade-password reset --json
重置遗忘的交易密码。
bash
npx leapcat@latest auth trade-password reset --json

auth trade-password status

auth trade-password status

Check whether a trade password has been set.
bash
npx leapcat@latest auth trade-password status --json
检查是否已设置交易密码。
bash
npx leapcat@latest auth trade-password status --json

Workflow

工作流程

  1. Check auth status — Run
    auth status --json
    to determine if the user is already logged in.
  2. Login if needed — If not authenticated, execute the two-step login flow:
    • Send OTP with
      --send-only
    • Ask the user for the OTP code they received
    • Complete login with
      --otp-id
      and
      --otp-code
  3. Refresh when expired — If a command returns a 401/token-expired error, run
    auth refresh --json
    . If refresh fails, re-run the full login flow.
  4. Re-auth for sensitive operations — Before wallet withdrawals or other sensitive actions, run
    auth reauth --json
    to elevate the session.
  1. 检查认证状态 — 运行
    auth status --json
    确认用户是否已登录。
  2. 如有需要执行登录 — 若未认证,执行两步登录流程:
    • 携带
      --send-only
      参数发送OTP
    • 向用户询问其收到的OTP验证码
    • 携带
      --otp-id
      --otp-code
      参数完成登录
  3. 过期时刷新 — 若命令返回401/token-expired错误,运行
    auth refresh --json
    。如果刷新失败,重新执行完整登录流程。
  4. 敏感操作前重新认证 — 在钱包提现或其他敏感操作前,运行
    auth reauth --json
    提升会话权限。

Error Handling

错误处理

ErrorCauseResolution
OTP_EXPIRED
OTP code timed outRe-send OTP with
--send-only
and retry
INVALID_OTP
Wrong OTP code enteredAsk the user to double-check the code and retry
TOKEN_EXPIRED
Auth token has expiredRun
auth refresh --json
; if that fails, login again
NOT_AUTHENTICATED
No active sessionRun the full login flow
TRADE_PASSWORD_NOT_SET
Trade password required but not setRun
auth trade-password set --json
错误原因解决方案
OTP_EXPIRED
OTP验证码超时携带
--send-only
参数重新发送OTP后重试
INVALID_OTP
输入的OTP验证码错误请用户核对验证码后重试
TOKEN_EXPIRED
认证token已过期运行
auth refresh --json
;如果操作失败,重新登录
NOT_AUTHENTICATED
无活跃会话执行完整登录流程
TRADE_PASSWORD_NOT_SET
需要交易密码但尚未设置运行
auth trade-password set --json