diff --git a/.babelrc b/.babelrc deleted file mode 100644 index e69de29..0000000 diff --git a/package.json b/package.json index 0e39cad..6f76a36 100644 --- a/package.json +++ b/package.json @@ -1,34 +1,34 @@ { "devDependencies": { - "@babel/eslint-parser": "^7.13.14", + "@babel/eslint-parser": "^7.14.2", "@types/prismjs": "^1.16.5", "@types/uikit": "^3.3.1", - "@typescript-eslint/eslint-plugin": "^4.22.1", - "@typescript-eslint/parser": "^4.22.1", + "@typescript-eslint/eslint-plugin": "^4.23.0", + "@typescript-eslint/parser": "^4.23.0", "clipboard": "^2.0.8", "codejar": "^3.4.0", "css-loader": "^5.2.4", "date-fns": "^2.21.3", "eslint": "^7.26.0", "eslint-config-prettier": "^8.3.0", - "eslint-plugin-import": "^2.22.1", + "eslint-plugin-import": "^2.23.2", "eslint-plugin-prettier": "^3.4.0", "eslint-plugin-sort-imports-es6-autofix": "^0.6.0", "file-saver": "^2.0.5", "git-revision-webpack-plugin": "^5.0.0", "html-webpack-plugin": "^5.3.1", - "i18next": "^20.2.2", + "i18next": "^20.2.4", "mini-css-extract-plugin": "^1.6.0", - "node-sass": "^5.0.0", + "node-sass": "^6.0.0", "prettier": "^2.3.0", "prismjs": "^1.23.0", "qr-scanner": "^1.2.0", "raw-loader": "^4.0.2", - "sass-loader": "^11.0.1", + "sass-loader": "^11.1.1", "ts-loader": "^9.1.2", "typescript": "^4.2.4", "uikit": "^3.6.21", - "webpack": "^5.36.2", + "webpack": "^5.37.0", "webpack-cli": "^4.7.0", "webpack-dev-server": "^3.11.2", "z-pagerouter": "^1.0.1" diff --git a/src/allPages.ts b/src/allPages.ts index 0538e80..953290a 100644 --- a/src/allPages.ts +++ b/src/allPages.ts @@ -62,7 +62,6 @@ export const allPages: pagesList = { NEW_TRANSIT_ENGINE: new NewTransitEnginePage(), }; - // This should implement all o PageListType class PageList { constructor(pages: pagesList) { diff --git a/src/elements/QRScanner.ts b/src/elements/QRScanner.ts index 476cd20..8c8b99a 100644 --- a/src/elements/QRScanner.ts +++ b/src/elements/QRScanner.ts @@ -33,7 +33,7 @@ export async function QRScanner(onScan: (code: string) => void): Promise { try { diff --git a/src/main.ts b/src/main.ts index 7d7c1a4..fe9b553 100644 --- a/src/main.ts +++ b/src/main.ts @@ -102,30 +102,27 @@ async function onLoad(): Promise { document.addEventListener( "DOMContentLoaded", - function () { + async () => { console.log("Loading..."); // @ts-expect-error console.log("Build Data:", BUILD_STRING); - void i18next - .init({ - lng: pageState.language, - fallbackLng: "en", - debug: true, - // @ts-ignore - resources: Object.fromEntries( - Object.entries(translations).map(([k, v]) => [k, { translation: v }]), - ), - interpolation: { - format: function (value: unknown, format, _): string { - if (format === "until_date" && value instanceof Date) - return formatDistance(new Date(), new Date(value), pageState.language); - return value as string; - }, + await i18next.init({ + lng: pageState.language, + fallbackLng: "en", + debug: true, + // @ts-ignore + resources: Object.fromEntries( + Object.entries(translations).map(([k, v]) => [k, { translation: v }]), + ), + interpolation: { + format: function (value: unknown, format, _): string { + if (format === "until_date" && value instanceof Date) + return formatDistance(new Date(), new Date(value), pageState.language); + return value as string; }, - }) - .then(function (_) { - void onLoad(); - }); + }, + }); + await onLoad(); }, false, ); diff --git a/src/pages/KeyValue/KeyValueDelete.ts b/src/pages/KeyValue/KeyValueDelete.ts index 1c34e10..3f52ffd 100644 --- a/src/pages/KeyValue/KeyValueDelete.ts +++ b/src/pages/KeyValue/KeyValueDelete.ts @@ -30,16 +30,15 @@ export class KeyValueDeletePage extends Page { tag: "button", class: ["uk-button", "uk-button-danger"], text: i18next.t("kv_delete_btn"), - onclick: () => { - void deleteSecret( + onclick: async () => { + await deleteSecret( this.state.currentBaseMount, this.state.currentMountType, this.state.currentSecretPath, this.state.currentSecret, this.state.currentSecretVersion, - ).then(() => { - void this.goBack(); - }); + ); + await this.goBack(); }, }), ], diff --git a/src/pages/Me.ts b/src/pages/Me.ts index b63e9ab..3bd6ba5 100644 --- a/src/pages/Me.ts +++ b/src/pages/Me.ts @@ -49,14 +49,14 @@ export class MePage extends Page { children: makeElement({ tag: "a", text: i18next.t("renew_lease_btn"), - onclick: () => { - renewSelf() - .then(() => { - void this.router.changePage("HOME"); - }) - .catch((e: Error) => { - setErrorText(e.message); - }); + onclick: async () => { + try { + await renewSelf(); + await this.router.changePage("HOME"); + } catch (e: unknown) { + const error = e as Error; + setErrorText(error.message); + } }, }), }), diff --git a/src/pages/TOTP/TOTPView.ts b/src/pages/TOTP/TOTPView.ts index 7ec65ae..c451829 100644 --- a/src/pages/TOTP/TOTPView.ts +++ b/src/pages/TOTP/TOTPView.ts @@ -55,7 +55,7 @@ export class TOTPViewPage extends Page { const totpListElement = this.makeTOTPListElement(totpKeyName); totpList.appendChild(totpListElement); this.totpListElements[totpKeyName] = totpListElement; - void this.updateTOTPElement(totpKeyName, totpListElement); + await this.updateTOTPElement(totpKeyName, totpListElement); } document.getElementById("loadingText").remove(); } catch (e: unknown) { @@ -76,8 +76,8 @@ export class TOTPViewPage extends Page { ); }; await totpRefresher(); - this.refresher = setInterval(() => { - void totpRefresher(); + this.refresher = setInterval(async () => { + await totpRefresher(); }, 3000) as unknown as number; } diff --git a/src/pages/Unseal.ts b/src/pages/Unseal.ts index 139f52e..7aba5df 100644 --- a/src/pages/Unseal.ts +++ b/src/pages/Unseal.ts @@ -40,8 +40,8 @@ export class UnsealPage extends Page { } makeRefresher(): void { - const id = setInterval(() => { - void (this as UnsealPage).doRefresh().then(() => {}); + const id = setInterval(async () => { + await this.doRefresh(); return; }, 1000); this.refresher = id as unknown as number; @@ -83,7 +83,7 @@ export class UnsealPage extends Page { ], }), ); - this.switchInputMode(this.mode); + await this.switchInputMode(this.mode); await this.updateSealProgress(await getSealStatus()); this.makeRefresher(); } @@ -102,18 +102,18 @@ export class UnsealPage extends Page { tag: "button", class: ["uk-button", "uk-button-primary"], text: buttonText, - onclick: () => { - this.switchInputMode(newMethod); + onclick: async () => { + await this.switchInputMode(newMethod); }, }), ); } - switchInputMode(method: string): void { + async switchInputMode(method: string): Promise { this.deinitWebcam(); this.unsealInputContent.querySelectorAll("*").forEach((n) => n.remove()); if (method == UnsealInputModes.FORM_INPUT) this.makeUnsealForm(); - if (method == UnsealInputModes.QR_INPUT) void this.makeQRInput(); + if (method == UnsealInputModes.QR_INPUT) await this.makeQRInput(); this.setButtons(method); } @@ -143,9 +143,9 @@ export class UnsealPage extends Page { ], }) as HTMLFormElement; this.unsealInputContent.appendChild(this.unsealKeyForm); - this.unsealKeyForm.addEventListener("submit", (e: Event) => { + this.unsealKeyForm.addEventListener("submit", async (e: Event) => { e.preventDefault(); - void this.handleKeySubmit(); + await this.handleKeySubmit(); }); }