auth-web-cloudbase
БесплатноБез исполняемых скриптовНе проверенComplete guide for CloudBase Auth v2 using Web SDK (@cloudbase/[email protected]) - all login flows, user management, captcha handling, and best practices in one file.
от diegosouzapw★ 68 звёзд на GitHubОб этом скилле
When to use this skill
Use this skill for frontend Web authentication in a CloudBase project, using the new auth system (Auth v2) and @cloudbase/[email protected].
Use it when you need to:
- Design and implement login/sign-up flows in a browser app
- Integrate CloudBase identity (
uid, tokens) with your own backend - Manage sessions and user profiles on the frontend
Default login method: If not specified, assume phone number + SMS verification code (passwordless).
Do NOT use for:
- Server-side auth (Node SDK)
- Direct HTTP API calls (use the CloudBase HTTP Auth skill at
skills/auth-http-api-skill) - Database or storage operations (use database/storage skills)
How to use this skill (for a coding agent)
Confirm CloudBase environment
Ask the user for:
env– CloudBase environment ID
Always initialize the SDK in this pattern (update values only):
import cloudbase from "@cloudbase/js-sdk"; const app = cloudbase.init({ env: "xxxx-yyy", }); const auth = app.auth();CloudBase Web JS SDK must be initialized synchronously:
- Always use top-level
import cloudbase from "@cloudbase/js-sdk"; - Do not use dynamic imports like
import("@cloudbase/js-sdk")or async wrappers such asinitCloudBase()with internalinitPromise
- Always use top-level
Check console configuration (do not assume it's done)
- ⚠️ MANDATORY: Always guide users to configure login methods in console
- Console URL format:
https://tcb.cloud.tencent.com/dev?envId={envId}#/identity/login-manage- Replace
{envId}with the actual CloudBase environment ID (e.g.,zirali-7gwqot6f31a0ab27) - Example:
https://tcb.cloud.tencent.com/dev?envId=test-xxx#/identity/login-manage
- Replace
- Before implementing any login flow, you MUST:
- Guide the user to open the console login management page using the URL above
- Confirm the required 登录方式 are enabled(短信 / 邮箱 / 用户名密码 / 微信开放平台 / 自定义登录)
- Confirm 短信/邮箱 模板已配置(if using SMS/email login)
- Confirm 当前 Web 域名已加入 安全域名 (安全来源列表)
- If something is missing, explain clearly what the user must configure and provide the console URL.
Pick a scenario from this file
- For login / sign-up, start with Scenario 1–8.
- For session & user info, use Scenario 9–22.
- Never invent new auth flows; always adapt from an existing scenario.
Follow CloudBase API shapes exactly
- Treat method names and parameter shapes in this file as canonical.
- You may change variable names and UI, but do not change API names or field names.
If you’re unsure about an API
- Look it up in the official docs mirror:
/source-of-truth/auth/web-sdk/authentication.md. - If an API is not documented there, do not use or invent it. Instead:
- Use a documented Web SDK API, or
- Ask the user to use a Node/HTTP skill for server-side or HTTP flows.
- Look it up in the official docs mirror:
Installation and initialization
npm install --save @cloudbase/js-sdk
import cloudbase from "@cloudbase/js-sdk";
const app = cloudbase.init({
env: "your-env-id", // CloudBase 环境 ID
});
const auth = app.auth();
Initialization rules (Web, @cloudbase/js-sdk):
- Always use synchronous initialization with the pattern above
- Do not lazy-load the SDK with
import("@cloudbase/js-sdk") - Do not wrap SDK initialization in async helpers such as
initCloudBase()with internalinitPromisecaches - Keep a single shared
app/authinstance in your frontend app; reuse it instead of re-initializing
Local development proxy for default login page
When using auth.toDefaultLoginPage() during local development, you must ensure that the /__auth path is proxied to your CloudBase Web hosting domain. For example, in a Vite + React project:
// vite.config.ts
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
export default defineConfig({
plugins: [react()],
base: "./", // Use relative paths to avoid asset issues on static hosting
server: {
host: "127.0.0.1",
proxy: {
"/__auth": {
target: "https://envId-appid.tcloudbaseapp.com/", // Replace with your CloudBase Web app domain
changeOrigin: true,
},
},
allowedHosts: true,
},
});
The CloudBase Web hosting domain can be obtained via the CloudBase MCP envQuery tool (Static hosting config); in the response, use the value from the StaticDomain field.
For other tooling (Webpack dev server, Next.js, custom Node dev servers, etc.), configure an equivalent /__auth proxy rule so that all /__auth requests are forwarded to the CloudBase domain during local development.
⚠️ Important: Console Configuration Required
Before using any login method, you MUST configure it in the CloudBase console:
- Open login management page:
- Console URL: `https://tcb.cloud.tencent.com/dev?env
Установить auth-web-cloudbase в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл auth-web-cloudbase?
Complete guide for CloudBase Auth v2 using Web SDK (@cloudbase/[email protected]) - all login flows, user management, captcha handling, and best practices in one file.
Как установить скилл auth-web-cloudbase?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл auth-web-cloudbase запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic