lib/SafeNet.js
/**
   * Create a connection to WebSocket
   * @private
   */
Create a connection to WebSocket
@private
Create a connection to WebSocket @private
async _connect() {
    const options = this[PRIVATE_FIELDS];
    this._terminated(false);
    const retryResolver = await (0, _asyncRetry.default)(async bail => {
      try {
        if (options.terminator.terminated) return;
        this._incrementRetry();
        this._setTerminatorResolver(bail);
        const ws = await (0, _utils.createSocket)(options.endpoint);
        this._setSocket(ws);
        this._emitConnectEvent(ws);
        ws.addEventListener('close', () => {
          this._setSocket(null);
          this._terminated();
        });
        return ws;
      } catch (error) {
        if (options.retry.count >= options.retry.limit) {
          this.terminate(new Error('Failed to communicate with eToken device.'));
          return;
        }
        throw error;
      }
    }, {
      retry: options.retry.limit,
      onRetry: () => {
        this._emitRetryEvent(options.terminator.resolver);
      }
    });
    return retryResolver;
  }
async _connect ( ) { const options = this [ PRIVATE_FIELDS ] ; this . _terminated ( false ) ; const retryResolver = await ( 0 , _asyncRetry . default ) ( async bail => { try { if ( options . terminator . terminated ) return ; this . _incrementRetry ( ) ; this . _setTerminatorResolver ( bail ) ; const ws = await ( 0 , _utils . createSocket ) ( options . endpoint ) ; this . _setSocket ( ws ) ; this . _emitConnectEvent ( ws ) ; ws . addEventListener ( 'close' , ( ) => { this . _setSocket ( null ) ; this . _terminated ( ) ; } ) ; return ws ; } catch ( error ) { if ( options . retry . count >= options . retry . limit ) { this . terminate ( new Error ( 'Failed to communicate with eToken device.' ) ) ; return ; } throw error ; } } , { retry : options . retry . limit , onRetry : ( ) => { this . _emitRetryEvent ( options . terminator . resolver ) ; } } ) ; return retryResolver ; }
Create a connection to WebSocket
 @private
Create a connection to WebSocket @private