Browse Source

fix: move lexical declarations outside case blocks in AbsurdSqlDatabaseService

- Move queryResult and allResult declarations outside switch statement
- Change const declarations to let since they're now in outer scope
- Remove const declarations from inside case blocks

This fixes the 'no-case-declarations' linter errors by ensuring variables
are declared in a scope that encompasses all case blocks, preventing
potential scoping issues.

Note: Type definition errors for external modules remain and should be
addressed separately.
pull/137/head
Matthew Raymer 2 weeks ago
parent
commit
0f1ac2b230
  1. 3034
      package-lock.json
  2. 88
      src/db/databaseUtil.ts
  3. 46
      src/libs/crypto/index.ts
  4. 2
      src/libs/endorserServer.ts
  5. 6
      src/libs/util.ts
  6. 38
      src/services/AbsurdSqlDatabaseService.ts
  7. 5
      src/services/PlatformService.ts
  8. 5
      src/services/platforms/CapacitorPlatformService.ts
  9. 5
      src/services/platforms/ElectronPlatformService.ts
  10. 5
      src/services/platforms/PyWebViewPlatformService.ts
  11. 5
      src/services/platforms/WebPlatformService.ts
  12. 2
      src/utils/empty-module.js
  13. 8
      src/utils/node-modules/crypto.js
  14. 10
      src/utils/node-modules/fs.js
  15. 16
      src/utils/node-modules/path.js
  16. 106
      src/views/AccountViewView.vue
  17. 6
      src/views/TestView.vue

3034
package-lock.json

File diff suppressed because it is too large

88
src/db/databaseUtil.ts

