insforge-integrations

作者: insforge

在將外部驗證提供者(Clerk、Auth0、WorkOS、Kinde、Stytch、Better Auth)接入 InsForge 以實現基於 JWT 的 RLS 時使用,或是在新增 OKX x402 支付中介以實現鏈上按用量計費時使用。

npx skills add https://github.com/insforge/agent-skills --skill insforge-integrations

InsForge Integrations

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.

Auth Providers

ProviderGuideWhen to use
ClerkClerk JWT Templates + InsForge RLSClerk signs tokens directly via JWT Template — no server-side signing needed
Auth0Auth0 Actions + InsForge RLSAuth0 uses a post-login Action to embed claims into the access token
WorkOSWorkOS AuthKit + InsForge RLSWorkOS AuthKit middleware + server-side JWT signing with jsonwebtoken
KindeKinde + InsForge RLSKinde token customization for InsForge integration
StytchStytch + InsForge RLSStytch session tokens for InsForge integration
Better AuthBetter Auth + InsForge RLSSelf-hosted auth running in your InsForge Postgres — no third-party SaaS, no per-MAU cost

Payment Facilitators

ProviderGuideWhen to use
OKX x402OKX as x402 facilitator (USDG on X Layer)Pay-per-use HTTP endpoints settled onchain with zero gas for the payer

Common Patterns

Auth providers

  1. Provider signs or issues a JWT containing the user's ID
  2. JWT is passed to InsForge via accessToken in createClient() (deprecated alias: edgeFunctionToken)
  3. InsForge exposes claims through auth.jwt() in SQL
  4. RLS policies use a requesting_user_id() function to enforce row-level security

Payment facilitators (x402)

  1. Server returns 402 Payment Required with a JSON challenge base64-encoded in PAYMENT-REQUIRED header
  2. Client signs an EIP-3009 authorization using the stablecoin's EIP-712 domain
  3. Server forwards the signed payload to the facilitator's /verify + /settle endpoints
  4. Server records the settled payment in an InsForge table with a realtime trigger for live dashboards

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
  • Better Auth — Self-hosted in your Postgres; no SaaS vendor; you own the user table. Pairs cleanly with InsForge's Postgres via a connection string + a small bridge route. Requires a one-time REVOKE after migrate to seal PostgREST exposure.

Payment facilitators

  • OKX x402 — Onchain pay-per-use via USDG on X Layer; zero gas for the payer

Setup

  1. Identify which provider the project uses
  2. Read the corresponding reference guide from the tables above
  3. 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 references/<provider>.md file for complete examples.

Best Practices

Auth

  • All auth provider user IDs are strings (not UUIDs) — always use TEXT columns for user_id
  • Use requesting_user_id() instead of auth.uid() for RLS policies
  • Pass the JWT via accessToken — a static string, not a function; for short-lived tokens (Clerk) sync refreshes with client.setAccessToken(token, AuthChangeEvent.TOKEN_REFRESHED) after the initial same-user sign-in
  • Always get the JWT secret via npx -y @insforge/cli secrets get JWT_SECRET

Payment facilitators (x402)

  • Always check the result of the database insert(...) after settlement — settlement takes money onchain before the insert runs; a silent DB failure loses the record
  • Add UNIQUE to the tx_hash column to prevent duplicate records from retries
  • Verify EIP-712 domain (name, version) against the token contract's on-chain DOMAIN_SEPARATOR — wrong values produce Invalid Authority errors
  • Use a MOCK_OKX_FACILITATOR env flag for local dev so the full flow can be exercised without real funds

Common Mistakes

Auth

MistakeSolution
Using auth.uid() for RLSUse requesting_user_id() — third-party IDs are strings, not UUIDs
Using UUID columns for user_idUse TEXT — all supported providers use string-format IDs
Hardcoding the JWT secretAlways retrieve via npx -y @insforge/cli secrets get JWT_SECRET
Missing requesting_user_id() functionMust be created before RLS policies will work

Payments (x402)

