Skip to content

Commit

Permalink
Upgrade dependencies, format
Browse files Browse the repository at this point in the history
  • Loading branch information
perry-mitchell committed Nov 11, 2023
1 parent 7a87f2e commit 33e1945
Show file tree
Hide file tree
Showing 101 changed files with 6,358 additions and 4,145 deletions.
8 changes: 6 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"printWidth": 120,
"tabWidth": 4
"arrowParens": "always",
"bracketSpacing": true,
"printWidth": 100,
"quoteProps": "consistent",
"tabWidth": 4,
"trailingComma": "none"
}
7,490 changes: 4,516 additions & 2,974 deletions package-lock.json

Large diffs are not rendered by default.

52 changes: 26 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@
},
"homepage": "https://github.com/buttercup/buttercup-core#readme",
"dependencies": {
"@buttercup/channel-queue": "^1.2.0",
"@buttercup/dropbox-client": "^2.1.0",
"@buttercup/googledrive-client": "^2.2.0",
"@buttercup/channel-queue": "^1.3.0",
"@buttercup/dropbox-client": "^2.2.0",
"@buttercup/googledrive-client": "^2.3.0",
"crypto-random-string": "^5.0.0",
"eventemitter3": "^5.0.0",
"fast-levenshtein": "^3.0.0",
Expand All @@ -95,53 +95,53 @@
"hash.js": "^1.1.7",
"iocane": "^5.1.1",
"is-promise": "^4.0.0",
"layerr": "^0.1.2",
"layerr": "^2.0.1",
"pako": "^1.0.11",
"path-posix": "^1.0.0",
"pify": "^6.1.0",
"url-join": "^5.0.0",
"uuid": "^9.0.0",
"webdav": "^5.0.0-r2"
"uuid": "^9.0.1",
"webdav": "^5.3.0"
},
"devDependencies": {
"@babel/cli": "^7.20.7",
"@babel/core": "^7.20.12",
"@babel/cli": "^7.23.0",
"@babel/core": "^7.23.3",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
"@babel/preset-env": "^7.20.2",
"@types/node": "^18.11.18",
"@babel/preset-env": "^7.23.3",
"@types/node": "^20.9.0",
"arraybuffer-loader": "^1.0.8",
"babel-loader": "^9.1.2",
"babel-loader": "^9.1.3",
"base64-js": "^1.5.1",
"chai": "^4.3.7",
"concurrently": "^7.6.0",
"chai": "^4.3.10",
"concurrently": "^8.2.2",
"husky": "^4.3.8",
"jsdoc-to-markdown": "^8.0.0",
"karma": "^6.4.1",
"karma-chrome-launcher": "^3.1.1",
"karma": "^6.4.2",
"karma-chrome-launcher": "^3.2.0",
"karma-firefox-launcher": "^2.1.2",
"karma-mocha": "^2.0.1",
"karma-sinon": "^1.0.5",
"karma-spec-reporter": "^0.0.36",
"karma-webpack": "^5.0.0",
"lint-staged": "^13.1.0",
"lint-staged": "^15.0.2",
"mocha": "^10.2.0",
"nested-property": "^4.0.0",
"nodemon": "^2.0.20",
"nodemon": "^3.0.1",
"npm-run-all": "^4.1.1",
"null-loader": "^4.0.1",
"nyc": "^15.1.0",
"prettier": "^1.19.1",
"resolve-typescript-plugin": "^2.0.0",
"rimraf": "^4.1.2",
"sinon": "^15.0.1",
"prettier": "^3.0.3",
"resolve-typescript-plugin": "^2.0.1",
"rimraf": "^5.0.5",
"sinon": "^17.0.1",
"sleep-promise": "^9.1.0",
"tmp": "^0.2.1",
"ts-loader": "^9.4.2",
"typescript": "^4.9.5",
"ts-loader": "^9.5.0",
"typescript": "^5.2.2",
"webdav-server": "^2.6.2",
"webpack": "^5.75.0",
"webpack-bundle-analyzer": "^4.7.0",
"webpack-cli": "^5.0.1"
"webpack": "^5.89.0",
"webpack-bundle-analyzer": "^4.9.1",
"webpack-cli": "^5.1.4"
}
}
9 changes: 6 additions & 3 deletions source/attachments/AttachmentManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ export class AttachmentManager {
throw new Error(`Attachment not available: ${attachmentID}`);
}
const credentials = await this._getAttachmentsCredentials();
const data = await this._source._datasource.getAttachment(this._source.vault.id, attachmentID);
const data = await this._source._datasource.getAttachment(
this._source.vault.id,
attachmentID
);
return decryptAttachment(data, credentials);
}

