1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-06 12:02:40 +03:00

Fix sending auth: null due to broken types around UIA (#3594)

* Fix type issue around `getSessionBackupPrivateKey`

* Fix sending auth: null due to broken types around UIA

* Discard changes to src/crypto/index.ts

* Add comment
This commit is contained in:
Michael Telatynski
2023-07-12 14:55:02 +01:00
committed by GitHub
parent 0fb3dc1b13
commit 9602aa88ea
3 changed files with 9 additions and 6 deletions

View File

@@ -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.

View File

@@ -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<T> = (makeRequest: (authData: IAuthDict) => Promise<UIAResponse<T>>) => Promise<T>;
export type UIAuthCallback<T> = (makeRequest: (authData: IAuthDict | null) => Promise<UIAResponse<T>>) => Promise<T>;
interface IOpts<T> {
/**

View File

@@ -116,11 +116,13 @@ export class OutgoingRequestProcessor {
}
const parsedBody = JSON.parse(body);
const makeRequest = async (auth: IAuthDict): Promise<UIAResponse<T>> => {
const newBody = {
const makeRequest = async (auth: IAuthDict | null): Promise<UIAResponse<T>> => {
const newBody: Record<string, any> = {
...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;
};