mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
**Category:** new-feature **User Impact:** Mobile users must confirm with Face ID, biometrics, or their device passcode before sending their Buzz identity to Desktop. **Problem:** A signed-in phone could send its full identity, including the `nsec`, to a desktop without fresh local verification. **Solution:** Require OS device authentication before opening the identity-recovery scanner, retain that authorization only for the active pairing session and short pairing window, and require fresh authentication again if it expires before the identity payload is sent. Normal app opening, identity import, and community removal remain unchanged. ## Screencasts | Enable Face ID | Use Face ID | | --- | --- | |  |  | <details> <summary>File changes</summary> **Android and iOS integration** - `mobile/android/app/build.gradle.kts` declares the AppCompat dependency required by the biometric activity theme. - `mobile/android/app/src/main/kotlin/xyz/block/buzz/mobile/MainActivity.kt` uses the activity type required by the system authentication prompt. - `mobile/android/app/src/main/res/values/styles.xml` and `mobile/android/app/src/main/res/values-night/styles.xml` use the compatible launch theme. - `mobile/ios/Podfile.lock` records the native local-authentication dependency. - `mobile/ios/Runner/Info.plist` explains why Buzz requests Face ID access. **Identity policy and pairing flow** - `mobile/lib/shared/security/sensitive_action_authorizer.dart` wraps OS authentication and maps platform errors to stable app-level outcomes. - `mobile/lib/shared/community/community.dart` and `mobile/lib/shared/community/community_storage.dart` persist the sensitive-action policy. - `mobile/lib/features/invites/invite_join_provider.dart` assigns the explicit policy for invite-created communities. - `mobile/lib/features/pairing/pairing_provider.dart` gates export, binds grants to the active community/session, reauthenticates expired grants, and clears grants on every terminal path. - `mobile/lib/features/pairing/pairing_page.dart` lets users choose biometric protection while importing an identity. - `mobile/lib/features/settings/settings_page.dart` wires pairing into settings. - `mobile/lib/features/settings/settings_page/connection_section.dart` authenticates before opening export recovery and bounds the foreground-resume wait. - `mobile/pubspec.yaml` and `mobile/pubspec.lock` add and lock `local_auth`. **Coverage** - `mobile/test/shared/security/sensitive_action_authorizer_test.dart` covers native result mapping, unsupported devices, and single-flight behavior. - `mobile/test/shared/community/community_test.dart` and `mobile/test/shared/community/community_storage_test.dart` cover policy defaults and persistence. - `mobile/test/features/invites/invite_join_provider_test.dart` covers the invite policy. - `mobile/test/features/pairing/pairing_page_test.dart` covers import protection controls. - `mobile/test/features/pairing/pairing_provider_test.dart` covers export/import authorization, stale/reset/concurrent guards, malformed payload cleanup, and no-export failure paths. - `mobile/test/features/settings/connection_section_test.dart` covers the tap gate, lifecycle resume, and timeout behavior. </details> ## Reproduction steps 1. Pair an identity into the mobile app. 2. Open Settings and choose “Send identity to desktop.” 3. Verify Face ID, biometrics, or the device passcode is required before the recovery scanner opens. 4. Cancel device authentication and verify the scanner does not open and no identity transfer begins. 5. Authenticate, scan a Desktop recovery code, confirm the SAS, and verify the identity transfer completes. ## Validation At `be5620f5f10aa6cc16e86a4f01f102f3d9aeef9b`: - `cd mobile && ../bin/flutter analyze` — no issues - `cd mobile && ../bin/flutter test` — 1,368 tests passed - `cd mobile/android && JAVA_HOME=$(/usr/libexec/java_home -v 21) ./gradlew app:assembleDebug` — debug APK assembled successfully --------- Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
139 lines
4.2 KiB
Dart
139 lines
4.2 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:lucide_icons_flutter/lucide_icons.dart';
|
|
import 'package:nostr/nostr.dart' as nostr;
|
|
import 'package:package_info_plus/package_info_plus.dart';
|
|
|
|
import '../../shared/auth/auth.dart';
|
|
import '../../shared/clipboard_utils.dart';
|
|
import '../../shared/community/community_membership_provider.dart';
|
|
import '../../shared/relay/relay.dart';
|
|
import '../pairing/pairing_provider.dart';
|
|
import '../../shared/theme/theme.dart';
|
|
import '../../shared/widgets/app_list.dart';
|
|
import '../../shared/widgets/app_list_card.dart';
|
|
import '../../shared/widgets/frosted_app_bar.dart';
|
|
import '../../shared/widgets/frosted_scaffold.dart';
|
|
import '../../shared/widgets/modal_presentation.dart';
|
|
import 'accent_picker_page.dart';
|
|
import 'theme_picker_page.dart';
|
|
|
|
part 'settings_page/appearance_section.dart';
|
|
part 'settings_page/community_section.dart';
|
|
part 'settings_page/connection_section.dart';
|
|
|
|
class SettingsPage extends HookConsumerWidget {
|
|
/// Creates the settings page.
|
|
const SettingsPage({
|
|
super.key,
|
|
required this.profileHeader,
|
|
required this.invitePageBuilder,
|
|
required this.identityRecoveryPageBuilder,
|
|
});
|
|
|
|
/// Header widget displayed at the top of settings.
|
|
final Widget profileHeader;
|
|
|
|
/// Builds the community-invite page pushed from the invite settings row.
|
|
final WidgetBuilder invitePageBuilder;
|
|
|
|
/// Builds the identity-recovery page pushed from the recovery settings row.
|
|
final WidgetBuilder identityRecoveryPageBuilder;
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final packageInfoFuture = useMemoized(() => PackageInfo.fromPlatform());
|
|
final packageInfo = useFuture(packageInfoFuture);
|
|
final topSectionHeight = frostedAppBarHeight(
|
|
context,
|
|
bottomHeight: Grid.xxs,
|
|
);
|
|
|
|
return FrostedScaffold(
|
|
backgroundColor: context.colors.surface,
|
|
appBar: FrostedAppBar(
|
|
automaticallyImplyLeading: false,
|
|
horizontalInset: Grid.gutter,
|
|
showBottomDivider: false,
|
|
leading: SizedBox(
|
|
width: Grid.xl,
|
|
height: Grid.xl,
|
|
child: IconButton(
|
|
tooltip: 'Close settings',
|
|
onPressed: () {
|
|
unawaited(HapticFeedback.lightImpact());
|
|
Navigator.of(context).pop();
|
|
},
|
|
color: navigationPrimaryForeground(context),
|
|
icon: const Icon(LucideIcons.x),
|
|
),
|
|
),
|
|
bottomHeight: Grid.xxs,
|
|
bottom: const SizedBox.expand(),
|
|
),
|
|
body: Column(
|
|
children: [
|
|
Expanded(
|
|
child: ListView(
|
|
padding: EdgeInsets.only(top: topSectionHeight, bottom: Grid.xs),
|
|
children: [
|
|
profileHeader,
|
|
_CommunitySection(invitePageBuilder: invitePageBuilder),
|
|
const _AppearanceSection(),
|
|
_ConnectionSection(
|
|
identityRecoveryPageBuilder: identityRecoveryPageBuilder,
|
|
),
|
|
const _RemoveCommunitySection(),
|
|
],
|
|
),
|
|
),
|
|
if (packageInfo.hasData)
|
|
_VersionFooter(version: packageInfo.data!.version),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _VersionFooter extends StatelessWidget {
|
|
const _VersionFooter({required this.version});
|
|
|
|
final String version;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SafeArea(
|
|
top: false,
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(bottom: Grid.xs, top: Grid.xxs),
|
|
child: Center(
|
|
child: Text(
|
|
'v$version',
|
|
style: context.textTheme.bodySmall?.copyWith(
|
|
color: context.colors.onSurfaceVariant.withValues(alpha: 0.6),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Trailing affordance shared by the rows that push a picker page.
|
|
class _RowChevron extends StatelessWidget {
|
|
const _RowChevron();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Icon(
|
|
LucideIcons.chevronRight,
|
|
size: 18,
|
|
color: context.colors.onSurfaceVariant,
|
|
);
|
|
}
|
|
}
|