@columenlabs/lumen-people

中文文档
0.1.219发布于 2026/11/09MITTypeScriptES Module近 30 天下载 3.1万

Lumen's people, access and invites on the server: the rules, a SQL store, single-use invite links, a pluggable mailer and the routes the People screens call.

原始使用文档
文档目录4 节
  1. Install
  2. Scopes and levels
  3. The service
  4. The routes

@columenlabs/lumen-people

Lumen's people, access and invites, server side: who may sign in, what each person may do in each part of an app, invites with a single-use link that expires, and an audit log of every change. It pairs with the People screens in @columenlabs/lumen-ui/people. No dependencies beyond @columenlabs/lumen-ui-types: Web Crypto, Request and Response, so it runs in a Worker, a Durable Object, Bun or Node.

Install

bun add @columenlabs/lumen-people @columenlabs/lumen-ui-types

Pin both to the same exact version as the other Lumen packages.

Scopes and levels

A scope is anything access is given on: an app, or a construct inside one (a folder, a collection). Each has its own ordered levels, lowest first (None, View, Edit, Admin when it names none). A person holds one level per scope; no grant is the lowest. Admins hold the top level everywhere; disabled people and expired invites hold the lowest.

import type { Scope } from '@columenlabs/lumen-ui-types/people';

export const SCOPES: Scope[] = [
  { id: 'tools', name: 'Tools' },
  { id: 'recipes', name: 'Recipes' },
  { id: 'collections', name: 'Collections', parent: 'recipes', resourceLabel: 'Collection' },
];

The service

import { can, createPeople, doSql, sqlStore } from '@columenlabs/lumen-people';

// In a Durable Object, so the admin floor check and its write never interleave:
const people = createPeople({
  store: sqlStore(doSql(ctx.storage.sql)),   // or sqlStore(d1Sql(env.DB))
  scopes: SCOPES,
  fixedAdmins: ['[email protected]'],        // always an active admin
  inviteDays: 7,
});

const person = await people.seen('[email protected]');   // on each sign-in: null = refuse
can(person, SCOPES[0], 'view', SCOPES);              // the one check a route makes

The rules it keeps:

  • One active admin always; the built-in admins can never lose it.
  • Only an admin invites, changes access or removes; refusals are logged too.
  • An invite link is single use; only its SHA-256 hash is stored. Resend makes a new link and restarts the clock, revoke kills it. An invite past its life is refused at sign-in until resent.
  • Every change is one audit event (who, what, when, from where), kept a year.

The routes

import { peopleRoutes } from '@columenlabs/lumen-people/routes';

const routes = peopleRoutes({
  base: '/api/people',
  people: () => people,                                 // or a Durable Object stub
  actor: (req) => ({ email, admin, via: 'app' }),       // your verified caller
  scopes: SCOPES,
  appName: 'Example',
  link: (token) => `https://app.example.com/invite/${token}`,
  mailer: () => myMailer,                               // optional: (msg) => { ok, detail }
  onRemove: async (person) => { /* delete their data */ },
});

app.all('/api/people/*', (c) => routes(c.req.raw));

Without a mailer every invite returns its link to copy by hand; a failed send never undoes an invite.

版本与发布记录

@columenlabs/lumen-people 共发布 154 个版本,首次发布于 2026/10/26;过去 12 个月发布了 154 个版本。

版本发布日期距今
0.1.219latest2026/11/091 天前
0.1.2182026/11/091 天前
0.1.2172026/11/091 天前
0.1.2162026/11/091 天前
0.1.2152026/11/091 天前
0.1.2142026/11/091 天前

关于 @columenlabs/lumen-people 的常见问题

@columenlabs/lumen-people 是什么?

Lumen's people, access and invites on the server: the rules, a SQL store, single-use invite links, a pluggable mailer and the routes the People screens call.

如何安装 @columenlabs/lumen-people?

在项目目录运行 npm install @columenlabs/lumen-people,或使用 pnpm add / yarn add / bun add。

@columenlabs/lumen-people 支持 TypeScript 吗?

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

@columenlabs/lumen-people 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@columenlabs/lumen-people 可以商用吗?

@columenlabs/lumen-people 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@columenlabs/lumen-people 的下载量有多少?

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

@columenlabs/lumen-people 还在维护吗?

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