@rei-standard/amsg-server 2.3.1 → 2.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +43 -13
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @rei-standard/amsg-server
2
2
 
3
- `@rei-standard/amsg-server` 是 ReiStandard 主动消息标准的服务端 SDK(v2.0.1),提供 Blob 租户配置、租户 token 鉴权和标准路由处理器。
3
+ `@rei-standard/amsg-server` 是 ReiStandard 主动消息标准的服务端 SDK:Blob 租户配置、`tenantToken` / `cronToken` 鉴权、标准路由处理器。API 规范见 [API 技术规范](https://github.com/Tosd0/ReiStandard/blob/main/standards/active-messaging-api.md)。
4
4
 
5
5
  ## v2.0.1 变更摘要
6
6
 
@@ -9,6 +9,8 @@
9
9
  - 业务端点统一使用 `Authorization: Bearer <tenantToken>`
10
10
  - `send-notifications` 支持 `cronToken`(Header 或 query token)
11
11
 
12
+ 2.2+ 的字段增量(`messages` 数组、`splitPattern`、`avatarUrl` 严格校验)在规范的 [§6.1](https://github.com/Tosd0/ReiStandard/blob/main/standards/active-messaging-api.md#61-ai-消息字段约束) / [§6.2](https://github.com/Tosd0/ReiStandard/blob/main/standards/active-messaging-api.md#62-avatarurl-严格校验);行为已对齐 `amsg-instant`,向后兼容。
13
+
12
14
  ## 安装
13
15
 
14
16
  ```bash
@@ -52,7 +54,7 @@ const rei = await createReiServer({
52
54
 
53
55
  ## 关于 `messageType: 'instant'`
54
56
 
55
- > **Note**:新代码的 instant 消息请用 [@rei-standard/amsg-instant](../instant/README.md),跳过本端点的"建任务 → 处理 → 删任务" DB 来回。本端点的 `instant` 分支为兼容保留,行为不变、不会有运行时警告。
57
+ > **Note**:新代码的 instant 消息请用 [@rei-standard/amsg-instant](https://github.com/Tosd0/ReiStandard/blob/main/packages/rei-standard-amsg/instant/README.md),跳过本端点的"建任务 → 处理 → 删任务" DB 来回。本端点的 `instant` 分支为兼容保留,行为不变、不会有运行时警告。
56
58
 
57
59
  ## AI 接口 `apiUrl` 约束
58
60
 
@@ -130,17 +132,45 @@ AI 配置消息的提示词可以用两种形态之一,**互斥二选一**:
130
132
  ## 运行环境与要求
131
133
 
132
134
  - Node.js `>=20`
133
- - 必须安装 `web-push`
134
- - 必须安装 `@netlify/blobs`
135
- - 必须安装至少一个数据库驱动(`@neondatabase/serverless` 或 `pg`)
136
- - 必须配置:
137
- - `VAPID_EMAIL`
138
- - `NEXT_PUBLIC_VAPID_PUBLIC_KEY`
139
- - `VAPID_PRIVATE_KEY`
140
- - `TENANT_CONFIG_KEK`
141
- - `TENANT_TOKEN_SIGNING_KEY`
142
- - 可选配置:
143
- - `INIT_SECRET`(配置后 `init-tenant` 必须带 `X-Init-Secret`)
135
+ - 必须装:`web-push`、`@netlify/blobs`、以及至少一个数据库驱动(`@neondatabase/serverless` 或 `pg`)
136
+
137
+ ### 环境变量
138
+
139
+ 必填:
140
+
141
+ - `VAPID_EMAIL` — VAPID 联系邮箱
142
+ - `NEXT_PUBLIC_VAPID_PUBLIC_KEY` / `VAPID_PRIVATE_KEY` — VAPID 公私钥对,[vapidkeys.com](https://vapidkeys.com) 生成
143
+ - `TENANT_CONFIG_KEK` — 加密 Blob 里租户配置(含 db connection、masterKey)的 KEK
144
+ - `TENANT_TOKEN_SIGNING_KEY` — `tenantToken` / `cronToken` 的 HMAC 签名密钥
145
+
146
+ 可选:
147
+
148
+ - `INIT_SECRET` — 配了之后 `POST /api/v1/init-tenant` 必须带 `X-Init-Secret` 头才能初始化租户
149
+ - `PUBLIC_BASE_URL` — 生产域名(如 `https://your-domain.com`),用来让 `init-tenant` 返回完整 `cronWebhookUrl`
150
+ - `VERCEL_PROTECTION_BYPASS` — Vercel 部署 + Preview Protection 时给 cron 走的 bypass key
151
+
152
+ `TENANT_CONFIG_KEK` / `TENANT_TOKEN_SIGNING_KEY` / `INIT_SECRET` 推荐:
153
+
154
+ ```bash
155
+ openssl rand -base64 32
156
+ ```
157
+
158
+ ### `.env` 模板
159
+
160
+ ```dotenv
161
+ VAPID_EMAIL=youremail@example.com
162
+ NEXT_PUBLIC_VAPID_PUBLIC_KEY=YOUR-PUBLIC-KEY
163
+ VAPID_PRIVATE_KEY=YOUR-PRIVATE-KEY
164
+ TENANT_CONFIG_KEK=YOUR-KEK-SECRET
165
+ TENANT_TOKEN_SIGNING_KEY=YOUR-TOKEN-SIGNING-KEY
166
+
167
+ # 可选
168
+ INIT_SECRET=YOUR-INIT-SECRET
169
+ PUBLIC_BASE_URL=https://your-domain.com
170
+ VERCEL_PROTECTION_BYPASS=YOUR_BYPASS_KEY
171
+ ```
172
+
173
+ Vercel 部署配置可参考 [`examples/vercel.json.example`](https://github.com/Tosd0/ReiStandard/blob/main/examples/vercel.json.example)。
144
174
 
145
175
  ## 相关链接(绝对 URL)
146
176
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rei-standard/amsg-server",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
4
4
  "description": "ReiStandard Active Messaging server SDK with pluggable database adapters",
5
5
  "repository": {
6
6
  "type": "git",