Skip to content

Commit 5f32b3f

Browse files
author
Kerry Archibald
committed
improve types
1 parent 6ab8cc4 commit 5f32b3f

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/autodiscovery.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,18 @@ enum AutoDiscoveryError {
4848
InvalidJson = "Invalid JSON",
4949
}
5050

51-
interface WellKnownConfig extends Omit<IWellKnownConfig, "error"> {
52-
state: AutoDiscoveryAction;
53-
error?: IWellKnownConfig["error"] | null;
54-
}
55-
interface DelegatedAuthConfig extends IDelegatedAuthConfig, ValidatedIssuerConfig {
51+
interface AutoDiscoveryState {
5652
state: AutoDiscoveryAction;
5753
error?: IWellKnownConfig["error"] | null;
5854
}
55+
interface WellKnownConfig extends Omit<IWellKnownConfig, "error">, AutoDiscoveryState {}
56+
57+
interface DelegatedAuthConfig extends IDelegatedAuthConfig, ValidatedIssuerConfig, AutoDiscoveryState {}
5958

6059
export interface ClientConfig extends Omit<IClientWellKnown, "m.homeserver" | "m.identity_server"> {
6160
"m.homeserver": WellKnownConfig;
6261
"m.identity_server": WellKnownConfig;
63-
"m.authentication"?: DelegatedAuthConfig;
62+
"m.authentication"?: DelegatedAuthConfig | AutoDiscoveryState;
6463
}
6564

6665
/**
@@ -276,7 +275,7 @@ export class AutoDiscovery {
276275

277276
public static async validateDiscoveryAuthenticationConfig(
278277
wellKnown: IClientWellKnown,
279-
): Promise<DelegatedAuthConfig> {
278+
): Promise<DelegatedAuthConfig | AutoDiscoveryState> {
280279
try {
281280
const homeserverAuthenticationConfig = validateWellKnownAuthentication(wellKnown);
282281

@@ -310,11 +309,10 @@ export class AutoDiscovery {
310309
? AutoDiscoveryAction.IGNORE
311310
: AutoDiscoveryAction.FAIL_ERROR;
312311

313-
// @TODO(kerrya) better way to handle this fail type
314312
return {
315313
state,
316314
error: errorType,
317-
} as unknown as DelegatedAuthConfig;
315+
};
318316
}
319317
}
320318

0 commit comments

Comments
 (0)