@hazae41/kdbx
Version:
Rust-like KeePass (KDBX 4) file format for TypeScript
211 lines (210 loc) • 8.25 kB
TypeScript
export * from "./cipher/mod.ts";
export * from "./compression/mod.ts";
import { Dictionary, Value } from "../../dictionary/mod.ts";
import { type CompositeKey, DerivedKey, MasterKeys } from "../../mod.ts";
import { Vector } from "../../vector/mod.ts";
import { Unknown } from "@hazae41/binary";
import type { Cursor } from "@hazae41/cursor";
import { Nullable } from "../../../../libs/nullable/mod.ts";
import { Cipher } from "./cipher/mod.ts";
import { Compression } from "./compression/mod.ts";
export declare class Version {
readonly major: number;
readonly minor: number;
constructor(major: number, minor: number);
sizeOrThrow(): number;
writeOrThrow(cursor: Cursor<ArrayBuffer>): void;
cloneOrThrow(): this;
}
export declare class MagicAndVersionAndHeadersWithBytesWithHashAndHmacWithKeys {
readonly data: MagicAndVersionAndHeadersWithBytesWithHashAndHmac;
readonly keys: MasterKeys;
constructor(data: MagicAndVersionAndHeadersWithBytesWithHashAndHmac, keys: MasterKeys);
sizeOrThrow(): number;
writeOrThrow(cursor: Cursor<ArrayBuffer>): void;
rotateOrThrow(composite: CompositeKey): Promise<MagicAndVersionAndHeadersWithBytesWithHashAndHmacWithKeys>;
}
export declare class MagicAndVersionAndHeadersWithBytesWithHashAndHmac {
readonly data: MagicAndVersionAndHeadersWithBytes;
readonly hash: Unknown<ArrayBuffer, 32>;
readonly hmac: Unknown<ArrayBuffer, 32>;
constructor(data: MagicAndVersionAndHeadersWithBytes, hash: Unknown<ArrayBuffer, 32>, hmac: Unknown<ArrayBuffer, 32>);
static computeOrThrow(data: MagicAndVersionAndHeadersWithBytes, keys: MasterKeys): Promise<MagicAndVersionAndHeadersWithBytesWithHashAndHmac>;
verifyOrThrow(keys: MasterKeys): Promise<void>;
sizeOrThrow(): number;
writeOrThrow(cursor: Cursor<ArrayBuffer>): void;
cloneOrThrow(): MagicAndVersionAndHeadersWithBytesWithHashAndHmac;
deriveOrThrow(composite: CompositeKey): Promise<MasterKeys>;
}
export declare namespace MagicAndVersionAndHeadersWithBytesWithHashAndHmac {
function readOrThrow(cursor: Cursor<ArrayBuffer>): MagicAndVersionAndHeadersWithBytesWithHashAndHmac;
}
export declare class MagicAndVersionAndHeadersWithBytes {
readonly value: MagicAndVersionAndHeaders;
readonly bytes: Unknown<ArrayBuffer>;
constructor(value: MagicAndVersionAndHeaders, bytes: Unknown<ArrayBuffer>);
static computeOrThrow(value: MagicAndVersionAndHeaders): MagicAndVersionAndHeadersWithBytes;
rotateOrThrow(): MagicAndVersionAndHeadersWithBytes;
sizeOrThrow(): number;
writeOrThrow(cursor: Cursor<ArrayBuffer>): void;
cloneOrThrow(): MagicAndVersionAndHeadersWithBytes;
deriveOrThrow(composite: CompositeKey): Promise<MasterKeys>;
}
export declare namespace MagicAndVersionAndHeadersWithBytes {
function readOrThrow(cursor: Cursor<ArrayBuffer>): MagicAndVersionAndHeadersWithBytes;
}
export declare class MagicAndVersionAndHeaders {
readonly version: Version;
readonly headers: Headers;
constructor(version: Version, headers: Headers);
rotateOrThrow(): MagicAndVersionAndHeaders;
sizeOrThrow(): number;
writeOrThrow(cursor: Cursor<ArrayBuffer>): void;
cloneOrThrow(): MagicAndVersionAndHeaders;
deriveOrThrow(composite: CompositeKey): Promise<MasterKeys>;
}
export declare namespace MagicAndVersionAndHeaders {
function readOrThrow(cursor: Cursor<ArrayBuffer>): MagicAndVersionAndHeaders;
}
export interface HeadersInit {
readonly cipher: Cipher;
readonly compression: Compression;
readonly seed: Unknown<ArrayBuffer, 32>;
readonly iv: Unknown<ArrayBuffer>;
readonly kdf: KdfParameters;
readonly custom?: Nullable<Dictionary>;
}
export declare class Headers {
readonly value: Vector<{
2: readonly [Cipher];
3: readonly [Compression];
4: readonly [Unknown<ArrayBuffer, 32>];
7: readonly [Unknown<ArrayBuffer>];
11: readonly [KdfParameters];
12?: readonly [Dictionary];
}>;
constructor(value: Vector<{
2: readonly [Cipher];
3: readonly [Compression];
4: readonly [Unknown<ArrayBuffer, 32>];
7: readonly [Unknown<ArrayBuffer>];
11: readonly [KdfParameters];
12?: readonly [Dictionary];
}>);
get cipher(): Cipher;
get compression(): Compression;
get seed(): Unknown<ArrayBuffer, 32>;
get iv(): Unknown<ArrayBuffer>;
get kdf(): KdfParameters;
get custom(): Nullable<Dictionary>;
rotateOrThrow(): Headers;
sizeOrThrow(): number;
writeOrThrow(cursor: Cursor<ArrayBuffer>): void;
cloneOrThrow(): Headers;
deriveOrThrow(composite: CompositeKey): Promise<MasterKeys>;
}
export declare namespace Headers {
function initOrThrow(init: HeadersInit): Headers;
function readOrThrow(cursor: Cursor<ArrayBuffer>): Headers;
}
export declare class Seed {
readonly bytes: Unknown<ArrayBuffer, 32>;
constructor(bytes: Unknown<ArrayBuffer, 32>);
static readOrThrow(cursor: Cursor<ArrayBuffer>): Seed;
}
export type KdfParameters = KdfParameters.AesKdf | KdfParameters.Argon2d | KdfParameters.Argon2id;
export declare namespace KdfParameters {
class AesKdf {
readonly value: Dictionary<{
$UUID: Value.Bytes;
R: Value.UInt32;
S: Value.Bytes;
}>;
constructor(value: Dictionary<{
$UUID: Value.Bytes;
R: Value.UInt32;
S: Value.Bytes;
}>);
get seed(): Unknown<ArrayBuffer>;
get rounds(): number;
rotateOrThrow(): AesKdf;
deriveOrThrow(key: CompositeKey): never;
sizeOrThrow(): number;
writeOrThrow(cursor: Cursor<ArrayBuffer>): void;
cloneOrThrow(): AesKdf;
}
namespace AesKdf {
const $UUID = "c9d9f39a-628a-4460-bf74-0d08c18a4fea";
function parseOrThrow(dictionary: Dictionary): AesKdf;
}
type Argon2 = Argon2d | Argon2id;
namespace Argon2 {
type Version = 0x10 | 0x13;
}
class Argon2d {
readonly value: Dictionary<{
$UUID: Value.Bytes;
S: Value.Bytes<32>;
P: Value.UInt32;
M: Value.UInt64;
I: Value.UInt64;
V: Value.UInt32<Argon2.Version>;
}>;
constructor(value: Dictionary<{
$UUID: Value.Bytes;
S: Value.Bytes<32>;
P: Value.UInt32;
M: Value.UInt64;
I: Value.UInt64;
V: Value.UInt32<Argon2.Version>;
}>);
get salt(): Unknown<ArrayBuffer>;
get parallelism(): number;
get memory(): bigint;
get iterations(): bigint;
get version(): Argon2.Version;
rotateOrThrow(): Argon2d;
deriveOrThrow(key: CompositeKey): DerivedKey;
sizeOrThrow(): number;
writeOrThrow(cursor: Cursor<ArrayBuffer>): void;
cloneOrThrow(): Argon2d;
}
namespace Argon2d {
const $UUID = "ef636ddf-8c29-444b-91f7-a9a403e30a0c";
function createOrThrow(): Argon2d;
function parseOrThrow(dictionary: Dictionary): Argon2d;
}
class Argon2id {
readonly value: Dictionary<{
$UUID: Value.Bytes;
S: Value.Bytes<32>;
P: Value.UInt32;
M: Value.UInt64;
I: Value.UInt64;
V: Value.UInt32<Argon2.Version>;
}>;
constructor(value: Dictionary<{
$UUID: Value.Bytes;
S: Value.Bytes<32>;
P: Value.UInt32;
M: Value.UInt64;
I: Value.UInt64;
V: Value.UInt32<Argon2.Version>;
}>);
get salt(): Unknown<ArrayBuffer>;
get parallelism(): number;
get memory(): bigint;
get iterations(): bigint;
get version(): Argon2.Version;
rotateOrThrow(): Argon2d;
deriveOrThrow(key: CompositeKey): DerivedKey;
sizeOrThrow(): number;
writeOrThrow(cursor: Cursor<ArrayBuffer>): void;
cloneOrThrow(): Argon2id;
}
namespace Argon2id {
const $UUID = "9e298b19-56db-4773-b23d-fc3ec6f0a1e6";
function parseOrThrow(dictionary: Dictionary): Argon2id;
}
function readOrThrow(cursor: Cursor<ArrayBuffer>): KdfParameters;
}