mirror of
https://github.com/selfxyz/self.git
synced 2026-04-05 03:00:53 -04:00
Fix nfc configuration scanning issue (#978)
* fix nfc scanning on ios and android * save test * fix tests * fix lint
This commit is contained in:
@@ -200,18 +200,24 @@ const flushMixpanelEvents = async () => {
|
||||
// --- Mixpanel NFC Analytics ---
|
||||
export const configureNfcAnalytics = async () => {
|
||||
if (!MIXPANEL_NFC_PROJECT_TOKEN || mixpanelConfigured) return;
|
||||
const enableDebugLogs = JSON.parse(String(ENABLE_DEBUG_LOGS));
|
||||
if (PassportReader.configure) {
|
||||
await Promise.resolve(
|
||||
PassportReader.configure(MIXPANEL_NFC_PROJECT_TOKEN, enableDebugLogs, {
|
||||
flushInterval: 20,
|
||||
flushCount: 5,
|
||||
flushOnBackground: true,
|
||||
flushOnForeground: true,
|
||||
flushOnNetworkChange: true,
|
||||
}),
|
||||
);
|
||||
const enableDebugLogs =
|
||||
String(ENABLE_DEBUG_LOGS ?? '')
|
||||
.trim()
|
||||
.toLowerCase() === 'true';
|
||||
|
||||
// Check if PassportReader and configure method exist (Android doesn't have configure)
|
||||
if (PassportReader && typeof PassportReader.configure === 'function') {
|
||||
try {
|
||||
// iOS configure method only accepts token and enableDebugLogs
|
||||
// Android doesn't have this method at all
|
||||
await Promise.resolve(
|
||||
PassportReader.configure(MIXPANEL_NFC_PROJECT_TOKEN, enableDebugLogs),
|
||||
);
|
||||
} catch (error) {
|
||||
console.warn('Failed to configure NFC analytics:', error);
|
||||
}
|
||||
}
|
||||
|
||||
setupFlushPolicies();
|
||||
mixpanelConfigured = true;
|
||||
};
|
||||
|
||||
@@ -68,13 +68,17 @@ const scanAndroid = async (inputs: Inputs) => {
|
||||
|
||||
const scanIOS = async (inputs: Inputs) => {
|
||||
return await Promise.resolve(
|
||||
PassportReader.scan({
|
||||
documentNumber: inputs.passportNumber,
|
||||
dateOfBirth: inputs.dateOfBirth,
|
||||
dateOfExpiry: inputs.dateOfExpiry,
|
||||
canNumber: inputs.canNumber ?? '',
|
||||
useCan: inputs.useCan ?? false,
|
||||
}),
|
||||
PassportReader.scanPassport(
|
||||
inputs.passportNumber,
|
||||
inputs.dateOfBirth,
|
||||
inputs.dateOfExpiry,
|
||||
inputs.canNumber ?? '',
|
||||
inputs.useCan ?? false,
|
||||
inputs.skipPACE ?? false,
|
||||
inputs.skipCA ?? false,
|
||||
inputs.extendedMode ?? false,
|
||||
inputs.usePacePolling ?? false,
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -183,6 +183,7 @@ interface ProvingState {
|
||||
endpointType: EndpointType | null;
|
||||
fcmToken: string | null;
|
||||
env: 'prod' | 'stg' | null;
|
||||
selfClient: SelfClient | null;
|
||||
setFcmToken: (token: string) => void;
|
||||
init: (
|
||||
selfClient: SelfClient,
|
||||
@@ -330,6 +331,7 @@ export const useProvingStore = create<ProvingState>((set, get) => {
|
||||
reason: null,
|
||||
endpointType: null,
|
||||
fcmToken: null,
|
||||
selfClient: null,
|
||||
setFcmToken: (token: string) => {
|
||||
set({ fcmToken: token });
|
||||
trackEvent(ProofEvents.FCM_TOKEN_STORED);
|
||||
@@ -632,6 +634,7 @@ export const useProvingStore = create<ProvingState>((set, get) => {
|
||||
circuitType,
|
||||
endpointType: null,
|
||||
env: null,
|
||||
selfClient,
|
||||
});
|
||||
|
||||
actor = createActor(provingMachine);
|
||||
@@ -649,7 +652,7 @@ export const useProvingStore = create<ProvingState>((set, get) => {
|
||||
|
||||
const { data: passportData } = selectedDocument;
|
||||
|
||||
const secret = await selfClient.getPrivateKey();
|
||||
const secret = await get().selfClient?.getPrivateKey();
|
||||
if (!secret) {
|
||||
console.error('Could not load secret');
|
||||
trackEvent(ProofEvents.LOAD_SECRET_FAILED);
|
||||
|
||||
Reference in New Issue
Block a user