Options
All
  • Public
  • Public/Protected
  • All
Menu

Class to handle cookies management, login, and fetching. Other implementations including:

  • on-demand login & cookies generation
  • throttled & cached login
  • expiring session check logic

Hierarchy

  • default

Index

Constructors

Properties

__cookieJar: PHPCookieJar = ...
__isLoggedIn: boolean = false
cookieProgress: null | Promise<void> = null
credential?: Credential
headers: { User-Agent: string } = ...

Type declaration

  • User-Agent: string
lockCookies: boolean = false
loginProgress: null | Promise<void> = null
BASE_URL: "http://prodeskel.binapemdes.kemendagri.go.id" = ...
HOST: "prodeskel.binapemdes.kemendagri.go.id" = ...

Accessors

  • get isLoggedIn(): boolean

Methods

  • fetch(input: RequestInfo, init?: Omit<RequestInit, "body"> & { body?: any }): Promise<Response>
  • Wrapped fetch function that will make sure connection is logged in before doing the request.

    Will auto-login if not already logged in, as long as useCredential is set up, else throwing error.

    Auto login is throttled by this.isLoggedIn, will wait for ongoing login call before calling own function.

    Parameters

    • input: RequestInfo
    • Optional init: Omit<RequestInit, "body"> & { body?: any }

    Returns Promise<Response>

  • generateCookies(): Promise<void>
  • Generate cookies (mainly to get PHPSESSID) from the server by touching /app_login/

    Returns Promise<void>

  • login(credential?: null | Credential): Promise<void>
  • Logging in to prodeskel by POST-ing to /app_login/. Requires cookies to be generated beforehand and PHPSESSID cookie exist.

    If useCredential is set up, input credential will be ignored.

    Will call this.generateCookies() when no cookies found.

    Calling this method will make sure that cookies is generated, cookies.sessionId is exist, and this.isLogin exist

    Throw error on fail attempt.

    Parameters

    Returns Promise<void>

Generated using TypeDoc