asn1tools-js
Version:
ASN.1 encoding and decoding library for TypeScript/JavaScript, compatible with Python asn1tools
81 lines • 2.06 kB
JavaScript
;
/**
* Core type definitions for ASN.1 tools TypeScript implementation
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.CompileError = exports.ParseError = exports.DecodeError = exports.EncodeError = exports.Asn1Error = exports.BER = void 0;
// BER encoding constants
exports.BER = {
CLASS: {
UNIVERSAL: 0x00,
APPLICATION: 0x40,
CONTEXT_SPECIFIC: 0x80,
PRIVATE: 0xc0
},
ENCODING: {
PRIMITIVE: 0x00,
CONSTRUCTED: 0x20
},
TAG: {
BOOLEAN: 0x01,
INTEGER: 0x02,
BIT_STRING: 0x03,
OCTET_STRING: 0x04,
NULL: 0x05,
OBJECT_IDENTIFIER: 0x06,
ENUMERATED: 0x0a,
SEQUENCE: 0x10,
SET: 0x11,
PRINTABLE_STRING: 0x13,
IA5_STRING: 0x16,
UTC_TIME: 0x17,
GENERALIZED_TIME: 0x18,
CHOICE: 0xff // Special marker for CHOICE types
}
};
// Error classes
class Asn1Error extends Error {
constructor(message) {
super(message);
this.name = 'Asn1Error';
}
}
exports.Asn1Error = Asn1Error;
class EncodeError extends Asn1Error {
constructor(message) {
super(message);
this.name = 'EncodeError';
}
}
exports.EncodeError = EncodeError;
class DecodeError extends Asn1Error {
constructor(message, offset) {
super(message);
this.name = 'DecodeError';
if (offset !== undefined) {
this.offset = offset;
}
}
}
exports.DecodeError = DecodeError;
class ParseError extends Asn1Error {
constructor(message, line, column) {
super(message);
this.name = 'ParseError';
if (line !== undefined) {
this.line = line;
}
if (column !== undefined) {
this.column = column;
}
}
}
exports.ParseError = ParseError;
class CompileError extends Asn1Error {
constructor(message) {
super(message);
this.name = 'CompileError';
}
}
exports.CompileError = CompileError;
//# sourceMappingURL=types.js.map