1 Commits

Author SHA1 Message Date
Your Name
3109a93163 Fixed issue not recognizing browser extension 2025-09-22 15:37:53 -04:00
5 changed files with 779 additions and 1012 deletions

View File

@@ -104,6 +104,18 @@
}}); }});
// Check for existing authentication state on page load
const authState = getAuthState();
if (authState && authState.method) {
console.log('Found existing authentication:', authState.method);
document.getElementById('status').textContent = `Authenticated with: ${authState.method}`;
document.getElementById('test-section').style.display = 'block';
// Store some test data for encryption/decryption
window.testCiphertext = null;
window.testCiphertext44 = null;
}
// Listen for authentication events // Listen for authentication events
window.addEventListener('nlMethodSelected', (event) => { window.addEventListener('nlMethodSelected', (event) => {
console.log('User authenticated:', event.detail); console.log('User authenticated:', event.detail);

View File

@@ -1 +1 @@
0.1.4 0.1.5

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1131,7 +1131,6 @@ class Modal {
} }
_setAuthMethod(method, options = {}) { _setAuthMethod(method, options = {}) {
// SINGLE-EXTENSION ARCHITECTURE: Handle method switching
console.log('Modal: _setAuthMethod called with:', method, options); console.log('Modal: _setAuthMethod called with:', method, options);
// CRITICAL: Never install facade for extension methods - leave window.nostr as the extension // CRITICAL: Never install facade for extension methods - leave window.nostr as the extension
@@ -1154,46 +1153,57 @@ class Modal {
return; return;
} }
// For non-extension methods, we need to ensure WindowNostr facade is available // FOR NON-EXTENSION METHODS: Force-install facade with resilience
console.log('Modal: Non-extension method detected:', method); console.log('Modal: Non-extension method - FORCE-INSTALLING facade with resilience:', method);
// Check if we have a preserved extension but no WindowNostr facade installed // Store the current extension if any (for potential restoration later)
const hasPreservedExtension = !!window.NOSTR_LOGIN_LITE?._instance?.preservedExtension; const currentExtension = (window.nostr?.constructor?.name !== 'WindowNostr') ? window.nostr : null;
const hasWindowNostrFacade = window.nostr?.constructor?.name === 'WindowNostr';
console.log('Modal: Method switching check:'); // Get NostrLite instance for facade operations
console.log(' method:', method); const nostrLiteInstance = window.NOSTR_LOGIN_LITE?._instance;
console.log(' hasPreservedExtension:', hasPreservedExtension); if (!nostrLiteInstance || typeof nostrLiteInstance._installFacade !== 'function') {
console.log(' hasWindowNostrFacade:', hasWindowNostrFacade); console.error('Modal: Cannot access NostrLite instance or _installFacade method');
console.log(' current window.nostr constructor:', window.nostr?.constructor?.name); // Fallback: emit event anyway
const event = new CustomEvent('nlMethodSelected', {
detail: { method, ...options }
});
window.dispatchEvent(event);
this.close();
return;
}
// If we have a preserved extension but no facade, install facade for method switching // IMMEDIATE FACADE INSTALLATION
if (hasPreservedExtension && !hasWindowNostrFacade) { console.log('Modal: Installing WindowNostr facade immediately for method:', method);
console.log('Modal: Installing WindowNostr facade for method switching (non-extension authentication)'); const preservedExtension = nostrLiteInstance.preservedExtension || currentExtension;
nostrLiteInstance._installFacade(preservedExtension, true);
console.log('Modal: WindowNostr facade force-installed, current window.nostr:', window.nostr?.constructor?.name);
// DELAYED FACADE RESILIENCE - Reinstall after extension override attempts
const forceReinstallFacade = () => {
console.log('Modal: RESILIENCE CHECK - Current window.nostr after delay:', window.nostr?.constructor?.name);
// Get the NostrLite instance and install facade with preserved extension // If facade was overridden by extension, reinstall it
const nostrLiteInstance = window.NOSTR_LOGIN_LITE?._instance; if (window.nostr?.constructor?.name !== 'WindowNostr') {
if (nostrLiteInstance && typeof nostrLiteInstance._installFacade === 'function') { console.log('Modal: FACADE OVERRIDDEN! Force-reinstalling WindowNostr facade for user choice:', method);
const preservedExtension = nostrLiteInstance.preservedExtension; nostrLiteInstance._installFacade(preservedExtension, true);
console.log('Modal: Installing facade with preserved extension:', preservedExtension?.constructor?.name); console.log('Modal: Resilient facade force-reinstall complete, window.nostr:', window.nostr?.constructor?.name);
nostrLiteInstance._installFacade(preservedExtension); // Schedule another check in case of persistent extension override
console.log('Modal: WindowNostr facade installed for method switching'); setTimeout(() => {
if (window.nostr?.constructor?.name !== 'WindowNostr') {
console.log('Modal: PERSISTENT OVERRIDE! Final facade force-reinstall for method:', method);
nostrLiteInstance._installFacade(preservedExtension, true);
}
}, 1000);
} else { } else {
console.error('Modal: Cannot access NostrLite instance or _installFacade method'); console.log('Modal: Facade persistence verified - no override detected');
} }
} };
// If no extension at all, ensure facade is installed for local/NIP-46/readonly methods // Schedule resilience checks at multiple intervals
else if (!hasPreservedExtension && !hasWindowNostrFacade) { setTimeout(forceReinstallFacade, 100); // Quick check
console.log('Modal: Installing WindowNostr facade for non-extension methods (no extension detected)'); setTimeout(forceReinstallFacade, 500); // Main check
setTimeout(forceReinstallFacade, 1500); // Final check
const nostrLiteInstance = window.NOSTR_LOGIN_LITE?._instance;
if (nostrLiteInstance && typeof nostrLiteInstance._installFacade === 'function') {
nostrLiteInstance._installFacade();
console.log('Modal: WindowNostr facade installed for non-extension methods');
}
}
// Emit auth method selection // Emit auth method selection
const event = new CustomEvent('nlMethodSelected', { const event = new CustomEvent('nlMethodSelected', {