@auth0/actions

中文文档
0.36.0发布于 2026/10/31Apache-2.0TypeScriptCommonJS零依赖构建来源已验证近 30 天下载 21.5万

Auth0 Official Actions TypeScript定义,该定义将帮助您编码并测试您的项目在外部编辑器和IDE上的动作.

中文使用文档
文档目录4 节
  1. 开始
  2. 反馈和贡献
  3. 许可证
  4. 什么是奥特?

Actions for Auth0

License NPM Downloads

🚀 开始 • 反馈

官方 Auth0 动作类型脚本定义, 将帮助您编码并测试您的项目在外部编辑器和IDE上的动作 .

开始

先决条件:

安装 :

使用 npm 安装软件包 :

npm install --save-dev @auth0/actions

或用纱线:

yarn add --dev @auth0/actions

或使用pnpm:

pnpm add --save-dev @auth0/actions

用法 :

使用下列方法之一将类型脚本定义导入您的 Auth0 动作:

@ import:

如果您想要启用 IntelliSense而不改变您现有的 JavaScript 代码结构, 请使用此方法 :

/** @import {Event, PostLoginAPI} from "@auth0/actions/post-login/v3" */

/**
* Handler that will be called during the execution of a PostLogin flow.
*
* @param {Event} event - Details about the user and the context in which they are logging in.
* @param {PostLoginAPI} api - Interface whose methods can be used to change the behavior of the login.
*/
exports.onExecutePostLogin = async (event, api) => {
  const user = event.user;

  // Your Action logic here
  if (user.email?.endsWith('@example.com')) {
    api.user.setAppMetadata('department', 'internal');
  }
}

校对:Soup

JavaScript 文件中使用 JSDoc 注释中的导入语句对类型安全使用此方法:


/**
* Handler that will be called during the execution of a PostLogin flow.
*
* @param {import('@auth0/actions/post-login/v3').Event} event - Details about the user and the context in which they are logging in.
* @param {import('@auth0/actions/post-login/v3').PostLoginAPI} api - Interface whose methods can be used to change the behavior of the login.
*/
exports.onExecutePostLogin = async (event, api) => {
  const user = event.user;

  // Your Action logic here
  if (user.email?.endsWith('@example.com')) {
    api.user.setAppMetadata('department', 'internal');
  }
}

类型脚本导入 :

在使用 TypeScript 开发全类型检查和现代语法时使用此方法 :

import type { Event, PostLoginAPI } from '@auth0/actions/post-login/v3';

/**
* Handler that will be called during the execution of a PostLogin flow.
*
* @param {Event} event - Details about the user and the context in which they are logging in.
* @param {PostLoginAPI} api - Interface whose methods can be used to change the behavior of the login.
*/
exports.onExecutePostLogin = async (event: Event, api: PostLoginAPI) => {
  const user = event.user;

  // Your Action logic here
  if (user.email?.endsWith('@example.com')) {
    api.user.setAppMetadata('department', 'internal');
  }
};

重要内容: 使用 TypeScript 时,必须在部署到 Auth0 之前将您的代码编译为 JavaScript 。 Auth0 动作运行时间只执行 JavaScript 。 使用 TypeScript 编译器(tsc转写您的 .ts 文件为 .js 文档,在可以部署之前。 您还必须加入 JSDoc 评论, 以启用 Intellisense 在 Dashboard 中.

反馈和贡献

此寄存器包含自动生成的类型Script类型和用于Auth0动作开发的公用设备. 本套件中的类型由Auth0的内部系统生成并被发布,以帮助开发者构建Action. 该寄存器不接受外部捐款. 此包的内容由Auth0的内部系统自动生成并维护. 需要帮助使用此软件包、报告问题或提供反馈:

许可证

版权2026 Okta, Inc.

这个项目根据Apache 2.0许可证获得许可. 见 自由主义 需要更多信息的文件.

什么是奥特?

Auth0 Logo

Auth0是一个易于执行,可适应的认证和授权平台. 学习更多退房 为什么是Auth0?

版本与发布记录

@auth0/actions 共发布 31 个版本,首次发布于 2025/10/21;过去 12 个月发布了 27 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.36.0latest2026/10/318 天前
0.35.02026/10/0930 天前
0.34.02026/09/191 个月前
0.33.02026/09/171 个月前
0.32.02026/08/282 个月前
0.31.02026/08/182 个月前

关于 @auth0/actions 的常见问题

@auth0/actions 是什么?

Auth0 Official Actions TypeScript定义,该定义将帮助您编码并测试您的项目在外部编辑器和IDE上的动作.

如何安装 @auth0/actions?

在项目目录运行 npm install @auth0/actions,或使用 pnpm add / yarn add / bun add。

@auth0/actions 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@auth0/actions 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@auth0/actions 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@auth0/actions 可以商用吗?

@auth0/actions 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@auth0/actions 的下载量有多少?

根据 npm 官方下载统计,@auth0/actions 在 2026/10/07 – 2026/11/05 这 30 天内被下载 214,684 次,日均约 7,156 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@auth0/actions 还在维护吗?

最新版本 0.36.0 发布于 2026/10/31(8 天前);至今共发布 31 个版本,其中过去 12 个月发布了 27 个;首次发布于 2025/10/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。