@distilled.cloud/onepassword

中文文档
1.0.0-rc.20发布于 2026/11/13Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 2123
原始使用文档
文档目录4 节
  1. Installation
  2. APIs
  3. Quick start
  4. Auth

@distilled.cloud/onepassword

Effect-native 1Password SDK, generated from 1Password's published OpenAPI specs: Connect, Events, Users, OAuth and Partnership.

Installation

npm install @distilled.cloud/onepassword effect

APIs

Each API is a service namespace with its own credentials layer and protocol. A service is also importable on its own, e.g. @distilled.cloud/onepassword/connect.

APIOperationsCredentialsProtocol
ConnectOnepassword.connect.getVaults, …ConnectCredentialsFromEnvConnectProtocol
EventsOnepassword.events.getAuditEventsV2, …EventsCredentialsFromEnvEventsProtocol
UsersOnepassword.users.listUsers, …UsersCredentialsFromEnvUsersProtocol
OAuthOnepassword.oauth.requestAccessToken, …OAuthCredentialsFromEnvOAuthProtocol
PartnershipOnepassword.partnership.createPartnerAccount, …PartnershipCredentialsFromEnvPartnershipProtocol

Quick start

Connect (a self-hosted Connect server):

import { Effect, Layer } from "effect";
import * as FetchHttpClient from "effect/http/FetchHttpClient";
import * as Onepassword from "@distilled.cloud/onepassword";

const program = Effect.gen(function* () {
  const vaults = yield* Onepassword.connect.getVaults({});
  return vaults;
});

const Live = Layer.mergeAll(
  FetchHttpClient.layer,
  Onepassword.ConnectCredentialsFromEnv,
  Onepassword.ConnectProtocol,
);

program.pipe(Effect.provide(Live), Effect.runPromise);

Events (audit events from an Events Reporting integration):

import { Effect, Layer } from "effect";
import * as FetchHttpClient from "effect/http/FetchHttpClient";
import * as Onepassword from "@distilled.cloud/onepassword";

const program = Effect.gen(function* () {
  // Start a cursor with a page size and a start time, then pass the returned
  // `cursor` back as `{ body: { cursor } }` to continue.
  const page = yield* Onepassword.events.getAuditEventsV2({
    body: { limit: 100, start_time: "2026-10-01T00:00:00Z" },
  });
  return page.items;
});

const Live = Layer.mergeAll(
  FetchHttpClient.layer,
  Onepassword.EventsCredentialsFromEnv,
  Onepassword.EventsProtocol,
);

program.pipe(Effect.provide(Live), Effect.runPromise);

Users (suspend a user; the access token is requested and refreshed for you):

import { Effect, Layer } from "effect";
import * as FetchHttpClient from "effect/http/FetchHttpClient";
import * as Onepassword from "@distilled.cloud/onepassword";

const program = Onepassword.users.suspendUser({
  account: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
  user: "ZYXWVUTSRQPONMLKJIHGFEDCBA",
});

const Live = Layer.mergeAll(
  FetchHttpClient.layer,
  Onepassword.UsersCredentialsFromEnv,
  Onepassword.UsersProtocol,
);

program.pipe(Effect.provide(Live), Effect.runPromise);

Auth

APIRequiredOptionalSent as
ConnectOP_CONNECT_TOKENOP_CONNECT_HOST or OP_CONNECT_API_BASE_URL (default http://localhost:8080/v1)Authorization: Bearer
EventsOP_EVENTS_API_TOKENOP_EVENTS_API_BASE_URL (default https://events.1password.com)Authorization: Bearer
UsersOP_USERS_API_CLIENT_ID, OP_USERS_API_CLIENT_SECRETOP_USERS_API_BASE_URL (default https://api.1password.com)Authorization: Bearer <access token>
OAuthOP_USERS_API_CLIENT_ID, OP_USERS_API_CLIENT_SECRETOP_USERS_API_BASE_URL (default https://api.1password.com)Authorization: Basic
PartnershipOP_PARTNERSHIP_API_TOKENOP_PARTNERSHIP_API_BASE_URL (default https://billing.1password.com)Authorization: Bearer

1Password publishes no environment variable names for the Events, Users or Partnership APIs; the names above are this SDK's. Accounts outside the US use a regional host: *.1password.ca, *.1password.eu or *.ent.1password.com.

The Users credentials exchange the OAuth application's client ID and secret for a 15-minute access token at POST /v1/oauth/token, cache it, and request a new one shortly before it expires. To pass values directly, use connectCredentials({ token }), eventsCredentials({ token }), usersCredentials({ clientId, clientSecret }), usersCredentialsFromAccessToken({ accessToken }), oauthCredentials(...) or partnershipCredentials({ token }); secrets are Redacted<string>.

版本与发布记录

@distilled.cloud/onepassword 共发布 13 个版本,首次发布于 2026/09/10;过去 12 个月发布了 13 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.0.0-rc.20latest2026/11/131 天前
1.0.0-rc.192026/11/122 天前
1.0.0-rc.182026/11/0311 天前
1.0.0-rc.172026/10/2421 天前
1.0.0-rc.162026/10/2322 天前
1.0.0-rc.152026/10/131 个月前

关于 @distilled.cloud/onepassword 的常见问题

如何安装 @distilled.cloud/onepassword?

在项目目录运行 npm install @distilled.cloud/onepassword,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:effect(^4.1.2)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@distilled.cloud/onepassword 支持 TypeScript 吗?

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

@distilled.cloud/onepassword 支持 ESM 还是 CommonJS?

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

@distilled.cloud/onepassword 可以商用吗?

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

@distilled.cloud/onepassword 的下载量有多少?

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

@distilled.cloud/onepassword 还在维护吗?

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