diff --git a/src/crypto/EncryptionSetup.ts b/src/crypto/EncryptionSetup.ts index b8f52fcdc..2c8384467 100644 --- a/src/crypto/EncryptionSetup.ts +++ b/src/crypto/EncryptionSetup.ts @@ -188,7 +188,7 @@ export class EncryptionSetupOperation { // We must only call `uploadDeviceSigningKeys` from inside this auth // helper to ensure we properly handle auth errors. await this.crossSigningKeys.authUpload?.((authDict) => { - return baseApis.uploadDeviceSigningKeys(authDict, keys as CrossSigningKeys); + return baseApis.uploadDeviceSigningKeys(authDict ?? undefined, keys as CrossSigningKeys); }); // pass the new keys to the main instance of our own CrossSigningInfo. diff --git a/src/interactive-auth.ts b/src/interactive-auth.ts index e85ac9c27..0a75ab523 100644 --- a/src/interactive-auth.ts +++ b/src/interactive-auth.ts @@ -159,11 +159,12 @@ export class NoAuthFlowFoundError extends Error { * The type of an application callback to perform the user-interactive bit of UIA. * * It is called with a single parameter, `makeRequest`, which is a function which takes the UIA parameters and - * makes the HTTP request. + * makes the HTTP request. The `authData` parameter in `makeRequest` can be set to null to omit the `auth` field + * from the UIA request. * * The generic parameter `T` is the type of the response of the endpoint, once it is eventually successful. */ -export type UIAuthCallback = (makeRequest: (authData: IAuthDict) => Promise>) => Promise; +export type UIAuthCallback = (makeRequest: (authData: IAuthDict | null) => Promise>) => Promise; interface IOpts { /** diff --git a/src/rust-crypto/OutgoingRequestProcessor.ts b/src/rust-crypto/OutgoingRequestProcessor.ts index 20c0b93fa..213f8dd84 100644 --- a/src/rust-crypto/OutgoingRequestProcessor.ts +++ b/src/rust-crypto/OutgoingRequestProcessor.ts @@ -116,11 +116,13 @@ export class OutgoingRequestProcessor { } const parsedBody = JSON.parse(body); - const makeRequest = async (auth: IAuthDict): Promise> => { - const newBody = { + const makeRequest = async (auth: IAuthDict | null): Promise> => { + const newBody: Record = { ...parsedBody, - auth, }; + if (auth !== null) { + newBody.auth = auth; + } const resp = await this.rawJsonRequest(method, path, queryParams, JSON.stringify(newBody)); return JSON.parse(resp) as T; };