Token导航 LogoToken导航TokenDH.com
开发敏感数据github未标认证来源可访问许可证需确认审计通过

ce-authCE 认证

Agent Skill

用于辅助安全审计、权限检查、凭据风险、认证流程和常见漏洞排查。它适合让 Agent 梳理敏感配置、检查依赖风险、分析鉴权逻辑或生成安全复核清单。使用时不能把工具输出直接当最终结论,涉及密钥、令牌、用户数据或生产系统时,应先确认最小权限、脱敏方式和操作边界。

总安装

654

周安装

27

GitHub Stars

公开资料未说明

下载量

214
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:ce-auth(CE 认证)
来源仓库:https://github.com/commercengine/skills
仓库路径:skills/ce-auth
安装命令:
npx skills add https://github.com/commercengine/skills --skill ce-auth
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/commercengine/skills --skill ce-auth

简介

ce-auth 提供 Commerce Engine 认证与用户管理集成方案,支持登录注册与会话维持。

  • 适用于在 Codex、Claude、Cursor、Gemini CLI 中构建账户体系或钱包功能时调用。
  • 区分 Hosted Checkout 与自定义 UI 两种模式,后者需处理订单历史等状态保持。
  • 必须初始化 SDK 并使用 session() 客户端处理敏感操作。
  • 包含 OAuth 流与 JWT 令牌刷新机制说明,但不含密码学算法实现细节。

SKILL.md

LLM Docs Header: All requests to https://llm-docs.commercengine.io must include the Accept: text/markdown header (or append .md to the URL path). Without it, responses return HTML instead of parseable markdown.

Authentication & User Management

Prerequisite: SDK must be initialized. See setup/ if not done.

When to Implement Auth Directly

If using Hosted Checkout, login and registration are usually handled inside the checkout drawer. Build custom auth UI only when the storefront needs logged-in state outside checkout, for example:

  • account pages
  • saved addresses
  • order history
  • loyalty or wallet pages
  • a persistent signed-in header state

Current Mental Model

  • Public product and category reads can use public() and do not require anonymous auth.
  • Live cart, account, and checkout flows should use the session client.
  • In managed session mode, the SDK can bootstrap anonymous auth automatically on the first token-required request.
  • If you need the anonymous session eagerly, call sdk.ensureAccessToken() once during startup.

Quick Reference

Auth MethodEndpointUse Case
Anonymous bootstrapsdk.ensureAccessToken() or sdk.auth.getAnonymousToken()Start a live session
Email OTPsdk.auth.loginWithEmail() -> sdk.auth.verifyOtp()Passwordless email login
Phone OTPsdk.auth.loginWithPhone() -> sdk.auth.verifyOtp()Passwordless phone login
WhatsApp OTPsdk.auth.loginWithWhatsApp() -> sdk.auth.verifyOtp()Passwordless WhatsApp login
Password loginsdk.auth.loginWithPassword()Traditional login
Password registrationsdk.auth.registerWithPassword() -> OTP verificationPassword sign-up
Forgot passwordsdk.auth.forgotPassword() -> sdk.auth.resetPassword()Reset password with OTP
Token refreshsdk.auth.refreshToken()Renew expired access token

Decision Tree

User Request
    │
    ├─ Public catalog-only page
    │   └─ No auth bootstrap needed; use public()
    │
    ├─ New visitor starting a live session
    │   └─ sdk.ensureAccessToken()
    │
    ├─ "Login" / "Sign in"
    │   ├─ Passwordless → loginWithEmail/Phone/WhatsApp() → verifyOtp()
    │   └─ Password → loginWithPassword()
    │
    ├─ "Register"
    │   └─ registerWithPassword() / registerWithPhonePassword() → verifyOtp()
    │
    ├─ "Forgot password"
    │   └─ forgotPassword() → resetPassword()
    │
    ├─ "Account" / "Profile"
    │   └─ getUserDetails() / updateUserDetails()
    │
    └─ "Token expired" / 401
        └─ refreshToken() or rely on managed session refresh

User States

StateHow CreatedCapabilities
Publicpublic() accessor onlyPublic catalog/store/helper reads
Anonymous sessionsdk.ensureAccessToken() or /auth/anonymousCart, checkout, analytics, session continuity
Logged-in sessionOTP verification, password login, or password reset completionAll anonymous capabilities plus account, orders, addresses, loyalty

