micro509 0.8.0 → 0.10.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.
Files changed (108) hide show
  1. package/dist/index.d.ts +4 -4
  2. package/dist/index.js +15 -15
  3. package/dist/internal/asn1/asn1.js +145 -186
  4. package/dist/internal/asn1/asn1.js.map +1 -0
  5. package/dist/internal/asn1/der.js +210 -227
  6. package/dist/internal/asn1/der.js.map +1 -0
  7. package/dist/internal/asn1/oids.js +297 -101
  8. package/dist/internal/asn1/oids.js.map +1 -0
  9. package/dist/internal/asn1/oids2.js +69 -0
  10. package/dist/internal/asn1/oids2.js.map +1 -0
  11. package/dist/internal/crypto/algorithm-names.js +37 -35
  12. package/dist/internal/crypto/algorithm-names.js.map +1 -0
  13. package/dist/internal/crypto/ecdsa.js +25 -28
  14. package/dist/internal/crypto/ecdsa.js.map +1 -0
  15. package/dist/internal/crypto/hash.js +56 -117
  16. package/dist/internal/crypto/hash.js.map +1 -0
  17. package/dist/internal/crypto/pbes2.js +122 -133
  18. package/dist/internal/crypto/pbes2.js.map +1 -0
  19. package/dist/internal/crypto/rsa-pss.js +118 -124
  20. package/dist/internal/crypto/rsa-pss.js.map +1 -0
  21. package/dist/internal/crypto/sig-verify.js +87 -99
  22. package/dist/internal/crypto/sig-verify.js.map +1 -0
  23. package/dist/internal/crypto/signing.d.ts +12 -8
  24. package/dist/internal/crypto/signing.js +53 -55
  25. package/dist/internal/crypto/signing.js.map +1 -0
  26. package/dist/internal/crypto/webcrypto.js +5 -3
  27. package/dist/internal/crypto/webcrypto.js.map +1 -0
  28. package/dist/internal/shared/base64.js +10 -9
  29. package/dist/internal/shared/base64.js.map +1 -0
  30. package/dist/internal/shared/dn.js +50 -57
  31. package/dist/internal/shared/dn.js.map +1 -0
  32. package/dist/internal/shared/ip.js +43 -53
  33. package/dist/internal/shared/ip.js.map +1 -0
  34. package/dist/internal/verify/name-constraints-engine.js +211 -239
  35. package/dist/internal/verify/name-constraints-engine.js.map +1 -0
  36. package/dist/internal/verify/policy-engine.js +228 -247
  37. package/dist/internal/verify/policy-engine.js.map +1 -0
  38. package/dist/internal/verify/verify-path.js +213 -228
  39. package/dist/internal/verify/verify-path.js.map +1 -0
  40. package/dist/internal/x509/extension-bits.js +62 -59
  41. package/dist/internal/x509/extension-bits.js.map +1 -0
  42. package/dist/internal/x509/extension-registry.js +133 -164
  43. package/dist/internal/x509/extension-registry.js.map +1 -0
  44. package/dist/internal/x509/name-fields.js +35 -41
  45. package/dist/internal/x509/name-fields.js.map +1 -0
  46. package/dist/keys/keys.d.ts +626 -447
  47. package/dist/keys/keys.js +652 -404
  48. package/dist/keys/keys.js.map +1 -0
  49. package/dist/keys.d.ts +2 -2
  50. package/dist/keys.js +2 -2
  51. package/dist/pem/pem.d.ts +46 -46
  52. package/dist/pem/pem.js +62 -81
  53. package/dist/pem/pem.js.map +1 -0
  54. package/dist/pem.js +2 -2
  55. package/dist/pkcs/pfx.d.ts +96 -80
  56. package/dist/pkcs/pfx.js +191 -231
  57. package/dist/pkcs/pfx.js.map +1 -0
  58. package/dist/pkcs/pkcs12-mac.d.ts +20 -18
  59. package/dist/pkcs/pkcs12-mac.js +90 -111
  60. package/dist/pkcs/pkcs12-mac.js.map +1 -0
  61. package/dist/pkcs/pkcs7.d.ts +118 -69
  62. package/dist/pkcs/pkcs7.js +401 -443
  63. package/dist/pkcs/pkcs7.js.map +1 -0
  64. package/dist/pkcs.d.ts +2 -2
  65. package/dist/pkcs.js +4 -4
  66. package/dist/result/result.d.ts +37 -32
  67. package/dist/result/result.js +46 -44
  68. package/dist/result/result.js.map +1 -0
  69. package/dist/result.js +2 -2
  70. package/dist/revocation/chain.d.ts +138 -119
  71. package/dist/revocation/chain.js +248 -281
  72. package/dist/revocation/chain.js.map +1 -0
  73. package/dist/revocation/crl.d.ts +125 -123
  74. package/dist/revocation/crl.js +653 -745
  75. package/dist/revocation/crl.js.map +1 -0
  76. package/dist/revocation/ocsp.d.ts +183 -177
  77. package/dist/revocation/ocsp.js +581 -638
  78. package/dist/revocation/ocsp.js.map +1 -0
  79. package/dist/revocation/revocation.d.ts +26 -26
  80. package/dist/revocation/revocation.js +104 -125
  81. package/dist/revocation/revocation.js.map +1 -0
  82. package/dist/revocation.js +5 -5
  83. package/dist/verify/identity.d.ts +42 -42
  84. package/dist/verify/identity.js +158 -167
  85. package/dist/verify/identity.js.map +1 -0
  86. package/dist/verify/name-constraints.d.ts +7 -7
  87. package/dist/verify/policy.d.ts +10 -10
  88. package/dist/verify/verify.d.ts +163 -163
  89. package/dist/verify/verify.js +396 -392
  90. package/dist/verify/verify.js.map +1 -0
  91. package/dist/verify.js +3 -3
  92. package/dist/x509/certificate.d.ts +117 -117
  93. package/dist/x509/certificate.js +51 -60
  94. package/dist/x509/certificate.js.map +1 -0
  95. package/dist/x509/csr.d.ts +25 -25
  96. package/dist/x509/csr.js +26 -30
  97. package/dist/x509/csr.js.map +1 -0
  98. package/dist/x509/extensions.d.ts +228 -184
  99. package/dist/x509/extensions.js +175 -200
  100. package/dist/x509/extensions.js.map +1 -0
  101. package/dist/x509/name.d.ts +94 -93
  102. package/dist/x509/name.js +30 -29
  103. package/dist/x509/name.js.map +1 -0
  104. package/dist/x509/parse.d.ts +185 -185
  105. package/dist/x509/parse.js +638 -676
  106. package/dist/x509/parse.js.map +1 -0
  107. package/dist/x509.js +6 -6
  108. package/package.json +79 -41
