Add public key (npub) login support
- Backend: POST /auth/login-npub endpoint, JWT carries login method - Backend: Enforce Lightning address lock for npub logins in claim/quote - Frontend: LoginModal supports npub via new endpoint, clear copy - Frontend: Track loginMethod, lock LN address editing for npub users - Handle missing Lightning address for npub users with helpful message Made-with: Cursor
This commit is contained in:
@@ -5,7 +5,7 @@ import { nip98Auth } from "./nip98.js";
|
||||
const BEARER_PREFIX = "Bearer ";
|
||||
|
||||
/**
|
||||
* Accept either Bearer JWT or NIP-98. Sets req.nostr = { pubkey }.
|
||||
* Accept either Bearer JWT or NIP-98. Sets req.nostr = { pubkey, method }.
|
||||
*/
|
||||
export function authOrNip98(req: Request, res: Response, next: NextFunction): void {
|
||||
const auth = req.headers.authorization;
|
||||
@@ -13,7 +13,7 @@ export function authOrNip98(req: Request, res: Response, next: NextFunction): vo
|
||||
const token = auth.slice(BEARER_PREFIX.length).trim();
|
||||
const payload = verifyJwt(token);
|
||||
if (payload) {
|
||||
req.nostr = { pubkey: payload.pubkey, eventId: "" };
|
||||
req.nostr = { pubkey: payload.pubkey, eventId: "", method: payload.method };
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ const AUTH_SCHEME = "Nostr ";
|
||||
export interface NostrAuthPayload {
|
||||
pubkey: string;
|
||||
eventId: string;
|
||||
method?: "nip98" | "npub";
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
Reference in New Issue
Block a user