Skip to content

Commit

Permalink
cleanup RN console logging
Browse files Browse the repository at this point in the history
  • Loading branch information
tmgrask committed Nov 12, 2024
1 parent af5eb15 commit ac7316d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/auth/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
keyPairToBase64nopad,
} from "@/src/common/cryptography";
import { wrapError } from "@/src/common/errors";
import { timedLog } from "@/src/common/utils";
import {
SECURESTORE_ACCOUNT_KEYPAIR_BASE64_KEY,
SECURESTORE_DEVICE_NONCE_KEY,
Expand Down Expand Up @@ -61,6 +62,7 @@ export async function createOrLoadAccount(): Promise<Account | Error> {
SECURESTORE_MNEMONIC_KEY,
);
if (!storedMnemonic) {
timedLog("Generating new root mnemonic");
const newMnemonic = bip39.generateMnemonic(englishWordlist);
await SecureStore.setItemAsync(
SECURESTORE_MNEMONIC_KEY,
Expand All @@ -77,6 +79,7 @@ export async function createOrLoadAccount(): Promise<Account | Error> {
SECURESTORE_ACCOUNT_KEYPAIR_BASE64_KEY,
);
if (!storedAccountKeyPairBase64nopad) {
timedLog("Deriving account key from root mnemonic");
const derived = deriveEd25519KeyPair(mnemonic);
if (derived instanceof Error) {
throw derived;
Expand Down Expand Up @@ -106,6 +109,7 @@ export async function createOrLoadAccount(): Promise<Account | Error> {
SECURESTORE_DEVICE_NONCE_KEY,
);
if (!storedDeviceNonce) {
timedLog("Picking new random device nonce");
const newDeviceNonce = Math.floor(Math.random() * 0x80000000);
await SecureStore.setItemAsync(
SECURESTORE_DEVICE_NONCE_KEY,
Expand All @@ -122,6 +126,7 @@ export async function createOrLoadAccount(): Promise<Account | Error> {
SECURESTORE_INPROXY_KEYPAIR_BASE64_KEY,
);
if (!storedConduitKeyPairBase64nopad) {
timedLog("Deriving new conduit key pair from root mnemonic");
const derived = deriveEd25519KeyPair(
mnemonic,
formatConduitBip32Path(deviceNonce),
Expand Down
2 changes: 2 additions & 0 deletions src/auth/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import * as SecureStore from "expo-secure-store";
import React from "react";

import { createOrLoadAccount } from "@/src/auth/account";
import { timedLog } from "@/src/common/utils";
import {
QUERYKEY_ACCOUNT_KEYPAIR,
QUERYKEY_INPROXY_KEYPAIR,
Expand Down Expand Up @@ -64,6 +65,7 @@ export function AuthProvider(props: React.PropsWithChildren) {
}

// expose the account keys to the rest of the app through useQuery
timedLog("Setting keys in queryData");
queryClient.setQueryData(
[QUERYKEY_ACCOUNT_KEYPAIR],
account.accountKey,
Expand Down
2 changes: 0 additions & 2 deletions src/components/ConduitOrbToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ export function ConduitOrbToggle({
width: number;
height: number;
}) {
timedLog("ConduitOrbToggle");

const { t } = useTranslation();
const { toggleInproxy } = useInproxyContext();
const { data: inproxyStatus } = useInproxyStatus();
Expand Down

0 comments on commit ac7316d

Please sign in to comment.