Skip to content

Commit

Permalink
feat: add new api for send a refresh-token
Browse files Browse the repository at this point in the history
  • Loading branch information
guerinoni committed Jan 31, 2024
1 parent d2bf603 commit 1232460
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3263,4 +3263,13 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
async commitMessage(id: string) {
return await this.post<APIResponse & MessageResponse>(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);
}
}
5 changes: 5 additions & 0 deletions src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,4 +622,9 @@ export class StableWSConnection<StreamChatGenerics extends ExtendableGenerics =
}
}, this.connectionCheckTimeout);
};

refreshToken = (token: string) => {
const d = JSON.stringify({ api_key: this.client.key, token });
this.ws?.send(d);
};
}

0 comments on commit 1232460

Please sign in to comment.