@cyberity/websdk
v1.0.0
Published
Cyberity WebSdk
Downloads
407
Readme
Cyberity WebSDK
Installation
npm i @cyberity/websdk --save
How to use
import cyberitySdk from '@cyberity/websdk';
function launchWebSdk(accessToken, applicantEmail, applicantPhone) {
let sdkInstance = cyberitySdk.init(
accessToken,
// token update callback, must return Promise
// Access token expired
// get a new one and pass it to the callback to re-initiate the WebSDK
() => this.getNewAccessToken()
)
.withConf({
lang: 'en', //language of WebSDK texts and comments (ISO 639-1 format)
email: applicantEmail,
phone: applicantPhone,
})
.on('idCheck.stepCompleted', (payload) => {
console.log('stepCompleted', payload)
})
.on('idCheck.onError', (error) => {
console.log('onError', error)
})
.build();
// you are ready to go:
// just launch the WebSDK by providing the container element for it
sdkInstance.launch('#websdk-container');
}
function getNewAccessToken() {
return Promise.resolve(newAccessToken) // get a new token from your backend
}