@documenso/pdf-sign

中文文档
0.1.0发布于 2024/03/15AGPL-3.0TypeScriptCommonJS零依赖近 30 天下载 4543

This package provides functionality to sign PDF documents using various signing methods, including private keys, P12 containers, and Google Cloud. It is designed to be used with the Documenso platform.

原始使用文档
文档目录10 节
  1. Installation
  2. Usage
  3. Signing with a Private Key
  4. Signing with a P12 Container
  5. Signing with Google Cloud
  6. API
  7. signWithPrivateKey(options)
  8. signWithP12(options)
  9. signWithGCloud(options)
  10. License

@documenso/pdf-sign

This package provides functionality to sign PDF documents using various signing methods, including private keys, P12 containers, and Google Cloud. It is designed to be used with the Documenso platform.

Installation

To install the package, run:

npm install @documenso/pdf-sign

Usage

Signing with a Private Key

const { signWithPrivateKey } = require('@documenso/pdf-sign');

const content = Buffer.from('...'); // PDF content
const cert = Buffer.from('...'); // Certificate in PEM format
const privateKey = Buffer.from('...'); // Private key in PEM format

const signedPdf = await signWithPrivateKey({
  content,
  cert,
  privateKey,
  // Optional fields
  signingTime: '2023-03-15T12:00:00Z', // ISO 8601 format
  timestampServer: 'http://timestamp.server',
});

Signing with a P12 Container

const { signWithP12 } = require('@documenso/pdf-sign');

const content = Buffer.from('...'); // PDF content
const p12 = Buffer.from('...'); // P12 container

const signedPdf = await signWithP12({
  content,
  cert: p12,
  // Optional fields
  password: 'p12password',
  signingTime: '2023-03-15T12:00:00Z', // ISO 8601 format
  timestampServer: 'http://timestamp.server',
});

Signing with Google Cloud

const { signWithGCloud } = require('@documenso/pdf-sign');

const content = Buffer.from('...'); // PDF content
const cert = Buffer.from('...'); // Certificate in PEM format
const keyPath = 'projects/project-id/locations/global/keyRings/keyring-name/cryptoKeys/key-name';

const signedPdf = await signWithGCloud({
  content,
  cert,
  keyPath,
  // Optional fields
  signingTime: '2023-03-15T12:00:00Z', // ISO 8601 format
  timestampServer: 'http://timestamp.server',
});

API

signWithPrivateKey(options)

  • options.content (Buffer): The PDF content to be signed.
  • options.cert (Buffer): The certificate in PEM format.
  • options.privateKey (Buffer): The private key in PEM format.
  • options.signingTime (string, optional): The signing time in ISO 8601 format.
  • options.timestampServer (string, optional): The URL of the timestamp server.

Returns a Promise that resolves to a Buffer containing the signed PDF.

signWithP12(options)

  • options.content (Buffer): The PDF content to be signed.
  • options.cert (Buffer): The P12 container.
  • options.password (string, optional): The password for the P12 container.
  • options.signingTime (string, optional): The signing time in ISO 8601 format.
  • options.timestampServer (string, optional): The URL of the timestamp server.

Returns a Promise that resolves to a Buffer containing the signed PDF.

signWithGCloud(options)

  • options.content (Buffer): The PDF content to be signed.
  • options.cert (Buffer): The certificate in PEM format.
  • options.keyPath (string): The Google Cloud key path.
  • options.signingTime (string, optional): The signing time in ISO 8601 format.
  • options.timestampServer (string, optional): The URL of the timestamp server.

Returns a Promise that resolves to a Buffer containing the signed PDF.

License

This package is licensed under the AGPL-3.0 License.

版本与发布记录

@documenso/pdf-sign 共发布 1 个版本,首次发布于 2024/03/15;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.1.0latest2024/03/152 年前

关于 @documenso/pdf-sign 的常见问题

@documenso/pdf-sign 是什么?

This package provides functionality to sign PDF documents using various signing methods, including private keys, P12 containers, and Google Cloud. It is designed to be used with the Documenso platform.

如何安装 @documenso/pdf-sign?

在项目目录运行 npm install @documenso/pdf-sign,或使用 pnpm add / yarn add / bun add。

@documenso/pdf-sign 支持 TypeScript 吗?

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

@documenso/pdf-sign 支持 ESM 还是 CommonJS?

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

@documenso/pdf-sign 需要什么版本的 Node.js?

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

@documenso/pdf-sign 可以商用吗?

@documenso/pdf-sign 使用 AGPL-3.0 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@documenso/pdf-sign 的下载量有多少?

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

@documenso/pdf-sign 还在维护吗?

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