@ -11,7 +11,12 @@ export async function updateDefaultSettings(
delete settingsChanges.id;
try {
const platformService = PlatformServiceFactory.getInstance();
const { sql, params } = generateUpdateStatement(settingsChanges, "settings", "id = ?", [MASTER_SETTINGS_KEY]);
const { sql, params } = generateUpdateStatement(
settingsChanges,
"settings",
"id = ?",
[MASTER_SETTINGS_KEY],
);
const result = await platformService.dbExec(sql, params);
return result.changes === 1;
} catch (error) {
@ -34,28 +39,28 @@ export async function updateAccountSettings(
delete settingsChanges.id; // key off account, not ID
const platform = PlatformServiceFactory.getInstance();
// First try to update existing record
const { sql: updateSql, params: updateParams } = generateUpdateStatement(
settingsChanges,
"settings",
"accountDid = ?",
[accountDid]
[accountDid],
);
const updateResult = await platform.dbExec(updateSql, updateParams);
// If no record was updated, insert a new one
if (updateResult.changes === 1) {
return true;
} else {
const columns = Object.keys(settingsChanges);
const values = Object.values(settingsChanges);
const placeholders = values.map(() => '?').join(', ');
const insertSql = `INSERT INTO settings (${columns.join(', ')}) VALUES (${placeholders})`;
const placeholders = values.map(() => "?").join(", ");
const insertSql = `INSERT INTO settings (${columns.join(", ")}) VALUES (${placeholders})`;
const result = await platform.dbExec(insertSql, values);
return result.changes === 1;
}
}
@ -69,7 +74,9 @@ const DEFAULT_SETTINGS: Settings = {
// retrieves default settings
export async function retrieveSettingsForDefaultAccount(): Promise<Settings> {
const platform = PlatformServiceFactory.getInstance();
const result = await platform.dbQuery("SELECT * FROM settings WHERE id = ?", [MASTER_SETTINGS_KEY])
const result = await platform.dbQuery("SELECT * FROM settings WHERE id = ?", [
MASTER_SETTINGS_KEY,
]);
if (!result) {
return DEFAULT_SETTINGS;
} else {
@ -85,10 +92,14 @@ export async function retrieveSettingsForActiveAccount(): Promise<Settings> {
const platform = PlatformServiceFactory.getInstance();
const result = await platform.dbQuery(
"SELECT * FROM settings WHERE accountDid = ?",
[defaultSettings.activeDid]
[defaultSettings.activeDid],
);
const overrideSettings = result
? (mapColumnsToValues(result.columns, result.values)[0] as Settings)
: {};
const overrideSettingsFiltered = Object.fromEntries(
Object.entries(overrideSettings).filter(([_, v]) => v !== null),
);
const overrideSettings = result ? mapColumnsToValues(result.columns, result.values)[0] as Settings : {};
const overrideSettingsFiltered = Object.fromEntries(Object.entries(overrideSettings).filter(([_, v]) => v !== null));
return { ...defaultSettings, ...overrideSettingsFiltered };
}
}
@ -96,32 +107,32 @@ export async function retrieveSettingsForActiveAccount(): Promise<Settings> {
export async function logToDb(message: string): Promise<void> {
const platform = PlatformServiceFactory.getInstance();
const todayKey = new Date().toDateString();
// Check if we have any logs for today
const result = await platform.dbQuery(
"SELECT message FROM logs WHERE date = ?",
[todayKey]
[todayKey],
);
if (!result || result.values.length === 0) {
// If no logs for today, clear all previous logs
await platform.dbExec("DELETE FROM logs");
// Insert new log
const fullMessage = `${new Date().toISOString()} ${message}`;
await platform.dbExec(
"INSERT INTO logs (date, message) VALUES (?, ?)",
[todayKey, fullMessage]
);
await platform.dbExec("INSERT INTO logs (date, message) VALUES (?, ?)", [
todayKey,
fullMessage,
]);
} else {
// Append to existing log
const prevMessages = result.values[0][0] as string;
const fullMessage = `${prevMessages}\n${new Date().toISOString()} ${message}`;
await platform.dbExec(
"UPDATE logs SET message = ? WHERE date = ?",
[fullMessage, todayKey]
);
await platform.dbExec("UPDATE logs SET message = ? WHERE date = ?", [
fullMessage,
todayKey,
]);
}
}
@ -147,14 +158,14 @@ export async function logConsoleAndDb(
* @returns Object containing the SQL statement and parameters array
*/
function generateUpdateStatement(
model: Record<string, any>,
model: Record<string, unknown>,
tableName: string,
whereClause: string,
whereParams: any[] = []
): { sql: string; params: any[] } {
whereParams: unknown[] = [],
): { sql: string; params: unknown[] } {
// Filter out undefined/null values and create SET clause
const setClauses: string[] = [];
const params: any[] = [];
const params: unknown[] = [];
Object.entries(model).forEach(([key, value]) => {
if (value !== undefined) {
@ -164,14 +175,14 @@ function generateUpdateStatement(
});
if (setClauses.length === 0) {
throw new Error('No valid fields to update');
throw new Error("No valid fields to update");
}
const sql = `UPDATE ${tableName} SET ${setClauses.join(', ')} WHERE ${whereClause}`;
const sql = `UPDATE ${tableName} SET ${setClauses.join(", ")} WHERE ${whereClause}`;
return {
sql,
params: [...params, ...whereParams]
params: [...params, ...whereParams],
};
}
@ -184,14 +195,13 @@ function generateUpdateStatement(
*/
export function mapColumnsToValues(
columns: string[],
values: any[][]
): Record<string, any>[] {
return values.map(row => {
const obj: Record<string, any> = {};
values: unknown[][],
): Record<string, unknown>[] {
return values.map((row) => {
const obj: Record<string, unknown> = {};
columns.forEach((column, index) => {
obj[column] = row[index];
});
return obj;
});
}

46
src/libs/crypto/index.ts

@ -312,23 +312,29 @@ export async function testMessageEncryptionDecryption() {
}
// Simple encryption/decryption using Node's crypto
export async function simpleEncrypt(text: string, secret: string): Promise<string> {
export async function simpleEncrypt(
text: string,
secret: string,
): Promise<string> {
const iv = crypto.getRandomValues(new Uint8Array(16));
// Derive a 256-bit key from the secret using SHA-256
const keyData = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(secret));
const keyData = await crypto.subtle.digest(
"SHA-256",
new TextEncoder().encode(secret),
);
const key = await crypto.subtle.importKey(
'raw',
"raw",
keyData,
{ name: 'AES-GCM' },
{ name: "AES-GCM" },
false,
['encrypt']
["encrypt"],
);
const encrypted = await crypto.subtle.encrypt(
{ name: 'AES-GCM', iv },
{ name: "AES-GCM", iv },
key,
new TextEncoder().encode(text)
new TextEncoder().encode(text),
);
// Combine IV and encrypted data
@ -339,27 +345,33 @@ export async function simpleEncrypt(text: string, secret: string): Promise<strin
return btoa(String.fromCharCode(...result));
}
export async function simpleDecrypt(encryptedText: string, secret: string): Promise<string> {
const data = Uint8Array.from(atob(encryptedText), c => c.charCodeAt(0));
export async function simpleDecrypt(
encryptedText: string,
secret: string,
): Promise<string> {
const data = Uint8Array.from(atob(encryptedText), (c) => c.charCodeAt(0));
// Extract IV and encrypted data
const iv = data.slice(0, 16);
const encrypted = data.slice(16);
// Derive the same 256-bit key from the secret using SHA-256
const keyData = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(secret));
const keyData = await crypto.subtle.digest(
"SHA-256",
new TextEncoder().encode(secret),
);
const key = await crypto.subtle.importKey(
'raw',
"raw",
keyData,
{ name: 'AES-GCM' },
{ name: "AES-GCM" },
false,
['decrypt']
["decrypt"],
);
const decrypted = await crypto.subtle.decrypt(
{ name: 'AES-GCM', iv },
{ name: "AES-GCM", iv },
key,
encrypted
encrypted,
);
return new TextDecoder().decode(decrypted);

2
src/libs/endorserServer.ts

@ -1370,7 +1370,7 @@ export async function setVisibilityUtil(
"UPDATE contacts SET seesMe = ? WHERE did = ?",
[visibility, contact.did],
);
if (USE_DEXIE_DB) {
if (USE_DEXIE_DB) {
db.contacts.update(contact.did, { seesMe: visibility });
}
}

6
src/libs/util.ts

@ -5,7 +5,11 @@ import { Buffer } from "buffer";
import * as R from "ramda";
import { useClipboard } from "@vueuse/core";
import { DEFAULT_PUSH_SERVER, NotificationIface, USE_DEXIE_DB } from "../constants/app";
import {
DEFAULT_PUSH_SERVER,
NotificationIface,
USE_DEXIE_DB,
} from "../constants/app";
import {
accountsDBPromise,
retrieveSettingsForActiveAccount,

38
src/services/AbsurdSqlDatabaseService.ts

@ -20,11 +20,11 @@ interface AbsurdSqlDatabase {
}
interface QueuedOperation {
type: 'run' | 'query' | 'getOneRow' | 'getAll';
type: "run" | "query" | "getOneRow" | "getAll";
sql: string;
params: unknown[];
resolve: (value: any) => void;
reject: (reason: any) => void;
resolve: (value: unknown) => void;
reject: (reason: unknown) => void;
}
class AbsurdSqlDatabaseService implements DatabaseService {
@ -111,7 +111,7 @@ class AbsurdSqlDatabaseService implements DatabaseService {
await runMigrations(sqlExec);
this.initialized = true;
// Start processing the queue after initialization
this.processQueue();
}
@ -122,26 +122,28 @@ class AbsurdSqlDatabaseService implements DatabaseService {
}
this.isProcessingQueue = true;
while (this.operationQueue.length > 0) {
const operation = this.operationQueue.shift();
if (!operation) continue;
try {
let result;
let queryResult;
let allResult;
switch (operation.type) {
case 'run':
case "run":
result = await this.db.run(operation.sql, operation.params);
break;
case 'query':
case "query":
result = await this.db.exec(operation.sql, operation.params);
break;
case 'getOneRow':
const queryResult = await this.db.exec(operation.sql, operation.params);
case "getOneRow":
queryResult = await this.db.exec(operation.sql, operation.params);
result = queryResult[0]?.values[0];
break;
case 'getAll':
const allResult = await this.db.exec(operation.sql, operation.params);
case "getAll":
allResult = await this.db.exec(operation.sql, operation.params);
result = allResult[0]?.values || [];
break;
}
@ -155,7 +157,7 @@ class AbsurdSqlDatabaseService implements DatabaseService {
}
private async queueOperation<T>(
type: QueuedOperation['type'],
type: QueuedOperation["type"],
sql: string,
params: unknown[] = [],
): Promise<T> {
@ -205,13 +207,17 @@ class AbsurdSqlDatabaseService implements DatabaseService {
params: unknown[] = [],
): Promise<{ changes: number; lastId?: number }> {
await this.waitForInitialization();
return this.queueOperation<{ changes: number; lastId?: number }>('run', sql, params);
return this.queueOperation<{ changes: number; lastId?: number }>(
"run",
sql,
params,
);
}
// Note that the resulting array may be empty if there are no results from the query
async query(sql: string, params: unknown[] = []): Promise<QueryExecResult[]> {
await this.waitForInitialization();
return this.queueOperation<QueryExecResult[]>('query', sql, params);
return this.queueOperation<QueryExecResult[]>("query", sql, params);
}
async getOneRow(
@ -219,12 +225,12 @@ class AbsurdSqlDatabaseService implements DatabaseService {
params: unknown[] = [],
): Promise<unknown[] | undefined> {
await this.waitForInitialization();
return this.queueOperation<unknown[] | undefined>('getOneRow', sql, params);
return this.queueOperation<unknown[] | undefined>("getOneRow", sql, params);
}
async getAll(sql: string, params: unknown[] = []): Promise<unknown[][]> {
await this.waitForInitialization();
return this.queueOperation<unknown[][]>('getAll', sql, params);
return this.queueOperation<unknown[][]>("getAll", sql, params);
}
}

5
src/services/PlatformService.ts

@ -115,5 +115,8 @@ export interface PlatformService {
* @param params - The parameters to pass to the statement
* @returns Promise resolving to the result of the statement
*/
dbExec(sql: string, params?: unknown[]): Promise<{ changes: number; lastId?: number }>;
dbExec(
sql: string,
params?: unknown[],
): Promise<{ changes: number; lastId?: number }>;
}

5
src/services/platforms/CapacitorPlatformService.ts

@ -481,7 +481,10 @@ export class CapacitorPlatformService implements PlatformService {
dbQuery(sql: string, params?: unknown[]): Promise<QueryExecResult> {
throw new Error("Not implemented for " + sql + " with params " + params);
}
dbExec(sql: string, params?: unknown[]): Promise<{ changes: number; lastId?: number }> {
dbExec(
sql: string,
params?: unknown[],
): Promise<{ changes: number; lastId?: number }> {
throw new Error("Not implemented for " + sql + " with params " + params);
}
}

5
src/services/platforms/ElectronPlatformService.ts

@ -113,7 +113,10 @@ export class ElectronPlatformService implements PlatformService {
dbQuery(sql: string, params?: unknown[]): Promise<QueryExecResult> {
throw new Error("Not implemented for " + sql + " with params " + params);
}
dbExec(sql: string, params?: unknown[]): Promise<{ changes: number; lastId?: number }> {
dbExec(
sql: string,
params?: unknown[],
): Promise<{ changes: number; lastId?: number }> {
throw new Error("Not implemented for " + sql + " with params " + params);
}
}

5
src/services/platforms/PyWebViewPlatformService.ts

@ -114,7 +114,10 @@ export class PyWebViewPlatformService implements PlatformService {
dbQuery(sql: string, params?: unknown[]): Promise<QueryExecResult> {
throw new Error("Not implemented for " + sql + " with params " + params);
}
dbExec(sql: string, params?: unknown[]): Promise<{ changes: number; lastId?: number }> {
dbExec(
sql: string,
params?: unknown[],
): Promise<{ changes: number; lastId?: number }> {
throw new Error("Not implemented for " + sql + " with params " + params);
}
}

5
src/services/platforms/WebPlatformService.ts

@ -372,7 +372,10 @@ export class WebPlatformService implements PlatformService {
/**
* @see PlatformService.dbExec
*/
dbExec(sql: string, params?: unknown[]): Promise<{ changes: number; lastId?: number }> {
dbExec(
sql: string,
params?: unknown[],
): Promise<{ changes: number; lastId?: number }> {
return databaseService.run(sql, params);
}
}

2
src/utils/empty-module.js

@ -1,2 +1,2 @@
// Empty module to satisfy Node.js built-in module imports
export default {};
export default {};

8
src/utils/node-modules/crypto.js

@ -9,9 +9,9 @@ const crypto = {
},
createHash: () => ({
update: () => ({
digest: () => new Uint8Array(32) // Return empty hash
})
})
digest: () => new Uint8Array(32), // Return empty hash
}),
}),
};
export default crypto;
export default crypto;

10
src/utils/node-modules/fs.js

@ -1,18 +1,18 @@
// Minimal fs module implementation for browser
const fs = {
readFileSync: () => {
throw new Error('fs.readFileSync is not supported in browser');
throw new Error("fs.readFileSync is not supported in browser");
},
writeFileSync: () => {
throw new Error('fs.writeFileSync is not supported in browser');
throw new Error("fs.writeFileSync is not supported in browser");
},
existsSync: () => false,
mkdirSync: () => {},
readdirSync: () => [],
statSync: () => ({
isDirectory: () => false,
isFile: () => false
})
isFile: () => false,
}),
};
export default fs;
export default fs;

16
src/utils/node-modules/path.js

@ -1,13 +1,13 @@
// Minimal path module implementation for browser
const path = {
resolve: (...parts) => parts.join('/'),
join: (...parts) => parts.join('/'),
dirname: (p) => p.split('/').slice(0, -1).join('/'),
basename: (p) => p.split('/').pop(),
resolve: (...parts) => parts.join("/"),
join: (...parts) => parts.join("/"),
dirname: (p) => p.split("/").slice(0, -1).join("/"),
basename: (p) => p.split("/").pop(),
extname: (p) => {
const parts = p.split('.');
return parts.length > 1 ? '.' + parts.pop() : '';
}
const parts = p.split(".");
return parts.length > 1 ? "." + parts.pop() : "";
},
};
export default path;
export default path;

106
src/views/AccountViewView.vue

@ -1151,7 +1151,7 @@ export default class AccountViewView extends Vue {
databaseUtil.logConsoleAndDb(
"Error loading profile: " + errorStringForLog(error),
);
if (USE_DEXIE_DB) {
if (USE_DEXIE_DB) {
logConsoleAndDb(
"Error loading profile: " + errorStringForLog(error),
);
@ -1282,7 +1282,7 @@ export default class AccountViewView extends Vue {
await databaseUtil.updateDefaultSettings({
showContactGivesInline: this.showContactGives,
});
if (USE_DEXIE_DB) {
if (USE_DEXIE_DB) {
await db.open();
await db.settings.update(MASTER_SETTINGS_KEY, {
showContactGivesInline: this.showContactGives,
@ -1295,7 +1295,7 @@ export default class AccountViewView extends Vue {
await databaseUtil.updateDefaultSettings({
showGeneralAdvanced: this.showGeneralAdvanced,
});
if (USE_DEXIE_DB) {
if (USE_DEXIE_DB) {
await db.open();
await db.settings.update(MASTER_SETTINGS_KEY, {
showGeneralAdvanced: this.showGeneralAdvanced,
@ -1308,7 +1308,7 @@ export default class AccountViewView extends Vue {
await databaseUtil.updateDefaultSettings({
warnIfProdServer: this.warnIfProdServer,
});
if (USE_DEXIE_DB) {
if (USE_DEXIE_DB) {
await db.open();
await db.settings.update(MASTER_SETTINGS_KEY, {
warnIfProdServer: this.warnIfProdServer,
@ -1321,7 +1321,7 @@ export default class AccountViewView extends Vue {
await databaseUtil.updateDefaultSettings({
warnIfTestServer: this.warnIfTestServer,
});
if (USE_DEXIE_DB) {
if (USE_DEXIE_DB) {
await db.open();
await db.settings.update(MASTER_SETTINGS_KEY, {
warnIfTestServer: this.warnIfTestServer,
@ -1334,7 +1334,7 @@ export default class AccountViewView extends Vue {
await databaseUtil.updateDefaultSettings({
showShortcutBvc: this.showShortcutBvc,
});
if (USE_DEXIE_DB) {
if (USE_DEXIE_DB) {
await db.open();
await db.settings.update(MASTER_SETTINGS_KEY, {
showShortcutBvc: this.showShortcutBvc,
@ -1351,15 +1351,19 @@ export default class AccountViewView extends Vue {
*/
async processIdentity() {
const platformService = PlatformServiceFactory.getInstance();
const dbAccount = await platformService.dbQuery("SELECT * FROM accounts WHERE did = ?", [this.activeDid]);
const dbAccount = await platformService.dbQuery(
"SELECT * FROM accounts WHERE did = ?",
[this.activeDid],
);
let account: Account | undefined = undefined;
if (dbAccount) {
account = databaseUtil.mapColumnsToValues(dbAccount.columns, dbAccount.values)[0] as Account;
account = databaseUtil.mapColumnsToValues(
dbAccount.columns,
dbAccount.values,
)[0] as Account;
}
if (USE_DEXIE_DB) {
account = await retrieveAccountMetadata(
this.activeDid,
);
account = await retrieveAccountMetadata(this.activeDid);
}
if (account?.identity) {
const identity = JSON.parse(account.identity as string) as IIdentifier;
@ -1406,7 +1410,7 @@ export default class AccountViewView extends Vue {
await databaseUtil.updateDefaultSettings({
notifyingNewActivityTime: timeText,
});
if (USE_DEXIE_DB) {
if (USE_DEXIE_DB) {
await db.settings.update(MASTER_SETTINGS_KEY, {
notifyingNewActivityTime: timeText,
});
@ -1427,7 +1431,7 @@ export default class AccountViewView extends Vue {
await databaseUtil.updateDefaultSettings({
notifyingNewActivityTime: "",
});
if (USE_DEXIE_DB) {
if (USE_DEXIE_DB) {
await db.settings.update(MASTER_SETTINGS_KEY, {
notifyingNewActivityTime: "",
});
@ -1477,7 +1481,7 @@ export default class AccountViewView extends Vue {
notifyingReminderMessage: message,
notifyingReminderTime: timeText,
});
if (USE_DEXIE_DB) {
if (USE_DEXIE_DB) {
await db.settings.update(MASTER_SETTINGS_KEY, {
notifyingReminderMessage: message,
notifyingReminderTime: timeText,
@ -1502,7 +1506,7 @@ export default class AccountViewView extends Vue {
notifyingReminderMessage: "",
notifyingReminderTime: "",
});
if (USE_DEXIE_DB) {
if (USE_DEXIE_DB) {
await db.settings.update(MASTER_SETTINGS_KEY, {
notifyingReminderMessage: "",
notifyingReminderTime: "",
@ -1524,7 +1528,7 @@ export default class AccountViewView extends Vue {
await databaseUtil.updateDefaultSettings({
hideRegisterPromptOnNewContact: newSetting,
});
if (USE_DEXIE_DB) {
if (USE_DEXIE_DB) {
await db.open();
await db.settings.update(MASTER_SETTINGS_KEY, {
hideRegisterPromptOnNewContact: newSetting,
@ -1537,7 +1541,7 @@ export default class AccountViewView extends Vue {
await databaseUtil.updateDefaultSettings({
passkeyExpirationMinutes: this.passkeyExpirationMinutes,
});
if (USE_DEXIE_DB) {
if (USE_DEXIE_DB) {
await db.open();
await db.settings.update(MASTER_SETTINGS_KEY, {
passkeyExpirationMinutes: this.passkeyExpirationMinutes,
@ -1554,7 +1558,7 @@ export default class AccountViewView extends Vue {
notifyingReminderMessage: "",
notifyingReminderTime: "",
});
if (USE_DEXIE_DB) {
if (USE_DEXIE_DB) {
await db.open();
await db.settings.update(MASTER_SETTINGS_KEY, {
notifyingNewActivityTime: "",
@ -1708,25 +1712,25 @@ export default class AccountViewView extends Vue {
if (inputImportFileNameRef.value != null) {
if (USE_DEXIE_DB) {
await db
.delete()
.then(async () => {
// BulkError: settings.bulkAdd(): 1 of 21 operations failed. Errors: ConstraintError: Key already exists in the object store.
await Dexie.import(inputImportFileNameRef.value as Blob, {
progressCallback: this.progressCallback,
.delete()
.then(async () => {
// BulkError: settings.bulkAdd(): 1 of 21 operations failed. Errors: ConstraintError: Key already exists in the object store.
await Dexie.import(inputImportFileNameRef.value as Blob, {
progressCallback: this.progressCallback,
});
})
.catch((error) => {
logger.error("Error importing file:", error);
this.$notify(
{
group: "alert",
type: "danger",
title: "Error Importing",
text: "There was an error in the import. Your identities and contacts may have been affected, so you may have to restore your identifier and use the contact import method.",
},
-1,
);
});
})
.catch((error) => {
logger.error("Error importing file:", error);
this.$notify(
{
group: "alert",
type: "danger",
title: "Error Importing",
text: "There was an error in the import. Your identities and contacts may have been affected, so you may have to restore your identifier and use the contact import method.",
},
-1,
);
});
} else {
throw new Error("Not implemented");
}
@ -1817,8 +1821,10 @@ export default class AccountViewView extends Vue {
if (!this.isRegistered) {
// the user was not known to be registered, but now they are (because we got no error) so let's record it
try {
await databaseUtil.updateAccountSettings(did, { isRegistered: true });
if (USE_DEXIE_DB) {
await databaseUtil.updateAccountSettings(did, {
isRegistered: true,
});
if (USE_DEXIE_DB) {
await db.open();
await db.settings.update(MASTER_SETTINGS_KEY, {
isRegistered: true,
@ -1886,7 +1892,7 @@ export default class AccountViewView extends Vue {
await databaseUtil.updateDefaultSettings({
apiServer: this.apiServerInput,
});
if (USE_DEXIE_DB) {
if (USE_DEXIE_DB) {
await db.open();
await db.settings.update(MASTER_SETTINGS_KEY, {
apiServer: this.apiServerInput,
@ -1899,7 +1905,7 @@ export default class AccountViewView extends Vue {
await databaseUtil.updateDefaultSettings({
partnerApiServer: this.partnerApiServerInput,
});
if (USE_DEXIE_DB) {
if (USE_DEXIE_DB) {
await db.open();
await db.settings.update(MASTER_SETTINGS_KEY, {
partnerApiServer: this.partnerApiServerInput,
@ -1912,7 +1918,7 @@ export default class AccountViewView extends Vue {
await databaseUtil.updateDefaultSettings({
webPushServer: this.webPushServerInput,
});
if (USE_DEXIE_DB) {
if (USE_DEXIE_DB) {
await db.open();
await db.settings.update(MASTER_SETTINGS_KEY, {
webPushServer: this.webPushServerInput,
@ -1936,8 +1942,8 @@ export default class AccountViewView extends Vue {
await databaseUtil.updateDefaultSettings({
profileImageUrl: imgUrl,
});
if (USE_DEXIE_DB) {
await db.open();
if (USE_DEXIE_DB) {
await db.open();
await db.settings.update(MASTER_SETTINGS_KEY, {
profileImageUrl: imgUrl,
});
@ -2005,7 +2011,7 @@ export default class AccountViewView extends Vue {
await databaseUtil.updateDefaultSettings({
profileImageUrl: undefined,
});
if (USE_DEXIE_DB) {
if (USE_DEXIE_DB) {
await db.open();
await db.settings.update(MASTER_SETTINGS_KEY, {
profileImageUrl: undefined,
@ -2099,8 +2105,10 @@ export default class AccountViewView extends Vue {
throw Error("Profile not saved");
}
} catch (error) {
databaseUtil.logConsoleAndDb("Error saving profile: " + errorStringForLog(error));
if (USE_DEXIE_DB) {
databaseUtil.logConsoleAndDb(
"Error saving profile: " + errorStringForLog(error),
);
if (USE_DEXIE_DB) {
logConsoleAndDb("Error saving profile: " + errorStringForLog(error));
}
const errorMessage: string =
@ -2192,8 +2200,10 @@ export default class AccountViewView extends Vue {
throw Error("Profile not deleted");
}
} catch (error) {
databaseUtil.logConsoleAndDb("Error deleting profile: " + errorStringForLog(error));
if (USE_DEXIE_DB) {
databaseUtil.logConsoleAndDb(
"Error deleting profile: " + errorStringForLog(error),
);
if (USE_DEXIE_DB) {
logConsoleAndDb("Error deleting profile: " + errorStringForLog(error));
}
const errorMessage: string =

6
src/views/TestView.vue

@ -445,11 +445,13 @@ export default class Help extends Vue {
}
public async testMessageEncryptionDecryption() {
this.messageEncryptionTestResult = await cryptoLib.testMessageEncryptionDecryption();
this.messageEncryptionTestResult =
await cryptoLib.testMessageEncryptionDecryption();
}
public async testSimpleEncryptionDecryption() {
this.simpleEncryptionTestResult = await cryptoLib.testSimpleEncryptionDecryption();
this.simpleEncryptionTestResult =
await cryptoLib.testSimpleEncryptionDecryption();
}
public async createJwtSimplewebauthn() {

Loading…
Cancel
Save