@kagal/acme 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,583 @@
1
+ /** Identifier type values. */
2
+ declare const identifierTypes: readonly ["dns", "ip"];
3
+ /**
4
+ * Identifier type union.
5
+ *
6
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-9.7.7}
7
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8738}
8
+ */
9
+ type IdentifierType = (typeof identifierTypes)[number];
10
+ /** Runtime set of valid identifier types. */
11
+ declare const IdentifierTypes: ReadonlySet<IdentifierType>;
12
+
13
+ /** Order status values (RFC 8555 §7.1.3). */
14
+ declare const orderStatuses: readonly ["pending", "ready", "processing", "valid", "invalid"];
15
+ /**
16
+ * Order status union type.
17
+ *
18
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-7.1.3}
19
+ */
20
+ type OrderStatus = (typeof orderStatuses)[number];
21
+ /** Runtime set of valid order statuses. */
22
+ declare const OrderStatuses: ReadonlySet<OrderStatus>;
23
+ /** Authorization status values (RFC 8555 §7.1.4). */
24
+ declare const authorizationStatuses: readonly ["pending", "valid", "invalid", "deactivated", "expired", "revoked"];
25
+ /**
26
+ * Authorisation status union type.
27
+ *
28
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-7.1.4}
29
+ */
30
+ type AuthorizationStatus = (typeof authorizationStatuses)[number];
31
+ /** Runtime set of valid authorisation statuses. */
32
+ declare const AuthorizationStatuses: ReadonlySet<AuthorizationStatus>;
33
+ /** Challenge status values (RFC 8555 §7.1.5). */
34
+ declare const challengeStatuses: readonly ["pending", "processing", "valid", "invalid"];
35
+ /**
36
+ * Challenge status union type.
37
+ *
38
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-7.1.5}
39
+ */
40
+ type ChallengeStatus = (typeof challengeStatuses)[number];
41
+ /** Runtime set of valid challenge statuses. */
42
+ declare const ChallengeStatuses: ReadonlySet<ChallengeStatus>;
43
+ /** Account status values (RFC 8555 §7.1.2). */
44
+ declare const accountStatuses: readonly ["valid", "deactivated", "revoked"];
45
+ /**
46
+ * Account status union type.
47
+ *
48
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-7.1.2}
49
+ */
50
+ type AccountStatus = (typeof accountStatuses)[number];
51
+ /** Runtime set of valid account statuses. */
52
+ declare const AccountStatuses: ReadonlySet<AccountStatus>;
53
+
54
+ /**
55
+ * Base64url-encoded string without padding
56
+ * (RFC 7515 §2).
57
+ *
58
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc7515#section-2}
59
+ */
60
+ type Base64url = string;
61
+
62
+ /**
63
+ * Optional JWK members shared by all key types (RFC 7517 §4).
64
+ *
65
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc7517#section-4}
66
+ */
67
+ type JWKBase = {
68
+ /** Algorithm (§4.4). */
69
+ 'alg'?: string;
70
+ /** Key operations (§4.3). */
71
+ 'key_ops'?: readonly string[];
72
+ /** Key ID (§4.5). */
73
+ 'kid'?: string;
74
+ /** Public key use (§4.2). */
75
+ 'use'?: string;
76
+ /** X.509 certificate chain (§4.7). */
77
+ 'x5c'?: readonly string[];
78
+ /** X.509 SHA-1 thumbprint (§4.8). */
79
+ 'x5t'?: string;
80
+ /** X.509 SHA-256 thumbprint (§4.9). */
81
+ 'x5t#S256'?: string;
82
+ /** X.509 URL (§4.6). */
83
+ 'x5u'?: string;
84
+ };
85
+ /**
86
+ * EC key (RFC 7518 §6.2).
87
+ *
88
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc7518#section-6.2}
89
+ */
90
+ type ECJWK = JWKBase & {
91
+ kty: 'EC';
92
+ crv: string;
93
+ x: string;
94
+ y: string;
95
+ };
96
+ /**
97
+ * OKP key (RFC 8037 §2).
98
+ *
99
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8037#section-2}
100
+ */
101
+ type OKPJWK = JWKBase & {
102
+ kty: 'OKP';
103
+ crv: string;
104
+ x: string;
105
+ };
106
+ /**
107
+ * RSA key (RFC 7518 §6.3).
108
+ *
109
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc7518#section-6.3}
110
+ */
111
+ type RSAJWK = JWKBase & {
112
+ kty: 'RSA';
113
+ e: string;
114
+ n: string;
115
+ };
116
+ /**
117
+ * JWK — discriminated union on `kty`.
118
+ *
119
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc7517}
120
+ */
121
+ type JWK = ECJWK | OKPJWK | RSAJWK;
122
+
123
+ /**
124
+ * Flattened JWS Serialization (RFC 7515 §7.2.2).
125
+ *
126
+ * @remarks
127
+ * ACME uses the flattened serialisation exclusively —
128
+ * compact and general forms are not used. `payload`
129
+ * may be empty for POST-as-GET requests (RFC 8555
130
+ * §6.3).
131
+ *
132
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc7515#section-7.2.2}
133
+ */
134
+ interface FlattenedJWS {
135
+ /** Base64url-encoded protected header. */
136
+ protected: Base64url;
137
+ /** Base64url-encoded payload (empty for POST-as-GET). */
138
+ payload: string;
139
+ /** Base64url-encoded signature. */
140
+ signature: Base64url;
141
+ }
142
+ /**
143
+ * JWS protected header (RFC 7515 §4.1).
144
+ *
145
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc7515#section-4.1}
146
+ */
147
+ interface JWSProtectedHeader {
148
+ /** Signature algorithm (e.g. 'ES256', 'EdDSA'). */
149
+ alg: string;
150
+ /** JSON Web Key (RFC 7515 §4.1.3). */
151
+ jwk?: JWK;
152
+ /** Key ID (RFC 7515 §4.1.4). */
153
+ kid?: string;
154
+ }
155
+ /**
156
+ * ACME protected header fields (RFC 8555 §6.2).
157
+ *
158
+ * @remarks
159
+ * Extends {@link JWSProtectedHeader} with ACME-required
160
+ * `nonce` and `url`. Inner JWS objects (EAB, key change)
161
+ * omit `nonce` and use {@link JWSProtectedHeader} directly.
162
+ *
163
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-6.2}
164
+ */
165
+ interface ACMEProtectedHeader extends JWSProtectedHeader {
166
+ /** Anti-replay nonce (RFC 8555 §6.5). */
167
+ nonce: string;
168
+ /** Request URL (RFC 8555 §6.4). */
169
+ url: string;
170
+ }
171
+ /**
172
+ * Outer ACME request header with `jwk` XOR `kid`.
173
+ *
174
+ * @remarks
175
+ * `jwk` for newAccount and revokeCert-by-cert-key;
176
+ * `kid` (account URL) for all other requests.
177
+ * Servers MUST reject headers containing both.
178
+ *
179
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-6.2}
180
+ */
181
+ type ACMERequestHeader = ACMEProtectedHeader & {
182
+ /** Account public key. */
183
+ jwk: JWK;
184
+ kid?: never;
185
+ } | ACMEProtectedHeader & {
186
+ jwk?: never;
187
+ /** Account URL. */
188
+ kid: string;
189
+ };
190
+
191
+ /**
192
+ * External account binding (RFC 8555 §7.3.4).
193
+ *
194
+ * Structurally identical to {@link FlattenedJWS} —
195
+ * the payload is the account's public key, signed
196
+ * with the EAB HMAC key.
197
+ *
198
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-7.3.4}
199
+ */
200
+ type ExternalAccountBinding = FlattenedJWS;
201
+ /**
202
+ * ACME account object.
203
+ *
204
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-7.1.2}
205
+ */
206
+ interface Account {
207
+ /** Account state. */
208
+ status: AccountStatus;
209
+ /** Contact URIs (`mailto:...`). */
210
+ contact?: string[];
211
+ /** EAB JWS (registration only). */
212
+ externalAccountBinding?: ExternalAccountBinding;
213
+ /** URL to order list. */
214
+ orders: string;
215
+ /** Whether ToS was accepted. */
216
+ termsOfServiceAgreed?: boolean;
217
+ }
218
+
219
+ /**
220
+ * Domain or IP identifier.
221
+ *
222
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-9.7.7}
223
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8738}
224
+ */
225
+ interface Identifier {
226
+ /** Identifier type — see {@link IdentifierType}. */
227
+ type: IdentifierType;
228
+ /** Domain name or IP address. */
229
+ value: string;
230
+ }
231
+
232
+ /**
233
+ * Per-identifier sub-error (RFC 8555 §6.7.1).
234
+ *
235
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-6.7.1}
236
+ */
237
+ interface Subproblem {
238
+ /** URN error type. */
239
+ type: string;
240
+ /** Human-readable description. */
241
+ detail?: string;
242
+ /** Related identifier. */
243
+ identifier?: Identifier;
244
+ /** URI reference for this occurrence (RFC 7807 §3.1). */
245
+ instance?: string;
246
+ /** HTTP status code. */
247
+ status?: number;
248
+ /** Human-readable summary (RFC 7807 §3.1). */
249
+ title?: string;
250
+ }
251
+ /**
252
+ * ACME problem document (RFC 7807).
253
+ *
254
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc7807}
255
+ */
256
+ interface Problem extends Subproblem {
257
+ /** Per-identifier errors. */
258
+ subproblems?: Subproblem[];
259
+ }
260
+
261
+ /**
262
+ * Shared challenge fields.
263
+ *
264
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-7.1.5}
265
+ */
266
+ interface ChallengeBase {
267
+ /** Error details. */
268
+ error?: Problem;
269
+ /** Challenge state. */
270
+ status: ChallengeStatus;
271
+ /** Challenge URL. */
272
+ url: string;
273
+ /** RFC 3339 validation timestamp. */
274
+ validated?: string;
275
+ }
276
+ /**
277
+ * HTTP-01 challenge (RFC 8555 §8.3).
278
+ *
279
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-8.3}
280
+ */
281
+ type HTTPChallenge = ChallengeBase & {
282
+ type: 'http-01';
283
+ token: string;
284
+ };
285
+ /**
286
+ * DNS-01 challenge (RFC 8555 §8.4).
287
+ *
288
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-8.4}
289
+ */
290
+ type DNSChallenge = ChallengeBase & {
291
+ type: 'dns-01';
292
+ token: string;
293
+ };
294
+ /**
295
+ * TLS-ALPN-01 challenge (RFC 8737).
296
+ *
297
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8737}
298
+ */
299
+ type TLSALPNChallenge = ChallengeBase & {
300
+ type: 'tls-alpn-01';
301
+ token: string;
302
+ };
303
+ /**
304
+ * Discriminated challenge union.
305
+ *
306
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-8}
307
+ */
308
+ type Challenge = DNSChallenge | HTTPChallenge | TLSALPNChallenge;
309
+
310
+ /**
311
+ * Shared authorisation fields.
312
+ *
313
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-7.1.4}
314
+ */
315
+ interface AuthorizationBase {
316
+ /** Associated challenges. */
317
+ challenges: Challenge[];
318
+ /** RFC 3339 expiry timestamp. */
319
+ expires?: string;
320
+ /** Subject identifier. */
321
+ identifier: Identifier;
322
+ /** True for wildcard authorisations. */
323
+ wildcard?: boolean;
324
+ }
325
+ /**
326
+ * Discriminated authorisation union.
327
+ *
328
+ * @remarks
329
+ * `expires` is required when status is `'valid'`.
330
+ *
331
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-7.1.4}
332
+ */
333
+ type Authorization = AuthorizationBase & {
334
+ /** Required when valid. */
335
+ expires: string;
336
+ status: 'valid';
337
+ } | AuthorizationBase & {
338
+ status: 'pending';
339
+ } | AuthorizationBase & {
340
+ status: Exclude<AuthorizationStatus, 'pending' | 'valid'>;
341
+ };
342
+
343
+ /**
344
+ * Directory metadata.
345
+ *
346
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-7.1.1}
347
+ */
348
+ interface DirectoryMeta {
349
+ /** CAA hostnames. */
350
+ caaIdentities?: string[];
351
+ /** Whether EAB is required. */
352
+ externalAccountRequired?: boolean;
353
+ /** URL to terms of service. */
354
+ termsOfService?: string;
355
+ /** CA information URL. */
356
+ website?: string;
357
+ /**
358
+ * Profile name to description map
359
+ * (draft-ietf-acme-profiles).
360
+ *
361
+ * @beta
362
+ * @see {@link https://datatracker.ietf.org/doc/draft-ietf-acme-profiles/}
363
+ */
364
+ profiles?: Record<string, string>;
365
+ }
366
+ /**
367
+ * ACME directory resource.
368
+ *
369
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-7.1.1}
370
+ */
371
+ interface Directory {
372
+ /** Key rollover URL. */
373
+ keyChange: string;
374
+ /** Server metadata. */
375
+ meta?: DirectoryMeta;
376
+ /** Account creation URL. */
377
+ newAccount: string;
378
+ /** Pre-authorisation URL (optional). */
379
+ newAuthz?: string;
380
+ /** Nonce endpoint URL. */
381
+ newNonce: string;
382
+ /** Order creation URL. */
383
+ newOrder: string;
384
+ /** Revocation URL. */
385
+ revokeCert: string;
386
+ /**
387
+ * ARI endpoint URL (RFC 9773 §3).
388
+ *
389
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc9773#section-3}
390
+ */
391
+ renewalInfo?: string;
392
+ }
393
+
394
+ /**
395
+ * ARI certificate identifier —
396
+ * `base64url(AKI) + "." + base64url(Serial)`.
397
+ *
398
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc9773#section-4.1}
399
+ */
400
+ type CertID = string;
401
+ /**
402
+ * Renewal information (RFC 9773 §4).
403
+ *
404
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc9773#section-4}
405
+ */
406
+ interface RenewalInfo {
407
+ /** Suggested renewal window. */
408
+ suggestedWindow: {
409
+ /** RFC 3339 end timestamp. */
410
+ end: string;
411
+ /** RFC 3339 start timestamp. */
412
+ start: string;
413
+ };
414
+ /** URL explaining the renewal suggestion. */
415
+ explanationURL?: string;
416
+ }
417
+
418
+ /**
419
+ * ACME order object.
420
+ *
421
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-7.1.3}
422
+ */
423
+ interface Order {
424
+ /** Order state. */
425
+ status: OrderStatus;
426
+ /** Authorization URLs. */
427
+ authorizations: string[];
428
+ /** Certificate download URL. */
429
+ certificate?: string;
430
+ /** Error details. */
431
+ error?: Problem;
432
+ /** RFC 3339 expiry timestamp. */
433
+ expires?: string;
434
+ /** Finalize URL. */
435
+ finalize: string;
436
+ /** Requested domains/IPs. */
437
+ identifiers: Identifier[];
438
+ /** Certificate validity end. */
439
+ notAfter?: string;
440
+ /** Certificate validity start. */
441
+ notBefore?: string;
442
+ /**
443
+ * Selected profile (draft-ietf-acme-profiles).
444
+ *
445
+ * @beta
446
+ * @see {@link https://datatracker.ietf.org/doc/draft-ietf-acme-profiles/}
447
+ */
448
+ profile?: string;
449
+ /**
450
+ * ARI predecessor certID (RFC 9773 §5).
451
+ *
452
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc9773#section-5}
453
+ */
454
+ replaces?: CertID;
455
+ }
456
+
457
+ /**
458
+ * Order finalisation payload.
459
+ *
460
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-7.4}
461
+ */
462
+ type Finalize = {
463
+ /** Base64url-encoded DER CSR. */
464
+ csr: Base64url;
465
+ };
466
+
467
+ /**
468
+ * Inner JWS payload for key rollover.
469
+ *
470
+ * @remarks
471
+ * Signed with the new key; the outer JWS is signed
472
+ * with the old key.
473
+ *
474
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-7.3.5}
475
+ */
476
+ type KeyChange = {
477
+ /** Account URL. */
478
+ account: string;
479
+ /** Old account public key. */
480
+ oldKey: JWK;
481
+ };
482
+
483
+ /**
484
+ * newAccount request payload.
485
+ *
486
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-7.3}
487
+ */
488
+ type NewAccount = {
489
+ /** Contact URIs. */
490
+ contact?: string[];
491
+ /** External account binding JWS. */
492
+ externalAccountBinding?: ExternalAccountBinding;
493
+ /** Return existing account only. */
494
+ onlyReturnExisting?: boolean;
495
+ /** ToS agreement. */
496
+ termsOfServiceAgreed?: boolean;
497
+ };
498
+ /**
499
+ * Account deactivation payload.
500
+ *
501
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-7.3.6}
502
+ */
503
+ type DeactivateAccount = {
504
+ status: 'deactivated';
505
+ };
506
+
507
+ /**
508
+ * Pre-authorisation request payload.
509
+ *
510
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-7.4.1}
511
+ */
512
+ type NewAuthz = {
513
+ /** Identifier to pre-authorise. */
514
+ identifier: Identifier;
515
+ };
516
+ /**
517
+ * Authorisation deactivation payload.
518
+ *
519
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-7.5.2}
520
+ */
521
+ type DeactivateAuthorization = {
522
+ status: 'deactivated';
523
+ };
524
+
525
+ /**
526
+ * newOrder request payload.
527
+ *
528
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-7.4}
529
+ */
530
+ type NewOrder = {
531
+ /** Requested identifiers. */
532
+ identifiers: Identifier[];
533
+ /** Certificate validity end (RFC 3339). */
534
+ notAfter?: string;
535
+ /** Certificate validity start (RFC 3339). */
536
+ notBefore?: string;
537
+ /**
538
+ * Desired profile name.
539
+ *
540
+ * @beta
541
+ * @see {@link https://datatracker.ietf.org/doc/draft-ietf-acme-profiles/}
542
+ */
543
+ profile?: string;
544
+ /**
545
+ * ARI predecessor certID (RFC 9773 §5).
546
+ *
547
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc9773#section-5}
548
+ */
549
+ replaces?: CertID;
550
+ };
551
+
552
+ /**
553
+ * CRL reason code (RFC 5280 §5.3.1).
554
+ *
555
+ * @remarks
556
+ * Code 7 is not used.
557
+ *
558
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc5280#section-5.3.1}
559
+ */
560
+ type CRLReasonCode = 0 | // unspecified
561
+ 1 | // keyCompromise
562
+ 2 | // cACompromise
563
+ 3 | // affiliationChanged
564
+ 4 | // superseded
565
+ 5 | // cessationOfOperation
566
+ 6 | // certificateHold
567
+ 8 | // removeFromCRL
568
+ 9 | // privilegeWithdrawn
569
+ 10;
570
+ /**
571
+ * Certificate revocation payload.
572
+ *
573
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8555#section-7.6}
574
+ */
575
+ type RevokeCert = {
576
+ /** Base64url-encoded DER certificate. */
577
+ certificate: Base64url;
578
+ /** CRL reason code (RFC 5280 §5.3.1). */
579
+ reason?: CRLReasonCode;
580
+ };
581
+
582
+ export { OrderStatuses as L, accountStatuses as U, authorizationStatuses as V, challengeStatuses as W, identifierTypes as X, orderStatuses as Y, AccountStatuses as d, AuthorizationStatuses as h, ChallengeStatuses as m, IdentifierTypes as u };
583
+ export type { ACMEProtectedHeader as A, Base64url as B, CRLReasonCode as C, DNSChallenge as D, ECJWK as E, Finalize as F, OrderStatus as G, HTTPChallenge as H, Identifier as I, JWK as J, KeyChange as K, RenewalInfo as M, NewAccount as N, OKPJWK as O, Problem as P, RevokeCert as Q, RSAJWK as R, Subproblem as S, TLSALPNChallenge as T, ACMERequestHeader as a, Account as b, AccountStatus as c, Authorization as e, AuthorizationBase as f, AuthorizationStatus as g, CertID as i, Challenge as j, ChallengeBase as k, ChallengeStatus as l, DeactivateAccount as n, DeactivateAuthorization as o, Directory as p, DirectoryMeta as q, ExternalAccountBinding as r, FlattenedJWS as s, IdentifierType as t, JWKBase as v, JWSProtectedHeader as w, NewAuthz as x, NewOrder as y, Order as z };