$npx -y skills add TencentCloudBase/cloudbase-skills --skill auth-nodejsCloudBase Node SDK auth guide for server-side identity, user lookup, and custom login tickets. This skill should be used when Node.js code must read caller identity, inspect end users, or bridge an existing user system into CloudBase; not when configuring providers or building cl
| 1 | ## Standalone Install Note |
| 2 | |
| 3 | If this environment only installed the current skill, start from the CloudBase main entry and use the published `cloudbase/references/...` paths for sibling skills. |
| 4 | |
| 5 | - CloudBase main entry: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/SKILL.md` |
| 6 | - Current skill raw source: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/auth-nodejs/SKILL.md` |
| 7 | |
| 8 | Keep local `references/...` paths for files that ship with the current skill directory. When this file points to a sibling skill such as `auth-tool` or `web-development`, use the standalone fallback URL shown next to that reference. |
| 9 | |
| 10 | ## Activation Contract |
| 11 | |
| 12 | ### Use this first when |
| 13 | |
| 14 | - Node.js code in cloud functions or backend services must read caller identity, look up users, or issue custom login tickets. |
| 15 | - The backend responsibility is auth / identity, not provider setup or frontend login UI. |
| 16 | |
| 17 | ### Read before writing code if |
| 18 | |
| 19 | - The task mentions `@cloudbase/node-sdk`, server-side auth, custom login tickets, or "who is calling". |
| 20 | - The request mixes frontend login with backend identity logic; split the flow and route client-side work elsewhere. |
| 21 | |
| 22 | ### Then also read |
| 23 | |
| 24 | - Provider setup / publishable key -> `../auth-tool/SKILL.md` (standalone fallback: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/auth-tool/SKILL.md`) |
| 25 | - Web login UI that consumes custom tickets -> `../auth-web/SKILL.md` (standalone fallback: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/auth-web/SKILL.md`) |
| 26 | - Raw HTTP auth client -> `../http-api/SKILL.md` (standalone fallback: `https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/http-api/SKILL.md`) |
| 27 | |
| 28 | ### Do NOT use for |
| 29 | |
| 30 | - Provider enable/disable or login console configuration. |
| 31 | - Frontend login / sign-up UI. |
| 32 | - Mini program native auth. |
| 33 | |
| 34 | ### Common mistakes / gotchas |
| 35 | |
| 36 | - Using this skill as the entry point for every auth request. |
| 37 | - Mixing provider-management work with Node-side identity code. |
| 38 | - Reaching for raw HTTP examples when Node SDK already covers the job. |
| 39 | |
| 40 | ## When to use this skill |
| 41 | |
| 42 | Use this skill whenever the task involves **server-side authentication or identity** in a CloudBase project, and the code is running in **Node.js**, for example: |
| 43 | |
| 44 | - CloudBase 云函数 (Node runtime) that needs to know **who is calling** |
| 45 | - Node services that use **CloudBase Node SDK** to look up user information |
| 46 | - Backends that issue **custom login tickets** for Web / mobile clients |
| 47 | - Admin or ops tools that need to inspect CloudBase end-user profiles |
| 48 | |
| 49 | **Do NOT use this skill for:** |
| 50 | |
| 51 | - Frontend Web login / sign-up flows using `@cloudbase/js-sdk` (handle those with the **auth-web** skill, not this Node skill). |
| 52 | - Direct HTTP auth API integrations (this skill does not describe raw HTTP endpoints; use the **http-api** skill instead). |
| 53 | - Database or storage operations that do not involve identity (use database/storage docs or skills). |
| 54 | |
| 55 | When the user request mixes frontend and backend concerns (e.g. "build a web login page and a Node API that knows the user"), treat them separately: |
| 56 | |
| 57 | - Use Web-side auth docs/skills for client login and UX. |
| 58 | - Use this Node Auth skill for how the backend sees and uses the authenticated user. |
| 59 | |
| 60 | --- |
| 61 | |
| 62 | ## How to use this skill (for a coding agent) |
| 63 | |
| 64 | When you load this skill to work on a task: |
| 65 | |
| 66 | 1. **Clarify the runtime and responsibility** |
| 67 | |
| 68 | Ask the user: |
| 69 | |
| 70 | - Where does this Node code run? |
| 71 | - CloudBase 云函数 |
| 72 | - Long‑running Node service using CloudBase |
| 73 | - What do they need from auth? |
| 74 | - Just the **caller identity** for authorization? |
| 75 | - **Look up arbitrary users** by UID / login identifier? |
| 76 | - **Bridge their own user system** into CloudBase via custom login? |
| 77 | |
| 78 | 2. **Confirm CloudBase environment and SDK** |
| 79 | |
| 80 | - Ask for: |
| 81 | - `env` – CloudBase environment ID |
| 82 | - Install the latest `@cloudbase/node-sdk` from npm if it is not already available. |
| 83 | - Always initialize the SDK using this pattern (values can change, shape must not): |
| 84 | |
| 85 | ```ts |
| 86 | import tcb from "@cloudbase/node-sdk"; |
| 87 | |
| 88 | const app = tcb.init({ env: "your-env-id" }); |
| 89 | const auth = app.auth(); |
| 90 | ``` |
| 91 | |
| 92 | 3. **Pick the relevant scenario from this file** |
| 93 | |
| 94 | - For **caller identity inside a function**, use the `getUserInfo` scenarios. |
| 95 | - For **full user profile or admin lookup**, use the `getEndUserInfo` and `queryUserInfo` scenarios. |
| 96 | - For **client systems that already have their own users**, use the **custom login ticket** |