@peculiar/x509
Advanced tools
Comparing version 1.0.8 to 1.0.9
import { Name as AsnName } from "@peculiar/asn1-x509"; | ||
export interface IdOrName { | ||
[idOrName: string]: string; | ||
} | ||
export declare class NameIdentifier { | ||
private items; | ||
get(idOrName: string): string | null; | ||
register(id: string, name: string): void; | ||
} | ||
export interface JsonAttributeAndValue { | ||
@@ -7,4 +15,6 @@ [type: string]: string[]; | ||
export declare class Name { | ||
private extraNames; | ||
private asn; | ||
constructor(data: BufferSource | AsnName | string | JsonName); | ||
constructor(data: BufferSource | AsnName | string | JsonName, extraNames?: IdOrName); | ||
private getName; | ||
toString(): string; | ||
@@ -11,0 +21,0 @@ toJSON(): JsonName; |
@@ -155,11 +155,12 @@ /*! | ||
} | ||
var ValueType; | ||
(function (ValueType) { | ||
ValueType[ValueType["simple"] = 0] = "simple"; | ||
ValueType[ValueType["quoted"] = 1] = "quoted"; | ||
ValueType[ValueType["hexadecimal"] = 2] = "hexadecimal"; | ||
})(ValueType || (ValueType = {})); | ||
class Name { | ||
constructor(data) { | ||
constructor(data, extraNames = {}) { | ||
this.extraNames = new NameIdentifier(); | ||
this.asn = new asn1X509.Name(); | ||
for (const key in extraNames) { | ||
if (Object.prototype.hasOwnProperty.call(extraNames, key)) { | ||
const value = extraNames[key]; | ||
this.extraNames.register(key, value); | ||
} | ||
} | ||
if (typeof data === "string") { | ||
@@ -178,5 +179,8 @@ this.asn = this.fromString(data); | ||
} | ||
getName(idOrName) { | ||
return this.extraNames.get(idOrName) || names.get(idOrName); | ||
} | ||
toString() { | ||
return this.asn.map(rdn => rdn.map(o => { | ||
const type = names.get(o.type) || o.type; | ||
const type = this.getName(o.type) || o.type; | ||
const value = o.value.anyValue | ||
@@ -196,3 +200,3 @@ ? `#${pvtsutils.Convert.ToHex(o.value.anyValue)}` | ||
for (const attr of rdn) { | ||
const type = names.get(attr.type) || attr.type; | ||
const type = this.getName(attr.type) || attr.type; | ||
(_a = jsonItem[type]) !== null && _a !== void 0 ? _a : (jsonItem[type] = []); | ||
@@ -207,3 +211,3 @@ jsonItem[type].push(attr.value.anyValue ? `#${pvtsutils.Convert.ToHex(attr.value.anyValue)}` : attr.value.toString()); | ||
const asn = new asn1X509.Name(); | ||
const regex = /(\d\.[\d.]*\d|[A-Z]+)=(((?:").*?(?<!\\)(?:"))|([^"].*?))((?<!\\)[,+])/g; | ||
const regex = /(\d\.[\d.]*\d|[A-Za-z]+)=(((?:").*?(?<!\\)(?:"))|([^"].*?))((?<!\\)[,+])/g; | ||
let matches = null; | ||
@@ -215,3 +219,3 @@ let level = ","; | ||
if (!/[\d.]+/.test(type)) { | ||
type = names.get(type) || ""; | ||
type = this.getName(type) || ""; | ||
} | ||
@@ -235,3 +239,3 @@ if (!type) { | ||
.replace(/\\(.)/g, "$1"); | ||
if (type === names.get("E") || type === names.get("DC")) { | ||
if (type === this.getName("E") || type === this.getName("DC")) { | ||
attr.value.ia5String = value; | ||
@@ -260,3 +264,3 @@ } | ||
if (!/[\d.]+/.test(type)) { | ||
typeId = names.get(type) || ""; | ||
typeId = this.getName(type) || ""; | ||
} | ||
@@ -273,3 +277,3 @@ if (!typeId) { | ||
else { | ||
if (typeId === names.get("E") || typeId === names.get("DC")) { | ||
if (typeId === this.getName("E") || typeId === this.getName("DC")) { | ||
asnAttr.value.ia5String = value; | ||
@@ -1357,2 +1361,3 @@ } | ||
exports.Name = Name; | ||
exports.NameIdentifier = NameIdentifier; | ||
exports.OtherName = OtherName; | ||
@@ -1359,0 +1364,0 @@ exports.PemConverter = PemConverter; |
@@ -151,11 +151,12 @@ /*! | ||
} | ||
var ValueType; | ||
(function (ValueType) { | ||
ValueType[ValueType["simple"] = 0] = "simple"; | ||
ValueType[ValueType["quoted"] = 1] = "quoted"; | ||
ValueType[ValueType["hexadecimal"] = 2] = "hexadecimal"; | ||
})(ValueType || (ValueType = {})); | ||
class Name { | ||
constructor(data) { | ||
constructor(data, extraNames = {}) { | ||
this.extraNames = new NameIdentifier(); | ||
this.asn = new Name$1(); | ||
for (const key in extraNames) { | ||
if (Object.prototype.hasOwnProperty.call(extraNames, key)) { | ||
const value = extraNames[key]; | ||
this.extraNames.register(key, value); | ||
} | ||
} | ||
if (typeof data === "string") { | ||
@@ -174,5 +175,8 @@ this.asn = this.fromString(data); | ||
} | ||
getName(idOrName) { | ||
return this.extraNames.get(idOrName) || names.get(idOrName); | ||
} | ||
toString() { | ||
return this.asn.map(rdn => rdn.map(o => { | ||
const type = names.get(o.type) || o.type; | ||
const type = this.getName(o.type) || o.type; | ||
const value = o.value.anyValue | ||
@@ -192,3 +196,3 @@ ? `#${Convert.ToHex(o.value.anyValue)}` | ||
for (const attr of rdn) { | ||
const type = names.get(attr.type) || attr.type; | ||
const type = this.getName(attr.type) || attr.type; | ||
(_a = jsonItem[type]) !== null && _a !== void 0 ? _a : (jsonItem[type] = []); | ||
@@ -203,3 +207,3 @@ jsonItem[type].push(attr.value.anyValue ? `#${Convert.ToHex(attr.value.anyValue)}` : attr.value.toString()); | ||
const asn = new Name$1(); | ||
const regex = /(\d\.[\d.]*\d|[A-Z]+)=(((?:").*?(?<!\\)(?:"))|([^"].*?))((?<!\\)[,+])/g; | ||
const regex = /(\d\.[\d.]*\d|[A-Za-z]+)=(((?:").*?(?<!\\)(?:"))|([^"].*?))((?<!\\)[,+])/g; | ||
let matches = null; | ||
@@ -211,3 +215,3 @@ let level = ","; | ||
if (!/[\d.]+/.test(type)) { | ||
type = names.get(type) || ""; | ||
type = this.getName(type) || ""; | ||
} | ||
@@ -231,3 +235,3 @@ if (!type) { | ||
.replace(/\\(.)/g, "$1"); | ||
if (type === names.get("E") || type === names.get("DC")) { | ||
if (type === this.getName("E") || type === this.getName("DC")) { | ||
attr.value.ia5String = value; | ||
@@ -256,3 +260,3 @@ } | ||
if (!/[\d.]+/.test(type)) { | ||
typeId = names.get(type) || ""; | ||
typeId = this.getName(type) || ""; | ||
} | ||
@@ -269,3 +273,3 @@ if (!typeId) { | ||
else { | ||
if (typeId === names.get("E") || typeId === names.get("DC")) { | ||
if (typeId === this.getName("E") || typeId === this.getName("DC")) { | ||
asnAttr.value.ia5String = value; | ||
@@ -1340,2 +1344,2 @@ } | ||
export { AlgorithmProvider, AsnData, Attribute, AttributeFactory, AuthorityKeyIdentifierExtension, BasicConstraintsExtension, ChallengePasswordAttribute, CryptoProvider, EcAlgorithm, ExtendedKeyUsageExtension, Extension, ExtensionFactory, ExtensionsAttribute, KeyUsageFlags, KeyUsagesExtension, Name, OtherName, PemConverter, Pkcs10CertificateRequest, Pkcs10CertificateRequestGenerator, PublicKey, RsaAlgorithm, SubjectAlternativeNameExtension, SubjectKeyIdentifierExtension, X509Certificate, X509CertificateGenerator, X509Certificates, X509ChainBuilder, cryptoProvider, diAlgorithm, diAlgorithmProvider }; | ||
export { AlgorithmProvider, AsnData, Attribute, AttributeFactory, AuthorityKeyIdentifierExtension, BasicConstraintsExtension, ChallengePasswordAttribute, CryptoProvider, EcAlgorithm, ExtendedKeyUsageExtension, Extension, ExtensionFactory, ExtensionsAttribute, KeyUsageFlags, KeyUsagesExtension, Name, NameIdentifier, OtherName, PemConverter, Pkcs10CertificateRequest, Pkcs10CertificateRequestGenerator, PublicKey, RsaAlgorithm, SubjectAlternativeNameExtension, SubjectKeyIdentifierExtension, X509Certificate, X509CertificateGenerator, X509Certificates, X509ChainBuilder, cryptoProvider, diAlgorithm, diAlgorithmProvider }; |
{ | ||
"name": "@peculiar/x509", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "@peculiar/x509 is an easy to use TypeScript/Javascript library based on @peculiar/asn1-schema that makes generating X.509 Certificates and Certificate Requests as well as validating certificate chains easy", | ||
@@ -5,0 +5,0 @@ "main": "build/x509.cjs.js", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
304957
3742