Token导航 LogoToken导航TokenDH.com
研究检索敏感数据github未标认证来源可访问许可证需确认审计提醒

auth0-spa-jsauth0 温泉 js

Agent Skill

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

总安装

1,248

周安装

52

GitHub Stars

17

下载量

416
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/auth0/agent-skills --skill auth0-spa-js

简介

用于辅助安全审计、权限检查、凭据风险和认证流程排查。

  • 适合梳理敏感配置、检查依赖风险、分析鉴权逻辑或生成安全复核清单。
  • 通过系统步骤发现项目结构、识别认证文件和中间件配置,提供路由保护建议。
  • 使用时不能把工具输出直接当最终结论,涉及密钥、令牌或生产系统时应确认最小权限和操作边界。
  • auth0-spa-js 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Auth0 SPA JS Integration

Add authentication to any browser-based single-page application using @auth0/auth0-spa-js — the low-level Auth0 SDK for Vanilla JS, Svelte, SolidJS, and any SPA not using React, Angular, or Vue.

Agent instruction: Before providing SDK setup instructions, fetch the latest release version by running: `` gh api repos/auth0/auth0-spa-js/releases/latest --jq '.tag_name' `` Use the returned version in all dependency lines instead of any hardcoded version below. If the command fails, fall back to checking https://github.com/auth0/auth0-spa-js/releases.

Prerequisites

  • Modern browser with ES2017+ support
  • npm or yarn (or use CDN for no-bundler apps)
  • Auth0 account with a Single Page Application configured
  • If you don't have Auth0 set up, see auth0-quickstart

When NOT to Use

Quick Start Workflow

1. Install SDK

npm install @auth0/auth0-spa-js

Or via CDN (no bundler). Run this to get the latest version, then use it in your HTML:

VERSION=$(npm view @auth0/auth0-spa-js version)
<script src="https://cdn.auth0.com/js/auth0-spa-js/$VERSION/auth0-spa-js.production.js"></script>

2. Configure Auth0

For automated setup with Auth0 CLI, see Setup Guide for complete scripts.

For manual setup, create .env (Vite):

VITE_AUTH0_DOMAIN=your-tenant.auth0.com
VITE_AUTH0_CLIENT_ID=your-client-id

In Auth0 Dashboard, set for your Single Page Application:

  • Allowed Callback URLs: http://localhost:5173
  • Allowed Logout URLs: http://localhost:5173
  • Allowed Web Origins: http://localhost:5173

3. Initialize Auth0 Client

import { createAuth0Client } from '@auth0/auth0-spa-js';

const auth0 = await createAuth0Client({
  domain: import.meta.env.VITE_AUTH0_DOMAIN,
  clientId: import.meta.env.VITE_AUTH0_CLIENT_ID,
  authorizationParams: {
    redirect_uri: window.location.origin
  }
});

// Handle redirect callback after login
const query = new URLSearchParams(window.location.search);
if ((query.has('code') || query.has('error')) && query.has('state')) {
  await auth0.handleRedirectCallback();
  window.history.replaceState({}, document.title, window.location.pathname);
}

4. Add Login / Logout

Agent instruction: Before adding new UI elements, search the project for existing click handlers for login, logout, sign-in, or sign-out buttons. If existing handlers are found, hook the Auth0 code into them without modifying the existing UI. Only create new buttons if no existing handlers are found.
// Login
document.getElementById('login-btn').addEventListener('click', async () => {
  await auth0.loginWithRedirect();
});

// Logout
document.getElementById('logout-btn').addEventListener('click', () => {
  auth0.logout({
    logoutParams: { returnTo: window.location.origin }
  });
});

// Update UI based on auth state
const isAuthenticated = await auth0.isAuthenticated();
if (isAuthenticated) {
  const user = await auth0.getUser();
  console.log(user.name, user.email);
}

5. Get Access Tokens for API Calls

const accessToken = await auth0.getTokenSilently();

const response = await fetch('https://your-api.example.com/data', {
  headers: { Authorization: `Bearer ${accessToken}` }
});

6. Build & Verify

Agent instruction: After completing the integration, build the project to verify it compiles successfully: ``bash npm run build ` If the build fails, analyze the error output and fix the issues. Common integration build failures include: - **Module not found**: Missing npm install @auth0/auth0-spa-js — run the install command - **Cannot find name 'import.meta'**: TypeScript target too low — set "target": "ES2020" or higher in tsconfig.json - **createAuth0Client is not a function**: Wrong import path or CDN usage without bundle step - **Env vars undefined at runtime**: Vite requires VITE_ prefix; webpack/CRA requires REACT_APP_ prefix Re-run the build after each fix. Track the number of build-fix iterations. **Failcheck:** If the build still fails after 5–6 fix attempts, stop and ask the user using AskUserQuestion`: *"The build is still failing after several fix attempts. How would you like to proceed?"* - Let the skill continue fixing iteratively — continue the build-fix loop for another 5–6 attempts - Fix it manually — show the remaining errors and let the user resolve them - Skip build verification — proceed without a successful build

Detailed Documentation

  • Setup Guide — Automated setup scripts (Bash/PowerShell), Auth0 CLI commands, .env configuration, callback URL setup
  • Integration Patterns — Token management, calling APIs, refresh tokens, organizations, MFA, DPoP, error handling, advanced patterns
  • Testing & Reference — Configuration options, claims reference, testing checklist, common issues, security considerations

Common Mistakes

MistakeFix
Callback URL port mismatch (e.g., localhost:3001 vs localhost:5173)Match Allowed Callback URLs exactly to your dev server port in Auth0 Dashboard
client_secret in SPA codeSPAs must never have a client secret — remove it. Auth0 sets auth method to None for SPA apps
Tokens stored in localStorageUse in-memory storage (default) or sessionStorage. Never localStorage — XSS risk
getTokenSilently() throws login_required on page refreshAdd your app origin to Allowed Web Origins in Auth0 Dashboard
handleRedirectCallback() not called after redirectMust call after login redirect to exchange the auth code; without this the URL params persist and re-trigger
Domain includes https:// prefixAuth0 domain should be hostname only: your-tenant.auth0.com, not https://your-tenant.auth0.com
loginWithPopup() called from async init codePopups must be triggered directly from a user gesture (click handler). Never call from init or page load code
Using Auth0Provider from @auth0/auth0-react in Vanilla JSFor Vanilla JS, use createAuth0Client() directly — no provider component needed

Related Skills

Quick Reference

Core Methods

MethodDescription
createAuth0Client(options)Create and initialize client (calls checkSession internally)
new Auth0Client(options)Instantiate without auto session check
auth0.loginWithRedirect(options?)Redirect to Auth0 Universal Login
auth0.loginWithPopup(options?)Open Auth0 login in a popup
auth0.logout(options?)Clear session and redirect
auth0.handleRedirectCallback(url?)Process redirect result after login
auth0.isAuthenticated()Promise<boolean>
auth0.getUser()`Promise<User \undefined>`
auth0.getTokenSilently(options?)Promise<string> — access token
auth0.checkSession()Attempt silent re-authentication

Common Use Cases

References

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

34.18%
按下载量换算142

Claude

32.71%
按下载量换算136

Cursor

19.05%
按下载量换算79

Gemini CLI

9.64%
按下载量换算40

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

敏感数据

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

安装前确认

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

来源信息

继续浏览同类 Skills