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
@@ -2,7 +2,6 @@ import { ErrorResult, Micro509Error } from "../result/result.js";
2
2
  import { ImportKeyResult, PublicKeyImportInput } from "../keys/keys.js";
3
3
  import { NameFieldKey } from "./name.js";
4
4
  import { AuthorityInformationAccess, BasicConstraints, CertificatePolicies, DistributionPointReason, ExtendedKeyUsage, GeneralName, GeneralSubtree, InhibitAnyPolicy, KeyUsage, NameConstraints, ParsedBitFlags, ParsedNameConstraintForm, PolicyConstraints, PolicyMappings, SubjectAltName } from "./extensions.js";
5
-
6
5
  //#region src/x509/parse.d.ts
7
6
  /** Machine-readable failure reason for {@linkcode parseCertificateDer} / {@linkcode parseCertificatePem}. */
8
7
  type ParseCertificateErrorCode = "malformed";
@@ -24,20 +23,20 @@ interface ParseCertificateSigningRequestFailure extends Micro509Error<ParseCerti
24
23
  readonly ok: false;
25
24
  }
26
25
  /**
27
- * Success-or-failure result from {@linkcode parseCertificateSigningRequestDer} /
28
- * {@linkcode parseCertificateSigningRequestPem}.
29
- */
26
+ * Success-or-failure result from {@linkcode parseCertificateSigningRequestDer} /
27
+ * {@linkcode parseCertificateSigningRequestPem}.
28
+ */
30
29
  type ParseCertificateSigningRequestResult<TMap extends ExtensionDecoderMap = Record<never, never>> = {
31
30
  readonly ok: true;
32
31
  readonly value: ParsedCertificateSigningRequest<TMap>;
33
32
  } | ErrorResult<ParseCertificateSigningRequestErrorCode, Record<never, never>, ParseCertificateSigningRequestFailure>;
