feat(useragent): bootstrap / unseal flow implementattion

This commit is contained in:
hdbg
2026-03-15 22:12:21 +01:00
parent c61a9e30ac
commit 4db102b3d1
19 changed files with 1213 additions and 114 deletions

View File

@@ -6,6 +6,7 @@ part 'bootstrap_token.g.dart';
@Riverpod(keepAlive: true)
class BootstrapToken extends _$BootstrapToken {
@override
String? build() {
return null;
}
@@ -14,9 +15,13 @@ class BootstrapToken extends _$BootstrapToken {
state = token;
}
void clear() {
state = null;
}
String? take() {
final token = state;
state = null;
return token;
}
}
}

View File

@@ -41,7 +41,7 @@ final class BootstrapTokenProvider
}
}
String _$bootstrapTokenHash() => r'a59e679ab0561ed2ab4148660499891571d439db';
String _$bootstrapTokenHash() => r'5c09ea4480fc3a7fd0d0a0bced712912542cca5d';
abstract class _$BootstrapToken extends $Notifier<String?> {
String? build();

View File

@@ -20,12 +20,18 @@ class ConnectionManager extends _$ConnectionManager {
}
final Connection connection;
try {
connection = await connectAndAuthorize(serverInfo, key, bootstrapToken: token);
connection = await connectAndAuthorize(
serverInfo,
key,
bootstrapToken: token,
);
if (token != null) {
ref.read(bootstrapTokenProvider.notifier).clear();
}
} catch (e) {
talker.handle(e);
rethrow;
}
ref.onDispose(() {
final connection = state.asData?.value;

View File

@@ -33,7 +33,7 @@ final class ConnectionManagerProvider
ConnectionManager create() => ConnectionManager();
}
String _$connectionManagerHash() => r'8923346dff75a9a06127c71a0a39ca65d9733d8c';
String _$connectionManagerHash() => r'd01084e550f315bc6cadfe74413a7f959426a80e';
abstract class _$ConnectionManager extends $AsyncNotifier<Connection?> {
FutureOr<Connection?> build();