micro509 0.17.1 → 0.18.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 (126) hide show
  1. package/CHANGELOG.md +78 -6
  2. package/dist/crypto/crypto.d.ts +2 -3
  3. package/dist/crypto.d.ts +6 -0
  4. package/dist/der/der.d.ts +14 -4
  5. package/dist/der/der.js +19 -19
  6. package/dist/der.d.ts +26 -2
  7. package/dist/der.js +4 -4
  8. package/dist/index.d.ts +82 -15
  9. package/dist/index.js +19 -19
  10. package/dist/internal/asn1/asn1.d.ts +1 -2
  11. package/dist/internal/asn1/der.d.ts +1 -2
  12. package/dist/internal/asn1/oids.js +71 -353
  13. package/dist/internal/asn1/oids.js.map +1 -1
  14. package/dist/internal/asn1/oids.json.js +357 -0
  15. package/dist/internal/asn1/oids.json.js.map +1 -0
  16. package/dist/internal/crypto/algorithm-names.js +1 -1
  17. package/dist/internal/crypto/pbes2.d.ts +1 -2
  18. package/dist/internal/crypto/pbes2.js +70 -70
  19. package/dist/internal/crypto/prime-ec.js +37 -0
  20. package/dist/internal/crypto/prime-ec.js.map +1 -0
  21. package/dist/internal/crypto/rsa-pss.js +50 -50
  22. package/dist/internal/crypto/sig-verify.d.ts +1 -2
  23. package/dist/internal/crypto/sig-verify.js +60 -60
  24. package/dist/internal/crypto/signing.d.ts +1 -2
  25. package/dist/internal/crypto/signing.js +26 -26
  26. package/dist/internal/jose/json-data.js +108 -0
  27. package/dist/internal/jose/json-data.js.map +1 -0
  28. package/dist/internal/jose/strict-json.d.ts +1 -2
  29. package/dist/internal/shared/dn.d.ts +1 -2
  30. package/dist/internal/shared/dn.js +1 -1
  31. package/dist/internal/shared/ip.d.ts +1 -2
  32. package/dist/internal/verify/name-constraints-engine.js +64 -64
  33. package/dist/internal/verify/policy-engine.js +1 -1
  34. package/dist/internal/verify/verify-path.d.ts +1 -2
  35. package/dist/internal/verify/verify-path.js +19 -19
  36. package/dist/internal/x509/directory-name.js +10 -10
  37. package/dist/internal/x509/extension-errors.d.ts +1 -2
  38. package/dist/internal/x509/extension-registry.js +18 -18
  39. package/dist/internal/x509/general-name-profile.js +9 -9
  40. package/dist/internal/x509/general-name.js +32 -32
  41. package/dist/internal/x509/name-fields.js +1 -1
  42. package/dist/jose/base64url.d.ts +4 -0
  43. package/dist/jose/base64url.js +14 -0
  44. package/dist/jose/base64url.js.map +1 -0
  45. package/dist/jose/errors.d.ts +9 -3
  46. package/dist/jose/errors.js.map +1 -1
  47. package/dist/jose/jwe.d.ts +64 -0
  48. package/dist/jose/jwe.js +188 -0
  49. package/dist/jose/jwe.js.map +1 -0
  50. package/dist/jose/jwks.d.ts +38 -10
  51. package/dist/jose/jwks.js +156 -96
  52. package/dist/jose/jwks.js.map +1 -1
  53. package/dist/jose/jws.d.ts +8 -6
  54. package/dist/jose/jws.js +216 -170
  55. package/dist/jose/jws.js.map +1 -1
  56. package/dist/jose/jwt.d.ts +8 -2
  57. package/dist/jose/jwt.js +98 -98
  58. package/dist/jose/remote-jwks.d.ts +1 -2
  59. package/dist/jose/remote-jwks.js +106 -108
  60. package/dist/jose/remote-jwks.js.map +1 -1
  61. package/dist/jose.d.ts +15 -4
  62. package/dist/jose.js +7 -5
  63. package/dist/kdf/argon2.d.ts +7 -2
  64. package/dist/kdf.d.ts +6 -0
  65. package/dist/keys/keys.d.ts +31 -6
  66. package/dist/keys/keys.js +315 -233
  67. package/dist/keys/keys.js.map +1 -1
  68. package/dist/keys.d.ts +11 -2
  69. package/dist/keys.js +2 -2
  70. package/dist/pem/pem.d.ts +1 -2
  71. package/dist/pem/pem.js +40 -25
  72. package/dist/pem/pem.js.map +1 -1
  73. package/dist/pem.d.ts +6 -0
  74. package/dist/pkcs/pfx.d.ts +2 -3
  75. package/dist/pkcs/pfx.js +142 -142
  76. package/dist/pkcs/pkcs12-mac.d.ts +1 -2
  77. package/dist/pkcs/pkcs12-mac.js +122 -122
  78. package/dist/pkcs/pkcs7.d.ts +14 -3
  79. package/dist/pkcs/pkcs7.js +268 -248
  80. package/dist/pkcs/pkcs7.js.map +1 -1
  81. package/dist/pkcs.d.ts +10 -1
  82. package/dist/pkcs.js +4 -4
  83. package/dist/result/result.d.ts +1 -2
  84. package/dist/result.d.ts +6 -0
  85. package/dist/revocation/chain.d.ts +2 -3
  86. package/dist/revocation/chain.js +52 -52
  87. package/dist/revocation/crl.d.ts +2 -3
  88. package/dist/revocation/crl.js +319 -319
  89. package/dist/revocation/crl.js.map +1 -1
  90. package/dist/revocation/ocsp.d.ts +2 -3
  91. package/dist/revocation/ocsp.js +395 -395
  92. package/dist/revocation/revocation.d.ts +2 -3
  93. package/dist/revocation/revocation.js +22 -22
  94. package/dist/revocation.d.ts +12 -3
  95. package/dist/revocation.js +4 -4
  96. package/dist/ssh/ssh.d.ts +2 -3
  97. package/dist/ssh/ssh.js +165 -170
  98. package/dist/ssh/ssh.js.map +1 -1
  99. package/dist/ssh/wire.d.ts +1 -2
  100. package/dist/ssh/wire.js +10 -10
  101. package/dist/ssh.d.ts +8 -0
  102. package/dist/verify/identity.d.ts +1 -2
  103. package/dist/verify/identity.js +31 -31
  104. package/dist/verify/name-constraints.d.ts +9 -2
  105. package/dist/verify/policy.d.ts +9 -2
  106. package/dist/verify/verify.d.ts +3 -4
  107. package/dist/verify/verify.js +121 -121
  108. package/dist/verify.d.ts +9 -0
  109. package/dist/x509/certificate.d.ts +4 -5
  110. package/dist/x509/certificate.js +40 -40
  111. package/dist/x509/csr.d.ts +3 -4
  112. package/dist/x509/csr.js +15 -15
  113. package/dist/x509/extensions.d.ts +1 -2
  114. package/dist/x509/extensions.js +165 -165
  115. package/dist/x509/extensions.js.map +1 -1
  116. package/dist/x509/fingerprint.d.ts +1 -2
  117. package/dist/x509/name-text.d.ts +1 -2
  118. package/dist/x509/name.d.ts +1 -2
  119. package/dist/x509/name.js +15 -15
  120. package/dist/x509/parse.d.ts +3 -4
  121. package/dist/x509/parse.js +423 -423
  122. package/dist/x509.d.ts +17 -4
  123. package/dist/x509.js +8 -8
  124. package/package.json +22 -23
  125. package/dist/internal/asn1/oids2.js +0 -75
  126. package/dist/internal/asn1/oids2.js.map +0 -1
