UNPKG

@estos/asn1ts

Version:

ASN1.ts is a cross platform ASN1 library written in typescript. It supports encoding and (schema supported) decoding of ber encoded asn1 structures.

1,365 lines (1,313 loc) 73.4 kB
/*! * Copyright (c) 2014, GMO GlobalSign * Copyright (c) 2015-2022, Peculiar Ventures * Copyright (c) 2022, estos GmbH (extensions missing features see README.md - What has been added by estos) * All rights reserved. * * Author 2014-2019, Yury Strozhevsky * Author 2019-2022, Peculiar Ventures * Author from 2022, estos GmbH * * estos created a fork of the library, mainly written by Yury Strozhevsky and * Peculiar Ventures, in 2022 to add extensions, missing features. Details about those in the README.md * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, this * list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ import * as pvtsutils from 'pvtsutils'; interface IBerConvertible { /** * Base function for converting block from BER encoded array of bytes * @param inputBuffer ASN.1 BER encoded array * @param inputOffset Offset in ASN.1 BER encoded array where decoding should be started * @param inputLength Maximum length of array of bytes which can be using in this function * @returns Offset after least decoded byte */ fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; /** * Encoding of current ASN.1 block into ASN.1 encoded array (BER rules) * @param sizeOnly Flag that we need only a size of encoding, not a real array of bytes * @returns ASN.1 BER encoded array */ toBER(sizeOnly?: boolean): ArrayBuffer; } interface IStringConvertible { /** * Returns a string representation of an object * @returns String representation of the class object */ toString(): string; /** * Creates a class object from the string * @param data Input string to convert from */ fromString(data: string): void; } interface IDateConvertible { /** * Converts a class object into the JavaScrip Date Object * @returns Date object */ toDate(): Date; /** * Creates a class object from the JavaScript Date object * @param date Date object */ fromDate(date: Date): void; } declare class ViewWriter { items: ArrayBuffer[]; /** * Writes buffer * @param buf */ write(buf: ArrayBuffer): void; /** * Concatenates all buffers * @returns Concatenated buffer */ final(): ArrayBuffer; } interface ILocalBaseBlock { blockLength: number; error: string; warnings: string[]; } interface LocalBaseBlockJson extends ILocalBaseBlock { blockName: string; valueBeforeDecode: string; } interface LocalBaseBlockParams extends Partial<ILocalBaseBlock> { valueBeforeDecode?: pvtsutils.BufferSource; } interface LocalBaseBlockConstructor<T extends LocalBaseBlock = LocalBaseBlock> { new (...args: any[]): T; prototype: T; NAME: string; defaultIDs: IBaseIDs; blockName(): string; } /** * Class used as a base block for all remaining ASN.1 classes */ declare class LocalBaseBlock implements ILocalBaseBlock { /** * Name of the block */ static NAME: string; /** * The default ids for this kind of asn1 tag */ static defaultIDs: IBaseIDs; /** * Aux function, need to get a block name. Need to have it here for inheritance * @returns Returns name of the block */ static blockName(): string; blockLength: number; error: string; warnings: string[]; /** * @deprecated since version 3.0.0 */ get valueBeforeDecode(): ArrayBuffer; /** * @deprecated since version 3.0.0 */ set valueBeforeDecode(value: ArrayBuffer); /** * @since 3.0.0 */ valueBeforeDecodeView: Uint8Array; /** * Creates and initializes an object instance of that class * @param param0 Initialization parameters */ constructor({ blockLength, error, warnings, valueBeforeDecode, }?: LocalBaseBlockParams); /** * Returns a JSON representation of an object * @returns JSON object */ toJSON(): LocalBaseBlockJson; } interface ILocalLengthBlock { isIndefiniteForm: boolean; longFormUsed: boolean; length: number; } interface LocalLengthBlockParams { lenBlock?: Partial<ILocalLengthBlock>; } interface LocalLengthBlockJson extends LocalBaseBlockJson, ILocalLengthBlock { isIndefiniteForm: boolean; longFormUsed: boolean; length: number; } declare class LocalLengthBlock extends LocalBaseBlock implements ILocalLengthBlock, IBerConvertible { static NAME: string; isIndefiniteForm: boolean; longFormUsed: boolean; length: number; constructor({ lenBlock, }?: LocalLengthBlockParams); fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; toBER(sizeOnly?: boolean): ArrayBuffer; toJSON(): LocalLengthBlockJson; } type IValueBlock = ILocalBaseBlock; type ValueBlockParams = LocalBaseBlockParams; type ValueBlockJson = LocalBaseBlockJson; declare class ValueBlock extends LocalBaseBlock implements IValueBlock, IBerConvertible { static NAME: string; fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; toBER(sizeOnly?: boolean, writer?: ViewWriter): ArrayBuffer; } interface IBaseBlock { name: string; optional: boolean; primitiveSchema?: BaseBlock; } interface IBaseBlockIDs { /** * These are the default IDs a certain asn1 object is using to express itself e.g. a UTF8String uses ETagClass.UNIVERSAL, tagNumber: EUniversalTagNumber.Utf8String * The values are static to have them accessible without needing to create the object */ defaultIDs: IBaseIDs; } interface BaseBlockParams extends LocalBaseBlockParams, ILocalIdentificationBlockParams, LocalLengthBlockParams, Partial<IBaseBlock> { } interface ValueBlockConstructor<T extends ValueBlock = ValueBlock> { new (...args: any[]): T; } interface BaseBlockJson<T extends LocalBaseBlockJson = LocalBaseBlockJson> extends LocalBaseBlockJson, Omit<IBaseBlock, "primitiveSchema"> { idBlock: LocalIdentificationBlockJson; lenBlock: LocalLengthBlockJson; valueBlock: T; primitiveSchema?: BaseBlockJson; } type StringEncoding = "ascii" | "hex"; declare class BaseBlock<T extends ValueBlock = ValueBlock, J extends ValueBlockJson = ValueBlockJson> extends LocalBaseBlock implements IBaseBlock, IBerConvertible { static NAME: string; static defaultIDs: IBaseIDs; idBlock: LocalIdentificationBlock; lenBlock: LocalLengthBlock; valueBlock: T; name: string; choiceName?: string; optional: boolean; primitiveSchema?: BaseBlock; constructor({ name, optional, primitiveSchema, ...parameters }?: BaseBlockParams, valueBlockType?: ValueBlockConstructor<T>); fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; toBER(sizeOnly?: boolean, writer?: ViewWriter): ArrayBuffer; toJSON(): BaseBlockJson<J>; toString(encoding?: StringEncoding): string; protected onAsciiEncoding(): string; /** * Determines whether two object instances are equal * * @param other Object to compare with the current object * @returns true if the two objects are equal */ isEqual(other: unknown): other is this; /** * Retrieve the tag type (universal object type) of this object * * @returns the universal tagNumber if the class is universal, otherwise undefined */ getUniversalTagNumber(): EUniversalTagNumber | undefined; /** * Merges baseID tagClass and tagNumber into params if they have not been already set * @param params the baseblock we want to merge the baseIDS into * @param baseIDS the baseIDS (tagClass, tagNumber) to merge into the params */ static mergeIDBlock(params: BaseBlockParams, baseIDs: IBaseIDs): void; /** * Implements the core typeguard check function * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ protected static matches(obj: unknown): boolean; } interface IAny { name: string; optional: boolean; } type AnyParams = Partial<IAny>; declare class Any implements IAny { name: string; optional: boolean; constructor({ name, optional, }?: AnyParams); } type ConstructedItem = BaseBlock | Any; interface ILocalConstructedValueBlock { value: ConstructedItem[]; isIndefiniteForm: boolean; } interface LocalConstructedValueBlockParams extends ValueBlockParams, Partial<ILocalConstructedValueBlock> { } interface LocalConstructedValueBlockJson extends LocalBaseBlockJson, Omit<ILocalConstructedValueBlock, "value"> { value: LocalBaseBlockJson[]; } declare class LocalConstructedValueBlock extends ValueBlock implements ILocalConstructedValueBlock { static NAME: string; value: BaseBlock[]; isIndefiniteForm: boolean; constructor({ value, isIndefiniteForm, ...parameters }?: LocalConstructedValueBlockParams); fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; toBER(sizeOnly?: boolean, writer?: ViewWriter): ArrayBuffer; toJSON(): LocalConstructedValueBlockJson; } interface ILocalBitStringValueBlock { unusedBits: number; isConstructed: boolean; } interface LocalBitStringValueBlockParams extends HexBlockParams, LocalConstructedValueBlockParams, Partial<ILocalBitStringValueBlock> { value?: BitString[]; } interface LocalBitStringValueBlockJson extends HexBlockJson, LocalConstructedValueBlockJson, ILocalBitStringValueBlock { } declare const LocalBitStringValueBlock_base: { new (...args: any[]): { isHexOnly: boolean; valueHex: ArrayBuffer; valueHexView: Uint8Array; fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; toBER(sizeOnly?: boolean): ArrayBuffer; toJSON(): { isHexOnly: boolean; valueHex: string; blockName: string; valueBeforeDecode: string; blockLength: number; error: string; warnings: string[]; }; blockLength: number; error: string; warnings: string[]; valueBeforeDecode: ArrayBuffer; valueBeforeDecodeView: Uint8Array; }; NAME: string; defaultIDs: IBaseIDs; blockName(): string; } & typeof LocalConstructedValueBlock; declare class LocalBitStringValueBlock extends LocalBitStringValueBlock_base implements ILocalBitStringValueBlock { static NAME: string; unusedBits: number; isConstructed: boolean; constructor({ unusedBits, isConstructed, ...parameters }?: LocalBitStringValueBlockParams); fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; toBER(sizeOnly?: boolean, writer?: ViewWriter): ArrayBuffer; toJSON(): LocalBitStringValueBlockJson; } interface BitStringParams extends BaseBlockParams, LocalBitStringValueBlockParams { } type BitStringJson = BaseBlockJson<LocalBitStringValueBlockJson>; declare class BitString extends BaseBlock<LocalBitStringValueBlock, LocalBitStringValueBlockJson> { static NAME: string; static defaultIDs: IBaseIDs; constructor(parameters?: BitStringParams); fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; protected onAsciiEncoding(): string; /** * A typeguard that allows to validate if a certain asn1.js object is of our type * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ static typeGuard(obj: unknown | undefined): obj is BitString; } type LocalUtf8StringValueBlockParams = LocalSimpleStringBlockParams; type LocalUtf8StringValueBlockJson = LocalSimpleStringBlockJson; declare class LocalUtf8StringValueBlock extends LocalSimpleStringBlock { static NAME: string; fromBuffer(inputBuffer: ArrayBuffer | Uint8Array): void; fromString(inputString: string): void; } interface ILocalStringValueBlock { value: string; } interface LocalStringValueBlockParams extends Omit<HexBlockParams, "isHexOnly">, ValueBlockParams, Partial<ILocalStringValueBlock> { } interface LocalStringValueBlockJson extends HexBlockJson, ValueBlockJson, ILocalStringValueBlock { } declare const LocalStringValueBlock_base: { new (...args: any[]): { isHexOnly: boolean; valueHex: ArrayBuffer; valueHexView: Uint8Array; fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; toBER(sizeOnly?: boolean): ArrayBuffer; toJSON(): { isHexOnly: boolean; valueHex: string; blockName: string; valueBeforeDecode: string; blockLength: number; error: string; warnings: string[]; }; blockLength: number; error: string; warnings: string[]; valueBeforeDecode: ArrayBuffer; valueBeforeDecodeView: Uint8Array; }; NAME: string; defaultIDs: IBaseIDs; blockName(): string; } & typeof ValueBlock; declare abstract class LocalStringValueBlock extends LocalStringValueBlock_base implements ILocalStringValueBlock { static NAME: string; value: string; constructor({ ...parameters }?: LocalUtf8StringValueBlockParams); toJSON(): LocalUtf8StringValueBlockJson; } interface BaseStringBlockParams extends BaseBlockParams, LocalStringValueBlockParams { } type BaseStringBlockJson = LocalStringValueBlockJson; declare abstract class BaseStringBlock<T extends LocalStringValueBlock = LocalStringValueBlock, J extends BaseStringBlockJson = BaseStringBlockJson> extends BaseBlock<T, J> implements IStringConvertible { static NAME: string; /** * String value * @since 3.0.0 */ getValue(): string; /** * String value * @param value String value * @since 3.0.0 */ setValue(value: string): void; constructor({ value, ...parameters }: BaseStringBlockParams | undefined, stringValueBlockType: new () => T); fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; /** * Function converting ArrayBuffer into ASN.1 internal string * @param inputBuffer ASN.1 BER encoded array */ abstract fromBuffer(inputBuffer: ArrayBuffer | Uint8Array): void; abstract fromString(inputString: string): void; protected onAsciiEncoding(): string; } type LocalSimpleStringValueBlockParams = LocalStringValueBlockParams; type LocalSimpleStringValueBlockJson = LocalStringValueBlockJson; declare class LocalSimpleStringValueBlock extends LocalStringValueBlock { static NAME: string; } interface LocalSimpleStringBlockParams extends BaseBlockParams, LocalSimpleStringValueBlockParams { } type LocalSimpleStringBlockJson = LocalSimpleStringValueBlockJson; declare class LocalSimpleStringBlock extends BaseStringBlock<LocalSimpleStringValueBlock, LocalSimpleStringValueBlockJson> { static NAME: string; constructor({ ...parameters }?: LocalSimpleStringBlockParams); fromBuffer(inputBuffer: ArrayBuffer | Uint8Array): void; fromString(inputString: string): void; } type LocalBmpStringValueBlockParams = LocalSimpleStringBlockParams; type LocalBmpStringValueBlockJson = LocalSimpleStringBlockJson; declare class LocalBmpStringValueBlock extends LocalSimpleStringBlock { static NAME: string; fromBuffer(inputBuffer: ArrayBuffer | Uint8Array): void; fromString(inputString: string): void; } type BmpStringParams = LocalBmpStringValueBlockParams; type BmpStringJson = LocalBmpStringValueBlockJson; declare class BmpString extends LocalBmpStringValueBlock { static NAME: string; static defaultIDs: IBaseIDs; constructor(parameters?: BmpStringParams); /** * A typeguard that allows to validate if a certain asn1.js object is of our type * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ static typeGuard(obj: unknown | undefined): obj is BmpString; } interface ILocalBooleanValueBlock { value: boolean; } interface LocalBooleanValueBlockParams extends ValueBlockParams, HexBlockParams, Partial<ILocalBooleanValueBlock> { } interface LocalBooleanValueBlockJson extends ValueBlockJson, HexBlockJson, ILocalBooleanValueBlock { } declare const LocalBooleanValueBlock_base: { new (...args: any[]): { isHexOnly: boolean; valueHex: ArrayBuffer; valueHexView: Uint8Array; fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; toBER(sizeOnly?: boolean): ArrayBuffer; toJSON(): { isHexOnly: boolean; valueHex: string; blockName: string; valueBeforeDecode: string; blockLength: number; error: string; warnings: string[]; }; blockLength: number; error: string; warnings: string[]; valueBeforeDecode: ArrayBuffer; valueBeforeDecodeView: Uint8Array; }; NAME: string; defaultIDs: IBaseIDs; blockName(): string; } & typeof ValueBlock; declare class LocalBooleanValueBlock extends LocalBooleanValueBlock_base implements ILocalBooleanValueBlock { static NAME: string; get value(): boolean; set value(value: boolean); constructor({ value, ...parameters }?: LocalBooleanValueBlockParams); fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; toBER(): ArrayBuffer; toJSON(): LocalBooleanValueBlockJson; } interface BooleanParams extends BaseBlockParams, LocalBooleanValueBlockParams { } type BooleanJson = BaseBlockJson<LocalBooleanValueBlockJson>; declare class Boolean extends BaseBlock<LocalBooleanValueBlock, LocalBooleanValueBlockJson> { /** * Gets value * * @since 3.0.0 * @returns the boolean value */ getValue(): boolean; /** * Sets value * * @param value Boolean value to set * @since 3.0.0 */ setValue(value: boolean): void; static NAME: string; static defaultIDs: IBaseIDs; constructor(parameters?: BooleanParams); protected onAsciiEncoding(): string; /** * A typeguard that allows to validate if a certain asn1.js object is of our type * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ static typeGuard(obj: unknown | undefined): obj is Boolean; } type CharacterStringParams = LocalSimpleStringBlockParams; type CharacterStringJson = LocalSimpleStringBlockJson; declare class CharacterString extends LocalSimpleStringBlock { static NAME: string; static defaultIDs: { tagClass: ETagClass; tagNumber: EUniversalTagNumber; }; constructor(parameters?: CharacterStringParams); /** * A typeguard that allows to validate if a certain asn1.js object is of our type * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ static typeGuard(obj: unknown | undefined): obj is CharacterString; } interface ConstructedParams extends BaseBlockParams, LocalConstructedValueBlockParams { } type ConstructedJson = BaseBlockJson<LocalConstructedValueBlockJson>; declare class Constructed extends BaseBlock<LocalConstructedValueBlock, LocalConstructedValueBlockJson> { static NAME: string; constructor(parameters?: ConstructedParams); fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; /** * Queries a value from the valueBlock by name * * @param name the property we are looking for * @returns the property if found or undefined */ getValueByName(name: string): AsnType | undefined; /** * Queries a value from the valueBlock by name and ensures it is of the given type * * @param type the property type we are looking for e.g. asn1ts.UTF8String * @param name the property we are looking for * @returns the property if found and of type T (e.g. asn1ts.UTF8String) or undefined */ getTypedValueByName<T extends LocalBaseBlock>(c: new () => T, name: string): T | undefined; getValue(): BaseBlock[]; setValue(value: BaseBlock[]): void; } interface Utf8StringParams extends BaseStringBlockParams, LocalUtf8StringValueBlockParams { } type Utf8StringJson = BaseBlockJson<LocalUtf8StringValueBlockJson>; declare class Utf8String extends LocalUtf8StringValueBlock { static NAME: string; static defaultIDs: { tagClass: ETagClass; tagNumber: EUniversalTagNumber; }; constructor(parameters?: Utf8StringParams); /** * A typeguard that allows to validate if a certain asn1.js object is of our type * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ static typeGuard(obj: unknown | undefined): obj is Utf8String; } type DATEParams = Utf8StringParams; type DATEJson = Utf8StringJson; declare class DATE extends Utf8String { static NAME: string; static defaultIDs: { tagClass: ETagClass; tagNumber: EUniversalTagNumber; }; constructor(parameters?: DATEParams); /** * A typeguard that allows to validate if a certain asn1.js object is of our type * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ static typeGuard(obj: unknown | undefined): obj is DATE; } type DateTimeParams = Utf8StringParams; type DateTimeJson = Utf8StringJson; declare class DateTime extends Utf8String { static NAME: string; static defaultIDs: { tagClass: ETagClass; tagNumber: EUniversalTagNumber; }; constructor(parameters?: DateTimeParams); /** * A typeguard that allows to validate if a certain asn1.js object is of our type * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ static typeGuard(obj: unknown | undefined): obj is DateTime; } type DurationParams = Utf8StringParams; type DurationJson = Utf8StringJson; declare class Duration extends Utf8String { static NAME: string; static defaultIDs: { tagClass: ETagClass; tagNumber: EUniversalTagNumber; }; constructor(parameters?: DurationParams); /** * A typeguard that allows to validate if a certain asn1.js object is of our type * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ static typeGuard(obj: unknown | undefined): obj is Duration; } declare class LocalEndOfContentValueBlock extends ValueBlock { static override: string; fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; toBER(sizeOnly?: boolean): ArrayBuffer; } type EndOfContentParams = BaseBlockParams; type EndOfContentJson = BaseBlockJson; declare class EndOfContent extends BaseBlock<LocalEndOfContentValueBlock> { static NAME: string; static defaultIDs: { tagClass: ETagClass; tagNumber: EUniversalTagNumber; }; constructor(parameters?: EndOfContentParams); getValue(): null; setValue(value: number): void; /** * A typeguard that allows to validate if a certain asn1.js object is of our type * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ static typeGuard(obj: unknown | undefined): obj is EndOfContent; } interface ILocalIntegerValueBlock { value: number; } interface LocalIntegerValueBlockParams extends HexBlockParams, ValueBlockParams, Partial<ILocalIntegerValueBlock> { } interface LocalIntegerValueBlockJson extends HexBlockJson, ValueBlockJson { valueDec: number; } declare const LocalIntegerValueBlock_base: { new (...args: any[]): { isHexOnly: boolean; valueHex: ArrayBuffer; valueHexView: Uint8Array; fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; toBER(sizeOnly?: boolean): ArrayBuffer; toJSON(): { isHexOnly: boolean; valueHex: string; blockName: string; valueBeforeDecode: string; blockLength: number; error: string; warnings: string[]; }; blockLength: number; error: string; warnings: string[]; valueBeforeDecode: ArrayBuffer; valueBeforeDecodeView: Uint8Array; }; NAME: string; defaultIDs: IBaseIDs; blockName(): string; } & typeof ValueBlock; declare class LocalIntegerValueBlock extends LocalIntegerValueBlock_base { protected setValueHex(): void; static NAME: string; private _value; constructor({ value, ...parameters }?: LocalIntegerValueBlockParams); set value(v: number); get value(): number; fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number; toBER(sizeOnly?: boolean): ArrayBuffer; toJSON(): LocalIntegerValueBlockJson; toString(): string; } interface IntegerParams extends BaseBlockParams, LocalIntegerValueBlockParams { } type IntegerJson = BaseBlockJson<LocalIntegerValueBlockJson>; declare class Integer extends BaseBlock<LocalIntegerValueBlock, LocalIntegerValueBlockJson> { static NAME: string; static defaultIDs: { tagClass: ETagClass; tagNumber: EUniversalTagNumber; }; constructor(parameters?: IntegerParams); getValue(): number; setValue(value: number): void; /** * Converts Integer into BigInt * @throws Throws Error if BigInt is not supported * @since 3.0.0 */ toBigInt(): bigint; /** * Creates Integer from BigInt value * @param value BigInt value * @returns ASN.1 Integer * @throws Throws Error if BigInt is not supported * @since 3.0.0 */ static fromBigInt(value: number | string | bigint | boolean): Integer; protected onAsciiEncoding(): string; /** * A typeguard that allows to validate if a certain asn1.js object is of our type * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ static typeGuard(obj: unknown | undefined): obj is Integer; } type EnumeratedParams = IntegerParams; type EnumeratedJson = IntegerJson; declare class Enumerated extends Integer { static NAME: string; static defaultIDs: { tagClass: ETagClass; tagNumber: EUniversalTagNumber; }; constructor(parameters?: EnumeratedParams); /** * A typeguard that allows to validate if a certain asn1.js object is of our type * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ static typeGuard(obj: unknown | undefined): obj is Enumerated; } type VisibleStringParams = LocalSimpleStringBlockParams; type VisibleStringJson = LocalSimpleStringBlockJson; declare class VisibleString extends LocalSimpleStringBlock { static NAME: string; static defaultIDs: { tagClass: ETagClass; tagNumber: EUniversalTagNumber; }; constructor(parameters?: VisibleStringParams); /** * A typeguard that allows to validate if a certain asn1.js object is of our type * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ static typeGuard(obj: unknown | undefined): obj is VisibleString; } interface IUTCTime { year: number; month: number; day: number; hour: number; minute: number; second: number; } interface UTCTimeParams extends VisibleStringParams { value?: string; valueDate?: Date; } interface UTCTimeJson extends BaseBlockJson<LocalSimpleStringValueBlockJson>, IUTCTime { } type DateStringEncoding = StringEncoding | "iso"; declare class UTCTime extends VisibleString implements IUTCTime, IDateConvertible { static NAME: string; static defaultIDs: { tagClass: ETagClass; tagNumber: EUniversalTagNumber; }; year: number; month: number; day: number; hour: number; minute: number; second: number; constructor({ value, valueDate, ...parameters }?: UTCTimeParams); fromBuffer(inputBuffer: ArrayBuffer | Uint8Array): void; /** * Function converting ASN.1 internal string into ArrayBuffer * @returns */ toBuffer(): ArrayBuffer; /** * Function converting "Date" object into ASN.1 internal string * @param {!Date} inputDate JavaScript "Date" object */ fromDate(inputDate: Date): void; toDate(): Date; fromString(inputString: string): void; toString(encoding?: DateStringEncoding): string; protected onAsciiEncoding(): string; toJSON(): UTCTimeJson; /** * A typeguard that allows to validate if a certain asn1.js object is of our type * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ static typeGuard(obj: unknown | undefined): obj is UTCTime; } interface IGeneralizedTime extends IUTCTime { millisecond: number; } type GeneralizedTimeParams = UTCTimeParams; interface GeneralizedTimeJson extends UTCTimeJson { millisecond: number; } declare class GeneralizedTime extends UTCTime { static NAME: string; static defaultIDs: { tagClass: ETagClass; tagNumber: EUniversalTagNumber; }; millisecond: number; constructor(parameters?: GeneralizedTimeParams); fromDate(inputDate: Date): void; toDate(): Date; fromString(inputString: string): void; toString(encoding?: DateStringEncoding): string; toJSON(): GeneralizedTimeJson; /** * A typeguard that allows to validate if a certain asn1.js object is of our type * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ static typeGuard(obj: unknown | undefined): obj is GeneralizedTime; } type GeneralStringParams = LocalSimpleStringBlockParams; type GeneralStringJson = LocalSimpleStringBlockJson; declare class GeneralString extends LocalSimpleStringBlock { static NAME: string; static defaultIDs: { tagClass: ETagClass; tagNumber: EUniversalTagNumber; }; constructor(parameters?: GeneralStringParams); /** * A typeguard that allows to validate if a certain asn1.js object is of our type * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ static typeGuard(obj: unknown | undefined): obj is GeneralString; } type GraphicStringParams = LocalSimpleStringBlockParams; type GraphicStringJson = LocalSimpleStringBlockJson; declare class GraphicString extends LocalSimpleStringBlock { static NAME: string; static defaultIDs: { tagClass: ETagClass; tagNumber: EUniversalTagNumber; }; constructor(parameters?: GraphicStringParams); /** * A typeguard that allows to validate if a certain asn1.js object is of our type * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ static typeGuard(obj: unknown | undefined): obj is GraphicString; } type IA5StringParams = LocalSimpleStringBlockParams; type IA5StringJson = LocalSimpleStringBlockJson; declare class IA5String extends LocalSimpleStringBlock { static NAME: string; static defaultIDs: { tagClass: ETagClass; tagNumber: EUniversalTagNumber; }; constructor(parameters?: IA5StringParams); /** * A typeguard that allows to validate if a certain asn1.js object is of our type * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ static typeGuard(obj: unknown | undefined): obj is IA5String; } interface ILocalRealValueBlock { value: number; } interface LocalRealValueBlockParams extends HexBlockParams, ValueBlockParams, Partial<ILocalRealValueBlock> { } interface LocalRealValueBlockJson extends HexBlockJson, ValueBlockJson { valueDec: number; } declare const LocalRealValueBlock_base: { new (...args: any[]): { isHexOnly: boolean; valueHex: ArrayBuffer; valueHexView: Uint8Array; fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; toBER(sizeOnly?: boolean): ArrayBuffer; toJSON(): { isHexOnly: boolean; valueHex: string; blockName: string; valueBeforeDecode: string; blockLength: number; error: string; warnings: string[]; }; blockLength: number; error: string; warnings: string[]; valueBeforeDecode: ArrayBuffer; valueBeforeDecodeView: Uint8Array; }; NAME: string; defaultIDs: IBaseIDs; blockName(): string; } & typeof ValueBlock; declare class LocalRealValueBlock extends LocalRealValueBlock_base { protected setValueHex(): void; private decodeBinary; private decodeDecimal; private decodeSpecialRealValue; static NAME: string; private _value; constructor({ value, ...parameters }?: LocalRealValueBlockParams); set value(v: number); get value(): number; fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number; toBER(sizeOnly?: boolean): ArrayBuffer; toJSON(): LocalRealValueBlockJson; toString(): string; } interface RealParams extends BaseBlockParams, LocalRealValueBlockParams { } type RealJson = BaseBlockJson<LocalRealValueBlockJson>; declare class Real extends BaseBlock<LocalRealValueBlock, LocalRealValueBlockJson> { static NAME: string; static defaultIDs: { tagClass: ETagClass; tagNumber: EUniversalTagNumber; }; constructor(parameters?: RealParams); getValue(): number; setValue(value: number): void; /** * Converts Real into BigInt * @throws Throws Error if BigInt is not supported * @since 3.0.0 */ toBigInt(): bigint; /** * Creates Real from BigInt value * @param value BigInt value * @returns ASN.1 Real * @throws Throws Error if BigInt is not supported * @since 3.0.0 */ static fromBigInt(value: number | string | bigint | boolean): Real; protected onAsciiEncoding(): string; /** * A typeguard that allows to validate if a certain asn1.js object is of our type * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ static typeGuard(obj: unknown | undefined): obj is Real; } type NullParams = BaseBlockParams; type NullJson = BaseBlockJson<ValueBlockJson>; declare class Null extends BaseBlock<ValueBlock, ValueBlockJson> { static NAME: string; static defaultIDs: { tagClass: ETagClass; tagNumber: EUniversalTagNumber; }; constructor(parameters?: NullParams); getValue(): null; setValue(value: number): void; fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; toBER(sizeOnly?: boolean, writer?: ViewWriter): ArrayBuffer; protected onAsciiEncoding(): string; /** * A typeguard that allows to validate if a certain asn1.js object is of our type * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ static typeGuard(obj: unknown | undefined): obj is Null; } type NumericStringParams = LocalSimpleStringBlockParams; type NumericStringJson = LocalSimpleStringBlockJson; declare class NumericString extends LocalSimpleStringBlock { static NAME: string; static defaultIDs: { tagClass: ETagClass; tagNumber: EUniversalTagNumber; }; constructor(parameters?: NumericStringParams); /** * A typeguard that allows to validate if a certain asn1.js object is of our type * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ static typeGuard(obj: unknown | undefined): obj is NumericString; } interface ILocalSidValueBlock { valueDec: number; isFirstSid: boolean; } interface LocalSidValueBlockParams extends HexBlockParams, ValueBlockParams, Partial<ILocalSidValueBlock> { } interface LocalSidValueBlockJson extends HexBlockJson, ValueBlockJson, ILocalSidValueBlock { } declare const LocalSidValueBlock_base: { new (...args: any[]): { isHexOnly: boolean; valueHex: ArrayBuffer; valueHexView: Uint8Array; fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; toBER(sizeOnly?: boolean): ArrayBuffer; toJSON(): { isHexOnly: boolean; valueHex: string; blockName: string; valueBeforeDecode: string; blockLength: number; error: string; warnings: string[]; }; blockLength: number; error: string; warnings: string[]; valueBeforeDecode: ArrayBuffer; valueBeforeDecodeView: Uint8Array; }; NAME: string; defaultIDs: IBaseIDs; blockName(): string; } & typeof ValueBlock; declare class LocalSidValueBlock extends LocalSidValueBlock_base implements ILocalSidValueBlock { static NAME: string; valueDec: number; isFirstSid: boolean; constructor({ valueDec, isFirstSid, ...parameters }?: LocalSidValueBlockParams); fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; set valueBigInt(value: bigint); toBER(sizeOnly?: boolean): ArrayBuffer; toString(): string; toJSON(): LocalSidValueBlockJson; } interface ILocalObjectIdentifierValueBlock { value: string; } interface LocalObjectIdentifierValueBlockParams extends ValueBlockParams, Partial<ILocalObjectIdentifierValueBlock> { } interface LocalObjectIdentifierValueBlockJson extends ValueBlockJson, ILocalObjectIdentifierValueBlock { sidArray: LocalSidValueBlockJson[]; } declare class LocalObjectIdentifierValueBlock extends ValueBlock implements IStringConvertible { static NAME: string; value: LocalSidValueBlock[]; constructor({ value, ...parameters }?: LocalObjectIdentifierValueBlockParams); fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; toBER(sizeOnly?: boolean): ArrayBuffer; fromString(string: string): void; toString(): string; toJSON(): LocalObjectIdentifierValueBlockJson; } interface ObjectIdentifierParams extends BaseBlockParams, LocalObjectIdentifierValueBlockParams { } interface ObjectIdentifierJson extends BaseBlockJson<LocalObjectIdentifierValueBlockJson> { value: string; } declare class ObjectIdentifier extends BaseBlock<LocalObjectIdentifierValueBlock, LocalObjectIdentifierValueBlockJson> { static NAME: string; static defaultIDs: { tagClass: ETagClass; tagNumber: EUniversalTagNumber; }; /** * Gets string representation of Object Identifier * @since 3.0.0 */ getValue(): string; /** * Sets Object Identifier value from string * @param value String value * @since 3.0.0 */ setValue(value: string): void; constructor(parameters?: ObjectIdentifierParams); protected onAsciiEncoding(): string; toJSON(): ObjectIdentifierJson; /** * A typeguard that allows to validate if a certain asn1.js object is of our type * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ static typeGuard(obj: unknown | undefined): obj is ObjectIdentifier; } interface ILocalOctetStringValueBlock { isConstructed: boolean; } interface LocalOctetStringValueBlockParams extends HexBlockParams, LocalConstructedValueBlockParams, Partial<ILocalOctetStringValueBlock> { value?: OctetString[]; } interface LocalOctetStringValueBlockJson extends HexBlockJson, LocalConstructedValueBlockJson, ILocalOctetStringValueBlock { } declare const LocalOctetStringValueBlock_base: { new (...args: any[]): { isHexOnly: boolean; valueHex: ArrayBuffer; valueHexView: Uint8Array; fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; toBER(sizeOnly?: boolean): ArrayBuffer; toJSON(): { isHexOnly: boolean; valueHex: string; blockName: string; valueBeforeDecode: string; blockLength: number; error: string; warnings: string[]; }; blockLength: number; error: string; warnings: string[]; valueBeforeDecode: ArrayBuffer; valueBeforeDecodeView: Uint8Array; }; NAME: string; defaultIDs: IBaseIDs; blockName(): string; } & typeof LocalConstructedValueBlock; declare class LocalOctetStringValueBlock extends LocalOctetStringValueBlock_base { static NAME: string; isConstructed: boolean; constructor({ isConstructed, ...parameters }?: LocalOctetStringValueBlockParams); fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number; toBER(sizeOnly?: boolean, writer?: ViewWriter): ArrayBuffer; toJSON(): LocalOctetStringValueBlockJson; } interface OctetStringParams extends BaseBlockParams, LocalOctetStringValueBlockParams { } type OctetStringJson = BaseBlockJson<LocalOctetStringValueBlockJson>; declare class OctetString extends BaseBlock<LocalOctetStringValueBlock, LocalOctetStringValueBlockJson> { static NAME: string; static defaultIDs: { tagClass: ETagClass; tagNumber: EUniversalTagNumber; }; constructor(parameters?: OctetStringParams); fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; protected onAsciiEncoding(): string; /** * Returns OctetString value. If OctetString is constructed, returns concatenated internal OctetString values * @returns Array buffer * @since 3.0.0 */ getValue(): ArrayBuffer; /** * A typeguard that allows to validate if a certain asn1.js object is of our type * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ static typeGuard(obj: unknown | undefined): obj is OctetString; } interface LocalPrimitiveValueBlockParams extends HexBlockParams, ValueBlockParams { } interface LocalPrimitiveValueBlockJson extends HexBlockJson, ValueBlockJson { } declare const LocalPrimitiveValueBlock_base: { new (...args: any[]): { isHexOnly: boolean; valueHex: ArrayBuffer; valueHexView: Uint8Array; fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; toBER(sizeOnly?: boolean): ArrayBuffer; toJSON(): { isHexOnly: boolean; valueHex: string; blockName: string; valueBeforeDecode: string; blockLength: number; error: string; warnings: string[]; }; blockLength: number; error: string; warnings: string[]; valueBeforeDecode: ArrayBuffer; valueBeforeDecodeView: Uint8Array; }; NAME: string; defaultIDs: IBaseIDs; blockName(): string; } & typeof ValueBlock; declare class LocalPrimitiveValueBlock extends LocalPrimitiveValueBlock_base { static NAME: string; constructor({ isHexOnly, ...parameters }?: LocalPrimitiveValueBlockParams); } interface PrimitiveParams extends BaseBlockParams, LocalPrimitiveValueBlockParams { } type PrimitiveJson = BaseBlockJson<LocalPrimitiveValueBlockJson>; declare class Primitive extends BaseBlock<LocalPrimitiveValueBlock, LocalPrimitiveValueBlockJson> { static NAME: string; constructor(parameters?: PrimitiveParams); getValue(): null; setValue(value: number): void; } type PrintableStringParams = LocalSimpleStringBlockParams; type PrintableStringJson = LocalSimpleStringBlockJson; declare class PrintableString extends LocalSimpleStringBlock { static NAME: string; static defaultIDs: { tagClass: ETagClass; tagNumber: EUniversalTagNumber; }; constructor(parameters?: PrintableStringParams); /** * A typeguard that allows to validate if a certain asn1.js object is of our type * * @param obj The object we want to match against the type of this class * @returns true if obj is of the same type as our class */ static typeGuard(obj: unknown | undefined): obj is PrintableString; } interface ILocalRelativeSidValueBlock { valueDec: number; } interface LocalRelativeSidValueBlockParams extends HexBlockParams, ValueBlockParams, Partial<ILocalRelativeSidValueBlock> { } interface LocalRelativeSidValueBlockJson extends HexBlockJson, ValueBlockJson, ILocalRelativeSidValueBlock { } declare const LocalRelativeSidValueBlock_base: { new (...args: any[]): { isHexOnly: boolean; valueHex: ArrayBuffer; valueHexView: Uint8Array; fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; toBER(sizeOnly?: boolean): ArrayBuffer; toJSON(): { isHexOnly: boolean; valueHex: string; blockName: string; valueBeforeDecode: string; blockLength: number; error: string; warnings: string[]; }; blockLength: number; error: string; warnings: string[]; valueBeforeDecode: ArrayBuffer; valueBeforeDecodeView: Uint8Array; }; NAME: string; defaultIDs: IBaseIDs; blockName(): string; } & typeof LocalBaseBlock; declare class LocalRelativeSidValueBlock extends LocalRelativeSidValueBlock_base implements ILocalRelativeSidValueBlock { static NAME: string; valueDec: number; constructor({ valueDec, ...parameters }?: LocalRelativeSidValueBlockParams); fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; toBER(sizeOnly?: boolean): ArrayBuffer; toString(): string; toJSON(): LocalRelativeSidValueBlockJson; } interface ILocalRelativeObjectIdentifierValueBlock { value: string; } interface LocalRelativeObjectIdentifierValueBlockParams extends ValueBlockParams, Partial<ILocalRelativeObjectIdentifierValueBlock> { } interface LocalRelativeObjectIdentifierValueBlockJson extends ValueBlockJson, ILocalRelativeObjectIdentifierValueBlock { sidArray: LocalRelativeSidValueBlockJson[]; } declare class LocalRelativeObjectIdentifierValueBlock extends ValueBlock implements IStringConvertible { static NAME: string; value: LocalRelativeSidValueBlock[]; constructor({ value, ...parameters }?: LocalRelativeObjectIdentifierValueBlockParams); fromBER(inputBuffer: ArrayBuffer | Uint8Array, inputOffset: number, inputLength: number): number; toBER(sizeOnly?: boolean, writer?: ViewWriter): ArrayBuffer; fromString(string: string): boolean; toString(): string; toJSON(): LocalRelativeObjectIdentifierValueBlockJson; } interface RelativeObjectIdentifierParams extends BaseBlockParams, LocalRelativeObjectIdentifierValueBlockParams { } interface RelativeObjectIdentifierJson extends BaseBlockJson<LocalRelativeOb