41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
![]() |
import { API_BASE_URL } from "./constants";
|
||
|
|
||
|
export interface VerificationResult {
|
||
|
status: string;
|
||
|
citizenshipVerified: boolean;
|
||
|
eligibilityVerified: boolean;
|
||
|
error?: string;
|
||
|
}
|
||
|
|
||
|
export interface VerificationData {
|
||
|
country: string;
|
||
|
userData: {
|
||
|
privadoID?: string;
|
||
|
selfAttestedEligible?: string;
|
||
|
[key: string]: string | undefined;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Verify a user's identity and eligibility
|
||
|
*/
|
||
|
export async function verifyIdentity(data: VerificationData): Promise<VerificationResult> {
|
||
|
try {
|
||
|
const response = await fetch(`${API_BASE_URL}/verify`, {
|
||
|
method: "POST",
|
||
|
headers: {
|
||
|
"Content-Type": "application/json",
|
||
|
},
|
||
|
body: JSON.stringify(data),
|
||
|
});
|
||
|
|
||
|
if (!response.ok) {
|
||
|
throw new Error(`Verification failed: ${response.status}`);
|
||
|
}
|
||
|
|
||
|
return await response.json();
|
||
|
} catch (error) {
|
||
|
console.error("Error verifying identity:", error);
|
||
|
throw error;
|
||
|
}
|
||
|
}
|