Best for
- CloudBase 云函数 (Node runtime) that needs to know who is calling
- Node services that use CloudBase Node SDK to look up user information
- Backends that issue custom login tickets for Web / mobile clients
TencentCloudBase/CloudBase-AI-Toolkit/config/source/skills/auth-nodejs-cloudbase/SKILL.md
CloudBase 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 client login UI.
Decision brief
If this environment only installed the current skill, start from the CloudBase main entry and use the published cloudbase/references/... paths for sibling skills.
Compatibility matrix
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/TencentCloudBase/CloudBase-AI-Toolkit --skill "config/source/skills/auth-nodejs-cloudbase"Inspect the Agent Skill "auth-nodejs-cloudbase" from https://github.com/TencentCloudBase/CloudBase-AI-Toolkit/blob/1dddc898085c55ae616c3b0bf989b4b7b7797b35/config/source/skills/auth-nodejs-cloudbase/SKILL.md at commit 1dddc898085c55ae616c3b0bf989b4b7b7797b35. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
When you load this skill to work on a task:
If this environment only installed the current skill, start from the CloudBase main entry and use the published cloudbase/references/... paths for sibling skills.
Node.js code in cloud functions or backend services must read caller identity, look up users, or issue custom login tickets.
Node.js code in cloud functions or backend services must read caller identity, look up users, or issue custom login tickets.
The task mentions @cloudbase/node-sdk, server-side auth, custom login tickets, or "who is calling".
Permission review
No configured static risk pattern was detected
This is not proof of safety. Runtime behavior, indirect dependencies, and hidden external systems are outside the static scan.
Evidence record
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 95/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 1,066 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
If this environment only installed the current skill, start from the CloudBase main entry and use the published cloudbase/references/... paths for sibling skills.
https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/SKILL.mdhttps://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/auth-nodejs-cloudbase/SKILL.mdKeep local references/... paths for files that ship with the current skill directory. When this file points to a sibling skill such as auth-tool-cloudbase or web-development, use the standalone fallback URL shown next to that reference.
@cloudbase/node-sdk, server-side auth, custom login tickets, or "who is calling".../auth-tool-cloudbase/SKILL.md (standalone fallback: https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/auth-tool-cloudbase/SKILL.md)../auth-web-cloudbase/SKILL.md (standalone fallback: https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/auth-web-cloudbase/SKILL.md)../http-api-cloudbase/SKILL.md (standalone fallback: https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/http-api-cloudbase/SKILL.md)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:
Do NOT use this skill for:
@cloudbase/js-sdk (handle those with the auth-web skill, not this Node skill).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:
When you load this skill to work on a task:
Clarify the runtime and responsibility
Ask the user:
Confirm CloudBase environment and SDK
env – CloudBase environment ID@cloudbase/node-sdk from npm if it is not already available.import tcb from "@cloudbase/node-sdk";
const app = tcb.init({ env: "your-env-id" });
const auth = app.auth();
Pick the relevant scenario from this file
getUserInfo scenarios.getEndUserInfo and queryUserInfo scenarios.createTicket.getClientIP scenario.Follow Node SDK API shapes exactly
auth.* methods and parameter shapes in this file as canonical.If you are unsure about an API
CloudBase Auth separates where users log in from where backend code runs:
In practice, Node code usually does one or more of:
Identify the current caller
auth.getUserInfo() to read uid, openId, and customUserId.Look up other users
auth.getEndUserInfo(uid) when you know the CloudBase uid.auth.queryUserInfo({ platform, platformId, uid? }) when you only have login identifiers such as phone, email, username, or a custom ID.Issue custom login tickets
auth.createTicket(customUserId, options) and return the ticket to a trusted client.Log client IP for security
auth.getClientIP() returns the caller IP, which you can use for audit logs, anomaly detection, or access control.The scenarios later in this file turn these responsibilities into explicit, copy‑pasteable patterns.
This skill covers the following auth methods on the CloudBase Node SDK. Treat these method signatures as the only supported entry points for Node auth flows when using this skill:
getUserInfo(): IGetUserInfoResult
Returns { openId, appId, uid, customUserId } for the current caller.
getEndUserInfo(uid?: string, opts?: ICustomReqOpts): Promise<{ userInfo: EndUserInfo; requestId?: string }>
Returns detailed CloudBase end‑user profile for a given uid or for the current caller (when uid is omitted).
queryUserInfo(query: IUserInfoQuery, opts?: ICustomReqOpts): Promise<{ userInfo: EndUserInfo; requestId?: string }>
Finds a user by login identifier (platform + platformId) or uid.
getClientIP(): string
Returns the caller’s IP address when running in a supported environment (e.g. 云函数).
createTicket(customUserId: string, options?: ICreateTicketOpts): string
Creates a custom login ticket for the given customUserId that clients can exchange for a CloudBase login.
The exact field names and allowed values for EndUserInfo, IUserInfoQuery, and ICreateTicketOpts are defined by the official CloudBase Node SDK typings and documentation. When writing Node code, do not guess shapes; follow the SDK types and the examples in this file.
Use this when writing a CloudBase 云函数 that needs to interact with Auth:
import tcb from "@cloudbase/node-sdk";
const app = tcb.init({ env: "your-env-id" });
const auth = app.auth();
exports.main = async (event, context) => {
// Your logic here
};
Key points:
env as configured for the function’s CloudBase 环境.Use this when you need to know who is calling your cloud function:
import tcb from "@cloudbase/node-sdk";
const app = tcb.init({ env: "your-env-id" });
const auth = app.auth();
exports.main = async (event, context) => {
const { openId, appId, uid, customUserId } = auth.getUserInfo();
console.log("Caller identity", { openId, appId, uid, customUserId });
// Use uid / customUserId for authorization decisions
// e.g. check roles, permissions, or data ownership
};
Best practices:
uid as the canonical CloudBase user identifier.customUserId only when you have enabled 自定义登录 and mapped your own users.openId/appId alone for authorization; they are WeChat‑specific identifiers.Use this when you know a user’s CloudBase uid (for example, from a database record) and you need detailed profile information:
import tcb from "@cloudbase/node-sdk";
const app = tcb.init({ env: "your-env-id" });
const auth = app.auth();
exports.main = async (event, context) => {
const uid = "user-uid";
try {
const { userInfo } = await auth.getEndUserInfo(uid);
console.log("User profile", userInfo);
} catch (error) {
console.error("Failed to get end user info", error.message);
}
};
Best practices:
getEndUserInfo from trusted backend code only; do not expose it directly to untrusted clients.Use this when you want the current caller’s full profile without manually passing uid:
import tcb from "@cloudbase/node-sdk";
const app = tcb.init({ env: "your-env-id" });
const auth = app.auth();
exports.main = async (event, context) => {
try {
const { userInfo } = await auth.getEndUserInfo();
console.log("Current caller profile", userInfo);
} catch (error) {
console.error("Failed to get current caller profile", error.message);
}
};
This relies on the environment providing the caller’s identity (e.g. within a CloudBase 云函数). If called where no caller context exists, refer to the official docs and handle errors gracefully.
Use this when you only know a user’s login identifier (phone, email, username, or custom ID) and need their CloudBase profile:
import tcb from "@cloudbase/node-sdk";
const app = tcb.init({ env: "your-env-id" });
const auth = app.auth();
exports.main = async (event, context) => {
try {
// Find by phone number
const { userInfo: byPhone } = await auth.queryUserInfo({
platform: "PHONE",
platformId: "+86 13800000000",
});
// Find by email
const { userInfo: byEmail } = await auth.queryUserInfo({
platform: "EMAIL",
platformId: "[email protected]",
});
// Find by customUserId
const { userInfo: byCustomId } = await auth.queryUserInfo({
platform: "CUSTOM",
platformId: "your-customUserId",
});
console.log({ byPhone, byEmail, byCustomId });
} catch (error) {
console.error("Failed to query user info", error.message);
}
};
Best practices:
uid when you already have it; use queryUserInfo only when needed.platformId uses the exact format you used at sign‑up (e.g. +86 + phone number).Use this for logging or basic IP‑based checks:
import tcb from "@cloudbase/node-sdk";
const app = tcb.init({ env: "your-env-id" });
const auth = app.auth();
exports.main = async (event, context) => {
const ip = auth.getClientIP();
console.log("Caller IP", ip);
// e.g. block or flag suspicious IPs
};
Custom login lets you keep your existing user system while still mapping each user to a CloudBase account.
Before issuing tickets, install the custom login private key file from the CloudBase console and load it in Node:
import tcb from "@cloudbase/node-sdk";
import path from "node:path";
const app = tcb.init({
env: "your-env-id",
credentials: require(path.join(__dirname, "tcb_custom_login.json")),
});
const auth = app.auth();
Keep tcb_custom_login.json secret and never bundle it into frontend code.
Use this in backend code that has already authenticated your own user and wants to let them log into CloudBase:
import tcb from "@cloudbase/node-sdk";
const app = tcb.init({
env: "your-env-id",
credentials: require("/secure/path/to/tcb_custom_login.json"),
});
const auth = app.auth();
exports.main = async (event, context) => {
const customUserId = "your-customUserId";
const ticket = auth.createTicket(customUserId, {
refresh: 3600 * 1000, // access_token refresh interval (ms)
expire: 24 * 3600 * 1000, // ticket expiration time (ms)
});
// Return the ticket to the trusted client (e.g. via HTTP response)
return { ticket };
};
Constraints for customUserId (from official docs):
_-#@(){}[]:.,<>+#~.Best practices:
customUserId in your own user database and keep it stable over time.customUserId for multiple distinct people.This skill only covers Node-side ticket issuance. For the client-side flow:
@cloudbase/js-sdk's custom login support:
ticket.auth.setCustomSignFunc(async () => ticketFromBackend).auth.signInWithCustomTicket() to finish login.Keep the responsibility clear:
Single source of truth for identity
uid as the primary key when relating end‑user records.customUserId only as a bridge to your own user system.Least privilege
uid, roles, and ownership, not just login success.getEndUserInfo / queryUserInfo results directly to clients.Error handling
auth.* calls in try/catch when they return promises.error.message (and error.code if present), but avoid logging sensitive data.Security
tcb_custom_login.json as you would any private key.Use this Node Auth skill whenever you need to:
uid or login identifier.For end‑to‑end experiences, pair this skill with:
@cloudbase/js-sdk).Treat the official CloudBase Auth Node SDK documentation as the canonical reference for Node auth APIs, and treat the scenarios in this file as vetted best‑practice building blocks.
Alternatives
coreyhaines31/marketingskills
When the user wants to plan, design, or implement an A/B test or experiment, or build a growth experimentation program. Also use when the user mentions "A/B test," "split test," "experiment," "test this change," "variant copy," "multivariate test," "hypothesis," "should I test this," "which version is better," "test two versions," "statistical significance," "how long should I run this test," "growth experiments," "experiment velocity," "experiment backlog," "ICE score," "experimentation program
JasonColapietro/suede-creator-skills
Suede-owned experimentation discipline for hypotheses, sample sizing, test duration, significance, and repeatable experiment programs. Use when comparing variants, deciding whether a result is reliable, or building an experiment backlog and cadence. NOT FOR: analytics instrumentation (use suede-analytics), post-click conversion diagnosis (use suede-site-alchemy), or writing the variant copy itself (use suede-copy).
narrative-io/narrative-skills-marketplace
Translate a fuzzy analytical question into a rigorous investigation plan. Interrogates the ask, grounds the plan in the available data dictionary, applies analytical best practices, and produces a structured brief of query specifications for a downstream query-writing skill. Plans, does not write SQL. Use when: "why did X drop", "is there a relationship between A and B", "who are our highest-value customers", "what's driving the change in Y", "investigate this trend", "design an analysis for", "
event4u-app/agent-config
Use BEFORE writing or editing any non-trivial UI — inventories components, design tokens, shadcn primitives, and reusable patterns into state.ui_audit. Hard gate for the ui directive set.