UNPKG

@hazae41/kdbx

Version:

Rust-like KeePass (KDBX 4) file format for TypeScript

49 lines (46 loc) 1.39 kB
import { Opaque } from '@hazae41/binary'; class TLV { type; value; constructor(type, value) { this.type = type; this.value = value; } sizeOrThrow() { return 1 + 4 + this.value.sizeOrThrow(); } writeOrThrow(cursor) { cursor.writeUint8OrThrow(this.type); cursor.writeUint32OrThrow(this.value.sizeOrThrow(), true); this.value.writeOrThrow(cursor); } cloneOrThrow() { return new TLV(this.type, this.value.cloneOrThrow()); } readIntoOrThrow(readable) { return new TLV(this.type, this.value.readIntoOrThrow(readable)); } } (function (TLV) { (function (Empty) { Empty.type = 0x00; function sizeOrThrow() { return 1 + 4; } Empty.sizeOrThrow = sizeOrThrow; function writeOrThrow(cursor) { cursor.writeUint8OrThrow(Empty.type); cursor.writeUint32OrThrow(0, true); } Empty.writeOrThrow = writeOrThrow; })(TLV.Empty || (TLV.Empty = {})); function readOrThrow(cursor) { const type = cursor.readUint8OrThrow(); const length = cursor.readUint32OrThrow(true); const bytes = new Opaque(cursor.readOrThrow(length)); return new TLV(type, bytes); } TLV.readOrThrow = readOrThrow; })(TLV || (TLV = {})); export { TLV }; //# sourceMappingURL=index.mjs.map