Skip to content
Merged
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
18 changes: 17 additions & 1 deletion app/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ module.exports = {
files: ['docs/examples/**/*.ts'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'no-console': 'off',
'no-unused-vars': 'off',
'import/no-unresolved': 'off',
},
Expand All @@ -194,11 +196,14 @@ module.exports = {
},
{
files: ['tests/**/*.{ts,tsx}'],
env: {
jest: true,
},
parserOptions: {
project: './tsconfig.test.json',
},
rules: {
// Allow console logging in tests
// Allow console logging and relaxed typing in tests
'no-console': 'off',
// Allow require() imports in tests for mocking
'@typescript-eslint/no-require-imports': 'off',
Expand All @@ -220,6 +225,13 @@ module.exports = {
'@typescript-eslint/no-require-imports': 'off',
},
},
{
// Allow require imports for conditional loading in navigation
files: ['src/navigation/index.tsx'],
rules: {
'@typescript-eslint/no-require-imports': 'off',
},
},
{
files: ['*.cjs', '*.js'],
env: {
Expand All @@ -232,6 +244,10 @@ module.exports = {
sourceType: 'script',
},
rules: {
'no-console': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-require-imports': 'off',
'no-undef': 'off',
Expand Down
6 changes: 2 additions & 4 deletions app/docs/examples/tree-shaking/level2-optimal-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ import { hash } from '@selfxyz/common/utils/hash';
export function optimalLevel2Example(data: PassportData) {
// This will result in the smallest possible bundle
// Only the specific functions and constants we use are included

// eslint-disable-next-line no-console
console.log('Using API:', API_URL);
// eslint-disable-next-line no-console

console.log('Attestation ID:', PASSPORT_ATTESTATION_ID);

const hashedData = hash(JSON.stringify(data));
// eslint-disable-next-line no-console

console.log('Hashed passport data:', hashedData);

return {
Expand Down
8 changes: 3 additions & 5 deletions app/docs/examples/tree-shaking/level3-optimal-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,18 @@ export function optimalLevel3Example(data: PassportData, secret: string) {
// This will result in the smallest possible bundle
// Only the specific individual functions we use are included
// Bundle size reduction: ~75-90% compared to broad imports!

// eslint-disable-next-line no-console
console.log('Using API:', API_URL);
// eslint-disable-next-line no-console

console.log('Attestation ID:', PASSPORT_ATTESTATION_ID);

// Use specific hash function from SHA module
const hashedData = hash([1, 2, 3, 4], 'hex');
// eslint-disable-next-line no-console

console.log('SHA hashed data:', hashedData);

// Use specific Poseidon function for commitment
const poseidonHash = flexiblePoseidon([BigInt(1), BigInt(2)]);
// eslint-disable-next-line no-console

console.log('Poseidon hash:', poseidonHash);

// Use specific passport functions
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/mobile-deploy-confirm.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const REGEX_PATTERNS = {
function safeReadFile(filePath, description) {
try {
return fs.readFileSync(filePath, 'utf8');
} catch (_error) {
} catch {
console.warn(`Warning: Could not read ${description} at ${filePath}`);
return null;
}
Expand Down Expand Up @@ -91,7 +91,7 @@ function safeExecSync(command, description) {

try {
return execSync(command, { encoding: 'utf8' }).trim();
} catch (_error) {
} catch {
console.warn(`Warning: Could not ${description}`);
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/typography/Additional.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { shouldShowAesopRedesign } from '@/hooks/useAesopRedesign';
import { slate400 } from '@/utils/colors';
import { dinot } from '@/utils/fonts';

interface AdditionalProps extends TextProps {}
type AdditionalProps = TextProps;

const Additional = ({ children, style, ...props }: AdditionalProps) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/typography/Caution.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { StyleSheet, Text } from 'react-native';
import { slate700 } from '@/utils/colors';
import { dinot } from '@/utils/fonts';

interface CautionProps extends TextProps {}
type CautionProps = TextProps;

const Caution = ({ children, style, ...props }: CautionProps) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/typography/Description.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { shouldShowAesopRedesign } from '@/hooks/useAesopRedesign';
import { slate500 } from '@/utils/colors';
import { dinot } from '@/utils/fonts';

interface DescriptionProps extends TextProps {}
type DescriptionProps = TextProps;

const Description = ({ children, style, ...props }: DescriptionProps) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion app/src/hooks/useRecoveryPrompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function useRecoveryPrompts() {
if (shouldPrompt) {
showModal();
}
} catch (_error) {
} catch {
// Silently fail to avoid breaking the hook
// If we can't get documents, we shouldn't show the prompt
return;
Expand Down
2 changes: 1 addition & 1 deletion app/src/layouts/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { PropsWithChildren } from 'react';
import React from 'react';
import { SafeAreaProvider } from 'react-native-safe-area-context';

interface ConnectedAppLayoutProps extends PropsWithChildren {}
type ConnectedAppLayoutProps = PropsWithChildren;

export default function ConnectedAppLayout({
children,
Expand Down
2 changes: 1 addition & 1 deletion app/src/layouts/ExpandableBottomLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const TopSection: React.FC<TopSectionProps> = ({
);
};

interface FullSectionProps extends ViewProps {}
type FullSectionProps = ViewProps;
/*
* Rather than using a top and bottom section, this component is te entire thing.
* It leave space for the safe area insets and provides basic padding
Expand Down
17 changes: 8 additions & 9 deletions app/src/layouts/SimpleScrolledTitleLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ import { Title } from '@/components/typography/Title';
import { ExpandableBottomLayout } from '@/layouts/ExpandableBottomLayout';
import { white } from '@/utils/colors';

interface DetailListProps
extends PropsWithChildren<{
title: string;
onDismiss: () => void;
secondaryButtonText?: string;
onSecondaryButtonPress?: () => void;
header?: React.ReactNode;
footer?: React.ReactNode;
}> {}
type DetailListProps = PropsWithChildren<{
title: string;
onDismiss: () => void;
secondaryButtonText?: string;
onSecondaryButtonPress?: () => void;
header?: React.ReactNode;
footer?: React.ReactNode;
}>;

export default function SimpleScrolledTitleLayout({
title,
Expand Down
5 changes: 4 additions & 1 deletion app/src/navigation/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { lazy } from 'react';
import type { NativeStackNavigationOptions } from '@react-navigation/native-stack';

import DevPrivateKeyScreen from '@/screens/dev/DevPrivateKeyScreen';
// DevPrivateKeyScreen is loaded lazily to avoid bundling in production
import { black, white } from '@/utils/colors';

const DevFeatureFlagsScreen = lazy(
Expand All @@ -17,6 +17,9 @@ const MockDataScreen = lazy(() => import('@/screens/dev/MockDataScreen'));
const MockDataScreenDeepLink = lazy(
() => import('@/screens/dev/MockDataScreenDeepLink'),
);
const DevPrivateKeyScreen = lazy(
() => import('@/screens/dev/DevPrivateKeyScreen'),
);

const devScreens = {
CreateMock: {
Expand Down
17 changes: 12 additions & 5 deletions app/src/navigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { DefaultNavBar } from '@/components/NavBar';
import AppLayout from '@/layouts/AppLayout';
import { getAesopScreens } from '@/navigation/aesop';
import devScreens from '@/navigation/dev';
// Import dev screens type for conditional inclusion
import type devScreensType from '@/navigation/dev';
// Dev screens are conditionally loaded to avoid bundling in production
import homeScreens from '@/navigation/home';
import miscScreens from '@/navigation/misc';
import passportScreens from '@/navigation/passport';
Expand All @@ -25,6 +27,11 @@ import analytics from '@/utils/analytics';
import { white } from '@/utils/colors';
import { setupUniversalLinkListenerInNavigation } from '@/utils/deeplinks';

// Conditionally load dev screens only in development
const devScreens: typeof devScreensType = __DEV__
? require('@/navigation/dev').default
: ({} as typeof devScreensType);

export const navigationScreens = {
...miscScreens,
...passportScreens,
Expand All @@ -36,9 +43,6 @@ export const navigationScreens = {
// add last to override other screens
...getAesopScreens(),
};

export type RootStackParamList = StaticParamList<typeof AppNavigation>;

const AppNavigation = createNativeStackNavigator({
id: undefined,
initialRouteName: Platform.OS === 'web' ? 'Home' : 'Splash',
Expand All @@ -50,11 +54,14 @@ const AppNavigation = createNativeStackNavigator({
screens: navigationScreens,
});

export type RootStackParamList = StaticParamList<typeof AppNavigation>;

// Create a ref that we can use to access the navigation state
export const navigationRef = createNavigationContainerRef();
export const navigationRef = createNavigationContainerRef<RootStackParamList>();

declare global {
namespace ReactNavigation {
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
interface RootParamList extends RootStackParamList {}
}
}
Expand Down
8 changes: 4 additions & 4 deletions app/src/providers/passportDataProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export async function clearDocumentCatalogForMigrationTesting() {
try {
await Keychain.resetGenericPassword({ service: `document-${doc.id}` });
console.log(`Cleared document: ${doc.id}`);
} catch (_error) {
} catch {
console.log(`Document ${doc.id} not found or already cleared`);
}
}
Expand All @@ -287,7 +287,7 @@ export async function clearDocumentCatalogForMigrationTesting() {
try {
await Keychain.resetGenericPassword({ service: 'documentCatalog' });
console.log('Cleared document catalog');
} catch (_error) {
} catch {
console.log('Document catalog not found or already cleared');
}

Expand All @@ -305,7 +305,7 @@ export async function clearPassportData() {
for (const doc of catalog.documents) {
try {
await Keychain.resetGenericPassword({ service: `document-${doc.id}` });
} catch (_error) {
} catch {
console.log(`Document ${doc.id} not found or already cleared`);
}
}
Expand Down Expand Up @@ -345,7 +345,7 @@ export async function deleteDocument(documentId: string): Promise<void> {
// Delete the actual document
try {
await Keychain.resetGenericPassword({ service: `document-${documentId}` });
} catch (_error) {
} catch {
console.log(`Document ${documentId} not found or already cleared`);
}
}
Expand Down
6 changes: 1 addition & 5 deletions app/src/screens/aesop/PassportOnboardingScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ import { ExpandableBottomLayout } from '@/layouts/ExpandableBottomLayout';
import { black, slate100, white } from '@/utils/colors';
import { hasAnyValidRegisteredDocument } from '@/utils/proving/validateDocument';

interface PassportOnboardingScreenProps {}

const PassportOnboardingScreen: React.FC<
PassportOnboardingScreenProps
> = ({}) => {
const PassportOnboardingScreen: React.FC = () => {
const handleCameraPress = useHapticNavigation('PassportCamera');
const navigateToLaunch = useHapticNavigation('Launch', {
action: 'cancel',
Expand Down
4 changes: 1 addition & 3 deletions app/src/screens/dev/DevPrivateKeyScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import { unsafe_getPrivateKey } from '@/providers/authProvider';
import { black, slate50, slate200, teal500, white } from '@/utils/colors';
import { confirmTap } from '@/utils/haptic';

interface DevPrivateKeyScreen {}

const DevPrivateKeyScreen: React.FC<DevPrivateKeyScreen> = ({}) => {
const DevPrivateKeyScreen: React.FC = () => {
const [privateKey, setPrivateKey] = useState<string | null>(
'Loading private key…',
);
Expand Down
15 changes: 10 additions & 5 deletions app/src/screens/dev/DevSettingsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,16 @@ const DevSettingsScreen: React.FC<DevSettingsScreenProps> = ({}) => {
darkMode={true}
>
{[
{
label: 'Display your private key',
onPress: () => navigation.navigate('DevPrivateKey'),
dangerTheme: false,
},
// Only show private key button in development
...(__DEV__
? [
{
label: 'Display your private key',
onPress: () => navigation.navigate('DevPrivateKey'),
dangerTheme: false,
},
]
: []),
{
label: 'Delete your private key',
onPress: handleClearSecretsPress,
Expand Down
4 changes: 1 addition & 3 deletions app/src/screens/dev/MockDataScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ import { buttonTap, selectionChange } from '@/utils/haptic';

const { trackEvent } = analytics();

interface MockDataScreenProps {}

const documentTypes = {
mock_passport: 'Passport',
mock_id_card: 'ID Card',
Expand Down Expand Up @@ -244,7 +242,7 @@ const FormSection: React.FC<FormSectionProps> = ({
);
};

const MockDataScreen: React.FC<MockDataScreenProps> = ({}) => {
const MockDataScreen: React.FC = () => {
const navigation = useNavigation();
const [age, setAge] = useState(21);
const [expiryYears, setExpiryYears] = useState(5);
Expand Down
2 changes: 1 addition & 1 deletion app/src/screens/misc/ModalScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export interface ModalParams extends Record<string, any> {
preventDismiss?: boolean;
}

interface ModalScreenProps extends StaticScreenProps<ModalNavigationParams> {}
type ModalScreenProps = StaticScreenProps<ModalNavigationParams>;

const ModalScreen: React.FC<ModalScreenProps> = ({ route: { params } }) => {
const navigation = useNavigation();
Expand Down
4 changes: 1 addition & 3 deletions app/src/screens/passport/PassportCameraScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ import { dinot } from '@/utils/fonts';
import { hasAnyValidRegisteredDocument } from '@/utils/proving/validateDocument';
import { checkScannedInfo } from '@/utils/utils';

interface PassportNFCScanScreen {}

const { trackEvent } = analytics();

const PassportCameraScreen: React.FC<PassportNFCScanScreen> = ({}) => {
const PassportCameraScreen: React.FC = () => {
const navigation = useNavigation();
const isFocused = useIsFocused();
const store = useUserStore();
Expand Down
4 changes: 1 addition & 3 deletions app/src/screens/passport/PassportNFCScanScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ import { hasAnyValidRegisteredDocument } from '@/utils/proving/validateDocument'

const { trackEvent } = analytics();

interface PassportNFCScanScreenProps {}

const emitter =
Platform.OS === 'android'
? new NativeEventEmitter(NativeModules.nativeModule)
Expand All @@ -73,7 +71,7 @@ type PassportNFCScanRoute = RouteProp<
string
>;

const PassportNFCScanScreen: React.FC<PassportNFCScanScreenProps> = ({}) => {
const PassportNFCScanScreen: React.FC = () => {
const navigation = useNavigation();
const route = useRoute<PassportNFCScanRoute>();
const {
Expand Down
Loading
Loading