User ID vs Customer ID

For most stores, user_id and customer_id are the same value — one user = one customer. In B2B storefronts, one customer can have multiple users (e.g., a company account with multiple employees).

The SDK exposes helpers to fetch both:

const userId = await sdk.getUserId();
const customerId = await sdk.getCustomerId();

Most SDK methods that require a user or customer ID have parameterless overloads that auto-resolve from the current session. For example, sdk.cart.getUserCart() (no params) fetches the cart for the logged-in user automatically. Only pass IDs explicitly when operating on behalf of a different user (admin scenarios).

Key Patterns

Start a live anonymous session

const sdk = storefront.session();
await sdk.ensureAccessToken();

Call this once during startup if you want eager bootstrap. Do not repeat it before ordinary session-aware cart, order, or customer calls.

OTP Login Flow (Email)

const { data, error } = await sdk.auth.loginWithEmail({
  email: "user@example.com",
  register_if_not_exists: true,
});

if (error) throw error;

const { otp_token, otp_action } = data!;

const { error: verifyError } = await sdk.auth.verifyOtp({
  otp: "123456",
  otp_token,
  otp_action,
});

if (verifyError) throw verifyError;

Password Login

const { data, error } = await sdk.auth.loginWithPassword({
  email: "user@example.com",
  password: "securepassword",
});

if (error) throw error;

Password Registration

Password registration is OTP-first in the latest contract.

const { data, error } = await sdk.auth.registerWithPassword({
  email: "user@example.com",
  password: "securepassword",
  confirm_password: "securepassword",
});

if (error) throw error;

await sdk.auth.verifyOtp({
  otp: "123456",
  otp_token: data!.otp_token,
  otp_action: data!.otp_action,
});

Forgot Password

const { data, error } = await sdk.auth.forgotPassword({
  email: "user@example.com",
});

if (error) throw error;

await sdk.auth.resetPassword({
  otp: "123456",
  otp_token: data!.otp_token,
  new_password: "newPass123",
  confirm_password: "newPass123",
});

User Profile

Auth client methods require explicit IDs (no parameterless overloads). Use sdk.getUserId() to get the current user's ID:

const userId = await sdk.getUserId();

const { data: userData } = await sdk.auth.getUserDetails({ id: userId! });

await sdk.auth.updateUserDetails({ id: userId! }, {
  first_name: "Jane",
  last_name: "Doe",
});

Key Feature: register_if_not_exists

Setting register_if_not_exists: true on login endpoints eliminates separate login and sign-up entry points. If the user does not exist, Commerce Engine creates the account and continues the OTP flow.

This is also the recommended approach for checkout auth — there is no separate "guest checkout" flow. The user provides their email or phone, gets verified via OTP, and the account is created if needed. This path of least resistance ensures address verification and order attribution. Hosted Checkout handles this entire flow automatically.

Logout

The SDK exposes sdk.auth.logout() for custom logout buttons:

const { data, error } = await sdk.auth.logout();

logout() does not clear tokens — it returns new tokens with reduced privileges. The session continues with full continuity (same cart, same analytics trail), but the user is no longer in a logged-in state. The SDK's onTokensUpdated callback fires with the new tokens, and the two-way sync with Hosted Checkout (when using authMode: "provided") propagates them automatically — no manual token clearing or updateTokens("", "") needed.

Common Pitfalls

LevelIssueSolution
CRITICALUsing public() for auth or account operationsUse the session client
CRITICALAssuming every page needs anonymous authPublic reads do not; only live session flows do
HIGHBuilding separate login and sign-up flows by defaultPrefer register_if_not_exists: true where appropriate
HIGHForgetting otp_token and otp_action between stepsPersist both and pass them to verifyOtp()
HIGHStoring tokens insecurely or with the wrong storage for the runtimeUse managed session storage appropriate to the environment
MEDIUMIgnoring {data, error}Always check error before using data

See Also

  • setup/ - SDK installation and session storage
  • cart-checkout/ - Checkout flows and Hosted Checkout
  • orders/ - Logged-in order flows
  • ssr-patterns/ - Server Actions/functions for auth mutations (Next.js, TanStack Start)

Documentation

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.6%
按下载量换算74

Claude

28.66%
按下载量换算61

Cursor

18.81%
按下载量换算40

Gemini CLI

9.46%
按下载量换算20

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills