| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746 |
- /*!
- * MIT License
- *
- * Copyright (c) Peculiar Ventures. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
- import * as asn1X509 from '@peculiar/asn1-x509';
- import { Extension as Extension$1, SubjectPublicKeyInfo, Attribute as Attribute$1, AlgorithmIdentifier, Name as Name$1, Certificate, RevokedCertificate, CertificateList, Version } from '@peculiar/asn1-x509';
- import * as asn1Rsa from '@peculiar/asn1-rsa';
- import { CertificationRequest } from '@peculiar/asn1-csr';
- import { BufferSource as BufferSource$1 } from 'pvtsutils';
- interface TextObjectConvertible {
- /**
- * Returns the object in textual representation
- */
- toTextObject(): TextObject;
- }
- type TextObjectItemType = string | number | boolean | Date | BufferSource | TextObject | TextObject[] | TextObjectConvertible;
- declare const NAME: unique symbol;
- declare const VALUE: unique symbol;
- declare class TextObject {
- static NAME: typeof NAME;
- static VALUE: typeof VALUE;
- [key: string | symbol]: TextObjectItemType;
- [NAME]: string;
- [VALUE]: string;
- constructor(name: string, items?: Record<string, TextObjectItemType>, value?: string);
- }
- interface AlgorithmSerializer {
- toTextObject(alg: asn1X509.AlgorithmIdentifier): TextObject;
- }
- declare abstract class DefaultAlgorithmSerializer {
- static toTextObject(alg: asn1X509.AlgorithmIdentifier): TextObject;
- }
- declare abstract class OidSerializer {
- static items: Record<string, string>;
- static toString(oid: string): string;
- }
- declare abstract class TextConverter {
- static oidSerializer: typeof OidSerializer;
- static algorithmSerializer: AlgorithmSerializer;
- static serialize(obj: TextObject): string;
- private static pad;
- private static serializeObj;
- private static serializeBufferSource;
- static serializeAlgorithm(alg: asn1X509.AlgorithmIdentifier): TextObject;
- }
- type AsnDataStringFormat = "asn" | "text" | "hex" | "base64" | "base64url";
- /**
- * Represents an ASN.1 data
- */
- declare abstract class AsnData<T> implements TextObjectConvertible {
- #private;
- static NAME: string;
- /**
- * Gets a DER encoded buffer
- */
- get rawData(): ArrayBuffer;
- /**
- * ASN.1 object
- */
- protected readonly asn: T;
- /**
- * Creates a new instance
- * @param raw DER encoded buffer
- * @param type ASN.1 convertible class for `@peculiar/asn1-schema` schema
- */
- constructor(raw: BufferSource, type: new () => T);
- /**
- * ASN.1 object
- * @param asn
- */
- constructor(asn: T);
- /**
- * Occurs on instance initialization
- * @param asn ASN.1 object
- */
- protected abstract onInit(asn: T): void;
- /**
- * Returns `true` if ASN.1 data is equal to another ASN.1 data, otherwise `false`
- * @param data Any data
- */
- equal(data: any): data is this;
- toString(format?: AsnDataStringFormat): string;
- protected getTextName(): string;
- toTextObject(): TextObject;
- protected toTextObjectEmpty(value?: string): TextObject;
- }
- /**
- * Represents the certificate extension
- */
- declare class Extension extends AsnData<Extension$1> {
- /**
- * Gets an extension identifier
- */
- type: string;
- /**
- * Indicates where extension is critical
- */
- critical: boolean;
- /**
- * Gets a DER encoded value of extension
- */
- value: ArrayBuffer;
- /**
- * Creates a new instance from DER encoded Buffer
- * @param raw DER encoded buffer
- */
- constructor(raw: BufferSource);
- /**
- * Creates a new instance
- * @param type Extension identifier
- * @param critical Indicates where extension is critical
- * @param value DER encoded value of extension
- */
- constructor(type: string, critical: boolean, value: BufferSource);
- protected onInit(asn: Extension$1): void;
- toTextObject(): TextObject;
- toTextObjectWithoutValue(): TextObject;
- }
- interface JsonGeneralName {
- type: GeneralNameType;
- value: string;
- }
- declare const DNS = "dns";
- declare const DN = "dn";
- declare const EMAIL = "email";
- declare const IP = "ip";
- declare const URL = "url";
- declare const GUID = "guid";
- declare const UPN = "upn";
- declare const REGISTERED_ID = "id";
- type GeneralNameType = typeof DNS | typeof DN | typeof EMAIL | typeof GUID | typeof IP | typeof URL | typeof UPN | typeof REGISTERED_ID;
- /**
- * Represents ASN.1 type of GeneralName.
- *
- * This class doesn't support no standard string format is
- * defined for otherName, X.400 name, EDI party name, or any other type of names.
- */
- declare class GeneralName extends AsnData<asn1X509.GeneralName> {
- /**
- * Type of the storing value
- */
- type: GeneralNameType;
- /**
- * Text representation of ASN.1 GeneralName
- */
- value: string;
- constructor(type: GeneralNameType, value: string);
- constructor(asn: asn1X509.GeneralName);
- constructor(raw: BufferSource);
- /**
- * Occurs on instance initialization
- * @param asn
- *
- * @throws Throws error if ASN.1 GeneralName contains
- * unsupported value (eg otherName, X400 address, EDI party name)
- */
- protected onInit(asn: asn1X509.GeneralName): void;
- toJSON(): JsonGeneralName;
- toTextObject(): TextObject;
- }
- type JsonGeneralNames = JsonGeneralName[];
- declare class GeneralNames extends AsnData<asn1X509.GeneralNames> {
- static NAME: string;
- items: readonly GeneralName[];
- constructor(json: JsonGeneralNames);
- constructor(asn: asn1X509.GeneralNames | asn1X509.GeneralName[]);
- constructor(raw: BufferSource);
- protected onInit(asn: asn1X509.GeneralNames): void;
- toJSON(): JsonGeneralNames;
- toTextObject(): TextObject;
- }
- type AsnExportType = "pem" | AsnDataStringFormat;
- type AsnEncodedType = BufferSource | string;
- declare abstract class PemData<T> extends AsnData<T> {
- static isAsnEncoded(data: any): data is AsnEncodedType;
- /**
- * Converts encoded raw to ArrayBuffer. Supported formats are HEX, DER, Base64, Base64Url, PEM
- * @param raw Encoded data
- */
- static toArrayBuffer(raw: BufferSource | string): ArrayBuffer;
- /**
- * PEM tag
- */
- protected abstract readonly tag: string;
- /**
- * Creates a new instance
- * @param raw Encoded buffer (DER, PEM, HEX, Base64, Base64Url)
- * @param type ASN.1 convertible class for `@peculiar/asn1-schema` schema
- */
- constructor(raw: AsnEncodedType, type: new () => T);
- /**
- * Creates a new instance
- * @param asn ASN.1 object
- */
- constructor(asn: T);
- /**
- * Returns encoded object in PEM format
- */
- toString(): string;
- /**
- * Returns encoded object in selected format
- * @param format hex, base64, base64url, pem, asn, text
- */
- toString(format: AsnExportType): string;
- }
- interface IPublicKeyContainer {
- publicKey: PublicKey;
- }
- /**
- * Public key type. Represents a public key in different formats.
- */
- type PublicKeyType = PublicKey | CryptoKey | IPublicKeyContainer | BufferSource;
- /**
- * Representation of Subject Public Key Info
- */
- declare class PublicKey extends PemData<SubjectPublicKeyInfo> {
- /**
- * Creates a new instance from a public key data
- * @param data Public key data
- * @param crypto Crypto provider. Default is from CryptoProvider
- */
- static create(data: PublicKeyType, crypto?: Crypto): Promise<PublicKey>;
- protected readonly tag: string;
- /**
- * Gets a key algorithm
- */
- algorithm: Algorithm;
- /**
- * Creates a new instance from ASN.1
- * @param asn ASN.1 object
- */
- constructor(asn: SubjectPublicKeyInfo);
- /**
- * Creates a new instance
- * @param raw Encoded buffer (DER, PEM, HEX, Base64, Base64Url)
- */
- constructor(raw: AsnEncodedType);
- /**
- * Returns a public CryptoKey
- * @param crypto Crypto provider. Default is from CryptoProvider
- */
- export(crypto?: Crypto): Promise<CryptoKey>;
- /**
- * Returns a public CryptoKey with specified parameters
- * @param algorithm Algorithm
- * @param keyUsages A list of key usages
- * @param crypto Crypto provider. Default is from CryptoProvider
- */
- export(algorithm: Algorithm | EcKeyImportParams | RsaHashedImportParams, keyUsages: KeyUsage[], crypto?: Crypto): Promise<CryptoKey>;
- protected onInit(asn: SubjectPublicKeyInfo): void;
- /**
- * Returns a SHA-1 public key thumbprint
- * @param crypto Crypto provider. Default is from CryptoProvider
- */
- getThumbprint(crypto?: Crypto): Promise<ArrayBuffer>;
- /**
- * Returns a public key thumbprint for specified mechanism
- * @param algorithm Hash algorithm
- * @param crypto Crypto provider. Default is from CryptoProvider
- */
- getThumbprint(algorithm: globalThis.AlgorithmIdentifier, crypto?: Crypto): Promise<ArrayBuffer>;
- /**
- * Returns Subject Key Identifier as specified in {@link https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.2 RFC5280}
- * @param crypto Crypto provider. Default is from CryptoProvider
- */
- getKeyIdentifier(crypto?: Crypto): Promise<ArrayBuffer>;
- /**
- * Returns Subject Key Identifier for specified algorithm
- * @param algorithm Hash algorithm
- * @param crypto Crypto provider. Default is from CryptoProvider
- */
- getKeyIdentifier(algorithm: globalThis.AlgorithmIdentifier, crypto?: Crypto): Promise<ArrayBuffer>;
- toTextObject(): TextObject;
- }
- interface CertificateIdentifier {
- /**
- * Name
- */
- name: asn1X509.GeneralName[] | asn1X509.GeneralNames | GeneralNames;
- /**
- * Hexadecimal string
- */
- serialNumber: string;
- }
- /**
- * Represents the Authority Key Identifier certificate extension
- */
- declare class AuthorityKeyIdentifierExtension extends Extension {
- static NAME: string;
- /**
- * Creates authority key identifier extension from certificate identifier
- * @param certId Certificate identifier
- * @param critical Indicates where extension is critical. Default is `false`
- * @param crypto WebCrypto provider. Default is from CryptoProvider
- */
- static create(certId: CertificateIdentifier, critical?: boolean, crypto?: Crypto): Promise<AuthorityKeyIdentifierExtension>;
- /**
- * Creates authority key identifier extension from public key data
- * @param publicKey Public key data
- * @param critical Indicates where extension is critical. Default is `false`
- * @param crypto WebCrypto provider. Default is from CryptoProvider
- */
- static create(publicKey: PublicKeyType, critical?: boolean, crypto?: Crypto): Promise<AuthorityKeyIdentifierExtension>;
- /**
- * Gets a hexadecimal representation of key identifier
- */
- keyId?: string;
- /**
- * Gets a certificate identifier in the issuer name and serial number
- */
- certId?: CertificateIdentifier;
- /**
- * Creates a new instance from DER encoded buffer
- * @param raw DER encoded buffer
- */
- constructor(raw: BufferSource);
- /**
- * Creates a new instance
- * @param identifier Hexadecimal representation of key identifier
- * @param critical Indicates where extension is critical. Default is `false`
- */
- constructor(identifier: string, critical?: boolean);
- /**
- * Creates a new instance
- * @param id Certificate identifier in the issuer name and serial number
- * @param critical Indicates where extension is critical. Default is `false`
- */
- constructor(id: CertificateIdentifier, critical?: boolean);
- protected onInit(asn: asn1X509.Extension): void;
- toTextObject(): TextObject;
- }
- /**
- * Represents the Basic Constraints certificate extension
- */
- declare class BasicConstraintsExtension extends Extension {
- static NAME: string;
- /**
- * Indicates whether the certified public key may be used
- * to verify certificate signatures
- */
- readonly ca: boolean;
- /**
- * Gets a maximum number of non-self-issued intermediate certificates that may
- * follow this certificate in a valid certification path
- */
- readonly pathLength?: number;
- /**
- * Creates a new instance from DER encoded buffer
- * @param raw DER encoded buffer
- */
- constructor(raw: BufferSource);
- /**
- * Creates a new instance
- * @param ca
- * @param pathLength
- * @param critical
- */
- constructor(ca: boolean, pathLength?: number, critical?: boolean);
- toTextObject(): TextObject;
- }
- declare enum ExtendedKeyUsage {
- serverAuth = "1.3.6.1.5.5.7.3.1",
- clientAuth = "1.3.6.1.5.5.7.3.2",
- codeSigning = "1.3.6.1.5.5.7.3.3",
- emailProtection = "1.3.6.1.5.5.7.3.4",
- timeStamping = "1.3.6.1.5.5.7.3.8",
- ocspSigning = "1.3.6.1.5.5.7.3.9"
- }
- type ExtendedKeyUsageType = asn1X509.ExtendedKeyUsage | string;
- /**
- * Represents the Extended Key Usage certificate extension
- */
- declare class ExtendedKeyUsageExtension extends Extension {
- static NAME: string;
- /**
- * Gets a list of purposes for which the certified public key may be used
- */
- readonly usages: ExtendedKeyUsageType[];
- /**
- * Creates a new instance from DER encoded buffer
- * @param raw DER encoded buffer
- */
- constructor(raw: BufferSource);
- /**
- * Creates a new instance
- * @param usages
- * @param critical
- */
- constructor(usages: ExtendedKeyUsageType[], critical?: boolean);
- toTextObject(): TextObject;
- }
- /**
- * X509 key usages flags
- */
- declare enum KeyUsageFlags {
- digitalSignature = 1,
- nonRepudiation = 2,
- keyEncipherment = 4,
- dataEncipherment = 8,
- keyAgreement = 16,
- keyCertSign = 32,
- cRLSign = 64,
- encipherOnly = 128,
- decipherOnly = 256
- }
- /**
- * Represents the Key Usage certificate extension
- */
- declare class KeyUsagesExtension extends Extension {
- static NAME: string;
- /**
- * Gets a key usages flag
- */
- readonly usages: KeyUsageFlags;
- /**
- * Creates a new instance from DER encoded buffer
- * @param raw DER encoded buffer
- */
- constructor(raw: BufferSource);
- /**
- * Creates a new instance
- * @param usages
- * @param critical
- */
- constructor(usages: KeyUsageFlags, critical?: boolean);
- toTextObject(): TextObject;
- }
- /**
- * Represents the Subject Key Identifier certificate extension
- */
- declare class SubjectKeyIdentifierExtension extends Extension {
- static NAME: string;
- /**
- * Creates subject key identifier extension from public key data
- * @param publicKey Public key data
- * @param critical Indicates where extension is critical. Default is `false`
- * @param crypto WebCrypto provider. Default is from CryptoProvider
- */
- static create(publicKey: PublicKeyType, critical?: boolean, crypto?: Crypto): Promise<SubjectKeyIdentifierExtension>;
- /**
- * Gets hexadecimal representation of key identifier
- */
- readonly keyId: string;
- /**
- * Creates a new instance from DER encoded buffer
- * @param raw DER encoded buffer
- */
- constructor(raw: BufferSource);
- /**
- * Creates a new instance
- * @param keyId Hexadecimal representation of key identifier
- * @param critical Indicates where extension is critical. Default is `false`
- */
- constructor(keyId: string, critical?: boolean);
- toTextObject(): TextObject;
- }
- /**
- * Represents the Subject Alternative Name certificate extension
- */
- declare class SubjectAlternativeNameExtension extends Extension {
- names: GeneralNames;
- static NAME: string;
- /**
- * Creates a new instance from DER encoded buffer
- * @param raw DER encoded buffer
- */
- constructor(raw: BufferSource);
- /**
- * Creates a new instance
- * @param data JSON representation of SAN
- * @param critical Indicates where extension is critical. Default is `false`
- */
- constructor(data?: JsonGeneralNames, critical?: boolean);
- onInit(asn: asn1X509.Extension): void;
- toTextObject(): TextObject;
- }
- /**
- * Represents the Certificate Policy extension
- */
- declare class CertificatePolicyExtension extends Extension {
- static NAME: string;
- /**
- * Gets the list of certificate policies
- */
- readonly policies: readonly string[];
- /**
- * Creates a new instance from DER encoded buffer
- * @param raw DER encoded buffer
- */
- constructor(raw: BufferSource);
- /**
- * Creates a new instance
- * @param policies
- * @param critical
- */
- constructor(policies: string[], critical?: boolean);
- toTextObject(): TextObject;
- }
- /**
- * Represents the CRL Distribution Points extension
- */
- declare class CRLDistributionPointsExtension extends Extension {
- static NAME: string;
- distributionPoints: asn1X509.DistributionPoint[];
- /**
- * Creates a new instance from DER encoded buffer
- * @param raw DER encoded buffer
- */
- constructor(raw: BufferSource);
- /**
- * Creates a new instance
- * @param value The value of the extension
- * @param critical Indicates whether the extension is critical. Default is `false`
- */
- constructor(value: asn1X509.DistributionPoint[], critical?: boolean);
- /**
- * Creates a new instance from an array of URLs
- * @param urls An array of URLs to be used as distribution points.
- * @param critical Indicates whether the extension is critical. Default is `false`
- */
- constructor(urls: string[], critical?: boolean);
- protected onInit(asn: asn1X509.Extension): void;
- toTextObject(): TextObject;
- }
- type AccessItemTypes = GeneralName | GeneralName[] | string | string[];
- interface AuthorityInfoAccessParams {
- ocsp?: AccessItemTypes;
- caIssuers?: AccessItemTypes;
- timeStamping?: AccessItemTypes;
- caRepository?: AccessItemTypes;
- }
- /**
- * Represents the Authority Info Access certificate extension
- */
- declare class AuthorityInfoAccessExtension extends Extension {
- static NAME: string;
- ocsp: GeneralName[];
- caIssuers: GeneralName[];
- timeStamping: GeneralName[];
- caRepository: GeneralName[];
- /**
- * Creates a new instance from DER encoded buffer
- * @param raw DER encoded buffer
- */
- constructor(raw: BufferSource);
- /**
- * Creates a new instance
- * @param value The value of the extension
- * @param critical Indicates whether the extension is critical. Default is `false`
- */
- constructor(value: asn1X509.AuthorityInfoAccessSyntax, critical?: boolean);
- /**
- * Creates a new instance
- * @param params The value of the extension
- * @param critical Indicates whether the extension is critical. Default is `false`
- */
- constructor(params: AuthorityInfoAccessParams, critical?: boolean);
- protected onInit(asn: asn1X509.Extension): void;
- toTextObject(): TextObject;
- }
- /**
- * Represents the Issuer Alternative Name certificate extension
- */
- declare class IssuerAlternativeNameExtension extends Extension {
- names: GeneralNames;
- static NAME: string;
- /**
- * Creates a new instance from DER encoded buffer
- * @param raw DER encoded buffer
- */
- constructor(raw: BufferSource);
- /**
- * Creates a new instance
- * @param data JSON representation of IAN
- * @param critical Indicates where extension is critical. Default is `false`
- */
- constructor(data?: JsonGeneralNames, critical?: boolean);
- onInit(asn: asn1X509.Extension): void;
- toTextObject(): TextObject;
- }
- /**
- * Static class to manage X509 extensions
- */
- declare class ExtensionFactory {
- private static items;
- /**
- * Registers a new X509 Extension class. If id already exists replaces it
- * @param id Extension identifier
- * @param type Extension class
- *
- * @example
- * ```js
- * ExtensionFactory.register(
- * asnX509.id_ce_basicConstraints,
- * extensions.BasicConstraintsExtension,
- * );
- * ```
- */
- static register(id: string, type: any): void;
- /**
- * Returns X509 Extension based on it's identifier
- * @param data DER encoded buffer
- *
- * @example
- * ```js
- * const ext = ExtensionFactory.create(asnExtRaw);
- * ```
- */
- static create(data: BufferSource): Extension;
- }
- /**
- * Represents the Attribute structure
- */
- declare class Attribute extends AsnData<Attribute$1> {
- static NAME: string;
- /**
- * Gets an attribute identifier
- */
- type: string;
- /**
- * Gets a list of DER encoded attribute values
- */
- values: ArrayBuffer[];
- /**
- * Crates a new instance
- * @param type Attribute identifier
- * @param values List of DER encoded attribute values
- */
- constructor(type: string, values?: BufferSource[]);
- /**
- * Crates a new instance from DER encoded buffer
- * @param raw DER encoded buffer
- */
- constructor(raw: BufferSource);
- protected onInit(asn: Attribute$1): void;
- toTextObject(): TextObject;
- toTextObjectWithoutValue(): TextObject;
- }
- declare class ChallengePasswordAttribute extends Attribute {
- static NAME: string;
- password: string;
- /**
- * Creates a new instance from DER encoded buffer
- * @param raw DER encoded buffer
- */
- constructor(raw: BufferSource);
- /**
- * Creates a new instance
- * @param value
- */
- constructor(value: string);
- protected onInit(asn: asn1X509.Attribute): void;
- toTextObject(): TextObject;
- }
- declare class ExtensionsAttribute extends Attribute {
- static NAME: string;
- items: Extension[];
- /**
- * Creates a new instance from DER encoded buffer
- * @param raw DER encoded buffer
- */
- constructor(raw: BufferSource);
- /**
- * Creates a new instance
- * @param extensions
- */
- constructor(extensions: Extension[]);
- protected onInit(asn: asn1X509.Attribute): void;
- toTextObject(): TextObject;
- }
- /**
- * Static class to manage X509 attributes
- */
- declare class AttributeFactory {
- private static items;
- /**
- * Registers a new X509 Attribute class. If id already exists replaces it
- * @param id Attribute identifier
- * @param type Attribute class
- *
- * @example
- * ```js
- * AttributeFactory.register(asnPkcs9.id_pkcs9_at_challengePassword, ChallengePasswordAttribute);
- * ```
- */
- static register(id: string, type: any): void;
- /**
- * Returns X509 Attribute based on it's identifier
- * @param data DER encoded buffer
- *
- * @example
- * ```js
- * const attr = AttributeFactory.create(asnAttrRaw);
- * ```
- */
- static create(data: BufferSource): Attribute;
- }
- /**
- * Dependency injection identifier for `IAsnSignatureFormatter` interface
- */
- declare const diAsnSignatureFormatter = "crypto.signatureFormatter";
- /**
- * Provides mechanism to convert ASN.1 signature value to WebCrypto and back
- *
- * To register it's implementation in global use `tsyringe` container
- * @example
- * ```
- * import { container } from "tsyringe";
- *
- * container.registerSingleton(diAsnSignatureFormatter, AsnDefaultSignatureFormatter);
- * ```
- */
- interface IAsnSignatureFormatter {
- /**
- * Converts ASN.1 signature to WebCrypto format
- * @param algorithm Key and signing algorithm
- * @param signature ASN.1 signature value in DER format
- */
- toAsnSignature(algorithm: Algorithm, signature: BufferSource): ArrayBuffer | null;
- /**
- * Converts WebCrypto signature to ASN.1 DER encoded signature value
- * @param algorithm
- * @param signature
- */
- toWebSignature(algorithm: Algorithm, signature: BufferSource): ArrayBuffer | null;
- }
- declare class AsnDefaultSignatureFormatter implements IAsnSignatureFormatter {
- toAsnSignature(algorithm: Algorithm, signature: BufferSource): ArrayBuffer | null;
- toWebSignature(algorithm: Algorithm, signature: BufferSource): ArrayBuffer | null;
- }
- interface UnknownAlgorithm extends Algorithm {
- name: string;
- parameters?: ArrayBuffer | null;
- }
- interface IAlgorithm {
- /**
- * Converts WebCrypto algorithm to ASN.1 algorithm
- * @param alg WebCrypto algorithm
- * @returns ASN.1 algorithm or null
- */
- toAsnAlgorithm(alg: Algorithm): AlgorithmIdentifier | null;
- /**
- * Converts ASN.1 algorithm to WebCrypto algorithm
- * @param alg ASN.1 algorithm
- * @returns WebCrypto algorithm or null
- */
- toWebAlgorithm(alg: AlgorithmIdentifier): Algorithm | null;
- }
- /**
- * Dependency Injection algorithm identifier
- */
- declare const diAlgorithm = "crypto.algorithm";
- declare class AlgorithmProvider {
- /**
- * Returns all registered algorithm providers
- */
- getAlgorithms(): IAlgorithm[];
- /**
- * Converts WebCrypto algorithm to ASN.1 algorithm
- * @param alg WebCrypto algorithm
- * @returns ASN.1 algorithm
- * @throws Error whenever cannot convert an algorithm
- */
- toAsnAlgorithm(alg: Algorithm): AlgorithmIdentifier;
- /**
- * ConvertsASN.1 algorithm to WebCrypto algorithm
- * @param alg ASN.1 algorithm
- * @returns algorithm
- */
- toWebAlgorithm(alg: AlgorithmIdentifier): Algorithm;
- }
- declare const diAlgorithmProvider = "crypto.algorithmProvider";
- interface HashedAlgorithm extends Algorithm {
- hash: Algorithm;
- }
- /**
- * RSA algorithm provider
- */
- declare class RsaAlgorithm implements IAlgorithm {
- static createPssParams(hash: unknown, saltLength: number): asn1Rsa.RsaSaPssParams | null;
- static getHashAlgorithm(alg: unknown): AlgorithmIdentifier | null;
- toAsnAlgorithm(alg: Algorithm): AlgorithmIdentifier | null;
- toWebAlgorithm(alg: AlgorithmIdentifier): Algorithm | HashedAlgorithm | null;
- }
- /**
- * EC algorithm provider
- */
- declare class EcAlgorithm implements IAlgorithm {
- static SECP256K1: string;
- toAsnAlgorithm(alg: HashedAlgorithm | EcKeyGenParams): AlgorithmIdentifier | null;
- toWebAlgorithm(alg: AlgorithmIdentifier): HashedAlgorithm | EcKeyGenParams | null;
- }
- /**
- * SHA algorithm provider
- */
- declare class ShaAlgorithm implements IAlgorithm {
- toAsnAlgorithm(alg: Algorithm): AlgorithmIdentifier | null;
- toWebAlgorithm(alg: AlgorithmIdentifier): Algorithm | null;
- }
- declare class AsnEcSignatureFormatter implements IAsnSignatureFormatter {
- static namedCurveSize: Map<string, number>;
- static defaultNamedCurveSize: number;
- private addPadding;
- private removePadding;
- toAsnSignature(algorithm: Algorithm, signature: BufferSource): ArrayBuffer | null;
- toWebSignature(algorithm: Algorithm, signature: BufferSource): ArrayBuffer | null;
- }
- declare const idX25519 = "1.3.101.110";
- declare const idX448 = "1.3.101.111";
- declare const idEd25519 = "1.3.101.112";
- declare const idEd448 = "1.3.101.113";
- /**
- * ECDH-ES and EdDSA algorithm provider
- */
- declare class EdAlgorithm implements IAlgorithm {
- toAsnAlgorithm(alg: EcKeyGenParams): AlgorithmIdentifier | null;
- toWebAlgorithm(alg: AlgorithmIdentifier): HashedAlgorithm | EcKeyGenParams | Algorithm | null;
- }
- type IdOrName = Record<string, string>;
- declare class NameIdentifier {
- private items;
- constructor(names?: Record<string, string>);
- get(idOrName: string): string | null;
- findId(idOrName: string): string | null;
- register(id: string, name: string): void;
- }
- /**
- * JSON representation of Attribute and Value
- */
- type JsonAttributeAndStringValue = Record<string, string[]>;
- interface JsonAttributeObject {
- ia5String?: string;
- utf8String?: string;
- universalString?: string;
- bmpString?: string;
- printableString?: string;
- }
- type JsonAttributeAndObjectValue = Record<string, JsonAttributeObject[]>;
- type JsonAttributeAndValue = JsonAttributeAndStringValue | JsonAttributeAndObjectValue;
- /**
- * JSON array of Attribute and Value
- */
- type JsonName = JsonAttributeAndStringValue[];
- type JsonNameParams = JsonAttributeAndValue[];
- /**
- * UTF-8 String Representation of Distinguished Names
- *
- * https://tools.ietf.org/html/rfc2253
- */
- declare class Name {
- private extraNames;
- /**
- * Returns `true` if text is ASCII otherwise `false`
- * @param text Text
- * @returns
- */
- static isASCII(text: string): boolean;
- /**
- * Checks if a given string is a printable string.
- * A printable string contains only printable ASCII characters.
- *
- * @param text - The string to be checked.
- * @returns True if the string is a printable string, false otherwise.
- */
- static isPrintableString(text: string): boolean;
- /**
- * ASN.1 Name
- */
- private asn;
- /**
- * Creates a new instance
- * @param data
- * @param extraNames Extra identifiers for name customization
- * @example
- * const text = "URL=http://some.url.com, IP=192.168.0.1, GUID={8ee13e53-2c1c-42bb-8df7-39927c0bdbb6}";
- * const name = new x509.Name(text, {
- * "Email": "1.2.3.4.5.1",
- * "IP": "1.2.3.4.5.2",
- * "GUID": "1.2.3.4.5.3",
- * });
- */
- constructor(data: BufferSource | Name$1 | string | JsonNameParams, extraNames?: IdOrName);
- /**
- * Returns a list of string values filtered by specified id or name
- * @param idOrName ObjectIdentifier or string name
- * @returns Returns a list of strings. Returns an empty list if there are not any
- * values for specified id/name.
- */
- getField(idOrName: string): string[];
- private getName;
- /**
- * Returns string serialized Name
- */
- toString(): string;
- /**
- * Returns a JSON representation of the Name
- */
- toJSON(): JsonName;
- /**
- * Creates AsnName object from string
- * @param data
- */
- private fromString;
- /**
- * Creates AsnName from JSON
- * @param data
- */
- private fromJSON;
- /**
- * Gets the OID for a given type name
- * @param type The type name
- * @returns The OID string
- */
- private getTypeOid;
- /**
- * Creates an AttributeTypeAndValue object
- * @param type The type OID
- * @param value The value
- * @returns The AttributeTypeAndValue object
- */
- private createAttribute;
- /**
- * Processes a string value by unescaping and replacing special characters
- * @param value The string value
- * @returns The processed string value
- */
- private processStringValue;
- /**
- * Returns Name in DER encoded format
- */
- toArrayBuffer(): ArrayBuffer;
- /**
- * Returns a SHA-1 thumbprint
- * @param crypto Crypto provider. Default is from CryptoProvider
- */
- getThumbprint(crypto?: Crypto): Promise<ArrayBuffer>;
- /**
- * Returns a thumbprint for specified mechanism
- * @param algorithm Hash algorithm
- * @param crypto Crypto provider. Default is from CryptoProvider
- */
- getThumbprint(algorithm: globalThis.AlgorithmIdentifier, crypto?: Crypto): Promise<ArrayBuffer>;
- }
- interface PemHeader {
- key: string;
- value: string;
- }
- /**
- * Represents PEM structure
- */
- interface PemStruct {
- /**
- * Type
- */
- type: string;
- /**
- * Headers
- */
- headers: PemHeader[];
- /**
- * Decoded message data
- */
- rawData: ArrayBuffer;
- }
- type AtLeast<T, K extends keyof T> = Partial<T> & Pick<T, K>;
- type PemStructEncodeParams = AtLeast<PemStruct, "type" | "rawData">;
- /**
- * Represents PEM Converter.
- */
- declare class PemConverter {
- static CertificateTag: string;
- static CrlTag: string;
- static CertificateRequestTag: string;
- static PublicKeyTag: string;
- static PrivateKeyTag: string;
- static isPem(data: any): data is string;
- static decodeWithHeaders(pem: string): PemStruct[];
- /**
- * Decodes PEM to a list of raws
- * @param pem message in PEM format
- */
- static decode(pem: string): ArrayBuffer[];
- /**
- * Decodes PEM and returns first item from the list
- * @param pem message in PEM format
- * @throw Throws RangeError if list of decoded items is empty
- */
- static decodeFirst(pem: string): ArrayBuffer;
- /**
- * Encodes a list of PemStruct in PEM format
- * @param structs A list of PemStruct
- * @param tag PEM tag
- */
- static encode(structs: PemStructEncodeParams[]): string;
- /**
- * Encodes a raw data in PEM format
- * @param rawData Raw data
- * @param tag PEM tag
- */
- static encode(rawData: BufferSource, tag: string): string;
- /**
- * Encodes a list of raws in PEM format
- * @param raws A list of raws
- * @param tag PEM tag
- */
- static encode(rawData: BufferSource[], tag: string): string;
- /**
- * Encodes PEMStruct in PEM block
- * @param pem PEM structure for encoding
- * @returns Returns PEM encoded block
- */
- private static encodeStruct;
- }
- /**
- * Representation of PKCS10 Certificate Request
- */
- declare class Pkcs10CertificateRequest extends PemData<CertificationRequest> implements IPublicKeyContainer {
- #private;
- static NAME: string;
- protected readonly tag: string;
- /**
- * Gets the subject value from the certificate as an Name
- */
- get subjectName(): Name;
- /**
- * Gets a string subject name
- */
- get subject(): string;
- /**
- * Gets a signature algorithm
- */
- get signatureAlgorithm(): HashedAlgorithm;
- /**
- * Gets a signature
- */
- get signature(): ArrayBuffer;
- /**
- * Gets a public key of CSR
- */
- get publicKey(): PublicKey;
- /**
- * Gets a list fo CSR attributes
- */
- get attributes(): Attribute[];
- /**
- * Gets a list of CSR extensions
- */
- get extensions(): Extension[];
- /**
- * Gets the ToBeSigned block
- */
- private get tbs();
- /**
- * Creates a new instance fromDER encoded buffer
- * @param raw DER encoded buffer
- */
- constructor(raw: AsnEncodedType);
- /**
- * Creates a new instance from ASN.1 CertificationRequest
- * @param asn ASN.1 CertificationRequest
- */
- constructor(asn: CertificationRequest);
- protected onInit(_asn: CertificationRequest): void;
- /**
- * Returns attribute of the specified type
- * @param type Attribute identifier
- * @returns Attribute or null
- */
- getAttribute(type: string): Attribute | null;
- /**
- * Returns a list of attributes of the specified type
- * @param type Attribute identifier
- */
- getAttributes(type: string): Attribute[];
- /**
- * Returns extension of the specified type
- * @param type Extension identifier
- * @returns Extension or null
- */
- getExtension(type: string): Extension | null;
- /**
- * Returns a list of extension of the specified type
- * @param type Extension identifier
- */
- getExtensions(type: string): Extension[];
- /**
- * Validates CSR signature
- * @param crypto Crypto provider. Default is from CryptoProvider
- */
- verify(crypto?: Crypto): Promise<boolean>;
- toTextObject(): TextObject;
- }
- type Pkcs10CertificateRequestCreateParamsName = string | JsonName | Name;
- /**
- * Pkcs10CertificateRequest create parameters
- */
- interface Pkcs10CertificateRequestCreateParams {
- /**
- * Subject name
- */
- name?: Pkcs10CertificateRequestCreateParamsName;
- /**
- * Extensions
- */
- extensions?: Extension[];
- /**
- * Attributes
- */
- attributes?: Attribute[];
- /**
- * Signing algorithm
- */
- signingAlgorithm: Algorithm | EcdsaParams;
- /**
- * Crypto key pair
- */
- keys: CryptoKeyPair;
- }
- /**
- * Generator of PKCS10 certificate requests
- */
- declare class Pkcs10CertificateRequestGenerator {
- /**
- * Creates a new PKCS10 Certificate request
- * @param params Create parameters
- * @param crypto Crypto provider. Default is from CryptoProvider
- */
- static create(params: Pkcs10CertificateRequestCreateParams, crypto?: Crypto): Promise<Pkcs10CertificateRequest>;
- }
- type MapForEachCallback = (value: Crypto, key: string, map: Map<string, Crypto>) => void;
- /**
- * Crypto provider
- */
- declare class CryptoProvider {
- static DEFAULT: string;
- private items;
- /**
- * Returns `true` if data is CryptoKeyPair
- * @param data
- */
- static isCryptoKeyPair(data: any): data is CryptoKeyPair;
- static isCryptoKey(data: any): data is CryptoKey;
- /**
- * Creates a new instance
- */
- constructor();
- clear(): void;
- delete(key: string): boolean;
- forEach(callbackfn: MapForEachCallback, thisArg?: any): void;
- has(key: string): boolean;
- get size(): number;
- entries(): IterableIterator<[string, Crypto]>;
- keys(): IterableIterator<string>;
- values(): IterableIterator<Crypto>;
- [Symbol.iterator](): IterableIterator<[string, Crypto]>;
- [Symbol.toStringTag]: string;
- /**
- * Returns default crypto
- * @throws Error whenever default provider not set
- */
- get(): Crypto;
- /**
- * Returns crypto by name
- * @param key Crypto name
- * @throws Error whenever provider with specified identifier does not exist
- */
- get(key: string): Crypto;
- /**
- * Sets default crypto
- * @param value
- */
- set(value: Crypto): this;
- /**
- * Sets crypto with specified identifier
- * @param key Identifier
- * @param value crypto provider
- */
- set(key: string, value: Crypto): this;
- }
- /**
- * Singleton crypto provider
- */
- declare const cryptoProvider: CryptoProvider;
- /**
- * Verification params of X509 certificate
- */
- interface X509CertificateVerifyParams {
- date?: Date;
- publicKey?: PublicKeyType;
- signatureOnly?: boolean;
- }
- /**
- * Representation of X509 certificate
- */
- declare class X509Certificate extends PemData<Certificate> implements IPublicKeyContainer {
- #private;
- static NAME: string;
- protected readonly tag: string;
- /**
- * Gets a public key of the certificate
- */
- get publicKey(): PublicKey;
- /**
- * Gets a hexadecimal string of the serial number
- */
- get serialNumber(): string;
- /**
- * Gets the subject value from the certificate as an Name
- */
- get subjectName(): Name;
- /**
- * Gets a string subject name
- */
- get subject(): string;
- /**
- * Gets the issuer value from the certificate as an Name
- */
- get issuerName(): Name;
- /**
- * Gets a string issuer name
- */
- get issuer(): string;
- /**
- * Gets a date before which certificate can't be used
- */
- get notBefore(): Date;
- /**
- * Gets a date after which certificate can't be used
- */
- get notAfter(): Date;
- /**
- * Gets a signature algorithm
- */
- get signatureAlgorithm(): HashedAlgorithm;
- /**
- * Gets a signature
- */
- get signature(): ArrayBuffer;
- /**
- * Gets a list of certificate extensions
- */
- get extensions(): Extension[];
- /**
- * Gets a private key of the certificate
- */
- privateKey?: CryptoKey;
- /**
- * Gets the ToBeSigned block
- */
- private get tbs();
- /**
- * Creates a new instance from ASN.1 Certificate object
- * @param asn ASN.1 Certificate object
- */
- constructor(asn: Certificate);
- /**
- * Creates a new instance
- * @param raw Encoded buffer (DER, PEM, HEX, Base64, Base64Url)
- */
- constructor(raw: AsnEncodedType);
- protected onInit(_asn: Certificate): void;
- /**
- * Returns an extension of specified type
- * @param type Extension identifier
- * @returns Extension or null
- */
- getExtension<T extends Extension>(type: string): T | null;
- /**
- * Returns an extension of specified type
- * @param type Extension type
- * @returns Extension or null
- */
- getExtension<T extends Extension>(type: new (raw: BufferSource) => T): T | null;
- /**
- * Returns a list of extensions of specified type
- * @param type Extension identifier
- */
- getExtensions<T extends Extension>(type: string): T[];
- /**
- * Returns a list of extensions of specified type
- * @param type Extension type
- */
- getExtensions<T extends Extension>(type: new (raw: BufferSource) => T): T[];
- /**
- * Validates a certificate signature
- * @param params Verification parameters
- * @param crypto Crypto provider. Default is from CryptoProvider
- */
- verify(params?: X509CertificateVerifyParams, crypto?: Crypto): Promise<boolean>;
- /**
- * Returns a SHA-1 certificate thumbprint
- * @param crypto Crypto provider. Default is from CryptoProvider
- */
- getThumbprint(crypto?: Crypto): Promise<ArrayBuffer>;
- /**
- * Returns a certificate thumbprint for specified mechanism
- * @param algorithm Hash algorithm
- * @param crypto Crypto provider. Default is from CryptoProvider
- */
- getThumbprint(algorithm: globalThis.AlgorithmIdentifier, crypto?: Crypto): Promise<ArrayBuffer>;
- isSelfSigned(crypto?: Crypto): Promise<boolean>;
- toTextObject(): TextObject;
- }
- type X509CertificatesExportType = AsnExportType | "pem-chain";
- /**
- * X509 Certificate collection
- */
- declare class X509Certificates extends Array<X509Certificate> implements TextObjectConvertible {
- /**
- * Creates a new instance
- */
- constructor();
- /**
- * Creates a new instance from encoded PKCS7 buffer
- * @param raw Encoded PKCS7 buffer. Supported formats are DER, PEM, HEX, Base64, or Base64Url
- */
- constructor(raw: AsnEncodedType);
- /**
- * Creates a new instance form X509 certificate
- * @param cert X509 certificate
- */
- constructor(cert: X509Certificate);
- /**
- * Creates a new instance from a list of x509 certificates
- * @param certs List of x509 certificates
- */
- constructor(certs: X509Certificate[]);
- /**
- * Returns encoded object in PEM format
- */
- export(): string;
- /**
- * Returns encoded object in DER format
- * @param format `der` format
- */
- export(format: "raw"): ArrayBuffer;
- /**
- * Returns encoded object in selected format
- * @param format `hex`, `base64`, `base64url`, `pem`. Default is `pem`
- */
- export(format?: AsnExportType): string;
- /**
- * Import certificates from encoded PKCS7 data. Supported formats are HEX, DER,
- * Base64, Base64Url, PEM
- * @param data
- */
- import(data: AsnEncodedType): void;
- /**
- * Removes all items from collection
- */
- clear(): void;
- toString(format?: X509CertificatesExportType): string;
- toTextObject(): TextObject;
- }
- interface X509ChainBuilderParams {
- certificates?: X509Certificate[];
- }
- /**
- * Represents a chain-building engine for X509Certificate certificates
- * @example
- * ```js
- * const chain = new x509.X509ChainBuilder({
- * certificates: [
- * new x509.X509Certificate(raw1),
- * new x509.X509Certificate(raw2),
- * // ...
- * new x509.X509Certificate(rawN),
- * ],
- * });
- *
- * const cert = x509.X509Certificate(raw);
- * const items = await chain.build(cert);
- * ```
- */
- declare class X509ChainBuilder {
- certificates: X509Certificate[];
- constructor(params?: X509ChainBuilderParams);
- build(cert: X509Certificate, crypto?: Crypto): Promise<X509Certificates>;
- private findIssuer;
- }
- type X509CertificateCreateParamsName = string | JsonName | Name;
- /**
- * Base arguments for certificate creation
- */
- interface X509CertificateCreateParamsBase {
- /**
- * Hexadecimal serial number. If not specified, random value will be generated
- */
- serialNumber?: string;
- /**
- * Date before which certificate can't be used. Default is current date
- */
- notBefore?: Date;
- /**
- * Date after which certificate can't be used. Default is 1 year from now
- */
- notAfter?: Date;
- /**
- * List of extensions
- */
- extensions?: Extension[];
- /**
- * Signing algorithm. Default is SHA-256 with key algorithm
- */
- signingAlgorithm?: Algorithm | EcdsaParams;
- }
- /**
- * Common parameters for X509 Certificate generation
- */
- interface X509CertificateCreateCommonParams extends X509CertificateCreateParamsBase {
- subject?: X509CertificateCreateParamsName;
- issuer?: X509CertificateCreateParamsName;
- }
- /**
- * Parameters for X509 Certificate generation with private key
- */
- interface X509CertificateCreateWithKeyParams extends X509CertificateCreateCommonParams {
- publicKey: PublicKeyType;
- signingKey: CryptoKey;
- }
- /**
- * Parameters for X509 Certificate generation with existing signature value
- */
- interface X509CertificateCreateWithSignatureParams extends X509CertificateCreateCommonParams {
- /**
- * Signature for manually initialized certificates
- */
- signature: BufferSource$1;
- /**
- * Manual signing requires CryptoKey that includes signature algorithm
- */
- publicKey: PublicKeyType;
- }
- type X509CertificateCreateParams = X509CertificateCreateWithKeyParams | X509CertificateCreateWithSignatureParams;
- /**
- * Parameters for self-signed X509 Certificate generation
- */
- interface X509CertificateCreateSelfSignedParams extends X509CertificateCreateParamsBase {
- name?: X509CertificateCreateParamsName;
- keys: CryptoKeyPair;
- }
- /**
- * Generator of X509 certificates
- */
- declare class X509CertificateGenerator {
- /**
- * Creates a self-signed certificate
- * @param params Parameters
- * @param crypto Crypto provider. Default is from CryptoProvider
- */
- static createSelfSigned(params: X509CertificateCreateSelfSignedParams, crypto?: Crypto): Promise<X509Certificate>;
- /**
- * Creates a certificate signed by private key
- * @param params Parameters
- * @param crypto Crypto provider. Default is from CryptoProvider
- */
- static create(params: X509CertificateCreateParams, crypto?: Crypto): Promise<X509Certificate>;
- }
- /**
- * Reason Code
- * The reasonCode is a non-critical CRL entry extension that identifies
- * the reason for the certificate revocation.
- */
- declare enum X509CrlReason {
- unspecified = 0,
- keyCompromise = 1,
- cACompromise = 2,
- affiliationChanged = 3,
- superseded = 4,
- cessationOfOperation = 5,
- certificateHold = 6,
- removeFromCRL = 8,
- privilegeWithdrawn = 9,
- aACompromise = 10
- }
- /**
- * Representation of X509CrlEntry
- */
- declare class X509CrlEntry extends AsnData<RevokedCertificate> {
- #private;
- /**
- * Gets a hexadecimal string of the serial number, the userCertificate
- */
- get serialNumber(): string;
- /**
- * Gets the revocation date
- */
- get revocationDate(): Date;
- /**
- * Gets the reason code
- */
- get reason(): X509CrlReason | undefined;
- /**
- * Gets the invalidity Date
- * The invalidity date is a non-critical CRL entry extension that
- * provides the date on which it is known or suspected that the private
- * key was compromised or that the certificate otherwise became invalid.
- */
- get invalidity(): Date | undefined;
- /**
- * Gets crl entry extensions
- */
- get extensions(): Extension[];
- /**
- * Creates a new instance from DER encoded Buffer
- * @param raw DER encoded buffer
- */
- constructor(raw: BufferSource);
- /**
- * Creates a new instance from ASN.1 object
- * @param asn ASN.1 object
- */
- constructor(asn: RevokedCertificate);
- /**
- * Creates a new instance
- * @param serialNumber Serial number of certificate
- * @param revocationDate Revocation date
- * @param extensions List of crl extensions
- */
- constructor(serialNumber: string, revocationDate: Date, extensions: Extension[]);
- protected onInit(_asn: RevokedCertificate): void;
- }
- interface X509CrlVerifyParams {
- publicKey: CryptoKey | PublicKey | X509Certificate;
- }
- /**
- * Representation of X.509 Certificate Revocation List (CRL)
- */
- declare class X509Crl extends PemData<CertificateList> {
- #private;
- protected readonly tag: string;
- /**
- * Gets a version
- */
- get version(): Version | undefined;
- /**
- * Gets a signature algorithm
- */
- get signatureAlgorithm(): HashedAlgorithm;
- /**
- * Gets a signature
- */
- get signature(): ArrayBuffer;
- /**
- * Gets a string issuer name
- */
- get issuer(): string;
- /**
- * Gets the issuer value from the crl as an Name
- */
- get issuerName(): Name;
- /**
- * Gets a thisUpdate date from the CRL
- */
- get thisUpdate(): Date;
- /**
- * Gets a nextUpdate date from the CRL
- */
- get nextUpdate(): Date | undefined;
- /**
- * Gets a crlEntries from the CRL
- *
- * @remarks
- * Reading this property parses all revoked certificates, which can be slow for large CRLs.
- * Use findRevoked() for efficient searching of specific certificates.
- */
- get entries(): readonly X509CrlEntry[];
- /**
- * Gets a list of crl extensions
- */
- get extensions(): Extension[];
- /**
- * Gets the ToBeSigned block
- */
- private get tbs();
- /**
- * Gets the signature algorithm from tbsCertList
- */
- private get tbsCertListSignatureAlgorithm();
- /**
- * Gets the signature algorithm from CertificateList
- */
- private get certListSignatureAlgorithm();
- /**
- * Creates a new instance from ASN.1 CertificateList object
- * @param asn ASN.1 CertificateList object
- */
- constructor(asn: CertificateList);
- /**
- * Creates a new instance
- * @param raw Encoded buffer (DER, PEM, HEX, Base64, Base64Url)
- */
- constructor(raw: AsnEncodedType);
- protected onInit(_asn: CertificateList): void;
- /**
- * Returns an extension of specified type
- * @param type Extension identifier
- * @returns Extension or null
- */
- getExtension<T extends Extension>(type: string): T | null;
- /**
- * Returns an extension of specified type
- * @param type Extension type
- * @returns Extension or null
- */
- getExtension<T extends Extension>(type: new (raw: BufferSource) => T): T | null;
- /**
- * Returns a list of extensions of specified type
- * @param type Extension identifier
- */
- getExtensions<T extends Extension>(type: string): T[];
- /**
- * Returns a list of extensions of specified type
- * @param type Extension type
- */
- getExtensions<T extends Extension>(type: new (raw: BufferSource) => T): T[];
- /**
- * Validates a crl signature
- * @param params Verification parameters
- * @param crypto Crypto provider. Default is from CryptoProvider
- */
- verify(params: X509CrlVerifyParams, crypto?: Crypto): Promise<boolean>;
- /**
- * Returns a SHA-1 certificate thumbprint
- * @param crypto Crypto provider. Default is from CryptoProvider
- */
- getThumbprint(crypto?: Crypto): Promise<ArrayBuffer>;
- /**
- * Returns a certificate thumbprint for specified mechanism
- * @param algorithm Hash algorithm
- * @param crypto Crypto provider. Default is from CryptoProvider
- */
- getThumbprint(algorithm: globalThis.AlgorithmIdentifier, crypto?: Crypto): Promise<ArrayBuffer>;
- /**
- * Gets the CRL entry, with the given X509Certificate or certificate serialNumber.
- *
- * @param certOrSerialNumber certificate | serialNumber
- */
- findRevoked(certOrSerialNumber: X509Certificate | string): X509CrlEntry | null;
- }
- interface X509CrlEntryParams {
- /**
- * Hexadecimal serial number
- */
- serialNumber: string;
- revocationDate?: Date;
- reason?: X509CrlReason;
- invalidity?: Date;
- issuer?: X509CertificateCreateParamsName;
- extensions?: Extension[];
- }
- /**
- * Base arguments for crl creation
- */
- interface X509CrlCreateParamsBase {
- issuer: X509CertificateCreateParamsName;
- thisUpdate?: Date;
- /**
- * Signing algorithm
- */
- signingAlgorithm: Algorithm | EcdsaParams;
- }
- /**
- * Parameters for X509 CRL generation
- */
- interface X509CrlCreateParams extends X509CrlCreateParamsBase {
- nextUpdate?: Date;
- extensions?: Extension[];
- entries?: X509CrlEntryParams[];
- signingKey: CryptoKey;
- }
- /**
- * Generator of X509 crl
- */
- declare class X509CrlGenerator {
- /**
- * Creates a crl signed by private key
- * @param params Parameters
- * @param crypto Crypto provider. Default is from CryptoProvider
- */
- static create(params: X509CrlCreateParams, crypto?: Crypto): Promise<X509Crl>;
- }
- export { AlgorithmProvider, AsnData, AsnDefaultSignatureFormatter, AsnEcSignatureFormatter, Attribute, AttributeFactory, AuthorityInfoAccessExtension, AuthorityKeyIdentifierExtension, BasicConstraintsExtension, CRLDistributionPointsExtension, CertificatePolicyExtension, ChallengePasswordAttribute, CryptoProvider, DN, DNS, DefaultAlgorithmSerializer, EMAIL, EcAlgorithm, EdAlgorithm, ExtendedKeyUsage, ExtendedKeyUsageExtension, Extension, ExtensionFactory, ExtensionsAttribute, GUID, GeneralName, GeneralNames, IP, IssuerAlternativeNameExtension, KeyUsageFlags, KeyUsagesExtension, Name, NameIdentifier, OidSerializer, PemConverter, PemData, Pkcs10CertificateRequest, Pkcs10CertificateRequestGenerator, PublicKey, REGISTERED_ID, RsaAlgorithm, ShaAlgorithm, SubjectAlternativeNameExtension, SubjectKeyIdentifierExtension, TextConverter, TextObject, UPN, URL, X509Certificate, X509CertificateGenerator, X509Certificates, X509ChainBuilder, X509Crl, X509CrlEntry, X509CrlGenerator, X509CrlReason, cryptoProvider, diAlgorithm, diAlgorithmProvider, diAsnSignatureFormatter, idEd25519, idEd448, idX25519, idX448 };
- export type { AccessItemTypes, AlgorithmSerializer, AsnDataStringFormat, AsnEncodedType, AsnExportType, AuthorityInfoAccessParams, CertificateIdentifier, ExtendedKeyUsageType, GeneralNameType, HashedAlgorithm, IAlgorithm, IAsnSignatureFormatter, IPublicKeyContainer, IdOrName, JsonAttributeAndObjectValue, JsonAttributeAndStringValue, JsonAttributeAndValue, JsonAttributeObject, JsonGeneralName, JsonGeneralNames, JsonName, JsonNameParams, MapForEachCallback, PemHeader, PemStruct, PemStructEncodeParams, Pkcs10CertificateRequestCreateParams, Pkcs10CertificateRequestCreateParamsName, PublicKeyType, TextObjectConvertible, TextObjectItemType, UnknownAlgorithm, X509CertificateCreateCommonParams, X509CertificateCreateParams, X509CertificateCreateParamsBase, X509CertificateCreateParamsName, X509CertificateCreateSelfSignedParams, X509CertificateCreateWithKeyParams, X509CertificateCreateWithSignatureParams, X509CertificateVerifyParams, X509CertificatesExportType, X509ChainBuilderParams, X509CrlCreateParams, X509CrlCreateParamsBase, X509CrlEntryParams, X509CrlVerifyParams };
|