Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(HW-761): log all navigation params for Posthog #2115

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "haqq",
"version": "1.9.3",
"version": "1.9.4",
"private": true,
"scripts": {
"android": "react-native run-android",
Expand Down
17 changes: 1 addition & 16 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ import {VariablesBool} from '@app/models/variables-bool';
import {Wallet} from '@app/models/wallet';
import {navigator} from '@app/navigator';
import {
HomeStackRoutes,
KeystoneStackRoutes,
LedgerStackRoutes,
OnboardingStackRoutes,
SssMigrateStackRoutes,
WelcomeStackRoutes,
} from '@app/route-types';
import {RootStack} from '@app/screens/RootStack';
import {AppTheme, ModalType} from '@app/types';
Expand Down Expand Up @@ -79,15 +77,6 @@ const SAFE_AREA_INTIAL_METRICS: Metrics = {
},
};

// We need to log some screens with params
// be careful with this list to avoid capturing sensitive data
const ALLOWED_SCREEN_TO_LOG_PARAMS = [
HomeStackRoutes.TransactionDetail,
HomeStackRoutes.Web3BrowserPopup,
HomeStackRoutes.InAppBrowser,
WelcomeStackRoutes.InAppBrowser,
];

export const App = () => {
const [initialized, setInitialized] = useState(false);
const [isPinReseted, setPinReseted] = useState(false);
Expand Down Expand Up @@ -249,11 +238,7 @@ export const App = () => {
captureScreens: true,
navigation: {
routeToProperties: (name, params) => {
// @ts-ignore
if (ALLOWED_SCREEN_TO_LOG_PARAMS.includes(name)) {
return params;
}
return undefined;
return params;
},
},
}}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/onboarding-repeat-pin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const OnboardingRepeatPin = ({

useEffect(() => {
if (pin.length === 6) {
if (pin === currentPin) {
if (pin === currentPin.value) {
onSetPin(pin);
} else {
const invalidCode = getText(I18N.onboardingRepeatPinInvalidCode);
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/get-provider-for-new-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function getProviderForNewWallet(params?: WalletInitialData) {
params.sssLocalShare || null,
null,
params.verifier,
params.token,
params.token.value,
app.getPassword.bind(app),
storage,
{
Expand Down
23 changes: 23 additions & 0 deletions src/modifiers/secure-value.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export class SecureValue<T> {
private readonly _value: T;

constructor(value: T) {
this._value = value;

Object.defineProperty(this, 'toJSON', {
value: () => 'This is secured value, not for public usage',
writable: true,
configurable: true,
});

Object.defineProperty(this, 'toString', {
value: () => 'This is secured value, not for public usage',
writable: true,
configurable: true,
});
}

get value() {
return this._value;
}
}
9 changes: 5 additions & 4 deletions src/route-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
import {WalletConnectApproveConnectionEvent} from '@app/types/wallet-connect';

import {Fee} from './models/fee';
import {SecureValue} from './modifiers/secure-value';
import {CalculatedFees} from './services/eth-network/types';

export type AnyRouteFromParent =
Expand Down Expand Up @@ -169,15 +170,15 @@ export type SssMigrateStackParamList = HomeStackParamList & {
[SssMigrateStackRoutes.SssMigrateNetworks]: {accountId: string};
[SssMigrateStackRoutes.SssMigrateRewrite]: {
accountId: string;
privateKey: string;
privateKey: SecureValue<string>;
provider: SssProviders;
email?: string;
verifier: string;
token: string;
};
[SssMigrateStackRoutes.SssMigrateStore]: {
accountId: string;
privateKey: string | null;
privateKey: SecureValue<string | null>;
provider?: SssProviders;
email?: string;
verifier: string;
Expand Down Expand Up @@ -675,13 +676,13 @@ export enum OnboardingStackRoutes {
export type OnboardingStackParamList = WelcomeStackParamList & {
[OnboardingStackRoutes.OnboardingSetupPin]: WalletInitialData & {
provider?: ProviderMnemonicBase;
currentPin: string;
currentPin: SecureValue<string>;
nextScreen: AnyRouteFromParent;
errorText?: string;
};
[OnboardingStackRoutes.OnboardingRepeatPin]: WalletInitialData & {
provider?: ProviderMnemonicBase;
currentPin: string;
currentPin: SecureValue<string>;
nextScreen: AnyRouteFromParent;
};
[OnboardingStackRoutes.OnboardingBiometry]: {
Expand Down
7 changes: 5 additions & 2 deletions src/screens/HomeStack/SssMigrate/sss-migrate-networks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {app} from '@app/contexts';
import {getMetadataValueWrapped} from '@app/helpers/wrappers/get-metadata-value';
import {useTypedNavigation, useTypedRoute} from '@app/hooks';
import {ErrorHandler} from '@app/models/error-handler';
import {SecureValue} from '@app/modifiers/secure-value';
import {
SssMigrateStackParamList,
SssMigrateStackRoutes,
Expand Down Expand Up @@ -60,7 +61,9 @@ export const SssMigrateNetworksScreen = memo(() => {
//@ts-ignore
navigation.navigate(nextScreen, {
accountId: route.params.accountId,
privateKey: creds?.privateKey,
privateKey: new SecureValue<string | null | undefined>(
creds?.privateKey,
),
token: creds?.token,
verifier: creds?.verifier,
provider,
Expand All @@ -81,7 +84,7 @@ export const SssMigrateNetworksScreen = memo(() => {
} else {
navigation.navigate(SssMigrateStackRoutes.SssMigrateStore, {
accountId: route.params.accountId,
privateKey: null,
privateKey: new SecureValue<string | null>(null),
token: creds.token,
verifier: creds.verifier,
});
Expand Down
2 changes: 1 addition & 1 deletion src/screens/HomeStack/SssMigrate/sss-migrate-store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const SssMigrateStoreScreen = observer(() => {
entropy = entropy.padStart(64, '0');

const provider = await ProviderSSSBase.initialize(
route.params.privateKey,
route.params.privateKey.value,
null,
null,
entropy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, {memo, useCallback, useEffect, useState} from 'react';

import {OnboardingSetupPin} from '@app/components/onboardinng-setup-pin';
import {useTypedNavigation, useTypedRoute} from '@app/hooks';
import {SecureValue} from '@app/modifiers/secure-value';
import {
OnboardingStackParamList,
OnboardingStackRoutes,
Expand Down Expand Up @@ -29,7 +30,7 @@ export const OnboardingSetupPinScreen = memo(() => {
if (pin.length === 6) {
navigation.navigate(OnboardingStackRoutes.OnboardingRepeatPin, {
...route,
currentPin: pin,
currentPin: new SecureValue<string>(pin),
});
setPin('');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {utils} from 'ethers';
import {SignInRestore} from '@app/components/singin-restore-wallet';
import {app} from '@app/contexts';
import {useTypedNavigation} from '@app/hooks';
import {SecureValue} from '@app/modifiers/secure-value';
import {SignInStackParamList, SignInStackRoutes} from '@app/route-types';
import {makeID} from '@app/utils';

Expand All @@ -26,7 +27,9 @@ export const SignInRestoreScreen = memo(() => {

navigation.push(nextScreen, {
type: 'privateKey',
privateKey: pk.startsWith('0x') ? pk : `0x${pk}`,
privateKey: new SecureValue<string>(
pk.startsWith('0x') ? pk : `0x${pk}`,
),
});

return;
Expand All @@ -45,7 +48,7 @@ export const SignInRestoreScreen = memo(() => {
navigation.push(SignInStackRoutes.SigninChooseAccount, {
provider,
type: 'mnemonic',
mnemonic: seed.trim().toLowerCase(),
mnemonic: new SecureValue<string>(seed.trim().toLowerCase()),
});

return;
Expand Down
11 changes: 6 additions & 5 deletions src/screens/WelcomeStack/SignInStack/signin-store-wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ export const SignInStoreWalletScreen = observer(() => {
number: `${total + 1}`,
});

let privateKey = params.privateKey.startsWith('0x')
? params.privateKey.slice(2)
: params.privateKey;
const privateKeyValue = params.privateKey.value;
let privateKey = privateKeyValue.startsWith('0x')
? privateKeyValue.slice(2)
: privateKeyValue;

const provider = await ProviderHotBase.initialize(
privateKey,
Expand All @@ -77,7 +78,7 @@ export const SignInStoreWalletScreen = observer(() => {
break;
case 'mnemonic':
const mnemonicProvider = await ProviderMnemonicBase.initialize(
params.mnemonic,
params.mnemonic.value,
getPassword,
{},
);
Expand All @@ -97,7 +98,7 @@ export const SignInStoreWalletScreen = observer(() => {
params.sssLocalShare,
null,
params.verifier,
params.token,
params.token.value,
app.getPassword.bind(app),
storage,
{
Expand Down
7 changes: 4 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {EIP155_SIGNING_METHODS} from '@app/variables/EIP155';

import {AwaitValue} from './helpers/await-for-value';
import {Fee} from './models/fee';
import {SecureValue} from './modifiers/secure-value';

export enum MarketingEvents {
accountCreated = 'q3vxmg',
Expand Down Expand Up @@ -115,19 +116,19 @@ export type SendTransactionRequest = Awaited<
export type WalletInitialData =
| {
type: 'mnemonic';
mnemonic: string;
mnemonic: SecureValue<string>;
}
| {
type: 'privateKey';
privateKey: string;
privateKey: SecureValue<string>;
}
| {
type: 'sss';
sssPrivateKey: string | null;
sssCloudShare: string | null;
sssLocalShare: string | null;
verifier: string;
token: string;
token: SecureValue<string>;
action?: 'restore' | 'replace';
provider: SssProviders;
}
Expand Down
Loading