migrate to Protobuf ES

This commit is contained in:
seavor 2026-04-13 15:03:57 -05:00
parent 68e22d22bf
commit fd55f4fb7f
133 changed files with 1745 additions and 1621 deletions

View file

@ -1,8 +1,13 @@
import { ForgotPasswordResetParams } from 'store';
import { StatusEnum, WebSocketConnectOptions } from 'types';
import { create } from '@bufbuild/protobuf';
import type { MessageInitShape } from '@bufbuild/protobuf';
import webClient from '../../WebClient';
import { BackendService } from '../../services/BackendService';
import {
Command_ForgotPasswordReset_ext, Command_ForgotPasswordResetSchema,
} from 'generated/proto/session_commands_pb';
import { SessionPersistence } from '../../persistence';
import { hashPassword } from '../../utils';
@ -11,19 +16,16 @@ import { disconnect, updateStatus } from '.';
export function forgotPasswordReset(options: WebSocketConnectOptions, newPassword?: string, passwordSalt?: string): void {
const { userName, token } = options as unknown as ForgotPasswordResetParams;
const params: any = {
const params: MessageInitShape<typeof Command_ForgotPasswordResetSchema> = {
...webClient.clientConfig,
userName,
token,
...(passwordSalt
? { hashedNewPassword: hashPassword(passwordSalt, newPassword) }
: { newPassword }),
};
if (passwordSalt) {
params.hashedNewPassword = hashPassword(passwordSalt, newPassword);
} else {
params.newPassword = newPassword;
}
BackendService.sendSessionCommand('Command_ForgotPasswordReset', params, {
BackendService.sendSessionCommand(Command_ForgotPasswordReset_ext, create(Command_ForgotPasswordResetSchema, params), {
onSuccess: () => {
updateStatus(StatusEnum.DISCONNECTED, null);
SessionPersistence.resetPasswordSuccess();