@@ -137,5 +137,4 @@ export declare function encodeName(input: NameInput): Uint8Array;
137
137
  * @throws {ResultError} If the attribute list is empty, contains an unsupported field key, an empty or over-long value, or an invalid country code.
138
138
  */
139
139
  export declare function encodeRelativeDistinguishedName(attributes: RelativeDistinguishedNameInput): Uint8Array;
140
- export { canonicalDnKey, compareDistinguishedNames, isWithinDirectoryNameSubtree };
141
- //# sourceMappingURL=name.d.ts.map
140
+ export { canonicalDnKey, compareDistinguishedNames, isWithinDirectoryNameSubtree };
package/dist/x509/name.js CHANGED
@@ -1,6 +1,6 @@
1
- import { throwMicro509Error as e } from "../result/result.js";
2
- import { hasLoneSurrogate as t, objectIdentifier as n, sequence as r, setOf as i } from "../internal/asn1/der.js";
3
- import { NAME_FIELD_DEFINITIONS as a, NAME_OBJECT_ORDER as o, nameFieldKeyFromOid as s } from "../internal/x509/name-fields.js";
1
+ import { hasLoneSurrogate as e, objectIdentifier as t, sequence as n, setOf as r } from "../internal/asn1/der.js";
2
+ import { NAME_FIELD_DEFINITIONS as i, NAME_OBJECT_ORDER as a, nameFieldKeyFromOid as o } from "../internal/x509/name-fields.js";
3
+ import { throwMicro509Error as s } from "../result/result.js";
4
4
  import { canonicalDnKey as c, compareDistinguishedNames as l, isWithinDirectoryNameSubtree as u } from "../internal/shared/dn.js";
