Client
nervoscan-js-sdk / Client
Class: Client
Defined in: Client.ts:20
Client class for interacting with the Nervoscan API. This class provides methods for authentication, video upload/streaming, and result retrieval.
Methods
initialize()
initialize(
__namedParameters):void
Defined in: Client.ts:74
Initializes the client with credentials and selects the backend. Notes:
- Username/password authentication is deprecated; prefer
licenseKey. - If both
licenseKeyandusername/passwordare provided,licenseKeytakes precedence.
Parameters
__namedParameters
ClientOptions
Returns
void
Throws
If the server type is invalid
initializeStreaming()
initializeStreaming(
videoStream,videoElement,config):Promise<void>
Defined in: Client.ts:174
Initializes the streaming manager.
Parameters
videoStream
MediaStream
The video stream to stream
videoElement
HTMLVideoElement
The video element to stream to
config
RGBManagerConfig = {}
Optional RGB capture and quality configuration
Returns
Promise<void>
setOnAlignmentStatus()
setOnAlignmentStatus(
callback):void
Defined in: Client.ts:144
Sets a callback function to handle face alignment status updates.
Parameters
callback
(status) => void
Function to be called with alignment status. Takes a FaceAlignmentStatus parameter.
Returns
void
setOnDisconnection()
setOnDisconnection(
callback):void
Defined in: Client.ts:135
Sets a callback function to handle disconnection.
Parameters
callback
() => void
Function to be called when the connection is lost. Takes no parameters.
Returns
void
setOnError()
setOnError(
callback):void
Defined in: Client.ts:127
Sets a callback function to handle errors.
Parameters
callback
(error) => void
Function to be called with error. Takes a single parameter of type any containing the error data.
Returns
void
setOnFinalResults()
setOnFinalResults(
callback):void
Defined in: Client.ts:119
Sets a callback function to handle final averaged results when they arrive.
Parameters
callback
(results) => void
Function to be called with final results. Takes a single parameter of type any containing the averaged results data.
Returns
void
startFaceDetection()
startFaceDetection():
void
Defined in: Client.ts:152
Starts face detection for alignment feedback (without data collection). Call this after video stream is available to get real-time face positioning feedback.
Returns
void
startStreaming()
startStreaming():
Promise<string>
Defined in: Client.ts:199
Starts streaming the video to the server.
Returns
Promise<string>
The API key (job id) if streaming started successfully
Throws
If the client is not initialized
Throws
If the user has no scans available in the current plan
Throws
If the access token is invalid
Throws
If the username is invalid. The user should reinitialize the client with the correct credentials. Run Client.initialize()
Throws
If the password is invalid. The user should reinitialize the client with the correct credentials. Run Client.initialize()
Throws
If the license key is invalid
Throws
If the license is inactive
stopFaceDetection()
stopFaceDetection():
void
Defined in: Client.ts:161
Stops face detection for alignment feedback.
Returns
void
stopStreaming()
stopStreaming(
skipValidation):Promise<void>
Defined in: Client.ts:225
Stops streaming the video to the server and cleans up RGB capture state.
Parameters
skipValidation
boolean = false
Optional parameter to skip automatic scan completion validation
Returns
Promise<void>
uploadVideo()
uploadVideo(
videoBlob):Promise<undefined|string>
Defined in: Client.ts:96
Uploads a video and returns the API key (job id).
Parameters
videoBlob
Blob
The video blob to upload
Returns
Promise<undefined | string>
The API key
Throws
If the client is not initialized
Throws
If the video blob is not a Blob
Throws
If the video blob is empty
Throws
If the user has no scans available in the current plan
Throws
If the access token is invalid
Throws
If the username is invalid. The user should reinitialize the client with the correct credentials. Run Client.initialize()
Throws
If the password is invalid. The user should reinitialize the client with the correct credentials. Run Client.initialize()
Throws
If the license key is invalid
Throws
If the license is inactive
validateScanCompletion()
validateScanCompletion():
Promise<void>
Defined in: Client.ts:251
Validates scan completion by checking RGB data sufficiency and FPS requirements. This method should be called after streaming is complete to ensure data quality before processing.
Returns
Promise<void>
Resolves if validation passes, throws appropriate error if validation fails
Throws
If the client is not initialized
Throws
If insufficient RGB data was collected
Throws
If the frame rate is too low for quality analysis
getInstance()
staticgetInstance():Client
Defined in: Client.ts:53
Gets the singleton instance of the Client class.
Returns
Client