mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-06 00:37:23 +00:00
fix: callback for non-mobile and localstorage
This commit is contained in:
1 parent
86d3d67eef
commit
ac88a3a5c1
3 files changed
+121
-3
No files matched your search
@@ -8,6 +8,12 @@ import { useAppContext } from '@/hooks/useAppContext';
|
||||
|
||||
// NOTE: This file should not be edited except for adding new login methods.
|
||||
|
||||
/** Check if running on actual mobile device (not just small screen) */
|
||||
function isMobileDevice(): boolean {
|
||||
if (typeof navigator === 'undefined') return false;
|
||||
return /Android|iPhone|iPad|iPod/i.test(navigator.userAgent);
|
||||
}
|
||||
|
||||
/** Parameters for initiating a nostrconnect:// session */
|
||||
export interface NostrConnectParams {
|
||||
clientSecretKey: Uint8Array;
|
||||
@@ -29,9 +35,10 @@ export function generateNostrConnectURI(params: NostrConnectParams, appName?: st
|
||||
searchParams.set('name', appName);
|
||||
}
|
||||
|
||||
// Add callback URL based on current origin (works on any domain)
|
||||
if (typeof window !== 'undefined') {
|
||||
searchParams.set('callback', window.location.origin);
|
||||
// Add callback URL only on mobile devices (not desktop QR code scanning)
|
||||
// When scanning QR from desktop, the signer app is on the phone but the session is on desktop
|
||||
if (typeof window !== 'undefined' && isMobileDevice()) {
|
||||
searchParams.set('callback', `${window.location.origin}/remoteloginsuccess`);
|
||||
}
|
||||
|
||||
return `nostrconnect://${params.clientPubkey}?${searchParams.toString()}`;
|
||||
|
||||
Reference in new issue
Block a user