feat: implement three-phase Amber login flow in AuthModal

- Updated Amber login button to reflect new three-phase process.
- Added handling for reading public key and signature from clipboard.
- Introduced new state management for Amber login phases.
- Enhanced user feedback during each phase with appropriate messaging.
- Refactored related functions for clarity and maintainability.
This commit is contained in:
Dorian
2026-02-14 09:28:25 +00:00
parent 38293b1f95
commit 276dab207c
6 changed files with 434 additions and 170 deletions

View File

@@ -243,9 +243,19 @@ export const useAuthStore = defineStore('auth', () => {
}
/**
* Login with Nostr signature
* Login with Nostr signature.
*
* @param preSignedAuthHeader Optional pre-built `Nostr <base64>` header.
* When provided the active signer is NOT called for NIP-98 signing.
* This is required for Amber / clipboard-based signers that cannot
* sign events inline.
*/
async function loginWithNostr(pubkey: string, signature: string, event: any) {
async function loginWithNostr(
pubkey: string,
signature: string,
event: any,
preSignedAuthHeader?: string,
) {
isLoading.value = true
// Mock Nostr login helper
@@ -271,12 +281,12 @@ export const useAuthStore = defineStore('auth', () => {
}
// Real API call — creates NIP-98 signed session via the active
// Nostr account in accountManager (set by useAccounts before this call)
const response = await authService.createNostrSession({
pubkey,
signature,
event,
})
// Nostr account in accountManager (set by useAccounts before this call).
// When preSignedAuthHeader is provided the signer is bypassed.
const response = await authService.createNostrSession(
{ pubkey, signature, event },
preSignedAuthHeader,
)
nostrPubkey.value = pubkey
authType.value = 'nostr'