Deprecate Keys.storageService sync field

This commit is contained in:
Fedor Indutny 2024-11-12 11:36:58 -08:00 committed by GitHub
parent 8772880ca1
commit fbf39a36fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 5 additions and 26 deletions

View file

@ -498,14 +498,14 @@ message SyncMessage {
BLOCKED = 3; BLOCKED = 3;
CONFIGURATION = 4; CONFIGURATION = 4;
KEYS = 5; KEYS = 5;
PNI_IDENTITY = 6; reserved /* PNI_IDENTITY */ 6;
} }
optional Type type = 1; optional Type type = 1;
} }
message Keys { message Keys {
optional bytes storageService = 1; // deprecated: this field will be removed in a future release. reserved /* storageService */ 1; // deprecated: this field will be removed in a future release.
optional bytes master = 2; // deprecated: this field will be removed in a future release. optional bytes master = 2; // deprecated: this field will be removed in a future release.
optional string accountEntropyPool = 3; optional string accountEntropyPool = 3;
optional bytes mediaRootBackupKey = 4; optional bytes mediaRootBackupKey = 4;

View file

@ -3276,7 +3276,6 @@ export async function startApp(): Promise<void> {
ev.confirm(); ev.confirm();
const { accountEntropyPool, masterKey, mediaRootBackupKey } = ev; const { accountEntropyPool, masterKey, mediaRootBackupKey } = ev;
let { storageServiceKey } = ev;
const prevMasterKeyBase64 = window.storage.get('masterKey'); const prevMasterKeyBase64 = window.storage.get('masterKey');
const prevMasterKey = prevMasterKeyBase64 const prevMasterKey = prevMasterKeyBase64
@ -3314,7 +3313,6 @@ export async function startApp(): Promise<void> {
log.info('onKeysSync: updating masterKey'); log.info('onKeysSync: updating masterKey');
} }
// Override provided storageServiceKey because it is deprecated. // Override provided storageServiceKey because it is deprecated.
storageServiceKey = deriveStorageServiceKey(derivedMasterKey);
await window.storage.put('masterKey', Bytes.toBase64(derivedMasterKey)); await window.storage.put('masterKey', Bytes.toBase64(derivedMasterKey));
} }
@ -3331,12 +3329,8 @@ export async function startApp(): Promise<void> {
await window.storage.put('backupMediaRootKey', mediaRootBackupKey); await window.storage.put('backupMediaRootKey', mediaRootBackupKey);
} }
if (storageServiceKey == null) { if (derivedMasterKey != null) {
log.warn('onKeysSync: deleting window.storageKey'); const storageServiceKey = deriveStorageServiceKey(derivedMasterKey);
await window.storage.remove('storageKey');
}
if (storageServiceKey) {
const storageServiceKeyBase64 = Bytes.toBase64(storageServiceKey); const storageServiceKeyBase64 = Bytes.toBase64(storageServiceKey);
if (window.storage.get('storageKey') === storageServiceKeyBase64) { if (window.storage.get('storageKey') === storageServiceKeyBase64) {
log.info( log.info(

View file

@ -3363,15 +3363,8 @@ export default class MessageReceiver
logUnexpectedUrgentValue(envelope, 'keySync'); logUnexpectedUrgentValue(envelope, 'keySync');
if (!sync.storageService && !sync.master) {
return undefined;
}
const ev = new KeysEvent( const ev = new KeysEvent(
{ {
storageServiceKey: Bytes.isNotEmpty(sync.storageService)
? sync.storageService
: undefined,
masterKey: Bytes.isNotEmpty(sync.master) ? sync.master : undefined, masterKey: Bytes.isNotEmpty(sync.master) ? sync.master : undefined,
accountEntropyPool: sync.accountEntropyPool || undefined, accountEntropyPool: sync.accountEntropyPool || undefined,
mediaRootBackupKey: Bytes.isNotEmpty(sync.mediaRootBackupKey) mediaRootBackupKey: Bytes.isNotEmpty(sync.mediaRootBackupKey)

View file

@ -389,30 +389,22 @@ export class FetchLatestEvent extends ConfirmableEvent {
} }
export type KeysEventData = Readonly<{ export type KeysEventData = Readonly<{
storageServiceKey: Uint8Array | undefined;
masterKey: Uint8Array | undefined; masterKey: Uint8Array | undefined;
accountEntropyPool: string | undefined; accountEntropyPool: string | undefined;
mediaRootBackupKey: Uint8Array | undefined; mediaRootBackupKey: Uint8Array | undefined;
}>; }>;
export class KeysEvent extends ConfirmableEvent { export class KeysEvent extends ConfirmableEvent {
public readonly storageServiceKey: Uint8Array | undefined;
public readonly masterKey: Uint8Array | undefined; public readonly masterKey: Uint8Array | undefined;
public readonly accountEntropyPool: string | undefined; public readonly accountEntropyPool: string | undefined;
public readonly mediaRootBackupKey: Uint8Array | undefined; public readonly mediaRootBackupKey: Uint8Array | undefined;
constructor( constructor(
{ { masterKey, accountEntropyPool, mediaRootBackupKey }: KeysEventData,
storageServiceKey,
masterKey,
accountEntropyPool,
mediaRootBackupKey,
}: KeysEventData,
confirm: ConfirmCallback confirm: ConfirmCallback
) { ) {
super('keys', confirm); super('keys', confirm);
this.storageServiceKey = storageServiceKey;
this.masterKey = masterKey; this.masterKey = masterKey;
this.accountEntropyPool = accountEntropyPool; this.accountEntropyPool = accountEntropyPool;
this.mediaRootBackupKey = mediaRootBackupKey; this.mediaRootBackupKey = mediaRootBackupKey;