Constructors

  • Parameters

    • gun: IGunInstance
    • appScope: string = "shogun"

    Returns DataBase

Properties

_rxjs?: RxJS
crypto: crypto
eventEmitter: EventEmitter
gun: IGunInstance
node: IGunChain<any, any, any, any>
onAuthCallbacks: AuthCallback[] = []
sea: SEA
user: null | IGunUserInstance<any, any, any, any> = null
Errors: GunErrors = GunErrors

Methods

  • Adds a new peer to the network

    Parameters

    • peer: string

      URL of the peer to add

    Returns void

  • Authenticates user after creation

    Parameters

    • username: string
    • password: string
    • Optionalpair: null | ISEAPair

    Returns Promise<{ error?: string; success: boolean; userPub?: string }>

  • Builds login result object

    Parameters

    • username: string
    • userPub: string

    Returns AuthResult

  • Clear session

    Returns void

  • Creates alias index following GunDB pattern: ~@alias -> userPub

    Parameters

    • username: string
    • userPub: string

    Returns Promise<boolean>

  • Creates epub index: epubKeys/epub -> userPub

    Parameters

    • epub: string
    • userPub: string

    Returns Promise<boolean>

  • Creates a new user in Gun

    Parameters

    • username: string
    • password: string

    Returns Promise<{ error?: string; success: boolean; userPub?: string }>

  • Creates a new user in Gun with pair-based authentication (for Web3/plugins)

    Parameters

    • username: string
    • pair: ISEAPair

    Returns Promise<{ error?: string; success: boolean; userPub?: string }>

  • Creates reverse lookup: userPub -> alias

    Parameters

    • username: string
    • userPub: string

    Returns Promise<boolean>

  • Creates user metadata in user's own node

    Parameters

    • username: string
    • userPub: string
    • epub: null | string

    Returns Promise<boolean>

  • Creates username mapping: usernames/alias -> userPub

    Parameters

    • username: string
    • userPub: string

    Returns Promise<boolean>

  • Creates user registry: users/userPub -> user data

    Parameters

    • username: string
    • userPub: string
    • epub: null | string

    Returns Promise<boolean>

  • Emits an event

    Parameters

    • event: string | symbol

      Event name

    • Optionaldata: any

      Event data

    Returns boolean

  • Recovers password hint using security question answers

    Parameters

    • username: string

      Username

    • securityAnswers: string[]

      Array of answers to security questions

    Returns Promise<{ error?: string; hint?: string; success: boolean }>

    Promise resolving with the password hint

  • Gets a node at the specified path

    Parameters

    • path: string

      Path to the node

    Returns IGunChain<any, any>

    Gun node

  • Gets the list of all configured peers (connected and disconnected)

    Returns string[]

    Array of peer URLs

  • Gets all registered users (for admin purposes)

    Returns Promise<
        {
            epub: null
            | string;
            lastSeen: number;
            registeredAt: number;
            username: string;
            userPub: string;
        }[],
    >

    Promise resolving to array of user information

  • Get app scope

    Returns string

  • Gets the list of currently connected peers

    Returns string[]

    Array of peer URLs

  • Gets the current user

    Returns null | UserInfo

    Current user object or null

  • Gets data at the specified path (one-time read)

    Parameters

    • path: string

      Path to get the data from

    Returns Promise<any>

    Promise resolving to the data

  • Gets the Gun instance

    Returns IGunInstance

    Gun instance

  • Get password hint

    Returns null | string

  • Gets detailed information about all peers

    Returns { [peer: string]: { connected: boolean; status: string } }

    Object with peer information

  • Gets the current user instance

    Returns IGunUserInstance

    User instance

  • Gets user alias by public key

    Parameters

    • userPub: string

      User's public key

    Returns Promise<null | string>

    Promise resolving to user alias or null if not found

  • Gets user information by alias using the comprehensive tracking system

    Parameters

    • alias: string

      Username/alias to lookup

    Returns Promise<
        | null
        | {
            epub: null
            | string;
            lastSeen: number;
            registeredAt: number;
            username: string;
            userPub: string;
        },
    >

    Promise resolving to user information or null if not found

  • Gets user information by public key

    Parameters

    • userPub: string

      User's public key

    Returns Promise<
        | null
        | {
            epub: null
            | string;
            lastSeen: number;
            registeredAt: number;
            username: string;
            userPub: string;
        },
    >

    Promise resolving to user information or null if not found

  • Get user public key

    Returns null | string

  • Gets user public key by encryption public key (epub)

    Parameters

    • epub: string

      User's encryption public key

    Returns Promise<null | string>

    Promise resolving to user public key or null if not found

  • Initialize the GunInstance asynchronously This method should be called after construction to perform async operations

    Parameters

    • appScope: string = "shogun"

    Returns Promise<void>

  • Check if user is authenticated

    Returns boolean

  • Checks if a user is currently logged in

    Returns boolean

    True if logged in

  • Leave user session

    Returns void

  • Load session from storage

    Returns any

  • Performs login with username and password

    Parameters

    • username: string

      Username

    • password: string

      Password

    • Optionalpair: null | ISEAPair

      SEA pair (optional)

    Returns Promise<AuthResult>

    Promise resolving to AuthResult object

  • Performs login with GunDB pair directly

    Parameters

    • username: string

      Username

    • pair: ISEAPair

      SEA pair

    Returns Promise<AuthResult>

    Promise resolving to AuthResult object

  • Returns void

  • Helper method to navigate to a nested path by splitting and chaining .get() calls

    Parameters

    • node: IGunChain<any>

      Starting Gun node

    • path: string

      Path string (e.g., "test/data/marco")

    Returns IGunChain<any>

    Gun node at the specified path

  • Parameters

    • pub: string

    Returns void

  • Removes an event listener

    Parameters

    • event: string | symbol

      Event name

    • listener: EventListener

      Event listener function

    Returns void

  • Adds an event listener

    Parameters

    • event: string | symbol

      Event name

    • listener: EventListener

      Event listener function

    Returns void

  • Registers an authentication callback

    Parameters

    • callback: AuthCallback

      Function to call on auth events

    Returns () => void

    Function to unsubscribe the callback

  • Adds a one-time event listener

    Parameters

    • event: string | symbol

      Event name

    • listener: EventListener

      Event listener function

    Returns void

  • Performs authentication with Gun

    Parameters

    • username: string
    • password: string
    • Optionalpair: null | ISEAPair

    Returns Promise<{ ack?: any; error?: string; success: boolean }>

  • Puts data at the specified path

    Parameters

    • path: string

      Path to store data

    • data: any

      Data to store

    Returns Promise<GunMessagePut>

    Promise resolving to operation result

  • Recall user session

    Parameters

    • Optionaloptions: { sessionStorage?: boolean }

    Returns void

  • Reconnects to a specific peer

    Parameters

    • peer: string

      URL of the peer to reconnect

    Returns void

  • Removes data at the specified path

    Parameters

    • path: string

      Path to remove

    Returns Promise<GunMessagePut>

    Promise resolving to operation result

  • Removes a peer from the network

    Parameters

    • peer: string

      URL of the peer to remove

    Returns void

  • Clears all peers and optionally adds new ones

    Parameters

    • OptionalnewPeers: string[]

      Optional array of new peers to add

    Returns void

  • Attempts to restore user session from local storage

    Returns { error?: string; success: boolean; userPub?: string }

    Promise resolving to session restoration result

  • Parameters

    • username: string
    • userPub: string
    • authResult: any

    Returns Promise<SignUpResult>

  • Accesses the RxJS module for reactive programming

    Returns RxJS

    GunRxJS instance

  • Parameters

    • userInfo: { alias: string; pair: ISEAPair; userPub: string }

    Returns void

  • Save session to storage

    Parameters

    • session: any

    Returns void

  • Sets data at the specified path

    Parameters

    • path: string

      Path to store data

    • data: any

      Data to store

    Returns Promise<GunMessagePut>

    Promise resolving to operation result

  • Set password hint

    Parameters

    • hint: string

    Returns void

  • Sets up security questions and password hint

    Parameters

    • username: string

      Username

    • password: string

      Current password

    • hint: string

      Password hint

    • securityQuestions: string[]

      Array of security questions

    • securityAnswers: string[]

      Array of answers to security questions

    Returns Promise<{ error?: string; success: boolean }>

    Promise resolving with the operation result

  • Sets up comprehensive user tracking system for agile user lookup Creates multiple indexes for efficient user discovery

    Parameters

    • username: string
    • userPub: string
    • epub: string

    Returns Promise<boolean>

  • Set user data

    Parameters

    • data: any

    Returns void

  • Signs up a new user using direct Gun authentication

    Parameters

    • username: string

      Username

    • password: string

      Password

    • Optionalpair: null | ISEAPair

      Optional SEA pair for Web3 login

    Returns Promise<SignUpResult>

    Promise resolving to signup result

  • Returns void

  • Updates user's last seen timestamp

    Parameters

    • userPub: string

      User's public key

    Returns Promise<void>

  • Validates password strength according to security requirements

    Parameters

    • password: string

    Returns { error?: string; valid: boolean }

  • Validates signup credentials with enhanced security

    Parameters

    • username: string
    • password: string
    • Optionalpair: null | ISEAPair

    Returns { error?: string; valid: boolean }