Options
All
  • Public
  • Public/Protected
  • All
Menu

Module services/util

Utilities for services.

Variables

Const dbURL

dbURL: string = ...

Database connection URL.

Const emailChangeIDLength

emailChangeIDLength: "16" = 16

Length of an email change ID.

Const idLength

idLength: "4" = 4

Standard length of an ID.

Const passwordResetIDLength

passwordResetIDLength: "16" = 16

Length of a password reset ID.

Const sessionIDLength

sessionIDLength: "16" = 16

Length of a session ID.

Const verifyIDLength

verifyIDLength: "16" = 16

Length of a verification ID.

Functions

checkPassword

  • checkPassword(password: string, hash: string): Promise<boolean>
  • Check if passwords match.

    Parameters

    • password: string

      The password.

    • hash: string

      The hashed password.

    Returns Promise<boolean>

    Whether or not the password and hash match.

getTime

  • getTime(): number
  • Get the current timestamp.

    Returns number

    The timestamp in seconds.

hashPassword

  • hashPassword(dbm: default, password: string, rounds?: number): Promise<string>
  • Hash a password.

    Parameters

    • dbm: default

      The database manager.

    • password: string

      The password.

    • rounds: number = null

      The number of salt rounds for bcrypt to use.

    Returns Promise<string>

    The hashed password.

hashPasswordAsync

  • hashPasswordAsync(password: string, rounds: number): Promise<string>
  • Hash a password asynchronously.

    Parameters

    • password: string

      The password.

    • rounds: number

      The number of salt rounds for bcrypt to use.

    Returns Promise<string>

    The hashed password.

newID

  • newID(len?: number): Promise<string>
  • Generate a new ID.

    Parameters

    • len: number = ...

      The length of the ID.

    Returns Promise<string>

    The new ID.

newUniqueID

  • newUniqueID(dbm: default, table: string, len?: number): Promise<string>
  • Generate a new unique ID for a table.

    Parameters

    • dbm: default

      The database manager.

    • table: string

      The table name.

    • len: number = ...

      The length of the ID.

    Returns Promise<string>

    The new unique ID.

pruneEmailChangeRecord

  • pruneEmailChangeRecord(dbm: default, emailChangeID: string, timeRemaining?: number): Promise<void>
  • Delete an email change record when the time comes.

    Parameters

    • dbm: default

      The database manager.

    • emailChangeID: string

      An email change ID.

    • timeRemaining: number = null

      The amount of time to wait before removing the record.

    Returns Promise<void>

pruneEmailChangeRecords

  • pruneEmailChangeRecords(dbm: default): Promise<void>
  • Delete all active email change records when the time comes.

    Parameters

    • dbm: default

      The database manager.

    Returns Promise<void>

prunePasswordResetRecord

  • prunePasswordResetRecord(dbm: default, resetID: string, timeRemaining?: number): Promise<void>
  • Delete a password reset record when the time comes.

    Parameters

    • dbm: default

      The database manager.

    • resetID: string

      A password reset ID.

    • timeRemaining: number = null

      The amount of time to wait before removing the record.

    Returns Promise<void>

prunePasswordResetRecords

  • prunePasswordResetRecords(dbm: default): Promise<void>
  • Delete all active password reset records when the time comes.

    Parameters

    • dbm: default

      The database manager.

    Returns Promise<void>

pruneSession

  • pruneSession(dbm: default, sessionID: string, timeRemaining?: number): Promise<void>
  • Delete a session when the time comes.

    Parameters

    • dbm: default

      The database manager.

    • sessionID: string

      A session's ID.

    • timeRemaining: number = null

      The amount of time to wait before removing the session.

    Returns Promise<void>

pruneSessions

  • pruneSessions(dbm: default): Promise<void>
  • Delete all active sessions when the time comes.

    Parameters

    • dbm: default

      The database manager.

    Returns Promise<void>

pruneSuspension

  • pruneSuspension(dbm: default, suspensionID: string, timeRemaining?: number): Promise<void>
  • Delete a suspension record when the time comes.

    Parameters

    • dbm: default

      The database manager.

    • suspensionID: string

      A suspension record ID.

    • timeRemaining: number = null

      The amount of time to wait before removing the record.

    Returns Promise<void>

pruneSuspensions

  • pruneSuspensions(dbm: default): Promise<void>
  • Delete all active suspension records when the time comes.

    Parameters

    • dbm: default

      The database manager.

    Returns Promise<void>

pruneVerifyRecord

  • pruneVerifyRecord(dbm: default, verifyID: string, timeRemaining?: number): Promise<void>
  • Delete a verification record when the time comes.

    Parameters

    • dbm: default

      The database manager.

    • verifyID: string

      A verification ID.

    • timeRemaining: number = null

      The amount of time to wait before removing the record.

    Returns Promise<void>

pruneVerifyRecords

  • pruneVerifyRecords(dbm: default): Promise<void>
  • Delete all active verification records when the time comes.

    Parameters

    • dbm: default

      The database manager.

    Returns Promise<void>

setBigTimeout

  • setBigTimeout(callback: function, ms: number, ...args: any[]): void
  • Set a timeout without the 32-bit limit.

    Parameters

    • callback: function

      The callback.

        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • ms: number

      Number of milliseconds before calling the callback.

    • Rest ...args: any[]

      Arguments to pass to the callback.

    Returns void

Generated using TypeDoc