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.
- package/CHANGELOG.md +78 -6
- package/dist/crypto/crypto.d.ts +2 -3
- package/dist/crypto.d.ts +6 -0
- package/dist/der/der.d.ts +14 -4
- package/dist/der/der.js +19 -19
- package/dist/der.d.ts +26 -2
- package/dist/der.js +4 -4
- package/dist/index.d.ts +82 -15
- package/dist/index.js +19 -19
- package/dist/internal/asn1/asn1.d.ts +1 -2
- package/dist/internal/asn1/der.d.ts +1 -2
- package/dist/internal/asn1/oids.js +71 -353
- package/dist/internal/asn1/oids.js.map +1 -1
- package/dist/internal/asn1/oids.json.js +357 -0
- package/dist/internal/asn1/oids.json.js.map +1 -0
- package/dist/internal/crypto/algorithm-names.js +1 -1
- package/dist/internal/crypto/pbes2.d.ts +1 -2
- package/dist/internal/crypto/pbes2.js +70 -70
- package/dist/internal/crypto/prime-ec.js +37 -0
- package/dist/internal/crypto/prime-ec.js.map +1 -0
- package/dist/internal/crypto/rsa-pss.js +50 -50
- package/dist/internal/crypto/sig-verify.d.ts +1 -2
- package/dist/internal/crypto/sig-verify.js +60 -60
- package/dist/internal/crypto/signing.d.ts +1 -2
- package/dist/internal/crypto/signing.js +26 -26
- package/dist/internal/jose/json-data.js +108 -0
- package/dist/internal/jose/json-data.js.map +1 -0
- package/dist/internal/jose/strict-json.d.ts +1 -2
- package/dist/internal/shared/dn.d.ts +1 -2
- package/dist/internal/shared/dn.js +1 -1
- package/dist/internal/shared/ip.d.ts +1 -2
- package/dist/internal/verify/name-constraints-engine.js +64 -64
- package/dist/internal/verify/policy-engine.js +1 -1
- package/dist/internal/verify/verify-path.d.ts +1 -2
- package/dist/internal/verify/verify-path.js +19 -19
- package/dist/internal/x509/directory-name.js +10 -10
- package/dist/internal/x509/extension-errors.d.ts +1 -2
- package/dist/internal/x509/extension-registry.js +18 -18
- package/dist/internal/x509/general-name-profile.js +9 -9
- package/dist/internal/x509/general-name.js +32 -32
- package/dist/internal/x509/name-fields.js +1 -1
- package/dist/jose/base64url.d.ts +4 -0
- package/dist/jose/base64url.js +14 -0
- package/dist/jose/base64url.js.map +1 -0
- package/dist/jose/errors.d.ts +9 -3
- package/dist/jose/errors.js.map +1 -1
- package/dist/jose/jwe.d.ts +64 -0
- package/dist/jose/jwe.js +188 -0
- package/dist/jose/jwe.js.map +1 -0
- package/dist/jose/jwks.d.ts +38 -10
- package/dist/jose/jwks.js +156 -96
- package/dist/jose/jwks.js.map +1 -1
- package/dist/jose/jws.d.ts +8 -6
- package/dist/jose/jws.js +216 -170
- package/dist/jose/jws.js.map +1 -1
- package/dist/jose/jwt.d.ts +8 -2
- package/dist/jose/jwt.js +98 -98
- package/dist/jose/remote-jwks.d.ts +1 -2
- package/dist/jose/remote-jwks.js +106 -108
- package/dist/jose/remote-jwks.js.map +1 -1
- package/dist/jose.d.ts +15 -4
- package/dist/jose.js +7 -5
- package/dist/kdf/argon2.d.ts +7 -2
- package/dist/kdf.d.ts +6 -0
- package/dist/keys/keys.d.ts +31 -6
- package/dist/keys/keys.js +315 -233
- package/dist/keys/keys.js.map +1 -1
- package/dist/keys.d.ts +11 -2
- package/dist/keys.js +2 -2
- package/dist/pem/pem.d.ts +1 -2
- package/dist/pem/pem.js +40 -25
- package/dist/pem/pem.js.map +1 -1
- package/dist/pem.d.ts +6 -0
- package/dist/pkcs/pfx.d.ts +2 -3
- package/dist/pkcs/pfx.js +142 -142
- package/dist/pkcs/pkcs12-mac.d.ts +1 -2
- package/dist/pkcs/pkcs12-mac.js +122 -122
- package/dist/pkcs/pkcs7.d.ts +14 -3
- package/dist/pkcs/pkcs7.js +268 -248
- package/dist/pkcs/pkcs7.js.map +1 -1
- package/dist/pkcs.d.ts +10 -1
- package/dist/pkcs.js +4 -4
- package/dist/result/result.d.ts +1 -2
- package/dist/result.d.ts +6 -0
- package/dist/revocation/chain.d.ts +2 -3
- package/dist/revocation/chain.js +52 -52
- package/dist/revocation/crl.d.ts +2 -3
- package/dist/revocation/crl.js +319 -319
- package/dist/revocation/crl.js.map +1 -1
- package/dist/revocation/ocsp.d.ts +2 -3
- package/dist/revocation/ocsp.js +395 -395
- package/dist/revocation/revocation.d.ts +2 -3
- package/dist/revocation/revocation.js +22 -22
- package/dist/revocation.d.ts +12 -3
- package/dist/revocation.js +4 -4
- package/dist/ssh/ssh.d.ts +2 -3
- package/dist/ssh/ssh.js +165 -170
- package/dist/ssh/ssh.js.map +1 -1
- package/dist/ssh/wire.d.ts +1 -2
- package/dist/ssh/wire.js +10 -10
- package/dist/ssh.d.ts +8 -0
- package/dist/verify/identity.d.ts +1 -2
- package/dist/verify/identity.js +31 -31
- package/dist/verify/name-constraints.d.ts +9 -2
- package/dist/verify/policy.d.ts +9 -2
- package/dist/verify/verify.d.ts +3 -4
- package/dist/verify/verify.js +121 -121
- package/dist/verify.d.ts +9 -0
- package/dist/x509/certificate.d.ts +4 -5
- package/dist/x509/certificate.js +40 -40
- package/dist/x509/csr.d.ts +3 -4
- package/dist/x509/csr.js +15 -15
- package/dist/x509/extensions.d.ts +1 -2
- package/dist/x509/extensions.js +165 -165
- package/dist/x509/extensions.js.map +1 -1
- package/dist/x509/fingerprint.d.ts +1 -2
- package/dist/x509/name-text.d.ts +1 -2
- package/dist/x509/name.d.ts +1 -2
- package/dist/x509/name.js +15 -15
- package/dist/x509/parse.d.ts +3 -4
- package/dist/x509/parse.js +423 -423
- package/dist/x509.d.ts +17 -4
- package/dist/x509.js +8 -8
- package/package.json +22 -23
- package/dist/internal/asn1/oids2.js +0 -75
- package/dist/internal/asn1/oids2.js.map +0 -1
package/dist/x509/name.d.ts
CHANGED
|
@@ -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 {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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(
|
|
71
|
-
e
|
|
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 ?
|
|
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"),
|
|
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
|
|
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(
|
|
159
|
-
let
|
|
160
|
-
|
|
161
|
-
let o = [...
|
|
162
|
-
return o === 0 && throwNameEncoderError("name_attribute_empty", `Name attribute ${
|
|
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
|
|
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,
|
|
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
|
package/dist/x509/parse.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
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 };
|