Constructs a new DataBase instance connected to a GunDB instance.
The main GunDB instance.
Optionalcore: anyOptionally, the root Gun instance (unused in this context).
Optionalsea: anyOptional cryptography (Gun SEA) instance; will be auto-discovered if not provided.
Private_isWhether the database instance has been destroyed
Private Optional_rxjsRxJS-based GunDB observable/stream helper
Private Optional ReadonlycoreShogunCore instance for emitting events
Crypto utilities used internally
Private ReadonlyeventEventEmitter for app-specific event management
GunDB instance
Private ReadonlyonRegistered callbacks for auth state changes
Gun SEA cryptography context (usually gun.SEA)
Cached user instance or null if not logged in
Private ReadonlyusernamesGun node dedicated to mapping usernames to pubkeys
Aggressively clean up authentication state and session. Typically used for error recovery.
PrivatebuildInternalAssemble a standard AuthResult object after a successful login.
Resulting username.
Public key (pub) for logged-in user.
AuthResult.
Tears down the DataBase instance and performs cleanup of all resources/listeners. No further actions should be performed on this instance after destruction.
Emit a custom event.
Event name.
Optionaldata: anyOptional associated data.
true if listeners were notified; otherwise false.
PrivateensureReturns the currently authenticated user's public key and Gun user instance, if logged in.
Object containing pub (public key) and optionally user, or null.
Get current user's public key.
User's public key or null if not logged in.
Initialize the database instance.
PrivateisPrivateisCheck if a user is currently logged in (there is a valid session).
true if logged in; otherwise false.
Sign in (authenticate) as an existing user by username/password or SEA pair.
Username to log in as.
User's password (or "" if using pair).
Optionalpair: null | ISEAPairOptional cryptographic SEA pair.
AuthResult Promise.
Authenticate using a SEA pair directly (no password required).
The user's username for identification (not cryptographically enforced).
GunDB SEA pair for authentication.
Promise with authentication result.
Legacy API: Sign in using a username and SEA pair (password parameter is unused).
Username to sign in as.
SEA key pair.
AuthResult Promise.
Log out the current user, clear local state and remove session from storage.
PrivatenotifyInternalInternal: notify all onAuth callbacks with current user.
User's public key (pub).
Remove an event handler.
Event name.
Listener function.
Register an event handler.
Event name.
Listener function.
Listen for authentication/sign-in events (login, logout, etc).
Function to call with new user instance.
Function to remove the registered callback.
Register an event handler for a single event occurrence.
Event name.
Listener function.
PrivateregisterPrivateresetInternalReset gun.user() authentication state and clear cached user.
Attempt to restore a previously saved session from sessionStorage.
Object indicating success, error, and userPub if restored.
PrivatesaveSave credentials for the current session to sessionStorage, if available.
The credentials and user identity to store.
Register and authenticate a new user account.
The username to create/account for.
The user's password.
Optionalpair: null | ISEAPairOptional cryptographic pair (for auth instead of password).
SignUpResult Promise.
PrivatesubscribeInternalInternal: subscribe to GunDB "auth" events and notify listeners. Listeners are invoked on authentication status change.
PrivatevalidateValidate that a provided password meets minimum length requirements.
Password string to validate.
Object indicating validity and, if invalid, an error.
PrivatevalidateValidate a signup request's username, password, and/or cryptographic pair.
Username string.
Password string.
Optionalpair: null | ISEAPairOptional cryptographic SEA pair.
Object with validation status and optional error.
DataBase
Manages GunDB user authentication and various utility helpers for session, alias/username, SEA cryptography, event handling, and reactive streams.