-
Notifications
You must be signed in to change notification settings - Fork 180
move fcm token storage #1175
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
move fcm token storage #1175
Changes from 2 commits
1fe5c8d
4854d6f
3afb31d
77b85dc
369d9d3
7478477
e5522cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |
| import { unsafe_getPrivateKey } from '@/providers/authProvider'; | ||
| import { selfClientDocumentsAdapter } from '@/providers/passportDataProvider'; | ||
| import { logNFCEvent, logProofEvent } from '@/Sentry'; | ||
| import { useSettingStore } from '@/stores/settingStore'; | ||
| import analytics from '@/utils/analytics'; | ||
|
|
||
| type GlobalCrypto = { crypto?: { subtle?: Crypto['subtle'] } }; | ||
|
|
@@ -147,7 +148,7 @@ | |
| navigationRef.navigate('UnsupportedDocument', { | ||
| countryCode, | ||
| documentCategory, | ||
| } as any); | ||
|
Check warning on line 151 in app/src/providers/selfClientProvider.tsx
|
||
| } | ||
| }, | ||
| ); | ||
|
|
@@ -158,6 +159,35 @@ | |
| } | ||
| }); | ||
|
|
||
| addListener( | ||
| SdkEvents.PROVING_BEGIN_GENERATION, | ||
| async ({ uuid, isMock, context }) => { | ||
| const { fcmToken } = useSettingStore.getState(); | ||
|
|
||
| if (fcmToken) { | ||
| try { | ||
| adapters.analytics?.trackEvent('DEVICE_TOKEN_REG_STARTED'); | ||
| logProofEvent('info', 'Device token registration started', context); | ||
|
|
||
| const { registerDeviceToken: registerFirebaseDeviceToken } = | ||
| await import('@/utils/notifications/notificationService'); | ||
| await registerFirebaseDeviceToken(uuid, fcmToken, isMock); | ||
|
|
||
| adapters.analytics?.trackEvent('DEVICE_TOKEN_REG_SUCCESS'); | ||
| logProofEvent('info', 'Device token registration success', context); | ||
| } catch (error) { | ||
| logProofEvent('warn', 'Device token registration failed', context, { | ||
| error: error instanceof Error ? error.message : String(error), | ||
| }); | ||
| console.error('Error registering device token:', error); | ||
| adapters.analytics?.trackEvent('DEVICE_TOKEN_REG_FAILED', { | ||
| message: error instanceof Error ? error.message : String(error), | ||
| }); | ||
| } | ||
| } | ||
| }, | ||
| ); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: FCM Token Registration Race ConditionsThe FCM token registration, now an async Additional Locations (1)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the proving flow doesnt need the notification for completion
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the token will be there.... trust me |
||
|
|
||
| addListener(SdkEvents.PROOF_EVENT, ({ level, context, event, details }) => { | ||
| // Log proof events for monitoring/debugging | ||
| logProofEvent(level, event, context, details); | ||
|
|
@@ -169,7 +199,7 @@ | |
| }); | ||
|
|
||
| return map; | ||
| }, []); | ||
|
Check warning on line 202 in app/src/providers/selfClientProvider.tsx
|
||
|
|
||
| return ( | ||
| <SDKSelfClientProvider | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential sensitive data exposure in error logging.
The
console.errorstatement logs the raw error object, which could potentially contain sensitive information such as tokens, API responses, or PII depending on what theregisterFirebaseDeviceTokenfunction might throw.Consider sanitizing the error before logging:
The error details are already captured in the analytics event and
logProofEventcall, so the console.error can be simplified to avoid potential data leakage.As per coding guidelines: Never log sensitive data including credentials, tokens, API keys, or private keys.
📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aaronmgdr Understood, I'll leave the logging as-is. Thanks for clarifying!
🧠 Learnings used