@keenext/kdbxweb 0.0.0-stage → 2.2.0-keenext.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/FORK.md +56 -0
- package/LICENSE +20 -0
- package/README.md +523 -2
- package/dist/index.js +5750 -0
- package/dist/index.js.map +7 -0
- package/dist/types/crypto/chacha20.d.ts +11 -0
- package/dist/types/crypto/crypto-engine.d.ts +27 -0
- package/dist/types/crypto/hashed-block-transform.d.ts +2 -0
- package/dist/types/crypto/hmac-block-transform.d.ts +4 -0
- package/dist/types/crypto/key-encryptor-aes.d.ts +2 -0
- package/dist/types/crypto/key-encryptor-kdf.d.ts +2 -0
- package/dist/types/crypto/protect-salt-generator.d.ts +12 -0
- package/dist/types/crypto/protected-value.d.ts +20 -0
- package/dist/types/crypto/salsa20.d.ts +17 -0
- package/dist/types/crypto/twofish.d.ts +22 -0
- package/dist/types/defs/consts.d.ts +119 -0
- package/dist/types/defs/xml-names.d.ts +94 -0
- package/dist/types/errors/kdbx-error.d.ts +5 -0
- package/dist/types/format/kdbx-binaries.d.ts +34 -0
- package/dist/types/format/kdbx-context.d.ts +10 -0
- package/dist/types/format/kdbx-credentials.d.ts +16 -0
- package/dist/types/format/kdbx-custom-data.d.ts +12 -0
- package/dist/types/format/kdbx-deleted-object.d.ts +9 -0
- package/dist/types/format/kdbx-entry.d.ts +94 -0
- package/dist/types/format/kdbx-format.d.ts +43 -0
- package/dist/types/format/kdbx-group.d.ts +49 -0
- package/dist/types/format/kdbx-header.d.ts +74 -0
- package/dist/types/format/kdbx-meta.d.ts +110 -0
- package/dist/types/format/kdbx-times.d.ts +16 -0
- package/dist/types/format/kdbx-uuid.d.ts +11 -0
- package/dist/types/format/kdbx.d.ts +184 -0
- package/dist/types/index.d.ts +32 -0
- package/dist/types/utils/binary-stream.d.ts +38 -0
- package/dist/types/utils/byte-utils.d.ts +11 -0
- package/dist/types/utils/int64.d.ts +9 -0
- package/dist/types/utils/var-dictionary.d.ts +28 -0
- package/dist/types/utils/xml-utils.d.ts +42 -0
- package/package.json +46 -4
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class ChaCha20 {
|
|
2
|
+
private readonly _sigmaWords;
|
|
3
|
+
private readonly _block;
|
|
4
|
+
private _blockUsed;
|
|
5
|
+
private readonly _x;
|
|
6
|
+
private readonly _input;
|
|
7
|
+
constructor(key: Uint8Array, nonce: Uint8Array);
|
|
8
|
+
getBytes(numberOfBytes: number): Uint8Array;
|
|
9
|
+
private generateBlock;
|
|
10
|
+
encrypt(data: Uint8Array): Uint8Array;
|
|
11
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare function sha256(data: ArrayBuffer): Promise<ArrayBuffer>;
|
|
2
|
+
export declare function sha512(data: ArrayBuffer): Promise<ArrayBuffer>;
|
|
3
|
+
export declare function hmacSha256(key: ArrayBuffer, data: ArrayBuffer): Promise<ArrayBuffer>;
|
|
4
|
+
export declare abstract class AesCbc {
|
|
5
|
+
abstract importKey(key: ArrayBuffer): Promise<void>;
|
|
6
|
+
abstract encrypt(data: ArrayBuffer, iv: ArrayBuffer): Promise<ArrayBuffer>;
|
|
7
|
+
abstract decrypt(data: ArrayBuffer, iv: ArrayBuffer): Promise<ArrayBuffer>;
|
|
8
|
+
}
|
|
9
|
+
export declare function createAesCbc(): AesCbc;
|
|
10
|
+
export declare function random(len: number): Uint8Array;
|
|
11
|
+
/**
|
|
12
|
+
* Twofish-256 in CBC mode with PKCS#7 padding, as used for KDBX payloads by
|
|
13
|
+
* KeePass (TwofishCipher plugin), KeePassXC and KeePassDX.
|
|
14
|
+
*/
|
|
15
|
+
export declare function twofishCbc(data: ArrayBuffer, key: ArrayBuffer, iv: ArrayBuffer, encrypt: boolean): Promise<ArrayBuffer>;
|
|
16
|
+
export declare function chacha20(data: ArrayBuffer, key: ArrayBuffer, iv: ArrayBuffer): Promise<ArrayBuffer>;
|
|
17
|
+
export declare const Argon2TypeArgon2d = 0;
|
|
18
|
+
export declare const Argon2TypeArgon2id = 2;
|
|
19
|
+
export type Argon2Type = typeof Argon2TypeArgon2d | typeof Argon2TypeArgon2id;
|
|
20
|
+
export type Argon2Version = 0x10 | 0x13;
|
|
21
|
+
/**
|
|
22
|
+
* `signal` is aborted when the caller of Kdbx.load gives up; an implementation that can
|
|
23
|
+
* stop early (e.g. by terminating a worker) rejects with `signal.reason`.
|
|
24
|
+
*/
|
|
25
|
+
export type Argon2Fn = (password: ArrayBuffer, salt: ArrayBuffer, memory: number, iterations: number, length: number, parallelism: number, type: Argon2Type, version: Argon2Version, signal?: AbortSignal) => Promise<ArrayBuffer>;
|
|
26
|
+
export declare function argon2(password: ArrayBuffer, salt: ArrayBuffer, memory: number, iterations: number, length: number, parallelism: number, type: Argon2Type, version: Argon2Version, signal?: AbortSignal): Promise<ArrayBuffer>;
|
|
27
|
+
export declare function setArgon2Impl(impl: Argon2Fn): void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Int64 } from '../utils/int64';
|
|
2
|
+
export declare function getHmacKey(key: ArrayBuffer, blockIndex: Int64): Promise<ArrayBuffer>;
|
|
3
|
+
export declare function decrypt(data: ArrayBuffer, key: ArrayBuffer): Promise<ArrayBuffer>;
|
|
4
|
+
export declare function encrypt(data: ArrayBuffer, key: ArrayBuffer): Promise<ArrayBuffer>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Salsa20 } from './salsa20';
|
|
2
|
+
import { ChaCha20 } from './chacha20';
|
|
3
|
+
/**
|
|
4
|
+
* Protect information used for decrypt and encrypt protected data fields
|
|
5
|
+
* @constructor
|
|
6
|
+
*/
|
|
7
|
+
export declare class ProtectSaltGenerator {
|
|
8
|
+
private _algo;
|
|
9
|
+
constructor(algo: Salsa20 | ChaCha20);
|
|
10
|
+
getSalt(len: number): ArrayBuffer;
|
|
11
|
+
static create(key: ArrayBuffer | Uint8Array, crsAlgorithm: number): Promise<ProtectSaltGenerator>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare class ProtectedValue {
|
|
2
|
+
readonly value: Uint8Array;
|
|
3
|
+
readonly salt: Uint8Array;
|
|
4
|
+
constructor(value: ArrayBuffer, salt: ArrayBuffer);
|
|
5
|
+
toString(): string;
|
|
6
|
+
static fromString(str: string): ProtectedValue;
|
|
7
|
+
toBase64(): string;
|
|
8
|
+
static fromBase64(base64: string): ProtectedValue;
|
|
9
|
+
/**
|
|
10
|
+
* Keep in mind that you're passing the ownership of this array, the contents will be destroyed
|
|
11
|
+
*/
|
|
12
|
+
static fromBinary(binary: ArrayBuffer): ProtectedValue;
|
|
13
|
+
includes(str: string): boolean;
|
|
14
|
+
getHash(): Promise<ArrayBuffer>;
|
|
15
|
+
getText(): string;
|
|
16
|
+
getBinary(): Uint8Array;
|
|
17
|
+
setSalt(newSalt: ArrayBuffer): void;
|
|
18
|
+
clone(): ProtectedValue;
|
|
19
|
+
get byteLength(): number;
|
|
20
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare class Salsa20 {
|
|
2
|
+
private readonly _rounds;
|
|
3
|
+
private readonly _sigmaWords;
|
|
4
|
+
private readonly _keyWords;
|
|
5
|
+
private readonly _nonceWords;
|
|
6
|
+
private readonly _counterWords;
|
|
7
|
+
private readonly _block;
|
|
8
|
+
private _blockUsed;
|
|
9
|
+
constructor(key: Uint8Array, nonce: Uint8Array);
|
|
10
|
+
private setKey;
|
|
11
|
+
private setNonce;
|
|
12
|
+
getBytes(numberOfBytes: number): Uint8Array;
|
|
13
|
+
getHexString(numberOfBytes: number): string;
|
|
14
|
+
private reset;
|
|
15
|
+
private incrementCounter;
|
|
16
|
+
private generateBlock;
|
|
17
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const Q0: Uint8Array<ArrayBufferLike>;
|
|
2
|
+
export declare const Q1: Uint8Array<ArrayBufferLike>;
|
|
3
|
+
export declare class Twofish {
|
|
4
|
+
static readonly BlockSize = 16;
|
|
5
|
+
private readonly subkeys;
|
|
6
|
+
private readonly sboxes;
|
|
7
|
+
constructor(key: Uint8Array);
|
|
8
|
+
private g;
|
|
9
|
+
/** Encrypts the 16-byte block at `offset` in place. */
|
|
10
|
+
encryptBlock(block: Uint8Array, offset?: number): void;
|
|
11
|
+
/** Decrypts the 16-byte block at `offset` in place. */
|
|
12
|
+
decryptBlock(block: Uint8Array, offset?: number): void;
|
|
13
|
+
/** CBC with PKCS#7 padding; always adds 1–16 padding bytes. */
|
|
14
|
+
encryptCbc(data: Uint8Array, iv: Uint8Array): Uint8Array;
|
|
15
|
+
/**
|
|
16
|
+
* Inverse of encryptCbc. A wrong key almost always yields invalid padding,
|
|
17
|
+
* reported as InvalidKey like the AES path does.
|
|
18
|
+
*/
|
|
19
|
+
decryptCbc(data: Uint8Array, iv: Uint8Array): Uint8Array;
|
|
20
|
+
/** Overwrites the expanded key material. */
|
|
21
|
+
clear(): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
export declare const Signatures: {
|
|
2
|
+
readonly FileMagic: 2594363651;
|
|
3
|
+
readonly Sig2Kdbx: 3041655655;
|
|
4
|
+
readonly Sig2Kdb: 3041655653;
|
|
5
|
+
};
|
|
6
|
+
export declare const ErrorCodes: {
|
|
7
|
+
readonly NotImplemented: "NotImplemented";
|
|
8
|
+
readonly InvalidArg: "InvalidArg";
|
|
9
|
+
readonly BadSignature: "BadSignature";
|
|
10
|
+
readonly InvalidVersion: "InvalidVersion";
|
|
11
|
+
readonly Unsupported: "Unsupported";
|
|
12
|
+
readonly FileCorrupt: "FileCorrupt";
|
|
13
|
+
readonly InvalidKey: "InvalidKey";
|
|
14
|
+
readonly MergeError: "MergeError";
|
|
15
|
+
readonly InvalidState: "InvalidState";
|
|
16
|
+
};
|
|
17
|
+
export declare const CompressionAlgorithm: {
|
|
18
|
+
readonly None: 0;
|
|
19
|
+
readonly GZip: 1;
|
|
20
|
+
};
|
|
21
|
+
export declare const CrsAlgorithm: {
|
|
22
|
+
readonly Null: 0;
|
|
23
|
+
readonly ArcFourVariant: 1;
|
|
24
|
+
readonly Salsa20: 2;
|
|
25
|
+
readonly ChaCha20: 3;
|
|
26
|
+
};
|
|
27
|
+
export declare const KdfId: {
|
|
28
|
+
readonly Argon2: "72Nt34wpREuR96mkA+MKDA==";
|
|
29
|
+
readonly Argon2d: "72Nt34wpREuR96mkA+MKDA==";
|
|
30
|
+
readonly Argon2id: "nimLGVbbR3OyPfw+xvCh5g==";
|
|
31
|
+
readonly Aes: "ydnzmmKKRGC/dA0IwYpP6g==";
|
|
32
|
+
};
|
|
33
|
+
export declare const CipherId: {
|
|
34
|
+
readonly Aes: "McHy5r9xQ1C+WAUhavxa/w==";
|
|
35
|
+
readonly ChaCha20: "1gOKK4tvTLWlJDOaMdu1mg==";
|
|
36
|
+
readonly Twofish: "rWjyn1dvS7mjatR6+WU0bA==";
|
|
37
|
+
};
|
|
38
|
+
export declare const AutoTypeObfuscationOptions: {
|
|
39
|
+
readonly None: 0;
|
|
40
|
+
readonly UseClipboard: 1;
|
|
41
|
+
};
|
|
42
|
+
export declare const Defaults: {
|
|
43
|
+
readonly KeyEncryptionRounds: 300000;
|
|
44
|
+
readonly MntncHistoryDays: 365;
|
|
45
|
+
readonly HistoryMaxItems: 10;
|
|
46
|
+
readonly HistoryMaxSize: number;
|
|
47
|
+
readonly RecycleBinName: "Recycle Bin";
|
|
48
|
+
};
|
|
49
|
+
export declare const Icons: {
|
|
50
|
+
readonly Key: 0;
|
|
51
|
+
readonly World: 1;
|
|
52
|
+
readonly Warning: 2;
|
|
53
|
+
readonly NetworkServer: 3;
|
|
54
|
+
readonly MarkedDirectory: 4;
|
|
55
|
+
readonly UserCommunication: 5;
|
|
56
|
+
readonly Parts: 6;
|
|
57
|
+
readonly Notepad: 7;
|
|
58
|
+
readonly WorldSocket: 8;
|
|
59
|
+
readonly Identity: 9;
|
|
60
|
+
readonly PaperReady: 10;
|
|
61
|
+
readonly Digicam: 11;
|
|
62
|
+
readonly IRCommunication: 12;
|
|
63
|
+
readonly MultiKeys: 13;
|
|
64
|
+
readonly Energy: 14;
|
|
65
|
+
readonly Scanner: 15;
|
|
66
|
+
readonly WorldStar: 16;
|
|
67
|
+
readonly CDRom: 17;
|
|
68
|
+
readonly Monitor: 18;
|
|
69
|
+
readonly EMail: 19;
|
|
70
|
+
readonly Configuration: 20;
|
|
71
|
+
readonly ClipboardReady: 21;
|
|
72
|
+
readonly PaperNew: 22;
|
|
73
|
+
readonly Screen: 23;
|
|
74
|
+
readonly EnergyCareful: 24;
|
|
75
|
+
readonly EMailBox: 25;
|
|
76
|
+
readonly Disk: 26;
|
|
77
|
+
readonly Drive: 27;
|
|
78
|
+
readonly PaperQ: 28;
|
|
79
|
+
readonly TerminalEncrypted: 29;
|
|
80
|
+
readonly Console: 30;
|
|
81
|
+
readonly Printer: 31;
|
|
82
|
+
readonly ProgramIcons: 32;
|
|
83
|
+
readonly Run: 33;
|
|
84
|
+
readonly Settings: 34;
|
|
85
|
+
readonly WorldComputer: 35;
|
|
86
|
+
readonly Archive: 36;
|
|
87
|
+
readonly Homebanking: 37;
|
|
88
|
+
readonly DriveWindows: 38;
|
|
89
|
+
readonly Clock: 39;
|
|
90
|
+
readonly EMailSearch: 40;
|
|
91
|
+
readonly PaperFlag: 41;
|
|
92
|
+
readonly Memory: 42;
|
|
93
|
+
readonly TrashBin: 43;
|
|
94
|
+
readonly Note: 44;
|
|
95
|
+
readonly Expired: 45;
|
|
96
|
+
readonly Info: 46;
|
|
97
|
+
readonly Package: 47;
|
|
98
|
+
readonly Folder: 48;
|
|
99
|
+
readonly FolderOpen: 49;
|
|
100
|
+
readonly FolderPackage: 50;
|
|
101
|
+
readonly LockOpen: 51;
|
|
102
|
+
readonly PaperLocked: 52;
|
|
103
|
+
readonly Checked: 53;
|
|
104
|
+
readonly Pen: 54;
|
|
105
|
+
readonly Thumbnail: 55;
|
|
106
|
+
readonly Book: 56;
|
|
107
|
+
readonly List: 57;
|
|
108
|
+
readonly UserKey: 58;
|
|
109
|
+
readonly Tool: 59;
|
|
110
|
+
readonly Home: 60;
|
|
111
|
+
readonly Star: 61;
|
|
112
|
+
readonly Tux: 62;
|
|
113
|
+
readonly Feather: 63;
|
|
114
|
+
readonly Apple: 64;
|
|
115
|
+
readonly Wiki: 65;
|
|
116
|
+
readonly Money: 66;
|
|
117
|
+
readonly Certificate: 67;
|
|
118
|
+
readonly BlackBerry: 68;
|
|
119
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export declare const Elem: {
|
|
2
|
+
readonly DocNode: "KeePassFile";
|
|
3
|
+
readonly Meta: "Meta";
|
|
4
|
+
readonly Root: "Root";
|
|
5
|
+
readonly Group: "Group";
|
|
6
|
+
readonly Entry: "Entry";
|
|
7
|
+
readonly Generator: "Generator";
|
|
8
|
+
readonly HeaderHash: "HeaderHash";
|
|
9
|
+
readonly SettingsChanged: "SettingsChanged";
|
|
10
|
+
readonly DbName: "DatabaseName";
|
|
11
|
+
readonly DbNameChanged: "DatabaseNameChanged";
|
|
12
|
+
readonly DbDesc: "DatabaseDescription";
|
|
13
|
+
readonly DbDescChanged: "DatabaseDescriptionChanged";
|
|
14
|
+
readonly DbDefaultUser: "DefaultUserName";
|
|
15
|
+
readonly DbDefaultUserChanged: "DefaultUserNameChanged";
|
|
16
|
+
readonly DbMntncHistoryDays: "MaintenanceHistoryDays";
|
|
17
|
+
readonly DbColor: "Color";
|
|
18
|
+
readonly DbKeyChanged: "MasterKeyChanged";
|
|
19
|
+
readonly DbKeyChangeRec: "MasterKeyChangeRec";
|
|
20
|
+
readonly DbKeyChangeForce: "MasterKeyChangeForce";
|
|
21
|
+
readonly RecycleBinEnabled: "RecycleBinEnabled";
|
|
22
|
+
readonly RecycleBinUuid: "RecycleBinUUID";
|
|
23
|
+
readonly RecycleBinChanged: "RecycleBinChanged";
|
|
24
|
+
readonly EntryTemplatesGroup: "EntryTemplatesGroup";
|
|
25
|
+
readonly EntryTemplatesGroupChanged: "EntryTemplatesGroupChanged";
|
|
26
|
+
readonly HistoryMaxItems: "HistoryMaxItems";
|
|
27
|
+
readonly HistoryMaxSize: "HistoryMaxSize";
|
|
28
|
+
readonly LastSelectedGroup: "LastSelectedGroup";
|
|
29
|
+
readonly LastTopVisibleGroup: "LastTopVisibleGroup";
|
|
30
|
+
readonly MemoryProt: "MemoryProtection";
|
|
31
|
+
readonly ProtTitle: "ProtectTitle";
|
|
32
|
+
readonly ProtUserName: "ProtectUserName";
|
|
33
|
+
readonly ProtPassword: "ProtectPassword";
|
|
34
|
+
readonly ProtUrl: "ProtectURL";
|
|
35
|
+
readonly ProtNotes: "ProtectNotes";
|
|
36
|
+
readonly CustomIcons: "CustomIcons";
|
|
37
|
+
readonly CustomIconItem: "Icon";
|
|
38
|
+
readonly CustomIconItemID: "UUID";
|
|
39
|
+
readonly CustomIconItemData: "Data";
|
|
40
|
+
readonly CustomIconItemName: "Name";
|
|
41
|
+
readonly AutoType: "AutoType";
|
|
42
|
+
readonly History: "History";
|
|
43
|
+
readonly Name: "Name";
|
|
44
|
+
readonly Notes: "Notes";
|
|
45
|
+
readonly Uuid: "UUID";
|
|
46
|
+
readonly Icon: "IconID";
|
|
47
|
+
readonly CustomIconID: "CustomIconUUID";
|
|
48
|
+
readonly FgColor: "ForegroundColor";
|
|
49
|
+
readonly BgColor: "BackgroundColor";
|
|
50
|
+
readonly OverrideUrl: "OverrideURL";
|
|
51
|
+
readonly Times: "Times";
|
|
52
|
+
readonly Tags: "Tags";
|
|
53
|
+
readonly QualityCheck: "QualityCheck";
|
|
54
|
+
readonly PreviousParentGroup: "PreviousParentGroup";
|
|
55
|
+
readonly CreationTime: "CreationTime";
|
|
56
|
+
readonly LastModTime: "LastModificationTime";
|
|
57
|
+
readonly LastAccessTime: "LastAccessTime";
|
|
58
|
+
readonly ExpiryTime: "ExpiryTime";
|
|
59
|
+
readonly Expires: "Expires";
|
|
60
|
+
readonly UsageCount: "UsageCount";
|
|
61
|
+
readonly LocationChanged: "LocationChanged";
|
|
62
|
+
readonly GroupDefaultAutoTypeSeq: "DefaultAutoTypeSequence";
|
|
63
|
+
readonly EnableAutoType: "EnableAutoType";
|
|
64
|
+
readonly EnableSearching: "EnableSearching";
|
|
65
|
+
readonly String: "String";
|
|
66
|
+
readonly Binary: "Binary";
|
|
67
|
+
readonly Key: "Key";
|
|
68
|
+
readonly Value: "Value";
|
|
69
|
+
readonly AutoTypeEnabled: "Enabled";
|
|
70
|
+
readonly AutoTypeObfuscation: "DataTransferObfuscation";
|
|
71
|
+
readonly AutoTypeDefaultSeq: "DefaultSequence";
|
|
72
|
+
readonly AutoTypeItem: "Association";
|
|
73
|
+
readonly Window: "Window";
|
|
74
|
+
readonly KeystrokeSequence: "KeystrokeSequence";
|
|
75
|
+
readonly Binaries: "Binaries";
|
|
76
|
+
readonly IsExpanded: "IsExpanded";
|
|
77
|
+
readonly LastTopVisibleEntry: "LastTopVisibleEntry";
|
|
78
|
+
readonly DeletedObjects: "DeletedObjects";
|
|
79
|
+
readonly DeletedObject: "DeletedObject";
|
|
80
|
+
readonly DeletionTime: "DeletionTime";
|
|
81
|
+
readonly CustomData: "CustomData";
|
|
82
|
+
readonly StringDictExItem: "Item";
|
|
83
|
+
};
|
|
84
|
+
export declare const Attr: {
|
|
85
|
+
readonly Id: "ID";
|
|
86
|
+
readonly Ref: "Ref";
|
|
87
|
+
readonly Protected: "Protected";
|
|
88
|
+
readonly ProtectedInMemPlainXml: "ProtectInMemory";
|
|
89
|
+
readonly Compressed: "Compressed";
|
|
90
|
+
};
|
|
91
|
+
export declare const Val: {
|
|
92
|
+
readonly False: "False";
|
|
93
|
+
readonly True: "True";
|
|
94
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ProtectedValue } from '../crypto/protected-value';
|
|
2
|
+
export type KdbxBinaryRef = {
|
|
3
|
+
ref: string;
|
|
4
|
+
};
|
|
5
|
+
export type KdbxBinaryRefWithValue = {
|
|
6
|
+
ref: string;
|
|
7
|
+
value: KdbxBinary;
|
|
8
|
+
};
|
|
9
|
+
export type KdbxBinaryWithHash = {
|
|
10
|
+
hash: string;
|
|
11
|
+
value: KdbxBinary;
|
|
12
|
+
};
|
|
13
|
+
export type KdbxBinary = ProtectedValue | ArrayBuffer;
|
|
14
|
+
export type KdbxBinaryOrRef = KdbxBinary | KdbxBinaryRef;
|
|
15
|
+
export type KdbxBinaryIn = KdbxBinary | Uint8Array;
|
|
16
|
+
export declare class KdbxBinaries {
|
|
17
|
+
private readonly _mapById;
|
|
18
|
+
private readonly _mapByHash;
|
|
19
|
+
private readonly _idToHash;
|
|
20
|
+
computeHashes(): Promise<void>;
|
|
21
|
+
private static getBinaryHash;
|
|
22
|
+
add(value: KdbxBinaryIn): Promise<KdbxBinaryWithHash>;
|
|
23
|
+
addWithNextId(value: KdbxBinaryIn): void;
|
|
24
|
+
addWithId(id: string, value: KdbxBinaryIn): void;
|
|
25
|
+
addWithHash(binary: KdbxBinaryWithHash): void;
|
|
26
|
+
deleteWithHash(hash: string): void;
|
|
27
|
+
getByRef(binaryRef: KdbxBinaryRef): KdbxBinaryWithHash | undefined;
|
|
28
|
+
getRefByHash(hash: string): KdbxBinaryRef | undefined;
|
|
29
|
+
getAll(): KdbxBinaryRefWithValue[];
|
|
30
|
+
getAllWithHashes(): KdbxBinaryWithHash[];
|
|
31
|
+
getValueByHash(hash: string): KdbxBinary | undefined;
|
|
32
|
+
static isKdbxBinaryRef(binary: KdbxBinaryOrRef | undefined): binary is KdbxBinaryRef;
|
|
33
|
+
static isKdbxBinaryWithHash(binary: KdbxBinaryOrRef | KdbxBinaryWithHash | undefined): binary is KdbxBinaryWithHash;
|
|
34
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ProtectedValue } from '../crypto/protected-value';
|
|
2
|
+
export type KdbxChallengeResponseFn = (challenge: ArrayBuffer) => Promise<ArrayBuffer | Uint8Array>;
|
|
3
|
+
export declare class KdbxCredentials {
|
|
4
|
+
readonly ready: Promise<KdbxCredentials>;
|
|
5
|
+
passwordHash: ProtectedValue | undefined;
|
|
6
|
+
keyFileHash: ProtectedValue | undefined;
|
|
7
|
+
private _challengeResponse;
|
|
8
|
+
constructor(password: ProtectedValue | null, keyFile?: ArrayBuffer | Uint8Array | null, challengeResponse?: KdbxChallengeResponseFn);
|
|
9
|
+
setPassword(password: ProtectedValue | null): Promise<void>;
|
|
10
|
+
setKeyFile(keyFile: ArrayBuffer | Uint8Array | null | undefined): Promise<void>;
|
|
11
|
+
private setChallengeResponse;
|
|
12
|
+
getHash(challenge?: ArrayBuffer): Promise<ArrayBuffer>;
|
|
13
|
+
getChallengeResponse(challenge?: ArrayBuffer): Promise<ArrayBuffer | Uint8Array | null>;
|
|
14
|
+
static createRandomKeyFile(version?: number): Promise<Uint8Array>;
|
|
15
|
+
static createKeyFileWithHash(keyBytes: ArrayBuffer, version?: number): Promise<Uint8Array>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { KdbxContext } from './kdbx-context';
|
|
2
|
+
export type KdbxCustomDataItem = {
|
|
3
|
+
value: string | undefined;
|
|
4
|
+
lastModified?: Date | undefined;
|
|
5
|
+
};
|
|
6
|
+
export type KdbxCustomDataMap = Map<string, KdbxCustomDataItem>;
|
|
7
|
+
export declare class KdbxCustomData {
|
|
8
|
+
static copy(customData: KdbxCustomDataMap | undefined): KdbxCustomDataMap | undefined;
|
|
9
|
+
static read(node: Node): KdbxCustomDataMap;
|
|
10
|
+
static write(parentNode: Node, ctx: KdbxContext, customData: KdbxCustomDataMap | undefined): void;
|
|
11
|
+
private static readItem;
|
|
12
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { KdbxUuid } from './kdbx-uuid';
|
|
2
|
+
import { KdbxContext } from './kdbx-context';
|
|
3
|
+
export declare class KdbxDeletedObject {
|
|
4
|
+
uuid: KdbxUuid | undefined;
|
|
5
|
+
deletionTime: Date | undefined;
|
|
6
|
+
private readNode;
|
|
7
|
+
write(parentNode: Node, ctx: KdbxContext): void;
|
|
8
|
+
static read(xmlNode: Node): KdbxDeletedObject;
|
|
9
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { KdbxTimes } from './kdbx-times';
|
|
2
|
+
import { ProtectedValue } from '../crypto/protected-value';
|
|
3
|
+
import { KdbxCustomDataMap } from './kdbx-custom-data';
|
|
4
|
+
import { KdbxUuid } from './kdbx-uuid';
|
|
5
|
+
import { KdbxContext } from './kdbx-context';
|
|
6
|
+
import { KdbxBinary, KdbxBinaryWithHash } from './kdbx-binaries';
|
|
7
|
+
import { KdbxMeta } from './kdbx-meta';
|
|
8
|
+
import { KdbxGroup } from './kdbx-group';
|
|
9
|
+
import { MergeObjectMap } from './kdbx';
|
|
10
|
+
export type KdbxEntryField = string | ProtectedValue;
|
|
11
|
+
export interface KdbxAutoTypeItem {
|
|
12
|
+
window: string;
|
|
13
|
+
keystrokeSequence: string;
|
|
14
|
+
}
|
|
15
|
+
export interface KdbxEntryAutoType {
|
|
16
|
+
enabled: boolean;
|
|
17
|
+
obfuscation: number;
|
|
18
|
+
defaultSequence?: string;
|
|
19
|
+
items: KdbxAutoTypeItem[];
|
|
20
|
+
}
|
|
21
|
+
export interface KdbxEntryEditState {
|
|
22
|
+
added: number[];
|
|
23
|
+
deleted: number[];
|
|
24
|
+
}
|
|
25
|
+
export declare class KdbxEntry {
|
|
26
|
+
uuid: KdbxUuid;
|
|
27
|
+
icon: number | undefined;
|
|
28
|
+
customIcon: KdbxUuid | undefined;
|
|
29
|
+
fgColor: string | undefined;
|
|
30
|
+
bgColor: string | undefined;
|
|
31
|
+
overrideUrl: string | undefined;
|
|
32
|
+
tags: string[];
|
|
33
|
+
times: KdbxTimes;
|
|
34
|
+
fields: Map<string, KdbxEntryField>;
|
|
35
|
+
binaries: Map<string, KdbxBinary | KdbxBinaryWithHash>;
|
|
36
|
+
autoType: KdbxEntryAutoType;
|
|
37
|
+
history: KdbxEntry[];
|
|
38
|
+
parentGroup: KdbxGroup | undefined;
|
|
39
|
+
previousParentGroup: KdbxUuid | undefined;
|
|
40
|
+
customData: KdbxCustomDataMap | undefined;
|
|
41
|
+
qualityCheck: boolean | undefined;
|
|
42
|
+
_editState: KdbxEntryEditState | undefined;
|
|
43
|
+
get lastModTime(): number;
|
|
44
|
+
get locationChanged(): number;
|
|
45
|
+
private readNode;
|
|
46
|
+
private readField;
|
|
47
|
+
private writeFields;
|
|
48
|
+
private readBinary;
|
|
49
|
+
private writeBinaries;
|
|
50
|
+
private readAutoType;
|
|
51
|
+
private readAutoTypeItem;
|
|
52
|
+
private writeAutoType;
|
|
53
|
+
private readHistory;
|
|
54
|
+
private writeHistory;
|
|
55
|
+
private readCustomData;
|
|
56
|
+
private writeCustomData;
|
|
57
|
+
private setField;
|
|
58
|
+
private addHistoryTombstone;
|
|
59
|
+
write(parentNode: Element, ctx: KdbxContext): void;
|
|
60
|
+
pushHistory(): void;
|
|
61
|
+
removeHistory(index: number, count?: number): void;
|
|
62
|
+
/**
|
|
63
|
+
* Copies the entry's state, everything but history, parentGroup and _editState.
|
|
64
|
+
* Merge, history snapshots and importEntry rely on this being complete.
|
|
65
|
+
*/
|
|
66
|
+
copyFrom(entry: KdbxEntry): void;
|
|
67
|
+
merge(objectMap: MergeObjectMap): void;
|
|
68
|
+
/**
|
|
69
|
+
* Merge entry history with remote entry history
|
|
70
|
+
* Tombstones are stored locally and must be immediately discarded by replica after successful upstream push.
|
|
71
|
+
* It's client responsibility, to save and load tombstones for local replica, and to clear them after successful upstream push.
|
|
72
|
+
*
|
|
73
|
+
* Implements remove-win OR-set CRDT with local tombstones stored in _editState.
|
|
74
|
+
*
|
|
75
|
+
* Format doesn't allow saving tombstones for history entries, so they are stored locally.
|
|
76
|
+
* Any unmodified state from past or modifications of current state synced with central upstream will be successfully merged.
|
|
77
|
+
* Assumes there's only one central upstream, may produce inconsistencies while merging outdated replica outside main upstream.
|
|
78
|
+
* Phantom entries and phantom deletions will appear if remote replica checked out an old state and has just added a new state.
|
|
79
|
+
* If a client is using central upstream for sync, the remote replica must first sync it state and
|
|
80
|
+
* only after it update the upstream, so this should never happen.
|
|
81
|
+
*
|
|
82
|
+
* References:
|
|
83
|
+
*
|
|
84
|
+
* An Optimized Conflict-free Replicated Set arXiv:1210.3368 [cs.DC]
|
|
85
|
+
* http://arxiv.org/abs/1210.3368
|
|
86
|
+
*
|
|
87
|
+
* Gene T. J. Wuu and Arthur J. Bernstein. Efficient solutions to the replicated log and dictionary
|
|
88
|
+
* problems. In Symp. on Principles of Dist. Comp. (PODC), pages 233–242, Vancouver, BC, Canada, August 1984.
|
|
89
|
+
* https://pages.lip6.fr/Marc.Shapiro/papers/RR-7687.pdf
|
|
90
|
+
*/
|
|
91
|
+
private mergeHistory;
|
|
92
|
+
static create(meta: KdbxMeta, parentGroup: KdbxGroup): KdbxEntry;
|
|
93
|
+
static read(xmlNode: Node, ctx: KdbxContext, parentGroup?: KdbxGroup): KdbxEntry;
|
|
94
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Kdbx } from './kdbx';
|
|
2
|
+
import { KdbxContext } from './kdbx-context';
|
|
3
|
+
export declare class KdbxFormat {
|
|
4
|
+
readonly kdbx: Kdbx;
|
|
5
|
+
readonly ctx: KdbxContext;
|
|
6
|
+
preserveXml: boolean;
|
|
7
|
+
/** Stops key derivation when aborted; set by Kdbx.load. */
|
|
8
|
+
signal: AbortSignal | undefined;
|
|
9
|
+
constructor(kdbx: Kdbx);
|
|
10
|
+
load(data: ArrayBuffer): Promise<Kdbx>;
|
|
11
|
+
private loadV3;
|
|
12
|
+
private loadV4;
|
|
13
|
+
loadXml(xmlStr: string): Promise<Kdbx>;
|
|
14
|
+
/**
|
|
15
|
+
* Files become KDBX 4.1 when they hold values their version cannot store, instead of
|
|
16
|
+
* losing them. KDBX 3 keeps its AES-KDF and rounds. Leaving KDBX 3 locks out clients
|
|
17
|
+
* that only read KDBX 3, so a moved object (previous parent group) alone does not
|
|
18
|
+
* justify it.
|
|
19
|
+
*/
|
|
20
|
+
private raiseVersionIfNeeded;
|
|
21
|
+
save(): Promise<ArrayBuffer>;
|
|
22
|
+
private saveV3;
|
|
23
|
+
private saveV4;
|
|
24
|
+
saveXml(prettyPrint?: boolean): Promise<string>;
|
|
25
|
+
private decryptXmlV3;
|
|
26
|
+
private encryptXmlV3;
|
|
27
|
+
private getMasterKeyV3;
|
|
28
|
+
private trimStartBytesV3;
|
|
29
|
+
private setProtectedValues;
|
|
30
|
+
private getProtectSaltGenerator;
|
|
31
|
+
private getHeaderHash;
|
|
32
|
+
private getHeaderHmac;
|
|
33
|
+
private checkHeaderHashV3;
|
|
34
|
+
private computeKeysV4;
|
|
35
|
+
private decryptData;
|
|
36
|
+
private encryptData;
|
|
37
|
+
private getEncryptionIV;
|
|
38
|
+
private transformDataTwofish;
|
|
39
|
+
private transformDataV4Aes;
|
|
40
|
+
private transformDataV4ChaCha20;
|
|
41
|
+
private requireXml;
|
|
42
|
+
private cleanXml;
|
|
43
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { KdbxTimes } from './kdbx-times';
|
|
2
|
+
import { KdbxUuid } from './kdbx-uuid';
|
|
3
|
+
import { KdbxEntry } from './kdbx-entry';
|
|
4
|
+
import { KdbxCustomDataMap } from './kdbx-custom-data';
|
|
5
|
+
import { KdbxContext } from './kdbx-context';
|
|
6
|
+
import { MergeObjectMap } from './kdbx';
|
|
7
|
+
export declare class KdbxGroup {
|
|
8
|
+
uuid: KdbxUuid;
|
|
9
|
+
name: string | undefined;
|
|
10
|
+
notes: string | undefined;
|
|
11
|
+
icon: number | undefined;
|
|
12
|
+
customIcon: KdbxUuid | undefined;
|
|
13
|
+
tags: string[];
|
|
14
|
+
times: KdbxTimes;
|
|
15
|
+
expanded: boolean | undefined;
|
|
16
|
+
defaultAutoTypeSeq: string | undefined;
|
|
17
|
+
enableAutoType: boolean | null | undefined;
|
|
18
|
+
enableSearching: boolean | null | undefined;
|
|
19
|
+
lastTopVisibleEntry: KdbxUuid | undefined;
|
|
20
|
+
groups: KdbxGroup[];
|
|
21
|
+
entries: KdbxEntry[];
|
|
22
|
+
parentGroup: KdbxGroup | undefined;
|
|
23
|
+
previousParentGroup: KdbxUuid | undefined;
|
|
24
|
+
customData: KdbxCustomDataMap | undefined;
|
|
25
|
+
get lastModTime(): number;
|
|
26
|
+
get locationChanged(): number;
|
|
27
|
+
private readNode;
|
|
28
|
+
write(parentNode: Node, ctx: KdbxContext): void;
|
|
29
|
+
allGroups(): IterableIterator<KdbxGroup>;
|
|
30
|
+
allEntries(): IterableIterator<KdbxEntry>;
|
|
31
|
+
allGroupsAndEntries(): IterableIterator<KdbxGroup | KdbxEntry>;
|
|
32
|
+
merge(objectMap: MergeObjectMap): void;
|
|
33
|
+
/**
|
|
34
|
+
* Merge object collection with remote collection
|
|
35
|
+
* Implements 2P-set CRDT with tombstones stored in objectMap.deleted
|
|
36
|
+
* Assumes tombstones are already merged
|
|
37
|
+
*/
|
|
38
|
+
private mergeCollection;
|
|
39
|
+
/**
|
|
40
|
+
* Finds a best place to insert new item into collection
|
|
41
|
+
*/
|
|
42
|
+
private static findInsertIx;
|
|
43
|
+
/**
|
|
44
|
+
* Copies the group's own state; groups, entries and parentGroup are left to merge.
|
|
45
|
+
*/
|
|
46
|
+
copyFrom(group: KdbxGroup): void;
|
|
47
|
+
static create(name: string, parentGroup?: KdbxGroup): KdbxGroup;
|
|
48
|
+
static read(xmlNode: Node, ctx: KdbxContext, parentGroup?: KdbxGroup): KdbxGroup;
|
|
49
|
+
}
|