|
| 1 | +--- |
| 2 | +name: CloudBase Auth |
| 3 | +description: A single skill that helps design and implement CloudBase Auth v2 using Web SDK, Node SDK, and HTTP APIs, including login methods, tokens, and best practices. |
| 4 | +--- |
| 5 | + |
| 6 | +## When to use this skill |
| 7 | + |
| 8 | +Use this skill whenever the task involves **authentication or user identity** in a CloudBase project, for example: |
| 9 | + |
| 10 | +- Designing which login methods to support (anonymous, username/password, SMS, email, WeChat, custom login) |
| 11 | +- Implementing auth with **Web SDK** (`@cloudbase/js-sdk@2.x`) on the frontend |
| 12 | +- Working with **Node SDK** for user info, admin operations, or issuing **custom login tickets** |
| 13 | +- Calling **HTTP auth APIs** directly from any backend or script |
| 14 | +- Understanding tokens, login state, and auth-related best practices |
| 15 | + |
| 16 | +If the task is not about authentication (e.g. only about database or storage), this skill is probably not needed. |
| 17 | + |
| 18 | +## Quick orientation |
| 19 | + |
| 20 | +CloudBase Auth v2 provides: |
| 21 | + |
| 22 | +- Multiple **login methods** with a unified user identity system |
| 23 | +- Clear **user types** (internal, external, anonymous) and account linking |
| 24 | +- A token-based **session model** with JWT access tokens and refresh tokens |
| 25 | +- SDKs (Web, Node) and **HTTP APIs** that expose the same core flows |
| 26 | + |
| 27 | +This `SKILL.md` acts as a **launcher**. For deeper details, read the linked files only as needed. |
| 28 | + |
| 29 | +## Table of contents (progressive disclosure) |
| 30 | + |
| 31 | +### 1. Concepts & design |
| 32 | + |
| 33 | +- `concepts/overview.md` – what CloudBase Auth v2 is, high-level architecture, and where to configure it. |
| 34 | +- `concepts/login_methods.md` – supported login methods, when to use each, and tradeoffs. |
| 35 | +- `concepts/user_accounts_and_roles.md` – internal vs external vs anonymous users, UIDs, and multi-account linking. |
| 36 | +- `concepts/tokens_and_sessions.md` – access_token vs refresh_token, v1 vs v2, and validation. |
| 37 | + |
| 38 | +### 2. Web SDK (`@cloudbase/js-sdk@2.x`) |
| 39 | + |
| 40 | +- `web-sdk/web_quickstart.md` – install/init SDK, get `auth` instance, basic sign-up/sign-in flow. |
| 41 | +- `web-sdk/web_login_flows.md` – concrete flows for: |
| 42 | + - Username/password |
| 43 | + - SMS verification code login |
| 44 | + - Email verification code login |
| 45 | + - Anonymous login and upgrade |
| 46 | + - WeChat OAuth login |
| 47 | +- `web-sdk/captcha_and_rate_limits.md` – when captchas are triggered, how to integrate the captcha adapter + UI, and how to handle errors. |
| 48 | +- `web-sdk/web_best_practices.md` – avoiding redundant logins, login-state persistence, and common UX patterns. |
| 49 | + |
| 50 | +### 3. Node SDK & custom login |
| 51 | + |
| 52 | +- `node-sdk/node_overview_and_user_info.md` – using the Node SDK to get user info, end-user info, query users, and read client IP. |
| 53 | +- `node-sdk/node_custom_login_ticket.md` – issuing custom login tickets on the server and integrating with your own user system. |
| 54 | + |
| 55 | +### 4. HTTP APIs |
| 56 | + |
| 57 | +- `http-api/http_overview.md` – the HTTP API surface for auth and how to discover endpoints. |
| 58 | +- `http-api/http_login_and_token_flows.md` – high-level flows for sign-in, sign-up, anonymous login, token grant/refresh/revoke, and user operations over HTTP. |
| 59 | + |
| 60 | +### 5. Troubleshooting & FAQ |
| 61 | + |
| 62 | +- `troubleshooting/faq.md` – common questions and pitfalls: anonymous vs unauthenticated, token expiry, verification limits, etc. |
| 63 | + |
| 64 | +## How to use this skill |
| 65 | + |
| 66 | +When working on a CloudBase auth task, follow this sequence: |
| 67 | + |
| 68 | +1. **Clarify the scenario** |
| 69 | + - Is this **frontend Web**, **Node backend/cloud function**, or a generic backend calling **HTTP APIs**? |
| 70 | + - What login methods are required (e.g. phone, email, WeChat, custom SSO, anonymous trial)? |
| 71 | + - Are there existing users/identity systems that must be integrated? |
| 72 | + |
| 73 | +2. **Load only the relevant conceptual context** |
| 74 | + - For high-level decisions, read: |
| 75 | + - `concepts/overview.md` |
| 76 | + - `concepts/login_methods.md` |
| 77 | + - `concepts/user_accounts_and_roles.md` |
| 78 | + - Read `concepts/tokens_and_sessions.md` only if token behavior or migration is important to the task. |
| 79 | + |
| 80 | +3. **Jump to the relevant implementation section** |
| 81 | + - For **Web** implementation details, read `web-sdk/web_quickstart.md` and then the specific flow file (e.g. `web-sdk/web_login_flows.md`, `web-sdk/captcha_and_rate_limits.md`). |
| 82 | + - For **Node/server** logic or custom login ticket issuance, use the `node-sdk/` files. |
| 83 | + - For **language-agnostic HTTP integration**, use the `http-api/` files. |
| 84 | + |
| 85 | +4. **Design first, then code** |
| 86 | + - Use the conceptual files to pick login methods, user types, and token strategy. |
| 87 | + - Then use Web/Node/HTTP sections to implement and verify the flow end-to-end. |
| 88 | + |
| 89 | +5. **Use troubleshooting only when needed** |
| 90 | + - Only read `troubleshooting/faq.md` when the user has issues like “anonymous vs not logged in”, unexpected expiration, or captcha errors. |
| 91 | + |
| 92 | +Keep this file short in context. Load deeper files selectively based on the user’s question to keep the context window efficient. |
0 commit comments