feat: cleaner auth state management

1. removes the "auth-state.update" event since it was bloated and fairly unnecessary
2. adds "creds.update" event that only sends the updated properties of the auth credentials
3. ensure the auth creds are not mutated anywhere, but only with the "creds.update" event
4. Separates the signal credentials from the auth credentials (kinda in progress)
5. in memory key store requires a save function to let one know when to save the keys

!BREAKING_CHANGE
This commit is contained in:
Adhiraj Singh
2021-11-20 16:21:56 +05:30
parent c2c27a5dea
commit 3d0704a317
13 changed files with 229 additions and 201 deletions

View File

@@ -16,12 +16,16 @@ export type SignalIdentity = {
export type LTHashState = { version: number, hash: Buffer, mutations: ChatMutation[] }
export type AuthenticationCreds = {
noiseKey: KeyPair
signedIdentityKey: KeyPair
signedPreKey: SignedKeyPair
registrationId: number
advSecretKey: string
export type SignalCreds = {
readonly signedIdentityKey: KeyPair
readonly signedPreKey: SignedKeyPair
readonly registrationId: number
}
export type AuthenticationCreds = SignalCreds & {
readonly noiseKey: KeyPair
readonly advSecretKey: string
me?: Contact
account?: proto.IADVSignedDeviceIdentity
signalIdentities?: SignalIdentity[]
@@ -49,6 +53,11 @@ export type SignalKeyStore = {
setAppStateSyncVersion: (id: WAPatchName, item: LTHashState) => Awaitable<void>
}
export type SignalAuthState = {
creds: SignalCreds
keys: SignalKeyStore
}
export type AuthenticationState = {
creds: AuthenticationCreds
keys: SignalKeyStore