parent
784e5254e2
commit
23046f08a9
8 changed files with 448 additions and 36 deletions
|
|
@ -12,9 +12,23 @@ class const ClientState({
|
|||
required final String? userId,
|
||||
required final String? deviceId,
|
||||
required final String? homeserverUrl,
|
||||
final VerificationState verificationState = const .new(),
|
||||
}) with _$ClientState {
|
||||
Map<String, Object?> toJson() => _$ClientStateToJson(this);
|
||||
|
||||
factory ClientState.fromJson(Map<String, Object?> json) =>
|
||||
_$ClientStateFromJson(json);
|
||||
}
|
||||
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const VerificationState({
|
||||
final bool stateChecked = false,
|
||||
final bool hasCrossSigning = false,
|
||||
@JsonKey(name: "has_ssss") final bool hasSecretStorage = false,
|
||||
}) with _$VerificationState {
|
||||
Map<String, Object?> toJson() => _$VerificationStateToJson(this);
|
||||
|
||||
factory VerificationState.fromJson(Map<String, Object?> json) =>
|
||||
_$VerificationStateFromJson(json);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,12 @@ class GomuksException implements Exception {
|
|||
String? get errorCode =>
|
||||
RegExp(r"^(M_[A-Z_]+)").firstMatch(message)?.group(1);
|
||||
|
||||
/// The HTTP status code of the failed request
|
||||
int? get statusCode => switch (RegExp(r"HTTP (\d{3})").firstMatch(message)) {
|
||||
final match? => int.parse(match.group(1)!),
|
||||
null => null,
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() => message;
|
||||
}
|
||||
|
|
|
|||
19
lib/models/recovery_key.dart
Normal file
19
lib/models/recovery_key.dart
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
|
||||
part "recovery_key.freezed.dart";
|
||||
part "recovery_key.g.dart";
|
||||
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable(includeIfNull: false)
|
||||
class const RecoveryKey({
|
||||
required final String recoveryKey,
|
||||
|
||||
required final IMap<String, dynamic> crossSigningKeys,
|
||||
final IMap<String, dynamic>? passphraseMeta,
|
||||
}) with _$RecoveryKey {
|
||||
Map<String, Object?> toJson() => _$RecoveryKeyToJson(this);
|
||||
|
||||
factory RecoveryKey.fromJson(Map<String, Object?> json) =>
|
||||
_$RecoveryKeyFromJson(json);
|
||||
}
|
||||
Loading…
Reference in a new issue