documentation changes
This commit is contained in:
93
README.md
93
README.md
@@ -3,61 +3,84 @@ Nostr_Login_Lite
|
|||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
Configure for login/logout:
|
Complete configuration showing all available options:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
await window.NOSTR_LOGIN_LITE.init({
|
await window.NOSTR_LOGIN_LITE.init({
|
||||||
theme: 'default',
|
// Theme configuration
|
||||||
|
theme: 'default', // 'default' | 'dark' | custom theme name
|
||||||
|
|
||||||
|
// 🔐 Authentication persistence configuration
|
||||||
|
persistence: true, // Enable persistent authentication (default: true)
|
||||||
|
isolateSession: false, // Use sessionStorage for per-tab isolation (default: false = localStorage)
|
||||||
|
|
||||||
|
// Relay configuration
|
||||||
|
relays: ['wss://relay.damus.io', 'wss://nos.lol'],
|
||||||
|
|
||||||
|
// Authentication methods
|
||||||
methods: {
|
methods: {
|
||||||
extension: true,
|
extension: true, // Browser extensions (Alby, nos2x, etc.)
|
||||||
local: true,
|
local: true, // Manual key entry & generation
|
||||||
seedphrase: true, // ✅ Must be explicitly enabled
|
readonly: true, // Read-only mode (no signing)
|
||||||
readonly: true,
|
connect: true, // NIP-46 remote signers
|
||||||
connect: true,
|
otp: false // OTP/DM authentication (not implemented yet)
|
||||||
otp: false
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Floating tab configuration
|
||||||
floatingTab: {
|
floatingTab: {
|
||||||
enabled: true,
|
enabled: true, // Show/hide floating login tab
|
||||||
hPosition: 0.95, // Near right edge
|
hPosition: 0.95, // 0.0 = left edge, 1.0 = right edge
|
||||||
vPosition: 0.1, // Near top
|
vPosition: 0.1, // 0.0 = top edge, 1.0 = bottom edge
|
||||||
|
offset: { x: 0, y: 0 }, // Fine-tune positioning (pixels)
|
||||||
|
|
||||||
appearance: {
|
appearance: {
|
||||||
style: 'pill',
|
style: 'pill', // 'pill' | 'square' | 'circle'
|
||||||
icon: '[LOGIN]',
|
theme: 'auto', // 'auto' | 'light' | 'dark'
|
||||||
text: 'Sign In',
|
icon: '[LOGIN]', // Text-based icon
|
||||||
iconOnly: false
|
text: 'Sign In', // Button text
|
||||||
|
iconOnly: false // Show icon only (no text)
|
||||||
},
|
},
|
||||||
|
|
||||||
behavior: {
|
behavior: {
|
||||||
hideWhenAuthenticated: false, // Keep visible after login
|
hideWhenAuthenticated: false, // Keep visible after login
|
||||||
showUserInfo: true,
|
showUserInfo: true, // Show user info when authenticated
|
||||||
autoSlide: true
|
autoSlide: true, // Slide animation on hover
|
||||||
},
|
persistent: false // Persist across page reloads
|
||||||
|
}
|
||||||
getUserInfo: true, // ✅ Fetch user profiles
|
|
||||||
getUserRelay: ['wss://relay.laantungir.net'] // Custom relays for profiles
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Control Methods
|
||||||
|
NOSTR_LOGIN_LITE.launch(); // Open login modal
|
||||||
|
NOSTR_LOGIN_LITE.logout(); // Clear authentication state
|
||||||
|
NOSTR_LOGIN_LITE.switchTheme('dark'); // Change theme
|
||||||
|
NOSTR_LOGIN_LITE.showFloatingTab(); // Show floating tab
|
||||||
|
NOSTR_LOGIN_LITE.hideFloatingTab(); // Hide floating tab
|
||||||
|
NOSTR_LOGIN_LITE.updateFloatingTab(options); // Update floating tab options
|
||||||
|
NOSTR_LOGIN_LITE.toggleFloatingTab(); // Toggle floating tab visibility
|
||||||
|
|
||||||
// After initialization, you can switch themes dynamically:
|
// Get Authentication State (Single Source of Truth)
|
||||||
NOSTR_LOGIN_LITE.switchTheme('dark');
|
const authState = NOSTR_LOGIN_LITE.getAuthState();
|
||||||
NOSTR_LOGIN_LITE.switchTheme('default');
|
const isAuthenticated = !!authState;
|
||||||
|
const userInfo = authState; // Contains { method, pubkey, etc. }
|
||||||
// Or customize individual theme variables:
|
|
||||||
NOSTR_LOGIN_LITE.setThemeVariable('--nl-accent-color', '#00ff00');
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Control methods:
|
**Authentication Persistence:**
|
||||||
```javascript
|
|
||||||
NOSTR_LOGIN_LITE.showFloatingTab();
|
Two-tier configuration system:
|
||||||
NOSTR_LOGIN_LITE.hideFloatingTab();
|
|
||||||
NOSTR_LOGIN_LITE.updateFloatingTab(options);
|
1. **`persistence: boolean`** - Master switch for authentication persistence
|
||||||
NOSTR_LOGIN_LITE.destroyFloatingTab();
|
- `true` (default): Save authentication state for automatic restore
|
||||||
```
|
- `false`: No persistence - user must login fresh every time
|
||||||
|
|
||||||
|
2. **`isolateSession: boolean`** - Storage location when persistence is enabled
|
||||||
|
- `false` (default): Use localStorage - shared across tabs/windows
|
||||||
|
- `true`: Use sessionStorage - isolated per tab/window
|
||||||
|
|
||||||
|
**Use Cases for Session Isolation (`isolateSession: true`):**
|
||||||
|
- Multi-tenant applications where different tabs need different users
|
||||||
|
- Testing environments requiring separate authentication per tab
|
||||||
|
- Privacy-focused applications that shouldn't share login state across tabs
|
||||||
|
|
||||||
## Embedded Modal API
|
## Embedded Modal API
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user