If the file is imported successfully, then the soundproof namespace which includes all relevant functionality will become available to the page. Note that you must not explicitly import the rest of the js files in your page using a <script> tag. They will be fetched and loaded automatically by soundproof.min.js.

Initialise the SoundProof object at page load, supplying the various callback functions in order to track various events during the authentication. You can also configure the base URL (which should be the Service hostname) as well as other optional parameters (see here for details). Here is an example on how to do it:

Start the SoundProof authentication step by providing the session_token that your backend server retrieved by calling /srv/auth/v1/user/auth. This can be achieved with a variety of ways. For example, you can:

use XHR or WebSocket, or

place the session_token somewhere in the DOM and make it available in JavaScript

Once the session_token is available you can call:

spFactor.soundproof.start(session_token);

When SoundProof has been completed, you have to call /srv/auth/v1/user/auth_status (see the Auth API Reference) to get the final result of the authentication step (NOTE: the result of the authentication can only be retrieved by the backend API and not via the SoundProof JS library).

By implementing the SoundProof callbacks you can respond to any kind of event, e.g. onComplete(), onError(). In order to retrieve the authentication step status, you can:

wait for SP onComplete() callback to be called and then make an XHR (or WebSocket send) to your backend server, which in turn makes the call to /srv/auth/v1/user/auth_status. The latter will respond with a final status (allow, deny) once the final result is available.

make an XHR (or WebSocket send) to your backend server, which in turn makes a synchronous call to /srv/auth/v1/user/auth_status with final_result=true right after starting SP and wait for the response (using a deferred object or promise)