MistakeSolution
Using an OKX exchange trading API keyCreate a separate Web3 API key at web3.okx.com/onchainos/dev-portal
Wrong EIP-712 domain valuesRead the token contract's DOMAIN_SEPARATOR — for USDG on X Layer use name: "Global Dollar", version: "1"
Ignoring DB insert error after settlementAlways destructure { error } and log/handle it — money has already moved
MOCK_OKX_FACILITATOR=true in productionMock mode is demo-only; it returns fake tx hashes and bypasses verification

來自 insforge 的更多技能

insforge-debug
insforge
在 InsForge 專案中診斷問題時使用 — 反應式故障(SDK 錯誤物件、HTTP 4xx/5xx、閘道逾時 502/503/504、邊緣函式失敗或逾時、登入/OAuth/驗證錯誤、RLS 拒絕、即時通道問題、單一端點查詢緩慢、邊緣函式或 Vercel 部署失敗)、主動式稽核(安全性/RLS 審查、效能/索引審查、系統健康檢查、上線前準備),或當使用者遇到錯誤但不知從何著手時。
insforge
insforge
在撰寫 InsForge 或 @insforge/sdk 的應用程式碼時使用此技能:資料庫 CRUD、驗證、儲存上傳/儲存 RLS、函式、OpenRouter AI、即時功能、電子郵件、Stripe 或 Razorpay 付款,或將 S3 相容工具(aws CLI、AWS SDK、rclone、Terraform、boto3)指向 InsForge Storage。觸發於如新增驗證、擷取資料、上傳檔案、將儲存桶設為公開、新增結帳、銷售訂閱或傳送電子郵件等請求。針對基礎設施、SQL 遷移、CLI 指令或付款供應商...
developmentdatabaseaws
insforge-cli
insforge
每當有人需要後端,或任務涉及透過 InsForge CLI 操作 InsForge 後端或雲端基礎設施時,使用此技能:專案、SQL、遷移、RLS 政策、函式、儲存、部署、運算、密鑰、設定、排程、日誌、診斷、匯入/匯出、AI/OpenRouter 設定、Stripe/Razorpay 付款、Apify 網頁爬取/資料來源、PostHog 產品分析、後端分支、代理記憶(記住/回顧專案事實與決策),或 CLI 文件。若涉及應用程式碼...
developmentdatabasedevops
insforge-debug
insforge
用於診斷 InsForge 專案中的問題時使用 — 反應式故障(SDK 錯誤物件、HTTP 4xx/5xx、閘道逾時 502/503/504、邊緣函式失敗或逾時、登入/OAuth/驗證錯誤、RLS 拒絕、即時通道問題、單一端點查詢緩慢、邊緣函式或 Vercel 部署失敗)、主動式稽核(安全性/RLS 審查、效能/索引審查、系統健康檢查、上線前準備),或當使用者遇到錯誤但不知從何開始時。
insforge-cli
insforge
每當有人需要後端,或任務涉及透過 InsForge CLI 操作 InsForge 後端或雲端基礎設施時,請使用此技能:專案、SQL、遷移、RLS 政策、函式、儲存、備份、部署、運算、密鑰、設定、排程、日誌、診斷、顧問掃描與抑制、匯入/匯出、AI/OpenRouter 設定與使用概覽、Stripe/Razorpay 付款、Apify 網頁爬取/資料來源、PostHog 產品分析、後端分支、組織成員資格……
insforge
insforge
使用此技能編寫InsForge或@insforge/sdk的應用程式碼時:資料庫CRUD、認證、儲存上傳/儲存RLS、函式、OpenRouter AI、即時功能、電子郵件、Stripe或Razorpay付款,或將S3相容工具(aws CLI、AWS SDKs、rclone、Terraform、boto3)指向InsForge Storage。在遇到新增認證、擷取資料、上傳檔案、將儲存桶設為公開、新增結帳、銷售訂閱或傳送電子郵件等請求時觸發。對於基礎設施、SQL遷移、CLI命令或付款供應商...
insforge-integrations
insforge
用於將外部認證提供者(Clerk、Auth0、WorkOS、Kinde、Stytch、Better Auth)接入 InsForge 以實現基於 JWT 的 RLS,或新增 OKX x402 支付促進器以進行鏈上按用量付費計費時使用。