insforge-integrations
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseInsForge Integrations
InsForge 集成
This skill covers integrating third-party providers with InsForge. Currently two categories are supported: auth providers (RLS via JWT claims) and payment facilitators (x402 HTTP payment protocol). Each provider has its own guide under this directory.
本Skill涵盖将第三方提供商与InsForge集成的内容。目前支持两类提供商:认证提供商(通过JWT声明实现RLS)和支付服务商(x402 HTTP支付协议)。每个提供商在本目录下都有对应的指南。
Auth Providers
认证提供商
| Provider | Guide | When to use |
|---|---|---|
| Clerk | Clerk JWT Templates + InsForge RLS | Clerk signs tokens directly via JWT Template — no server-side signing needed |
| Auth0 | Auth0 Actions + InsForge RLS | Auth0 uses a post-login Action to embed claims into the access token |
| WorkOS | WorkOS AuthKit + InsForge RLS | WorkOS AuthKit middleware + server-side JWT signing with |
| Kinde | Kinde + InsForge RLS | Kinde token customization for InsForge integration |
| Stytch | Stytch + InsForge RLS | Stytch session tokens for InsForge integration |
| 提供商 | 指南 | 使用场景 |
|---|---|---|
| Clerk | Clerk JWT 模板 + InsForge RLS | Clerk通过JWT模板直接签署令牌——无需服务端签署 |
| Auth0 | Auth0 Actions + InsForge RLS | Auth0使用登录后Action将声明嵌入访问令牌 |
| WorkOS | WorkOS AuthKit + InsForge RLS | WorkOS AuthKit中间件 + 使用 |
| Kinde | Kinde + InsForge RLS | 针对InsForge集成的Kinde令牌自定义 |
| Stytch | Stytch + InsForge RLS | 用于InsForge集成的Stytch会话令牌 |
Payment Facilitators
支付服务商
| Provider | Guide | When to use |
|---|---|---|
| OKX x402 | OKX as x402 facilitator (USDG on X Layer) | Pay-per-use HTTP endpoints settled onchain with zero gas for the payer |
| 提供商 | 指南 | 使用场景 |
|---|---|---|
| OKX x402 | OKX 作为x402服务商(X Layer上的USDG) | 链上按使用付费的HTTP端点,付款方无需支付Gas费 |
Common Patterns
通用模式
Auth providers
认证提供商
- Provider signs or issues a JWT containing the user's ID
- JWT is passed to InsForge via in
edgeFunctionTokencreateClient() - InsForge extracts claims via in SQL
request.jwt.claims - RLS policies use a function to enforce row-level security
requesting_user_id()
- 提供商签署或颁发包含用户ID的JWT
- 通过中的
createClient()将JWT传递给InsForgeedgeFunctionToken - InsForge通过SQL中的提取声明
request.jwt.claims - RLS策略使用函数强制执行行级安全
requesting_user_id()
Payment facilitators (x402)
支付服务商(x402)
- Server returns with a JSON challenge base64-encoded in
402 Payment RequiredheaderPAYMENT-REQUIRED - Client signs an EIP-3009 authorization using the stablecoin's EIP-712 domain
- Server forwards the signed payload to the facilitator's +
/verifyendpoints/settle - Server records the settled payment in an InsForge table with a realtime trigger for live dashboards
- 服务端返回响应,其中JSON挑战以Base64编码形式放在
402 Payment Required请求头中PAYMENT-REQUIRED - 客户端使用稳定币的EIP-712域签署EIP-3009授权
- 服务端将签署后的负载转发至服务商的和
/verify端点/settle - 服务端将已结算的支付记录到InsForge表中,并通过实时触发器更新实时仪表盘
Choosing a Provider
提供商选择
Auth
- Clerk — Simplest setup; JWT Template handles signing, no server code needed
- Auth0 — Flexible; uses post-login Actions for claim injection
- WorkOS — Enterprise-focused; AuthKit middleware + server-side JWT signing
- Kinde — Developer-friendly; built-in token customization
- Stytch — API-first; session-based token flow
Payment facilitators
- OKX x402 — Onchain pay-per-use via USDG on X Layer; zero gas for the payer
认证
- Clerk — 设置最简单;JWT模板处理签署,无需服务端代码
- Auth0 — 灵活性高;使用登录后Action注入声明
- WorkOS — 面向企业;AuthKit中间件 + 服务端JWT签署
- Kinde — 开发者友好;内置令牌自定义功能
- Stytch — API优先;基于会话的令牌流程
支付服务商
- OKX x402 — 通过X Layer上的USDG实现链上按使用付费;付款方无需支付Gas费
Setup
设置步骤
- Identify which provider the project uses
- Read the corresponding reference guide from the tables above
- Follow the provider-specific setup steps
- 确定项目使用的提供商
- 阅读上表中对应的参考指南
- 遵循提供商专属的设置步骤
Usage Examples
使用示例
Each provider guide includes full code examples for:
- Provider dashboard configuration (API keys, application settings, etc.)
- Server and client code (JWT utilities for auth; facilitator client + signing utilities for payments)
- Database setup (RLS for auth; payment table + realtime trigger for payments)
- Environment variable setup
Refer to the specific file for complete examples.
references/<provider>.md每个提供商指南都包含完整的代码示例,涵盖:
- 提供商仪表盘配置(API密钥、应用设置等)
- 服务端和客户端代码(认证用的JWT工具;支付用的服务商客户端 + 签署工具)
- 数据库设置(认证用的RLS;支付用的支付表 + 实时触发器)
- 环境变量设置
请参考具体的文件获取完整示例。
references/<provider>.mdBest Practices
最佳实践
Auth
- All auth provider user IDs are strings (not UUIDs) — always use columns for
TEXTuser_id - Use instead of
requesting_user_id()for RLS policiesauth.uid() - Set as an async function (Clerk) or server-signed JWT (Auth0, WorkOS, Kinde, Stytch)
edgeFunctionToken - Always get the JWT secret via
npx @insforge/cli secrets get JWT_SECRET
Payment facilitators (x402)
- Always check the result of the database after settlement — settlement takes money onchain before the insert runs; a silent DB failure loses the record
insert(...) - Add to the
UNIQUEcolumn to prevent duplicate records from retriestx_hash - Verify EIP-712 domain (,
name) against the token contract's on-chainversion— wrong values produceDOMAIN_SEPARATORerrorsInvalid Authority - Use a env flag for local dev so the full flow can be exercised without real funds
MOCK_OKX_FACILITATOR
认证
- 所有认证提供商的用户ID均为字符串(非UUID)——列请始终使用
user_id类型TEXT - RLS策略中使用而非
requesting_user_id()auth.uid() - 将设置为异步函数(Clerk)或服务端签署的JWT(Auth0、WorkOS、Kinde、Stytch)
edgeFunctionToken - 始终通过获取JWT密钥
npx @insforge/cli secrets get JWT_SECRET
支付服务商(x402)
- 结算完成后务必检查数据库的结果——结算会先在链上扣款,再执行插入操作;若数据库静默失败会丢失记录
insert(...) - 为列添加
tx_hash约束,防止重试产生重复记录UNIQUE - 验证EIP-712域(、
name)与令牌合约链上的version是否一致——错误值会导致DOMAIN_SEPARATOR错误Invalid Authority - 本地开发时使用环境变量,这样无需真实资金即可测试完整流程
MOCK_OKX_FACILITATOR
Common Mistakes
常见错误
Auth
| Mistake | Solution |
|---|---|
Using | Use |
Using UUID columns for | Use |
| Hardcoding the JWT secret | Always retrieve via |
Missing | Must be created before RLS policies will work |
Payments (x402)
| Mistake | Solution |
|---|---|
| Using an OKX exchange trading API key | Create a separate Web3 API key at |
| Wrong EIP-712 domain values | Read the token contract's |
| Ignoring DB insert error after settlement | Always destructure |
| Mock mode is demo-only; it returns fake tx hashes and bypasses verification |
认证
| 错误 | 解决方案 |
|---|---|
RLS中使用 | 使用 |
| 使用 |
| 硬编码JWT密钥 | 始终通过 |
缺少 | 必须先创建该函数,RLS策略才能生效 |
支付(x402)
| 错误 | 解决方案 |
|---|---|
| 使用OKX交易所交易API密钥 | 在 |
| EIP-712域值错误 | 读取令牌合约的 |
| 忽略结算后的数据库插入错误 | 务必解构 |
生产环境中设置 | 模拟模式仅用于演示;它会返回虚假交易哈希并跳过验证 |