Class

HttpClient

HttpClient(api, timeoutopt)

Internally used for communication with the Hanko API. It also handles authorization tokens to enable authorized requests. Currently, there is an issue with Safari and on iOS 15 devices where decoding a JSON response via the fetch API breaks the user gesture and the user is not able to use the authenticator. Therefore, this class uses XMLHttpRequests instead of the fetch API, but maintains compatibility by wrapping the XMLHttpRequests. So, if the issues are fixed, we can easily return to the fetch API.
Constructor

# new HttpClient(api, timeoutopt)

Parameters:
Name Type Attributes Description
api string The URL of your Hanko API instance
timeout number <optional>
The request timeout in milliseconds

View Source lib/client/HttpClient.ts, line 112

Methods

# _getAuthCookie() → {string|string}

Returns the authentication token that was stored in the cookie.

View Source lib/client/HttpClient.ts, line 289

string
string

# _setAuthCookie(token)

Stores the authentication token to the cookie.
Parameters:
Name Type Description
token string The authentication token to be stored.

View Source lib/client/HttpClient.ts, line 296

# delete(path) → {Promise.<Response>}

Performs a DELETE request.
Parameters:
Name Type Description
path string The path to the requested resource.

View Source lib/client/HttpClient.ts, line 356

Promise.<Response>

# get(path) → {Promise.<Response>}

Performs a GET request.
Parameters:
Name Type Description
path string The path to the requested resource.

View Source lib/client/HttpClient.ts, line 313

Promise.<Response>

# patch(path, bodyopt) → {Promise.<Response>}

Performs a PATCH request.
Parameters:
Name Type Attributes Description
path string The path to the requested resource.
body any <optional>
The request body.

View Source lib/client/HttpClient.ts, line 346

Promise.<Response>

# post(path, bodyopt) → {Promise.<Response>}

Performs a POST request.
Parameters:
Name Type Attributes Description
path string The path to the requested resource.
body any <optional>
The request body.

View Source lib/client/HttpClient.ts, line 324

Promise.<Response>

# put(path, bodyopt) → {Promise.<Response>}

Performs a PUT request.
Parameters:
Name Type Attributes Description
path string The path to the requested resource.
body any <optional>
The request body.

View Source lib/client/HttpClient.ts, line 335

Promise.<Response>

# removeAuthCookie(token)

Removes the cookie used for authentication.
Parameters:
Name Type Description
token string The authorization token to be stored.

View Source lib/client/HttpClient.ts, line 303