@gjermundgaraba/clankerauth-admin-api

中文文档
0.35.1发布于 2026/11/11MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 3444

The clankerauth administration contract: its effect-actions actions, schemas, errors and HTTP bindings, for administering an issuer from a program.

原始使用文档

@gjermundgaraba/clankerauth-admin-api

The administration contract of a clankerauth issuer: every owner action as an effect-actions action, with its input and output schemas, its tagged errors, and the HTTP bindings the issuer serves them on. The issuer, its dashboard, its MCP endpoint and the clankerauth CLI all derive from it, so a program calling it gets the same actions, typed, with no CLI in between.

Its version follows the issuer's: use the one matching the issuer you call.

Install

vp add @gjermundgaraba/clankerauth-admin-api effect @gjermundgaraba/effect-actions@^0.31.0

Effect 4.1, from 4.1.1, and effect-actions are peers, shared with the program. effect-actions 0.31 itself needs Effect 4.1.3 or a later 4.1 patch.

Call administration from a program

OwnerHttp is the binding served at /api/owner/<action>, authenticated by an owner's access token for the administration resource, the issuer's origin root, or by an administration key: an API key granted clankerauth:read or clankerauth:write on that resource. The owner's sign-in that clankerauth login <issuer> keeps gives a token: authorizing of @gjermundgaraba/clankerauth-sdk/credentials sends it with each request, refreshed as it expires, and the methods fail with SignInRequired when there is none. Given token, authorizing sends what the environment holds instead, so the program below runs unattended with an administration key in CLANKERAUTH_TOKEN, the variable the clankerauth command reads too, and with the owner's sign-in when it is unset.

import { OwnerHttp } from "@gjermundgaraba/clankerauth-admin-api";
import * as Credentials from "@gjermundgaraba/clankerauth-sdk/credentials";
import * as ActionHttp from "@gjermundgaraba/effect-actions/ActionHttp";
import { Config, Effect } from "effect";
import { FetchHttpClient } from "effect/http";

const issuer = "https://clankerauth.home.example";

const program = Effect.gen(function* () {
  const admin = yield* ActionHttp.client(OwnerHttp, {
    baseUrl: issuer,
    transformClient: Credentials.authorizing({
      url: issuer,
      token: Config.Redacted("CLANKERAUTH_TOKEN"),
    }),
  });

  const { created } = yield* admin.putResource({
    identifier: "https://notes.home.example/",
    name: "Notes",
    scopes: ["notes:read", "notes:write"],
  });

  return created;
}).pipe(Effect.provide(FetchHttpClient.layer));

A refusal fails with its tagged error, such as ResourceNotFound from getResource or deleteResource; each action declares the ones it can produce. getResource reads one resource, putResource creates or updates one to exactly the name and scopes given, so a deployment tool states what it wants without choosing between create and update, and deleteResource removes one.

The owner creates an administration key with clankerauth create-api-key --name deployer --permissions '{"https://clankerauth.home.example/":["clankerauth:read","clankerauth:write"]}' --expires-at null, or in the dashboard. What it may do, and when a change to it applies, is in the issuer's README.

MIT licensed.

版本与发布记录

@gjermundgaraba/clankerauth-admin-api 共发布 20 个版本,首次发布于 2026/10/17;过去 12 个月发布了 20 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.35.1latest2026/11/115 天前
0.35.02026/11/115 天前
0.34.02026/11/0610 天前
0.33.12026/11/0511 天前
0.33.02026/11/0214 天前
0.32.02026/11/0115 天前

关于 @gjermundgaraba/clankerauth-admin-api 的常见问题

@gjermundgaraba/clankerauth-admin-api 是什么?

The clankerauth administration contract: its effect-actions actions, schemas, errors and HTTP bindings, for administering an issuer from a program.

如何安装 @gjermundgaraba/clankerauth-admin-api?

在项目目录运行 npm install @gjermundgaraba/clankerauth-admin-api,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:effect(~4.1.1)、@gjermundgaraba/effect-actions(^0.31.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@gjermundgaraba/clankerauth-admin-api 支持 TypeScript 吗?

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

@gjermundgaraba/clankerauth-admin-api 支持 ESM 还是 CommonJS?

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

@gjermundgaraba/clankerauth-admin-api 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=26.13.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@gjermundgaraba/clankerauth-admin-api 可以商用吗?

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

@gjermundgaraba/clankerauth-admin-api 的下载量有多少?

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

@gjermundgaraba/clankerauth-admin-api 还在维护吗?

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