Repository navigation
Expand file tree
/
Copy pathkprpc.ts
More file actions
656 lines (555 loc) · 26.3 KB
/
Copy pathkprpc.ts
File metadata and controls
656 lines (555 loc) · 26.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
import JRPC from "jrpc";
import ModelMasher from "./model";
import kdbxweb, { Kdbx, KdbxEntry, KdbxGroup, ProtectedValue } from "kdbxweb";
import {KdbxPlaceholders} from "kdbx-placeholders";
import { KeeEntry, MatchAccuracyEnum } from "./kfDataModel";
let remote;
let pinger;
let stopReceiving;
let stopWaitingForStartup;
let requestedInstanceCount = 0;
/*
Create a new instance of this class, passing through an implementation object
that contains implementations for each KPRPC function.
This allows different applications to utilise this same framework without us
making any assumptions about how one can implement each feature. An initial
implementation is created for Kee Vault.
*/
type FileModel = {
db: Kdbx,
getEntry: (a: any) => any,
subId: (a: any) => any,
reload: () => void,
id: string,
setModified: () => void
};
let getEntry: Function;
let ping: Function;
let getDomain: Function;
let editEntry: Function;
let getFiles: Function;
let getFileInfos: Function;
let messageToKeeAddonProxy: Function;
let generatePassword: Function;
let getPasswordProfiles: Function;
let openOrUnlockOrFocusFile: Function;
let addEntry: Function;
let syncFile: (file: FileModel, opts: any) => void;
let getSetting: (name: string) => string;
let onKeeAddonEnabled: Function;
let onKeeAddonActivated: Function;
let modelMasher: ModelMasher;
let readAddonSettings: Function;
let updateAddonSettings: (settings: object, version: number) => void;
let delayUntilIntegrationReady: () => Promise<void>;
let launchBuiltInPasswordGenerator: () => void;
const impl = {
openEntryForEditing: function (uuid, dbFileId) {
logger.debug("Opening entry for editing. UUID: " + uuid + " in DB: " + dbFileId);
const items = getEntry(uuid, dbFileId);
if (items.length === 1) {
const item = items[0];
editEntry(item);
} else if (items.length > 1) {
logger.warn("Duplicate entry UUIDs found in open databases. KPRPC cannot proceed.");
} else {
logger.warn("Entry UUID not found.");
}
},
getCurrentKFConfig: function () {
return { knownDatabases: getFileInfos().first(16).map(fi => ({id: fi.id, name: fi.get("name")})) };
},
changeDatabase: function (dbFileId, closeCurrent) {
openOrUnlockOrFocusFile(dbFileId);
},
changeLocation: function (locationId) {
throw new Error("Not implemented yet. This feature may be removed.");
},
addLogin: function (login, parentUUID, dbFileId) {
logger.debug("adding login");
const files: any[] = [];
if (!dbFileId) {
// find the database
getFiles().forEach(file => {
if (file.open && modelMasher.isConfigCorrectVersion(file.db)) files.push(file);
});
} else {
const file = getFiles()._byId[dbFileId];
if (file.open && modelMasher.isConfigCorrectVersion(file.db)) files.push(file);
}
// Make sure there is a single (or specified) open database
if (!files || files.length !== 1) { return null; }
const chosenFile = files[0];
let parentGroup;
if (parentUUID && parentUUID.length > 0) {
const matchedGroup = chosenFile.getGroup(chosenFile.subId(parentUUID));
if (matchedGroup != null) { parentGroup = matchedGroup; }
}
if (!parentGroup) { parentGroup = modelMasher.getRootPwGroup(chosenFile.db); }
const newLogin = addEntry(parentGroup, chosenFile, login, modelMasher.fromKeeEntry.bind(modelMasher));
const newEntry = modelMasher.toKeeEntry(chosenFile.db,
newLogin,
{fileName: chosenFile.id, active: true},
{fullDetail: true, matchAccuracy: MatchAccuracyEnum.Best});
return newEntry;
},
updateLogin: function (login: KeeEntry, oldLoginUUID, urlMergeMode: number, dbFileId, save: boolean) {
logger.debug("updating login");
const files: FileModel[] = [];
if (!login) { throw new Error("(new) login was not passed to the updateLogin function"); }
if (!oldLoginUUID) { throw new Error("oldLoginUUID was not passed to the updateLogin function"); }
if (!dbFileId) { throw new Error("dbFileName was not passed to the updateLogin function"); }
const file = getFiles()._byId[dbFileId];
// file = app file model
// file.db = Kdbx
if (file.open && modelMasher.isConfigCorrectVersion(file.db)) files.push(file);
// Make sure there is a single (or specified) open database
if (!files || files.length !== 1) { return null; }
const chosenFile = files[0];
let tempEntry = chosenFile.db.createEntry(chosenFile.db.getDefaultGroup());
tempEntry = modelMasher.fromKeeEntry(chosenFile.db, login, tempEntry, getDomain);
const existingLogin = chosenFile.getEntry(chosenFile.subId(oldLoginUUID));
mergeEntries(existingLogin.entry, tempEntry, urlMergeMode, chosenFile.db);
existingLogin.setEntry(existingLogin.entry, existingLogin.group, chosenFile);
// Remove the temporary entry
chosenFile.db.move(tempEntry, null);
chosenFile.setModified();
chosenFile.reload();
if (save) syncFile(chosenFile, { skipValidation: true, startedByUser: false });
const newEntry = modelMasher.toKeeEntry(chosenFile.db,
existingLogin.entry,
{fileName: chosenFile.id, active: true},
{fullDetail: true, matchAccuracy: MatchAccuracyEnum.Best});
return newEntry;
},
getAllDatabases: function (fullDetail: boolean) {
const dbs = getFiles().map(val => {
// More than one DB can be active at once.
const db = modelMasher.toKeeDatabase(val.db, {fileName: val.id, active: true}, { fullDetail });
return db;
});
const config = readAddonSettings();
return {
dbs,
config
};
},
findLogins: function (unsanitisedURLs: string[], actionURL, httpRealm, lst, requireFullURLMatches, uniqueID, dbFileId, freeTextSearch, unusedUsername) {
logger.debug("Finding logins");
const files: any[] = [];
const allEntries: any[] = [];
if (!dbFileId) {
// find the database
getFiles().forEach(file => {
if (file.open && modelMasher.isConfigCorrectVersion(file.db)) files.push(file);
});
} else {
const file = getFiles()._byId[dbFileId];
if (file.open && modelMasher.isConfigCorrectVersion(file.db)) files.push(file);
}
// Make sure there is an open database
if (!files || files.length === 0) { return null; }
// if uniqueID is supplied, match just that one login. if not found, move on to search the content of the logins...
if (uniqueID != null && uniqueID.length > 0) {
files.forEach(file => {
const e = file.getEntry(file.subId(uniqueID));
//const dbModel = model.toKee.database(file.db, false, true);
if (e) {
const entry = modelMasher.toKeeEntry(file.db,
e.entry,
{fileName: file.id, active: true},
{fullDetail: true, matchAccuracy: MatchAccuracyEnum.Best}
) as KeeEntry;
allEntries.push(entry);
}
});
}
if (allEntries.length > 0) { return allEntries; }
if (freeTextSearch) {
files.forEach(file => {
file.forEachEntry({textLower: freeTextSearch}, e => {
const entry = modelMasher.toKeeEntry(file.db,
e.entry,
{fileName: file.id, active: true},
{fullDetail: true, matchAccuracy: MatchAccuracyEnum.None});
allEntries.push(entry);
});
});
}
// else we search for the URLs
// First, we remove any data URIs from the list - there aren't any practical use cases
// for this which can trump the security risks introduced by attempting to support their use.
const URLs: string[] = unsanitisedURLs.filter(u => u.indexOf("data:") !== 0);
if (allEntries.length === 0 && URLs.length > 0 && URLs[0]) {
const URLHostnameAndPorts: any[] = [];
// make sure that hostname and actionURL always represent only the hostname portion
// of the URL
// It's tempting to demand that the protocol must match too (e.g. http forms won't
// match a stored https login) but best not to define such a restriction in KeePassRPC
// - the RPC client (e.g. KeeFox) can decide to penalise protocol mismatches,
// potentially dependant on user configuration options in the client.
for (let i = 0; i < URLs.length; i++) {
URLHostnameAndPorts[URLs[i]] = modelMasher.getURLSummary(URLs[i], getDomain);
}
// foreach DB...
files.forEach(file => {
const dbConfig = modelMasher.getDatabaseKPRPCConfig(file.db);
const homeGroup = modelMasher.getRootPwGroup(file.db);
let totalAll = 0;
let totalEntries = 0;
for (const it of homeGroup.allGroupsAndEntriesFiltered( (groupOrEntry) => {
// halt iteration down into this group if it's in the recycle bin
if (groupOrEntry instanceof KdbxGroup && groupOrEntry.uuid.equals(file.db.meta.recycleBinUuid)) return false;
return true;
})) {
totalAll++;
// not interested in groups
if (it instanceof KdbxGroup) continue;
totalEntries++;
const conf = ModelMasher.getEntryConfig(it, dbConfig);
if (conf == null || conf.hide) { continue; }
let entryIsAMatch = false;
let bestMatchAccuracy = 0;
if (conf.regExURLs) {
URLs.forEach(URL => {
for (let i = 0; i < conf.regExURLs!.length; i++) {
const regexPattern = conf.regExURLs![i];
try {
if (regexPattern && new RegExp(regexPattern).test(URL)) {
entryIsAMatch = true;
bestMatchAccuracy = 50;
break;
}
} catch (ex) {
logger.warn("'" + regexPattern + "' is not a valid regular expression. This error was found in an entry in your database called '" +
it.fields.get("Title") + "'. You need to fix or delete this regular expression to prevent this warning message appearing.");
break;
}
}
});
}
// Check for matching URLs for the page or HTTPAuth
if (!entryIsAMatch) {
URLs.forEach(URL => {
const mam = modelMasher.getMatchAccuracyMethod(it, URLHostnameAndPorts[URL], dbConfig);
const accuracy = modelMasher.bestMatchAccuracyForAnyURL(it, conf, URL, URLHostnameAndPorts[URL], mam, file.db);
if (accuracy > bestMatchAccuracy) { bestMatchAccuracy = accuracy; }
});
}
if (bestMatchAccuracy === 50 ||
(!requireFullURLMatches && bestMatchAccuracy > 0)) {
entryIsAMatch = true;
}
// If we think we found a match, check it's not on a block list
if (entryIsAMatch) {
for (let i = 0; i < URLs.length; i++) {
const URL = URLs[i];
if (modelMasher.matchesAnyBlockedURL(conf, URL)) {
entryIsAMatch = false;
break;
}
if (conf.regExBlockedURLs) {
for (let j = 0; j < conf.regExBlockedURLs.length; j++) {
const pattern = conf.regExBlockedURLs[j];
try {
if (pattern && new RegExp(pattern).test(URL)) {
entryIsAMatch = false;
break;
}
} catch (ex) {
logger.warn("'" + pattern + "' is not a valid regular expression. This error was found in an entry in your database called '" +
it.fields.get("Title") + "'. You need to fix or delete this regular expression to prevent this warning message appearing.");
break;
}
}
}
}
}
if (entryIsAMatch) {
allEntries.push(modelMasher.toKeeEntry(file.db,
it,
{fileName: file.id, active: true},
{fullDetail: true, matchAccuracy: bestMatchAccuracy}));
}
}
logger.debug('total entries: ' + totalEntries + '. total all: ' + totalAll);
});
allEntries.sort((a, b) => {
const titleA = a.title ? a.title.toUpperCase() : "";
const titleB = b.title ? b.title.toUpperCase() : "";
if (titleA < titleB) return -1;
if (titleA > titleB) return 1;
return 0;
});
}
return allEntries;
}
};
const mergeEntries = function (destination: KdbxEntry, source: KdbxEntry, urlMergeMode: number, db: Kdbx) {
const dbConfig = modelMasher.getDatabaseKPRPCConfig(db);
const destConfig = ModelMasher.getEntryConfig(destination, dbConfig);
if (!destConfig) { return; }
const sourceConfig = ModelMasher.getEntryConfig(source, dbConfig);
if (!sourceConfig) { return; }
destination.pushHistory();
destConfig.hTTPRealm = sourceConfig.hTTPRealm;
destination.icon = source.icon;
destination.customIcon = source.customIcon;
const existingPassword = source.fields.get("Password");
destination.fields.set("Title", source.fields.get("Title") ?? "");
destination.fields.set("UserName", source.fields.get("UserName") ?? "");
destination.fields.set("Password", (existingPassword instanceof ProtectedValue) ? existingPassword.clone() : kdbxweb.ProtectedValue.fromString(existingPassword ?? ""));
destConfig.formFieldList = sourceConfig.formFieldList;
// This algorithm could probably be made more efficient (lots of O(n) operations
// but we're dealing with pretty small n so I've gone with the conceptually
// easiest approach for now).
let destURLs: string[] = [];
const destUrl = destination.fields.get("URL");
destURLs.push((destUrl instanceof ProtectedValue) ? destUrl.getText() : destUrl ?? "");
if (destConfig.altURLs) { destURLs = destURLs.concat(destConfig.altURLs); }
let sourceURLs: string[] = [];
const sourceUrl = source.fields.get("URL");
sourceURLs.push((sourceUrl instanceof ProtectedValue) ? sourceUrl.getText() : sourceUrl ?? "");
if (sourceConfig.altURLs) { sourceURLs = sourceURLs.concat(sourceConfig.altURLs); }
/// <param name="urlMergeMode">1= Replace the entry's URL (but still fill forms if you visit the old URL)
/// 2= Replace the entry's URL (delete the old URL completely)
/// 3= Keep the old entry's URL (but still fill forms if you visit the new URL)
/// 4= Keep the old entry's URL (don't add the new URL to the entry)
/// 5= No merge. Delete all URLs and replace with those supplied in the new entry data</param>
switch (urlMergeMode) {
case 1:
mergeInNewURLs(destURLs, sourceURLs);
break;
case 2:
destURLs.shift();
mergeInNewURLs(destURLs, sourceURLs);
break;
case 3:
if (sourceURLs.length > 0) {
sourceURLs.forEach(sourceUrl => {
if (!destURLs.includes(sourceUrl)) { destURLs.push(sourceUrl); }
});
}
break;
case 4:
// No changes to URLs
break;
case 5:
destURLs = sourceURLs;
break;
default:
// No changes to URLs
break;
}
// These might not have changed but meh
destination.fields.set("URL", destURLs[0]);
destConfig["altURLs"] = [];
if (destURLs.length > 1) { destConfig["altURLs"] = destURLs.slice(1, destURLs.length); }
ModelMasher.setEntryConfig(destination, destConfig);
destination.times.update();
};
const mergeInNewURLs = function (destURLs: string[], sourceURLs: string[]) {
if (sourceURLs.length > 0) {
for (let i = sourceURLs.length - 1; i >= 0; i--) {
const sourceUrl = sourceURLs[i];
if (!destURLs.includes(sourceUrl)) {
destURLs.unshift(sourceUrl);
} else if (i === 0) {
// Promote the URL from alternative URL list to primary URL
destURLs.splice(destURLs.indexOf(sourceUrl), 1);
destURLs.unshift(sourceUrl);
}
}
}
};
let logger;
let appMetadata;
export default class KPRPC {
public static SIGNAL_OPENED = 4;
public static SIGNAL_CLOSED = 6;
public static SIGNAL_SAVED = 8;
init (dependencies, loggerIn, appVersionString) {
logger = loggerIn;
requestedInstanceCount++;
if (requestedInstanceCount <= 0) {
logger.debug("Ignoring init request because we've seen enough shutdown requests to indicate we should not be running in this environment.");
return;
}
if (requestedInstanceCount > 1) {
logger.error("Unexpected init request. Call shutdown first if you want to reinit.");
return;
}
getEntry = dependencies.getEntry;
ping = dependencies.ping;
getDomain = dependencies.getDomain;
editEntry = dependencies.editEntry;
getFiles = dependencies.getFiles;
getFileInfos = dependencies.getFileInfos;
messageToKeeAddonProxy = dependencies.messageToKeeAddonProxy;
generatePassword = dependencies.generatePassword;
getPasswordProfiles = dependencies.getPasswordProfiles;
openOrUnlockOrFocusFile = dependencies.openOrUnlockOrFocusFile;
addEntry = dependencies.addEntry;
syncFile = dependencies.syncFile;
getSetting = dependencies.getSetting;
onKeeAddonEnabled = dependencies.onKeeAddonEnabled;
onKeeAddonActivated = dependencies.onKeeAddonActivated;
readAddonSettings = dependencies.readAddonSettings;
updateAddonSettings = dependencies.updateAddonSettings;
delayUntilIntegrationReady = dependencies.delayUntilIntegrationReady;
launchBuiltInPasswordGenerator = dependencies.launchBuiltInPasswordGenerator;
modelMasher = new ModelMasher(new KdbxPlaceholders(), getDomain, logger);
appMetadata = {
KeePassVersion: appVersionString,
IsMono: "unknown",
NETCLR: "0",
NETversion: "unknown",
MonoVersion: "unknown"
};
remote = new JRPC();
remote.expose({
LaunchGroupEditor: (params, next) => this.executeNow(() => this.LaunchGroupEditor(params[0], params[1]), next),
LaunchLoginEditor: (params, next) => this.executeNow(() => this.LaunchLoginEditor(params[0], params[1]), next),
GetCurrentKFConfig: (params, next) => this.deferIfNeeded(() => this.GetCurrentKFConfig(), next),
GetApplicationMetadata: (params, next) => this.executeNow(() => this.GetApplicationMetadata(), next),
ChangeDatabase: (params, next) => this.deferIfNeeded(() => this.ChangeDatabase(params[0], params[1]), next),
GetPasswordProfiles: (params, next) => this.executeNow(() => this.GetPasswordProfiles(), next),
GeneratePassword: (params, next) => this.executeNow(() => this.GeneratePassword(params[0], params[1]), next),
AddLogin: (params, next) => this.deferIfNeeded(() => this.AddLogin(params[0], params[1], params[2]), next),
UpdateLogin: (params, next) => this.deferIfNeeded(() => this.UpdateLogin(params[0], params[1], params[2], params[3]), next),
GetAllDatabases: (params, next) => this.executeNow(() => this.GetAllDatabases(params ? params[0] : false), next),
FindLogins: (params, next) => this.executeNow(() => this.FindLogins(params[0], params[1], params[2], params[3],
params[4], params[5], params[6], params[7], params[8]), next),
UpdateAddonSettings: (params, next) => this.deferIfNeeded(() => this.updateAddonSettings(params[0], params[1]), next)
});
// Let JRPC send requests and responses continuously
remote.setTransmitter((msg, next) => {
try {
if (messageToKeeAddonProxy) messageToKeeAddonProxy({ message: msg });
return next(false);
} catch (e) {
return next(true);
}
});
stopWaitingForStartup = listen(document, "KeeAddonEnabled", (event: CustomEvent) => {
if (!window["KeeAddonSupportedFeatures"]
|| !window["KeeAddonSupportedFeatures"].length
|| !["KPRPC_FEATURE_BROWSER_HOSTED", "KPRPC_FEATURE_VERSION_1_6", "BROWSER_SETTINGS_SYNC"]
.every(function (feature) {
return window["KeeAddonSupportedFeatures"].indexOf(feature) !== -1;
})
) {
logger.warn("Browser extension does not support features we require");
return;
}
onKeeAddonEnabled();
// now that the API is loaded we can invoke the connection startup code and
// modify the page app as needed to say we are connecting to the browser (if we want)
if (stopReceiving) {
stopReceiving();
}
stopReceiving = listen(document, event.detail, (e: CustomEvent) => {
if (e.detail === JSON.stringify({protocol: "ackinit"})) {
logger.debug("Setting up regular ping to browser");
if (pinger) {
clearInterval(pinger);
}
pinger = setInterval(ping, 1000 * 5);
onKeeAddonActivated();
} else if (e.detail === JSON.stringify({protocol: "showgenerator"})) {
// Maybe could/should/will one day be a new KPRPC feature but seems to be
// little benefit beyond the specific use case of Kee being unable/willing
// to create its usual profile selection iframe inside Kee Vault.
launchBuiltInPasswordGenerator();
} else {
remote.receive(e.detail);
}
});
logger.debug("Sending capabilities to browser");
messageToKeeAddonProxy({ features: [
"KPRPC_FEATURE_VERSION_1_6",
"KPRPC_GENERAL_CLIENTS",
"KPRPC_FEATURE_BROWSER_HOSTED",
"KPRPC_FEATURE_KEE_BRAND",
"KPRPC_FIELD_DEFAULT_NAME_AND_ID_EMPTY",
"BROWSER_SETTINGS_SYNC",
"KPRPC_FEATURE_ENTRY_URL_REPLACEMENT",
"KPRPC_SECURITY_FIX_20200729"
]});
});
}
getModelMasher () {
return modelMasher;
}
async deferIfNeeded (func, next) {
try {
await delayUntilIntegrationReady();
const result = await func();
next(false, result);
} catch (e) {
next(true, e);
}
}
executeNow (func, next) {
try {
const result = func();
next(false, result);
} catch (e) {
next(true, e);
}
}
shutdown () {
logger.debug("Shutting down KPRPC. Call init() again to restart.");
requestedInstanceCount--;
if (pinger) clearInterval(pinger);
if (stopWaitingForStartup) stopWaitingForStartup();
if (stopReceiving) stopReceiving();
if (remote) remote.shutdown();
remote = null;
}
LaunchGroupEditor (uuid, dbFileName) {
throw new Error("Not implemented");
}
LaunchLoginEditor (uuid, dbFileName) {
impl.openEntryForEditing(uuid, dbFileName);
}
GetCurrentKFConfig () {
return impl.getCurrentKFConfig();
}
GetApplicationMetadata () {
return appMetadata;
}
ChangeDatabase (fileName, closeCurrent) {
impl.changeDatabase(fileName, closeCurrent);
}
GetPasswordProfiles () {
return getPasswordProfiles();
}
GeneratePassword (profileDisplayName, url) {
return generatePassword(profileDisplayName, url);
}
AddLogin (login, parentUUID, dbFileName) {
return impl.addLogin(login, parentUUID, dbFileName);
}
UpdateLogin (login, oldLoginUUID, urlMergeMode, dbFileName) {
return impl.updateLogin(login, oldLoginUUID, urlMergeMode, dbFileName, getSetting("autosave") === "true");
}
GetAllDatabases (fullDetails) {
return impl.getAllDatabases(fullDetails);
}
FindLogins (URLs, actionURL, httpRealm, lst, requireFullURLMatches, uniqueID, dbFileName, freeTextSearch, username) {
return impl.findLogins(URLs, actionURL, httpRealm, lst, requireFullURLMatches, uniqueID, dbFileName, freeTextSearch, username);
}
updateAddonSettings (settings: object, version: number) {
updateAddonSettings(settings, version);
}
notify (signal) {
remote.notify("KPRPCListener", [signal]);
}
}
function listen (element, type: string, handler) {
element.addEventListener(type, handler);
return function () {
element.removeEventListener(type, handler);
};
}