You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-06 12:02:40 +03:00
Improve types around User Interactive Auth (#4709)
* Remove confused type UIAResponse Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update uia.ts --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
committed by
GitHub
parent
a1a0463229
commit
f11e1910f5
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { type AuthDict, type IAuthData } from "../interactive-auth.ts";
|
||||
import { type AuthDict } from "../interactive-auth.ts";
|
||||
|
||||
/**
|
||||
* Helper type to represent HTTP request body for a UIA enabled endpoint
|
||||
@@ -25,5 +25,6 @@ export type UIARequest<T> = T & {
|
||||
|
||||
/**
|
||||
* Helper type to represent HTTP response body for a UIA enabled endpoint
|
||||
* @deprecated - a successful response for a UIA enabled endpoint is no different, UIA is signalled via an error
|
||||
*/
|
||||
export type UIAResponse<T> = T | IAuthData;
|
||||
export type UIAResponse<T> = T;
|
||||
|
@@ -209,7 +209,7 @@ import { NamespacedValue, UnstableValue } from "./NamespacedValue.ts";
|
||||
import { ToDeviceMessageQueue } from "./ToDeviceMessageQueue.ts";
|
||||
import { type ToDeviceBatch } from "./models/ToDeviceMessage.ts";
|
||||
import { IgnoredInvites } from "./models/invites-ignorer.ts";
|
||||
import { type UIARequest, type UIAResponse } from "./@types/uia.ts";
|
||||
import { type UIARequest } from "./@types/uia.ts";
|
||||
import { type LocalNotificationSettings } from "./@types/local_notifications.ts";
|
||||
import { buildFeatureSupportMap, Feature, ServerSupport } from "./feature.ts";
|
||||
import { type CryptoBackend } from "./common-crypto/CryptoBackend.ts";
|
||||
@@ -6363,9 +6363,9 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
||||
* @returns Promise which resolves: On success, the token response
|
||||
* or UIA auth data.
|
||||
*/
|
||||
public async requestLoginToken(auth?: AuthDict): Promise<UIAResponse<LoginTokenPostResponse>> {
|
||||
public async requestLoginToken(auth?: AuthDict): Promise<LoginTokenPostResponse> {
|
||||
const body: UIARequest<unknown> = { auth };
|
||||
return this.http.authedRequest<UIAResponse<LoginTokenPostResponse>>(
|
||||
return this.http.authedRequest<LoginTokenPostResponse>(
|
||||
Method.Post,
|
||||
"/login/get_token",
|
||||
undefined, // no query params
|
||||
|
@@ -20,7 +20,6 @@ import { logger } from "./logger.ts";
|
||||
import { type MatrixClient } from "./client.ts";
|
||||
import { defer, type IDeferred } from "./utils.ts";
|
||||
import { MatrixError } from "./http-api/index.ts";
|
||||
import { type UIAResponse } from "./@types/uia.ts";
|
||||
import { type UserIdentifier } from "./@types/auth.ts";
|
||||
|
||||
const EMAIL_STAGE_TYPE = "m.login.email.identity";
|
||||
@@ -159,7 +158,7 @@ export class NoAuthFlowFoundError extends Error {
|
||||
*
|
||||
* The generic parameter `T` is the type of the response of the endpoint, once it is eventually successful.
|
||||
*/
|
||||
export type UIAuthCallback<T> = (makeRequest: (authData: AuthDict | null) => Promise<UIAResponse<T>>) => Promise<T>;
|
||||
export type UIAuthCallback<T> = (makeRequest: (authData: AuthDict | null) => Promise<T>) => Promise<T>;
|
||||
|
||||
interface IOpts<T> {
|
||||
/**
|
||||
|
@@ -31,7 +31,6 @@ import { logger } from "../logger.ts";
|
||||
import { calculateRetryBackoff, type IHttpOpts, type MatrixHttpApi, Method } from "../http-api/index.ts";
|
||||
import { logDuration, type QueryDict, sleep } from "../utils.ts";
|
||||
import { type AuthDict, type UIAuthCallback } from "../interactive-auth.ts";
|
||||
import { type UIAResponse } from "../@types/uia.ts";
|
||||
import { ToDeviceMessageId } from "../@types/event.ts";
|
||||
import { UnstablePrefix as DehydrationUnstablePrefix } from "./DehydratedDeviceManager.ts";
|
||||
|
||||
@@ -176,7 +175,7 @@ export class OutgoingRequestProcessor {
|
||||
}
|
||||
|
||||
const parsedBody = JSON.parse(body);
|
||||
const makeRequest = async (auth: AuthDict | null): Promise<UIAResponse<T>> => {
|
||||
const makeRequest = async (auth: AuthDict | null): Promise<T> => {
|
||||
const newBody: Record<string, any> = {
|
||||
...parsedBody,
|
||||
};
|
||||
|
Reference in New Issue
Block a user