3 Commits

Author SHA1 Message Date
Your Name
cb4f4b2a3c Remove more logs 2025-11-14 14:31:40 -04:00
Your Name
05a5306f86 Reorganize directories 2025-11-14 13:59:08 -04:00
Your Name
98b87de736 Comment out debug prints 2025-11-14 13:45:29 -04:00
9 changed files with 73 additions and 73 deletions

View File

@@ -8,7 +8,7 @@
* Two-file architecture: * Two-file architecture:
* 1. Load nostr.bundle.js (official nostr-tools bundle) * 1. Load nostr.bundle.js (official nostr-tools bundle)
* 2. Load nostr-lite.js (this file - NOSTR_LOGIN_LITE library with CSS-only themes) * 2. Load nostr-lite.js (this file - NOSTR_LOGIN_LITE library with CSS-only themes)
* Generated on: 2025-11-14T17:32:27.512Z * Generated on: 2025-11-14T18:31:40.699Z
*/ */
// Verify dependencies are loaded // Verify dependencies are loaded
@@ -18,10 +18,10 @@ if (typeof window !== 'undefined') {
throw new Error('Missing dependency: nostr.bundle.js'); throw new Error('Missing dependency: nostr.bundle.js');
} }
console.log('NOSTR_LOGIN_LITE: Dependencies verified ✓'); // console.log('NOSTR_LOGIN_LITE: Dependencies verified ✓');
console.log('NOSTR_LOGIN_LITE: NostrTools available with keys:', Object.keys(window.NostrTools)); // console.log('NOSTR_LOGIN_LITE: NostrTools available with keys:', Object.keys(window.NostrTools));
console.log('NOSTR_LOGIN_LITE: NIP-06 available:', !!window.NostrTools.nip06); // console.log('NOSTR_LOGIN_LITE: NIP-06 available:', !!window.NostrTools.nip06);
console.log('NOSTR_LOGIN_LITE: NIP-46 available:', !!window.NostrTools.nip46); // console.log('NOSTR_LOGIN_LITE: NIP-46 available:', !!window.NostrTools.nip46);
} }
// ====================================== // ======================================
@@ -282,7 +282,7 @@ function injectThemeCSS(themeName = 'default') {
style.id = 'nl-theme-css'; style.id = 'nl-theme-css';
style.textContent = themeCss; style.textContent = themeCss;
document.head.appendChild(style); document.head.appendChild(style);
console.log('NOSTR_LOGIN_LITE: ' + themeName + ' theme CSS injected'); // console.log('NOSTR_LOGIN_LITE: ' + themeName + ' theme CSS injected');
} }
} }
@@ -436,7 +436,7 @@ class Modal {
modalContent.appendChild(modalHeader); modalContent.appendChild(modalHeader);
// Add version element in bottom-right corner aligned with modal body // Add version element in bottom-right corner aligned with modal body
const versionElement = document.createElement('div'); const versionElement = document.createElement('div');
versionElement.textContent = 'v0.1.8'; versionElement.textContent = 'v0.1.11';
versionElement.style.cssText = ` versionElement.style.cssText = `
position: absolute; position: absolute;
bottom: 8px; bottom: 8px;
@@ -3404,10 +3404,10 @@ class AuthManager {
// Configure storage type based on isolateSession option // Configure storage type based on isolateSession option
if (options.isolateSession) { if (options.isolateSession) {
this.storage = sessionStorage; this.storage = sessionStorage;
console.log('🔐 AuthManager: Using sessionStorage for per-window isolation'); // console.log('🔐 AuthManager: Using sessionStorage for per-window isolation');
} else { } else {
this.storage = localStorage; this.storage = localStorage;
console.log('🔐 AuthManager: Using localStorage for cross-window persistence'); // console.log('🔐 AuthManager: Using localStorage for cross-window persistence');
} }
console.warn('🔐 SECURITY: Private keys stored unencrypted in browser storage'); console.warn('🔐 SECURITY: Private keys stored unencrypted in browser storage');
@@ -3417,7 +3417,7 @@ class AuthManager {
// Save authentication state using unified plaintext approach // Save authentication state using unified plaintext approach
async saveAuthState(authData) { async saveAuthState(authData) {
try { try {
console.log('🔐 AuthManager: Saving auth state with plaintext storage'); // console.log('🔐 AuthManager: Saving auth state with plaintext storage');
console.warn('🔐 SECURITY: Private key will be stored unencrypted for maximum usability'); console.warn('🔐 SECURITY: Private key will be stored unencrypted for maximum usability');
const authState = { const authState = {
@@ -3434,14 +3434,14 @@ class AuthManager {
hasGetPublicKey: typeof authData.extension?.getPublicKey === 'function', hasGetPublicKey: typeof authData.extension?.getPublicKey === 'function',
hasSignEvent: typeof authData.extension?.signEvent === 'function' hasSignEvent: typeof authData.extension?.signEvent === 'function'
}; };
console.log('🔐 AuthManager: Extension method - storing verification data only'); // console.log('🔐 AuthManager: Extension method - storing verification data only');
break; break;
case 'local': case 'local':
// UNIFIED PLAINTEXT: Store secret key directly for maximum compatibility // UNIFIED PLAINTEXT: Store secret key directly for maximum compatibility
if (authData.secret) { if (authData.secret) {
authState.secret = authData.secret; authState.secret = authData.secret;
console.log('🔐 AuthManager: Local method - storing secret key in plaintext'); // console.log('🔐 AuthManager: Local method - storing secret key in plaintext');
console.warn('🔐 SECURITY: Secret key stored unencrypted for developer convenience'); console.warn('🔐 SECURITY: Secret key stored unencrypted for developer convenience');
} }
break; break;
@@ -3454,13 +3454,13 @@ class AuthManager {
relays: authData.signer.relays, relays: authData.signer.relays,
// Don't store secret - user will need to reconnect // Don't store secret - user will need to reconnect
}; };
console.log('🔐 AuthManager: NIP-46 method - storing connection parameters'); // console.log('🔐 AuthManager: NIP-46 method - storing connection parameters');
} }
break; break;
case 'readonly': case 'readonly':
// Read-only mode has no secrets to store // Read-only mode has no secrets to store
console.log('🔐 AuthManager: Read-only method - storing basic auth state'); // console.log('🔐 AuthManager: Read-only method - storing basic auth state');
break; break;
default: default:
@@ -3469,7 +3469,7 @@ class AuthManager {
this.storage.setItem(this.storageKey, JSON.stringify(authState)); this.storage.setItem(this.storageKey, JSON.stringify(authState));
this.currentAuthState = authState; this.currentAuthState = authState;
console.log('🔐 AuthManager: Auth state saved successfully for method:', authData.method); // console.log('🔐 AuthManager: Auth state saved successfully for method:', authData.method);
} catch (error) { } catch (error) {
console.error('🔐 AuthManager: Failed to save auth state:', error); console.error('🔐 AuthManager: Failed to save auth state:', error);
@@ -3707,17 +3707,17 @@ class AuthManager {
} }
async _restoreLocalAuth(authState) { async _restoreLocalAuth(authState) {
console.log('🔐 AuthManager: === _restoreLocalAuth (Unified Plaintext) ==='); // console.log('🔐 AuthManager: === _restoreLocalAuth (Unified Plaintext) ===');
// Check for legacy encrypted format first // Check for legacy encrypted format first
if (authState.encrypted) { if (authState.encrypted) {
console.log('🔐 AuthManager: Detected LEGACY encrypted format - migrating to plaintext'); // console.log('🔐 AuthManager: Detected LEGACY encrypted format - migrating to plaintext');
console.warn('🔐 SECURITY: Converting from encrypted to plaintext storage for compatibility'); console.warn('🔐 SECURITY: Converting from encrypted to plaintext storage for compatibility');
// Try to decrypt legacy format // Try to decrypt legacy format
const sessionPassword = sessionStorage.getItem('nostr_session_key'); const sessionPassword = sessionStorage.getItem('nostr_session_key');
if (!sessionPassword) { if (!sessionPassword) {
console.log('🔐 AuthManager: Legacy session password not found - user must re-login'); // console.log('🔐 AuthManager: Legacy session password not found - user must re-login');
return null; return null;
} }
@@ -3734,11 +3734,11 @@ class AuthManager {
// NEW UNIFIED PLAINTEXT FORMAT // NEW UNIFIED PLAINTEXT FORMAT
if (!authState.secret) { if (!authState.secret) {
console.log('🔐 AuthManager: No secret found in plaintext format'); // console.log('🔐 AuthManager: No secret found in plaintext format');
return null; return null;
} }
console.log('🔐 AuthManager: ✅ Local auth restored from plaintext storage'); // console.log('🔐 AuthManager: ✅ Local auth restored from plaintext storage');
console.warn('🔐 SECURITY: Secret key was stored unencrypted'); console.warn('🔐 SECURITY: Secret key was stored unencrypted');
return { return {
@@ -3750,14 +3750,14 @@ class AuthManager {
async _restoreNip46Auth(authState) { async _restoreNip46Auth(authState) {
if (!authState.nip46) { if (!authState.nip46) {
console.log('🔐 AuthManager: No NIP-46 data found'); // console.log('🔐 AuthManager: No NIP-46 data found');
return null; return null;
} }
// For NIP-46, we can't automatically restore the connection // For NIP-46, we can't automatically restore the connection
// because it requires the user to re-authenticate with the remote signer // because it requires the user to re-authenticate with the remote signer
// Instead, we return the connection parameters so the UI can prompt for reconnection // Instead, we return the connection parameters so the UI can prompt for reconnection
console.log('🔐 AuthManager: NIP-46 connection data found, requires user reconnection'); // console.log('🔐 AuthManager: NIP-46 connection data found, requires user reconnection');
return { return {
method: 'nip46', method: 'nip46',
pubkey: authState.pubkey, pubkey: authState.pubkey,
@@ -3767,7 +3767,7 @@ class AuthManager {
} }
async _restoreReadonlyAuth(authState) { async _restoreReadonlyAuth(authState) {
console.log('🔐 AuthManager: Read-only auth restored successfully'); // console.log('🔐 AuthManager: Read-only auth restored successfully');
return { return {
method: 'readonly', method: 'readonly',
pubkey: authState.pubkey pubkey: authState.pubkey
@@ -3779,7 +3779,7 @@ class AuthManager {
this.storage.removeItem(this.storageKey); this.storage.removeItem(this.storageKey);
sessionStorage.removeItem('nostr_session_key'); // Clear legacy session key sessionStorage.removeItem('nostr_session_key'); // Clear legacy session key
this.currentAuthState = null; this.currentAuthState = null;
console.log('🔐 AuthManager: Auth state cleared from unified storage'); // console.log('🔐 AuthManager: Auth state cleared from unified storage');
} }
// Check if we have valid stored auth // Check if we have valid stored auth
@@ -3822,7 +3822,7 @@ function getGlobalAuthManager() {
// **UNIFIED GLOBAL FUNCTION**: Set authentication state (works for all methods) // **UNIFIED GLOBAL FUNCTION**: Set authentication state (works for all methods)
function setAuthState(authData, options = {}) { function setAuthState(authData, options = {}) {
try { try {
console.log('🌐 setAuthState: Setting global auth state for method:', authData.method); // console.log('🌐 setAuthState: Setting global auth state for method:', authData.method);
console.warn('🔐 SECURITY: Using unified plaintext storage for maximum compatibility'); console.warn('🔐 SECURITY: Using unified plaintext storage for maximum compatibility');
// Store in memory // Store in memory
@@ -3832,7 +3832,7 @@ function setAuthState(authData, options = {}) {
const authManager = new AuthManager(options); const authManager = new AuthManager(options);
authManager.saveAuthState(authData); authManager.saveAuthState(authData);
console.log('🌐 setAuthState: Auth state saved successfully'); // console.log('🌐 setAuthState: Auth state saved successfully');
} catch (error) { } catch (error) {
console.error('🌐 setAuthState: Failed to save auth state:', error); console.error('🌐 setAuthState: Failed to save auth state:', error);
throw error; throw error;
@@ -3855,13 +3855,13 @@ function getAuthState() {
} }
if (!stored) { if (!stored) {
console.log('🌐 getAuthState: No auth state found in storage'); // console.log('🌐 getAuthState: No auth state found in storage');
globalAuthState = null; globalAuthState = null;
return null; return null;
} }
const authState = JSON.parse(stored); const authState = JSON.parse(stored);
console.log('🌐 getAuthState: Retrieved auth state:', authState.method); // console.log('🌐 getAuthState: Retrieved auth state:', authState.method);
// Update in-memory cache // Update in-memory cache
globalAuthState = authState; globalAuthState = authState;
@@ -3877,7 +3877,7 @@ function getAuthState() {
// **UNIFIED GLOBAL FUNCTION**: Clear authentication state (works for all methods) // **UNIFIED GLOBAL FUNCTION**: Clear authentication state (works for all methods)
function clearAuthState() { function clearAuthState() {
try { try {
console.log('🌐 clearAuthState: Clearing global auth state'); // console.log('🌐 clearAuthState: Clearing global auth state');
// Clear in-memory state // Clear in-memory state
globalAuthState = null; globalAuthState = null;
@@ -3888,7 +3888,7 @@ function clearAuthState() {
sessionStorage.removeItem(storageKey); sessionStorage.removeItem(storageKey);
sessionStorage.removeItem('nostr_session_key'); // Clear legacy session key sessionStorage.removeItem('nostr_session_key'); // Clear legacy session key
console.log('🌐 clearAuthState: Auth state cleared from all storage locations'); // console.log('🌐 clearAuthState: Auth state cleared from all storage locations');
} catch (error) { } catch (error) {
console.error('🌐 clearAuthState: Failed to clear auth state:', error); console.error('🌐 clearAuthState: Failed to clear auth state:', error);
} }
@@ -4271,9 +4271,9 @@ if (typeof window !== 'undefined') {
_instance: nostrLite _instance: nostrLite
}; };
console.log('NOSTR_LOGIN_LITE: Library loaded and ready'); // console.log('NOSTR_LOGIN_LITE: Library loaded and ready');
console.log('NOSTR_LOGIN_LITE: Use window.NOSTR_LOGIN_LITE.init(options) to initialize'); // console.log('NOSTR_LOGIN_LITE: Use window.NOSTR_LOGIN_LITE.init(options) to initialize');
console.log('NOSTR_LOGIN_LITE: Detected', nostrLite.extensionBridge.getExtensionCount(), 'browser extensions'); // console.log('NOSTR_LOGIN_LITE: Detected', nostrLite.extensionBridge.getExtensionCount(), 'browser extensions');
console.warn('🔐 SECURITY: Unified plaintext storage enabled for maximum developer usability'); console.warn('🔐 SECURITY: Unified plaintext storage enabled for maximum developer usability');
} else { } else {
// Node.js environment // Node.js environment

View File

@@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
rsync -avz --chmod=644 --progress lite/{nostr-lite.js,nostr.bundle.js} ubuntu@laantungir.net:WWW/nostr-login-lite/ rsync -avz --chmod=644 --progress build/{nostr-lite.js,nostr.bundle.js} ubuntu@laantungir.net:html/nostr-login-lite/

View File

@@ -55,14 +55,14 @@ new_tag="v$new_version"
echo -e "${GREEN}📈 Incrementing version: $current_version$new_version${NC}" echo -e "${GREEN}📈 Incrementing version: $current_version$new_version${NC}"
# Step 2.5: Save version to lite/VERSION file # Step 2.5: Save version to src/VERSION file
echo -e "${YELLOW}💾 Saving version to lite/VERSION...${NC}" echo -e "${YELLOW}💾 Saving version to src/VERSION...${NC}"
echo "$new_version" > lite/VERSION echo "$new_version" > src/VERSION
echo -e "Version saved: ${GREEN}$new_version${NC}" echo -e "Version saved: ${GREEN}$new_version${NC}"
# Step 2.5: Run build.js # Step 2.5: Run build.js
echo -e "${YELLOW}🔧 Running build process...${NC}" echo -e "${YELLOW}🔧 Running build process...${NC}"
cd lite cd src
node build.js node build.js
cd .. cd ..
echo -e "${GREEN}✅ Build completed${NC}" echo -e "${GREEN}✅ Build completed${NC}"
@@ -100,8 +100,8 @@ git push --tags
echo -e "${GREEN}🎉 Successfully completed:${NC}" echo -e "${GREEN}🎉 Successfully completed:${NC}"
echo -e " • Version incremented to: ${GREEN}$new_version${NC}" echo -e " • Version incremented to: ${GREEN}$new_version${NC}"
echo -e " • VERSION file updated: ${GREEN}lite/VERSION${NC}" echo -e " • VERSION file updated: ${GREEN}src/VERSION${NC}"
echo -e " • Build completed: ${GREEN}lite/nostr-lite.js${NC}" echo -e " • Build completed: ${GREEN}build/nostr-lite.js${NC}"
echo -e " • Git tag created: ${GREEN}$new_tag${NC}" echo -e " • Git tag created: ${GREEN}$new_tag${NC}"
echo -e " • Changes pushed to remote${NC}" echo -e " • Changes pushed to remote${NC}"
echo -e "\n${GREEN}✨ Process complete!${NC}" echo -e "\n${GREEN}✨ Process complete!${NC}"

View File

@@ -1 +0,0 @@
0.1.8

1
src/VERSION Normal file
View File

@@ -0,0 +1 @@
0.1.11

View File

@@ -24,7 +24,7 @@ const path = require('path');
function createNostrLoginLiteBundle() { function createNostrLoginLiteBundle() {
// console.log('🔧 Creating NOSTR_LOGIN_LITE bundle for two-file architecture...'); // console.log('🔧 Creating NOSTR_LOGIN_LITE bundle for two-file architecture...');
const outputPath = path.join(__dirname, 'nostr-lite.js'); const outputPath = path.join(__dirname, '../build/nostr-lite.js');
// Remove old bundle // Remove old bundle
try { try {
@@ -56,10 +56,10 @@ if (typeof window !== 'undefined') {
throw new Error('Missing dependency: nostr.bundle.js'); throw new Error('Missing dependency: nostr.bundle.js');
} }
console.log('NOSTR_LOGIN_LITE: Dependencies verified ✓'); // console.log('NOSTR_LOGIN_LITE: Dependencies verified ✓');
console.log('NOSTR_LOGIN_LITE: NostrTools available with keys:', Object.keys(window.NostrTools)); // console.log('NOSTR_LOGIN_LITE: NostrTools available with keys:', Object.keys(window.NostrTools));
console.log('NOSTR_LOGIN_LITE: NIP-06 available:', !!window.NostrTools.nip06); // console.log('NOSTR_LOGIN_LITE: NIP-06 available:', !!window.NostrTools.nip06);
console.log('NOSTR_LOGIN_LITE: NIP-46 available:', !!window.NostrTools.nip46); // console.log('NOSTR_LOGIN_LITE: NIP-46 available:', !!window.NostrTools.nip46);
} }
// ====================================== // ======================================
@@ -109,7 +109,7 @@ if (typeof window !== 'undefined') {
bundle += ` style.id = 'nl-theme-css';\n`; bundle += ` style.id = 'nl-theme-css';\n`;
bundle += ` style.textContent = themeCss;\n`; bundle += ` style.textContent = themeCss;\n`;
bundle += ` document.head.appendChild(style);\n`; bundle += ` document.head.appendChild(style);\n`;
bundle += ` console.log('NOSTR_LOGIN_LITE: ' + themeName + ' theme CSS injected');\n`; bundle += ` // console.log('NOSTR_LOGIN_LITE: ' + themeName + ' theme CSS injected');\n`;
bundle += ` }\n`; bundle += ` }\n`;
bundle += `}\n\n`; bundle += `}\n\n`;
@@ -1393,10 +1393,10 @@ class AuthManager {
// Configure storage type based on isolateSession option // Configure storage type based on isolateSession option
if (options.isolateSession) { if (options.isolateSession) {
this.storage = sessionStorage; this.storage = sessionStorage;
console.log('🔐 AuthManager: Using sessionStorage for per-window isolation'); // console.log('🔐 AuthManager: Using sessionStorage for per-window isolation');
} else { } else {
this.storage = localStorage; this.storage = localStorage;
console.log('🔐 AuthManager: Using localStorage for cross-window persistence'); // console.log('🔐 AuthManager: Using localStorage for cross-window persistence');
} }
console.warn('🔐 SECURITY: Private keys stored unencrypted in browser storage'); console.warn('🔐 SECURITY: Private keys stored unencrypted in browser storage');
@@ -1406,7 +1406,7 @@ class AuthManager {
// Save authentication state using unified plaintext approach // Save authentication state using unified plaintext approach
async saveAuthState(authData) { async saveAuthState(authData) {
try { try {
console.log('🔐 AuthManager: Saving auth state with plaintext storage'); // console.log('🔐 AuthManager: Saving auth state with plaintext storage');
console.warn('🔐 SECURITY: Private key will be stored unencrypted for maximum usability'); console.warn('🔐 SECURITY: Private key will be stored unencrypted for maximum usability');
const authState = { const authState = {
@@ -1423,14 +1423,14 @@ class AuthManager {
hasGetPublicKey: typeof authData.extension?.getPublicKey === 'function', hasGetPublicKey: typeof authData.extension?.getPublicKey === 'function',
hasSignEvent: typeof authData.extension?.signEvent === 'function' hasSignEvent: typeof authData.extension?.signEvent === 'function'
}; };
console.log('🔐 AuthManager: Extension method - storing verification data only'); // console.log('🔐 AuthManager: Extension method - storing verification data only');
break; break;
case 'local': case 'local':
// UNIFIED PLAINTEXT: Store secret key directly for maximum compatibility // UNIFIED PLAINTEXT: Store secret key directly for maximum compatibility
if (authData.secret) { if (authData.secret) {
authState.secret = authData.secret; authState.secret = authData.secret;
console.log('🔐 AuthManager: Local method - storing secret key in plaintext'); // console.log('🔐 AuthManager: Local method - storing secret key in plaintext');
console.warn('🔐 SECURITY: Secret key stored unencrypted for developer convenience'); console.warn('🔐 SECURITY: Secret key stored unencrypted for developer convenience');
} }
break; break;
@@ -1443,13 +1443,13 @@ class AuthManager {
relays: authData.signer.relays, relays: authData.signer.relays,
// Don't store secret - user will need to reconnect // Don't store secret - user will need to reconnect
}; };
console.log('🔐 AuthManager: NIP-46 method - storing connection parameters'); // console.log('🔐 AuthManager: NIP-46 method - storing connection parameters');
} }
break; break;
case 'readonly': case 'readonly':
// Read-only mode has no secrets to store // Read-only mode has no secrets to store
console.log('🔐 AuthManager: Read-only method - storing basic auth state'); // console.log('🔐 AuthManager: Read-only method - storing basic auth state');
break; break;
default: default:
@@ -1458,7 +1458,7 @@ class AuthManager {
this.storage.setItem(this.storageKey, JSON.stringify(authState)); this.storage.setItem(this.storageKey, JSON.stringify(authState));
this.currentAuthState = authState; this.currentAuthState = authState;
console.log('🔐 AuthManager: Auth state saved successfully for method:', authData.method); // console.log('🔐 AuthManager: Auth state saved successfully for method:', authData.method);
} catch (error) { } catch (error) {
console.error('🔐 AuthManager: Failed to save auth state:', error); console.error('🔐 AuthManager: Failed to save auth state:', error);
@@ -1696,17 +1696,17 @@ class AuthManager {
} }
async _restoreLocalAuth(authState) { async _restoreLocalAuth(authState) {
console.log('🔐 AuthManager: === _restoreLocalAuth (Unified Plaintext) ==='); // console.log('🔐 AuthManager: === _restoreLocalAuth (Unified Plaintext) ===');
// Check for legacy encrypted format first // Check for legacy encrypted format first
if (authState.encrypted) { if (authState.encrypted) {
console.log('🔐 AuthManager: Detected LEGACY encrypted format - migrating to plaintext'); // console.log('🔐 AuthManager: Detected LEGACY encrypted format - migrating to plaintext');
console.warn('🔐 SECURITY: Converting from encrypted to plaintext storage for compatibility'); console.warn('🔐 SECURITY: Converting from encrypted to plaintext storage for compatibility');
// Try to decrypt legacy format // Try to decrypt legacy format
const sessionPassword = sessionStorage.getItem('nostr_session_key'); const sessionPassword = sessionStorage.getItem('nostr_session_key');
if (!sessionPassword) { if (!sessionPassword) {
console.log('🔐 AuthManager: Legacy session password not found - user must re-login'); // console.log('🔐 AuthManager: Legacy session password not found - user must re-login');
return null; return null;
} }
@@ -1723,11 +1723,11 @@ class AuthManager {
// NEW UNIFIED PLAINTEXT FORMAT // NEW UNIFIED PLAINTEXT FORMAT
if (!authState.secret) { if (!authState.secret) {
console.log('🔐 AuthManager: No secret found in plaintext format'); // console.log('🔐 AuthManager: No secret found in plaintext format');
return null; return null;
} }
console.log('🔐 AuthManager: ✅ Local auth restored from plaintext storage'); // console.log('🔐 AuthManager: ✅ Local auth restored from plaintext storage');
console.warn('🔐 SECURITY: Secret key was stored unencrypted'); console.warn('🔐 SECURITY: Secret key was stored unencrypted');
return { return {
@@ -1739,14 +1739,14 @@ class AuthManager {
async _restoreNip46Auth(authState) { async _restoreNip46Auth(authState) {
if (!authState.nip46) { if (!authState.nip46) {
console.log('🔐 AuthManager: No NIP-46 data found'); // console.log('🔐 AuthManager: No NIP-46 data found');
return null; return null;
} }
// For NIP-46, we can't automatically restore the connection // For NIP-46, we can't automatically restore the connection
// because it requires the user to re-authenticate with the remote signer // because it requires the user to re-authenticate with the remote signer
// Instead, we return the connection parameters so the UI can prompt for reconnection // Instead, we return the connection parameters so the UI can prompt for reconnection
console.log('🔐 AuthManager: NIP-46 connection data found, requires user reconnection'); // console.log('🔐 AuthManager: NIP-46 connection data found, requires user reconnection');
return { return {
method: 'nip46', method: 'nip46',
pubkey: authState.pubkey, pubkey: authState.pubkey,
@@ -1756,7 +1756,7 @@ class AuthManager {
} }
async _restoreReadonlyAuth(authState) { async _restoreReadonlyAuth(authState) {
console.log('🔐 AuthManager: Read-only auth restored successfully'); // console.log('🔐 AuthManager: Read-only auth restored successfully');
return { return {
method: 'readonly', method: 'readonly',
pubkey: authState.pubkey pubkey: authState.pubkey
@@ -1768,7 +1768,7 @@ class AuthManager {
this.storage.removeItem(this.storageKey); this.storage.removeItem(this.storageKey);
sessionStorage.removeItem('nostr_session_key'); // Clear legacy session key sessionStorage.removeItem('nostr_session_key'); // Clear legacy session key
this.currentAuthState = null; this.currentAuthState = null;
console.log('🔐 AuthManager: Auth state cleared from unified storage'); // console.log('🔐 AuthManager: Auth state cleared from unified storage');
} }
// Check if we have valid stored auth // Check if we have valid stored auth
@@ -1811,7 +1811,7 @@ function getGlobalAuthManager() {
// **UNIFIED GLOBAL FUNCTION**: Set authentication state (works for all methods) // **UNIFIED GLOBAL FUNCTION**: Set authentication state (works for all methods)
function setAuthState(authData, options = {}) { function setAuthState(authData, options = {}) {
try { try {
console.log('🌐 setAuthState: Setting global auth state for method:', authData.method); // console.log('🌐 setAuthState: Setting global auth state for method:', authData.method);
console.warn('🔐 SECURITY: Using unified plaintext storage for maximum compatibility'); console.warn('🔐 SECURITY: Using unified plaintext storage for maximum compatibility');
// Store in memory // Store in memory
@@ -1821,7 +1821,7 @@ function setAuthState(authData, options = {}) {
const authManager = new AuthManager(options); const authManager = new AuthManager(options);
authManager.saveAuthState(authData); authManager.saveAuthState(authData);
console.log('🌐 setAuthState: Auth state saved successfully'); // console.log('🌐 setAuthState: Auth state saved successfully');
} catch (error) { } catch (error) {
console.error('🌐 setAuthState: Failed to save auth state:', error); console.error('🌐 setAuthState: Failed to save auth state:', error);
throw error; throw error;
@@ -1844,13 +1844,13 @@ function getAuthState() {
} }
if (!stored) { if (!stored) {
console.log('🌐 getAuthState: No auth state found in storage'); // console.log('🌐 getAuthState: No auth state found in storage');
globalAuthState = null; globalAuthState = null;
return null; return null;
} }
const authState = JSON.parse(stored); const authState = JSON.parse(stored);
console.log('🌐 getAuthState: Retrieved auth state:', authState.method); // console.log('🌐 getAuthState: Retrieved auth state:', authState.method);
// Update in-memory cache // Update in-memory cache
globalAuthState = authState; globalAuthState = authState;
@@ -1866,7 +1866,7 @@ function getAuthState() {
// **UNIFIED GLOBAL FUNCTION**: Clear authentication state (works for all methods) // **UNIFIED GLOBAL FUNCTION**: Clear authentication state (works for all methods)
function clearAuthState() { function clearAuthState() {
try { try {
console.log('🌐 clearAuthState: Clearing global auth state'); // console.log('🌐 clearAuthState: Clearing global auth state');
// Clear in-memory state // Clear in-memory state
globalAuthState = null; globalAuthState = null;
@@ -1877,7 +1877,7 @@ function clearAuthState() {
sessionStorage.removeItem(storageKey); sessionStorage.removeItem(storageKey);
sessionStorage.removeItem('nostr_session_key'); // Clear legacy session key sessionStorage.removeItem('nostr_session_key'); // Clear legacy session key
console.log('🌐 clearAuthState: Auth state cleared from all storage locations'); // console.log('🌐 clearAuthState: Auth state cleared from all storage locations');
} catch (error) { } catch (error) {
console.error('🌐 clearAuthState: Failed to clear auth state:', error); console.error('🌐 clearAuthState: Failed to clear auth state:', error);
} }
@@ -2260,9 +2260,9 @@ if (typeof window !== 'undefined') {
_instance: nostrLite _instance: nostrLite
}; };
console.log('NOSTR_LOGIN_LITE: Library loaded and ready'); // console.log('NOSTR_LOGIN_LITE: Library loaded and ready');
console.log('NOSTR_LOGIN_LITE: Use window.NOSTR_LOGIN_LITE.init(options) to initialize'); // console.log('NOSTR_LOGIN_LITE: Use window.NOSTR_LOGIN_LITE.init(options) to initialize');
console.log('NOSTR_LOGIN_LITE: Detected', nostrLite.extensionBridge.getExtensionCount(), 'browser extensions'); // console.log('NOSTR_LOGIN_LITE: Detected', nostrLite.extensionBridge.getExtensionCount(), 'browser extensions');
console.warn('🔐 SECURITY: Unified plaintext storage enabled for maximum developer usability'); console.warn('🔐 SECURITY: Unified plaintext storage enabled for maximum developer usability');
} else { } else {
// Node.js environment // Node.js environment