Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyrat committed Feb 26, 2024
1 parent 9dc5805 commit cad62fb
Show file tree
Hide file tree
Showing 16 changed files with 1,049 additions and 5,817 deletions.
6 changes: 3 additions & 3 deletions formats/Format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ export class Format {
return;
}
let name = this.normaliseFieldNameCase(origName);
while (this.hasValue(entry.fields[name])) {
while (this.hasValue(entry.fields.get(name))) {
name = name + " (copy)";
}
entry.fields[name] = (forceProtection || this.db.meta.memoryProtection[this.normaliseFieldNameCaseMemoryProt(origName)])
entry.fields.set(name, (forceProtection || this.db.meta.memoryProtection[this.normaliseFieldNameCaseMemoryProt(origName)])
? ProtectedValue.fromString(this.removeInvalidCharacters(value))
: this.removeInvalidCharacters(value);
: this.removeInvalidCharacters(value));
}

processTags (tags: string, entry: KdbxEntry) {
Expand Down
12 changes: 6 additions & 6 deletions formats/GenericCSVFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ export class GenericCSVFormat extends Format {

meta.fields.forEach(field => {
switch (field.trim().toLowerCase()) {
case "notes": mapping["Notes"] = { col: field, protectedField: this.db.meta.memoryProtection.Notes }; break;
case "title": mapping["Title"] = { col: field, protectedField: this.db.meta.memoryProtection.Title }; break;
case "password": mapping["Password"] = { col: field, protectedField: this.db.meta.memoryProtection.Password }; break;
case "username": mapping["UserName"] = { col: field, protectedField: this.db.meta.memoryProtection.UserName }; break;
case "user name": mapping["UserName"] = { col: field, protectedField: this.db.meta.memoryProtection.UserName }; break;
case "url": mapping["URL"] = { col: field, protectedField: this.db.meta.memoryProtection.URL }; break;
case "notes": mapping["Notes"] = { col: field, protectedField: this.db.meta.memoryProtection.notes ?? false }; break;
case "title": mapping["Title"] = { col: field, protectedField: this.db.meta.memoryProtection.title ?? false }; break;
case "password": mapping["Password"] = { col: field, protectedField: this.db.meta.memoryProtection.password ?? false }; break;
case "username": mapping["UserName"] = { col: field, protectedField: this.db.meta.memoryProtection.userName ?? false }; break;
case "user name": mapping["UserName"] = { col: field, protectedField: this.db.meta.memoryProtection.userName ?? false }; break;
case "url": mapping["URL"] = { col: field, protectedField: this.db.meta.memoryProtection.url ?? false }; break;
case "group": mapping["Group"] = { col: field, protectedField: false }; break;
case "tags": mapping["Tags"] = { col: field, protectedField: false }; break;
}
Expand Down
10 changes: 5 additions & 5 deletions formats/LastPassFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ export class LastPassFormat extends GenericCSVFormat {
if (!meta || !meta.fields || meta.fields.length < 5) return ImportDTO.createError("bad meta fields found");

const mapping: CSVFieldMapping = {
Notes: { col: "extra", protectedField: this.db.meta.memoryProtection.Notes },
Title: { col: "name", protectedField: this.db.meta.memoryProtection.Title },
Password: { col: "password", protectedField: this.db.meta.memoryProtection.Password },
URL: { col: "url", protectedField: this.db.meta.memoryProtection.URL },
UserName: { col: "username", protectedField: this.db.meta.memoryProtection.UserName },
Notes: { col: "extra", protectedField: this.db.meta.memoryProtection.notes ?? false },
Title: { col: "name", protectedField: this.db.meta.memoryProtection.title ?? false },
Password: { col: "password", protectedField: this.db.meta.memoryProtection.password ?? false },
URL: { col: "url", protectedField: this.db.meta.memoryProtection.url ?? false },
UserName: { col: "username", protectedField: this.db.meta.memoryProtection.userName ?? false },
Group: { col: "grouping", protectedField: false },
Tags: { col: "fav", protectedField: false }
};
Expand Down
10 changes: 5 additions & 5 deletions formats/OnePasswordCSVFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export class OnePasswordCSVFormat extends GenericCSVFormat {
if (!meta || !meta.fields || meta.fields.length < 5) return ImportDTO.createError("bad meta fields found");

const mapping: CSVFieldMapping = {
Notes: { col: "Notes", protectedField: this.db.meta.memoryProtection.Notes },
Title: { col: "Title", protectedField: this.db.meta.memoryProtection.Title },
Password: { col: "Password", protectedField: this.db.meta.memoryProtection.Password },
URL: { col: "URL", protectedField: this.db.meta.memoryProtection.URL },
UserName: { col: "Username", protectedField: this.db.meta.memoryProtection.UserName },
Notes: { col: "Notes", protectedField: this.db.meta.memoryProtection.notes ?? false },
Title: { col: "Title", protectedField: this.db.meta.memoryProtection.title ?? false },
Password: { col: "Password", protectedField: this.db.meta.memoryProtection.password ?? false },
URL: { col: "URL", protectedField: this.db.meta.memoryProtection.url ?? false },
UserName: { col: "Username", protectedField: this.db.meta.memoryProtection.userName ?? false },
Group: { col: "Type", protectedField: false }
};

Expand Down
12 changes: 6 additions & 6 deletions formats/OnePasswordPIFFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class OnePasswordPIFFormat extends Format {
try {
const importDTO = new ImportDTO();
const rootGroup = this.db.getDefaultGroup();
const recycleBin = this.db.getGroup(this.db.meta.recycleBinUuid);
const recycleBin = this.db.getGroup(this.db.meta.recycleBinUuid ?? "");
this.groupMapping = {};

pif.split(/(?:\r\n|\r|\n)/).forEach(line => {
Expand Down Expand Up @@ -150,23 +150,23 @@ export class OnePasswordPIFFormat extends Format {
}

private createPasswordHistory (items: any[], entry: KdbxEntry) {
const importLimit = items.length > this.db.meta.historyMaxItems ? this.db.meta.historyMaxItems : items.length;
const importLimit = items.length > (this.db.meta.historyMaxItems ?? 0) ? this.db.meta.historyMaxItems ?? 0 : items.length;
const importStart = items.length - importLimit;

const currentPassword = entry.fields.Password;
const currentPassword = entry.fields.get('Password');
// const currentModTime = (entry.times as any).lastModTime;

items.sort((a, b) => a.time - b.time)
.slice(importStart).forEach((oldPassword: any) => {
const value = this.removeInvalidCharacters(oldPassword.value);
entry.fields.Password = this.db.meta.memoryProtection.password
entry.fields.set('Password', this.db.meta.memoryProtection.password
? ProtectedValue.fromString(value)
: value;
: value);
//TODO: kdbxweb doesn't support editing times yet
//entry.times.lastModTime = oldPassword.time;

entry.pushHistory();
});
entry.fields.Password = currentPassword;
entry.fields.set('Password', currentPassword ?? "" );
}
}
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
testEnvironment: 'node',
};
Loading

0 comments on commit cad62fb

Please sign in to comment.