Expand All @@ -68,9 +71,9 @@ export class AttachmentManager {
this._checkAttachmentSupport();
const attributes = entry.getAttribute();
const attachmentKeys = Object.keys(attributes).filter(
key => key.indexOf(Entry.Attributes.AttachmentPrefix) === 0
(key) => key.indexOf(Entry.Attributes.AttachmentPrefix) === 0
);
return attachmentKeys.map(key => JSON.parse(attributes[key]));
return attachmentKeys.map((key) => JSON.parse(attributes[key]));
}

/**
Expand Down
25 changes: 19 additions & 6 deletions source/core/Entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { generateUUID } from "../tools/uuid.js";
import { getEntryURLs, EntryURLType } from "../tools/entry.js";
import { Group } from "./Group.js";
import { Vault } from "./Vault.js";
import { EntryChange, EntryPropertyValueType, EntryType, GroupID, PropertyKeyValueObject } from "../types.js";
import {
EntryChange,
EntryPropertyValueType,
EntryType,
GroupID,
PropertyKeyValueObject
} from "../types.js";

/**
* Entry class - some secret item, login or perhaps
Expand Down Expand Up @@ -54,7 +60,8 @@ export class Entry extends VaultItem {
delete(skipTrash: boolean = false): boolean {
const trashGroup = this.vault.getTrashGroup();
const parentGroup = this.getGroup();
const canTrash = trashGroup && parentGroup && !parentGroup.isTrash() && !parentGroup.isInTrash();
const canTrash =
trashGroup && parentGroup && !parentGroup.isTrash() && !parentGroup.isInTrash();
if (canTrash && !skipTrash) {
// trash it
this.moveToGroup(trashGroup);
Expand Down Expand Up @@ -128,7 +135,7 @@ export class Entry extends VaultItem {
throw new Error(`No parent group found for entry: ${this.id}`);
}
const parentID = this.vault.format.getItemID(parentGroup);
return this.vault._groups.find(group => group.id === parentID);
return this.vault._groups.find((group) => group.id === parentID);
}

/**
Expand All @@ -153,7 +160,9 @@ export class Entry extends VaultItem {
* @returns The property value type
*/
getPropertyValueType(property: string): EntryPropertyValueType {
const attr = this.getAttribute(`${Entry.Attributes.FieldTypePrefix}${property}`) as EntryPropertyValueType;
const attr = this.getAttribute(
`${Entry.Attributes.FieldTypePrefix}${property}`
) as EntryPropertyValueType;
return attr || EntryPropertyValueType.Text;
}

