Constructor
# new cnContext()
Create an COLNEO infohub context with service endpoints set to null and empty user state.
- Since:
- 08.2025, jh
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
Members
# readonly SERVICE
Supported web services.
HUB | CONFIG | USR | IDP | IAM | RENDER | RPC | TYPES
Example
...
const url = `${ctx.getServiceUrl(cnContext.SERVICE.IDP)}/users/${userid}`;
Methods
# getServiceUrl(servicename) → {string|null}
Get URL of supported webservice.
Parameters:
Name | Type | Description |
---|---|---|
servicename |
string
|
- Since:
- 08.2025, jh
Url of service, null if not found
string
|
null
# setProjectShortId(sid) → {void}
Set current project short id.
Parameters:
Name | Type | Description |
---|---|---|
sid |
string
|
void
# setScopeAndProjectShortId(scope, project_sid) → {void}
Set scope and project short id.
Parameters:
Name | Type | Description |
---|---|---|
scope |
string
|
|
project_sid |
string
|
void
# setServiceUrls(cfg)
Set multiple service URLs at once.
Parameters:
Name | Type | Description |
---|---|---|
cfg |
Record.<string, string>
|
Object mapping service names to URLs |
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
|
void
# static getServiceNames() → {Array.<string>}
Get list of names of supported web services.
- Since:
- 08.2025, jh
Array of names as string
Array.<string>
Example
let names = Infohub.getServiceNames()