diff --git a/lib/src/omemo/sessionmanager.dart b/lib/src/omemo/sessionmanager.dart index 35b2a02..0969790 100644 --- a/lib/src/omemo/sessionmanager.dart +++ b/lib/src/omemo/sessionmanager.dart @@ -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 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)]!;