@keenext/kdbxweb 0.0.0-stage → 2.2.0-keenext.3
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 +57 -0
- package/LICENSE +20 -0
- package/README.md +525 -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,74 @@
|
|
|
1
|
+
import { KdbxUuid } from './kdbx-uuid';
|
|
2
|
+
import { VarDictionary } from '../utils/var-dictionary';
|
|
3
|
+
import { BinaryStream } from '../utils/binary-stream';
|
|
4
|
+
import { KdbxContext } from './kdbx-context';
|
|
5
|
+
export declare class KdbxHeader {
|
|
6
|
+
static readonly MaxFileVersion: 4;
|
|
7
|
+
versionMajor: number;
|
|
8
|
+
versionMinor: number;
|
|
9
|
+
dataCipherUuid: KdbxUuid | undefined;
|
|
10
|
+
compression: number | undefined;
|
|
11
|
+
masterSeed: ArrayBuffer | undefined;
|
|
12
|
+
transformSeed: ArrayBuffer | undefined;
|
|
13
|
+
keyEncryptionRounds: number | undefined;
|
|
14
|
+
encryptionIV: ArrayBuffer | undefined;
|
|
15
|
+
protectedStreamKey: ArrayBuffer | undefined;
|
|
16
|
+
streamStartBytes: ArrayBuffer | undefined;
|
|
17
|
+
crsAlgorithm: number | undefined;
|
|
18
|
+
endPos: number | undefined;
|
|
19
|
+
kdfParameters: VarDictionary | undefined;
|
|
20
|
+
publicCustomData: VarDictionary | undefined;
|
|
21
|
+
private readSignature;
|
|
22
|
+
private writeSignature;
|
|
23
|
+
private readVersion;
|
|
24
|
+
private writeVersion;
|
|
25
|
+
private readCipherID;
|
|
26
|
+
private writeCipherID;
|
|
27
|
+
private readCompressionFlags;
|
|
28
|
+
private writeCompressionFlags;
|
|
29
|
+
private readMasterSeed;
|
|
30
|
+
private writeMasterSeed;
|
|
31
|
+
private readTransformSeed;
|
|
32
|
+
private writeTransformSeed;
|
|
33
|
+
private readTransformRounds;
|
|
34
|
+
private writeTransformRounds;
|
|
35
|
+
private readEncryptionIV;
|
|
36
|
+
private writeEncryptionIV;
|
|
37
|
+
private readProtectedStreamKey;
|
|
38
|
+
private writeProtectedStreamKey;
|
|
39
|
+
private readStreamStartBytes;
|
|
40
|
+
private writeStreamStartBytes;
|
|
41
|
+
private readInnerRandomStreamID;
|
|
42
|
+
private writeInnerRandomStreamID;
|
|
43
|
+
private readInnerRandomStreamKey;
|
|
44
|
+
private writeInnerRandomStreamKey;
|
|
45
|
+
private readKdfParameters;
|
|
46
|
+
private writeKdfParameters;
|
|
47
|
+
private readPublicCustomData;
|
|
48
|
+
private hasPublicCustomData;
|
|
49
|
+
private writePublicCustomData;
|
|
50
|
+
private readBinary;
|
|
51
|
+
private writeBinary;
|
|
52
|
+
private writeEndOfHeader;
|
|
53
|
+
private readField;
|
|
54
|
+
private writeField;
|
|
55
|
+
private readFieldSize;
|
|
56
|
+
private writeFieldSize;
|
|
57
|
+
private writeFieldBytes;
|
|
58
|
+
private validate;
|
|
59
|
+
private validateInner;
|
|
60
|
+
private createKdfParameters;
|
|
61
|
+
write(stm: BinaryStream): void;
|
|
62
|
+
writeInnerHeader(stm: BinaryStream, ctx: KdbxContext): void;
|
|
63
|
+
generateSalts(): void;
|
|
64
|
+
setVersion(version: number): void;
|
|
65
|
+
setKdf(kdf: string): void;
|
|
66
|
+
/**
|
|
67
|
+
* KDBX 3 to 4 with the AES-KDF and its rounds kept, as KeePassXC does when a file
|
|
68
|
+
* needs KDBX 4; setVersion(4) switches to Argon2 with default parameters instead.
|
|
69
|
+
*/
|
|
70
|
+
upgradeToKdbx4KeepingAesKdf(): void;
|
|
71
|
+
static read(stm: BinaryStream, ctx: KdbxContext): KdbxHeader;
|
|
72
|
+
readInnerHeader(stm: BinaryStream, ctx: KdbxContext): void;
|
|
73
|
+
static create(): KdbxHeader;
|
|
74
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { KdbxUuid } from './kdbx-uuid';
|
|
2
|
+
import { KdbxCustomDataMap } from './kdbx-custom-data';
|
|
3
|
+
import { KdbxContext } from './kdbx-context';
|
|
4
|
+
import { MergeObjectMap } from './kdbx';
|
|
5
|
+
export interface KdbxMetaEditState {
|
|
6
|
+
mntncHistoryDaysChanged?: Date;
|
|
7
|
+
colorChanged?: Date;
|
|
8
|
+
keyChangeRecChanged?: Date;
|
|
9
|
+
keyChangeForceChanged?: Date;
|
|
10
|
+
historyMaxItemsChanged?: Date;
|
|
11
|
+
historyMaxSizeChanged?: Date;
|
|
12
|
+
lastSelectedGroupChanged?: Date;
|
|
13
|
+
lastTopVisibleGroupChanged?: Date;
|
|
14
|
+
memoryProtectionChanged?: Date;
|
|
15
|
+
}
|
|
16
|
+
export interface KdbxMemoryProtection {
|
|
17
|
+
title?: boolean;
|
|
18
|
+
userName?: boolean;
|
|
19
|
+
password?: boolean;
|
|
20
|
+
url?: boolean;
|
|
21
|
+
notes?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface KdbxCustomIcon {
|
|
24
|
+
data: ArrayBuffer;
|
|
25
|
+
name?: string;
|
|
26
|
+
lastModified?: Date;
|
|
27
|
+
}
|
|
28
|
+
export declare class KdbxMeta {
|
|
29
|
+
generator: string | undefined;
|
|
30
|
+
headerHash: ArrayBuffer | undefined;
|
|
31
|
+
settingsChanged: Date | undefined;
|
|
32
|
+
_name: string | undefined;
|
|
33
|
+
nameChanged: Date | undefined;
|
|
34
|
+
_desc: string | undefined;
|
|
35
|
+
descChanged: Date | undefined;
|
|
36
|
+
_defaultUser: string | undefined;
|
|
37
|
+
defaultUserChanged: Date | undefined;
|
|
38
|
+
_mntncHistoryDays: number | undefined;
|
|
39
|
+
_color: string | undefined;
|
|
40
|
+
keyChanged: Date | undefined;
|
|
41
|
+
_keyChangeRec: number | undefined;
|
|
42
|
+
_keyChangeForce: number | undefined;
|
|
43
|
+
_recycleBinEnabled: boolean | undefined;
|
|
44
|
+
_recycleBinUuid: KdbxUuid | undefined;
|
|
45
|
+
recycleBinChanged: Date | undefined;
|
|
46
|
+
_entryTemplatesGroup: KdbxUuid | undefined;
|
|
47
|
+
entryTemplatesGroupChanged: Date | undefined;
|
|
48
|
+
_historyMaxItems: number | undefined;
|
|
49
|
+
_historyMaxSize: number | undefined;
|
|
50
|
+
_lastSelectedGroup: KdbxUuid | undefined;
|
|
51
|
+
_lastTopVisibleGroup: KdbxUuid | undefined;
|
|
52
|
+
_memoryProtection: KdbxMemoryProtection;
|
|
53
|
+
customData: KdbxCustomDataMap;
|
|
54
|
+
customIcons: Map<string, KdbxCustomIcon>;
|
|
55
|
+
_editState: KdbxMetaEditState | undefined;
|
|
56
|
+
get editState(): KdbxMetaEditState | undefined;
|
|
57
|
+
set editState(value: KdbxMetaEditState | undefined);
|
|
58
|
+
private getOrCreateEditState;
|
|
59
|
+
get name(): string | undefined;
|
|
60
|
+
set name(value: string | undefined);
|
|
61
|
+
get desc(): string | undefined;
|
|
62
|
+
set desc(value: string | undefined);
|
|
63
|
+
get defaultUser(): string | undefined;
|
|
64
|
+
set defaultUser(value: string | undefined);
|
|
65
|
+
get mntncHistoryDays(): number | undefined;
|
|
66
|
+
set mntncHistoryDays(value: number | undefined);
|
|
67
|
+
get color(): string | undefined;
|
|
68
|
+
set color(value: string | undefined);
|
|
69
|
+
get keyChangeRec(): number | undefined;
|
|
70
|
+
set keyChangeRec(value: number | undefined);
|
|
71
|
+
get keyChangeForce(): number | undefined;
|
|
72
|
+
set keyChangeForce(value: number | undefined);
|
|
73
|
+
get recycleBinEnabled(): boolean | undefined;
|
|
74
|
+
set recycleBinEnabled(value: boolean | undefined);
|
|
75
|
+
get recycleBinUuid(): KdbxUuid | undefined;
|
|
76
|
+
set recycleBinUuid(value: KdbxUuid | undefined);
|
|
77
|
+
get entryTemplatesGroup(): KdbxUuid | undefined;
|
|
78
|
+
set entryTemplatesGroup(value: KdbxUuid | undefined);
|
|
79
|
+
get historyMaxItems(): number | undefined;
|
|
80
|
+
set historyMaxItems(value: number | undefined);
|
|
81
|
+
get historyMaxSize(): number | undefined;
|
|
82
|
+
set historyMaxSize(value: number | undefined);
|
|
83
|
+
get lastSelectedGroup(): KdbxUuid | undefined;
|
|
84
|
+
set lastSelectedGroup(value: KdbxUuid | undefined);
|
|
85
|
+
get lastTopVisibleGroup(): KdbxUuid | undefined;
|
|
86
|
+
set lastTopVisibleGroup(value: KdbxUuid | undefined);
|
|
87
|
+
get memoryProtection(): KdbxMemoryProtection;
|
|
88
|
+
set memoryProtection(value: KdbxMemoryProtection);
|
|
89
|
+
private readNode;
|
|
90
|
+
private readMemoryProtection;
|
|
91
|
+
private writeMemoryProtection;
|
|
92
|
+
private readCustomIcons;
|
|
93
|
+
private readCustomIcon;
|
|
94
|
+
private writeCustomIcons;
|
|
95
|
+
private readBinaries;
|
|
96
|
+
private readBinary;
|
|
97
|
+
private writeBinaries;
|
|
98
|
+
private readCustomData;
|
|
99
|
+
private writeCustomData;
|
|
100
|
+
write(parentNode: Node, ctx: KdbxContext): void;
|
|
101
|
+
merge(remote: KdbxMeta, objectMap: MergeObjectMap): void;
|
|
102
|
+
private mergeMapWithDates;
|
|
103
|
+
needUpdate(remoteDate: Date | undefined, localDate: Date | undefined): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Creates new meta
|
|
106
|
+
* @returns {KdbxMeta}
|
|
107
|
+
*/
|
|
108
|
+
static create(): KdbxMeta;
|
|
109
|
+
static read(xmlNode: Node, ctx: KdbxContext): KdbxMeta;
|
|
110
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { KdbxContext } from './kdbx-context';
|
|
2
|
+
export declare class KdbxTimes {
|
|
3
|
+
creationTime: Date | undefined;
|
|
4
|
+
lastModTime: Date | undefined;
|
|
5
|
+
lastAccessTime: Date | undefined;
|
|
6
|
+
expiryTime: Date | undefined;
|
|
7
|
+
expires: boolean | null | undefined;
|
|
8
|
+
usageCount: number | undefined;
|
|
9
|
+
locationChanged: Date | undefined;
|
|
10
|
+
private readNode;
|
|
11
|
+
clone(): KdbxTimes;
|
|
12
|
+
update(): void;
|
|
13
|
+
write(parentNode: Element, ctx: KdbxContext): void;
|
|
14
|
+
static create(): KdbxTimes;
|
|
15
|
+
static read(xmlNode: Node): KdbxTimes;
|
|
16
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class KdbxUuid {
|
|
2
|
+
readonly id: string;
|
|
3
|
+
readonly empty: boolean;
|
|
4
|
+
constructor(ab?: ArrayBuffer | Uint8Array | string);
|
|
5
|
+
equals(other: KdbxUuid | string | null | undefined): boolean;
|
|
6
|
+
get bytes(): ArrayBuffer;
|
|
7
|
+
static random(): KdbxUuid;
|
|
8
|
+
toString(): string;
|
|
9
|
+
valueOf(): string;
|
|
10
|
+
toBytes(): ArrayBuffer;
|
|
11
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { KdbxBinaries, KdbxBinary, KdbxBinaryWithHash } from './kdbx-binaries';
|
|
2
|
+
import { KdbxDeletedObject } from './kdbx-deleted-object';
|
|
3
|
+
import { KdbxGroup } from './kdbx-group';
|
|
4
|
+
import { KdbxMeta, KdbxMetaEditState } from './kdbx-meta';
|
|
5
|
+
import { KdbxCredentials } from './kdbx-credentials';
|
|
6
|
+
import { KdbxHeader } from './kdbx-header';
|
|
7
|
+
import { KdbxEntry, KdbxEntryEditState } from './kdbx-entry';
|
|
8
|
+
import { KdbxUuid } from './kdbx-uuid';
|
|
9
|
+
import { KdbxContext } from './kdbx-context';
|
|
10
|
+
export interface KdbxEditState {
|
|
11
|
+
entries?: {
|
|
12
|
+
[name: string]: KdbxEntryEditState;
|
|
13
|
+
};
|
|
14
|
+
meta?: KdbxMetaEditState;
|
|
15
|
+
}
|
|
16
|
+
export interface MergeObjectMap {
|
|
17
|
+
entries: Map<string, KdbxEntry>;
|
|
18
|
+
groups: Map<string, KdbxGroup>;
|
|
19
|
+
remoteEntries: Map<string, KdbxEntry>;
|
|
20
|
+
remoteGroups: Map<string, KdbxGroup>;
|
|
21
|
+
deleted: Map<string, Date>;
|
|
22
|
+
}
|
|
23
|
+
export declare class Kdbx {
|
|
24
|
+
header: KdbxHeader;
|
|
25
|
+
credentials: KdbxCredentials;
|
|
26
|
+
meta: KdbxMeta;
|
|
27
|
+
xml: Document | undefined;
|
|
28
|
+
binaries: KdbxBinaries;
|
|
29
|
+
groups: KdbxGroup[];
|
|
30
|
+
deletedObjects: KdbxDeletedObject[];
|
|
31
|
+
get versionMajor(): number;
|
|
32
|
+
get versionMinor(): number;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a new database
|
|
35
|
+
*/
|
|
36
|
+
static create(credentials: KdbxCredentials, name: string): Kdbx;
|
|
37
|
+
/**
|
|
38
|
+
* Load a kdbx file
|
|
39
|
+
* If there was an error loading file, throws an exception
|
|
40
|
+
* @param options.signal - aborting it stops the key derivation and rejects with its reason
|
|
41
|
+
*/
|
|
42
|
+
static load(data: ArrayBuffer, credentials: KdbxCredentials, options?: {
|
|
43
|
+
preserveXml?: boolean;
|
|
44
|
+
signal?: AbortSignal;
|
|
45
|
+
}): Promise<Kdbx>;
|
|
46
|
+
/**
|
|
47
|
+
* Import database from an xml file
|
|
48
|
+
* If there was an error loading file, throws an exception
|
|
49
|
+
*/
|
|
50
|
+
static loadXml(data: string, credentials: KdbxCredentials): Promise<Kdbx>;
|
|
51
|
+
/**
|
|
52
|
+
* Save the db to ArrayBuffer
|
|
53
|
+
*/
|
|
54
|
+
save(): Promise<ArrayBuffer>;
|
|
55
|
+
/**
|
|
56
|
+
* Save the db as XML string
|
|
57
|
+
*/
|
|
58
|
+
saveXml(prettyPrint?: boolean): Promise<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Creates a default group, if it's not yet created
|
|
61
|
+
*/
|
|
62
|
+
createDefaultGroup(): void;
|
|
63
|
+
/**
|
|
64
|
+
* Creates a recycle bin group, if it's not yet created
|
|
65
|
+
*/
|
|
66
|
+
createRecycleBin(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Adds a new group to an existing group
|
|
69
|
+
*/
|
|
70
|
+
createGroup(group: KdbxGroup, name: string): KdbxGroup;
|
|
71
|
+
/**
|
|
72
|
+
* Adds a new entry to a group
|
|
73
|
+
*/
|
|
74
|
+
createEntry(group: KdbxGroup): KdbxEntry;
|
|
75
|
+
/**
|
|
76
|
+
* Gets the default group
|
|
77
|
+
*/
|
|
78
|
+
getDefaultGroup(): KdbxGroup;
|
|
79
|
+
/**
|
|
80
|
+
* Get a group by uuid, returns undefined if it's not found
|
|
81
|
+
*/
|
|
82
|
+
getGroup(uuid: KdbxUuid | string, parentGroup?: KdbxGroup): KdbxGroup | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Move an object from one group to another
|
|
85
|
+
* @param object - object to be moved
|
|
86
|
+
* @param toGroup - target parent group
|
|
87
|
+
* @param atIndex - index in target group (by default, insert to the end of the group)
|
|
88
|
+
*/
|
|
89
|
+
move<T extends KdbxEntry | KdbxGroup>(object: T, toGroup: KdbxGroup | undefined | null, atIndex?: number): void;
|
|
90
|
+
/**
|
|
91
|
+
* Adds a so-called deleted object, this is used to keep track of objects during merging
|
|
92
|
+
* @param uuid - object uuid
|
|
93
|
+
* @param dt - deletion date
|
|
94
|
+
*/
|
|
95
|
+
addDeletedObject(uuid: KdbxUuid, dt: Date): void;
|
|
96
|
+
/**
|
|
97
|
+
* Delete an entry or a group
|
|
98
|
+
* Depending on settings, removes either to trash, or completely
|
|
99
|
+
*/
|
|
100
|
+
remove<T extends KdbxEntry | KdbxGroup>(object: T): void;
|
|
101
|
+
/**
|
|
102
|
+
* Creates a binary in the db and returns an object that can be put to entry.binaries
|
|
103
|
+
*/
|
|
104
|
+
createBinary(value: KdbxBinary): Promise<KdbxBinaryWithHash>;
|
|
105
|
+
/**
|
|
106
|
+
* Import an entry from another file
|
|
107
|
+
* It's up to caller to decide what should happen to the original entry in the source file
|
|
108
|
+
* Returns the new entry
|
|
109
|
+
* @param entry - entry to be imported
|
|
110
|
+
* @param group - target parent group
|
|
111
|
+
* @param file - the source file containing the group
|
|
112
|
+
*/
|
|
113
|
+
importEntry(entry: KdbxEntry, group: KdbxGroup, file: Kdbx): KdbxEntry;
|
|
114
|
+
/**
|
|
115
|
+
* Perform database cleanup
|
|
116
|
+
* @param settings.historyRules - remove extra history, it it doesn't match defined rules, e.g. records number
|
|
117
|
+
* @param settings.customIcons - remove unused custom icons
|
|
118
|
+
* @param settings.binaries - remove unused binaries
|
|
119
|
+
*/
|
|
120
|
+
cleanup(settings?: {
|
|
121
|
+
historyRules?: boolean;
|
|
122
|
+
customIcons?: boolean;
|
|
123
|
+
binaries?: boolean;
|
|
124
|
+
}): void;
|
|
125
|
+
/**
|
|
126
|
+
* Merge the db with another db
|
|
127
|
+
* Some parts of the remote DB are copied by reference, so it should NOT be modified after merge
|
|
128
|
+
* Suggested use case:
|
|
129
|
+
* - open the local db
|
|
130
|
+
* - get a remote db somehow and open in
|
|
131
|
+
* - merge the remote db into the local db: local.merge(remote)
|
|
132
|
+
* - close the remote db
|
|
133
|
+
* @param remote - database to merge in
|
|
134
|
+
*/
|
|
135
|
+
merge(remote: Kdbx): void;
|
|
136
|
+
/**
|
|
137
|
+
* Gets editing state tombstones (for successful merge)
|
|
138
|
+
* The replica must save this state with the db, assign in on opening the db,
|
|
139
|
+
* and call removeLocalEditState on successful upstream push.
|
|
140
|
+
* This state is JSON serializable.
|
|
141
|
+
*/
|
|
142
|
+
getLocalEditState(): KdbxEditState;
|
|
143
|
+
/**
|
|
144
|
+
* Sets editing state tombstones returned previously by getLocalEditState
|
|
145
|
+
* The replica must call this method on opening the db to the state returned previously on getLocalEditState.
|
|
146
|
+
* @param editingState - result of getLocalEditState invoked before on saving the db
|
|
147
|
+
*/
|
|
148
|
+
setLocalEditState(editingState: KdbxEditState): void;
|
|
149
|
+
/**
|
|
150
|
+
* Removes editing state tombstones
|
|
151
|
+
* Immediately after successful upstream push the replica must:
|
|
152
|
+
* - call this method
|
|
153
|
+
* - discard any previous state obtained by getLocalEditState call before
|
|
154
|
+
*/
|
|
155
|
+
removeLocalEditState(): void;
|
|
156
|
+
/**
|
|
157
|
+
* Upgrade the file to latest version
|
|
158
|
+
*/
|
|
159
|
+
upgrade(): void;
|
|
160
|
+
/**
|
|
161
|
+
* Set the file version to a specified number
|
|
162
|
+
*/
|
|
163
|
+
setVersion(version: 3 | 4): void;
|
|
164
|
+
/**
|
|
165
|
+
* Set file key derivation function
|
|
166
|
+
* @param kdf - KDF id, from KdfId
|
|
167
|
+
*/
|
|
168
|
+
setKdf(kdf: string): void;
|
|
169
|
+
private getObjectMap;
|
|
170
|
+
loadFromXml(ctx: KdbxContext): Promise<Kdbx>;
|
|
171
|
+
private parseMeta;
|
|
172
|
+
private parseRoot;
|
|
173
|
+
private readDeletedObjects;
|
|
174
|
+
private readGroup;
|
|
175
|
+
buildXml(ctx: KdbxContext): void;
|
|
176
|
+
/**
|
|
177
|
+
* Whether the database holds values the writers store only in KDBX 4.1 files (each
|
|
178
|
+
* `versionIsAtLeast(4, 1)` check); a quality check of true is the default and does not
|
|
179
|
+
* count. KeePassXC raises files to 4.1 for the same values. With `ignoreMoves`, a
|
|
180
|
+
* previous parent group (set by every move) does not count.
|
|
181
|
+
*/
|
|
182
|
+
hasKdbx41Values(ignoreMoves?: boolean): boolean;
|
|
183
|
+
versionIsAtLeast(major: number, minor: number): boolean;
|
|
184
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ChaCha20 } from './crypto/chacha20';
|
|
2
|
+
import * as CryptoEngine from './crypto/crypto-engine';
|
|
3
|
+
import * as HashedBlockTransform from './crypto/hashed-block-transform';
|
|
4
|
+
import * as HmacBlockTransform from './crypto/hmac-block-transform';
|
|
5
|
+
import * as KeyEncryptorAes from './crypto/key-encryptor-aes';
|
|
6
|
+
import * as KeyEncryptorKdf from './crypto/key-encryptor-kdf';
|
|
7
|
+
import { ProtectSaltGenerator } from './crypto/protect-salt-generator';
|
|
8
|
+
import { ProtectedValue } from './crypto/protected-value';
|
|
9
|
+
import { Salsa20 } from './crypto/salsa20';
|
|
10
|
+
import * as Consts from './defs/consts';
|
|
11
|
+
import * as XmlNames from './defs/xml-names';
|
|
12
|
+
import { KdbxError } from './errors/kdbx-error';
|
|
13
|
+
import { Kdbx, KdbxEditState } from './format/kdbx';
|
|
14
|
+
import { KdbxBinaries, KdbxBinary, KdbxBinaryIn, KdbxBinaryOrRef, KdbxBinaryRef, KdbxBinaryRefWithValue, KdbxBinaryWithHash } from './format/kdbx-binaries';
|
|
15
|
+
import { KdbxContext } from './format/kdbx-context';
|
|
16
|
+
import { KdbxChallengeResponseFn, KdbxCredentials } from './format/kdbx-credentials';
|
|
17
|
+
import { KdbxCustomData, KdbxCustomDataMap, KdbxCustomDataItem } from './format/kdbx-custom-data';
|
|
18
|
+
import { KdbxDeletedObject } from './format/kdbx-deleted-object';
|
|
19
|
+
import { KdbxAutoTypeItem, KdbxEntry, KdbxEntryAutoType, KdbxEntryEditState, KdbxEntryField } from './format/kdbx-entry';
|
|
20
|
+
import { KdbxFormat } from './format/kdbx-format';
|
|
21
|
+
import { KdbxGroup } from './format/kdbx-group';
|
|
22
|
+
import { KdbxHeader } from './format/kdbx-header';
|
|
23
|
+
import { KdbxMemoryProtection, KdbxMeta, KdbxMetaEditState, KdbxCustomIcon } from './format/kdbx-meta';
|
|
24
|
+
import { KdbxTimes } from './format/kdbx-times';
|
|
25
|
+
import { KdbxUuid } from './format/kdbx-uuid';
|
|
26
|
+
import { BinaryStream } from './utils/binary-stream';
|
|
27
|
+
import * as ByteUtils from './utils/byte-utils';
|
|
28
|
+
import { Int64 } from './utils/int64';
|
|
29
|
+
import { VarDictionary } from './utils/var-dictionary';
|
|
30
|
+
import * as XmlUtils from './utils/xml-utils';
|
|
31
|
+
export { ChaCha20, CryptoEngine, HashedBlockTransform, HmacBlockTransform, KeyEncryptorAes, KeyEncryptorKdf, ProtectSaltGenerator, ProtectedValue, Salsa20, Consts, XmlNames, KdbxError, Kdbx, KdbxBinaries, KdbxContext, KdbxCredentials, KdbxCredentials as Credentials, KdbxCustomData, KdbxDeletedObject, KdbxEntry, KdbxFormat, KdbxGroup, KdbxHeader, KdbxMeta, KdbxTimes, KdbxUuid, BinaryStream, ByteUtils, Int64, VarDictionary, XmlUtils };
|
|
32
|
+
export type { KdbxEditState, KdbxBinaryRef, KdbxBinaryRefWithValue, KdbxBinaryWithHash, KdbxBinary, KdbxBinaryOrRef, KdbxBinaryIn, KdbxChallengeResponseFn, KdbxCustomDataMap, KdbxCustomDataItem, KdbxEntryEditState, KdbxEntryField, KdbxAutoTypeItem, KdbxEntryAutoType, KdbxMetaEditState, KdbxCustomIcon, KdbxMemoryProtection };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads past the end throw FileCorrupt, so parsers of untrusted data get exactly
|
|
3
|
+
* the number of bytes a length field announces or an error.
|
|
4
|
+
*/
|
|
5
|
+
export declare class BinaryStream {
|
|
6
|
+
private _arrayBuffer;
|
|
7
|
+
private _dataView;
|
|
8
|
+
private _pos;
|
|
9
|
+
private readonly _canExpand;
|
|
10
|
+
constructor(arrayBuffer?: ArrayBuffer);
|
|
11
|
+
get pos(): number;
|
|
12
|
+
get byteLength(): number;
|
|
13
|
+
private checkAvailable;
|
|
14
|
+
readBytes(size: number): ArrayBuffer;
|
|
15
|
+
readBytesToEnd(): ArrayBuffer;
|
|
16
|
+
readBytesNoAdvance(startPos: number, endPos: number): ArrayBuffer;
|
|
17
|
+
writeBytes(bytes: ArrayBuffer | Uint8Array): void;
|
|
18
|
+
getWrittenBytes(): ArrayBuffer;
|
|
19
|
+
private checkCapacity;
|
|
20
|
+
getInt8(): number;
|
|
21
|
+
setInt8(value: number): void;
|
|
22
|
+
getUint8(): number;
|
|
23
|
+
setUint8(value: number): void;
|
|
24
|
+
getInt16(littleEndian: boolean): number;
|
|
25
|
+
setInt16(value: number, littleEndian: boolean): void;
|
|
26
|
+
getUint16(littleEndian: boolean): number;
|
|
27
|
+
setUint16(value: number, littleEndian: boolean): void;
|
|
28
|
+
getInt32(littleEndian: boolean): number;
|
|
29
|
+
setInt32(value: number, littleEndian: boolean): void;
|
|
30
|
+
getUint32(littleEndian: boolean): number;
|
|
31
|
+
setUint32(value: number, littleEndian: boolean): void;
|
|
32
|
+
getFloat32(littleEndian: boolean): number;
|
|
33
|
+
setFloat32(value: number, littleEndian: boolean): void;
|
|
34
|
+
getFloat64(littleEndian: boolean): number;
|
|
35
|
+
setFloat64(value: number, littleEndian: boolean): void;
|
|
36
|
+
getUint64(littleEndian: boolean): number;
|
|
37
|
+
setUint64(value: number, littleEndian: boolean): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type ArrayBufferOrArray = ArrayBuffer | Uint8Array;
|
|
2
|
+
export declare function arrayBufferEquals(ab1: ArrayBuffer, ab2: ArrayBuffer): boolean;
|
|
3
|
+
export declare function bytesToString(arr: ArrayBufferOrArray): string;
|
|
4
|
+
export declare function stringToBytes(str: string): Uint8Array;
|
|
5
|
+
export declare function base64ToBytes(str: string): Uint8Array;
|
|
6
|
+
export declare function bytesToBase64(arr: ArrayBufferOrArray): string;
|
|
7
|
+
export declare function hexToBytes(hex: string): Uint8Array;
|
|
8
|
+
export declare function bytesToHex(arr: ArrayBufferOrArray): string;
|
|
9
|
+
export declare function arrayToBuffer(arr: ArrayBufferOrArray): ArrayBuffer;
|
|
10
|
+
export declare function zeroBuffer(arr: ArrayBufferOrArray): void;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Int64 } from './int64';
|
|
2
|
+
import { BinaryStream } from './binary-stream';
|
|
3
|
+
export declare enum ValueType {
|
|
4
|
+
UInt32 = 4,
|
|
5
|
+
UInt64 = 5,
|
|
6
|
+
Bool = 8,
|
|
7
|
+
Int32 = 12,
|
|
8
|
+
Int64 = 13,
|
|
9
|
+
String = 24,
|
|
10
|
+
Bytes = 66
|
|
11
|
+
}
|
|
12
|
+
export type VarDictionaryAnyValue = number | Int64 | boolean | string | ArrayBuffer | undefined;
|
|
13
|
+
export declare class VarDictionary {
|
|
14
|
+
private _items;
|
|
15
|
+
private readonly _map;
|
|
16
|
+
static readonly ValueType: typeof ValueType;
|
|
17
|
+
keys(): string[];
|
|
18
|
+
get length(): number;
|
|
19
|
+
get(key: string): VarDictionaryAnyValue;
|
|
20
|
+
set(key: string, type: ValueType, value: VarDictionaryAnyValue): void;
|
|
21
|
+
remove(key: string): void;
|
|
22
|
+
static read(stm: BinaryStream): VarDictionary;
|
|
23
|
+
private readVersion;
|
|
24
|
+
private readItem;
|
|
25
|
+
write(stm: BinaryStream): void;
|
|
26
|
+
private writeVersion;
|
|
27
|
+
private writeItem;
|
|
28
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { KdbxUuid } from '../format/kdbx-uuid';
|
|
2
|
+
import { ProtectedValue } from '../crypto/protected-value';
|
|
3
|
+
import { ProtectSaltGenerator } from '../crypto/protect-salt-generator';
|
|
4
|
+
import { KdbxBinaryOrRef } from '../format/kdbx-binaries';
|
|
5
|
+
export declare function getNodeProtectedValue(node: Node): ProtectedValue | undefined;
|
|
6
|
+
export declare function setNodeProtectedValue(node: Node, value: ProtectedValue | undefined): void;
|
|
7
|
+
export declare function parse(xml: string): Document;
|
|
8
|
+
export declare function serialize(doc: Document, prettyPrint?: boolean): string;
|
|
9
|
+
export declare function create(rootNode: string): Document;
|
|
10
|
+
export declare function getChildNode(node: Node | null, tagName: string): Node | null;
|
|
11
|
+
export declare function getChildNode(node: Node | null, tagName: string, errorMsgIfAbsent: string): Node;
|
|
12
|
+
export declare function addChildNode(node: Node, tagName: string): Element;
|
|
13
|
+
export declare function getText(node: Node | null): string | undefined;
|
|
14
|
+
export declare function setText(node: Node, text: string | undefined): void;
|
|
15
|
+
export declare function getTags(node: Node): string[];
|
|
16
|
+
export declare function setTags(node: Node, tags: string[]): void;
|
|
17
|
+
export declare function getBytes(node: Node): ArrayBuffer | undefined;
|
|
18
|
+
export declare function setBytes(node: Node, bytes: ArrayBuffer | Uint8Array | string | undefined): void;
|
|
19
|
+
/**
|
|
20
|
+
* Binary dates after 9999-12-31 (KeePassDX writes some far beyond) are clamped to it,
|
|
21
|
+
* so they keep comparing as latest and can be written back.
|
|
22
|
+
* Text dates that do not parse, and binary values shorter than 8 bytes, read as absent.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getDate(node: Node): Date | undefined;
|
|
25
|
+
export declare function setDate(node: Node, date: Date | undefined, binary?: boolean): void;
|
|
26
|
+
export declare function getNumber(node: Node): number | undefined;
|
|
27
|
+
export declare function setNumber(node: Node, number: number | undefined): void;
|
|
28
|
+
export declare function getBoolean(node: Node): boolean | null | undefined;
|
|
29
|
+
export declare function setBoolean(node: Node, boolean: boolean | null | undefined): void;
|
|
30
|
+
export declare function strToBoolean(str: string | null | undefined): boolean | null | undefined;
|
|
31
|
+
export declare function getUuid(node: Node): KdbxUuid | undefined;
|
|
32
|
+
export declare function setUuid(node: Node, uuid: KdbxUuid | ArrayBuffer | Uint8Array | string | undefined): void;
|
|
33
|
+
export declare function getProtectedText(node: Node): ProtectedValue | string | undefined;
|
|
34
|
+
export declare function setProtectedText(node: Node, text: ProtectedValue | string): void;
|
|
35
|
+
export declare function getProtectedBinary(node: Node): KdbxBinaryOrRef | undefined;
|
|
36
|
+
export declare function setProtectedBinary(node: Node, binary: KdbxBinaryOrRef): void;
|
|
37
|
+
export declare function traverse(node: Node, callback: (node: Element) => void): void;
|
|
38
|
+
export declare function setProtectedValues(node: Node, protectSaltGenerator: ProtectSaltGenerator): void;
|
|
39
|
+
export declare function updateProtectedValuesSalt(node: Node, protectSaltGenerator: ProtectSaltGenerator): void;
|
|
40
|
+
export declare function unprotectValues(node: Node): void;
|
|
41
|
+
export declare function protectUnprotectedValues(node: Node): void;
|
|
42
|
+
export declare function protectPlainValues(node: Node): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keenext/kdbxweb",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "2.2.0-keenext.3",
|
|
4
|
+
"description": "Fork of keeweb/kdbxweb maintained for KeeNext, see FORK.md",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/keenext/kdbxweb.git"
|
|
9
|
+
},
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/keenext/kdbxweb/issues"
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "dist/index.js",
|
|
18
|
+
"types": "dist/types/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/types/index.d.ts",
|
|
22
|
+
"default": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"LICENSE",
|
|
28
|
+
"FORK.md"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "esbuild lib/index.ts --bundle --format=esm --platform=neutral --target=es2022 --external:fflate --sourcemap --outfile=dist/index.js && tsc -p tsconfig.json",
|
|
32
|
+
"test": "vitest run",
|
|
33
|
+
"prepublishOnly": "npm run build && npm test"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"fflate": "^0.8.3"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/expect.js": "^0.3.32",
|
|
40
|
+
"@types/node": "^24.19.1",
|
|
41
|
+
"@xmldom/xmldom": "^0.9.12",
|
|
42
|
+
"esbuild": "^0.28.2",
|
|
43
|
+
"expect.js": "^0.3.1",
|
|
44
|
+
"hash-wasm": "^4.12.0",
|
|
45
|
+
"typescript": "~5.9.3",
|
|
46
|
+
"vitest": "^4.1.11"
|
|
47
|
+
}
|
|
48
|
+
}
|