@authhero/aws-adapter

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

AWS DynamoDB adapter for AuthHero. This adapter implements the AuthHero data adapters using Amazon DynamoDB as the storage backend.

原始使用文档
文档目录9 节
  1. Features
  2. Installation
  3. Usage
  4. With AWS Lambda
  5. With Cloudflare Workers
  6. Table Design
  7. Global Secondary Indexes
  8. DynamoDB Table Setup
  9. License

@authhero/aws-adapter

AWS DynamoDB adapter for AuthHero. This adapter implements the AuthHero data adapters using Amazon DynamoDB as the storage backend.

Features

  • Single-table design for efficient DynamoDB usage
  • Works with AWS Lambda and Cloudflare Workers
  • Type-safe with full TypeScript support

Installation

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

Usage

With AWS Lambda

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",
});

With Cloudflare Workers

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",
});

Table Design

This adapter uses a single-table design with the following key structure:

EntityPKSK
TenantTENANT#{tenant_id}TENANT
UserTENANT#{tenant_id}USER#{user_id}
SessionTENANT#{tenant_id}SESSION#{session_id}
ClientTENANT#{tenant_id}CLIENT#{client_id}
ConnectionTENANT#{tenant_id}CONNECTION#{connection_id}
CodeTENANT#{tenant_id}CODE#{code_id}
PasswordTENANT#{tenant_id}#USER#{user_id}PASSWORD#{password_id}
.........

Global Secondary Indexes

  • GSI1: For querying by email across users

    • GSI1PK: TENANT#{tenant_id}#EMAIL#{email}
    • GSI1SK: USER
  • GSI2: For querying custom domains

    • GSI2PK: DOMAIN#{domain}
    • GSI2SK: CUSTOM_DOMAIN

DynamoDB Table Setup

Create a DynamoDB table with the following configuration:

{
  "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"
}

License

MIT

版本与发布记录

@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 adapter for AuthHero. This adapter implements the AuthHero data adapters using Amazon DynamoDB as the storage backend.

如何安装 @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 和提交记录判断。