@acme-ra/client 中文文档教程
@acme-ra/client
向 ACME API 提供了一个 JavaScript/TypeScript 客户端 API
Installation
该项目使用 NPM
npm install @acme-ra/client
:使用 Yarn:
yarn add @acme-ra/client
Usage
NodeJS
const acme = require("@acme-ra/client");
NodeJS 需要设置 WebCrypto 提供程序并为客户端获取函数。
const fetch = require("node-fetch");
const { Crypto } = require("@peculiar/webcrypto");
const crypto = new Crypto();
const alg = { name: "ECDSA", namedCurve: "P-256" };
const keys = await crypto.subtle.generateKey(alg, false, ["sign", "verify"]);
const client = await ApiClient.create(
keys,
"http://localhost:4000/acme/directory",
{
fetch,
crypto,
});
Browser
@acme-ra/client
的每个版本都会有新构建的 ./build/acme.min.js
供在浏览器中使用。 要访问模块类,请使用 acme
全局变量。
警告:出于安全原因,我们建议托管和控制您自己的副本
<script src="https://unpkg.com/@acme-ra/client"></script>
@acme-ra/client
This project provides a JavaScript/TypeScript client API into the ACME API
Installation
Using NPM:
npm install @acme-ra/client
Using Yarn:
yarn add @acme-ra/client
Usage
NodeJS
const acme = require("@acme-ra/client");
NodeJS requires to set WebCrypto provider and fetch function to client.
const fetch = require("node-fetch");
const { Crypto } = require("@peculiar/webcrypto");
const crypto = new Crypto();
const alg = { name: "ECDSA", namedCurve: "P-256" };
const keys = await crypto.subtle.generateKey(alg, false, ["sign", "verify"]);
const client = await ApiClient.create(
keys,
"http://localhost:4000/acme/directory",
{
fetch,
crypto,
});
Browser
Every release of @acme-ra/client
will have new build of ./build/acme.min.js
for use in the browser. To get access to module classes use acme
global variable.
WARN: We recommend hosting and controlling your own copy for security reasons
<script src="https://unpkg.com/@acme-ra/client"></script>