Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
connect(accessToken: string, shapeshiftAccessToken?: string) {
this.stop();
this.tokens = {
accessToken,
shapeshiftAccessToken,
};
try {
this.apiConfig = buildAPIConfig(accessToken);
if (!!shapeshiftAccessToken
&& shapeshiftAccessToken !== '') {
this.apiConfig.headers = {
...this.apiConfig.headers,
token: shapeshiftAccessToken,
};
}
const wsUrl = EXCHANGE_URL
.replace(/(https:\/\/)/gi, 'wss://')
.replace(/(http:\/\/)/gi, 'ws://');
this.io = new SocketIO(`${wsUrl}:443`, {
transports: ['websocket'],
query: {
token: accessToken,
},
});
this.io.on('disconnect', () => {
this.setConnected(false);
});
this.io.on('error', () => {
this.setConnected(false);
});
this.io.on('connect', () => {