Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Auth

A container for authentication data with static methods for interfacing with hackerapi

class
extends

{ HackerAPI.Base }

Hierarchy

Index

Constructors

Private constructor

  • new Auth(__namedParameters: { email: undefined | string; expires: undefined | Date; id: undefined | string; name: undefined | string; timestamp: undefined | Date; token: undefined | string; token_jwt: undefined | string }): Auth
  • Creates an Auth instance. You shouldn't be calling this directly.

    Parameters

    • __namedParameters: { email: undefined | string; expires: undefined | Date; id: undefined | string; name: undefined | string; timestamp: undefined | Date; token: undefined | string; token_jwt: undefined | string }
      • email: undefined | string
      • expires: undefined | Date
      • id: undefined | string
      • name: undefined | string
      • timestamp: undefined | Date
      • token: undefined | string
      • token_jwt: undefined | string

    Returns Auth

Properties

Optional email

email: undefined | string

Optional expires

expires: Date

Optional id

id: undefined | string

Optional name

name: undefined | string

specialHandlers

specialHandlers: {}

Type declaration

  • [key: string]: (...args: unknown[]) => [string, undefined | string]
      • (...args: unknown[]): [string, undefined | string]
      • Parameters

        • Rest ...args: unknown[]

        Returns [string, undefined | string]

Optional timestamp

timestamp: Date

Optional tokenJwt

tokenJwt: undefined | string

Static Private Optional _token

_token: undefined | string

Accessors

token

  • get token(): string | undefined

Static token

  • get token(): string | undefined
  • set token(t: string | undefined): void
  • Gets the default token

    Returns string | undefined

  • Sets the default token to use in requests

    todo

    Error throwing if invalid type

    Parameters

    • t: string | undefined

    Returns void

Methods

toHackerAPIFormat

  • toHackerAPIFormat(method?: undefined | string): {}

Static checkEmail

  • checkEmail(email: string | { email: string }): Promise<boolean>
  • Checks to see if a given email exists in the HackerAPI

    Parameters

    • email: string | { email: string }

    Returns Promise<boolean>

Static dateHandler

  • dateHandler(key: string, date: string | Date): string[]
  • Converts a Javascript date (where only day, month and year are relevant) to a format understood by hackerapi

    Parameters

    • key: string
    • date: string | Date

      Doesn't do anything if string

    Returns string[]

    key: [0], value: [1]

Static dateTimeHandler

  • dateTimeHandler(key: string, datetime: string | Date): string[]
  • Converts Javascript date to a format understood by hackerapi

    Parameters

    • key: string
    • datetime: string | Date

    Returns string[]

    key: [0], value: [1]

Static doNotSendHandler

  • doNotSendHandler(key: string, _: any): (undefined | string)[]
  • Does not send the field to hackerapi

    Parameters

    • key: string
    • _: any

    Returns (undefined | string)[]

    key: [0], value: [1]

Static login

  • login(email: string, password: string, firebase_service?: undefined | string): Promise<{}>
  • Gets a token to use with all subsequent authenticated requests

    Parameters

    • email: string
    • password: string
    • Optional firebase_service: undefined | string

    Returns Promise<{}>

Static loginJWT

  • loginJWT(jwt: string): Promise<{}>
  • Gets a token to use with all subsequent authenticated requests

    Parameters

    • jwt: string

    Returns Promise<{}>

Static renameHandler

  • renameHandler(renamedKey: string): (Anonymous function)
  • HOC for renaming a field before sending it to hackerapi

    Parameters

    • renamedKey: string

      The string to rename the key to

    Returns (Anonymous function)

    key: [0], value: [1]

Static resetPassword

  • resetPassword(email: string, callbackUrl: string, tokenOnly?: boolean): Promise<{ email: string; message: string; tokenHash: string }>
  • Triggers an email to reset your password

    Parameters

    • email: string
    • callbackUrl: string
    • Default value tokenOnly: boolean = false

    Returns Promise<{ email: string; message: string; tokenHash: string }>

Static setPassword

  • setPassword(email: string, password: string, token: string): Promise<{ email: string; message: string }>
  • Sets the user's password

    Parameters

    • email: string
    • password: string
    • token: string

    Returns Promise<{ email: string; message: string }>

Generated using TypeDoc