@axiam/opaque-wasm

中文文档
1.2.5发布于 2026/11/07Apache-2.0TypeScriptES Module零依赖构建来源已验证近 30 天下载 1964

WebAssembly build of AXIAM's OPAQUE (RFC 9807) client

原始使用文档
文档目录4 节
  1. Why this exists
  2. Building
  3. Usage
  4. What this does not do

axiam-opaque-wasm

WebAssembly build of AXIAM's OPAQUE (RFC 9807) client, published to npm as @axiam/opaque-wasm and consumed by the TypeScript SDK and the React admin UI.

Why this exists

sdks/CONTRACT.md §23.1 forbids an SDK from implementing OPAQUE itself. SRP was hand-written eleven times because it is modular arithmetic and every language has a bignum; OPAQUE needs an oblivious PRF, hash_to_curve, expand_message_xmd, an envelope construction and a three-message AKE. So there is one implementation — crates/axiam-opaque — and this crate is how JavaScript reaches it.

Building

wasm-pack build --target web --release crates/axiam-opaque-wasm

Not a Cargo workspace member on purpose: it only ever builds for wasm32, and including it would make a plain cargo test at the repository root try to compile wasm-bindgen for the host.

Usage

import init, { OpaqueLogin, OpaqueKsf } from "@axiam/opaque-wasm";

await init();

// 1. Blind the password and start the exchange.
const login = new OpaqueLogin(password);
const started = await postJson("/api/v1/auth/opaque/login/start", {
  org_slug, tenant_slug, username_or_email, ke1: login.ke1,
});

// 2. Build the KSF from what the SERVER named — never from local defaults.
const ksf = started.ksf === "argon2id"
  ? OpaqueKsf.argon2id(started.memory_kib, started.iterations, started.parallelism)
  : OpaqueKsf.scrypt(started.log_n, started.r, started.p);

// 3. Open the envelope. A throw here means wrong password, unknown account,
//    or a server that does not hold the record — indistinguishable by design,
//    and nothing further may be posted.
const finished = login.finish(password, started.ke2, ksf);

await postJson("/api/v1/auth/opaque/login/finish", {
  opaque_session: started.opaque_session,
  ke3: finished.ke3,
});

login is consumed by finish: a second call throws rather than reusing one OPRF blind across two exchanges.

What this does not do

It performs no HTTP. Endpoint selection, cookie handling and error mapping belong to the SDK or application that calls it — see CONTRACT §23.4 and §23.5.

版本与发布记录

@axiam/opaque-wasm 共发布 39 个版本,首次发布于 2026/08/21;过去 12 个月发布了 39 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.2.5latest2026/11/071 天前
1.2.42026/11/061 天前
1.2.32026/11/061 天前
1.2.22026/11/053 天前
1.2.12026/11/053 天前
1.1.32026/10/309 天前

其他发布通道:alpha → 1.0.0-alpha44,beta → 1.0.0-beta18。

关于 @axiam/opaque-wasm 的常见问题

@axiam/opaque-wasm 是什么?

WebAssembly build of AXIAM's OPAQUE (RFC 9807) client

如何安装 @axiam/opaque-wasm?

在项目目录运行 npm install @axiam/opaque-wasm,或使用 pnpm add / yarn add / bun add。

@axiam/opaque-wasm 支持 TypeScript 吗?

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

@axiam/opaque-wasm 支持 ESM 还是 CommonJS?

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

@axiam/opaque-wasm 可以商用吗?

@axiam/opaque-wasm 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@axiam/opaque-wasm 的下载量有多少?

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

@axiam/opaque-wasm 还在维护吗?

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