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
|
|
@ -268,6 +268,7 @@ void main() {
|
|||
address: 'ben@example.org',
|
||||
request: request,
|
||||
code: gateway.codeFor('ben@example.org'),
|
||||
handle: 'ben',
|
||||
);
|
||||
|
||||
expect(pending.needsAuthenticator, isTrue);
|
||||
|
|
@ -293,10 +294,76 @@ void main() {
|
|||
address: 'anna@example.org',
|
||||
request: request,
|
||||
code: gateway.codeFor('anna@example.org'),
|
||||
handle: 'anna_again',
|
||||
),
|
||||
failsWith(PasswordProblem.passwordExists),
|
||||
);
|
||||
});
|
||||
|
||||
test('checks the handle against the code mailed for the sign-up, and '
|
||||
'for nothing else (ADR 0020, D29)', () async {
|
||||
final request = await passwords.sendCode(
|
||||
'ben@example.org',
|
||||
language: 'en',
|
||||
purpose: MailCodePurpose.signUp,
|
||||
);
|
||||
gateway.handles['someone-else'] = 'anna';
|
||||
|
||||
expect(
|
||||
await passwords.checkSignUpHandle(request: request, handle: 'ben'),
|
||||
isNull,
|
||||
);
|
||||
expect(
|
||||
await passwords.checkSignUpHandle(request: request, handle: 'Anna'),
|
||||
HandleProblem.taken,
|
||||
);
|
||||
final reset = await passwords.sendCode(
|
||||
'ben@example.org',
|
||||
language: 'en',
|
||||
purpose: MailCodePurpose.accountReset,
|
||||
);
|
||||
await expectLater(
|
||||
passwords.checkSignUpHandle(request: reset, handle: 'ben'),
|
||||
failsWith(PasswordProblem.mailCodeExpired),
|
||||
);
|
||||
expect(gateway.handlesChecked, ['ben', 'Anna']);
|
||||
});
|
||||
|
||||
test('is refused a handle taken meanwhile before the code is used, '
|
||||
'which signs up with another', () async {
|
||||
final material = await passwords.makePassword('a new password');
|
||||
final request = await passwords.sendCode(
|
||||
'ben@example.org',
|
||||
language: 'en',
|
||||
purpose: MailCodePurpose.signUp,
|
||||
);
|
||||
gateway.handles['someone-else'] = 'ben';
|
||||
final code = gateway.codeFor('ben@example.org');
|
||||
|
||||
await expectLater(
|
||||
passwords.signUp(
|
||||
material,
|
||||
address: 'ben@example.org',
|
||||
request: request,
|
||||
code: code,
|
||||
handle: 'ben',
|
||||
),
|
||||
failsWith(PasswordProblem.handleTaken),
|
||||
);
|
||||
expect(gateway.accounts, isEmpty);
|
||||
|
||||
await passwords.signUp(
|
||||
material,
|
||||
address: 'ben@example.org',
|
||||
request: request,
|
||||
code: code,
|
||||
handle: 'ben_k',
|
||||
);
|
||||
expect(
|
||||
gateway.handles[gateway.accounts['ben@example.org']!.person],
|
||||
'ben_k',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
group('signed in', () {
|
||||
|
|
@ -310,11 +377,23 @@ void main() {
|
|||
);
|
||||
|
||||
final material = await passwords.makePassword('her password');
|
||||
// Without the handle it lacks, before the code is used (ADR 0020,
|
||||
// D28).
|
||||
await expectLater(
|
||||
passwords.setPassword(
|
||||
material,
|
||||
address: 'dana@example.org',
|
||||
request: request,
|
||||
code: gateway.codeFor('dana@example.org'),
|
||||
),
|
||||
failsWith(PasswordProblem.handleInvalid),
|
||||
);
|
||||
await passwords.setPassword(
|
||||
material,
|
||||
address: 'dana@example.org',
|
||||
request: request,
|
||||
code: gateway.codeFor('dana@example.org'),
|
||||
handle: 'dana',
|
||||
);
|
||||
|
||||
expect(
|
||||
|
|
@ -323,6 +402,7 @@ void main() {
|
|||
);
|
||||
expect(keys.kept['github-person'], material.keys);
|
||||
expect(addresses.addresses['github-person'], 'dana@example.org');
|
||||
expect(gateway.handles['github-person'], 'dana');
|
||||
});
|
||||
|
||||
test('someone signed up anew gets new keys, never the keys kept on the '
|
||||
|
|
|
|||
Loading…
Reference in a new issue