Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
43 changes: 20 additions & 23 deletions app/src/mocks/react-native-svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,44 @@
// SPDX-License-Identifier: BUSL-1.1
// NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE.

import React from 'react';
import React, { createElement, forwardRef } from 'react';

export const Circle = React.forwardRef<
export const Circle = forwardRef<
SVGCircleElement,
React.SVGProps<SVGCircleElement>
>((props, ref) => {
return React.createElement('circle', { ref, ...props });
return createElement('circle', { ref, ...props });
});
Comment on lines +7 to 12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Forwarded ref can be shadowed by a user-provided prop. Place ref last.

Spreading ...props after ref lets a stray ref prop override the forwarded ref, breaking ref wiring. Put ref last across these elements.

Apply this diff:

-  return createElement('circle', { ref, ...props });
+  return createElement('circle', { ...props, ref });

-    return createElement('path', { ref, ...props });
+    return createElement('path', { ...props, ref });

-    return createElement('rect', { ref, ...props });
+    return createElement('rect', { ...props, ref });

-    return createElement('svg', { ref, ...props });
+    return createElement('svg', { ...props, ref });

Also applies to: 16-20, 24-28, 33-37

🤖 Prompt for AI Agents
In app/src/mocks/react-native-svg.ts around lines 7-12 (and also apply same
change to ranges 16-20, 24-28, 33-37), the forwarded ref is being passed before
spreading props which allows a user-provided ref in ...props to shadow the
forwarded ref; update each createElement call so the ref property is placed
after the spread (i.e., spread props first, then set ref last) to ensure the
forwarded ref cannot be overridden.


Circle.displayName = 'Circle';

export const Path = React.forwardRef<
SVGPathElement,
React.SVGProps<SVGPathElement>
>((props, ref) => {
return React.createElement('path', { ref, ...props });
});
export const Path = forwardRef<SVGPathElement, React.SVGProps<SVGPathElement>>(
(props, ref) => {
return createElement('path', { ref, ...props });
},
);

Path.displayName = 'Path';

export const Rect = React.forwardRef<
SVGRectElement,
React.SVGProps<SVGRectElement>
>((props, ref) => {
return React.createElement('rect', { ref, ...props });
});
export const Rect = forwardRef<SVGRectElement, React.SVGProps<SVGRectElement>>(
(props, ref) => {
return createElement('rect', { ref, ...props });
},
);

Rect.displayName = 'Rect';

// Re-export other common SVG components that might be used
export const Svg = React.forwardRef<
SVGSVGElement,
React.SVGProps<SVGSVGElement>
>((props, ref) => {
return React.createElement('svg', { ref, ...props });
});
export const Svg = forwardRef<SVGSVGElement, React.SVGProps<SVGSVGElement>>(
(props, ref) => {
return createElement('svg', { ref, ...props });
},
);

Svg.displayName = 'Svg';

