diff --git a/src/frontend/app/service/signature-method/signature-method-modal.component.ts b/src/frontend/app/service/signature-method/signature-method-modal.component.ts index b51e894b578d1f2b0a1320603cda9a6ff4ec8d2a..649ff2d55696c8fdacc610a35af17e4509e973fb 100644 --- a/src/frontend/app/service/signature-method/signature-method-modal.component.ts +++ b/src/frontend/app/service/signature-method/signature-method-modal.component.ts @@ -81,7 +81,8 @@ export class SignatureMethodModalComponent implements OnInit, OnDestroy { async initFortify() { this.api = new FortifyAPI(null); - await this.api.start(); + await this.waitFortifyStart(); + const challenge = await this.api.challenge(); if (challenge) { @@ -93,6 +94,25 @@ export class SignatureMethodModalComponent implements OnInit, OnDestroy { .on('remove', (event: any) => this.updateProvider(event)); } + async waitFortifyStart() { + let fortifyState: boolean = false; + while (!fortifyState) { + fortifyState = await this.fortifyStart(); + await new Promise(resolve => setTimeout(resolve, 1000)); + } + } + + fortifyStart(): Promise<boolean> { + return new Promise(async (resolve) => { + try { + await this.api.start(); + resolve(true); + } catch (error) { + resolve(false); + } + }); + } + async certificateChosen(certData: any) { this.loadingController.create({ message: this.translate.instant('lang.processing'),