@adobe/helix-shared-secrets

中文文档
2.3.6发布于 2026/08/31Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 2916

Shared modules of the Helix Project - secrets

原始使用文档
文档目录4 节
  1. Usage
  2. Usage of secrets Wrapper with Custom nameFunction
  3. Example 1: Using a Simple Custom Path
  4. Example 2: Extending the Default Path

Helix Shared - Secrets Wrapper

When writing universal serverless functions with Helix Universal, then helix-shared-secrets will wrap your function to load secrets from the respective secrets provider of the cloud function provider.

Note: Currently only AWS secrets manager is supported.

By default, the secrets with the name <package>/<function name> (for example /helix-services/helix-admin) is loaded and added to the context and process.env, overwriting former secrets.

Usage

import wrap from '@adobe/helix-shared-wrap';
import secrets from '@adobe/helix-shared-secrets';

...

export const main = wrap(run)
  .with(secrets);

Usage of secrets Wrapper with Custom nameFunction

The secrets wrapper can be customized by providing a nameFunction within the options. This function can dynamically determine the secrets path based on the context (ctx) and options (opts), or use a default path. Here are two example usages of the secrets wrapper with different types of nameFunction.

Example 1: Using a Simple Custom Path

In this example, the nameFunction returns a hardcoded secrets path, ignoring the default path and context.

const nameFunction = () => {
  return "/my-custom-secrets-path";
};

...

export const main = wrap(run)
  .with(secrets, { name: nameFunction });

In this scenario, regardless of the context or default path, the secrets path will always be "/my-custom-secrets-path".

Example 2: Extending the Default Path

Here, the nameFunction appends "/ci" to the default path. This is useful for scenarios where the path needs to be environment-specific.

const nameFunction = (opts, ctx, defaultPath) => {
  return ctx.func.version === "ci" ? `${defaultPath}/ci` : defaultPath;
};

export const main = wrap(run)
  .with(secrets, { name: nameFunction });

In this case, the secrets path is dynamically constructed based on the default path, which is then extended with "/ci", allowing for environment-specific configurations.

版本与发布记录

@adobe/helix-shared-secrets 共发布 28 个版本,首次发布于 2023/01/25;过去 12 个月发布了 6 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.3.6latest2026/08/312 个月前
2.3.52026/07/143 个月前
2.3.42026/05/265 个月前
2.3.32026/05/215 个月前
2.3.22026/05/195 个月前
2.3.12026/05/125 个月前

关于 @adobe/helix-shared-secrets 的常见问题

@adobe/helix-shared-secrets 是什么?

Shared modules of the Helix Project - secrets

如何安装 @adobe/helix-shared-secrets?

在项目目录运行 npm install @adobe/helix-shared-secrets,或使用 pnpm add / yarn add / bun add。

@adobe/helix-shared-secrets 支持 TypeScript 吗?

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

@adobe/helix-shared-secrets 支持 ESM 还是 CommonJS?

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

@adobe/helix-shared-secrets 可以商用吗?

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

@adobe/helix-shared-secrets 的下载量有多少?

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

@adobe/helix-shared-secrets 还在维护吗?

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