confirmCode endpoint shouldn't reconnect socket
This commit is contained in:
parent
f048066693
commit
c68fd3d727
5 changed files with 34 additions and 59 deletions
|
@ -686,6 +686,7 @@ const URL_CALLS = {
|
|||
const WEBSOCKET_CALLS = new Set<keyof typeof URL_CALLS>([
|
||||
// MessageController
|
||||
'messages',
|
||||
'multiRecipient',
|
||||
'reportMessage',
|
||||
|
||||
// ProfileController
|
||||
|
@ -710,9 +711,6 @@ const WEBSOCKET_CALLS = new Set<keyof typeof URL_CALLS>([
|
|||
'directoryAuth',
|
||||
|
||||
// Storage
|
||||
'storageManifest',
|
||||
'storageModify',
|
||||
'storageRead',
|
||||
'storageToken',
|
||||
]);
|
||||
|
||||
|
@ -819,7 +817,7 @@ export type WebAPIType = {
|
|||
newPassword: string,
|
||||
registrationId: number,
|
||||
deviceName?: string | null,
|
||||
options?: { accessKey?: ArrayBuffer }
|
||||
options?: { accessKey?: ArrayBuffer; uuid?: string }
|
||||
) => Promise<any>;
|
||||
createGroup: (
|
||||
group: Proto.IGroup,
|
||||
|
@ -1490,7 +1488,7 @@ export function initialize({
|
|||
newPassword: string,
|
||||
registrationId: number,
|
||||
deviceName?: string | null,
|
||||
options: { accessKey?: ArrayBuffer } = {}
|
||||
options: { accessKey?: ArrayBuffer; uuid?: string } = {}
|
||||
) {
|
||||
const capabilities: CapabilitiesUploadType = {
|
||||
announcementGroup: true,
|
||||
|
@ -1499,7 +1497,7 @@ export function initialize({
|
|||
senderKey: true,
|
||||
};
|
||||
|
||||
const { accessKey } = options;
|
||||
const { accessKey, uuid } = options;
|
||||
const jsonData: any = {
|
||||
capabilities,
|
||||
fetchesMessages: true,
|
||||
|
@ -1515,21 +1513,29 @@ export function initialize({
|
|||
const call = deviceName ? 'devices' : 'accounts';
|
||||
const urlPrefix = deviceName ? '/' : '/code/';
|
||||
|
||||
// Reset old websocket credentials and disconnect.
|
||||
// AccountManager is our only caller and it will trigger
|
||||
// `registration_done` which will update credentials.
|
||||
await socketManager.authenticate({
|
||||
username: '',
|
||||
password: '',
|
||||
});
|
||||
|
||||
// Update REST credentials, though. We need them for the call below
|
||||
username = number;
|
||||
password = newPassword;
|
||||
|
||||
const response = await _ajax({
|
||||
call,
|
||||
httpType: 'PUT',
|
||||
responseType: 'json',
|
||||
urlParameters: urlPrefix + code,
|
||||
jsonData,
|
||||
username: number,
|
||||
password: newPassword,
|
||||
});
|
||||
|
||||
// From here on out, our username will be our UUID or E164 combined with device
|
||||
await authenticate({
|
||||
username: `${response.uuid || number}.${response.deviceId || 1}`,
|
||||
password,
|
||||
});
|
||||
// Set final REST credentials to let `registerKeys` succeed.
|
||||
username = `${uuid || response.uuid || number}.${response.deviceId || 1}`;
|
||||
password = newPassword;
|
||||
|
||||
return response;
|
||||
}
|
||||
|
@ -1792,6 +1798,7 @@ export function initialize({
|
|||
data,
|
||||
urlParameters: `?ts=${timestamp}&online=${online ? 'true' : 'false'}`,
|
||||
responseType: 'json',
|
||||
unauthenticated: true,
|
||||
headers: {
|
||||
'Unidentified-Access-Key': arrayBufferToBase64(accessKeys),
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue