@authhero/aws-adapter

中文文档
1.10.0发布于 2026/11/05AGPL-3.0-onlyTypeScriptESM + CJS构建来源已验证近 30 天下载 1939

AWS DynamoDB为AuthHero的适配器. 这个适配器执行AuthHero数据适配器,使用Amazon DynamoDB作为存储后端.

中文使用文档
文档目录9 节
  1. 特征
  2. 安装
  3. 使用量
  4. 与 AWS 蓝巴达
  5. 和云花岗工人
  6. 表格设计
  7. 全球二级指数
  8. DynamoDB 表格设置
  9. 许可证

@authhero/锯齿适应器

AWS DynamoDB为AuthHero的适配器. 这个适配器执行AuthHero数据适配器,使用Amazon DynamoDB作为存储后端.

特征

  • 用于高效使用DynamomaDB的单表设计
  • 与AWS Lambda和Cloudflare工人合作
  • 具有完整类型脚本支持的类型安全

安装

npm install @authhero/aws-adapter
# or
pnpm add @authhero/aws-adapter

使用量

与 AWS 蓝巴达

import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient } from "@aws-sdk/lib-dynamodb";
import createAdapters from "@authhero/aws-adapter";

const client = new DynamoDBClient({});
const docClient = DynamoDBDocumentClient.from(client);

const adapters = createAdapters(docClient, {
  tableName: "authhero",
});

和云花岗工人

import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient } from "@aws-sdk/lib-dynamodb";
import createAdapters from "@authhero/aws-adapter";

// In Cloudflare Workers, you need to provide credentials explicitly
const client = new DynamoDBClient({
  region: env.AWS_REGION,
  credentials: {
    accessKeyId: env.AWS_ACCESS_KEY_ID,
    secretAccessKey: env.AWS_SECRET_ACCESS_KEY,
  },
});
const docClient = DynamoDBDocumentClient.from(client);

const adapters = createAdapters(docClient, {
  tableName: "authhero",
});

表格设计

此适配器采用单表设计,并有以下关键结构: 1

实体PK 键苏格兰
租户TENANT#{tenant_id}TENANT
用户TENANT#{tenant_id}USER#{user_id}
会议TENANT#{tenant_id}SESSION#{session_id}
客户端TENANT#{tenant_id}CLIENT#{client_id}
连接TENANT#{tenant_id}CONNECTION#{connection_id}
代码TENANT#{tenant_id}CODE#{code_id}
密码TENANT#{tenant_id}#USER#{user_id}PASSWORD#{password_id}
...

全球二级指数

  • GSI1 (英语): 供用户通过电子邮件查询

    • GSI1PK: (英语) TENANT#{tenant_id}#EMAIL#{email}
    • GSI1SK: (英语) USER
  • GSI2 (英语):用于查询自定义域

    • GSI2PK: (英语) DOMAIN#{domain}
    • GSI2SK: (英语) CUSTOM_DOMAIN

DynamoDB 表格设置

创建带有以下配置的 DynamomDB 表格 :

{
  "TableName": "authhero",
  "KeySchema": [
    { "AttributeName": "PK", "KeyType": "HASH" },
    { "AttributeName": "SK", "KeyType": "RANGE" }
  ],
  "AttributeDefinitions": [
    { "AttributeName": "PK", "AttributeType": "S" },
    { "AttributeName": "SK", "AttributeType": "S" },
    { "AttributeName": "GSI1PK", "AttributeType": "S" },
    { "AttributeName": "GSI1SK", "AttributeType": "S" },
    { "AttributeName": "GSI2PK", "AttributeType": "S" },
    { "AttributeName": "GSI2SK", "AttributeType": "S" }
  ],
  "GlobalSecondaryIndexes": [
    {
      "IndexName": "GSI1",
      "KeySchema": [
        { "AttributeName": "GSI1PK", "KeyType": "HASH" },
        { "AttributeName": "GSI1SK", "KeyType": "RANGE" }
      ],
      "Projection": { "ProjectionType": "ALL" }
    },
    {
      "IndexName": "GSI2",
      "KeySchema": [
        { "AttributeName": "GSI2PK", "KeyType": "HASH" },
        { "AttributeName": "GSI2SK", "KeyType": "RANGE" }
      ],
      "Projection": { "ProjectionType": "ALL" }
    }
  ],
  "BillingMode": "PAY_PER_REQUEST"
}

许可证

麻省理工学院

版本与发布记录

@authhero/aws-adapter 共发布 150 个版本,首次发布于 2025/12/18;过去 12 个月发布了 150 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.10.0latest2026/11/052 天前
1.9.22026/11/043 天前
1.9.12026/10/309 天前
1.9.02026/10/2910 天前
1.8.02026/10/2612 天前
1.7.02026/10/2315 天前

关于 @authhero/aws-adapter 的常见问题

@authhero/aws-adapter 是什么?

AWS DynamoDB为AuthHero的适配器. 这个适配器执行AuthHero数据适配器,使用Amazon DynamoDB作为存储后端.

如何安装 @authhero/aws-adapter?

在项目目录运行 npm install @authhero/aws-adapter,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:hono(^4.6.8)、@hono/zod-openapi(^1.4.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@authhero/aws-adapter 支持 TypeScript 吗?

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

@authhero/aws-adapter 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@authhero/aws-adapter 可以商用吗?

@authhero/aws-adapter 使用 AGPL-3.0-only 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@authhero/aws-adapter 的下载量有多少?

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

@authhero/aws-adapter 还在维护吗?

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