Expand All @@ -173,7 +182,9 @@ export class Entry extends VaultItem {
}
const isRexp = propertyExpression instanceof RegExp;
return Object.keys(raw).reduce((aggr, key) => {
const matches = isRexp ? (<RegExp>propertyExpression).test(key) : propertyExpression === key;
const matches = isRexp
? (<RegExp>propertyExpression).test(key)
: propertyExpression === key;
return matches ? Object.assign(aggr, { [key]: raw[key] }) : aggr;
}, {});
}
Expand All @@ -183,7 +194,9 @@ export class Entry extends VaultItem {
* @returns
*/
getType(): EntryType {
return <EntryType | undefined>this.getAttribute(Entry.Attributes.FacadeType) || EntryType.Login;
return (
<EntryType | undefined>this.getAttribute(Entry.Attributes.FacadeType) || EntryType.Login
);
}

/**
Expand Down
29 changes: 20 additions & 9 deletions source/core/Group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ export class Group extends VaultItem {
}
// No trash or already in trash, so just delete:
// - Child groups
this.getGroups().forEach(group => group.delete(/* skip trash: */ true));
this.getGroups().forEach((group) => group.delete(/* skip trash: */ true));
// - Child entries
this.getEntries().forEach(entry => entry.delete(/* skip trash: */ true));
this.getEntries().forEach((entry) => entry.delete(/* skip trash: */ true));
// - This group
this.vault.format.deleteGroup(this.id);
const ind = this.vault._groups.indexOf(this);
Expand Down Expand Up @@ -123,7 +123,10 @@ export class Group extends VaultItem {
* @memberof Group
*/
findEntryByID(id: EntryID): Entry | null {
return getAllChildEntries(this.vault._entries, this.id).find(entry => entry.id === id) || null;
return (
getAllChildEntries(this.vault._entries, this.id).find((entry) => entry.id === id) ||
null
);
}

/**
Expand All @@ -135,7 +138,11 @@ export class Group extends VaultItem {
* @memberof Group
*/
findEntriesByProperty(property: RegExp | string, value: RegExp | string): Array<Entry> {
return findEntriesByProperty(getAllChildEntries(this.vault._entries, this.id), property, value);
return findEntriesByProperty(
getAllChildEntries(this.vault._entries, this.id),
property,
value
);
}

/**
Expand All @@ -145,7 +152,9 @@ export class Group extends VaultItem {
* @memberof Group
*/
findGroupByID(id: GroupID): Group | null {
return getAllChildGroups(this.vault._groups, this.id).find(group => group.id === id) || null;
return (
getAllChildGroups(this.vault._groups, this.id).find((group) => group.id === id) || null
);
}

/**
Expand Down Expand Up @@ -181,7 +190,7 @@ export class Group extends VaultItem {
* @memberof Group
*/
getEntries(): Array<Entry> {
return this.vault._entries.filter(entry => entry.getGroup() === this);
return this.vault._entries.filter((entry) => entry.getGroup() === this);
}

/**
Expand All @@ -190,7 +199,7 @@ export class Group extends VaultItem {
* @memberof Group
*/
getGroups(): Array<Group> {
return this.vault._groups.filter(group => group.getParentGroup() === this);
return this.vault._groups.filter((group) => group.getParentGroup() === this);
}

/**
Expand All @@ -203,9 +212,11 @@ export class Group extends VaultItem {
getParentGroup(): Group | null {
const parentID = this.vault.format.getItemParentID(this._source);
if (parentID === "0") return null;
const parentGroup = this.vault._groups.find(g => g.id === parentID);
const parentGroup = this.vault._groups.find((g) => g.id === parentID);
if (!parentGroup) {
throw new Error(`Failed getting parent Group: No group containing child ID found: ${this.id}`);
throw new Error(
`Failed getting parent Group: No group containing child ID found: ${this.id}`
);
}
return parentGroup;
}
Expand Down
24 changes: 12 additions & 12 deletions source/core/Vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ export class Vault extends EventEmitter {
emptyTrash(): this {
const trash = this.getTrashGroup();
if (!trash) return;
trash.getGroups().forEach(group => {
trash.getGroups().forEach((group) => {
group.delete(/* skip trash */ true);
});
trash.getEntries().forEach(entry => {
trash.getEntries().forEach((entry) => {
entry.delete(/* skip trash */ true);
});
return this;
Expand All @@ -157,7 +157,7 @@ export class Vault extends EventEmitter {
* @memberof Vault
*/
findEntryByID(id: EntryID): null | Entry {
return this._entries.find(entry => entry.id === id) || null;
return this._entries.find((entry) => entry.id === id) || null;
}

/**
Expand All @@ -178,7 +178,7 @@ export class Vault extends EventEmitter {
* @memberof Vault
*/
findGroupByID(id: GroupID): null | Group {
return this._groups.find(group => group.id === id) || null;
return this._groups.find((group) => group.id === id) || null;
}

/**
Expand Down Expand Up @@ -232,7 +232,7 @@ export class Vault extends EventEmitter {
* @memberof Vault
*/
getGroups(): Array<Group> {
return this._groups.filter(group => group.getParentGroup() === null);
return this._groups.filter((group) => group.getParentGroup() === null);
}

/**
Expand All @@ -242,7 +242,7 @@ export class Vault extends EventEmitter {
* @memberof Vault
*/
getTrashGroup(): Group | null {
const trashGroup = this.getGroups().find(group => group.isTrash());
const trashGroup = this.getGroups().find((group) => group.isTrash());
return trashGroup || null;
}

Expand All @@ -263,15 +263,15 @@ export class Vault extends EventEmitter {
this._groups = [];
this._entries = [];
}
this.format.getAllGroups().forEach(rawGroup => {
this.format.getAllGroups().forEach((rawGroup) => {
const id = this.format.getItemID(rawGroup);
if (!this._groups.find(g => g.id === id)) {
if (!this._groups.find((g) => g.id === id)) {
this._groups.push(new Group(this, rawGroup));
}
});
this.format.getAllEntries().forEach(rawEntry => {
this.format.getAllEntries().forEach((rawEntry) => {
const id = this.format.getItemID(rawEntry);
if (!this._entries.find(e => e.id === id)) {
if (!this._entries.find((e) => e.id === id)) {
this._entries.push(new Entry(this, rawEntry));
}
});
Expand All @@ -288,10 +288,10 @@ export class Vault extends EventEmitter {
this._format.removeAllListeners();
}
this._format = format;
this._groups.forEach(group => {
this._groups.forEach((group) => {
group._updateRefs();
});
this._entries.forEach(entry => {
this._entries.forEach((entry) => {
entry._updateRefs();
});
this._rebuild();
Expand Down
2 changes: 1 addition & 1 deletion source/core/VaultItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class VaultItem {
* @param perm The permission to revoke
*/
revokePermission(perm: string) {
this._source.permissions = this._source.permissions.filter(current => current !== perm);
this._source.permissions = this._source.permissions.filter((current) => current !== perm);
}

/**
Expand Down
Loading

0 comments on commit 33e1945

Please sign in to comment.