From ae2fb3b3031ecc1e5bf529a9f08c15ad13b1f11a Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 14 Aug 2025 02:10:21 +0800 Subject: [PATCH] :alien: Support new authorized device --- lib/models/{user.dart => account.dart} | 38 +- ...user.freezed.dart => account.freezed.dart} | 568 +++++++++++++++++- lib/models/{user.g.dart => account.g.dart} | 53 +- lib/models/activity.dart | 2 +- lib/models/auth.dart | 18 - lib/models/auth.freezed.dart | 322 +--------- lib/models/auth.g.dart | 27 - lib/models/chat.dart | 2 +- lib/models/custom_app.dart | 2 +- lib/models/publisher.dart | 2 +- lib/models/realm.dart | 2 +- lib/models/relationship.dart | 2 +- lib/models/wallet.dart | 2 +- lib/pods/userinfo.dart | 2 +- lib/screens/account/me/settings.dart | 4 +- lib/screens/account/me/settings_contacts.dart | 2 +- lib/screens/account/me/update.dart | 2 +- lib/screens/account/profile.dart | 2 +- lib/screens/notification.dart | 2 +- lib/screens/posts/pub_profile.dart | 2 +- lib/services/notify.dart | 4 +- ...ession_sheet.dart => account_devices.dart} | 39 +- ...on_sheet.g.dart => account_devices.g.dart} | 9 +- lib/widgets/account/account_name.dart | 2 +- lib/widgets/account/account_picker.dart | 2 +- lib/widgets/account/badge.dart | 2 +- lib/widgets/account/status.dart | 2 +- lib/widgets/account/status_creation.dart | 2 +- lib/widgets/app_notification.dart | 2 +- pubspec.lock | 42 +- pubspec.yaml | 8 +- 31 files changed, 745 insertions(+), 425 deletions(-) rename lib/models/{user.dart => account.dart} (82%) rename lib/models/{user.freezed.dart => account.freezed.dart} (82%) rename lib/models/{user.g.dart => account.g.dart} (86%) rename lib/widgets/account/{account_session_sheet.dart => account_devices.dart} (86%) rename lib/widgets/account/{account_session_sheet.g.dart => account_devices.g.dart} (75%) diff --git a/lib/models/user.dart b/lib/models/account.dart similarity index 82% rename from lib/models/user.dart rename to lib/models/account.dart index 3ae76fc1..0ed1a09b 100644 --- a/lib/models/user.dart +++ b/lib/models/account.dart @@ -1,9 +1,10 @@ import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:island/models/auth.dart'; import 'package:island/models/file.dart'; import 'package:island/models/wallet.dart'; -part 'user.freezed.dart'; -part 'user.g.dart'; +part 'account.freezed.dart'; +part 'account.g.dart'; @freezed sealed class SnAccount with _$SnAccount { @@ -174,3 +175,36 @@ sealed class SnVerificationMark with _$SnVerificationMark { factory SnVerificationMark.fromJson(Map json) => _$SnVerificationMarkFromJson(json); } + +@freezed +sealed class SnAuthDevice with _$SnAuthDevice { + const factory SnAuthDevice({ + required String id, + required String deviceId, + required String deviceName, + required String? deviceLabel, + required String accountId, + required int platform, + @Default(false) bool isCurrent, + }) = _SnAuthDevice; + + factory SnAuthDevice.fromJson(Map json) => + _$SnAuthDeviceFromJson(json); +} + +@freezed +sealed class SnAuthDeviceWithChallenge with _$SnAuthDeviceWithChallenge { + const factory SnAuthDeviceWithChallenge({ + required String id, + required String deviceId, + required String deviceName, + required String? deviceLabel, + required String accountId, + required int platform, + required List challenges, + @Default(false) bool isCurrent, + }) = _SnAuthDeviceWithChallengee; + + factory SnAuthDeviceWithChallenge.fromJson(Map json) => + _$SnAuthDeviceWithChallengeFromJson(json); +} diff --git a/lib/models/user.freezed.dart b/lib/models/account.freezed.dart similarity index 82% rename from lib/models/user.freezed.dart rename to lib/models/account.freezed.dart index 6d43b05b..42d6b900 100644 --- a/lib/models/user.freezed.dart +++ b/lib/models/account.freezed.dart @@ -3,7 +3,7 @@ // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark -part of 'user.dart'; +part of 'account.dart'; // ************************************************************************** // FreezedGenerator @@ -2452,6 +2452,572 @@ as String?, } +} + + +/// @nodoc +mixin _$SnAuthDevice { + + String get id; String get deviceId; String get deviceName; String? get deviceLabel; String get accountId; int get platform; bool get isCurrent; +/// Create a copy of SnAuthDevice +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$SnAuthDeviceCopyWith get copyWith => _$SnAuthDeviceCopyWithImpl(this as SnAuthDevice, _$identity); + + /// Serializes this SnAuthDevice to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is SnAuthDevice&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceId, deviceId) || other.deviceId == deviceId)&&(identical(other.deviceName, deviceName) || other.deviceName == deviceName)&&(identical(other.deviceLabel, deviceLabel) || other.deviceLabel == deviceLabel)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(identical(other.platform, platform) || other.platform == platform)&&(identical(other.isCurrent, isCurrent) || other.isCurrent == isCurrent)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,deviceId,deviceName,deviceLabel,accountId,platform,isCurrent); + +@override +String toString() { + return 'SnAuthDevice(id: $id, deviceId: $deviceId, deviceName: $deviceName, deviceLabel: $deviceLabel, accountId: $accountId, platform: $platform, isCurrent: $isCurrent)'; +} + + +} + +/// @nodoc +abstract mixin class $SnAuthDeviceCopyWith<$Res> { + factory $SnAuthDeviceCopyWith(SnAuthDevice value, $Res Function(SnAuthDevice) _then) = _$SnAuthDeviceCopyWithImpl; +@useResult +$Res call({ + String id, String deviceId, String deviceName, String? deviceLabel, String accountId, int platform, bool isCurrent +}); + + + + +} +/// @nodoc +class _$SnAuthDeviceCopyWithImpl<$Res> + implements $SnAuthDeviceCopyWith<$Res> { + _$SnAuthDeviceCopyWithImpl(this._self, this._then); + + final SnAuthDevice _self; + final $Res Function(SnAuthDevice) _then; + +/// Create a copy of SnAuthDevice +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? deviceId = null,Object? deviceName = null,Object? deviceLabel = freezed,Object? accountId = null,Object? platform = null,Object? isCurrent = null,}) { + return _then(_self.copyWith( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,deviceId: null == deviceId ? _self.deviceId : deviceId // ignore: cast_nullable_to_non_nullable +as String,deviceName: null == deviceName ? _self.deviceName : deviceName // ignore: cast_nullable_to_non_nullable +as String,deviceLabel: freezed == deviceLabel ? _self.deviceLabel : deviceLabel // ignore: cast_nullable_to_non_nullable +as String?,accountId: null == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable +as String,platform: null == platform ? _self.platform : platform // ignore: cast_nullable_to_non_nullable +as int,isCurrent: null == isCurrent ? _self.isCurrent : isCurrent // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +} + + +/// Adds pattern-matching-related methods to [SnAuthDevice]. +extension SnAuthDevicePatterns on SnAuthDevice { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _SnAuthDevice value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _SnAuthDevice() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _SnAuthDevice value) $default,){ +final _that = this; +switch (_that) { +case _SnAuthDevice(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _SnAuthDevice value)? $default,){ +final _that = this; +switch (_that) { +case _SnAuthDevice() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String id, String deviceId, String deviceName, String? deviceLabel, String accountId, int platform, bool isCurrent)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _SnAuthDevice() when $default != null: +return $default(_that.id,_that.deviceId,_that.deviceName,_that.deviceLabel,_that.accountId,_that.platform,_that.isCurrent);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String id, String deviceId, String deviceName, String? deviceLabel, String accountId, int platform, bool isCurrent) $default,) {final _that = this; +switch (_that) { +case _SnAuthDevice(): +return $default(_that.id,_that.deviceId,_that.deviceName,_that.deviceLabel,_that.accountId,_that.platform,_that.isCurrent);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String id, String deviceId, String deviceName, String? deviceLabel, String accountId, int platform, bool isCurrent)? $default,) {final _that = this; +switch (_that) { +case _SnAuthDevice() when $default != null: +return $default(_that.id,_that.deviceId,_that.deviceName,_that.deviceLabel,_that.accountId,_that.platform,_that.isCurrent);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _SnAuthDevice implements SnAuthDevice { + const _SnAuthDevice({required this.id, required this.deviceId, required this.deviceName, required this.deviceLabel, required this.accountId, required this.platform, this.isCurrent = false}); + factory _SnAuthDevice.fromJson(Map json) => _$SnAuthDeviceFromJson(json); + +@override final String id; +@override final String deviceId; +@override final String deviceName; +@override final String? deviceLabel; +@override final String accountId; +@override final int platform; +@override@JsonKey() final bool isCurrent; + +/// Create a copy of SnAuthDevice +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$SnAuthDeviceCopyWith<_SnAuthDevice> get copyWith => __$SnAuthDeviceCopyWithImpl<_SnAuthDevice>(this, _$identity); + +@override +Map toJson() { + return _$SnAuthDeviceToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnAuthDevice&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceId, deviceId) || other.deviceId == deviceId)&&(identical(other.deviceName, deviceName) || other.deviceName == deviceName)&&(identical(other.deviceLabel, deviceLabel) || other.deviceLabel == deviceLabel)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(identical(other.platform, platform) || other.platform == platform)&&(identical(other.isCurrent, isCurrent) || other.isCurrent == isCurrent)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,deviceId,deviceName,deviceLabel,accountId,platform,isCurrent); + +@override +String toString() { + return 'SnAuthDevice(id: $id, deviceId: $deviceId, deviceName: $deviceName, deviceLabel: $deviceLabel, accountId: $accountId, platform: $platform, isCurrent: $isCurrent)'; +} + + +} + +/// @nodoc +abstract mixin class _$SnAuthDeviceCopyWith<$Res> implements $SnAuthDeviceCopyWith<$Res> { + factory _$SnAuthDeviceCopyWith(_SnAuthDevice value, $Res Function(_SnAuthDevice) _then) = __$SnAuthDeviceCopyWithImpl; +@override @useResult +$Res call({ + String id, String deviceId, String deviceName, String? deviceLabel, String accountId, int platform, bool isCurrent +}); + + + + +} +/// @nodoc +class __$SnAuthDeviceCopyWithImpl<$Res> + implements _$SnAuthDeviceCopyWith<$Res> { + __$SnAuthDeviceCopyWithImpl(this._self, this._then); + + final _SnAuthDevice _self; + final $Res Function(_SnAuthDevice) _then; + +/// Create a copy of SnAuthDevice +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? deviceId = null,Object? deviceName = null,Object? deviceLabel = freezed,Object? accountId = null,Object? platform = null,Object? isCurrent = null,}) { + return _then(_SnAuthDevice( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,deviceId: null == deviceId ? _self.deviceId : deviceId // ignore: cast_nullable_to_non_nullable +as String,deviceName: null == deviceName ? _self.deviceName : deviceName // ignore: cast_nullable_to_non_nullable +as String,deviceLabel: freezed == deviceLabel ? _self.deviceLabel : deviceLabel // ignore: cast_nullable_to_non_nullable +as String?,accountId: null == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable +as String,platform: null == platform ? _self.platform : platform // ignore: cast_nullable_to_non_nullable +as int,isCurrent: null == isCurrent ? _self.isCurrent : isCurrent // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + +} + +SnAuthDeviceWithChallenge _$SnAuthDeviceWithChallengeFromJson( + Map json +) { + return _SnAuthDeviceWithChallengee.fromJson( + json + ); +} + +/// @nodoc +mixin _$SnAuthDeviceWithChallenge { + + String get id; String get deviceId; String get deviceName; String? get deviceLabel; String get accountId; int get platform; List get challenges; bool get isCurrent; +/// Create a copy of SnAuthDeviceWithChallenge +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$SnAuthDeviceWithChallengeCopyWith get copyWith => _$SnAuthDeviceWithChallengeCopyWithImpl(this as SnAuthDeviceWithChallenge, _$identity); + + /// Serializes this SnAuthDeviceWithChallenge to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is SnAuthDeviceWithChallenge&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceId, deviceId) || other.deviceId == deviceId)&&(identical(other.deviceName, deviceName) || other.deviceName == deviceName)&&(identical(other.deviceLabel, deviceLabel) || other.deviceLabel == deviceLabel)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(identical(other.platform, platform) || other.platform == platform)&&const DeepCollectionEquality().equals(other.challenges, challenges)&&(identical(other.isCurrent, isCurrent) || other.isCurrent == isCurrent)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,deviceId,deviceName,deviceLabel,accountId,platform,const DeepCollectionEquality().hash(challenges),isCurrent); + +@override +String toString() { + return 'SnAuthDeviceWithChallenge(id: $id, deviceId: $deviceId, deviceName: $deviceName, deviceLabel: $deviceLabel, accountId: $accountId, platform: $platform, challenges: $challenges, isCurrent: $isCurrent)'; +} + + +} + +/// @nodoc +abstract mixin class $SnAuthDeviceWithChallengeCopyWith<$Res> { + factory $SnAuthDeviceWithChallengeCopyWith(SnAuthDeviceWithChallenge value, $Res Function(SnAuthDeviceWithChallenge) _then) = _$SnAuthDeviceWithChallengeCopyWithImpl; +@useResult +$Res call({ + String id, String deviceId, String deviceName, String? deviceLabel, String accountId, int platform, List challenges, bool isCurrent +}); + + + + +} +/// @nodoc +class _$SnAuthDeviceWithChallengeCopyWithImpl<$Res> + implements $SnAuthDeviceWithChallengeCopyWith<$Res> { + _$SnAuthDeviceWithChallengeCopyWithImpl(this._self, this._then); + + final SnAuthDeviceWithChallenge _self; + final $Res Function(SnAuthDeviceWithChallenge) _then; + +/// Create a copy of SnAuthDeviceWithChallenge +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? deviceId = null,Object? deviceName = null,Object? deviceLabel = freezed,Object? accountId = null,Object? platform = null,Object? challenges = null,Object? isCurrent = null,}) { + return _then(_self.copyWith( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,deviceId: null == deviceId ? _self.deviceId : deviceId // ignore: cast_nullable_to_non_nullable +as String,deviceName: null == deviceName ? _self.deviceName : deviceName // ignore: cast_nullable_to_non_nullable +as String,deviceLabel: freezed == deviceLabel ? _self.deviceLabel : deviceLabel // ignore: cast_nullable_to_non_nullable +as String?,accountId: null == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable +as String,platform: null == platform ? _self.platform : platform // ignore: cast_nullable_to_non_nullable +as int,challenges: null == challenges ? _self.challenges : challenges // ignore: cast_nullable_to_non_nullable +as List,isCurrent: null == isCurrent ? _self.isCurrent : isCurrent // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +} + + +/// Adds pattern-matching-related methods to [SnAuthDeviceWithChallenge]. +extension SnAuthDeviceWithChallengePatterns on SnAuthDeviceWithChallenge { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _SnAuthDeviceWithChallengee value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _SnAuthDeviceWithChallengee() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _SnAuthDeviceWithChallengee value) $default,){ +final _that = this; +switch (_that) { +case _SnAuthDeviceWithChallengee(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _SnAuthDeviceWithChallengee value)? $default,){ +final _that = this; +switch (_that) { +case _SnAuthDeviceWithChallengee() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String id, String deviceId, String deviceName, String? deviceLabel, String accountId, int platform, List challenges, bool isCurrent)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _SnAuthDeviceWithChallengee() when $default != null: +return $default(_that.id,_that.deviceId,_that.deviceName,_that.deviceLabel,_that.accountId,_that.platform,_that.challenges,_that.isCurrent);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String id, String deviceId, String deviceName, String? deviceLabel, String accountId, int platform, List challenges, bool isCurrent) $default,) {final _that = this; +switch (_that) { +case _SnAuthDeviceWithChallengee(): +return $default(_that.id,_that.deviceId,_that.deviceName,_that.deviceLabel,_that.accountId,_that.platform,_that.challenges,_that.isCurrent);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String id, String deviceId, String deviceName, String? deviceLabel, String accountId, int platform, List challenges, bool isCurrent)? $default,) {final _that = this; +switch (_that) { +case _SnAuthDeviceWithChallengee() when $default != null: +return $default(_that.id,_that.deviceId,_that.deviceName,_that.deviceLabel,_that.accountId,_that.platform,_that.challenges,_that.isCurrent);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _SnAuthDeviceWithChallengee implements SnAuthDeviceWithChallenge { + const _SnAuthDeviceWithChallengee({required this.id, required this.deviceId, required this.deviceName, required this.deviceLabel, required this.accountId, required this.platform, required final List challenges, this.isCurrent = false}): _challenges = challenges; + factory _SnAuthDeviceWithChallengee.fromJson(Map json) => _$SnAuthDeviceWithChallengeeFromJson(json); + +@override final String id; +@override final String deviceId; +@override final String deviceName; +@override final String? deviceLabel; +@override final String accountId; +@override final int platform; + final List _challenges; +@override List get challenges { + if (_challenges is EqualUnmodifiableListView) return _challenges; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_challenges); +} + +@override@JsonKey() final bool isCurrent; + +/// Create a copy of SnAuthDeviceWithChallenge +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$SnAuthDeviceWithChallengeeCopyWith<_SnAuthDeviceWithChallengee> get copyWith => __$SnAuthDeviceWithChallengeeCopyWithImpl<_SnAuthDeviceWithChallengee>(this, _$identity); + +@override +Map toJson() { + return _$SnAuthDeviceWithChallengeeToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnAuthDeviceWithChallengee&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceId, deviceId) || other.deviceId == deviceId)&&(identical(other.deviceName, deviceName) || other.deviceName == deviceName)&&(identical(other.deviceLabel, deviceLabel) || other.deviceLabel == deviceLabel)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(identical(other.platform, platform) || other.platform == platform)&&const DeepCollectionEquality().equals(other._challenges, _challenges)&&(identical(other.isCurrent, isCurrent) || other.isCurrent == isCurrent)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,deviceId,deviceName,deviceLabel,accountId,platform,const DeepCollectionEquality().hash(_challenges),isCurrent); + +@override +String toString() { + return 'SnAuthDeviceWithChallenge(id: $id, deviceId: $deviceId, deviceName: $deviceName, deviceLabel: $deviceLabel, accountId: $accountId, platform: $platform, challenges: $challenges, isCurrent: $isCurrent)'; +} + + +} + +/// @nodoc +abstract mixin class _$SnAuthDeviceWithChallengeeCopyWith<$Res> implements $SnAuthDeviceWithChallengeCopyWith<$Res> { + factory _$SnAuthDeviceWithChallengeeCopyWith(_SnAuthDeviceWithChallengee value, $Res Function(_SnAuthDeviceWithChallengee) _then) = __$SnAuthDeviceWithChallengeeCopyWithImpl; +@override @useResult +$Res call({ + String id, String deviceId, String deviceName, String? deviceLabel, String accountId, int platform, List challenges, bool isCurrent +}); + + + + +} +/// @nodoc +class __$SnAuthDeviceWithChallengeeCopyWithImpl<$Res> + implements _$SnAuthDeviceWithChallengeeCopyWith<$Res> { + __$SnAuthDeviceWithChallengeeCopyWithImpl(this._self, this._then); + + final _SnAuthDeviceWithChallengee _self; + final $Res Function(_SnAuthDeviceWithChallengee) _then; + +/// Create a copy of SnAuthDeviceWithChallenge +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? deviceId = null,Object? deviceName = null,Object? deviceLabel = freezed,Object? accountId = null,Object? platform = null,Object? challenges = null,Object? isCurrent = null,}) { + return _then(_SnAuthDeviceWithChallengee( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,deviceId: null == deviceId ? _self.deviceId : deviceId // ignore: cast_nullable_to_non_nullable +as String,deviceName: null == deviceName ? _self.deviceName : deviceName // ignore: cast_nullable_to_non_nullable +as String,deviceLabel: freezed == deviceLabel ? _self.deviceLabel : deviceLabel // ignore: cast_nullable_to_non_nullable +as String?,accountId: null == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable +as String,platform: null == platform ? _self.platform : platform // ignore: cast_nullable_to_non_nullable +as int,challenges: null == challenges ? _self._challenges : challenges // ignore: cast_nullable_to_non_nullable +as List,isCurrent: null == isCurrent ? _self.isCurrent : isCurrent // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + } // dart format on diff --git a/lib/models/user.g.dart b/lib/models/account.g.dart similarity index 86% rename from lib/models/user.g.dart rename to lib/models/account.g.dart index 7a00d193..d14e51bd 100644 --- a/lib/models/user.g.dart +++ b/lib/models/account.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'user.dart'; +part of 'account.dart'; // ************************************************************************** // JsonSerializableGenerator @@ -297,3 +297,54 @@ Map _$SnVerificationMarkToJson(_SnVerificationMark instance) => 'description': instance.description, 'verified_by': instance.verifiedBy, }; + +_SnAuthDevice _$SnAuthDeviceFromJson(Map json) => + _SnAuthDevice( + id: json['id'] as String, + deviceId: json['device_id'] as String, + deviceName: json['device_name'] as String, + deviceLabel: json['device_label'] as String?, + accountId: json['account_id'] as String, + platform: (json['platform'] as num).toInt(), + isCurrent: json['is_current'] as bool? ?? false, + ); + +Map _$SnAuthDeviceToJson(_SnAuthDevice instance) => + { + 'id': instance.id, + 'device_id': instance.deviceId, + 'device_name': instance.deviceName, + 'device_label': instance.deviceLabel, + 'account_id': instance.accountId, + 'platform': instance.platform, + 'is_current': instance.isCurrent, + }; + +_SnAuthDeviceWithChallengee _$SnAuthDeviceWithChallengeeFromJson( + Map json, +) => _SnAuthDeviceWithChallengee( + id: json['id'] as String, + deviceId: json['device_id'] as String, + deviceName: json['device_name'] as String, + deviceLabel: json['device_label'] as String?, + accountId: json['account_id'] as String, + platform: (json['platform'] as num).toInt(), + challenges: + (json['challenges'] as List) + .map((e) => SnAuthChallenge.fromJson(e as Map)) + .toList(), + isCurrent: json['is_current'] as bool? ?? false, +); + +Map _$SnAuthDeviceWithChallengeeToJson( + _SnAuthDeviceWithChallengee instance, +) => { + 'id': instance.id, + 'device_id': instance.deviceId, + 'device_name': instance.deviceName, + 'device_label': instance.deviceLabel, + 'account_id': instance.accountId, + 'platform': instance.platform, + 'challenges': instance.challenges.map((e) => e.toJson()).toList(), + 'is_current': instance.isCurrent, +}; diff --git a/lib/models/activity.dart b/lib/models/activity.dart index c4f1d0e8..b870aa53 100644 --- a/lib/models/activity.dart +++ b/lib/models/activity.dart @@ -1,5 +1,5 @@ import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:island/models/user.dart'; +import 'package:island/models/account.dart'; part 'activity.freezed.dart'; part 'activity.g.dart'; diff --git a/lib/models/auth.dart b/lib/models/auth.dart index 77281a3f..197cd570 100644 --- a/lib/models/auth.dart +++ b/lib/models/auth.dart @@ -19,14 +19,12 @@ sealed class SnAuthChallenge with _$SnAuthChallenge { required int stepRemain, required int stepTotal, required int failedAttempts, - required int platform, required int type, required List blacklistFactors, required List audiences, required List scopes, required String ipAddress, required String userAgent, - required String deviceId, required String? nonce, required String? location, required String accountId, @@ -76,22 +74,6 @@ sealed class SnAuthFactor with _$SnAuthFactor { _$SnAuthFactorFromJson(json); } -@freezed -sealed class SnAuthDevice with _$SnAuthDevice { - const factory SnAuthDevice({ - required dynamic label, - required String userAgent, - required String deviceId, - required int platform, - required List sessions, - // Not from backend, used for UI - @Default(false) bool isCurrent, - }) = _SnAuthDevice; - - factory SnAuthDevice.fromJson(Map json) => - _$SnAuthDeviceFromJson(json); -} - @freezed sealed class SnAccountConnection with _$SnAccountConnection { const factory SnAccountConnection({ diff --git a/lib/models/auth.freezed.dart b/lib/models/auth.freezed.dart index 903d3f99..74365c69 100644 --- a/lib/models/auth.freezed.dart +++ b/lib/models/auth.freezed.dart @@ -272,7 +272,7 @@ as String, /// @nodoc mixin _$SnAuthChallenge { - String get id; DateTime get expiredAt; int get stepRemain; int get stepTotal; int get failedAttempts; int get platform; int get type; List get blacklistFactors; List get audiences; List get scopes; String get ipAddress; String get userAgent; String get deviceId; String? get nonce; String? get location; String get accountId; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; + String get id; DateTime get expiredAt; int get stepRemain; int get stepTotal; int get failedAttempts; int get type; List get blacklistFactors; List get audiences; List get scopes; String get ipAddress; String get userAgent; String? get nonce; String? get location; String get accountId; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt; /// Create a copy of SnAuthChallenge /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -285,16 +285,16 @@ $SnAuthChallengeCopyWith get copyWith => _$SnAuthChallengeCopyW @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is SnAuthChallenge&&(identical(other.id, id) || other.id == id)&&(identical(other.expiredAt, expiredAt) || other.expiredAt == expiredAt)&&(identical(other.stepRemain, stepRemain) || other.stepRemain == stepRemain)&&(identical(other.stepTotal, stepTotal) || other.stepTotal == stepTotal)&&(identical(other.failedAttempts, failedAttempts) || other.failedAttempts == failedAttempts)&&(identical(other.platform, platform) || other.platform == platform)&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other.blacklistFactors, blacklistFactors)&&const DeepCollectionEquality().equals(other.audiences, audiences)&&const DeepCollectionEquality().equals(other.scopes, scopes)&&(identical(other.ipAddress, ipAddress) || other.ipAddress == ipAddress)&&(identical(other.userAgent, userAgent) || other.userAgent == userAgent)&&(identical(other.deviceId, deviceId) || other.deviceId == deviceId)&&(identical(other.nonce, nonce) || other.nonce == nonce)&&(identical(other.location, location) || other.location == location)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is SnAuthChallenge&&(identical(other.id, id) || other.id == id)&&(identical(other.expiredAt, expiredAt) || other.expiredAt == expiredAt)&&(identical(other.stepRemain, stepRemain) || other.stepRemain == stepRemain)&&(identical(other.stepTotal, stepTotal) || other.stepTotal == stepTotal)&&(identical(other.failedAttempts, failedAttempts) || other.failedAttempts == failedAttempts)&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other.blacklistFactors, blacklistFactors)&&const DeepCollectionEquality().equals(other.audiences, audiences)&&const DeepCollectionEquality().equals(other.scopes, scopes)&&(identical(other.ipAddress, ipAddress) || other.ipAddress == ipAddress)&&(identical(other.userAgent, userAgent) || other.userAgent == userAgent)&&(identical(other.nonce, nonce) || other.nonce == nonce)&&(identical(other.location, location) || other.location == location)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hashAll([runtimeType,id,expiredAt,stepRemain,stepTotal,failedAttempts,platform,type,const DeepCollectionEquality().hash(blacklistFactors),const DeepCollectionEquality().hash(audiences),const DeepCollectionEquality().hash(scopes),ipAddress,userAgent,deviceId,nonce,location,accountId,createdAt,updatedAt,deletedAt]); +int get hashCode => Object.hash(runtimeType,id,expiredAt,stepRemain,stepTotal,failedAttempts,type,const DeepCollectionEquality().hash(blacklistFactors),const DeepCollectionEquality().hash(audiences),const DeepCollectionEquality().hash(scopes),ipAddress,userAgent,nonce,location,accountId,createdAt,updatedAt,deletedAt); @override String toString() { - return 'SnAuthChallenge(id: $id, expiredAt: $expiredAt, stepRemain: $stepRemain, stepTotal: $stepTotal, failedAttempts: $failedAttempts, platform: $platform, type: $type, blacklistFactors: $blacklistFactors, audiences: $audiences, scopes: $scopes, ipAddress: $ipAddress, userAgent: $userAgent, deviceId: $deviceId, nonce: $nonce, location: $location, accountId: $accountId, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; + return 'SnAuthChallenge(id: $id, expiredAt: $expiredAt, stepRemain: $stepRemain, stepTotal: $stepTotal, failedAttempts: $failedAttempts, type: $type, blacklistFactors: $blacklistFactors, audiences: $audiences, scopes: $scopes, ipAddress: $ipAddress, userAgent: $userAgent, nonce: $nonce, location: $location, accountId: $accountId, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; } @@ -305,7 +305,7 @@ abstract mixin class $SnAuthChallengeCopyWith<$Res> { factory $SnAuthChallengeCopyWith(SnAuthChallenge value, $Res Function(SnAuthChallenge) _then) = _$SnAuthChallengeCopyWithImpl; @useResult $Res call({ - String id, DateTime expiredAt, int stepRemain, int stepTotal, int failedAttempts, int platform, int type, List blacklistFactors, List audiences, List scopes, String ipAddress, String userAgent, String deviceId, String? nonce, String? location, String accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt + String id, DateTime expiredAt, int stepRemain, int stepTotal, int failedAttempts, int type, List blacklistFactors, List audiences, List scopes, String ipAddress, String userAgent, String? nonce, String? location, String accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt }); @@ -322,21 +322,19 @@ class _$SnAuthChallengeCopyWithImpl<$Res> /// Create a copy of SnAuthChallenge /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? expiredAt = null,Object? stepRemain = null,Object? stepTotal = null,Object? failedAttempts = null,Object? platform = null,Object? type = null,Object? blacklistFactors = null,Object? audiences = null,Object? scopes = null,Object? ipAddress = null,Object? userAgent = null,Object? deviceId = null,Object? nonce = freezed,Object? location = freezed,Object? accountId = null,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? expiredAt = null,Object? stepRemain = null,Object? stepTotal = null,Object? failedAttempts = null,Object? type = null,Object? blacklistFactors = null,Object? audiences = null,Object? scopes = null,Object? ipAddress = null,Object? userAgent = null,Object? nonce = freezed,Object? location = freezed,Object? accountId = null,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { return _then(_self.copyWith( id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as String,expiredAt: null == expiredAt ? _self.expiredAt : expiredAt // ignore: cast_nullable_to_non_nullable as DateTime,stepRemain: null == stepRemain ? _self.stepRemain : stepRemain // ignore: cast_nullable_to_non_nullable as int,stepTotal: null == stepTotal ? _self.stepTotal : stepTotal // ignore: cast_nullable_to_non_nullable as int,failedAttempts: null == failedAttempts ? _self.failedAttempts : failedAttempts // ignore: cast_nullable_to_non_nullable -as int,platform: null == platform ? _self.platform : platform // ignore: cast_nullable_to_non_nullable as int,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable as int,blacklistFactors: null == blacklistFactors ? _self.blacklistFactors : blacklistFactors // ignore: cast_nullable_to_non_nullable as List,audiences: null == audiences ? _self.audiences : audiences // ignore: cast_nullable_to_non_nullable as List,scopes: null == scopes ? _self.scopes : scopes // ignore: cast_nullable_to_non_nullable as List,ipAddress: null == ipAddress ? _self.ipAddress : ipAddress // ignore: cast_nullable_to_non_nullable as String,userAgent: null == userAgent ? _self.userAgent : userAgent // ignore: cast_nullable_to_non_nullable -as String,deviceId: null == deviceId ? _self.deviceId : deviceId // ignore: cast_nullable_to_non_nullable as String,nonce: freezed == nonce ? _self.nonce : nonce // ignore: cast_nullable_to_non_nullable as String?,location: freezed == location ? _self.location : location // ignore: cast_nullable_to_non_nullable as String?,accountId: null == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable @@ -425,10 +423,10 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( String id, DateTime expiredAt, int stepRemain, int stepTotal, int failedAttempts, int platform, int type, List blacklistFactors, List audiences, List scopes, String ipAddress, String userAgent, String deviceId, String? nonce, String? location, String accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( String id, DateTime expiredAt, int stepRemain, int stepTotal, int failedAttempts, int type, List blacklistFactors, List audiences, List scopes, String ipAddress, String userAgent, String? nonce, String? location, String accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _SnAuthChallenge() when $default != null: -return $default(_that.id,_that.expiredAt,_that.stepRemain,_that.stepTotal,_that.failedAttempts,_that.platform,_that.type,_that.blacklistFactors,_that.audiences,_that.scopes,_that.ipAddress,_that.userAgent,_that.deviceId,_that.nonce,_that.location,_that.accountId,_that.createdAt,_that.updatedAt,_that.deletedAt);case _: +return $default(_that.id,_that.expiredAt,_that.stepRemain,_that.stepTotal,_that.failedAttempts,_that.type,_that.blacklistFactors,_that.audiences,_that.scopes,_that.ipAddress,_that.userAgent,_that.nonce,_that.location,_that.accountId,_that.createdAt,_that.updatedAt,_that.deletedAt);case _: return orElse(); } @@ -446,10 +444,10 @@ return $default(_that.id,_that.expiredAt,_that.stepRemain,_that.stepTotal,_that. /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( String id, DateTime expiredAt, int stepRemain, int stepTotal, int failedAttempts, int platform, int type, List blacklistFactors, List audiences, List scopes, String ipAddress, String userAgent, String deviceId, String? nonce, String? location, String accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( String id, DateTime expiredAt, int stepRemain, int stepTotal, int failedAttempts, int type, List blacklistFactors, List audiences, List scopes, String ipAddress, String userAgent, String? nonce, String? location, String accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt) $default,) {final _that = this; switch (_that) { case _SnAuthChallenge(): -return $default(_that.id,_that.expiredAt,_that.stepRemain,_that.stepTotal,_that.failedAttempts,_that.platform,_that.type,_that.blacklistFactors,_that.audiences,_that.scopes,_that.ipAddress,_that.userAgent,_that.deviceId,_that.nonce,_that.location,_that.accountId,_that.createdAt,_that.updatedAt,_that.deletedAt);} +return $default(_that.id,_that.expiredAt,_that.stepRemain,_that.stepTotal,_that.failedAttempts,_that.type,_that.blacklistFactors,_that.audiences,_that.scopes,_that.ipAddress,_that.userAgent,_that.nonce,_that.location,_that.accountId,_that.createdAt,_that.updatedAt,_that.deletedAt);} } /// A variant of `when` that fallback to returning `null` /// @@ -463,10 +461,10 @@ return $default(_that.id,_that.expiredAt,_that.stepRemain,_that.stepTotal,_that. /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( String id, DateTime expiredAt, int stepRemain, int stepTotal, int failedAttempts, int platform, int type, List blacklistFactors, List audiences, List scopes, String ipAddress, String userAgent, String deviceId, String? nonce, String? location, String accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String id, DateTime expiredAt, int stepRemain, int stepTotal, int failedAttempts, int type, List blacklistFactors, List audiences, List scopes, String ipAddress, String userAgent, String? nonce, String? location, String accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt)? $default,) {final _that = this; switch (_that) { case _SnAuthChallenge() when $default != null: -return $default(_that.id,_that.expiredAt,_that.stepRemain,_that.stepTotal,_that.failedAttempts,_that.platform,_that.type,_that.blacklistFactors,_that.audiences,_that.scopes,_that.ipAddress,_that.userAgent,_that.deviceId,_that.nonce,_that.location,_that.accountId,_that.createdAt,_that.updatedAt,_that.deletedAt);case _: +return $default(_that.id,_that.expiredAt,_that.stepRemain,_that.stepTotal,_that.failedAttempts,_that.type,_that.blacklistFactors,_that.audiences,_that.scopes,_that.ipAddress,_that.userAgent,_that.nonce,_that.location,_that.accountId,_that.createdAt,_that.updatedAt,_that.deletedAt);case _: return null; } @@ -478,7 +476,7 @@ return $default(_that.id,_that.expiredAt,_that.stepRemain,_that.stepTotal,_that. @JsonSerializable() class _SnAuthChallenge implements SnAuthChallenge { - const _SnAuthChallenge({required this.id, required this.expiredAt, required this.stepRemain, required this.stepTotal, required this.failedAttempts, required this.platform, required this.type, required final List blacklistFactors, required final List audiences, required final List scopes, required this.ipAddress, required this.userAgent, required this.deviceId, required this.nonce, required this.location, required this.accountId, required this.createdAt, required this.updatedAt, required this.deletedAt}): _blacklistFactors = blacklistFactors,_audiences = audiences,_scopes = scopes; + const _SnAuthChallenge({required this.id, required this.expiredAt, required this.stepRemain, required this.stepTotal, required this.failedAttempts, required this.type, required final List blacklistFactors, required final List audiences, required final List scopes, required this.ipAddress, required this.userAgent, required this.nonce, required this.location, required this.accountId, required this.createdAt, required this.updatedAt, required this.deletedAt}): _blacklistFactors = blacklistFactors,_audiences = audiences,_scopes = scopes; factory _SnAuthChallenge.fromJson(Map json) => _$SnAuthChallengeFromJson(json); @override final String id; @@ -486,7 +484,6 @@ class _SnAuthChallenge implements SnAuthChallenge { @override final int stepRemain; @override final int stepTotal; @override final int failedAttempts; -@override final int platform; @override final int type; final List _blacklistFactors; @override List get blacklistFactors { @@ -511,7 +508,6 @@ class _SnAuthChallenge implements SnAuthChallenge { @override final String ipAddress; @override final String userAgent; -@override final String deviceId; @override final String? nonce; @override final String? location; @override final String accountId; @@ -532,16 +528,16 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnAuthChallenge&&(identical(other.id, id) || other.id == id)&&(identical(other.expiredAt, expiredAt) || other.expiredAt == expiredAt)&&(identical(other.stepRemain, stepRemain) || other.stepRemain == stepRemain)&&(identical(other.stepTotal, stepTotal) || other.stepTotal == stepTotal)&&(identical(other.failedAttempts, failedAttempts) || other.failedAttempts == failedAttempts)&&(identical(other.platform, platform) || other.platform == platform)&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other._blacklistFactors, _blacklistFactors)&&const DeepCollectionEquality().equals(other._audiences, _audiences)&&const DeepCollectionEquality().equals(other._scopes, _scopes)&&(identical(other.ipAddress, ipAddress) || other.ipAddress == ipAddress)&&(identical(other.userAgent, userAgent) || other.userAgent == userAgent)&&(identical(other.deviceId, deviceId) || other.deviceId == deviceId)&&(identical(other.nonce, nonce) || other.nonce == nonce)&&(identical(other.location, location) || other.location == location)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnAuthChallenge&&(identical(other.id, id) || other.id == id)&&(identical(other.expiredAt, expiredAt) || other.expiredAt == expiredAt)&&(identical(other.stepRemain, stepRemain) || other.stepRemain == stepRemain)&&(identical(other.stepTotal, stepTotal) || other.stepTotal == stepTotal)&&(identical(other.failedAttempts, failedAttempts) || other.failedAttempts == failedAttempts)&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other._blacklistFactors, _blacklistFactors)&&const DeepCollectionEquality().equals(other._audiences, _audiences)&&const DeepCollectionEquality().equals(other._scopes, _scopes)&&(identical(other.ipAddress, ipAddress) || other.ipAddress == ipAddress)&&(identical(other.userAgent, userAgent) || other.userAgent == userAgent)&&(identical(other.nonce, nonce) || other.nonce == nonce)&&(identical(other.location, location) || other.location == location)&&(identical(other.accountId, accountId) || other.accountId == accountId)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hashAll([runtimeType,id,expiredAt,stepRemain,stepTotal,failedAttempts,platform,type,const DeepCollectionEquality().hash(_blacklistFactors),const DeepCollectionEquality().hash(_audiences),const DeepCollectionEquality().hash(_scopes),ipAddress,userAgent,deviceId,nonce,location,accountId,createdAt,updatedAt,deletedAt]); +int get hashCode => Object.hash(runtimeType,id,expiredAt,stepRemain,stepTotal,failedAttempts,type,const DeepCollectionEquality().hash(_blacklistFactors),const DeepCollectionEquality().hash(_audiences),const DeepCollectionEquality().hash(_scopes),ipAddress,userAgent,nonce,location,accountId,createdAt,updatedAt,deletedAt); @override String toString() { - return 'SnAuthChallenge(id: $id, expiredAt: $expiredAt, stepRemain: $stepRemain, stepTotal: $stepTotal, failedAttempts: $failedAttempts, platform: $platform, type: $type, blacklistFactors: $blacklistFactors, audiences: $audiences, scopes: $scopes, ipAddress: $ipAddress, userAgent: $userAgent, deviceId: $deviceId, nonce: $nonce, location: $location, accountId: $accountId, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; + return 'SnAuthChallenge(id: $id, expiredAt: $expiredAt, stepRemain: $stepRemain, stepTotal: $stepTotal, failedAttempts: $failedAttempts, type: $type, blacklistFactors: $blacklistFactors, audiences: $audiences, scopes: $scopes, ipAddress: $ipAddress, userAgent: $userAgent, nonce: $nonce, location: $location, accountId: $accountId, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)'; } @@ -552,7 +548,7 @@ abstract mixin class _$SnAuthChallengeCopyWith<$Res> implements $SnAuthChallenge factory _$SnAuthChallengeCopyWith(_SnAuthChallenge value, $Res Function(_SnAuthChallenge) _then) = __$SnAuthChallengeCopyWithImpl; @override @useResult $Res call({ - String id, DateTime expiredAt, int stepRemain, int stepTotal, int failedAttempts, int platform, int type, List blacklistFactors, List audiences, List scopes, String ipAddress, String userAgent, String deviceId, String? nonce, String? location, String accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt + String id, DateTime expiredAt, int stepRemain, int stepTotal, int failedAttempts, int type, List blacklistFactors, List audiences, List scopes, String ipAddress, String userAgent, String? nonce, String? location, String accountId, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt }); @@ -569,21 +565,19 @@ class __$SnAuthChallengeCopyWithImpl<$Res> /// Create a copy of SnAuthChallenge /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? expiredAt = null,Object? stepRemain = null,Object? stepTotal = null,Object? failedAttempts = null,Object? platform = null,Object? type = null,Object? blacklistFactors = null,Object? audiences = null,Object? scopes = null,Object? ipAddress = null,Object? userAgent = null,Object? deviceId = null,Object? nonce = freezed,Object? location = freezed,Object? accountId = null,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? expiredAt = null,Object? stepRemain = null,Object? stepTotal = null,Object? failedAttempts = null,Object? type = null,Object? blacklistFactors = null,Object? audiences = null,Object? scopes = null,Object? ipAddress = null,Object? userAgent = null,Object? nonce = freezed,Object? location = freezed,Object? accountId = null,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) { return _then(_SnAuthChallenge( id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as String,expiredAt: null == expiredAt ? _self.expiredAt : expiredAt // ignore: cast_nullable_to_non_nullable as DateTime,stepRemain: null == stepRemain ? _self.stepRemain : stepRemain // ignore: cast_nullable_to_non_nullable as int,stepTotal: null == stepTotal ? _self.stepTotal : stepTotal // ignore: cast_nullable_to_non_nullable as int,failedAttempts: null == failedAttempts ? _self.failedAttempts : failedAttempts // ignore: cast_nullable_to_non_nullable -as int,platform: null == platform ? _self.platform : platform // ignore: cast_nullable_to_non_nullable as int,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable as int,blacklistFactors: null == blacklistFactors ? _self._blacklistFactors : blacklistFactors // ignore: cast_nullable_to_non_nullable as List,audiences: null == audiences ? _self._audiences : audiences // ignore: cast_nullable_to_non_nullable as List,scopes: null == scopes ? _self._scopes : scopes // ignore: cast_nullable_to_non_nullable as List,ipAddress: null == ipAddress ? _self.ipAddress : ipAddress // ignore: cast_nullable_to_non_nullable as String,userAgent: null == userAgent ? _self.userAgent : userAgent // ignore: cast_nullable_to_non_nullable -as String,deviceId: null == deviceId ? _self.deviceId : deviceId // ignore: cast_nullable_to_non_nullable as String,nonce: freezed == nonce ? _self.nonce : nonce // ignore: cast_nullable_to_non_nullable as String?,location: freezed == location ? _self.location : location // ignore: cast_nullable_to_non_nullable as String?,accountId: null == accountId ? _self.accountId : accountId // ignore: cast_nullable_to_non_nullable @@ -1189,286 +1183,6 @@ as Map?, } -/// @nodoc -mixin _$SnAuthDevice { - - dynamic get label; String get userAgent; String get deviceId; int get platform; List get sessions;// Not from backend, used for UI - bool get isCurrent; -/// Create a copy of SnAuthDevice -/// with the given fields replaced by the non-null parameter values. -@JsonKey(includeFromJson: false, includeToJson: false) -@pragma('vm:prefer-inline') -$SnAuthDeviceCopyWith get copyWith => _$SnAuthDeviceCopyWithImpl(this as SnAuthDevice, _$identity); - - /// Serializes this SnAuthDevice to a JSON map. - Map toJson(); - - -@override -bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is SnAuthDevice&&const DeepCollectionEquality().equals(other.label, label)&&(identical(other.userAgent, userAgent) || other.userAgent == userAgent)&&(identical(other.deviceId, deviceId) || other.deviceId == deviceId)&&(identical(other.platform, platform) || other.platform == platform)&&const DeepCollectionEquality().equals(other.sessions, sessions)&&(identical(other.isCurrent, isCurrent) || other.isCurrent == isCurrent)); -} - -@JsonKey(includeFromJson: false, includeToJson: false) -@override -int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(label),userAgent,deviceId,platform,const DeepCollectionEquality().hash(sessions),isCurrent); - -@override -String toString() { - return 'SnAuthDevice(label: $label, userAgent: $userAgent, deviceId: $deviceId, platform: $platform, sessions: $sessions, isCurrent: $isCurrent)'; -} - - -} - -/// @nodoc -abstract mixin class $SnAuthDeviceCopyWith<$Res> { - factory $SnAuthDeviceCopyWith(SnAuthDevice value, $Res Function(SnAuthDevice) _then) = _$SnAuthDeviceCopyWithImpl; -@useResult -$Res call({ - dynamic label, String userAgent, String deviceId, int platform, List sessions, bool isCurrent -}); - - - - -} -/// @nodoc -class _$SnAuthDeviceCopyWithImpl<$Res> - implements $SnAuthDeviceCopyWith<$Res> { - _$SnAuthDeviceCopyWithImpl(this._self, this._then); - - final SnAuthDevice _self; - final $Res Function(SnAuthDevice) _then; - -/// Create a copy of SnAuthDevice -/// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? label = freezed,Object? userAgent = null,Object? deviceId = null,Object? platform = null,Object? sessions = null,Object? isCurrent = null,}) { - return _then(_self.copyWith( -label: freezed == label ? _self.label : label // ignore: cast_nullable_to_non_nullable -as dynamic,userAgent: null == userAgent ? _self.userAgent : userAgent // ignore: cast_nullable_to_non_nullable -as String,deviceId: null == deviceId ? _self.deviceId : deviceId // ignore: cast_nullable_to_non_nullable -as String,platform: null == platform ? _self.platform : platform // ignore: cast_nullable_to_non_nullable -as int,sessions: null == sessions ? _self.sessions : sessions // ignore: cast_nullable_to_non_nullable -as List,isCurrent: null == isCurrent ? _self.isCurrent : isCurrent // ignore: cast_nullable_to_non_nullable -as bool, - )); -} - -} - - -/// Adds pattern-matching-related methods to [SnAuthDevice]. -extension SnAuthDevicePatterns on SnAuthDevice { -/// A variant of `map` that fallback to returning `orElse`. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case _: -/// return orElse(); -/// } -/// ``` - -@optionalTypeArgs TResult maybeMap(TResult Function( _SnAuthDevice value)? $default,{required TResult orElse(),}){ -final _that = this; -switch (_that) { -case _SnAuthDevice() when $default != null: -return $default(_that);case _: - return orElse(); - -} -} -/// A `switch`-like method, using callbacks. -/// -/// Callbacks receives the raw object, upcasted. -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case final Subclass2 value: -/// return ...; -/// } -/// ``` - -@optionalTypeArgs TResult map(TResult Function( _SnAuthDevice value) $default,){ -final _that = this; -switch (_that) { -case _SnAuthDevice(): -return $default(_that);} -} -/// A variant of `map` that fallback to returning `null`. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case _: -/// return null; -/// } -/// ``` - -@optionalTypeArgs TResult? mapOrNull(TResult? Function( _SnAuthDevice value)? $default,){ -final _that = this; -switch (_that) { -case _SnAuthDevice() when $default != null: -return $default(_that);case _: - return null; - -} -} -/// A variant of `when` that fallback to an `orElse` callback. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case _: -/// return orElse(); -/// } -/// ``` - -@optionalTypeArgs TResult maybeWhen(TResult Function( dynamic label, String userAgent, String deviceId, int platform, List sessions, bool isCurrent)? $default,{required TResult orElse(),}) {final _that = this; -switch (_that) { -case _SnAuthDevice() when $default != null: -return $default(_that.label,_that.userAgent,_that.deviceId,_that.platform,_that.sessions,_that.isCurrent);case _: - return orElse(); - -} -} -/// A `switch`-like method, using callbacks. -/// -/// As opposed to `map`, this offers destructuring. -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case Subclass2(:final field2): -/// return ...; -/// } -/// ``` - -@optionalTypeArgs TResult when(TResult Function( dynamic label, String userAgent, String deviceId, int platform, List sessions, bool isCurrent) $default,) {final _that = this; -switch (_that) { -case _SnAuthDevice(): -return $default(_that.label,_that.userAgent,_that.deviceId,_that.platform,_that.sessions,_that.isCurrent);} -} -/// A variant of `when` that fallback to returning `null` -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case _: -/// return null; -/// } -/// ``` - -@optionalTypeArgs TResult? whenOrNull(TResult? Function( dynamic label, String userAgent, String deviceId, int platform, List sessions, bool isCurrent)? $default,) {final _that = this; -switch (_that) { -case _SnAuthDevice() when $default != null: -return $default(_that.label,_that.userAgent,_that.deviceId,_that.platform,_that.sessions,_that.isCurrent);case _: - return null; - -} -} - -} - -/// @nodoc -@JsonSerializable() - -class _SnAuthDevice implements SnAuthDevice { - const _SnAuthDevice({required this.label, required this.userAgent, required this.deviceId, required this.platform, required final List sessions, this.isCurrent = false}): _sessions = sessions; - factory _SnAuthDevice.fromJson(Map json) => _$SnAuthDeviceFromJson(json); - -@override final dynamic label; -@override final String userAgent; -@override final String deviceId; -@override final int platform; - final List _sessions; -@override List get sessions { - if (_sessions is EqualUnmodifiableListView) return _sessions; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_sessions); -} - -// Not from backend, used for UI -@override@JsonKey() final bool isCurrent; - -/// Create a copy of SnAuthDevice -/// with the given fields replaced by the non-null parameter values. -@override @JsonKey(includeFromJson: false, includeToJson: false) -@pragma('vm:prefer-inline') -_$SnAuthDeviceCopyWith<_SnAuthDevice> get copyWith => __$SnAuthDeviceCopyWithImpl<_SnAuthDevice>(this, _$identity); - -@override -Map toJson() { - return _$SnAuthDeviceToJson(this, ); -} - -@override -bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnAuthDevice&&const DeepCollectionEquality().equals(other.label, label)&&(identical(other.userAgent, userAgent) || other.userAgent == userAgent)&&(identical(other.deviceId, deviceId) || other.deviceId == deviceId)&&(identical(other.platform, platform) || other.platform == platform)&&const DeepCollectionEquality().equals(other._sessions, _sessions)&&(identical(other.isCurrent, isCurrent) || other.isCurrent == isCurrent)); -} - -@JsonKey(includeFromJson: false, includeToJson: false) -@override -int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(label),userAgent,deviceId,platform,const DeepCollectionEquality().hash(_sessions),isCurrent); - -@override -String toString() { - return 'SnAuthDevice(label: $label, userAgent: $userAgent, deviceId: $deviceId, platform: $platform, sessions: $sessions, isCurrent: $isCurrent)'; -} - - -} - -/// @nodoc -abstract mixin class _$SnAuthDeviceCopyWith<$Res> implements $SnAuthDeviceCopyWith<$Res> { - factory _$SnAuthDeviceCopyWith(_SnAuthDevice value, $Res Function(_SnAuthDevice) _then) = __$SnAuthDeviceCopyWithImpl; -@override @useResult -$Res call({ - dynamic label, String userAgent, String deviceId, int platform, List sessions, bool isCurrent -}); - - - - -} -/// @nodoc -class __$SnAuthDeviceCopyWithImpl<$Res> - implements _$SnAuthDeviceCopyWith<$Res> { - __$SnAuthDeviceCopyWithImpl(this._self, this._then); - - final _SnAuthDevice _self; - final $Res Function(_SnAuthDevice) _then; - -/// Create a copy of SnAuthDevice -/// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? label = freezed,Object? userAgent = null,Object? deviceId = null,Object? platform = null,Object? sessions = null,Object? isCurrent = null,}) { - return _then(_SnAuthDevice( -label: freezed == label ? _self.label : label // ignore: cast_nullable_to_non_nullable -as dynamic,userAgent: null == userAgent ? _self.userAgent : userAgent // ignore: cast_nullable_to_non_nullable -as String,deviceId: null == deviceId ? _self.deviceId : deviceId // ignore: cast_nullable_to_non_nullable -as String,platform: null == platform ? _self.platform : platform // ignore: cast_nullable_to_non_nullable -as int,sessions: null == sessions ? _self._sessions : sessions // ignore: cast_nullable_to_non_nullable -as List,isCurrent: null == isCurrent ? _self.isCurrent : isCurrent // ignore: cast_nullable_to_non_nullable -as bool, - )); -} - - -} - - /// @nodoc mixin _$SnAccountConnection { diff --git a/lib/models/auth.g.dart b/lib/models/auth.g.dart index f14f327d..7c4238ae 100644 --- a/lib/models/auth.g.dart +++ b/lib/models/auth.g.dart @@ -20,7 +20,6 @@ _SnAuthChallenge _$SnAuthChallengeFromJson(Map json) => stepRemain: (json['step_remain'] as num).toInt(), stepTotal: (json['step_total'] as num).toInt(), failedAttempts: (json['failed_attempts'] as num).toInt(), - platform: (json['platform'] as num).toInt(), type: (json['type'] as num).toInt(), blacklistFactors: (json['blacklist_factors'] as List) @@ -30,7 +29,6 @@ _SnAuthChallenge _$SnAuthChallengeFromJson(Map json) => scopes: json['scopes'] as List, ipAddress: json['ip_address'] as String, userAgent: json['user_agent'] as String, - deviceId: json['device_id'] as String, nonce: json['nonce'] as String?, location: json['location'] as String?, accountId: json['account_id'] as String, @@ -49,14 +47,12 @@ Map _$SnAuthChallengeToJson(_SnAuthChallenge instance) => 'step_remain': instance.stepRemain, 'step_total': instance.stepTotal, 'failed_attempts': instance.failedAttempts, - 'platform': instance.platform, 'type': instance.type, 'blacklist_factors': instance.blacklistFactors, 'audiences': instance.audiences, 'scopes': instance.scopes, 'ip_address': instance.ipAddress, 'user_agent': instance.userAgent, - 'device_id': instance.deviceId, 'nonce': instance.nonce, 'location': instance.location, 'account_id': instance.accountId, @@ -133,29 +129,6 @@ Map _$SnAuthFactorToJson(_SnAuthFactor instance) => 'created_response': instance.createdResponse, }; -_SnAuthDevice _$SnAuthDeviceFromJson(Map json) => - _SnAuthDevice( - label: json['label'], - userAgent: json['user_agent'] as String, - deviceId: json['device_id'] as String, - platform: (json['platform'] as num).toInt(), - sessions: - (json['sessions'] as List) - .map((e) => SnAuthSession.fromJson(e as Map)) - .toList(), - isCurrent: json['is_current'] as bool? ?? false, - ); - -Map _$SnAuthDeviceToJson(_SnAuthDevice instance) => - { - 'label': instance.label, - 'user_agent': instance.userAgent, - 'device_id': instance.deviceId, - 'platform': instance.platform, - 'sessions': instance.sessions.map((e) => e.toJson()).toList(), - 'is_current': instance.isCurrent, - }; - _SnAccountConnection _$SnAccountConnectionFromJson(Map json) => _SnAccountConnection( id: json['id'] as String, diff --git a/lib/models/chat.dart b/lib/models/chat.dart index 5281a11b..09f391fd 100644 --- a/lib/models/chat.dart +++ b/lib/models/chat.dart @@ -1,7 +1,7 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:island/models/file.dart'; import 'package:island/models/realm.dart'; -import 'package:island/models/user.dart'; +import 'package:island/models/account.dart'; part 'chat.freezed.dart'; part 'chat.g.dart'; diff --git a/lib/models/custom_app.dart b/lib/models/custom_app.dart index df90fbb4..141f0826 100644 --- a/lib/models/custom_app.dart +++ b/lib/models/custom_app.dart @@ -1,6 +1,6 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:island/models/file.dart'; -import 'package:island/models/user.dart'; +import 'package:island/models/account.dart'; part 'custom_app.freezed.dart'; part 'custom_app.g.dart'; diff --git a/lib/models/publisher.dart b/lib/models/publisher.dart index dcd06c5c..3c695528 100644 --- a/lib/models/publisher.dart +++ b/lib/models/publisher.dart @@ -1,6 +1,6 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:island/models/file.dart'; -import 'package:island/models/user.dart'; +import 'package:island/models/account.dart'; part 'publisher.freezed.dart'; part 'publisher.g.dart'; diff --git a/lib/models/realm.dart b/lib/models/realm.dart index 31ed6e3d..df24fe43 100644 --- a/lib/models/realm.dart +++ b/lib/models/realm.dart @@ -1,6 +1,6 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:island/models/file.dart'; -import 'package:island/models/user.dart'; +import 'package:island/models/account.dart'; part 'realm.freezed.dart'; part 'realm.g.dart'; diff --git a/lib/models/relationship.dart b/lib/models/relationship.dart index e869376e..10198ba8 100644 --- a/lib/models/relationship.dart +++ b/lib/models/relationship.dart @@ -1,6 +1,6 @@ import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:island/models/user.dart'; +import 'package:island/models/account.dart'; part 'relationship.freezed.dart'; part 'relationship.g.dart'; diff --git a/lib/models/wallet.dart b/lib/models/wallet.dart index 39c36466..b55d66e8 100644 --- a/lib/models/wallet.dart +++ b/lib/models/wallet.dart @@ -1,5 +1,5 @@ import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:island/models/user.dart'; +import 'package:island/models/account.dart'; part 'wallet.freezed.dart'; part 'wallet.g.dart'; diff --git a/lib/pods/userinfo.dart b/lib/pods/userinfo.dart index 37aa2e2a..6e6b220c 100644 --- a/lib/pods/userinfo.dart +++ b/lib/pods/userinfo.dart @@ -3,7 +3,7 @@ import 'dart:developer'; import 'package:firebase_analytics/firebase_analytics.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:island/models/user.dart'; +import 'package:island/models/account.dart'; import 'package:island/pods/config.dart'; import 'package:island/pods/network.dart'; diff --git a/lib/screens/account/me/settings.dart b/lib/screens/account/me/settings.dart index 62013ddd..03f90a84 100644 --- a/lib/screens/account/me/settings.dart +++ b/lib/screens/account/me/settings.dart @@ -6,7 +6,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:island/models/auth.dart'; -import 'package:island/models/user.dart'; +import 'package:island/models/account.dart'; import 'package:island/pods/network.dart'; import 'package:island/pods/userinfo.dart'; import 'package:island/screens/account/me/settings_auth_factors.dart'; @@ -15,7 +15,7 @@ import 'package:island/screens/account/me/settings_contacts.dart'; import 'package:island/screens/auth/captcha.dart'; import 'package:island/screens/auth/login.dart'; import 'package:island/services/responsive.dart'; -import 'package:island/widgets/account/account_session_sheet.dart'; +import 'package:island/widgets/account/account_devices.dart'; import 'package:island/widgets/alert.dart'; import 'package:island/widgets/app_scaffold.dart'; import 'package:island/widgets/response.dart'; diff --git a/lib/screens/account/me/settings_contacts.dart b/lib/screens/account/me/settings_contacts.dart index 9d59c03d..c1c1f33a 100644 --- a/lib/screens/account/me/settings_contacts.dart +++ b/lib/screens/account/me/settings_contacts.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:gap/gap.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:island/models/user.dart'; +import 'package:island/models/account.dart'; import 'package:island/pods/network.dart'; import 'package:island/widgets/alert.dart'; import 'package:island/widgets/content/sheet.dart'; diff --git a/lib/screens/account/me/update.dart b/lib/screens/account/me/update.dart index 5b00f784..ce61f028 100644 --- a/lib/screens/account/me/update.dart +++ b/lib/screens/account/me/update.dart @@ -7,7 +7,7 @@ import 'package:gap/gap.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:image_picker/image_picker.dart'; import 'package:island/models/file.dart'; -import 'package:island/models/user.dart'; +import 'package:island/models/account.dart'; import 'package:island/pods/config.dart'; import 'package:island/pods/network.dart'; import 'package:island/pods/userinfo.dart'; diff --git a/lib/screens/account/profile.dart b/lib/screens/account/profile.dart index e3bded8c..87e1a87c 100644 --- a/lib/screens/account/profile.dart +++ b/lib/screens/account/profile.dart @@ -8,7 +8,7 @@ import 'package:gap/gap.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:island/models/chat.dart'; import 'package:island/models/relationship.dart'; -import 'package:island/models/user.dart'; +import 'package:island/models/account.dart'; import 'package:island/pods/config.dart'; import 'package:island/pods/event_calendar.dart'; import 'package:island/pods/network.dart'; diff --git a/lib/screens/notification.dart b/lib/screens/notification.dart index 38366123..3e6ced3f 100644 --- a/lib/screens/notification.dart +++ b/lib/screens/notification.dart @@ -5,7 +5,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:island/models/user.dart'; +import 'package:island/models/account.dart'; import 'package:island/pods/network.dart'; import 'package:island/pods/websocket.dart'; import 'package:island/route.dart'; diff --git a/lib/screens/posts/pub_profile.dart b/lib/screens/posts/pub_profile.dart index 04abb70d..baa13dd6 100644 --- a/lib/screens/posts/pub_profile.dart +++ b/lib/screens/posts/pub_profile.dart @@ -7,7 +7,7 @@ import 'package:gap/gap.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:island/models/post.dart'; import 'package:island/models/publisher.dart'; -import 'package:island/models/user.dart'; +import 'package:island/models/account.dart'; import 'package:island/pods/config.dart'; import 'package:island/pods/network.dart'; import 'package:island/services/color.dart'; diff --git a/lib/services/notify.dart b/lib/services/notify.dart index 980df061..c17b7422 100644 --- a/lib/services/notify.dart +++ b/lib/services/notify.dart @@ -10,7 +10,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; import 'package:island/main.dart'; import 'package:island/route.dart'; -import 'package:island/models/user.dart'; +import 'package:island/models/account.dart'; import 'package:island/pods/websocket.dart'; import 'package:island/widgets/app_notification.dart'; import 'package:top_snackbar_flutter/top_snack_bar.dart'; @@ -67,7 +67,7 @@ Future subscribePushNotification( Dio apiClient, { bool detailedErrors = false, }) async { - if (Platform.isLinux){ + if (Platform.isLinux) { return; } await FirebaseMessaging.instance.requestPermission( diff --git a/lib/widgets/account/account_session_sheet.dart b/lib/widgets/account/account_devices.dart similarity index 86% rename from lib/widgets/account/account_session_sheet.dart rename to lib/widgets/account/account_devices.dart index 451730db..3a707bca 100644 --- a/lib/widgets/account/account_session_sheet.dart +++ b/lib/widgets/account/account_devices.dart @@ -3,33 +3,34 @@ import 'dart:convert'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:island/models/auth.dart'; +import 'package:island/models/account.dart'; import 'package:island/pods/network.dart'; import 'package:island/services/responsive.dart'; +import 'package:island/services/udid.dart'; import 'package:island/widgets/alert.dart'; import 'package:island/widgets/content/sheet.dart'; import 'package:island/widgets/response.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:styled_widget/styled_widget.dart'; -part 'account_session_sheet.g.dart'; +part 'account_devices.g.dart'; @riverpod -Future> authDevices(Ref ref) async { +Future> authDevices(Ref ref) async { final resp = await ref .watch(apiClientProvider) .get('/id/accounts/me/devices'); - final sessionId = resp.headers.value('x-auth-session'); + final currentId = await getUdid(); final data = - resp.data.map((e) { - final ele = SnAuthDevice.fromJson(e); - return ele.copyWith(isCurrent: ele.sessions.first.id == sessionId); + resp.data.map((e) { + final ele = SnAuthDeviceWithChallenge.fromJson(e); + return ele.copyWith(isCurrent: ele.deviceId == currentId); }).toList(); return data; } class _DeviceListTile extends StatelessWidget { - final SnAuthDevice device; + final SnAuthDeviceWithChallenge device; final Function(String) updateDeviceLabel; final Function(String) logoutDevice; @@ -57,17 +58,16 @@ class _DeviceListTile extends StatelessWidget { subtitle: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Text('authSessionsCount'.plural(device.sessions.length)), Text( 'lastActiveAt'.tr( args: [ DateFormat().format( - device.sessions.first.lastGrantedAt.toLocal(), + device.challenges.first.createdAt.toLocal(), ), ], ), ), - Text(device.sessions.first.challenge.ipAddress), + Text(device.challenges.first.ipAddress), if (device.isCurrent) Row( children: [ @@ -84,7 +84,7 @@ class _DeviceListTile extends StatelessWidget { ).padding(top: 4), ], ), - title: Text(device.label ?? device.sessions.first.challenge.userAgent), + title: Text(device.deviceLabel ?? device.deviceName), trailing: isWideScreen(context) ? Row( @@ -93,14 +93,13 @@ class _DeviceListTile extends StatelessWidget { IconButton( icon: Icon(Icons.edit), tooltip: 'authDeviceEditLabel'.tr(), - onPressed: - () => updateDeviceLabel(device.sessions.first.id), + onPressed: () => updateDeviceLabel(device.deviceId), ), if (!device.isCurrent) IconButton( icon: Icon(Icons.logout), tooltip: 'authDeviceLogout'.tr(), - onPressed: () => logoutDevice(device.sessions.first.id), + onPressed: () => logoutDevice(device.deviceId), ), ], ) @@ -124,7 +123,7 @@ class AccountSessionSheet extends HookConsumerWidget { if (!confirm || !context.mounted) return; try { final apiClient = ref.watch(apiClientProvider); - await apiClient.delete('/id/accounts/me/sessions/$sessionId'); + await apiClient.delete('/id/accounts/me/devices/$sessionId'); ref.invalidate(authDevicesProvider); } catch (err) { showErrorAlert(err); @@ -163,7 +162,7 @@ class AccountSessionSheet extends HookConsumerWidget { try { final apiClient = ref.watch(apiClientProvider); await apiClient.patch( - '/accounts/me/sessions/$sessionId/label', + '/accounts/me/devices/$sessionId/label', data: jsonEncode(label), ); ref.invalidate(authDevicesProvider); @@ -194,7 +193,7 @@ class AccountSessionSheet extends HookConsumerWidget { ); } else { return Dismissible( - key: Key('device-${device.sessions.first.id}'), + key: Key('device-${device.id}'), direction: device.isCurrent ? DismissDirection.startToEnd @@ -213,7 +212,7 @@ class AccountSessionSheet extends HookConsumerWidget { ), confirmDismiss: (direction) async { if (direction == DismissDirection.startToEnd) { - updateDeviceLabel(device.sessions.first.id); + updateDeviceLabel(device.deviceId); return false; } else { final confirm = await showConfirmAlert( @@ -221,7 +220,7 @@ class AccountSessionSheet extends HookConsumerWidget { 'authDeviceLogout'.tr(), ); if (confirm && context.mounted) { - logoutDevice(device.sessions.first.id); + logoutDevice(device.deviceId); } return false; // Don't dismiss } diff --git a/lib/widgets/account/account_session_sheet.g.dart b/lib/widgets/account/account_devices.g.dart similarity index 75% rename from lib/widgets/account/account_session_sheet.g.dart rename to lib/widgets/account/account_devices.g.dart index b365c6bd..359f3bea 100644 --- a/lib/widgets/account/account_session_sheet.g.dart +++ b/lib/widgets/account/account_devices.g.dart @@ -1,17 +1,17 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'account_session_sheet.dart'; +part of 'account_devices.dart'; // ************************************************************************** // RiverpodGenerator // ************************************************************************** -String _$authDevicesHash() => r'8bc41a1ffc37df8e757c977b4ddae11db8faaeb5'; +String _$authDevicesHash() => r'feb19238f759921e51c888f8b443a3d7761e68da'; /// See also [authDevices]. @ProviderFor(authDevices) final authDevicesProvider = - AutoDisposeFutureProvider>.internal( + AutoDisposeFutureProvider>.internal( authDevices, name: r'authDevicesProvider', debugGetCreateSourceHash: @@ -24,6 +24,7 @@ final authDevicesProvider = @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element -typedef AuthDevicesRef = AutoDisposeFutureProviderRef>; +typedef AuthDevicesRef = + AutoDisposeFutureProviderRef>; // ignore_for_file: type=lint // ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/lib/widgets/account/account_name.dart b/lib/widgets/account/account_name.dart index 4d84de47..86cd3005 100644 --- a/lib/widgets/account/account_name.dart +++ b/lib/widgets/account/account_name.dart @@ -1,7 +1,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:gap/gap.dart'; -import 'package:island/models/user.dart'; +import 'package:island/models/account.dart'; import 'package:island/models/wallet.dart'; import 'package:material_symbols_icons/symbols.dart'; import 'package:styled_widget/styled_widget.dart'; diff --git a/lib/widgets/account/account_picker.dart b/lib/widgets/account/account_picker.dart index c081b623..92b81441 100644 --- a/lib/widgets/account/account_picker.dart +++ b/lib/widgets/account/account_picker.dart @@ -4,7 +4,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:island/models/user.dart'; +import 'package:island/models/account.dart'; import 'package:island/pods/network.dart'; import 'package:island/widgets/content/cloud_files.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; diff --git a/lib/widgets/account/badge.dart b/lib/widgets/account/badge.dart index e3911e49..e34d0dd2 100644 --- a/lib/widgets/account/badge.dart +++ b/lib/widgets/account/badge.dart @@ -1,6 +1,6 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:island/models/user.dart'; +import 'package:island/models/account.dart'; import 'package:island/models/badge.dart'; class BadgeList extends StatelessWidget { diff --git a/lib/widgets/account/status.dart b/lib/widgets/account/status.dart index 7524dd1f..3de97d5b 100644 --- a/lib/widgets/account/status.dart +++ b/lib/widgets/account/status.dart @@ -2,7 +2,7 @@ import 'package:dio/dio.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:island/models/user.dart'; +import 'package:island/models/account.dart'; import 'package:island/pods/network.dart'; import 'package:island/screens/account/profile.dart'; import 'package:island/services/time.dart'; diff --git a/lib/widgets/account/status_creation.dart b/lib/widgets/account/status_creation.dart index 1ffd1bbe..d6c0e32e 100644 --- a/lib/widgets/account/status_creation.dart +++ b/lib/widgets/account/status_creation.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:gap/gap.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:island/models/user.dart'; +import 'package:island/models/account.dart'; import 'package:island/pods/network.dart'; import 'package:island/pods/userinfo.dart'; import 'package:island/widgets/account/status.dart'; diff --git a/lib/widgets/app_notification.dart b/lib/widgets/app_notification.dart index 9fb37533..ae2545ac 100644 --- a/lib/widgets/app_notification.dart +++ b/lib/widgets/app_notification.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:island/models/user.dart'; +import 'package:island/models/account.dart'; import 'package:island/widgets/content/cloud_files.dart'; import 'package:material_symbols_icons/material_symbols_icons.dart'; import 'package:styled_widget/styled_widget.dart'; diff --git a/pubspec.lock b/pubspec.lock index b3c424b1..058d6960 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -301,10 +301,10 @@ packages: dependency: transitive description: name: connectivity_plus - sha256: "051849e2bd7c7b3bc5844ea0d096609ddc3a859890ec3a9ac4a65a2620cc1f99" + sha256: b5e72753cf63becce2c61fd04dfe0f1c430cc5278b53a1342dc5ad839eab29ec url: "https://pub.dev" source: hosted - version: "6.1.4" + version: "6.1.5" connectivity_plus_platform_interface: dependency: transitive description: @@ -413,10 +413,10 @@ packages: dependency: transitive description: name: dart_webrtc - sha256: a2ae542cdadc21359022adedc26138fa3487cc3b3547c24ff4f556681869e28c + sha256: "3bfa069a8b14a53ba506f6dd529e9b88c878ba0cc238f311051a39bf1e53d075" url: "https://pub.dev" source: hosted - version: "1.5.3+hotfix.4" + version: "1.5.3+hotfix.5" dbus: dependency: transitive description: @@ -565,10 +565,10 @@ packages: dependency: "direct main" description: name: file_picker - sha256: "970d33d79e1da667b6da222575fd7f2e30e323ca76251504477e6d51405b2d9a" + sha256: ef7d2a085c1b1d69d17b6842d0734aad90156de08df6bd3c12496d0bd6ddf8e2 url: "https://pub.dev" source: hosted - version: "10.2.4" + version: "10.3.1" file_selector_linux: dependency: transitive description: @@ -754,10 +754,10 @@ packages: dependency: "direct main" description: name: flutter_hooks - sha256: b772e710d16d7a20c0740c4f855095026b31c7eb5ba3ab67d2bd52021cd9461d + sha256: c3df76c62bb3a9f9bee75c57cdab40abab6123b734c1cd7e9b26a5dbd436eceb url: "https://pub.dev" source: hosted - version: "0.21.2" + version: "0.21.3" flutter_inappwebview: dependency: "direct main" description: @@ -1649,18 +1649,18 @@ packages: dependency: "direct main" description: name: package_info_plus - sha256: "7976bfe4c583170d6cdc7077e3237560b364149fcd268b5f53d95a991963b191" + sha256: "16eee997588c60225bda0488b6dcfac69280a6b7a3cf02c741895dd370a02968" url: "https://pub.dev" source: hosted - version: "8.3.0" + version: "8.3.1" package_info_plus_platform_interface: dependency: transitive description: name: package_info_plus_platform_interface - sha256: "6c935fb612dff8e3cc9632c2b301720c77450a126114126ffaafe28d2e87956c" + sha256: "202a487f08836a592a6bd4f901ac69b3a8f146af552bbd14407b6b41e1c3f086" url: "https://pub.dev" source: hosted - version: "3.2.0" + version: "3.2.1" palette_generator: dependency: "direct main" description: @@ -1833,10 +1833,10 @@ packages: dependency: transitive description: name: protobuf - sha256: "6153efcc92a06910918f3db8231fd2cf828ac81e50ebd87adc8f8a8cb3caff0e" + sha256: de9c9eb2c33f8e933a42932fe1dc504800ca45ebc3d673e6ed7f39754ee4053e url: "https://pub.dev" source: hosted - version: "4.1.1" + version: "4.2.0" provider: dependency: transitive description: @@ -2073,18 +2073,18 @@ packages: dependency: "direct main" description: name: share_plus - sha256: b2961506569e28948d75ec346c28775bb111986bb69dc6a20754a457e3d97fa0 + sha256: d7dc0630a923883c6328ca31b89aa682bacbf2f8304162d29f7c6aaff03a27a1 url: "https://pub.dev" source: hosted - version: "11.0.0" + version: "11.1.0" share_plus_platform_interface: dependency: transitive description: name: share_plus_platform_interface - sha256: "1032d392bc5d2095a77447a805aa3f804d2ae6a4d5eef5e6ebb3bd94c1bc19ef" + sha256: "88023e53a13429bd65d8e85e11a9b484f49d4c190abbd96c7932b74d6927cc9a" url: "https://pub.dev" source: hosted - version: "6.0.0" + version: "6.1.0" shared_preferences: dependency: "direct main" description: @@ -2206,10 +2206,10 @@ packages: dependency: transitive description: name: source_helper - sha256: "4f81479fe5194a622cdd1713fe1ecb683a6e6c85cd8cec8e2e35ee5ab3fdf2a1" + sha256: a447acb083d3a5ef17f983dd36201aeea33fedadb3228fa831f2f0c92f0f3aca url: "https://pub.dev" source: hosted - version: "1.3.6" + version: "1.3.7" source_span: dependency: transitive description: @@ -2718,4 +2718,4 @@ packages: version: "3.1.3" sdks: dart: ">=3.8.0 <4.0.0" - flutter: ">=3.29.0" + flutter: ">=3.32.0" diff --git a/pubspec.yaml b/pubspec.yaml index e1b79d9a..6592da3d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -36,7 +36,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.8 - flutter_hooks: ^0.21.2 + flutter_hooks: ^0.21.3 hooks_riverpod: ^2.6.1 bitsdojo_window: ^0.1.6 go_router: ^16.1.0 @@ -67,13 +67,13 @@ dependencies: easy_localization: ^3.0.8 flutter_inappwebview: ^6.1.5 animations: ^2.0.11 - package_info_plus: ^8.3.0 + package_info_plus: ^8.3.1 device_info_plus: ^11.5.0 tus_client_dart: git: https://github.com/LittleSheep2Code/tus_client.git cross_file: ^0.3.4+2 image_picker: ^1.1.2 - file_picker: ^10.2.4 + file_picker: ^10.3.1 riverpod_annotation: ^2.6.1 image_picker_platform_interface: ^2.10.1 image_picker_android: ^0.8.12+25 @@ -121,7 +121,7 @@ dependencies: local_auth: ^2.3.0 flutter_secure_storage: ^9.2.4 flutter_math_fork: ^0.7.4 - share_plus: ^11.0.0 + share_plus: ^11.1.0 receive_sharing_intent: ^1.8.1 top_snackbar_flutter: ^3.3.0 textfield_tags: