lib/extension/identity/authorization.js
/**
   * Dispatch authorization request
   * @param {number} timeout
   */
Dispatch authorization request
@param {number} timeout
Dispatch authorization request @param { number } timeout
async dispatch(timeout = AuthorizationRequest.DEFAULT_TIMEOUT) {
    await this.send();
    try {
      const { token, counter } = await this.request.dispatch(timeout);
      debug('authorization:approved', token, counter);
      if (this.identity.connection.verify(token, counter)) {
        await this.request.accept();
        debug('authorization:accepted', token, counter);
      } else {
        const reason = 'Invalid OTP token';
        await this.request.decline(reason);
        throw new AuthorizationFailedError(
          AuthorizationRequest.State.DECLINED,
          reason,
        );
      }
    } catch (e) {
      if (e instanceof OperationTimedOutError) {
        await this.request.cancel();
        e = new AuthorizationFailedError(
          AuthorizationRequest.State.CANCELED,
          'Operation canceled by platform',
        );
      }
      debug('authorization:error', e);
      throw e;
    }
    return this.request;
  }
async dispatch ( timeout = AuthorizationRequest . DEFAULT_TIMEOUT ) { await this . send ( ) ; try { const { token , counter } = await this . request . dispatch ( timeout ) ; debug ( 'authorization:approved' , token , counter ) ; if ( this . identity . connection . verify ( token , counter ) ) { await this . request . accept ( ) ; debug ( 'authorization:accepted' , token , counter ) ; } else { const reason = 'Invalid OTP token' ; await this . request . decline ( reason ) ; throw new AuthorizationFailedError ( AuthorizationRequest . State . DECLINED , reason , ) ; } } catch ( e ) { if ( e instanceof OperationTimedOutError ) { await this . request . cancel ( ) ; e = new AuthorizationFailedError ( AuthorizationRequest . State . CANCELED , 'Operation canceled by platform' , ) ; } debug ( 'authorization:error' , e ) ; throw e ; } return this . request ; }
Dispatch authorization request
 @param {number} timeout
Dispatch authorization request @param { number } timeout
// @todo cover edge case