34
33
  /**
35
- * A single decoded name attribute from an X.501 RelativeDistinguishedName.
36
- *
37
- * RFC 5280 / X.501 call this structure an `AttributeTypeAndValue`.
38
- *
39
- * @see {@link https://datatracker.ietf.org/doc/html/rfc5280#appendix-A.1 RFC 5280 Appendix A.1}
40
- */
34
+ * A single decoded name attribute from an X.501 RelativeDistinguishedName.
35
+ *
36
+ * RFC 5280 / X.501 call this structure an `AttributeTypeAndValue`.
37
+ *
38
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc5280#appendix-A.1 RFC 5280 Appendix A.1}
39
+ */
41
40
  interface ParsedNameAttribute {
42
41
  /** Dotted-decimal OID of the attribute type (e.g. `"2.5.4.3"` for CN). */
43
42
  readonly oid: string;
@@ -49,11 +48,11 @@ interface ParsedNameAttribute {
49
48
  readonly value: string;
50
49
  }
51
50
  /**
52
- * An X.501 Distinguished Name decoded from an issuer or subject field.
53
- *
54
- * Provides three views of the same data: ordered RDNs, a flat attribute
55
- * list, and a convenience key-value map for well-known fields.
56
- */
51
+ * An X.501 Distinguished Name decoded from an issuer or subject field.
52
+ *
53
+ * Provides three views of the same data: ordered RDNs, a flat attribute
54
+ * list, and a convenience key-value map for well-known fields.
55
+ */
57
56
  interface ParsedName {
58
57
  /** Hex-encoded DER of the complete Name SEQUENCE, usable for byte-exact comparisons. */
59
58
  readonly derHex: string;
@@ -74,9 +73,9 @@ interface ParsedRelativeDistinguishedName {
74
73
  readonly values: Readonly<Partial<Record<NameFieldKey, string>>>;
75
74
  }
76
75
  /**
77
- * The name component of a CRL Distribution Point (RFC 5280 §4.2.1.13).
78
- * Exactly one of `fullName` or `relativeName` will be present.
79
- */
76
+ * The name component of a CRL Distribution Point (RFC 5280 §4.2.1.13).
77
+ * Exactly one of `fullName` or `relativeName` will be present.
78
+ */
80
79
  interface ParsedDistributionPointName {
81
80
  /** Absolute GeneralName(s) identifying the distribution point. */
82
81
  readonly fullName?: readonly GeneralName[];
@@ -93,9 +92,9 @@ interface ParsedDistributionPoint {
93
92
  readonly crlIssuer?: readonly GeneralName[];
94
93
  }
95
94
  /**
96
- * Decoded Issuing Distribution Point CRL extension (RFC 5280 §5.2.5).
97
- * Constrains which certificates a CRL covers (scope, reasons, indirection).
98
- */
95
+ * Decoded Issuing Distribution Point CRL extension (RFC 5280 §5.2.5).
96
+ * Constrains which certificates a CRL covers (scope, reasons, indirection).
97
+ */
99
98
  interface ParsedIssuingDistributionPoint {
100
99
  /** Where to fetch this CRL, if specified. */
101
100
  readonly distributionPoint?: ParsedDistributionPointName;
@@ -122,11 +121,11 @@ interface ParsedExtension {
122
121
  readonly valueHex: string;
123
122
  }
124
123
  /**
125
- * User-supplied decoder for a single extension OID.
126
- *
127
- * Register with {@linkcode ParseOptions.decoders} or {@linkcode ParseOptions.decoderMap}
128
- * to decode custom extensions during parsing.
129
- */
124
+ * User-supplied decoder for a single extension OID.
125
+ *
126
+ * Register with {@linkcode ParseOptions.decoders} or {@linkcode ParseOptions.decoderMap}
127
+ * to decode custom extensions during parsing.
128
+ */
130
129
  interface ExtensionDecoder<TValue> {
131
130
  /** OID this decoder handles. */
132
131
  readonly oid: string;
@@ -134,23 +133,23 @@ interface ExtensionDecoder<TValue> {
134
133
  decode(extension: ParsedExtension): TValue;
135
134
  }
136
135
  /**
137
- * Identity helper that narrows the type of a custom {@linkcode ExtensionDecoder} literal.
138
- *
139
- * @param decoder Decoder definition to return unchanged.
140
- * @returns The same decoder, properly typed.
141
- */
136
+ * Identity helper that narrows the type of a custom {@linkcode ExtensionDecoder} literal.
137
+ *
138
+ * @param decoder Decoder definition to return unchanged.
139
+ * @returns The same decoder, properly typed.
140
+ */
142
141
  declare function defineExtensionDecoder<TValue>(decoder: ExtensionDecoder<TValue>): ExtensionDecoder<TValue>;
143
142
  /**
144
- * Identity helper that narrows the type of a custom {@linkcode ExtensionDecoderMap} literal.
145
- *
146
- * @param decoderMap Map of named decoders to return unchanged.
147
- * @returns The same map, properly typed.
148
- */
143
+ * Identity helper that narrows the type of a custom {@linkcode ExtensionDecoderMap} literal.
144
+ *
145
+ * @param decoderMap Map of named decoders to return unchanged.
146
+ * @returns The same map, properly typed.
147
+ */
149
148
  declare function defineExtensionDecoderMap<TMap extends ExtensionDecoderMap>(decoderMap: TMap): TMap;
150
149
  /** String-keyed map of {@linkcode ExtensionDecoder}s, used with {@linkcode ParseOptions.decoderMap}. */
151
150
  type ExtensionDecoderMap = Record<string, ExtensionDecoder<unknown>>;
152
151
  /** Inferred result type when decoding extensions via an {@linkcode ExtensionDecoderMap}. */
153
- type DecodedExtensionMap<TMap extends ExtensionDecoderMap> = { [TKey in keyof TMap]?: TMap[TKey] extends ExtensionDecoder<infer TValue> ? DecodedExtensionValue<TValue> : never };
152
+ type DecodedExtensionMap<TMap extends ExtensionDecoderMap> = { [TKey in keyof TMap]?: TMap[TKey] extends ExtensionDecoder<infer TValue> ? DecodedExtensionValue<TValue> : never; };
154
153
  /** A successfully decoded extension value paired with its OID and criticality. */
155
154
  interface DecodedExtensionValue<TValue> {
156
155
  /** Dotted-decimal OID of the decoded extension. */
@@ -161,12 +160,12 @@ interface DecodedExtensionValue<TValue> {
161
160
  readonly value: TValue;
162
161
  }
163
162
  /**
164
- * Options for {@linkcode parseCertificateDer}, {@linkcode parseCertificatePem},
165
- * and CSR parse functions.
166
- *
167
- * Supply custom extension decoders to have their results included in the parsed output alongside
168
- * the built-in extensions.
169
- */
163
+ * Options for {@linkcode parseCertificateDer}, {@linkcode parseCertificatePem},
164
+ * and CSR parse functions.
165
+ *
166
+ * Supply custom extension decoders to have their results included in the parsed output alongside
167
+ * the built-in extensions.
168
+ */
170
169
  interface ParseOptions<TMap extends ExtensionDecoderMap = Record<never, never>> {
171
170
  /** Array of decoders; decoded values appear in `decodedExtensions`. */
172
171
  readonly decoders?: readonly ExtensionDecoder<unknown>[];
@@ -174,12 +173,12 @@ interface ParseOptions<TMap extends ExtensionDecoderMap = Record<never, never>>
174
173
  readonly decoderMap?: TMap;
175
174
  }
176
175
  /**
177
- * A fully decoded X.509 certificate.
178
- *
179
- * Built-in extensions (basicConstraints, keyUsage, etc.) are decoded into
180
- * typed fields automatically.\
181
- * Supply {@linkcode ParseOptions} to also decode custom extensions.
182
- */
176
+ * A fully decoded X.509 certificate.
177
+ *
178
+ * Built-in extensions (basicConstraints, keyUsage, etc.) are decoded into
179
+ * typed fields automatically.\
180
+ * Supply {@linkcode ParseOptions} to also decode custom extensions.
181
+ */
183
182
  interface ParsedCertificate<TMap extends ExtensionDecoderMap = Record<never, never>> {
184
183
  /** Complete DER encoding of the certificate (copied from the input). */
185
184
  readonly der: Uint8Array;
@@ -249,11 +248,11 @@ interface ParsedCertificate<TMap extends ExtensionDecoderMap = Record<never, nev
249
248
  readonly authorityKeyIdentifier?: string;
250
249
  }
251
250
  /**
252
- * A fully decoded PKCS#10 Certificate Signing Request.
253
- *
254
- * Extension fields mirror {@linkcode ParsedCertificate} but come from the
255
- * CSR's extensionRequest attribute rather than the v3 extensions block.
256
- */
251
+ * A fully decoded PKCS#10 Certificate Signing Request.
252
+ *
253
+ * Extension fields mirror {@linkcode ParsedCertificate} but come from the
254
+ * CSR's extensionRequest attribute rather than the v3 extensions block.
255
+ */
257
256
  interface ParsedCertificateSigningRequest<TMap extends ExtensionDecoderMap = Record<never, never>> {
258
257
  /** PKCS#10 version number (always 1). */
259
258
  readonly version: number;
@@ -309,164 +308,165 @@ interface ParsedCertificateSigningRequest<TMap extends ExtensionDecoderMap = Rec
309
308
  readonly decodedExtensionMap?: DecodedExtensionMap<TMap>;
310
309
  }
311
310
  /**
312
- * Throwing core for {@linkcode parseCertificateDer}.
313
- *
314
- * Decodes a DER-encoded X.509 certificate into a {@linkcode ParsedCertificate},
315
- * throwing on malformed input. All built-in extensions (basicConstraints,
316
- * keyUsage, subjectAltNames, etc.) are decoded automatically.\
317
- * Pass {@linkcode ParseOptions} to also decode custom extensions.
318
- *
319
- * @param der Raw DER bytes of an X.509 certificate.
320
- * @param options Custom extension decoders to apply during parsing.
321
- */
311
+ * Throwing core for {@linkcode parseCertificateDer}.
312
+ *
313
+ * Decodes a DER-encoded X.509 certificate into a {@linkcode ParsedCertificate},
314
+ * throwing on malformed input. All built-in extensions (basicConstraints,
315
+ * keyUsage, subjectAltNames, etc.) are decoded automatically.\
316
+ * Pass {@linkcode ParseOptions} to also decode custom extensions.
317
+ *
318
+ * @param der Raw DER bytes of an X.509 certificate.
319
+ * @param options Custom extension decoders to apply during parsing.
320
+ */
322
321
  declare function parseCertificateDerOrThrow<TMap extends ExtensionDecoderMap = Record<never, never>>(der: Uint8Array, options?: ParseOptions<TMap>): ParsedCertificate<TMap>;
323
322
  /**
324
- * Decode a DER-encoded X.509 certificate into a {@linkcode ParsedCertificate}.
325
- *
326
- * @example
327
- * ```ts
328
- * import { parseCertificateDer } from 'micro509';
329
- *
330
- * const result = parseCertificateDer(derBytes);
331
- * if (result.ok) {
332
- * console.log(result.value.subject.values.commonName); // "example.com"
333
- * }
334
- * ```
335
- *
336
- * @param der Raw DER bytes of an X.509 certificate.
337
- * @param options Custom extension decoders to apply during parsing.
338
- */
323
+ * Decode a DER-encoded X.509 certificate into a {@linkcode ParsedCertificate}.
324
+ *
325
+ * @example
326
+ * ```ts
327
+ * import { parseCertificateDer } from 'micro509';
328
+ *
329
+ * const result = parseCertificateDer(derBytes);
330
+ * if (result.ok) {
331
+ * console.log(result.value.subject.values.commonName); // "example.com"
332
+ * }
333
+ * ```
334
+ *
335
+ * @param der Raw DER bytes of an X.509 certificate.
336
+ * @param options Custom extension decoders to apply during parsing.
337
+ */
339
338
  declare function parseCertificateDer<TMap extends ExtensionDecoderMap = Record<never, never>>(der: Uint8Array, options?: ParseOptions<TMap>): ParseCertificateResult<TMap>;
340
339
  /**
341
- * Decode a PEM-encoded X.509 certificate into a {@linkcode ParsedCertificate}.
342
- *
343
- * Expects a single `-----BEGIN CERTIFICATE-----` block. For bundles
344
- * containing multiple certificates, use {@linkcode parseCertificateChainPem}.
345
- *
346
- * @example
347
- * Throws on malformed input. For a typed failure instead, use the
348
- * Result-returning {@linkcode parseCertificatePem}.
349
- *
350
- * ```ts
351
- * const certificate = parseCertificatePemOrThrow(pemString); // throws if malformed
352
- * console.log(certificate.issuer.values.organization); // "Let's Encrypt"
353
- * ```
354
- *
355
- * @param pem PEM string with a CERTIFICATE block.
356
- * @param options Custom extension decoders to apply during parsing.
357
- */
340
+ * Decode a PEM-encoded X.509 certificate into a {@linkcode ParsedCertificate}.
341
+ *
342
+ * Expects a single `-----BEGIN CERTIFICATE-----` block. For bundles
343
+ * containing multiple certificates, use {@linkcode parseCertificateChainPem}.
344
+ *
345
+ * @example
346
+ * Throws on malformed input. For a typed failure instead, use the
347
+ * Result-returning {@linkcode parseCertificatePem}.
348
+ *
349
+ * ```ts
350
+ * const certificate = parseCertificatePemOrThrow(pemString); // throws if malformed
351
+ * console.log(certificate.issuer.values.organization); // "Let's Encrypt"
352
+ * ```
353
+ *
354
+ * @param pem PEM string with a CERTIFICATE block.
355
+ * @param options Custom extension decoders to apply during parsing.
356
+ */
358
357
  declare function parseCertificatePemOrThrow<TMap extends ExtensionDecoderMap = Record<never, never>>(pem: string, options?: ParseOptions<TMap>): ParsedCertificate<TMap>;
359
358
  /**
360
- * Decode a PEM-encoded X.509 certificate into a {@linkcode ParsedCertificate}.
361
- *
362
- * Expects a single `-----BEGIN CERTIFICATE-----` block. For bundles
363
- * containing multiple certificates, use {@linkcode parseCertificateChainPem}.
364
- *
365
- * @param pem PEM string with a CERTIFICATE block.
366
- * @param options Custom extension decoders to apply during parsing.
367
- */
359
+ * Decode a PEM-encoded X.509 certificate into a {@linkcode ParsedCertificate}.
360
+ *
361
+ * Expects a single `-----BEGIN CERTIFICATE-----` block. For bundles
362
+ * containing multiple certificates, use {@linkcode parseCertificateChainPem}.
363
+ *
364
+ * @param pem PEM string with a CERTIFICATE block.
365
+ * @param options Custom extension decoders to apply during parsing.
366
+ */
368
367
  declare function parseCertificatePem<TMap extends ExtensionDecoderMap = Record<never, never>>(pem: string, options?: ParseOptions<TMap>): ParseCertificateResult<TMap>;
369
368
  /**
370
- * Decode a PEM bundle containing one or more certificates.
371
- *
372
- * Non-CERTIFICATE blocks (e.g. private keys) are silently skipped.
373
- *
374
- * @param pemBundle PEM text that may contain multiple CERTIFICATE blocks.
375
- * @param options Custom extension decoders to apply during parsing.
376
- */
369
+ * Decode a PEM bundle containing one or more certificates.
370
+ *
371
+ * Non-CERTIFICATE blocks (e.g. private keys) are silently skipped.
372
+ *
373
+ * @param pemBundle PEM text that may contain multiple CERTIFICATE blocks.
374
+ * @param options Custom extension decoders to apply during parsing.
375
+ */
377
376
  declare function parseCertificateChainPem<TMap extends ExtensionDecoderMap = Record<never, never>>(pemBundle: string, options?: ParseOptions<TMap>): readonly ParsedCertificate<TMap>[];
378
377
  /**
379
- * Decode a DER-encoded PKCS#10 CSR into a {@linkcode ParsedCertificateSigningRequest}.
380
- *
381
- * @param der Raw DER bytes of a PKCS#10 certificate signing request.
382
- * @param options Custom extension decoders to apply during parsing.
383
- */
378
+ * Decode a DER-encoded PKCS#10 CSR into a {@linkcode ParsedCertificateSigningRequest}.
379
+ *
380
+ * @param der Raw DER bytes of a PKCS#10 certificate signing request.
381
+ * @param options Custom extension decoders to apply during parsing.
382
+ */
384
383
  declare function parseCertificateSigningRequestDerOrThrow<TMap extends ExtensionDecoderMap = Record<never, never>>(der: Uint8Array, options?: ParseOptions<TMap>): ParsedCertificateSigningRequest<TMap>;
385
384
  /**
386
- * Decode a DER-encoded PKCS#10 CSR into a {@linkcode ParsedCertificateSigningRequest}.
387
- *
388
- * @param der Raw DER bytes of a PKCS#10 certificate signing request.
389
- * @param options Custom extension decoders to apply during parsing.
390
- */
385
+ * Decode a DER-encoded PKCS#10 CSR into a {@linkcode ParsedCertificateSigningRequest}.
386
+ *
387
+ * @param der Raw DER bytes of a PKCS#10 certificate signing request.
388
+ * @param options Custom extension decoders to apply during parsing.
389
+ */
391
390
  declare function parseCertificateSigningRequestDer<TMap extends ExtensionDecoderMap = Record<never, never>>(der: Uint8Array, options?: ParseOptions<TMap>): ParseCertificateSigningRequestResult<TMap>;
392
391
  /**
393
- * Decode a PEM-encoded PKCS#10 CSR into a {@linkcode ParsedCertificateSigningRequest}.
394
- *
395
- * @param pem PEM string with a CERTIFICATE REQUEST block.
396
- * @param options Custom extension decoders to apply during parsing.
397
- */
392
+ * Decode a PEM-encoded PKCS#10 CSR into a {@linkcode ParsedCertificateSigningRequest}.
393
+ *
394
+ * @param pem PEM string with a CERTIFICATE REQUEST block.
395
+ * @param options Custom extension decoders to apply during parsing.
396
+ */
398
397
  declare function parseCertificateSigningRequestPemOrThrow<TMap extends ExtensionDecoderMap = Record<never, never>>(pem: string, options?: ParseOptions<TMap>): ParsedCertificateSigningRequest<TMap>;
399
398
  /**
400
- * Decode a PEM-encoded PKCS#10 CSR into a {@linkcode ParsedCertificateSigningRequest}.
401
- *
402
- * @param pem PEM string with a CERTIFICATE REQUEST block.
403
- * @param options Custom extension decoders to apply during parsing.
404
- */
399
+ * Decode a PEM-encoded PKCS#10 CSR into a {@linkcode ParsedCertificateSigningRequest}.
400
+ *
401
+ * @param pem PEM string with a CERTIFICATE REQUEST block.
402
+ * @param options Custom extension decoders to apply during parsing.
403
+ */
405
404
  declare function parseCertificateSigningRequestPem<TMap extends ExtensionDecoderMap = Record<never, never>>(pem: string, options?: ParseOptions<TMap>): ParseCertificateSigningRequestResult<TMap>;
406
405
  /**
407
- * Import the subject public key of a parsed certificate or CSR as a WebCrypto `CryptoKey`.
408
- *
409
- * The key algorithm — and, for EC keys, the curve — is inferred from the
410
- * SubjectPublicKeyInfo's own AlgorithmIdentifier (the same resolution
411
- * {@linkcode importSpkiDerOrThrow} applies when no algorithm is given), so
412
- * callers never map {@linkcode ParsedCertificate.publicKeyAlgorithmOid} /
413
- * {@linkcode ParsedCertificate.publicKeyParametersOid} by hand.\
414
- * RSA keys import with the default `pkcs1-v1_5`/`SHA-256` parameters (a plain
415
- * `rsaEncryption` SPKI encodes neither padding scheme nor hash); pass
416
- * `algorithm` to choose other RSA parameters or to assert an expected
417
- * algorithm.
418
- *
419
- * @param parsed Parsed certificate or CSR whose subject public key to import.
420
- * @param algorithm Optional expected algorithm; must match the key contents when given.
421
- * @returns Extractable `CryptoKey` with `verify` usage.
422
- *
423
- * @throws {Error} If the SubjectPublicKeyInfo is malformed, encodes an
424
- * unsupported algorithm, or doesn't match `algorithm`
425
- *
426
- * @example
427
- * ```ts
428
- * const parsed = parseCertificatePemOrThrow(pem);
429
- * const publicKey = await getSubjectPublicKeyOrThrow(parsed);
430
- * ```
431
- *
432
- * @see {@linkcode getSubjectPublicKey} for the non-throwing variant
433
- */
406
+ * Import the subject public key of a parsed certificate or CSR as a WebCrypto `CryptoKey`.
407
+ *
408
+ * The key algorithm — and, for EC keys, the curve — is inferred from the
409
+ * SubjectPublicKeyInfo's own AlgorithmIdentifier (the same resolution
410
+ * {@linkcode importSpkiDerOrThrow} applies when no algorithm is given), so
411
+ * callers never map {@linkcode ParsedCertificate.publicKeyAlgorithmOid} /
412
+ * {@linkcode ParsedCertificate.publicKeyParametersOid} by hand.\
413
+ * RSA keys import with the default `pkcs1-v1_5`/`SHA-256` parameters (a plain
414
+ * `rsaEncryption` SPKI encodes neither padding scheme nor hash); pass
415
+ * `algorithm` to choose other RSA parameters or to assert an expected
416
+ * algorithm.
417
+ *
418
+ * @param parsed Parsed certificate or CSR whose subject public key to import.
419
+ * @param algorithm Optional expected algorithm; must match the key contents when given.
420
+ * @returns Extractable `CryptoKey` with `verify` usage.
421
+ *
422
+ * @throws {Error} If the SubjectPublicKeyInfo is malformed, encodes an
423
+ * unsupported algorithm, or doesn't match `algorithm`
424
+ *
425
+ * @example
426
+ * ```ts
427
+ * const parsed = parseCertificatePemOrThrow(pem);
428
+ * const publicKey = await getSubjectPublicKeyOrThrow(parsed);
429
+ * ```
430
+ *
431
+ * @see {@linkcode getSubjectPublicKey} for the non-throwing variant
432
+ */
434
433
  declare function getSubjectPublicKeyOrThrow<TMap extends ExtensionDecoderMap = Record<never, never>>(parsed: ParsedCertificate<TMap> | ParsedCertificateSigningRequest<TMap>, algorithm?: PublicKeyImportInput): Promise<CryptoKey>;
435
434
  /**
436
- * Import the subject public key of a parsed certificate or CSR as a WebCrypto `CryptoKey`.
437
- *
438
- * @see `getSubjectPublicKeyOrThrow` for the throwing variant
439
- */
435
+ * Import the subject public key of a parsed certificate or CSR as a WebCrypto `CryptoKey`.
436
+ *
437
+ * @see `getSubjectPublicKeyOrThrow` for the throwing variant
438
+ */
440
439
  declare function getSubjectPublicKey<TMap extends ExtensionDecoderMap = Record<never, never>>(parsed: ParsedCertificate<TMap> | ParsedCertificateSigningRequest<TMap>, algorithm?: PublicKeyImportInput): Promise<ImportKeyResult<CryptoKey>>;
441
440
  /**
442
- * Find a raw extension by OID within a parsed extension list.
443
- *
444
- * @param extensions Extension list from a {@linkcode ParsedCertificate} or CSR.
445
- * @param oid Dotted-decimal OID to look up.
446
- * @returns The matching extension, or `undefined` if not present.
447
- */
441
+ * Find a raw extension by OID within a parsed extension list.
442
+ *
443
+ * @param extensions Extension list from a {@linkcode ParsedCertificate} or CSR.
444
+ * @param oid Dotted-decimal OID to look up.
445
+ * @returns The matching extension, or `undefined` if not present.
446
+ */
448
447
  declare function findExtension(extensions: readonly ParsedExtension[], oid: string): ParsedExtension | undefined;
449
448
  /**
450
- * Decode a single extension using a custom {@linkcode ExtensionDecoder}.
451
- *
452
- * @param extensions Extension list to search.
453
- * @param decoder Decoder whose OID will be matched.
454
- * @returns The decoded value, or `undefined` if the extension is absent.
455
- */
449
+ * Decode a single extension using a custom {@linkcode ExtensionDecoder}.
450
+ *
451
+ * @param extensions Extension list to search.
452
+ * @param decoder Decoder whose OID will be matched.
453
+ * @returns The decoded value, or `undefined` if the extension is absent.
454
+ */
456
455
  declare function decodeExtension<TValue>(extensions: readonly ParsedExtension[], decoder: ExtensionDecoder<TValue>): TValue | undefined;
457
456
  /**
458
- * Decode all matching extensions using an array of {@linkcode ExtensionDecoder}s.
459
- *
460
- * @param extensions Extension list to search.
461
- * @param decoders Decoders to apply. Only matching OIDs produce output.
462
- */
457
+ * Decode all matching extensions using an array of {@linkcode ExtensionDecoder}s.
458
+ *
459
+ * @param extensions Extension list to search.
460
+ * @param decoders Decoders to apply. Only matching OIDs produce output.
461
+ */
463
462
  declare function decodeExtensions(extensions: readonly ParsedExtension[], decoders: readonly ExtensionDecoder<unknown>[]): readonly DecodedExtensionValue<unknown>[];
464
463
  /**
465
- * Decode all matching extensions using a named {@linkcode ExtensionDecoderMap}.
466
- *
467
- * @param extensions Extension list to search.
468
- * @param decoderMap Named decoders. Results are keyed by the same map keys.
469
- */
464
+ * Decode all matching extensions using a named {@linkcode ExtensionDecoderMap}.
465
+ *
466
+ * @param extensions Extension list to search.
467
+ * @param decoderMap Named decoders. Results are keyed by the same map keys.
468
+ */
470
469
  declare function decodeExtensionMap<TMap extends ExtensionDecoderMap>(extensions: readonly ParsedExtension[], decoderMap: TMap): DecodedExtensionMap<TMap>;
471
470
  //#endregion
472
- export { DecodedExtensionMap, DecodedExtensionValue, ExtensionDecoder, ExtensionDecoderMap, ParseCertificateErrorCode, ParseCertificateFailure, ParseCertificateResult, ParseCertificateSigningRequestErrorCode, ParseCertificateSigningRequestFailure, ParseCertificateSigningRequestResult, ParseOptions, type ParsedBitFlags, ParsedCertificate, ParsedCertificateSigningRequest, ParsedDistributionPoint, ParsedDistributionPointName, ParsedExtension, ParsedIssuingDistributionPoint, ParsedName, ParsedNameAttribute, ParsedRelativeDistinguishedName, decodeExtension, decodeExtensionMap, decodeExtensions, defineExtensionDecoder, defineExtensionDecoderMap, findExtension, getSubjectPublicKey, getSubjectPublicKeyOrThrow, parseCertificateChainPem, parseCertificateDer, parseCertificateDerOrThrow, parseCertificatePem, parseCertificatePemOrThrow, parseCertificateSigningRequestDer, parseCertificateSigningRequestDerOrThrow, parseCertificateSigningRequestPem, parseCertificateSigningRequestPemOrThrow };
471
+ export { DecodedExtensionMap, DecodedExtensionValue, ExtensionDecoder, ExtensionDecoderMap, ParseCertificateErrorCode, ParseCertificateFailure, ParseCertificateResult, ParseCertificateSigningRequestErrorCode, ParseCertificateSigningRequestFailure, ParseCertificateSigningRequestResult, ParseOptions, type ParsedBitFlags, ParsedCertificate, ParsedCertificateSigningRequest, ParsedDistributionPoint, ParsedDistributionPointName, ParsedExtension, ParsedIssuingDistributionPoint, ParsedName, ParsedNameAttribute, ParsedRelativeDistinguishedName, decodeExtension, decodeExtensionMap, decodeExtensions, defineExtensionDecoder, defineExtensionDecoderMap, findExtension, getSubjectPublicKey, getSubjectPublicKeyOrThrow, parseCertificateChainPem, parseCertificateDer, parseCertificateDerOrThrow, parseCertificatePem, parseCertificatePemOrThrow, parseCertificateSigningRequestDer, parseCertificateSigningRequestDerOrThrow, parseCertificateSigningRequestPem, parseCertificateSigningRequestPemOrThrow };
472
+ //# sourceMappingURL=parse.d.ts.map