feat(base)!: a handle at password sign-up (ADR 0020, D26, D28–D30)
Every new account gets a handle, and an account without one gets its first as it sets a password. The handle is private until its person goes public (D5). - `passwordSignIn.signUp` takes a handle. `passwordSignIn.checkHandle` says whether a sign-up could take one, only while that sign-up's mailed code waits (`codeExpired` otherwise), counted per code request (30 an hour) and per network (60) (D29). Members ask the register. - `password.set` takes the first handle of an account without one (D28); `SignInWays.handle` tells the app whether there is one. - Each checks the handle before the code is used, so a refusal leaves the code for another try. An existing account at the address keeps its own handle where it has one, and the typed handle is still checked, so the answer says nothing about the address. - `first_handle.dart` holds what SimpleLogin, the keys and passwords share: `refusalOfNewHandle`, `insertFirstProfile`, `hasHandle`. - halkyon_app: one `HandleField` with its `HandleCheckCubit` (asked 300 ms after typing pauses, only about the handle typed last; the instance's suggestion is free without asking) (D30). The password setup asks for the handle between the phrase check and the code, and a refusal at the code sends back to it. SimpleLogin's sign-up and keys steps use the same field and now check as it is typed. - The module's README and ADR 0020 (D29, D30, the built state) amended. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
87671208df
commit
630965d920
1 changed files with 2305 additions and 395 deletions
|
|
@ -463,9 +463,15 @@ final class _Register implements AccountRegister {
|
|||
required PasswordSetup setup,
|
||||
UuidValue? request,
|
||||
String? code,
|
||||
String? handle,
|
||||
required String network,
|
||||
bool freshGitHubSignIn = false,
|
||||
UuidValue? keepSession,
|
||||
}) => _answer('setPassword', () {
|
||||
networks.add(network);
|
||||
if (handle != null) {
|
||||
handlesChecked.add(handle);
|
||||
}
|
||||
add(person);
|
||||
passwords.add(person);
|
||||
if (freshGitHubSignIn) {
|
||||
|
|
@ -512,13 +518,29 @@ final class _Register implements AccountRegister {
|
|||
return _answer('completePasswordSignIn', _proven);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ProfileRefusal?> checkSignUpHandle(
|
||||
Session session, {
|
||||
required UuidValue request,
|
||||
required String handle,
|
||||
required String network,
|
||||
}) => _answer('checkSignUpHandle', () {
|
||||
networks.add(network);
|
||||
handlesChecked.add(handle);
|
||||
return handleRefusal;
|
||||
});
|
||||
|
||||
@override
|
||||
Future<UuidValue> signUpWithCode(
|
||||
Session session, {
|
||||
required UuidValue request,
|
||||
required String code,
|
||||
required PasswordSetup setup,
|
||||
required String handle,
|
||||
required String network,
|
||||
}) => _answer('signUpWithCode', () {
|
||||
networks.add(network);
|
||||
handlesChecked.add(handle);
|
||||
final account = const Uuid().v7obj();
|
||||
add(account);
|
||||
passwords.add(account);
|
||||
|
|
@ -1020,6 +1042,23 @@ void main() {
|
|||
);
|
||||
});
|
||||
|
||||
test("checks a sign-up's handle at the register while the code "
|
||||
'travels (ADR 0020, D29), the device network passed on', () async {
|
||||
register.handleRefusal = ProfileRefusal.handleTaken;
|
||||
|
||||
expect(
|
||||
await endpoints.passwordSignIn.checkHandle(
|
||||
notSignedIn(),
|
||||
request: const Uuid().v7obj(),
|
||||
handle: 'carla',
|
||||
),
|
||||
ProfileRefusal.handleTaken,
|
||||
);
|
||||
expect(register.asked, ['checkSignUpHandle']);
|
||||
expect(register.handlesChecked, ['carla']);
|
||||
expect(register.networks, hasLength(1));
|
||||
});
|
||||
|
||||
test('sign up at the register, the new account signed in here, '
|
||||
'identified', () async {
|
||||
final device = await PasswordDevice.make();
|
||||
|
|
@ -1029,9 +1068,12 @@ void main() {
|
|||
request: const Uuid().v7obj(),
|
||||
code: 'K7QX-M2PD',
|
||||
setup: device.setup(),
|
||||
handle: 'anna',
|
||||
);
|
||||
|
||||
expect(register.asked, ['signUpWithCode']);
|
||||
expect(register.handlesChecked, ['anna']);
|
||||
expect(register.networks, hasLength(1));
|
||||
expect(register.passwords, {signedUp.authUserId});
|
||||
expect(await scopesOf(signedUp.authUserId), {identified.name});
|
||||
expect(
|
||||
|
|
|
|||
Loading…
Reference in a new issue