mirror of
https://github.com/selfxyz/self.git
synced 2026-02-19 02:24:25 -05:00
[SELF-1891] feat(kyc): Other IDs button (#1660)
* feat(kyc): Other IDs button * trigger sumsub flow directly from event listener * formatting * formatting * add todo * add feature flag --------- Co-authored-by: Justin Hernandez <justin.hernandez@self.xyz>
This commit is contained in:
committed by
GitHub
parent
e0c0c37372
commit
80d9e2d625
@@ -21,19 +21,25 @@ export interface SumsubConfig {
|
||||
const FETCH_TIMEOUT_MS = 30000; // 30 seconds
|
||||
|
||||
export const fetchAccessToken = async (
|
||||
phoneNumber: string,
|
||||
phoneNumber?: string,
|
||||
): Promise<AccessTokenResponse> => {
|
||||
const apiUrl = SUMSUB_TEE_URL;
|
||||
const controller = new AbortController();
|
||||
const timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
||||
|
||||
try {
|
||||
const requestBody: Record<string, string> = {};
|
||||
|
||||
if (phoneNumber) {
|
||||
requestBody.phone = phoneNumber;
|
||||
}
|
||||
|
||||
const response = await fetch(`${apiUrl}/access-token`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ phone: phoneNumber }),
|
||||
body: JSON.stringify(requestBody),
|
||||
signal: controller.signal,
|
||||
});
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
} from '@selfxyz/mobile-sdk-alpha';
|
||||
|
||||
import { logNFCEvent, logProofEvent } from '@/config/sentry';
|
||||
import { fetchAccessToken, launchSumsub } from '@/integrations/sumsub';
|
||||
import type { RootStackParamList } from '@/navigation';
|
||||
import { navigationRef } from '@/navigation';
|
||||
import {
|
||||
@@ -298,6 +299,16 @@ export const SelfClientProvider = ({ children }: PropsWithChildren) => {
|
||||
navigationRef.navigate('AadhaarUpload', { countryCode });
|
||||
}
|
||||
break;
|
||||
case 'kyc':
|
||||
fetchAccessToken()
|
||||
.then(accessToken => {
|
||||
launchSumsub({ accessToken: accessToken.token });
|
||||
})
|
||||
// TODO: show sumsub error screen
|
||||
.catch(error => {
|
||||
console.error('Error launching Sumsub:', error);
|
||||
});
|
||||
break;
|
||||
default:
|
||||
if (countryCode) {
|
||||
navigationRef.navigate('ComingSoon', { countryCode });
|
||||
|
||||
Reference in New Issue
Block a user