// Mock SvgXml component for web builds
export const SvgXml = React.forwardRef<
export const SvgXml = forwardRef<
HTMLDivElement,
{
xml: string;
Expand All @@ -51,7 +48,7 @@ export const SvgXml = React.forwardRef<
style?: React.CSSProperties;
}
>(({ xml, width, height, style, ...props }, ref) => {
return React.createElement('div', {
return createElement('div', {
ref,
style: {
width: width || 'auto',
Expand Down
1 change: 0 additions & 1 deletion app/src/navigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import proveScreens from '@/navigation/prove';
import recoveryScreens from '@/navigation/recovery';
import settingsScreens from '@/navigation/settings';
import systemScreens from '@/navigation/system';
import type { ProofHistory } from '@/stores/proof-types';
import analytics from '@/utils/analytics';
import { setupUniversalLinkListenerInNavigation } from '@/utils/deeplinks';

Expand Down
30 changes: 20 additions & 10 deletions app/src/screens/document/DocumentNFCScanScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
// NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE.

import LottieView from 'lottie-react-native';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import React, {
useCallback,
useEffect,
useMemo,
useRef,
useState,
} from 'react';
import {
Linking,
NativeEventEmitter,
Expand Down Expand Up @@ -109,11 +115,14 @@ const DocumentNFCScanScreen: React.FC = () => {
const scanCancelledRef = useRef(false);
const sessionIdRef = useRef(uuidv4());

const baseContext = {
sessionId: sessionIdRef.current,
platform: Platform.OS as 'ios' | 'android',
scanType: route.params?.useCan ? 'can' : 'mrz',
} as const;
const baseContext = useMemo(
() => ({
sessionId: sessionIdRef.current,
platform: Platform.OS as 'ios' | 'android',
scanType: route.params?.useCan ? 'can' : 'mrz',
}),
[route.params?.useCan],
);

const animationRef = useRef<LottieView>(null);

Expand All @@ -129,7 +138,7 @@ const DocumentNFCScanScreen: React.FC = () => {
stage: 'unmount',
});
};
}, []);
}, [baseContext]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

All logNFCEvent calls must pass NFCScanContext

Once baseContext includes userId, spreading with stage should satisfy the type at every call site (this one included). If TS still complains, cast per call: { ...baseContext, stage: 'mount' } as NFCScanContext.

🤖 Prompt for AI Agents
In app/src/screens/document/DocumentNFCScanScreen.tsx around line 141, the
logNFCEvent call is missing an NFCScanContext-typed object; update the call to
pass { ...baseContext, stage: 'mount' } so the staged spread satisfies the
NFCScanContext type (if TypeScript still complains, cast each call as {
...baseContext, stage: 'mount' } as NFCScanContext).


// Cleanup timeout on component unmount
useEffect(() => {
Expand Down Expand Up @@ -188,7 +197,7 @@ const DocumentNFCScanScreen: React.FC = () => {
onModalDismiss: () => {},
});
},
[showModal, goToNFCTrouble],
[baseContext, showModal, goToNFCTrouble],
);

const checkNfcSupport = useCallback(async () => {
Expand Down Expand Up @@ -233,7 +242,7 @@ const DocumentNFCScanScreen: React.FC = () => {
},
);
}
}, []);
}, [baseContext]);

const usePacePolling = (): boolean => {
const { usePacePolling: usePacePollingParam } = route.params ?? {};
Expand Down Expand Up @@ -483,6 +492,7 @@ const DocumentNFCScanScreen: React.FC = () => {
}
}
}, [
baseContext,
isNfcEnabled,
isNfcSupported,
route.params,
Expand Down Expand Up @@ -576,7 +586,7 @@ const DocumentNFCScanScreen: React.FC = () => {
scanTimeoutRef.current = null;
}
};
}, [checkNfcSupport]),
}, [baseContext, checkNfcSupport]),
);

