**Nostr Login:** Added server-side fallback for fresh challenges and improved client-side challenge resolution.

- 🔄 `requestNostrChallenge` now issues a new challenge when needed.
- 🛡️ Enhanced fallback logic in `nostrLogin.js` to ensure robust challenge retrieval.
-  Added test coverage for fresh challenge issuance.
This commit is contained in:
BT
2026-05-03 23:53:46 +02:00
parent bd7d39c1d7
commit 2efc88a7f8
3 changed files with 78 additions and 12 deletions
+17
View File
@@ -66,6 +66,23 @@ it('creates a new user and dispatches FetchNostrProfileJob when an unknown pubke
expect(auth()->id())->toBe($user->id);
});
it('issues a fresh challenge when requestNostrChallenge is called and the same value is verifiable', function () {
$component = Livewire::test('auth.login');
$initial = Session::get('nostr_login_challenge');
expect($initial)->toBeString()->not->toBe('');
$component->call('requestNostrChallenge');
$refreshed = Session::get('nostr_login_challenge');
expect($refreshed)
->toBeString()
->not->toBe('')
->not->toBe($initial);
$component->assertSet('nostrChallenge', $refreshed);
});
it('logs in an existing user without creating a duplicate when their pubkey is already known', function () {
Queue::fake();