@@ -281,40 +281,44 @@ export class HcaptchaProvider extends Provider {
281281 handleOnCompleted (
282282 details : chrome . webRequest . WebResponseHeadersDetails ,
283283 ) : void {
284- this . sendIssueRequest ( details . requestId ) ;
284+ this . triggerIssueRequest ( details . requestId ) ;
285285 }
286286
287287 handleOnErrorOccurred (
288288 details : chrome . webRequest . WebResponseErrorDetails ,
289289 ) : void {
290- this . sendIssueRequest ( details . requestId ) ;
290+ this . triggerIssueRequest ( details . requestId ) ;
291291 }
292292
293- private async sendIssueRequest ( requestId : string ) : Promise < void > {
294- // Is the completed request a trigger to initiate a secondary request to the provider for the issuing of signed tokens?
293+ private triggerIssueRequest ( requestId : string ) : void {
294+ // Is the current ( completed) request a trigger to initiate a secondary request to the provider for the issuing of signed tokens?
295295 if (
296296 ( this . issueInfo !== null ) &&
297297 ( this . issueInfo . requestId === requestId )
298298 ) {
299- try {
300- const url : string = this . issueInfo ! . url ;
299+ const url : string = this . issueInfo ! . url ;
301300
302- // Clear the issue info.
303- this . issueInfo = null ;
301+ // Clear the issue info.
302+ this . issueInfo = null ;
304303
305- // Issue tokens.
306- const tokens = await this . issue ( url ) ;
304+ this . sendIssueRequest ( url ) ;
305+ }
306+ }
307307
308- // Store tokens.
309- const cached = this . getStoredTokens ( ) ;
310- this . setStoredTokens ( cached . concat ( tokens ) ) ;
311- }
312- catch ( error : any ) {
313- console . error ( error . message ) ;
314- }
308+ private async sendIssueRequest ( url : string ) : Promise < void > {
309+ try {
310+ // Issue tokens.
311+ const tokens = await this . issue ( url ) ;
315312
316- this . callbacks . navigateUrl ( HcaptchaProvider . EARNED_TOKEN_COOKIE . url ) ;
313+ // Store tokens.
314+ const cached = this . getStoredTokens ( ) ;
315+ this . setStoredTokens ( cached . concat ( tokens ) ) ;
316+ }
317+ catch ( error : any ) {
318+ console . error ( error . message ) ;
317319 }
320+
321+ this . callbacks . navigateUrl ( HcaptchaProvider . EARNED_TOKEN_COOKIE . url ) ;
318322 }
319323
320324 private async issue ( url : string ) : Promise < Token [ ] > {
0 commit comments