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

@ -457,6 +457,15 @@ class OmemoSessionManager {
_eventStreamController.add(RatchetModifiedEvent(jid, deviceId, ratchet));
});
}
/// 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
OmemoDoubleRatchet getRatchet(String jid, int deviceId) => _ratchetMap[RatchetMapKey(jid, deviceId)]!;