Class

HttpClient

HttpClient(api, options)

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, options)

Parameters:
Name Type Description
api string The URL of your Hanko API instance
options HttpClientOptions The options the HttpClient must be provided

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

Methods

# 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 376

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 333

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 366

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 344

Promise.<Response>

# processResponseHeadersOnLogin(userID, response)

Processes the response headers on login and extracts the JWT and expiration time. Also, the passcode state will be removed, the session state updated und a `hanko-session-created` event will be dispatched.
Parameters:
Name Type Description
userID string The user ID.
response Response The HTTP response object.

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

# 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 355

Promise.<Response>