@farcaster/quick-auth (英语)
与 Farcaster Quick Auth 服务器互动的客户端 .
安装
npm install @auth-server/client
# or
yarn add @auth-server/client
# or
pnpm add @auth-server/client
使用量
import { createClient } from '@farcaster/quick-auth';
// Get a nonce
const domain = 'your-domain.com';
const client = createClient();
const nonce = await client.getNonce();
// Generate a SIWF message using nonce and domain (not shown)
// Verify a SIWF message and get a JWT token
const token = await client.verifySiwf({
message,
signature,
domain
});
// Use the return JWT as an Bearer token and validate on your server
const token = await client.verifyToken({
token,
domain
});
升级到0.1.0
0.1.0 取决于Zod 4(zod@^4.6.6)取而代之为佐德 3. 客户端API和运行时间行为不变.
导出 Endpoints.VerifyJwt.requestQueryParametersSchema 现在是一个Zod 4计划。 如果你把它编成自己的计划 比如说 z.object({ query: Endpoints.VerifyJwt.requestQueryParametersSchema }),您的代码也必须使用 Zod 4. Zod 3 schemas不能包含Zod 4 schemas,在类型检查时间和剖析时间这样做失败. Zod 3.25+ 也为Zod 4号船 zod/v4,因此您可以一次迁移一个呼叫网站:
import { z } from 'zod/v4';
import { Endpoints } from '@farcaster/quick-auth';
const schema = z.object({ query: Endpoints.VerifyJwt.requestQueryParametersSchema });
如果你只使用 createClient(), (中文(简体) ), createLightClient() 或者说 decodeJwt(),不需要修改.