You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-05 00:42:10 +03:00
Fix more typescript --strict violations (#2795)
* Stash tsc fixes * Iterate * Iterate * Iterate * Fix tests * Iterate * Iterate * Iterate * Iterate * Add tests
This commit is contained in:
committed by
GitHub
parent
4b3e6939d6
commit
9f2f08dfd3
@@ -207,15 +207,15 @@ export class InteractiveAuth {
|
||||
private data: IAuthData;
|
||||
private emailSid?: string;
|
||||
private requestingEmailToken = false;
|
||||
private attemptAuthDeferred: IDeferred<IAuthData> = null;
|
||||
private chosenFlow: IFlow = null;
|
||||
private currentStage: string = null;
|
||||
private attemptAuthDeferred: IDeferred<IAuthData> | null = null;
|
||||
private chosenFlow: IFlow | null = null;
|
||||
private currentStage: string | null = null;
|
||||
|
||||
private emailAttempt = 1;
|
||||
|
||||
// if we are currently trying to submit an auth dict (which includes polling)
|
||||
// the promise the will resolve/reject when it completes
|
||||
private submitPromise: Promise<void> = null;
|
||||
private submitPromise: Promise<void> | null = null;
|
||||
|
||||
constructor(opts: IOpts) {
|
||||
this.matrixClient = opts.matrixClient;
|
||||
@@ -229,7 +229,7 @@ export class InteractiveAuth {
|
||||
|
||||
if (opts.sessionId) this.data.session = opts.sessionId;
|
||||
this.clientSecret = opts.clientSecret || this.matrixClient.generateClientSecret();
|
||||
this.emailSid = opts.emailSid ?? null;
|
||||
this.emailSid = opts.emailSid;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -286,7 +286,7 @@ export class InteractiveAuth {
|
||||
client_secret: this.clientSecret,
|
||||
};
|
||||
if (await this.matrixClient.doesServerRequireIdServerParam()) {
|
||||
const idServerParsedUrl = new URL(this.matrixClient.getIdentityServerUrl());
|
||||
const idServerParsedUrl = new URL(this.matrixClient.getIdentityServerUrl()!);
|
||||
creds.id_server = idServerParsedUrl.host;
|
||||
}
|
||||
authDict = {
|
||||
@@ -308,7 +308,7 @@ export class InteractiveAuth {
|
||||
*
|
||||
* @return {string} session id
|
||||
*/
|
||||
public getSessionId(): string {
|
||||
public getSessionId(): string | undefined {
|
||||
return this.data?.session;
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ export class InteractiveAuth {
|
||||
return this.data.params?.[loginType];
|
||||
}
|
||||
|
||||
public getChosenFlow(): IFlow {
|
||||
public getChosenFlow(): IFlow | null {
|
||||
return this.chosenFlow;
|
||||
}
|
||||
|
||||
@@ -399,7 +399,7 @@ export class InteractiveAuth {
|
||||
*
|
||||
* @returns {string} The sid of the email auth session
|
||||
*/
|
||||
public getEmailSid(): string {
|
||||
public getEmailSid(): string | undefined {
|
||||
return this.emailSid;
|
||||
}
|
||||
|
||||
@@ -457,7 +457,7 @@ export class InteractiveAuth {
|
||||
private async doRequest(auth: IAuthData, background = false): Promise<void> {
|
||||
try {
|
||||
const result = await this.requestCallback(auth, background);
|
||||
this.attemptAuthDeferred.resolve(result);
|
||||
this.attemptAuthDeferred!.resolve(result);
|
||||
this.attemptAuthDeferred = null;
|
||||
} catch (error) {
|
||||
// sometimes UI auth errors don't come with flows
|
||||
@@ -491,12 +491,12 @@ export class InteractiveAuth {
|
||||
try {
|
||||
this.startNextAuthStage();
|
||||
} catch (e) {
|
||||
this.attemptAuthDeferred.reject(e);
|
||||
this.attemptAuthDeferred!.reject(e);
|
||||
this.attemptAuthDeferred = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.emailSid && this.chosenFlow.stages.includes(AuthType.Email)) {
|
||||
if (!this.emailSid && this.chosenFlow?.stages.includes(AuthType.Email)) {
|
||||
try {
|
||||
await this.requestEmailToken();
|
||||
// NB. promise is not resolved here - at some point, doRequest
|
||||
@@ -512,7 +512,7 @@ export class InteractiveAuth {
|
||||
// to do) or it could be a network failure. Either way, pass
|
||||
// the failure up as the user can't complete auth if we can't
|
||||
// send the email, for whatever reason.
|
||||
this.attemptAuthDeferred.reject(e);
|
||||
this.attemptAuthDeferred!.reject(e);
|
||||
this.attemptAuthDeferred = null;
|
||||
}
|
||||
}
|
||||
@@ -559,7 +559,7 @@ export class InteractiveAuth {
|
||||
* @return {string?} login type
|
||||
* @throws {NoAuthFlowFoundError} If no suitable authentication flow can be found
|
||||
*/
|
||||
private chooseStage(): AuthType {
|
||||
private chooseStage(): AuthType | undefined {
|
||||
if (this.chosenFlow === null) {
|
||||
this.chosenFlow = this.chooseFlow();
|
||||
}
|
||||
@@ -625,7 +625,7 @@ export class InteractiveAuth {
|
||||
* @param {object} flow
|
||||
* @return {string} login type
|
||||
*/
|
||||
private firstUncompletedStage(flow: IFlow): AuthType {
|
||||
private firstUncompletedStage(flow: IFlow): AuthType | undefined {
|
||||
const completed = this.data.completed || [];
|
||||
for (let i = 0; i < flow.stages.length; ++i) {
|
||||
const stageType = flow.stages[i];
|
||||
|
Reference in New Issue
Block a user