Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
/* istanbul ignore next */
if (!publicKey) {
throw new Error("Internal Error");
}
this.receiverPublicKey = publicKey;
this.create(endpointUrl, callback);
});
return;
}
}
this.endpointUrl = endpointUrl;
const transport = new ClientTCP_transport();
transport.timeout = this.transportTimeout;
this._establish_connection(
transport,
endpointUrl,
(err?: Error) => {
if (err) {
debugLog(chalk.red("cannot connect to server"));
transport.dispose();
return callback(err);
}
this._on_connection(transport, callback);
}
/* istanbul ignore next */
if (err) {
return callback(err);
}
self.receiverPublicKey = publicKey;
assert(!_.isUndefined(self.receiverPublicKey)); // make sure we wont go into infinite recursion calling create again.
self.create(endpointUrl, callback);
});
return;
}
assert(typeof self.receiverPublicKey === "string");
}
self.endpointUrl = endpointUrl;
const transport = new ClientTCP_transport();
transport.timeout = self.transportTimeout;
transport.protocolVersion = self.protocolVersion;
// -------------------------------------------------------------------------
// Handle reconnection
// --------------------------------------------------------------------------
const _establish_connection = function (transport, endpointUrl, callback) {
let last_err = null;
function _connect(_i_callback) {
if (self.__call && self.__call._cancelBackoff) {
return;