Skip to content

Commit b348236

Browse files
authored
housekeeping (#20)
* housekeeping * add encoding tests * modernize encoding.ts * improve exmample * llm typo? wtf * fix encoding * upgrade checkout action version * fix node ver to be >=25 to use native encoding * fix dep versions
1 parent 89ba466 commit b348236

23 files changed

+317
-209
lines changed

.github/actions/run-pebble/action.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Run Pebble
2+
description: Run pabble......
23

34
runs:
45
using: "composite"

.github/workflows/ci.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
name: "Format & Lint & Type Check"
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v6
1515
- uses: denoland/setup-deno@v2
1616
with:
1717
deno-version: v2.x # Run with latest stable Deno.
@@ -22,7 +22,7 @@ jobs:
2222
name: "Unit Test (Deno)"
2323
runs-on: ubuntu-latest
2424
steps:
25-
- uses: actions/checkout@v3
25+
- uses: actions/checkout@v6
2626
- uses: denoland/setup-deno@v2
2727
with:
2828
deno-version: v2.x # Run with latest stable Deno.
@@ -31,11 +31,11 @@ jobs:
3131
name: "Unit Test (Node.js)"
3232
runs-on: ubuntu-latest
3333
steps:
34-
- uses: actions/checkout@v3
34+
- uses: actions/checkout@v6
3535
- uses: denoland/setup-deno@v2
3636
with:
3737
deno-version: v2.x # Run with latest stable Deno.
3838
- uses: actions/setup-node@v4
3939
with:
40-
node-version: ">=20"
40+
node-version: ">=25"
4141
- run: deno task build:npm:unit

.github/workflows/e2e.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
build:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v4
12+
- uses: actions/checkout@v6
1313
- uses: denoland/setup-deno@v2
1414
with:
1515
deno-version: v2.x # Run with latest stable Deno.

.github/workflows/integration.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
name: Deno
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v4
14+
- uses: actions/checkout@v6
1515

1616
- uses: denoland/setup-deno@v2
1717
with:
@@ -25,15 +25,15 @@ jobs:
2525
name: Node
2626
runs-on: ubuntu-latest
2727
steps:
28-
- uses: actions/checkout@v4
28+
- uses: actions/checkout@v6
2929

3030
- uses: denoland/setup-deno@v2
3131
with:
3232
deno-version: v2.x # Run with latest stable Deno.
3333

34-
- uses: actions/setup-node@v4
34+
- uses: actions/setup-node@v6
3535
with:
36-
node-version: ">=20"
36+
node-version: ">=25"
3737

3838
- name: Run Pebble
3939
uses: ./.github/actions/run-pebble

.github/workflows/publish.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
id-token: write
1414

1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v6
1717

1818
- name: Publish package
1919
run: npx jsr publish
@@ -28,10 +28,10 @@ jobs:
2828
- uses: denoland/setup-deno@v2
2929
with:
3030
deno-version: v2.x # Run with latest stable Deno.
31-
- uses: actions/setup-node@v4
31+
- uses: actions/setup-node@v6
3232
with:
3333
registry-url: "https://registry.npmjs.org"
34-
- uses: actions/checkout@v4
34+
- uses: actions/checkout@v6
3535
- name: Build for NPM
3636
run: deno task build:npm
3737
- name: Publish to npm

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"prettier.enable": false,
33
"deno.enable": true,
44
"deno.lint": true,
5+
"typescript.validate.enable": false,
56
"editor.formatOnSave": true,
67
"editor.defaultFormatter": "denoland.vscode-deno",
78
"editor.codeActionsOnSave": {

AGENTS.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# AGENTS.md
2+
3+
This file provides guidance to AI Agents when working with code in this
4+
repository.
5+
6+
## Project Overview
7+
8+
`@fishballpkg/acme` is a zero-dependency, minimalistic, opinionated ACME client
9+
written in TypeScript. It is designed to be platform-agnostic, running on Deno,
10+
Node.js, and other modern JavaScript environments that support `WebCrypto` and
11+
`fetch`.
12+
13+
## Development Commands
14+
15+
This project uses Deno for development.
16+
17+
### Testing
18+
19+
There are multiple tiers of tests in this repository:
20+
21+
- **Unit Tests**: Run purely in-process, mocking external requests where
22+
necessary.
23+
- Command: `deno task test:unit`
24+
- Location: `src/**/*.test.ts`
25+
26+
- **Integration Tests**: Run against a local Pebble instance (Let's Encrypt's
27+
ACME test server).
28+
- **Prerequisites**: Docker must be running.
29+
- **Start Pebble**: `deno task pebble:start` (starts Pebble and `challtestsrv`
30+
via Docker Compose)
31+
- **Run Integration Tests**: `deno task test:integration`
32+
- **Stop Pebble**: `deno task pebble:stop`
33+
- Location: `integration/`
34+
35+
- **E2E Tests**:
36+
- Command: `deno task test:e2e`
37+
- Location: `e2e/`
38+
39+
### Building
40+
41+
The project is natively TypeScript/Deno but builds to NPM for Node.js
42+
compatibility using `dnt`.
43+
44+
- **Build for NPM**: `deno task build:npm`
45+
- This script (`scripts/build-npm.ts`) generates the `dist-npm` directory.
46+
47+
### Linting & Formatting
48+
49+
- **Lint**: Use `deno lint` standard command.
50+
- **Format**: Use `deno fmt` standard command.
51+
52+
## High-Level Architecture
53+
54+
The codebase follows the hierarchy of the ACME standard (RFC 8555).
55+
56+
### Core Components (`src/`)
57+
58+
- **Entry Point**: `src/mod.ts` exports the public API.
59+
- **AcmeClient** (`src/AcmeClient.ts`): The main entry point for users.
60+
Initializes with a directory URL.
61+
- **JWS Signing**: Handles JSON Web Signature (JWS) wrapping for requests
62+
using `src/utils/jws.ts` and `src/utils/crypto.ts`.
63+
- **Nonce Management**: detailed in `AcmeClient` private methods.
64+
- **AcmeAccount** (`src/AcmeAccount.ts`): Represents a registered account on the
65+
ACME server.
66+
- **AcmeOrder** (`src/AcmeOrder.ts`): Represents a certificate order. Handles
67+
polling for status steps.
68+
- **AcmeAuthorization** (`src/AcmeAuthorization.ts`): Represents validation for
69+
a specific domain.
70+
- **AcmeChallenge** (`src/AcmeChallenge.ts`): Represents a specific challenge
71+
method (e.g., `dns-01`).
72+
73+
### Utilities
74+
75+
- **`src/utils/`**: Internal helpers.
76+
- `jws.ts`: JWS signing logic.
77+
- `crypto.ts`: WebCrypto wrappers.
78+
- `generateCSR.ts`: Logic to generate valid Certificate Signing Requests (CSR)
79+
without external dependencies like OpenSSL.
80+
- **`src/ACME_DIRECTORY_URLS.ts`**: Constants for common ACME directories (Let's
81+
Encrypt, etc.).
82+
83+
### Workflows
84+
85+
- **`src/AcmeWorkflows.ts`**: Contains high-level abstraction functions (e.g.,
86+
`requestCertificate`) that bundle multiple steps (order creation, challenge
87+
solving, polling, finalization) into single calls for convenience.
88+
89+
## Design Principles
90+
91+
1. **Zero Dependencies**: Do not introduce NPM dependencies or external CLIs
92+
(like OpenSSL). Everything must be implemented using standard Web APIs
93+
(`WebCrypto`, `fetch`) or built from scratch (like the CSR generator).
94+
2. **Platform Agnostic**: Code must write to Deno standards but be compatible
95+
with Node.js via the build script. Avoid Deno-specific namespaces (`Deno.*`)
96+
in the `src/` directory unless strictly necessary or valid polyfills exist.
97+
3. **Opinionated**: Focus on `DNS-01` challenge and `ECDSA P-256` keys. Support
98+
for other methods is secondary.

deno.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,22 @@
1111
},
1212
"tasks": {
1313
"test:e2e": "deno test --lock -A e2e",
14-
"test:unit": "deno test --lock --allow-run=openssl src",
15-
"test:integration": "deno test --lock --unsafely-ignore-certificate-errors=localhost --allow-net=\"localhost,127.0.0.1,8.8.8.8,[2001:4860:4860::8888]\" integration",
14+
"test:unit": "deno test --lock -P=unit src",
15+
"test:integration": "deno test --lock --unsafely-ignore-certificate-errors=localhost -P=integration integration",
1616
"pebble:start": "docker compose -f integration/docker-compose.yaml up",
1717
"pebble:stop": "docker compose -f integration/docker-compose.yaml down",
1818
"build:npm": "deno run --lock -A scripts/build-npm.ts",
1919
"build:npm:integration": "deno run --lock -A scripts/build-npm-integration.ts",
2020
"build:npm:unit": "deno run --lock -A scripts/build-npm-unit.ts"
2121
},
22+
"permissions": {
23+
"unit": {
24+
"run": ["openssl"]
25+
},
26+
"integration": {
27+
"net": ["localhost", "127.0.0.1", "8.8.8.8", "[2001:4860:4860::8888]"]
28+
}
29+
},
2230
"compilerOptions": {
2331
"strict": true,
2432
"noUncheckedIndexedAccess": true,
@@ -30,6 +38,5 @@
3038
"exclude": ["**/*.test.ts"]
3139
},
3240
"exclude": ["dist*"],
33-
"imports": {},
3441
"license": "MIT"
3542
}

0 commit comments

Comments
 (0)