You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
Remove deprecated support for unstable MSC3882 (#3755)
* Support for stable MSC3882 get_login_token * Make changes non-breaking by deprecation * Remove deprecated exports from MSC3882 stabilisation * Feat remove support for unstable MSC3882 * Remove bad line from rebase
This commit is contained in:
@@ -536,21 +536,11 @@ export interface IThreadsCapability extends ICapability {}
|
||||
|
||||
export interface IGetLoginTokenCapability extends ICapability {}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link IGetLoginTokenCapability} instead
|
||||
*/
|
||||
export type IMSC3882GetLoginTokenCapability = IGetLoginTokenCapability;
|
||||
|
||||
export const GET_LOGIN_TOKEN_CAPABILITY = new NamespacedValue(
|
||||
"m.get_login_token",
|
||||
"org.matrix.msc3882.get_login_token",
|
||||
);
|
||||
|
||||
/**
|
||||
* @deprecated use {@link GET_LOGIN_TOKEN_CAPABILITY} instead
|
||||
*/
|
||||
export const UNSTABLE_MSC3882_CAPABILITY = GET_LOGIN_TOKEN_CAPABILITY;
|
||||
|
||||
export const UNSTABLE_MSC2666_SHARED_ROOMS = "uk.half-shot.msc2666";
|
||||
export const UNSTABLE_MSC2666_MUTUAL_ROOMS = "uk.half-shot.msc2666.mutual_rooms";
|
||||
export const UNSTABLE_MSC2666_QUERY_MUTUAL_ROOMS = "uk.half-shot.msc2666.query_mutual_rooms";
|
||||
@@ -8045,50 +8035,23 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
||||
|
||||
/**
|
||||
* Make a request for an `m.login.token` to be issued as per
|
||||
* [MSC3882](https://github.com/matrix-org/matrix-spec-proposals/pull/3882).
|
||||
* The server may require User-Interactive auth.
|
||||
* https://spec.matrix.org/v1.7/client-server-api/#post_matrixclientv1loginget_token
|
||||
*
|
||||
* Compatibility with unstable implementations of MSC3882 is deprecated and will be removed in a future release.
|
||||
* The server may require User-Interactive auth.
|
||||
*
|
||||
* @param auth - Optional. Auth data to supply for User-Interactive auth.
|
||||
* @returns Promise which resolves: On success, the token response
|
||||
* or UIA auth data.
|
||||
*/
|
||||
public async requestLoginToken(auth?: AuthDict): Promise<UIAResponse<LoginTokenPostResponse>> {
|
||||
// use capabilities to determine which revision of the MSC is being used
|
||||
const capabilities = await this.getCapabilities();
|
||||
|
||||
let endpoint: string;
|
||||
if (capabilities[GET_LOGIN_TOKEN_CAPABILITY.name]) {
|
||||
// use the stable endpoint
|
||||
endpoint = `${ClientPrefix.V1}/login/get_token`;
|
||||
} else if (capabilities[GET_LOGIN_TOKEN_CAPABILITY.altName!]) {
|
||||
// newer unstable r1 endpoint
|
||||
endpoint = `${ClientPrefix.Unstable}/org.matrix.msc3882/login/get_token`;
|
||||
} else {
|
||||
// old unstable r0 endpoint
|
||||
endpoint = `${ClientPrefix.Unstable}/org.matrix.msc3882/login/token`;
|
||||
}
|
||||
|
||||
const body: UIARequest<{}> = { auth };
|
||||
const res = await this.http.authedRequest<UIAResponse<LoginTokenPostResponse>>(
|
||||
return this.http.authedRequest<UIAResponse<LoginTokenPostResponse>>(
|
||||
Method.Post,
|
||||
endpoint,
|
||||
"/login/get_token",
|
||||
undefined, // no query params
|
||||
body,
|
||||
{ prefix: "" },
|
||||
{ prefix: ClientPrefix.V1 },
|
||||
);
|
||||
|
||||
// the representation of expires_in changed from unstable revision 0 to unstable revision 1 so we cross populate
|
||||
if ("login_token" in res) {
|
||||
if (typeof res.expires_in_ms === "number") {
|
||||
res.expires_in = Math.floor(res.expires_in_ms / 1000);
|
||||
} else if (typeof res.expires_in === "number") {
|
||||
res.expires_in_ms = res.expires_in * 1000;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user