Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

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от 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)

  1. 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 as initCloudBase() with internal initPromise
  2. 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
    • Before implementing any login flow, you MUST:
      1. Guide the user to open the console login management page using the URL above
      2. Confirm the required 登录方式 are enabled(短信 / 邮箱 / 用户名密码 / 微信开放平台 / 自定义登录)
      3. Confirm 短信/邮箱 模板已配置(if using SMS/email login)
      4. Confirm 当前 Web 域名已加入 安全域名 (安全来源列表)
    • If something is missing, explain clearly what the user must configure and provide the console URL.
  3. 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.
  4. 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.
  5. 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.

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 internal initPromise caches
  • Keep a single shared app/auth instance 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:

  1. Open login management page:
Полный SKILL.md на GitHub

Установить auth-web-cloudbase в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

metadata.json

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), без исполняемых скриптов.

Похожие скиллы

Сравнить auth-web-cloudbase с