diff --git a/src/client.ts b/src/client.ts index 690100192..ca3e4b126 100644 --- a/src/client.ts +++ b/src/client.ts @@ -3263,4 +3263,13 @@ export class StreamChat(this.baseURL + `/messages/${id}/commit`); } + + /** + * send over a WS the new token to the server, from server you would expect `token.ack` event in case of success. + * @param token the new token + * + */ + refreshToken(token: string) { + return this.wsConnection?.refreshToken(token); + } } diff --git a/src/connection.ts b/src/connection.ts index d567bdb56..23c33af31 100644 --- a/src/connection.ts +++ b/src/connection.ts @@ -622,4 +622,9 @@ export class StableWSConnection { + const d = JSON.stringify({ api_key: this.client.key, token }); + this.ws?.send(d); + }; }