Skip to content

Commit 2c85e75

Browse files
committed
Add option to refreshToken to force /v1 prefix
1 parent a8df2a9 commit 2c85e75

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/client.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,16 @@ export interface IStoredClientOpts extends IStartClientOpts {
468468
canResetEntireTimeline: ResetTimelineCallback;
469469
}
470470

471+
export interface IRefreshTokenOpts {
472+
/**
473+
* If true, forces refreshToken to use `/v1` API prefix instead of correct
474+
* `/v3`. Useful for targeting Synapse before v1.72.
475+
* https://github.com/matrix-org/synapse/pull/14364
476+
* @defaultValue false
477+
*/
478+
forcePrefixV1?: boolean;
479+
}
480+
471481
export enum RoomVersionStability {
472482
Stable = "stable",
473483
Unstable = "unstable",
@@ -7517,14 +7527,14 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
75177527
* @returns Promise which resolves to the new token.
75187528
* @returns Rejects with an error response.
75197529
*/
7520-
public refreshToken(refreshToken: string): Promise<IRefreshTokenResponse> {
7530+
public refreshToken(refreshToken: string, options: IRefreshTokenOpts = {}): Promise<IRefreshTokenResponse> {
75217531
return this.http.authedRequest(
75227532
Method.Post,
75237533
"/refresh",
75247534
undefined,
75257535
{ refresh_token: refreshToken },
75267536
{
7527-
prefix: ClientPrefix.V3,
7537+
prefix: options.forcePrefixV1 ? ClientPrefix.V1 : ClientPrefix.V3,
75287538
inhibitLogoutEmit: true, // we don't want to cause logout loops
75297539
},
75307540
);

0 commit comments

Comments
 (0)