UNPKG

@hazae41/kdbx

Version:

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

164 lines (163 loc) 5.22 kB
import type { Nullable } from "../../../libs/nullable/mod.ts"; import { Unknown } from "@hazae41/binary"; import { Cursor } from "@hazae41/cursor"; export declare class Dictionary<T extends { [key: string]: Value; } = { [key: string]: Value; }> { readonly version: Dictionary.Version; readonly entries: Entries<T>; constructor(version: Dictionary.Version, entries: Entries<T>); sizeOrThrow(): number; writeOrThrow(cursor: Cursor<ArrayBuffer>): void; cloneOrThrow(): Dictionary<T>; } export declare namespace Dictionary { class Version { readonly minor: number; readonly major: number; constructor(minor: number, major: number); sizeOrThrow(): number; writeOrThrow(cursor: Cursor<ArrayBuffer>): void; cloneOrThrow(): Version; } namespace Version { function readOrThrow(cursor: Cursor<ArrayBuffer>): Version; } function initOrThrow<T extends { [key: string]: Value; }>(version: Version, entries: T): Dictionary<T>; function readOrThrow(cursor: Cursor<ArrayBuffer>): Dictionary<{ [key: string]: Value; }>; } export declare class Entries<T extends { [key: string]: Value; } = { [key: string]: Value; }> { readonly bytes: Unknown<ArrayBuffer>; readonly value: T; constructor(bytes: Unknown<ArrayBuffer>, value: T); sizeOrThrow(): number; writeOrThrow(cursor: Cursor<ArrayBuffer>): void; cloneOrThrow(): Entries<T>; } export declare namespace Entries { function initOrThrow<T extends { [key: string]: Value; }>(value: T): Entries<T>; function readOrThrow(cursor: Cursor<ArrayBuffer>): Entries<{ [key: string]: Value; }>; } export declare class Entry<T extends Value> { readonly key: Key; readonly val: T; constructor(key: Key, val: T); sizeOrThrow(): number; writeOrThrow(cursor: Cursor<ArrayBuffer>): void; } export declare namespace Entry { function readOrThrow(cursor: Cursor<ArrayBuffer>): Nullable<Entry<Value>>; } export declare class Key { readonly bytes: Unknown<ArrayBuffer>; readonly value: string; constructor(bytes: Unknown<ArrayBuffer>, value: string); sizeOrThrow(): number; writeOrThrow(cursor: Cursor<ArrayBuffer>): void; } export declare namespace Key { function initOrThrow(value: string): Key; } export type Value = Value.UInt32 | Value.UInt64 | Value.Boolean | Value.Int32 | Value.Int64 | Value.String | Value.Bytes; export declare namespace Value { function parseOrThrow(type: number, value: Unknown<ArrayBuffer>): Value; class UInt32<T extends number = number> { #private; readonly value: T; constructor(value: T); get type(): number; sizeOrThrow(): number; writeOrThrow(cursor: Cursor<ArrayBuffer>): void; } namespace UInt32 { const type = 4; function readOrThrow(cursor: Cursor<ArrayBuffer>): UInt32; } class UInt64<T extends bigint = bigint> { #private; readonly value: T; constructor(value: T); get type(): number; sizeOrThrow(): number; writeOrThrow(cursor: Cursor<ArrayBuffer>): void; } namespace UInt64 { const type = 5; function readOrThrow(cursor: Cursor<ArrayBuffer>): UInt64; } class Boolean { #private; readonly value: boolean; constructor(value: boolean); get type(): number; sizeOrThrow(): number; writeOrThrow(cursor: Cursor<ArrayBuffer>): void; } namespace Boolean { const type = 8; function readOrThrow(cursor: Cursor<ArrayBuffer>): Boolean; } class Int32<T extends number = number> { #private; readonly value: T; constructor(value: T); get type(): number; sizeOrThrow(): number; writeOrThrow(cursor: Cursor<ArrayBuffer>): void; } namespace Int32 { const type = 12; function readOrThrow(cursor: Cursor<ArrayBuffer>): Int32; } class Int64<T extends bigint = bigint> { #private; readonly value: T; constructor(value: T); get type(): number; sizeOrThrow(): number; writeOrThrow(cursor: Cursor<ArrayBuffer>): void; } namespace Int64 { const type = 13; function readOrThrow(cursor: Cursor<ArrayBuffer>): Int64; } class String { #private; readonly bytes: Unknown<ArrayBuffer>; readonly value: string; constructor(bytes: Unknown<ArrayBuffer>, value: string); get type(): number; sizeOrThrow(): number; writeOrThrow(cursor: Cursor<ArrayBuffer>): void; } namespace String { const type = 24; function readOrThrow(cursor: Cursor<ArrayBuffer>): String; } class Bytes<N extends number = number> { #private; readonly value: Unknown<ArrayBuffer>; constructor(value: Unknown<ArrayBuffer>); get type(): number; sizeOrThrow(): number; writeOrThrow(cursor: Cursor<ArrayBuffer>): void; } namespace Bytes { const type = 66; function readOrThrow(cursor: Cursor<ArrayBuffer>): Bytes; } }