feat(identity): adding a profile from inside, as a key and not a second wallet
Phase 5 of docs/multiple-profiles.md. The two entrances, and the two things that were only safe with one profile. Under the list, on the switcher and on the startup selector alike, two rows: "sign in with a key", to the sign-in screen, and "create a new profile", to the create screen. Both push a screen that has a back button. Landing is not one of them -- it has no back button and clears the stack on its way out, because it is the first-run screen, and pushing it from inside would make it a pushed screen on some days and a root on others. A device with one profile can now be given a second, which it could not: Landing showed only when the device held nothing. A profile created from inside is a bare key. CreateProfileScreen generated twelve words behind its form -- a seed, a node, a wallet, and at the NIP-06 path the key that becomes the profile -- which is right for the first profile on a device, the one the wallet will belong to, and wrong for the second: a user who wants another profile has not asked for another Lightning node, another set of channels, or a second phrase with funds behind it. The screen now takes a NewProfileWriter and does not know which it was given: seedProfileWriter from Landing, bareKeyProfileWriter from the switcher, thirty-two random bytes written the way a pasted nsec is. CreateProfileRoute carries the choice. The view model writes the secret first, then the six bootstrap events for the key it derives, then hands the id to the tail -- so the events are only ever queued for a key the device holds, and they are in the database before the tail activates the identity, an ordering the sign-in screen documents as load-bearing and the create flow used to get away with by luck. The tail gains the popUpTo(0) the sign-in tail has. A second wallet is not offered from inside; a pasted recovery phrase still brings its own. "End this" goes. It wiped the database -- every profile's rooms, MLS state, key packages and queues -- from the screen whose purpose is to add a profile; it was only ever a development exit, and with several profiles on a device it was a way to lose the others. wipeDatabase leaves the view model and stays on the repository for the tests that use it. A key already on the device is refused with the id it is listed under. WriteNostrCredentialResult.AlreadyExists and WritingSeedState.Error. SeedAlreadyExists carry it -- the wallet's id where a seed derives the key -- and the sign-in screen's error state gains one action, "switch to it", which is the sign-in tail with that id. From Landing "already on this device" was the whole message; from inside it is a sentence with an obvious next step, and a duplicate paste becomes the fastest switch in the app. Found on the way, and fixed in the jvm actuals: DataStoreManager caches one GlobalPrefs per process behind an unsynchronised check-then-set, and DataStore refuses a second instance over the same file. Two first calls at once -- the listing on IO and a sign-in's write, or the startup screen on Main -- could both see the empty cache and both build one, and the loser threw "multiple DataStores active for the same file" at first use. The test for this phase hit it one run in three. JvmGlobalPrefs is now the one way the jvm target reaches the prefs, under a lock; Android goes through the Application's single instance and never raced; the library's own callers come at node start, when the cache is long populated. Tests: AddProfileFromInsideJvmTest, through the real view models on an in-memory database -- A open, B's nsec committed and switched to, and back, both accounts intact with their own kind 0; A's key pasted again refused with A's id; a profile made through the bare-key writer lists as a bare key with the kind 0 first of its six bootstrap rows, none signed yet, and no node ran. SignInToProfileViewModelJvmTest and IdentityWriterJvmTest assert the ids the three refusals carry. ProfilesScreenJvmTest: the two rows call their callbacks and switch nothing, under the caption that the open profile stays. CreateProfileScreenJvmTest: the state that carried "end this" is composed and the words are not there. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
25464595f4
commit
2f42023081
24 files changed
+624
-201
No files matched your search
@@ -85,7 +85,6 @@
|
||||
<string name="eg_st">eg. st</string>
|
||||
<string name="eg_to_kill_a_mocking_bird">eg. To Kill a Mocking Bird</string>
|
||||
<string name="emergency_kit">Emergency kit</string>
|
||||
<string name="end_this">end this</string>
|
||||
<string name="ended">ENDED</string>
|
||||
<string name="encrypt_and_back_your_recovery_information">Encrypt and back your recovery information up to your Google Drive or iCloud.</string>
|
||||
<string name="enter_the_name_you_want_to_use_for_your">Enter the name you want to use for your group</string>
|
||||
@@ -714,4 +713,9 @@
|
||||
<string name="loading_profiles">Loading profiles…</string>
|
||||
<string name="switch_profile">Switch profile</string>
|
||||
<string name="wallet">Wallet</string>
|
||||
<!-- Adding a profile from inside: the two rows under the list, and the duplicate that switches. -->
|
||||
<string name="create_a_new_profile">Create a new profile</string>
|
||||
<string name="sign_in_with_a_key">Sign in with a key</string>
|
||||
<string name="switch_to_it">Switch to it</string>
|
||||
<string name="the_profile_you_are_in_stays_on_this_device">The profile you are in stays on this device.</string>
|
||||
</resources>
|
||||
Reference in new issue
Block a user