asn1tools-js
Version:
ASN.1 encoding and decoding library for TypeScript/JavaScript, compatible with Python asn1tools
90 lines • 2.51 kB
TypeScript
/**
* Core type definitions for ASN.1 tools TypeScript implementation
*/
export interface Asn1Value {
[key: string]: any;
}
export interface Asn1Type {
name: string;
tag: number;
encode(value: any): Uint8Array;
decode(data: Uint8Array, offset?: number): {
value: any;
length: number;
};
}
export interface Asn1Module {
name: string;
types: Map<string, Asn1Type>;
}
export interface Asn1Specification {
modules: Map<string, Asn1Module>;
types: Map<string, Asn1Type>;
}
export interface ParsedType {
name: string;
type: string;
tag?: number | undefined;
optional?: boolean | undefined;
default?: any;
constraints?: any;
members?: ParsedType[] | undefined;
elementType?: ParsedType | undefined;
choices?: ParsedType[] | undefined;
}
export interface ParsedModule {
name: string;
types: Map<string, ParsedType>;
}
export interface CompileOptions {
codec?: 'ber' | 'der' | 'per' | 'uper';
checkConstraints?: boolean;
}
export declare const BER: {
readonly CLASS: {
readonly UNIVERSAL: 0;
readonly APPLICATION: 64;
readonly CONTEXT_SPECIFIC: 128;
readonly PRIVATE: 192;
};
readonly ENCODING: {
readonly PRIMITIVE: 0;
readonly CONSTRUCTED: 32;
};
readonly TAG: {
readonly BOOLEAN: 1;
readonly INTEGER: 2;
readonly BIT_STRING: 3;
readonly OCTET_STRING: 4;
readonly NULL: 5;
readonly OBJECT_IDENTIFIER: 6;
readonly ENUMERATED: 10;
readonly SEQUENCE: 16;
readonly SET: 17;
readonly PRINTABLE_STRING: 19;
readonly IA5_STRING: 22;
readonly UTC_TIME: 23;
readonly GENERALIZED_TIME: 24;
readonly CHOICE: 255;
};
};
export type BerTag = typeof BER.TAG[keyof typeof BER.TAG];
export declare class Asn1Error extends Error {
constructor(message: string);
}
export declare class EncodeError extends Asn1Error {
constructor(message: string);
}
export declare class DecodeError extends Asn1Error {
offset?: number | undefined;
constructor(message: string, offset?: number | undefined);
}
export declare class ParseError extends Asn1Error {
line?: number | undefined;
column?: number | undefined;
constructor(message: string, line?: number | undefined, column?: number | undefined);
}
export declare class CompileError extends Asn1Error {
constructor(message: string);
}
//# sourceMappingURL=types.d.ts.map