diff --git a/src/services/kyc/client.ts b/src/services/kyc/client.ts index 95b63778..43fcef2c 100644 --- a/src/services/kyc/client.ts +++ b/src/services/kyc/client.ts @@ -273,6 +273,22 @@ class KeetaKYCVerification { ...this.request })); } + + /** + * Wait for the certificates to be available, polling at the given interval + * and timing out after the given timeout period. + */ + async waitForCertificates(pollInterval: number = 500, timeout: number = 600000): Promise { + for (const startTime = Date.now(); Date.now() - startTime < timeout; ) { + try { + return(await this.getCertificates()); + } catch (getCertificatesError) { + /* XXX:TODO */ + throw(getCertificatesError); + } + } + throw(new Error('Timeout waiting for KYC certificates')); + } } /**