Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(websocket): we can only allow subscribe short names for public su…
…bscriptions since need wallet
  • Loading branch information
bradennapier committed Sep 1, 2020
1 parent 8f924b2 commit 767a567
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/client/webSocket/index.ts
Expand Up @@ -204,7 +204,7 @@ export class WebSocketClient {
public subscribe(
subscriptions: Array<
| types.AuthTokenWebSocketRequestSubscription
| types.WebSocketRequestSubscribeShortNames
| types.WebSocketRequestUnauthenticatedSubscription['name']
>,
markets?: string[],
cid?: string,
Expand Down Expand Up @@ -273,7 +273,7 @@ export class WebSocketClient {
private async subscribeRequest(
subscriptions: Array<
| types.AuthTokenWebSocketRequestSubscription
| types.WebSocketRequestSubscribeShortNames
| types.WebSocketRequestUnauthenticatedSubscription['name']
>,
markets?: string[],
cid?: string,
Expand Down Expand Up @@ -496,7 +496,7 @@ export class WebSocketClient {
// types
function isPublicSubscription(
subscription:
| types.WebSocketRequestSubscribeShortNames
| types.WebSocketRequestUnauthenticatedSubscription['name']
| types.WebSocketRequestSubscription,
): boolean {
return !isWebSocketAuthenticatedSubscription(subscription);
Expand Down
8 changes: 5 additions & 3 deletions src/client/webSocket/tokenManager.ts
@@ -1,6 +1,6 @@
import {
WebSocketRequestSubscription,
WebSocketRequestSubscribeShortNames,
WebSocketRequestUnauthenticatedSubscription,
} from '../../types';

type TokenValue = {
Expand Down Expand Up @@ -83,9 +83,11 @@ export default class WebsocketTokenManager {
*/
export const removeWalletFromSdkSubscription = (
subscription:
| WebSocketRequestSubscribeShortNames
| WebSocketRequestUnauthenticatedSubscription['name']
| (WebSocketRequestSubscription & { wallet?: string }),
): WebSocketRequestSubscribeShortNames | WebSocketRequestSubscription => {
):
| WebSocketRequestUnauthenticatedSubscription['name']
| WebSocketRequestSubscription => {
if (typeof subscription === 'string') {
return subscription;
}
Expand Down
2 changes: 1 addition & 1 deletion src/types/webSocket/request.ts
Expand Up @@ -166,7 +166,7 @@ export type WebSocketRequestSubscribe = {
subscriptions: Array<
| WebSocketRequestUnauthenticatedSubscription
| WebSocketRequestAuthenticatedSubscription
| WebSocketRequestSubscribeShortNames
| WebSocketRequestUnauthenticatedSubscription['name']
>;
};

Expand Down

0 comments on commit 767a567

Please sign in to comment.