Class

cnContext

cnContext()

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

Constructor

# new cnContext()

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

Since:
  • 08.2025, jh

View Source infohub/cnContext.js, line 19

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

cnContext

Members

# readonly SERVICE

Supported web services.

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

View Source infohub/cnContext.js, line 32

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

Methods

# dump() → {void}

Print current context to the console (for debugging).

View Source infohub/cnContext.js, line 119

void

# getProjectShortId()

Since:
  • 1.0, 09.2025, jh

View Source infohub/cnContext.js, line 283

Project ShortId

# getScope() → {string}

Get current scope.

View Source infohub/cnContext.js, line 200

string

# getServiceUrl(servicename) → {string|null}

Get URL of supported webservice.

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

View Source infohub/cnContext.js, line 260

Url of service, null if not found

string | null

# getToken() → {string}

Get current access token.

View Source infohub/cnContext.js, line 192

string

# getUserId() → {string}

Get current user id.

View Source infohub/cnContext.js, line 181

User ID (Email)

string

# resetProjectAndScope() → {void}

Reset scope and project to null.

View Source infohub/cnContext.js, line 139

void

# setProjectShortId(sid) → {void}

Set current project short id.

Parameters:
Name Type Description
sid string

View Source infohub/cnContext.js, line 272

void

# setScope(scope) → {void}

Set current scope.

Parameters:
Name Type Description
scope string

View Source infohub/cnContext.js, line 209

void

# setScopeAndProjectShortId(scope, project_sid) → {void}

Set scope and project short id.

Parameters:
Name Type Description
scope string
project_sid string

View Source infohub/cnContext.js, line 169

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/cnContext.js, line 234

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)

 

# setUserAndToken(userid, token) → {void}

Set current user id and authentication token.

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

View Source infohub/cnContext.js, line 154

void

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

Get list of names of supported web services.

Since:
  • 08.2025, jh

View Source infohub/cnContext.js, line 67

Array of names as string

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