← 返回
未分类

Liberfi Auth

Authenticate with LiberFi: register a new account, log in, manage session state, and verify wallet assignments. Two login modes are supported: 1. Key-based (...
在LiberFi上完成身份验证:注册新账户、登录、管理会话状态、验证钱包分配。支持两种登录模式:1. 基于密钥的(
bombmod bombmod 来源
未分类 clawhub v1.0.1 1 版本 100000 Key: 无需
★ 0
Stars
📥 359
下载
💾 1
安装
1
版本
#latest

概述

LiberFi Auth

Authenticate with LiberFi and manage your session.

Pre-flight Checks

See bootstrap.md for CLI installation and connectivity verification.

Login Modes

Mode 1 — Key-based Login (recommended for agents)

Generates a P-256 key pair on first use; on subsequent calls, the existing key is reused.

No user interaction required — suitable for automated and agent environments.

lfi login key --role AGENT --name "MyAgent" --json

Flow:

  1. Loads ~/.liberfi/keys/default.json or generates a new key pair.
  2. Signs Date.now() (Unix ms string) with the local private key (SHA-256 + ECDSA P-256).
  3. Sends POST /v1/auth/key with { publicKeyHex, uncompressedPublicKeyHex, timestampMs, signature }.
  4. Server verifies the signature and upserts the user record.
  5. If new user: server creates server-owned EVM + SOL TEE wallets.
  6. Returns a LiberFi JWT; stored in ~/.liberfi/session.json.

Token refresh:

  • Proactive: if the JWT expires in < 60 s, the CLI re-signs a new timestamp and calls POST /v1/auth/key.
  • Reactive: on any 401 response, the CLI attempts one automatic refresh before propagating the error.

Mode 2 — Email OTP Login (for human users)

Two steps: send OTP, then verify.

Step 1 — Send OTP:

lfi login user@example.com --json

Expected output:

{
  "ok": true,
  "otpId": "uuid-here",
  "message": "Verification code sent to user@example.com. It expires in 5 minutes."
}

Step 2 — Verify OTP:

lfi verify <otpId> <6-digit-code> --json

Expected output:

{
  "ok": true,
  "userId": "...",
  "role": "HUMAN",
  "evmAddress": "0x...",
  "solAddress": "...",
  "isNewUser": true,
  "message": "Email verified. Authenticated as ..."
}

Notes:

  • OTP expires in 5 minutes.
  • After verification, the locally generated P-256 key pair is saved as the permanent identity for session auto-refresh.
  • Subsequent refreshes work identically to key-based login (no additional email OTPs needed).

Commands

lfi status --json

Shows current authentication state without a network call.

{
  "ok": true,
  "authenticated": true,
  "userId": "...",
  "role": "HUMAN",
  "evmAddress": "0x...",
  "solAddress": "...",
  "expiresInSecs": 82340,
  "expired": false
}

lfi whoami --json

Fetches the current user's profile from the server (requires valid token).

{
  "userId": "...",
  "role": "HUMAN",
  "displayName": "",
  "email": "user@example.com",
  "evmAddress": "0x...",
  "solAddress": "..."
}

lfi logout --json

Clears ~/.liberfi/session.json. The JWT is not revoked server-side.


Pre-flight: Authentication Bootstrap

Run this sequence at the start of any operation that requires authentication:

# 1. Connectivity
lfi ping --json

# 2. Check session state
lfi status --json

Decision tree based on lfi status output:

authenticatedexpiredAction
------------------------------------
truefalseProceed — session is valid
truetrueRe-authenticate (token expired)
falseanyAuthenticate (no session)

Agent environment (automated):

lfi login key --role AGENT --name "AgentName" --json
lfi whoami --json

Human user (interactive):

lfi login user@example.com --json
# → prompt user to enter the 6-digit OTP code
lfi verify <otpId> <otp> --json
lfi whoami --json

Session Files

FileContents
----------------
~/.liberfi/session.jsonJWT, wallet addresses, key material for refresh
~/.liberfi/keys/default.jsonP-256 key pair (permanent identity)
~/.liberfi/keys/otp-pending.jsonTemporary key pair during email OTP flow

These files are created with mode 0600 (owner read/write only).

Never share or transmit these files.


Wallet Assignment

After authentication, the user is assigned two server-owned TEE wallets:

WalletFieldDescription
----------------------------
EVMevmAddressEthereum-compatible wallet (used for EVM swap operations)
SolanasolAddressSolana wallet (used for SVM swap operations)

These wallets are managed by LiberFi's backend.

The user's local P-256 private key is never used for on-chain signing.


Website Integration

Users who log in via the LiberFi website (social login) can exchange

their identity token for a LiberFi JWT using:

POST /v1/auth/exchange
{ "identityToken": "<identity-token>" }

This is handled transparently by the website's auth handler — CLI users do not

need to interact with this endpoint.


Error Handling

ErrorMeaningRecovery
--------------------------
"signature verification failed"Invalid key or tampered timestampRe-generate key pair with lfi login key
"timestamp is outside the ±300s window"System clock skewSync system clock
"OTP expired or not found"OTP TTL elapsed (5 min)Re-run lfi login
"incorrect OTP code"Wrong 6-digit codeRe-enter code or re-run lfi login
"invalid or expired token" on /auth/meJWT expired, refresh failedRe-authenticate
401 on swap/tx commandsSession expiredRun lfi status then re-authenticate

Security Notes

See security-policy.md for global rules.

Skill-specific rules:

  • The P-256 private key (~/.liberfi/keys/default.json) must be kept secret.

Never log, display, or transmit its contents.

  • The session file contains key material for refresh — treat it with the same

sensitivity as a private key.

  • OTP codes are single-use and expire in 5 minutes — do not store or reuse them.
  • LiberFi JWTs expire after 24 hours. Long-running agents should ensure

ensureSession() is called before each API request.

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-05-07 05:38 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

professional

Liberfi Predict

bombmod
浏览和交易预测市场:筛选和搜索活动列表,查看活动详情和嵌入市场,查看Kalshi和Polyma上的USDC余额...
★ 0 📥 454
business-ops

Discord

steipete
当需要通过discord工具控制Discord时使用:发送消息、添加反应、发布或上传表情包、上传表情、创建投票、管理帖子/置顶/搜索、获取权限或成员/角色/频道信息,或在Discord私信或频道中处理管理操作。
★ 79 📥 38,085
business-ops

Trello

steipete
使用 Trello REST API 管理看板、列表和卡片
★ 162 📥 41,324