Truework.js library reference
The Truework.js JavaScript library allows Truework Direct to be embedded directly into your frontend application.
Truework.credentials.init(config)
Initializes the Truework Direct widget. Accepts one required argument, a config
object. Returns a Truework.credentials
object
config
object
Publishable key that provides the configuration of this instance of the Truework Direct widget.
Applicant-specific token referencing the Truework Direct session created using the backend API.
Environment the session should be initialized in, one of:
Truework.credentials
object
Represents an initialized instance of the Truework Direct widget. This object has a number of methods to control the widget and subscribe to widget events.
Truework.credentials.open()
Opens the widget modal window over the current page.
Truework.credentials.close()
Closes the widget modal window.
Truework.credentials.onOpen(fn)
Registers a callback function to be called after the modal window is opened.
Truework.credentials.onClose(fn)
Registers a callback function to be called after the modal window is closed.
Truework.credentials.onSuccess(fn)
Registers a callback function to be called after valid user credentials have successfully been collected. This does not necessarily mean the verification has completed.
Truework.credentials.onError(fn)
Registers a callback function that accepts an ErrorCode
enum value, to be called after an error occurs.
Error handling
Truework.credentials.onError
callbacks will be called when the following events occur:
- Any API errors coming from our API
- Any handled/unhandled errors from our credentials partners
- Any Truework.js internal errors (e.g. session creation, react errors, etc)
There are two types of Truework Direct errors:
- Critical errors: where the widget closes, and then the
onError
callbacks are called. - Errors: where the widget remains open while the
onError
callbacks are called.
The ErrorCode
enum value passed to the callback obscures the root cause and details of the error (preventing PII exposure) while enabling integrators to handle errors as gracefully as possible.
For example:
Browser support
We do our best to support all recent versions of major browsers. For the sake of security and providing the best experience to the majority of customers, we do not support browsers that are no longer receiving security updates and represent a small minority of traffic.
- We support the latest three versions of the following desktop and mobile browsers: Chrome, Firefox, Safari, and Edge.
- Internet Explorer 11 (IE11) support ended on May 15, 2022.
Visit our Help Center for more information.