5
5
  // src/x509/name.ts
6
6
  /**
@@ -67,8 +67,8 @@ import { canonicalDnKey as c, compareDistinguishedNames as l, isWithinDirectoryN
67
67
  * @module
68
68
  */
69
69
  /** Throws a {@link ResultError} for a distinguished-name encoder input-validation failure. */
70
- function throwNameEncoderError(t, n) {
71
- e(t, n);
70
+ function throwNameEncoderError(e, t) {
71
+ s(e, t);
72
72
  }
73
73
  /**
74
74
  * DER-encodes an X.509 `Name`.
@@ -108,7 +108,7 @@ function throwNameEncoderError(t, n) {
108
108
  */
109
109
  function encodeName(e) {
110
110
  let t = isNameAttributes(e) ? e : nameObjectToAttributes(e);
111
- return t.length === 0 ? r([]) : r(t.map(encodeNameAttributeAsSet));
111
+ return t.length === 0 ? n([]) : n(t.map(encodeNameAttributeAsSet));
112
112
  }
113
113
  /** True when a {@linkcode NameInput} resolves to zero attributes (empty DN). */
114
114
  function isNameInputEmpty(e) {
@@ -140,7 +140,7 @@ function isNameInputEmpty(e) {
140
140
  * @throws {ResultError} If the attribute list is empty, contains an unsupported field key, an empty or over-long value, or an invalid country code.
141
141
  */
142
142
  function encodeRelativeDistinguishedName(e) {
143
- return e.length === 0 && throwNameEncoderError("relative_distinguished_name_empty", "Relative distinguished name must contain at least one attribute"), i(e.map(encodeNameAttribute));
143
+ return e.length === 0 && throwNameEncoderError("relative_distinguished_name_empty", "Relative distinguished name must contain at least one attribute"), r(e.map(encodeNameAttribute));
144
144
  }
145
145
  /** Narrows a {@linkcode NameInput} to the ordered-attribute-array form. */
146
146
  function isNameAttributes(e) {
@@ -148,23 +148,23 @@ function isNameAttributes(e) {
148
148
  }
149
149
  /** Wraps a single attribute in a SET OF for the Name SEQUENCE. */
150
150
  function encodeNameAttributeAsSet(e) {
151
- return i([encodeNameAttribute(e)]);
151
+ return r([encodeNameAttribute(e)]);
152
152
  }
153
153
  /**
154
154
  * DER-encodes one name attribute SEQUENCE.
155
155
  *
156
156
  * Throws for unsupported field keys, empty or over-long values, and invalid country codes.
157
157
  */
158
- function encodeNameAttribute(e) {
159
- let i = a[e.type];
160
- i === void 0 && throwNameEncoderError("unsupported_name_field", `Unsupported name field: ${e.type}`);
161
- let o = [...e.value].length;
162
- return o === 0 && throwNameEncoderError("name_attribute_empty", `Name attribute ${e.type} must not be empty`), t(e.value) && throwNameEncoderError("name_attribute_lone_surrogate", `Name attribute ${e.type} holds a lone UTF-16 surrogate`), e.type === "country" && e.value.length !== 2 && throwNameEncoderError("invalid_country_code", "Country must be a 2-character code"), i.maxLength !== void 0 && o > i.maxLength && throwNameEncoderError("name_attribute_too_long", `Name attribute ${e.type} must be at most ${i.maxLength} characters`), r([n(i.oid), i.encode(e.value)]);
158
+ function encodeNameAttribute(r) {
159
+ let a = i[r.type];
160
+ a === void 0 && throwNameEncoderError("unsupported_name_field", `Unsupported name field: ${r.type}`);
161
+ let o = [...r.value].length;
162
+ return o === 0 && throwNameEncoderError("name_attribute_empty", `Name attribute ${r.type} must not be empty`), e(r.value) && throwNameEncoderError("name_attribute_lone_surrogate", `Name attribute ${r.type} holds a lone UTF-16 surrogate`), r.type === "country" && r.value.length !== 2 && throwNameEncoderError("invalid_country_code", "Country must be a 2-character code"), a.maxLength !== void 0 && o > a.maxLength && throwNameEncoderError("name_attribute_too_long", `Name attribute ${r.type} must be at most ${a.maxLength} characters`), n([t(a.oid), a.encode(r.value)]);
163
163
  }
164
164
  /** Converts a {@linkcode NameObject} to ordered attributes per `NAME_OBJECT_ORDER`. */
165
165
  function nameObjectToAttributes(e) {
166
166
  let t = [];
167
- for (let n of o) {
167
+ for (let n of a) {
168
168
  let r = e[n];
169
169
  typeof r == "string" && r.length > 0 && t.push({
170
170
  type: n,
@@ -173,6 +173,6 @@ function nameObjectToAttributes(e) {
173
173
  }
174
174
  return t;
175
175
  }
176
- export { c as canonicalDnKey, l as compareDistinguishedNames, encodeName, encodeRelativeDistinguishedName, isNameInputEmpty, u as isWithinDirectoryNameSubtree, s as nameFieldKeyFromOid };
176
+ export { c as canonicalDnKey, l as compareDistinguishedNames, encodeName, encodeRelativeDistinguishedName, isNameInputEmpty, u as isWithinDirectoryNameSubtree, o as nameFieldKeyFromOid };
177
177
 
178
178
  //# sourceMappingURL=name.js.map
@@ -1,7 +1,7 @@
1
- import { DecodeFailureCode, DecodeRefusalCode, ErrorResult, Micro509Error } from "../result/result.js";
1
+ import { AuthorityInformationAccess, BasicConstraints, CertificatePolicies, DistributionPointReason, ExtendedKeyUsage, GeneralName, GeneralSubtree, InhibitAnyPolicy, KeyUsage, NameConstraints, ParsedBitFlags, ParsedNameConstraintForm, PolicyConstraints, PolicyMappings, SubjectAltName } from "./extensions.js";
2
2
  import { ImportKeyResult, PublicKeyImportInput } from "../keys/keys.js";
3
+ import { DecodeFailureCode, DecodeRefusalCode, ErrorResult, Micro509Error } from "../result/result.js";
3
4
  import { NameFieldKey } from "./name.js";
4
- import { AuthorityInformationAccess, BasicConstraints, CertificatePolicies, DistributionPointReason, ExtendedKeyUsage, GeneralName, GeneralSubtree, InhibitAnyPolicy, KeyUsage, NameConstraints, ParsedBitFlags, ParsedNameConstraintForm, PolicyConstraints, PolicyMappings, SubjectAltName } from "./extensions.js";
5
5
  /**
6
6
  * Machine-readable failure reason for {@linkcode parseCertificateDer} / {@linkcode parseCertificatePem}.
7
7
  *
@@ -675,5 +675,4 @@ export declare function parseCrlDistributionPoints(bytes: Uint8Array): readonly
675
675
  export declare function parseNameConstraints(bytes: Uint8Array): NameConstraints<ParsedNameConstraintForm>;
676
676
  /** Decodes the Authority Key Identifier extension, returning the keyIdentifier hex or undefined. */
677
677
  export declare function parseAuthorityKeyIdentifier(bytes: Uint8Array): string | undefined;
678
- export type { ParsedBitFlags };
679
- //# sourceMappingURL=parse.d.ts.map
678
+ export type { ParsedBitFlags };