fix(ssss): Strip all whitespace characters from recovery keys upon decode
Previously we stripped all spaces off of the recovery when decoding it, so that we could format the recovery key nicely. It turns out, however, that some element flavours also format with linebreaks, leading to the user having to manually remove them. We fix this by just stripping *all* whitespace off of the recovery key.
This commit is contained in:
parent
faed64cfde
commit
872bc04674
|
|
@ -121,7 +121,7 @@ class SSSS {
|
|||
}
|
||||
|
||||
static Uint8List decodeRecoveryKey(String recoveryKey) {
|
||||
final result = base58.decode(recoveryKey.replaceAll(' ', ''));
|
||||
final result = base58.decode(recoveryKey.replaceAll(RegExp(r'\s'), ''));
|
||||
|
||||
final parity = result.fold<int>(0, (a, b) => a ^ b);
|
||||
if (parity != 0) {
|
||||
|
|
|
|||
|
|
@ -126,7 +126,10 @@ void main() {
|
|||
if (!olmEnabled) return;
|
||||
final key = Uint8List.fromList(secureRandomBytes(32));
|
||||
final encoded = SSSS.encodeRecoveryKey(key);
|
||||
final decoded = SSSS.decodeRecoveryKey(encoded);
|
||||
var decoded = SSSS.decodeRecoveryKey(encoded);
|
||||
expect(key, decoded);
|
||||
|
||||
decoded = SSSS.decodeRecoveryKey(encoded + ' \n\t');
|
||||
expect(key, decoded);
|
||||
|
||||
final handle = client.encryption!.ssss.open();
|
||||
|
|
|
|||
Loading…
Reference in New Issue