@dotenvx/providers

中文文档
0.3.13发布于 2026/10/29BSD-3-ClauseCommonJS近 30 天下载 598.8万

Private key lookup for dotenvx

原始使用文档

@dotenvx/providers

npm install @dotenvx/providers
const { provider } = require('@dotenvx/providers')
const { parse, parseSync } = require('@dotenvx/primitives')

const keys = provider()

// Async
const result = await parse(source, { provider: keys.get })

// Sync
const resultSync = parseSync(source, { provider: keys.getSync })

Looks up private keys in this order, stopping at the first match:

  • .env.keys
  • macOS Keychain
  • Windows Credential Manager
  • Linux Secret Service
  • Dotenvx Armor (including enclave decryption)
  • 1Password
  • Bitwarden

providerOrder exports the same order for consumers with custom provider adapters. The platform's native store occupies one step between .env.keys and Armor.

Optional onLookup(name) and onLookupEnd(name) callbacks let consumers show progress without owning the lookup order. They run around each attempted lookup in both get and getSync; onLookupEnd also runs when a lookup throws. These synchronous callbacks should not throw.

Armor errors fall through to password managers. If none finds the key, the original Armor error is thrown. Other provider errors propagate immediately. An optional onArmorError(error) callback receives an unresolved Armor error instead of throwing it, allowing consumers with an additional interactive fallback to try it before reporting the error.

isNetworkError(error) classifies transport failures, including nested causes and aggregate errors. Armor normalizes those failures to ARMOR_UNREACHABLE with message, help, and messageWithHelp, preserved by synchronous workers. Consumers display these messages and choose whether to continue parsing without a resolved key; they do not need their own transport error-code lists.

Approval prompts

Armor prints an approval URL to stderr before polling when no onApprovalRequired({ approvalUri, code }) callback is supplied. Synchronous lookups print from their worker directly, so the prompt stays visible while the calling thread is blocked. Callbacks are only supported by asynchronous lookups.

An async consumer can customize presentation with onApprovalRequired, or call the exported approvalRequired(info) inside its callback to use the default message (for example, after stopping a spinner).

版本与发布记录

@dotenvx/providers 共发布 15 个版本,首次发布于 2026/10/07;过去 12 个月发布了 15 个版本。

版本发布日期距今
0.3.13latest2026/10/2915 天前
0.3.122026/10/2717 天前
0.3.112026/10/2024 天前
0.3.102026/10/2024 天前
0.3.82026/10/1628 天前
0.3.72026/10/1628 天前

关于 @dotenvx/providers 的常见问题

@dotenvx/providers 是什么?

Private key lookup for dotenvx

如何安装 @dotenvx/providers?

在项目目录运行 npm install @dotenvx/providers,或使用 pnpm add / yarn add / bun add。

@dotenvx/providers 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/dotenvx__providers 是否存在。

@dotenvx/providers 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@dotenvx/providers 可以商用吗?

@dotenvx/providers 使用 BSD-3-Clause 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。另外不得用原作者名义为衍生产品背书。以上为概括,不构成法律意见,请以许可原文为准。

@dotenvx/providers 的下载量有多少?

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

@dotenvx/providers 还在维护吗?

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