constructor

Create a new Upgrade Client for communicating to server

constructor(userId, hostUrl, options)

Arguments

userId (String): Id of user

hostUrl (String): Url of the upgrade server

options (Object): (Optional)

  • token (String): JWT Bearer token for the Upgrade Server Header (Optional)

  • clientSessionId (String): SessionId of application. If not provided, it will create a new sessionId(uuid) (Optional)

Example

import UpgradeClient from "upgrade_client_lib";

// construct upgrade client for student1
const userId = "student1";

// set host url for the Upgrade Backend deployed on Elastic Beanstalk:
const hostUrl = 'http://bsnl-upgrade-experiment-app.eba-xkparwve.us-east-1.elasticbeanstalk.com';

// Two ways for initializing user constructor:
const client = new UpgradeClient(userId, hostUrl);
const client = new UpgradeClient(userId, hostUrl, options);

Note: We set CLIENT_API_KEY and CLIENT_API_SECRET in the deployed Upgrade backend which are used for the authentication. The JWT Token is signed using the environment variable CLIENT_API_KEY and is passed in the constructor. We then verify this token's authentication in the ClientLibMiddleware against the CLIENT_API_SECRET

Last updated