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
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:
committed by
GitHub
parent
0fb3dc1b13
commit
9602aa88ea
@@ -188,7 +188,7 @@ export class EncryptionSetupOperation {
|
|||||||
// We must only call `uploadDeviceSigningKeys` from inside this auth
|
// We must only call `uploadDeviceSigningKeys` from inside this auth
|
||||||
// helper to ensure we properly handle auth errors.
|
// helper to ensure we properly handle auth errors.
|
||||||
await this.crossSigningKeys.authUpload?.((authDict) => {
|
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.
|
// pass the new keys to the main instance of our own CrossSigningInfo.
|
||||||
|
@@ -159,11 +159,12 @@ export class NoAuthFlowFoundError extends Error {
|
|||||||
* The type of an application callback to perform the user-interactive bit of UIA.
|
* 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
|
* 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.
|
* 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> {
|
interface IOpts<T> {
|
||||||
/**
|
/**
|
||||||
|
@@ -116,11 +116,13 @@ export class OutgoingRequestProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const parsedBody = JSON.parse(body);
|
const parsedBody = JSON.parse(body);
|
||||||
const makeRequest = async (auth: IAuthDict): Promise<UIAResponse<T>> => {
|
const makeRequest = async (auth: IAuthDict | null): Promise<UIAResponse<T>> => {
|
||||||
const newBody = {
|
const newBody: Record<string, any> = {
|
||||||
...parsedBody,
|
...parsedBody,
|
||||||
auth,
|
|
||||||
};
|
};
|
||||||
|
if (auth !== null) {
|
||||||
|
newBody.auth = auth;
|
||||||
|
}
|
||||||
const resp = await this.rawJsonRequest(method, path, queryParams, JSON.stringify(newBody));
|
const resp = await this.rawJsonRequest(method, path, queryParams, JSON.stringify(newBody));
|
||||||
return JSON.parse(resp) as T;
|
return JSON.parse(resp) as T;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user