insforge-integrations

โดย insforge

ใช้เมื่อเชื่อมต่อผู้ให้บริการยืนยันตัวตนภายนอก (Clerk, Auth0, WorkOS, Kinde, Stytch, Better Auth) เข้ากับ InsForge สำหรับ RLS ที่ใช้ JWT หรือเมื่อเพิ่มตัวประมวลผลการชำระเงิน OKX x402 สำหรับการเรียกเก็บเงินแบบจ่ายต่อการใช้งานบนเชน

npx skills add https://github.com/insforge/insforge-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

Skills เพิ่มเติมจาก insforge

insforge-debug
insforge
ใช้เมื่อวินิจฉัยปัญหาในโปรเจกต์ InsForge — ความล้มเหลวแบบรับรู้เหตุการณ์ (SDK error object, HTTP 4xx/5xx, gateway timeout 502/503/504, edge function ล้มเหลวหรือหมดเวลา, ข้อผิดพลาดการเข้าสู่ระบบ/OAuth/auth, การปฏิเสธ RLS, ปัญหาช่องทาง realtime, คิวรีช้าที่ปลายทางเดียว, edge function หรือการปรับใช้ Vercel ล้มเหลว), การตรวจสอบเชิงรุก (การตรวจสอบความปลอดภัย/RLS, การตรวจสอบประสิทธิภาพ/ดัชนี, การตรวจสอบสุขภาพระบบ, ความพร้อมก่อนเปิดตัว), หรือเมื่อผู้ใช้มีข้อผิดพลาดแต่ไม่รู้จะเริ่มต้นที่ไหน
insforge
insforge
ใช้สกิลนี้เมื่อเขียนโค้ดแอปด้วย InsForge หรือ @insforge/sdk: การทำ CRUD ฐานข้อมูล, การยืนยันตัวตน, การอัปโหลดพื้นที่จัดเก็บ/RLS พื้นที่จัดเก็บ, ฟังก์ชัน, OpenRouter AI, realtime, อีเมล, การชำระเงิน Stripe หรือ Razorpay, หรือการชี้เครื่องมือที่เข้ากันได้กับ S3 (aws CLI, AWS SDKs, rclone, Terraform, boto3) ไปที่ InsForge Storage เรียกใช้เมื่อมีคำขอเช่น เพิ่มการยืนยันตัวตน, ดึงข้อมูล, อัปโหลดไฟล์, ทำให้บัคเก็ตเป็นสาธารณะ, เพิ่มการชำระเงิน, ขายการสมัครสมาชิก, หรือส่งอีเมล สำหรับโครงสร้างพื้นฐาน, การย้ายฐานข้อมูล SQL, คำสั่ง CLI, หรือผู้ให้บริการชำระเงิน...
developmentdatabaseaws
insforge-cli
insforge
ใช้ทักษะนี้เมื่อมีคนต้องการแบ็กเอนด์ หรืองานที่เกี่ยวข้องกับแบ็กเอนด์หรือโครงสร้างพื้นฐานคลาวด์ของ InsForge ผ่าน InsForge CLI: โปรเจกต์, SQL, การย้ายข้อมูล, นโยบาย RLS, ฟังก์ชัน, พื้นที่จัดเก็บ, การปรับใช้, คอมพิวต์, ความลับ, การกำหนดค่า, ตารางเวลา, บันทึก, การวินิจฉัย, การนำเข้า/ส่งออก, การตั้งค่า AI/OpenRouter, การชำระเงิน Stripe/Razorpay, การขูดเว็บ Apify / แหล่งข้อมูล, การวิเคราะห์ผลิตภัณฑ์ PostHog, สาขาแบ็กเอนด์, หน่วยความจำเอเจนต์ (จดจำ/เรียกคืนข้อเท็จจริงและการตัดสินใจของโปรเจกต์), หรือเอกสาร CLI สำหรับโค้ดแอปพลิเคชันด้วย...
developmentdatabasedevops
insforge-integrations
insforge
ใช้เมื่อเชื่อมต่อผู้ให้บริการยืนยันตัวตนภายนอก (Clerk, Auth0, WorkOS, Kinde, Stytch, Better Auth) เข้ากับ InsForge สำหรับ JWT-based RLS หรือเมื่อเพิ่มตัวช่วยชำระเงิน OKX x402 สำหรับการเรียกเก็บเงินแบบจ่ายตามการใช้งานบนเชน
insforge-debug
insforge
ใช้เมื่อวินิจฉัยปัญหาในโปรเจกต์ InsForge — ความล้มเหลวแบบรีแอกทีฟ (ออบเจกต์ข้อผิดพลาด SDK, HTTP 4xx/5xx, เกตเวย์ไทม์เอาต์ 502/503/504, ความล้มเหลวหรือไทม์เอาต์ของ edge function, ข้อผิดพลาดการเข้าสู่ระบบ/OAuth/auth, การปฏิเสธ RLS, ปัญหาช่องทางเรียลไทม์, คิวรีช้าบนเอนด์พอยต์เดียว, ความล้มเหลวในการดีพลอย์ edge function หรือ Vercel), การตรวจสอบเชิงรุก (การตรวจสอบความปลอดภัย/RLS, การตรวจสอบประสิทธิภาพ/ดัชนี, การตรวจสอบสุขภาพระบบ, ความพร้อมก่อนเปิดตัว) หรือเมื่อผู้ใช้มีข้อผิดพลาดแต่ไม่รู้จะเริ่มจากตรงไหน
insforge-cli
insforge
ใช้สกิลนี้เมื่อใดก็ตามที่ต้องการแบ็กเอนด์ หรืองานที่เกี่ยวข้องกับแบ็กเอนด์หรือโครงสร้างพื้นฐานคลาวด์ของ InsForge ผ่าน InsForge CLI: โปรเจกต์, SQL, การย้ายข้อมูล, นโยบาย RLS, ฟังก์ชัน, พื้นที่จัดเก็บ, การสำรองข้อมูล, การปรับใช้, คอมพิวต์, ความลับ, การกำหนดค่า, ตารางเวลา, ระบบบันทึก, การวินิจฉัย, การสแกนและระงับคำแนะนำ, การนำเข้า/ส่งออก, การตั้งค่าและภาพรวมการใช้งาน AI/OpenRouter, การชำระเงิน Stripe/Razorpay, การขูดเว็บ Apify / แหล่งข้อมูล, การวิเคราะห์ผลิตภัณฑ์ PostHog, สาขาแบ็กเอนด์, การเป็นสมาชิกองค์กร...
insforge
insforge
ใช้สกิลนี้เมื่อเขียนโค้ดแอปด้วย InsForge หรือ @insforge/sdk: การทำ CRUD ฐานข้อมูล, การยืนยันตัวตน, การอัปโหลดพื้นที่จัดเก็บ/RLS พื้นที่จัดเก็บ, ฟังก์ชัน, OpenRouter AI, realtime, อีเมล, การชำระเงิน Stripe หรือ Razorpay, หรือการชี้เครื่องมือที่เข้ากันได้กับ S3 (aws CLI, AWS SDKs, rclone, Terraform, boto3) ไปที่ InsForge Storage เรียกใช้เมื่อมีคำขอเช่น เพิ่มการยืนยันตัวตน, ดึงข้อมูล, อัปโหลดไฟล์, ทำให้บัคเก็ตเป็นสาธารณะ, เพิ่มการชำระเงิน, ขายการสมัครสมาชิก, หรือส่งอีเมล สำหรับโครงสร้างพื้นฐาน, การย้ายฐานข้อมูล SQL, คำสั่ง CLI, หรือผู้ให้บริการชำระเงิน...