Class

Context

Context()

Class to configure access to COLNEO infohub.
Keeps track of user identity, project/scope, and base URLs for services.

Constructor

# new Context()

Create an COLNEO infohub context with service endpoints set to null and empty user state.

Since:
  • 08.2025, jh

View Source infohub/Context.js, line 21

Example
// create context
 const ctx = new cnContext();

 ctx.setServiceUrls({
   hub   : "https://app.colneo.services/hub",
   admin : "https://app.colneo.services/admin",
   usr   : "https://app.colneo.services/usr",
   idp   : "https://idp.colneo.services/service"
 });

 ctx.setUserAndToken( "user@example.com" , "... jwt_token ...");
 ctx.setScopeAndProject( "cn_c00", "proj_123");

 ctx.getScope(); // => "project"
 ctx.getProjectShortId(); // => "proj_123"
 ctx.getUser(); // => "user@example.com"
 ctx.getToken(); // => "jwt_token"

 console.log(cntx.getUser()); // => "user@example.com"

Classes

Context

Members

# readonly SERVICE

Supported web services.

HUB | CONFIG | USR | IDP | IAM | RENDER | RPC | TYPES

View Source infohub/Context.js, line 36

Example
...
 const url = `${ctx.getServiceUrl(cnContext.SERVICE.IDP)}/users/${userid}`;
 

Methods

# dump() → {void}

Print current context to the console (for debugging).

View Source infohub/Context.js, line 129

void

# async getProject() → {Promise.<(object|null)>}

api call to get project data from infohub by short id

View Source infohub/Context.js, line 368

Returns a Project object or null

Promise.<(object|null)>

# getProjectShortId()

Since:
  • 1.0, 09.2025, jh

View Source infohub/Context.js, line 359

Project ShortId

# getScope() → {string}

Get current scope.

View Source infohub/Context.js, line 249

string

# getServiceUrl(servicename) → {string|null}

Get URL of supported webservice.

Parameters:
Name Type Description
servicename string
Since:
  • 08.2025, jh

View Source infohub/Context.js, line 334

Url of service, null if not found

string | null

# getToken() → {string}

Get current access token.

View Source infohub/Context.js, line 241

string

# getUserId() → {string}

Get current user id.

View Source infohub/Context.js, line 230

User ID (Email)

string

# resetProjectAndScope() → {void}

Reset scope and project to null.

View Source infohub/Context.js, line 150

void

# setProjectShortId(sid) → {void}

Set current project short id.

Parameters:
Name Type Description
sid string

View Source infohub/Context.js, line 346

void

# setScope(scope) → {void}

Set current scope.

Parameters:
Name Type Description
scope string

View Source infohub/Context.js, line 258

void

# setScopeAndProjectShortId(scope, project_sid) → {void}

Set scope and project short id.

Parameters:
Name Type Description
scope string
project_sid string

View Source infohub/Context.js, line 208

void

# setServiceUrls(cfg)

Set multiple service URLs at once.

Parameters:
Name Type Description
cfg Record.<string, string>

Object mapping service names to URLs

View Source infohub/Context.js, line 285

If cfg is not a non-null object

TypeError
Example
const ctx = new cnContext();

 ctx.setServiceUrls({
   hub   : "https://app.colneo.services/hub",
   admin : "https://app.colneo.services/admin",
   usr   : "https://app.colneo.services/usr"
 });

 console.log(ctx.getServiceUrl("hub"));    // https://app.colneo.services/hub
 console.log(ctx.getServiceUrl("config")); // null (not set yet)

 

# setServiceUrlsDefault()

Set default values for services urls

View Source infohub/Context.js, line 309

# setUserAndToken(userid, token) → {void}

Set current user id and authentication token.

Parameters:
Name Type Description
userid string | null
token string | null

View Source infohub/Context.js, line 191

void

# static getServiceNames() → {Array.<string>}

Get list of names of supported web services.

Since:
  • 08.2025, jh

View Source infohub/Context.js, line 71

Array of names as string

Array.<string>
Example
let names = Infohub.getServiceNames()