@trulioo/kyc-documents
v3.0.49
Published
Trulioo KYC-Documents Javascript SDK
Readme
@trulioo/kyc-documents
Trulioo KYC-Documents Javascript SDK
For more information, see our Documentation.
Info
Some US states impose obligations on businesses that collect and use “biometric identifiers” and/or “biometric information”, which may include facial scan data extracted from photos during a document verification transaction. One such law is the Illinois Biometric Information Privacy Act (“BIPA”). A business required to comply with BIPA is under obligations to, among other things, ensure that it informs the individual of the purpose of the collection and obtain consent. Accordingly, we require a notice and consent mechanism be implemented for all document verification transactions, and our customers using our API must provide us with confirmation via API whether an individual is located in the United States and has consented to the transaction in the prescribed manner. We also strongly encourage all of our customers to consult with legal counsel to ensure their own compliance with such laws.
For more information about the required notice and consent mechanism, please refer to our Service Specific Terms for Document Verification.
Install and Usage
HTML
Create an HTML element where the SDK UI should be rendered:
<div id="trulioo-sdk"></div>JS
Import the Javascript modules and set up the SDK:
import {Trulioo, EventBuilder, ListenerCallback, Response} from "@trulioo/kyc-documents"
const elementID = "trulioo-sdk" // The HTML element id to attach to
const shortCode = "sample-short-code" // Set the obtained short code from the Trulioo Customer API
// Set up callbacks to get results and debugging errors
const callbacks = new ListenerCallback({
onComplete: (success: Response.Success) => {
console.info(`Verification Successful: ${success.transactionId} `)
},
onError: (error: Response.Error) => {
console.error(`Verification Failed with Error Code: ${error.code}, Reason: ${error.message}`)
},
onException: (exception: Response.Exception) => {
console.error("Verification Failed with Exception:", exception)
}
})
const events = new EventBuilder()
const callbackOption = events.setCallbacks(callbacks)
// Initialize the SDK with the shortcode
const trulioo = new Trulioo()
trulioo.initialize(shortCode)
.then(complete => {
console.info("Initialize complete:", complete)
// Launch the UI with the provided HTML element ID
trulioo.launch(elementID, callbackOption)
.then(success => {
console.info("Launch success:", success)
})
})
.catch(error =>
console.error("Error:", error)
)
Note: The SDK will import additional css files automatically. Be sure to not exclude the css files contained in the @trulioo/kyc-documents node_modules directory from your web app configuration if you are using webpack css-loader or something similar.
Customization
The SDK supports customization options that allow you to tailor the user experience. You can configure settings such as language locale and themes. All customization is managed through the Customer API at the time you create a transaction. Once the short code is provided to the SDK, it will automatically render using the configured locale and theme.
For details on how to configure these options, see the Customer API documentation.
Desktop to Mobile Workflow
The SDK also supports cross-device document capture.
When a user begins the verification flow on a desktop browser, they will be shown a QR code that can be scanned with their mobile phone.
This allows them to seamlessly continue the capture process using their phone’s camera.
After completing the document capture on mobile, the user is automatically redirected back to their desktop session to continue and complete the verification flow.
For details on how to configure these options, see the Customer API documentation.
Utilize the SDK from a CDN
In your project, you can import the Trulioo SDK:
import truliooKYC from "https://cdn.jsdelivr.net/npm/@trulioo/kyc-documents/+esm"You will now have full access to the SDK via your import, without any extra configuration steps needed. The above URL will get you the latest version of the SDK. If you want to use a more specific version for the SDK, you can do https://cdn.jsdelivr.net/npm/@trulioo/kyc-documents@VERSION_NUMBER/+esm and replace the VERSION_NUMBER to your choice.
