Browse Source

Enhance commentary and logging.

pull/146/head
Trent Larson 3 weeks ago
parent
commit
8a2966a13e
  1. 2
      .env.testing
  2. 1
      src/constants/app.ts
  3. 1
      src/db-sql/migration.ts
  4. 18
      src/libs/endorserServer.ts
  5. 2
      src/libs/util.ts
  6. 31
      src/views/AccountViewView.vue
  7. 5
      src/views/HomeView.vue

2
.env.testing

@ -1,6 +1,6 @@
# Only the variables that start with VITE_ are seen in the application import.meta.env in Vue. # Only the variables that start with VITE_ are seen in the application import.meta.env in Vue.
# iOS doesn't like spaces in the app title.
TIME_SAFARI_APP_TITLE="TimeSafari_Test" TIME_SAFARI_APP_TITLE="TimeSafari_Test"
VITE_APP_SERVER=https://test.timesafari.app VITE_APP_SERVER=https://test.timesafari.app
# This is the claim ID for actions in the BVC project. # This is the claim ID for actions in the BVC project.

1
src/constants/app.ts

@ -7,6 +7,7 @@ export enum AppString {
// This is used in titles and verbiage inside the app. // This is used in titles and verbiage inside the app.
// There is also an app name without spaces, for packaging in the package.json file used in the manifest. // There is also an app name without spaces, for packaging in the package.json file used in the manifest.
APP_NAME = "Time Safari", APP_NAME = "Time Safari",
// iOS doesn't like spaces in the app title.
APP_NAME_NO_SPACES = "TimeSafari", APP_NAME_NO_SPACES = "TimeSafari",
PROD_ENDORSER_API_SERVER = "https://api.endorser.ch", PROD_ENDORSER_API_SERVER = "https://api.endorser.ch",

1
src/db-sql/migration.ts

@ -29,6 +29,7 @@ import { arrayBufferToBase64 } from "@/libs/crypto";
const randomBytes = crypto.getRandomValues(new Uint8Array(32)); const randomBytes = crypto.getRandomValues(new Uint8Array(32));
const secretBase64 = arrayBufferToBase64(randomBytes); const secretBase64 = arrayBufferToBase64(randomBytes);
console.log('secretBase64', secretBase64); // useful while we have multiple DBs activating (at least on web)
// Each migration can include multiple SQL statements (with semicolons) // Each migration can include multiple SQL statements (with semicolons)
const MIGRATIONS = [ const MIGRATIONS = [

18
src/libs/endorserServer.ts

@ -60,7 +60,7 @@ import {
KeyMetaMaybeWithPrivate, KeyMetaMaybeWithPrivate,
} from "../interfaces/common"; } from "../interfaces/common";
import { PlanSummaryRecord } from "../interfaces/records"; import { PlanSummaryRecord } from "../interfaces/records";
import { logger } from "../utils/logger"; import { logger, safeStringify } from "../utils/logger";
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory"; import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
/** /**
@ -437,19 +437,23 @@ export async function getHeaders(
} }
headers["Authorization"] = "Bearer " + token; headers["Authorization"] = "Bearer " + token;
} catch (error) { } catch (error) {
// This rarely happens: we've seen it when they have account info but the
// encryption secret got lost. But in most cases we want users to at
// least see their feed -- and anything else that returns results for
// anonymous users.
// We'll continue with an anonymous request... still want to show feed and other things, but ideally let them know. // This rarely happens: we've seen it when they have account info but the
// encryption secret got lost.
// Replicate this in Chrome: go to Storage and hit 'Clear site data'.
// Check the util.ts retrieveFullyDecryptedAccount method where it calls simpleDecrypt.
// In most cases we want users to at least see their feed -- and anything
// else that returns results for anonymous users.
// We'll continue with an anonymous request... still want to show feed
// and other things, but we need to let them know.
logConsoleAndDb( logConsoleAndDb(
"Something failed in getHeaders call (will proceed anonymously" + "Something failed in getHeaders call (will proceed anonymously" +
($notify ? " and notify user" : "") + ($notify ? " and notify user" : "") +
"): " + "): " +
// IntelliJ type system complains about getCircularReplacer() with: Argument of type '(obj: any, key: string, value: any) => any' is not assignable to parameter of type '(this: any, key: string, value: any) => any'. // IntelliJ type system complains about getCircularReplacer() with: Argument of type '(obj: any, key: string, value: any) => any' is not assignable to parameter of type '(this: any, key: string, value: any) => any'.
//JSON.stringify(error, getCircularReplacer()), // JSON.stringify(error) on a Dexie error throws another error about: Converting circular structure to JSON //JSON.stringify(error, getCircularReplacer()), // JSON.stringify(error) on a Dexie error throws another error about: Converting circular structure to JSON
error, error + " - " + safeStringify(error),
true, true,
); );
if ($notify) { if ($notify) {

2
src/libs/util.ts

@ -605,7 +605,7 @@ export const retrieveFullyDecryptedAccount = async (
dbAccount.values.length === 0 || dbAccount.values.length === 0 ||
dbAccount.values[0].length === 0 dbAccount.values[0].length === 0
) { ) {
throw new Error("Account not found."); throw new Error("Account not found for did: " + activeDid);
} }
const fullAccountData = databaseUtil.mapQueryResultToValues( const fullAccountData = databaseUtil.mapQueryResultToValues(
dbAccount, dbAccount,

31
src/views/AccountViewView.vue

@ -126,7 +126,7 @@
<div class="flex justify-center text-center text-sm leading-tight mb-1"> <div class="flex justify-center text-center text-sm leading-tight mb-1">
People {{ profileImageUrl ? "without your image" : "" }} see this People {{ profileImageUrl ? "without your image" : "" }} see this
<br /> <br />
(if you've let them see your activity): (if you've let them see which posts are yours):
</div> </div>
<div class="flex justify-center"> <div class="flex justify-center">
<EntityIcon <EntityIcon
@ -1573,24 +1573,25 @@ export default class AccountViewView extends Vue {
* @throws Will notify the user if there is an export error. * @throws Will notify the user if there is an export error.
*/ */
public async exportDatabase() { public async exportDatabase() {
try { throw new Error("Not implemented");
// Generate the blob from the database // try {
const blob = await this.generateDatabaseBlob(); // // Generate the blob from the database
// const blob = await this.generateDatabaseBlob();
// Create a temporary URL for the blob // // Create a temporary URL for the blob
this.downloadUrl = this.createBlobURL(blob); // this.downloadUrl = this.createBlobURL(blob);
// Trigger the download // // Trigger the download
this.downloadDatabaseBackup(this.downloadUrl); // this.downloadDatabaseBackup(this.downloadUrl);
// Notify the user that the download has started // // Notify the user that the download has started
this.notifyDownloadStarted(); // this.notifyDownloadStarted();
// Revoke the temporary URL -- after a pause to avoid DuckDuckGo download failure // // Revoke the temporary URL -- after a pause to avoid DuckDuckGo download failure
setTimeout(() => URL.revokeObjectURL(this.downloadUrl), 1000); // setTimeout(() => URL.revokeObjectURL(this.downloadUrl), 1000);
} catch (error) { // } catch (error) {
this.handleExportError(error); // this.handleExportError(error);
} // }
} }
/** /**

5
src/views/HomeView.vue

@ -102,8 +102,7 @@ Raymer * @version 1.0.0 */
class="text-md font-bold bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white mt-2 px-2 py-3 rounded-md" class="text-md font-bold bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white mt-2 px-2 py-3 rounded-md"
@click="showNameThenIdDialog()" @click="showNameThenIdDialog()"
> >
Show them {{ PASSKEYS_ENABLED ? "default" : "your" }} identifier Show them your identification info
info
</button> </button>
</div> </div>
<UserNameDialog ref="userNameDialog" /> <UserNameDialog ref="userNameDialog" />
@ -683,7 +682,7 @@ export default class HomeView extends Vue {
group: "alert", group: "alert",
type: "warning", type: "warning",
title: "Feed Loading Issue", title: "Feed Loading Issue",
text: "Some feed data may be unavailable. Pull to refresh.", text: "Some feed data may be unavailable. Try refreshing the page.",
}, },
5000, 5000,
); );

Loading…
Cancel
Save