return (
Expand Down
5 changes: 2 additions & 3 deletions app/src/screens/home/IdDetailsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
// NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE.

import React, { useEffect, useState } from 'react';
import { ScrollView } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { Button, Text, XStack, YStack, ZStack } from 'tamagui';
import { BlurView } from '@react-native-community/blur';
import { useNavigation, useRoute } from '@react-navigation/native';
import { useNavigation } from '@react-navigation/native';

import { PassportData } from '@selfxyz/common/types';
import { DocumentCatalog } from '@selfxyz/common/utils/types';

import IdCardLayout from '@/components/homeScreen/idCard';
import { usePassport } from '@/providers/passportDataProvider';
import ProofHistoryList from '@/screens/home/ProofHistoryList';
import { ProofHistoryList } from '@/screens/home/ProofHistoryList';
import useUserStore from '@/stores/userStore';
import {
black,
Expand Down
2 changes: 0 additions & 2 deletions app/src/screens/home/ProofHistoryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
SectionList,
StyleSheet,
} from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { Card, Image, Text, View, XStack, YStack } from 'tamagui';
import { useNavigation } from '@react-navigation/native';
import { CheckSquare2, Wallet, XCircle } from '@tamagui/lucide-icons';
Expand Down Expand Up @@ -64,7 +63,6 @@ export const ProofHistoryList: React.FC<ProofHistoryListProps> = ({
} = useProofHistoryStore();
const [refreshing, setRefreshing] = useState(false);
const navigation = useNavigation();
const { bottom } = useSafeAreaInsets();

useEffect(() => {
initDatabase();
Expand Down
30 changes: 15 additions & 15 deletions app/src/utils/nfcScanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,15 @@ const handleResponseIOS = (response: unknown) => {
const signedAttributes = parsed?.signedAttributes;
const mrz = parsed?.passportMRZ;
const signatureBase64 = parsed?.signatureBase64;
const _dataGroupsPresent = parsed?.dataGroupsPresent;
const _placeOfBirth = parsed?.placeOfBirth;
const _activeAuthenticationPassed = parsed?.activeAuthenticationPassed;
const _isPACESupported = parsed?.isPACESupported;
const _isChipAuthenticationSupported = parsed?.isChipAuthenticationSupported;
const _residenceAddress = parsed?.residenceAddress;
const passportPhoto = parsed?.passportPhoto;
const _encapsulatedContentDigestAlgorithm =
parsed?.encapsulatedContentDigestAlgorithm;
// const _dataGroupsPresent = parsed?.dataGroupsPresent;
// const _placeOfBirth = parsed?.placeOfBirth;
// const _activeAuthenticationPassed = parsed?.activeAuthenticationPassed;
// const _isPACESupported = parsed?.isPACESupported;
// const _isChipAuthenticationSupported = parsed?.isChipAuthenticationSupported;
// const _residenceAddress = parsed?.residenceAddress;
// const passportPhoto = parsed?.passportPhoto;
// const _encapsulatedContentDigestAlgorithm =
// parsed?.encapsulatedContentDigestAlgorithm;
const documentSigningCertificate = parsed?.documentSigningCertificate;
const pem = JSON.parse(documentSigningCertificate).PEM.replace(/\n/g, '');
const eContentArray = Array.from(Buffer.from(signedAttributes, 'base64'));
Expand Down Expand Up @@ -203,12 +203,12 @@ const handleResponseAndroid = (response: AndroidScanResponse): PassportData => {
mrz,
eContent,
encryptedDigest,
_photo,
_digestAlgorithm,
_signerInfoDigestAlgorithm,
_digestEncryptionAlgorithm,
_LDSVersion,
_unicodeVersion,
// _photo,
// _digestAlgorithm,
// _signerInfoDigestAlgorithm,
// _digestEncryptionAlgorithm,
// _LDSVersion,
// _unicodeVersion,
encapContent,
documentSigningCertificate,
dataGroupHashes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
// NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE.

import type { SelfClient } from '@selfxyz/mobile-sdk-alpha';
import {
useProtocolStore,
useSelfAppStore,
} from '@selfxyz/mobile-sdk-alpha/stores';
import { useSelfAppStore } from '@selfxyz/mobile-sdk-alpha/stores';

// Do not import provingMachine here; we'll require it after setting up mocks per test

Expand Down
4 changes: 3 additions & 1 deletion sdk/core/src/SelfBackendVerifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ export class SelfBackendVerifier {
}

//check if timestamp is 1 day in the past
const circuitTimestampEOD = new Date(circuitTimestamp.getTime() + 23 * 60 * 60 * 1e3 + 59 * 60 * 1e3 + 59 * 1e3);
const circuitTimestampEOD = new Date(
circuitTimestamp.getTime() + 23 * 60 * 60 * 1e3 + 59 * 60 * 1e3 + 59 * 1e3
);
const oneDayAgo = new Date(currentTimestamp.getTime() - 24 * 60 * 60 * 1000);
if (circuitTimestampEOD < oneDayAgo) {
issues.push({
Expand Down
Loading