@@ -1,7 +1,6 @@
1
1
  import { ErrorResult, Micro509Error } from "../result/result.js";
2
2
  import { ParsedCertificate, ParsedName } from "../x509/parse.js";
3
3
  import { CrlSource } from "./crl.js";
4
-
5
4
  //#region src/revocation/ocsp.d.ts
6
5
  /** Hash algorithm used to compute OCSP CertID fields. SHA-1 is the RFC 6960 default. */
7
6
  type OcspHashAlgorithm = "SHA-1" | "SHA-256";
@@ -10,9 +9,9 @@ type OcspCertificateSource = string | Uint8Array | ParsedCertificate;
10
9
  /** PEM string, DER bytes, or already-parsed OCSP request. */
11
10
  type OcspRequestSource = string | Uint8Array | ParsedOcspRequest;
12
11
  /**
13
- * One certificate whose status to query in an OCSP request.
14
- * Used as an element of {@linkcode CreateOcspRequestInput.requests}.
15
- */
12
+ * One certificate whose status to query in an OCSP request.
13
+ * Used as an element of {@linkcode CreateOcspRequestInput.requests}.
14
+ */
16
15
  interface CreateOcspRequestItemInput {
17
16
  /** Certificate whose revocation status is being queried. */
18
17
  readonly certificate: OcspCertificateSource;
@@ -20,8 +19,8 @@ interface CreateOcspRequestItemInput {
20
19
  readonly issuerCertificate: OcspCertificateSource;
21
20
  }
22
21
  /**
23
- * Input for {@linkcode createOcspRequest}.
24
- */
22
+ * Input for {@linkcode createOcspRequest}.
23
+ */
25
24
  interface CreateOcspRequestInput {
26
25
  /** One or more certificates to query (batched into a single OCSP request). */
27
26
  readonly requests: readonly CreateOcspRequestItemInput[];
@@ -31,8 +30,8 @@ interface CreateOcspRequestInput {
31
30
  readonly nonce?: Uint8Array;
32
31
  }
33
32
  /**
34
- * Encoded OCSP request in multiple serialisation formats, returned by {@linkcode createOcspRequest}.
35
- */
33
+ * Encoded OCSP request in multiple serialisation formats, returned by {@linkcode createOcspRequest}.
34
+ */
36
35
  interface OcspRequestMaterial {
37
36
  /** Raw DER bytes. */
38
37
  readonly der: Uint8Array;
@@ -42,9 +41,9 @@ interface OcspRequestMaterial {
42
41
  readonly base64: string;
43
42
  }
44
43
  /**
45
- * Decoded OCSP CertID — identifies a certificate by hashed issuer name,
46
- * hashed issuer key, and serial number.
47
- */
44
+ * Decoded OCSP CertID — identifies a certificate by hashed issuer name,
45
+ * hashed issuer key, and serial number.
46
+ */
48
47
  interface ParsedOcspCertId {
49
48
  /** OID of the hash algorithm used for the name and key hashes. */
50
49
  readonly hashAlgorithmOid: string;
@@ -58,8 +57,8 @@ interface ParsedOcspCertId {
58
57
  readonly serialNumberHex: string;
59
58
  }
60
59
  /**
61
- * Decoded OCSP request, returned by {@linkcode parseOcspRequestDer} / {@linkcode parseOcspRequestPem}.
62
- */
60
+ * Decoded OCSP request, returned by {@linkcode parseOcspRequestDer} / {@linkcode parseOcspRequestPem}.
61
+ */
63
62
  interface ParsedOcspRequest {
64
63
  /** Original DER bytes when this object came from {@linkcode parseOcspRequestDer} or PEM parsing. */
65
64
  readonly der?: Uint8Array;
@@ -73,8 +72,8 @@ type OcspCertStatus = "good" | "revoked" | "unknown";
73
72
  /** RFC 6960 overall response status — anything other than `'successful'` means the response body is absent or unusable. */
74
73
  type OcspResponseStatus = "successful" | "malformedRequest" | "internalError" | "tryLater" | "sigRequired" | "unauthorized";
75
74
  /**
76
- * Status of one certificate inside an OCSP BasicResponse.
77
- */
75
+ * Status of one certificate inside an OCSP BasicResponse.
76
+ */
78
77
  interface ParsedOcspSingleResponse {
79
78
  /** Which certificate this status applies to. */
80
79
  readonly certId: ParsedOcspCertId;
@@ -90,21 +89,25 @@ interface ParsedOcspSingleResponse {
90
89
  readonly revocationReasonCode?: number;
91
90
  }
92
91
  /**
93
- * How the OCSP responder identifies itself — either by distinguished name or
94
- * by SHA-1 hash of its public key.
95
- */
92
+ * How the OCSP responder identifies itself — either by distinguished name or
93
+ * by SHA-1 hash of its public key.
94
+ */
96
95
  type ParsedOcspResponderId = {
97
- /** Responder identified by its certificate subject name. */readonly type: "byName"; /** Parsed distinguished name of the responder. */
96
+ /** Responder identified by its certificate subject name. */
97
+ readonly type: "byName";
98
+ /** Parsed distinguished name of the responder. */
98
99
  readonly name: ParsedName;
99
100
  } | {
100
- /** Responder identified by public-key hash. */readonly type: "byKeyHash"; /** Hex-encoded SHA-1 hash of the responder's SubjectPublicKey content. */
101
+ /** Responder identified by public-key hash. */
102
+ readonly type: "byKeyHash";
103
+ /** Hex-encoded SHA-1 hash of the responder's SubjectPublicKey content. */
101
104
  readonly keyHashHex: string;
102
105
  };
103
106
  /**
104
- * Decoded OCSP response, returned by {@linkcode parseOcspResponseDer} / {@linkcode parseOcspResponsePem}.
105
- *
106
- * When `responseStatus` is not `'successful'`, most fields are absent.
107
- */
107
+ * Decoded OCSP response, returned by {@linkcode parseOcspResponseDer} / {@linkcode parseOcspResponsePem}.
108
+ *
109
+ * When `responseStatus` is not `'successful'`, most fields are absent.
110
+ */
108
111
  interface ParsedOcspResponse {
109
112
  /** Original DER bytes when this object came from {@linkcode parseOcspResponseDer} or PEM parsing. */
110
113
  readonly der?: Uint8Array;
@@ -132,9 +135,9 @@ interface ParsedOcspResponse {
132
135
  readonly certificates?: readonly ParsedCertificate[];
133
136
  }
134
137
  /**
135
- * One certificate's status entry for {@linkcode CreateOcspResponseInput.responses}.
136
- * Extends {@linkcode CreateOcspRequestItemInput} with status and timing fields.
137
- */
138
+ * One certificate's status entry for {@linkcode CreateOcspResponseInput.responses}.
139
+ * Extends {@linkcode CreateOcspRequestItemInput} with status and timing fields.
140
+ */
138
141
  interface CreateOcspSingleResponseInput extends CreateOcspRequestItemInput {
139
142
  /** Status to assert for this certificate. */
140
143
  readonly certStatus: OcspCertStatus;
@@ -148,8 +151,8 @@ interface CreateOcspSingleResponseInput extends CreateOcspRequestItemInput {
148
151
  readonly revocationReasonCode?: number;
149
152
  }
150
153
  /**
151
- * Input for {@linkcode createOcspResponse}.
152
- */
154
+ * Input for {@linkcode createOcspResponse}.
155
+ */
153
156
  interface CreateOcspResponseInput {
154
157
  /** Private key used to sign the response. Algorithm is inferred from the key. */
155
158
  readonly signerPrivateKey: CryptoKey;
@@ -167,8 +170,8 @@ interface CreateOcspResponseInput {
167
170
  readonly includedCertificates?: readonly OcspCertificateSource[];
168
171
  }
169
172
  /**
170
- * Encoded OCSP response in multiple serialisation formats, returned by {@linkcode createOcspResponse}.
171
- */
173
+ * Encoded OCSP response in multiple serialisation formats, returned by {@linkcode createOcspResponse}.
174
+ */
172
175
  interface OcspResponseMaterial {
173
176
  /** Raw DER bytes. */
174
177
  readonly der: Uint8Array;
@@ -183,30 +186,31 @@ interface VerifyOcspResponseSignatureFailure extends Micro509Error<"signature_in
183
186
  readonly ok: false;
184
187
  }
185
188
  /**
186
- * Result of {@linkcode verifyOcspResponseSignature}.
187
- *
188
- * On success, `value` is the parsed response whose signature has been verified.
189
- */
189
+ * Result of {@linkcode verifyOcspResponseSignature}.
190
+ *
191
+ * On success, `value` is the parsed response whose signature has been verified.
192
+ */
190
193
  type VerifyOcspResponseSignatureResult = {
191
- readonly ok: true; /** Parsed response with a verified signature. */
194
+ readonly ok: true;
195
+ /** Parsed response with a verified signature. */
192
196
  readonly value: ParsedOcspResponse;
193
197
  } | ErrorResult<"signature_invalid", Record<never, never>, VerifyOcspResponseSignatureFailure>;
194
198
  /**
195
- * Revocation policy for delegated OCSP responder certificates (RFC 6960 §4.2.2.2.1).
196
- *
197
- * - `'honor-nocheck'` (default): a responder carrying `id-pkix-ocsp-nocheck`
198
- * is exempt from revocation checking. Otherwise, CRL evidence from
199
- * {@linkcode ValidateOcspResponseInput.responderRevocationCrls} is consulted
200
- * when provided — a revoked responder rejects the response; missing or
201
- * unusable evidence is tolerated (soft).
202
- * - `'require-evidence'`: `nocheck` is ignored; CRL evidence must positively
203
- * show the responder is not revoked, otherwise the response is rejected.
204
- * - `'skip'`: no responder revocation checking.
205
- */
199
+ * Revocation policy for delegated OCSP responder certificates (RFC 6960 §4.2.2.2.1).
200
+ *
201
+ * - `'honor-nocheck'` (default): a responder carrying `id-pkix-ocsp-nocheck`
202
+ * is exempt from revocation checking. Otherwise, CRL evidence from
203
+ * {@linkcode ValidateOcspResponseInput.responderRevocationCrls} is consulted
204
+ * when provided — a revoked responder rejects the response; missing or
205
+ * unusable evidence is tolerated (soft).
206
+ * - `'require-evidence'`: `nocheck` is ignored; CRL evidence must positively
207
+ * show the responder is not revoked, otherwise the response is rejected.
208
+ * - `'skip'`: no responder revocation checking.
209
+ */
206
210
  type OcspResponderRevocationPolicy = "honor-nocheck" | "require-evidence" | "skip";
207
211
  /**
208
- * Input for {@linkcode validateOcspResponse}.
209
- */
212
+ * Input for {@linkcode validateOcspResponse}.
213
+ */
210
214
  interface ValidateOcspResponseInput {
211
215
  /** The OCSP response to validate. */
212
216
  readonly response: string | Uint8Array | ParsedOcspResponse;
@@ -219,15 +223,15 @@ interface ValidateOcspResponseInput {
219
223
  /** When `true`, allows delegated responder chain validation beyond direct issuance. */
220
224
  readonly allowChainedResponderCertificate?: boolean;
221
225
  /**
222
- * Explicitly trusted responder certificates for this issuer's scope
223
- * (RFC 6960 §4.2.2.2 criterion 1 — local responder configuration).
224
- *
225
- * A response signer matching one of these certificates is accepted without
226
- * the delegated-responder issuance, chain, EKU, and revocation checks.
227
- * Signature verification and responder-ID binding are still enforced.
228
- * Also consulted during responder discovery when the response embeds no
229
- * matching certificate.
230
- */
226
+ * Explicitly trusted responder certificates for this issuer's scope
227
+ * (RFC 6960 §4.2.2.2 criterion 1 — local responder configuration).
228
+ *
229
+ * A response signer matching one of these certificates is accepted without
230
+ * the delegated-responder issuance, chain, EKU, and revocation checks.
231
+ * Signature verification and responder-ID binding are still enforced.
232
+ * Also consulted during responder discovery when the response embeds no
233
+ * matching certificate.
234
+ */
231
235
  readonly trustedOcspResponders?: readonly OcspCertificateSource[];
232
236
  /** Revocation policy for delegated responder certificates. Defaults to `'honor-nocheck'`. */
233
237
  readonly responderRevocationPolicy?: OcspResponderRevocationPolicy;
@@ -241,44 +245,45 @@ interface ValidateOcspResponseInput {
241
245
  /** Failure codes produced by {@linkcode validateOcspResponse}. */
242
246
  type ValidateOcspResponseErrorCode = "response_status_invalid" | "signature_invalid" | "responder_id_mismatch" | "nonce_mismatch" | "request_mismatch" | "issuer_mismatch" | "responder_chain_invalid" | "ocsp_signing_missing" | "responder_revoked" | "responder_revocation_unknown" | "stale_response";
243
247
  /**
244
- * Failure detail for {@linkcode validateOcspResponse}.
245
- *
246
- * Possible codes: `response_status_invalid`, `signature_invalid`,
247
- * `responder_id_mismatch`, `nonce_mismatch`, `request_mismatch`,
248
- * `issuer_mismatch`, `responder_chain_invalid`, `ocsp_signing_missing`,
249
- * `responder_revoked`, `responder_revocation_unknown`, `stale_response`.
250
- */
248
+ * Failure detail for {@linkcode validateOcspResponse}.
249
+ *
250
+ * Possible codes: `response_status_invalid`, `signature_invalid`,
251
+ * `responder_id_mismatch`, `nonce_mismatch`, `request_mismatch`,
252
+ * `issuer_mismatch`, `responder_chain_invalid`, `ocsp_signing_missing`,
253
+ * `responder_revoked`, `responder_revocation_unknown`, `stale_response`.
254
+ */
251
255
  interface ValidateOcspResponseFailure extends Micro509Error<ValidateOcspResponseErrorCode> {
252
256
  /** Always `false` for failures. */
253
257
  readonly ok: false;
254
258
  }
255
259
  /**
256
- * Result of {@linkcode validateOcspResponse}.
257
- *
258
- * On success, the response has passed status, signature, responder binding,
259
- * authorization (including responder revocation policy), freshness, nonce,
260
- * and request-coverage checks.
261
- */
260
+ * Result of {@linkcode validateOcspResponse}.
261
+ *
262
+ * On success, the response has passed status, signature, responder binding,
263
+ * authorization (including responder revocation policy), freshness, nonce,
264
+ * and request-coverage checks.
265
+ */
262
266
  type ValidateOcspResponseResult = {
263
- readonly ok: true; /** Fully validated OCSP response. */
267
+ readonly ok: true;
268
+ /** Fully validated OCSP response. */
264
269
  readonly value: ParsedOcspResponse;
265
270
  } | ErrorResult<ValidateOcspResponseErrorCode, Record<never, never>, ValidateOcspResponseFailure>;
266
271
  /**
267
- * Builds a DER-encoded OCSP request containing one or more CertID entries
268
- * and an optional nonce extension.
269
- *
270
- * @example
271
- * ```ts
272
- * import { createOcspRequest } from 'micro509';
273
- *
274
- * const req = await createOcspRequest({
275
- * requests: [{ certificate: leafPem, issuerCertificate: caPem }],
276
- * hashAlgorithm: 'SHA-256',
277
- * nonce: crypto.getRandomValues(new Uint8Array(16)),
278
- * });
279
- * // POST req.der to the OCSP responder URI
280
- * ```
281
- */
272
+ * Builds a DER-encoded OCSP request containing one or more CertID entries
273
+ * and an optional nonce extension.
274
+ *
275
+ * @example
276
+ * ```ts
277
+ * import { createOcspRequest } from 'micro509';
278
+ *
279
+ * const req = await createOcspRequest({
280
+ * requests: [{ certificate: leafPem, issuerCertificate: caPem }],
281
+ * hashAlgorithm: 'SHA-256',
282
+ * nonce: crypto.getRandomValues(new Uint8Array(16)),
283
+ * });
284
+ * // POST req.der to the OCSP responder URI
285
+ * ```
286
+ */
282
287
  declare function createOcspRequest(input: CreateOcspRequestInput): Promise<OcspRequestMaterial>;
283
288
  /** Machine-readable failure reason for the OCSP request parsers. */
284
289
  type ParseOcspRequestErrorCode = "malformed";
@@ -297,18 +302,18 @@ declare function parseOcspRequestDerOrThrow(der: Uint8Array): ParsedOcspRequest;
297
302
  /** Decodes a PEM-encoded OCSP request (`-----BEGIN OCSP REQUEST-----`). */
298
303
  declare function parseOcspRequestPemOrThrow(pem: string): ParsedOcspRequest;
299
304
  /**
300
- * Decodes a DER-encoded OCSP request into a structured {@linkcode ParsedOcspRequest}.
301
- *
302
- * Returns a typed failure (`code: 'malformed'`) on malformed input. For the
303
- * throwing form use {@linkcode parseOcspRequestDerOrThrow}.
304
- */
305
+ * Decodes a DER-encoded OCSP request into a structured {@linkcode ParsedOcspRequest}.
306
+ *
307
+ * Returns a typed failure (`code: 'malformed'`) on malformed input. For the
308
+ * throwing form use {@linkcode parseOcspRequestDerOrThrow}.
309
+ */
305
310
  declare function parseOcspRequestDer(der: Uint8Array): ParseOcspRequestResult;
306
311
  /**
307
- * Decodes a PEM-encoded OCSP request (`-----BEGIN OCSP REQUEST-----`).
308
- *
309
- * Returns a typed failure (`code: 'malformed'`) on malformed input. For the
310
- * throwing form use {@linkcode parseOcspRequestPemOrThrow}.
311
- */
312
+ * Decodes a PEM-encoded OCSP request (`-----BEGIN OCSP REQUEST-----`).
313
+ *
314
+ * Returns a typed failure (`code: 'malformed'`) on malformed input. For the
315
+ * throwing form use {@linkcode parseOcspRequestPemOrThrow}.
316
+ */
312
317
  declare function parseOcspRequestPem(pem: string): ParseOcspRequestResult;
313
318
  /** Machine-readable failure reason for the OCSP response parsers. */
314
319
  type ParseOcspResponseErrorCode = "malformed";
@@ -325,97 +330,98 @@ type ParseOcspResponseResult = {
325
330
  /** Throwing core for {@linkcode parseOcspResponseDer}. */
326
331
  declare function parseOcspResponseDerOrThrow(der: Uint8Array): ParsedOcspResponse;
327
332
  /**
328
- * Decodes a PEM-encoded OCSP response (`-----BEGIN OCSP RESPONSE-----`).
329
- *
330
- * @example
331
- * ```ts
332
- * import { parseOcspResponsePem } from 'micro509';
333
- *
334
- * const resp = parseOcspResponsePem(pemString);
335
- * if (resp.responseStatus === 'successful') {
336
- * for (const entry of resp.responses ?? []) {
337
- * console.log(entry.certId.serialNumberHex, entry.certStatus);
338
- * }
339
- * }
340
- * ```
341
- */
333
+ * Decodes a PEM-encoded OCSP response (`-----BEGIN OCSP RESPONSE-----`).
334
+ *
335
+ * @example
336
+ * ```ts
337
+ * import { parseOcspResponsePemOrThrow } from 'micro509';
338
+ *
339
+ * const resp = parseOcspResponsePemOrThrow(pemString);
340
+ * if (resp.responseStatus === 'successful') {
341
+ * for (const entry of resp.responses ?? []) {
342
+ * console.log(entry.certId.serialNumberHex, entry.certStatus);
343
+ * }
344
+ * }
345
+ * ```
346
+ */
342
347
  declare function parseOcspResponsePemOrThrow(pem: string): ParsedOcspResponse;
343
348
  /**
344
- * Decodes a DER-encoded OCSP response into a structured {@linkcode ParsedOcspResponse}.
345
- *
346
- * Returns a typed failure (`code: 'malformed'`) on malformed input. For the
347
- * throwing form use {@linkcode parseOcspResponseDerOrThrow}.
348
- */
349
+ * Decodes a DER-encoded OCSP response into a structured {@linkcode ParsedOcspResponse}.
350
+ *
351
+ * Returns a typed failure (`code: 'malformed'`) on malformed input. For the
352
+ * throwing form use {@linkcode parseOcspResponseDerOrThrow}.
353
+ */
349
354
  declare function parseOcspResponseDer(der: Uint8Array): ParseOcspResponseResult;
350
355
  /**
351
- * Decodes a PEM-encoded OCSP response (`-----BEGIN OCSP RESPONSE-----`).
352
- *
353
- * Returns a typed failure (`code: 'malformed'`) on malformed input. For the
354
- * throwing form use {@linkcode parseOcspResponsePemOrThrow}.
355
- */
356
+ * Decodes a PEM-encoded OCSP response (`-----BEGIN OCSP RESPONSE-----`).
357
+ *
358
+ * Returns a typed failure (`code: 'malformed'`) on malformed input. For the
359
+ * throwing form use {@linkcode parseOcspResponsePemOrThrow}.
360
+ */
356
361
  declare function parseOcspResponsePem(pem: string): ParseOcspResponseResult;
357
362
  /**
358
- * Signs and encodes an OCSP BasicResponse with a `successful` status.
359
- *
360
- * The responder is identified by key hash (SHA-1 of the signer's SubjectPublicKey).
361
- * Use `includedCertificates` to embed the responder's chain for relying parties.
362
- *
363
- * @example
364
- * ```ts
365
- * import { createOcspResponse } from 'micro509';
366
- *
367
- * const resp = await createOcspResponse({
368
- * signerPrivateKey: responderPrivateKey,
369
- * signerCertificate: responderCertPem,
370
- * responses: [
371
- * {
372
- * certificate: leafPem,
373
- * issuerCertificate: caPem,
374
- * certStatus: 'good',
375
- * thisUpdate: new Date('2025-01-01'),
376
- * nextUpdate: new Date('2025-01-08'),
377
- * },
378
- * ],
379
- * nonce: requestNonce,
380
- * });
381
- * // resp.der, resp.pem, resp.base64
382
- * ```
383
- */
363
+ * Signs and encodes an OCSP BasicResponse with a `successful` status.
364
+ *
365
+ * The responder is identified by key hash (SHA-1 of the signer's SubjectPublicKey).
366
+ * Use `includedCertificates` to embed the responder's chain for relying parties.
367
+ *
368
+ * @example
369
+ * ```ts
370
+ * import { createOcspResponse } from 'micro509';
371
+ *
372
+ * const resp = await createOcspResponse({
373
+ * signerPrivateKey: responderPrivateKey,
374
+ * signerCertificate: responderCertPem,
375
+ * responses: [
376
+ * {
377
+ * certificate: leafPem,
378
+ * issuerCertificate: caPem,
379
+ * certStatus: 'good',
380
+ * thisUpdate: new Date('2025-01-01'),
381
+ * nextUpdate: new Date('2025-01-08'),
382
+ * },
383
+ * ],
384
+ * nonce: requestNonce,
385
+ * });
386
+ * // resp.der, resp.pem, resp.base64
387
+ * ```
388
+ */
384
389
  declare function createOcspResponse(input: CreateOcspResponseInput): Promise<OcspResponseMaterial>;
385
390
  /**
386
- * Verifies the OCSP response signature against the given signer certificate.
387
- *
388
- * Does **not** check responder binding, freshness, or nonce — use
389
- * {@linkcode validateOcspResponse} for full validation.
390
- */
391
+ * Verifies the OCSP response signature against the given signer certificate.
392
+ *
393
+ * Does **not** check responder binding, freshness, or nonce — use
394
+ * {@linkcode validateOcspResponse} for full validation.
395
+ */
391
396
  declare function verifyOcspResponseSignature(response: string | Uint8Array | ParsedOcspResponse, signerCertificate: OcspCertificateSource): Promise<VerifyOcspResponseSignatureResult>;
392
397
  /**
393
- * Full OCSP response validation: response status check, signature verification,
394
- * responder ID binding (byName or byKeyHash), delegated-responder chain and
395
- * ocspSigning EKU checks, `producedAt`/`thisUpdate`/`nextUpdate` freshness,
396
- * nonce match, and request-coverage completeness.
397
- *
398
- * @example
399
- * ```ts
400
- * import { validateOcspResponse } from 'micro509';
401
- *
402
- * const result = await validateOcspResponse({
403
- * response: ocspResponseDer,
404
- * issuerCertificate: caPem,
405
- * request: ocspRequestDer,
406
- * });
407
- * if (result.ok) {
408
- * const entry = result.value.responses?.[0];
409
- * console.log(entry?.certStatus); // 'good' | 'revoked' | 'unknown'
410
- * }
411
- * ```
412
- */
398
+ * Full OCSP response validation: response status check, signature verification,
399
+ * responder ID binding (byName or byKeyHash), delegated-responder chain and
400
+ * ocspSigning EKU checks, `producedAt`/`thisUpdate`/`nextUpdate` freshness,
401
+ * nonce match, and request-coverage completeness.
402
+ *
403
+ * @example
404
+ * ```ts
405
+ * import { validateOcspResponse } from 'micro509';
406
+ *
407
+ * const result = await validateOcspResponse({
408
+ * response: ocspResponseDer,
409
+ * issuerCertificate: caPem,
410
+ * request: ocspRequestDer,
411
+ * });
412
+ * if (result.ok) {
413
+ * const entry = result.value.responses?.[0];
414
+ * console.log(entry?.certStatus); // 'good' | 'revoked' | 'unknown'
415
+ * }
416
+ * ```
417
+ */
413
418
  declare function validateOcspResponse(input: ValidateOcspResponseInput): Promise<ValidateOcspResponseResult>;
414
419
  /**
415
- * Reports whether a certificate carries the `id-pkix-ocsp-nocheck` extension
416
- * (RFC 6960 §4.2.2.2.1) — the CA's assertion that relying parties may trust
417
- * this OCSP responder certificate for its lifetime without revocation checks.
418
- */
420
+ * Reports whether a certificate carries the `id-pkix-ocsp-nocheck` extension
421
+ * (RFC 6960 §4.2.2.2.1) — the CA's assertion that relying parties may trust
422
+ * this OCSP responder certificate for its lifetime without revocation checks.
423
+ */
419
424
  declare function hasOcspNoCheckExtension(certificate: OcspCertificateSource): boolean;
420
425
  //#endregion
421
- export { CreateOcspRequestInput, CreateOcspRequestItemInput, CreateOcspResponseInput, CreateOcspSingleResponseInput, OcspCertStatus, OcspCertificateSource, OcspHashAlgorithm, OcspRequestMaterial, OcspRequestSource, OcspResponderRevocationPolicy, OcspResponseMaterial, OcspResponseStatus, ParseOcspRequestErrorCode, ParseOcspRequestFailure, ParseOcspRequestResult, ParseOcspResponseErrorCode, ParseOcspResponseFailure, ParseOcspResponseResult, ParsedOcspCertId, ParsedOcspRequest, ParsedOcspResponderId, ParsedOcspResponse, ParsedOcspSingleResponse, ValidateOcspResponseErrorCode, ValidateOcspResponseFailure, ValidateOcspResponseInput, ValidateOcspResponseResult, VerifyOcspResponseSignatureFailure, VerifyOcspResponseSignatureResult, createOcspRequest, createOcspResponse, hasOcspNoCheckExtension, parseOcspRequestDer, parseOcspRequestDerOrThrow, parseOcspRequestPem, parseOcspRequestPemOrThrow, parseOcspResponseDer, parseOcspResponseDerOrThrow, parseOcspResponsePem, parseOcspResponsePemOrThrow, validateOcspResponse, verifyOcspResponseSignature };
426
+ export { CreateOcspRequestInput, CreateOcspRequestItemInput, CreateOcspResponseInput, CreateOcspSingleResponseInput, OcspCertStatus, OcspCertificateSource, OcspHashAlgorithm, OcspRequestMaterial, OcspRequestSource, OcspResponderRevocationPolicy, OcspResponseMaterial, OcspResponseStatus, ParseOcspRequestErrorCode, ParseOcspRequestFailure, ParseOcspRequestResult, ParseOcspResponseErrorCode, ParseOcspResponseFailure, ParseOcspResponseResult, ParsedOcspCertId, ParsedOcspRequest, ParsedOcspResponderId, ParsedOcspResponse, ParsedOcspSingleResponse, ValidateOcspResponseErrorCode, ValidateOcspResponseFailure, ValidateOcspResponseInput, ValidateOcspResponseResult, VerifyOcspResponseSignatureFailure, VerifyOcspResponseSignatureResult, createOcspRequest, createOcspResponse, hasOcspNoCheckExtension, parseOcspRequestDer, parseOcspRequestDerOrThrow, parseOcspRequestPem, parseOcspRequestPemOrThrow, parseOcspResponseDer, parseOcspResponseDerOrThrow, parseOcspResponsePem, parseOcspResponsePemOrThrow, validateOcspResponse, verifyOcspResponseSignature };
427
+ //# sourceMappingURL=ocsp.d.ts.map