JavaScript Component

Integrating with a websocket server is very easy in Javascript and you can use the WebSocket object provided by the browser. Below you can find an example on how to manage the process described in the diagram above:

function startSession() {
    
    var socket = new WebSocket('wss://idws.uqudo.io/ws/v1/session');

    socket.addEventListener('open', function (event) {
        socket.send('qrCodeText'); // this is required to authenticate the web socket channel

        // you can create the qrCode at this stage. See example below
        new QRCode(document.getElementById('qrcode_id'), {
            text: 'qrCodeText or qrCodeTextWithDynamicLink',
            width: 128,
            height: 128,
            colorDark: "#000000",
            colorLight: "#ffffff",
            correctLevel: QRCode.CorrectLevel.H
        });
    });
    
    socket.addEventListener('message', function (event) {
        var message = JSON.parse(event.data);
        if (message.service && message.service == 'INFO') {
            socket.close();
            folloupWithRegistration(message.sessionId);
        }
    });
    
    socket.addEventListener('close', function (event) {
        // e.g. remove the qr code
    });
}

The QR code text sent to the server after opening the WebSocket session:

PropertyTypeOptionalDescription

qrCodeText

string

No

Used to authenticate the web socket channel and to create the QR code if qrCodeTextWithDynamicLink is not used instead

The object received during the on-boarding process

PropertyTypeOptionalDescription

service

string

No

Possible values:

  • SCAN

  • READ

  • FACE

  • BACKGROUND_CHECK

  • INFO

SCAN stands for document scanning. It is returned after a successful scanning of the document

READ stands for document reading, e.g. NFC for Emirates ID. It is returned after a successful read

FACE stands for facial recognition. It is returned after a successful facial recognition

BACKGROUND_CHECK stands for background check. It is returned after a successful background check

INFO is the last step of the onboarding process where the SDK retrieves the final result (JWS). It defines the end of the onboarding process

sessionId

string

No

The session is related to the onboarding session that can be used to follow up with the registration process and retrieve the data collected from the uqudo backend.

Last updated