npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rei-standard/amsg-server

v2.0.1

Published

ReiStandard Active Messaging server SDK with pluggable database adapters

Readme

@rei-standard/amsg-server

@rei-standard/amsg-server 是 ReiStandard 主动消息标准的服务端 SDK(v2.0.1),提供 Blob 租户配置、租户 token 鉴权和标准路由处理器。

v2.0.1 变更摘要

  • 初始化流程合并为 POST /api/v1/init-tenant
  • 移除旧端点:init-databaseinit-master-key
  • 业务端点统一使用 Authorization: Bearer <tenantToken>
  • send-notifications 支持 cronToken(Header 或 query token)

安装

npm install @rei-standard/amsg-server web-push @netlify/blobs

# 数据库驱动二选一
npm install @neondatabase/serverless
# 或
npm install pg

快速使用

import { createReiServer } from '@rei-standard/amsg-server';

const rei = await createReiServer({
  vapid: {
    email: process.env.VAPID_EMAIL,
    publicKey: process.env.NEXT_PUBLIC_VAPID_PUBLIC_KEY,
    privateKey: process.env.VAPID_PRIVATE_KEY
  },
  tenant: {
    blobNamespace: 'rei-tenants',
    kek: process.env.TENANT_CONFIG_KEK,
    tokenSigningKey: process.env.TENANT_TOKEN_SIGNING_KEY,
    initSecret: process.env.INIT_SECRET,
    publicBaseUrl: process.env.PUBLIC_BASE_URL
  }
});

// 映射路由
// POST /api/v1/init-tenant          -> rei.handlers.initTenant.POST
// GET  /api/v1/get-user-key         -> rei.handlers.getUserKey.GET
// POST /api/v1/schedule-message     -> rei.handlers.scheduleMessage.POST
// POST /api/v1/send-notifications   -> rei.handlers.sendNotifications.POST
// PUT  /api/v1/update-message       -> rei.handlers.updateMessage.PUT
// DELETE /api/v1/cancel-message     -> rei.handlers.cancelMessage.DELETE
// GET  /api/v1/messages             -> rei.handlers.messages.GET

AI 接口 apiUrl 约束

messageTypeprompted / auto,或 instant 使用 AI 配置时:

  • apiUrl 必须是完整聊天端点(例如:https://api.openai.com/v1/chat/completions)。
  • SDK 会自动做最小规范化:去首尾空白、去路径尾部多余 /
  • SDK 不会自动补全 /v1/chat/completions 等路径。
  • maxTokens 为可选字段:传了就映射为 max_tokens;不传则不指定(由上游模型默认策略决定)。

如果上游返回 405 Method Not Allowed,通常表示 apiUrl 指向了基础域名而非聊天端点,请优先检查配置值。

一体化初始化流程

  1. 管理员配置环境变量(VAPID + tenant secrets)
  2. 租户调用 POST /api/v1/init-tenant 提交自己的 databaseUrl
  3. 服务端自动完成:建表 + 生成 masterKey + 写入 Blob + 返回 tenantToken/cronToken
  4. 前端使用 tenantToken,cron 使用 cronToken

端点鉴权

  • get-user-keyschedule-messageupdate-messagecancel-messagemessages
    • Authorization: Bearer <tenantToken>
  • send-notifications
    • Authorization: Bearer <cronToken>?token=<cronToken>

导出 API(Exports)

  • createReiServer
  • createAdapter
  • createTenantToken
  • verifyTenantToken
  • deriveUserEncryptionKey
  • decryptPayload
  • encryptForStorage
  • decryptFromStorage
  • validateScheduleMessagePayload
  • isValidISO8601
  • isValidUrl
  • isValidUUID
  • isValidUUIDv4

运行环境与要求

  • Node.js >=20
  • 必须安装 web-push
  • 必须安装 @netlify/blobs
  • 必须安装至少一个数据库驱动(@neondatabase/serverlesspg
  • 必须配置:
    • VAPID_EMAIL
    • NEXT_PUBLIC_VAPID_PUBLIC_KEY
    • VAPID_PRIVATE_KEY
    • TENANT_CONFIG_KEK
    • TENANT_TOKEN_SIGNING_KEY
  • 可选配置:
    • INIT_SECRET(配置后 init-tenant 必须带 X-Init-Secret

相关链接(绝对 URL)