feat: Allow regenerating one's device identity

This commit is contained in:
PapaTutuWawa 2022-08-18 15:02:17 +02:00
parent fda06cef55
commit 0a03483aaf

View File

@ -458,6 +458,15 @@ class OmemoSessionManager {
}); });
} }
/// Generates an entirely new device. May be useful when the user wants to reset their cryptographic
/// identity. Triggers an event to commit it to storage.
Future<void> regenerateDevice({ int opkAmount = 100 }) async {
await _deviceLock.synchronized(() async {
_device = await Device.generateNewDevice(_device.jid, opkAmount: opkAmount);
_eventStreamController.add(DeviceModifiedEvent(_device));
});
}
@visibleForTesting @visibleForTesting
OmemoDoubleRatchet getRatchet(String jid, int deviceId) => _ratchetMap[RatchetMapKey(jid, deviceId)]!; OmemoDoubleRatchet getRatchet(String jid, int deviceId) => _ratchetMap[RatchetMapKey(jid, deviceId)]!;