tiun-sdk
tiun SDK skill
Use this skill whenever the user is integrating, extending, or debugging code that uses @tiun/sdk. Authoritative upstream docs: https://docs.tiun.io/llms-full.txt.
What tiun is
A commercial backend platform providing authentication, payments, and entitlements through a single JS SDK. The tiun singleton supports three flows; you pick based on the integrator's intent (see "Step 0 — Discovery before code"):
- Subscriptions — persistent user accounts (OTP login), recurring billing, per-product entitlements in
user.productAccess[]. Entry point:tiun.checkout({ productId }). See references/subscriptions.md. - One-time purchases — same accounts and same entry point as subscriptions, but a single fixed fee and permanent entitlement: no interval, no trial, no renewal, no expiry. Entry point:
tiun.checkout({ productId }). See references/one-time.md. - Time-based — per-session anonymous access (no account required), metered by time spent on paid content. Entry point:
tiun.start()+paywallShow/paywallHideevents. See references/time-based.md.
Install: npm install @tiun/sdk. Init: tiun.init({ snippetId, language: 'en' }) on app start (idempotent).
tiun runs live and sandbox as two independent parallel environments. The SDK's sandbox flag selects which one — see references/installation.md.
Step 0 — Discovery before code
Before writing any integration code, establish four things. Ask only for items the user has not already stated. If their prompt is fully specified ("wire up subscription with product p-test-pro in sandbox to gate /watch/*"), skip discovery.