IafPassSvc
Use the IafPassSvc API to create and manage the passport service resources, such as users, session users, user groups, user group invites, workspaces, applications, notification templates, and permissions.
addUsersToGroup
Adds users to a user group. To use this method, the current user nust have edit permission for the group.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The user group's id |
| userIds | Yes | Array<String> | The ids of the users you want to add to the user group |
| ctx | Yes | Ctx | Context, such as namespaces and authentication token information - Optional |
Array<User> - The array of the User class objects you add
const newUsers = await IafPassSvc.addUsersToGroup(id, userIds);
addUserToGroupByInvite
Adds a user to a user group after they accept an invitation.
| Parameter | Required | Type | Description |
|---|---|---|---|
| groupId | Yes | String | Pass the user group's UUID. |
| inviteId | Yes | String | Pass the invite's UUID. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
Array<User> - The user details of the invitee
const users = await IafPassSvc.addUserToGroupByInvite(groupId, inviteId);
createApplication
Creates an application
| Parameter | Required | Type | Description |
|---|---|---|---|
| application | Yes | Application | Application object with app owner user id and organization id |
| ctx | No | Ctx | Context, contains authentication token information |
| options | Yes | any |
{
"_id":"94a1eb2b-06bd-426e-a3ce-e7ab609ea231",
"_name": "DigitalTwin",
"_appOwner": "dtowner@xxxxxx.com",
"_userType":"web_app",
"_redirectUris":"https://app.xxxxxx.com/dt/login",
"_home":"https://app.xxxxxx.com/dt",
"_orgId":"36a1eb2b-06bd-426e-a3ce-e7ab609ea825"
}
createNotificationTemplates
Creates multiple NotificationTemplate class objects.
| Parameter | Required | Type | Description |
|---|---|---|---|
| notificationTemplates | Yes | Array<NotificationTemplate> | Pass an array of NotificationTemplate object. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information |
Promise<Page<NotificationTemplate>> - A promise with a page of the created NotificationTemplate objects
const notificationTemplates = [
{
_name: "app1_invite"
_title: "Invitaion to join Application 1"
_message: "Click the following link to join the application:"
_format: "text"
_appId: "68595r24-4cf5-4587-3325-955ac7a65872"
},
{
_name: "app2_invite"
_title: "Invitaion to join Application 2"
_message: "Click the following link to join the application:"
_format: "text"
_appId: "99663r24-4cf5-7878-4646-955ac7a55688"
}
];
const notificationTemplates = await IafPassSvc.createNotificationTemplates(notificationTemplates);
createOrganization
Creates an Organization.
| Parameter | Required | Type | Description |
|---|---|---|---|
| organization | Yes | Organization | Pass a Organization object you define. |
| ctx | No | Ctx | Context, authentication token information. |
| options | No | Options | Pass a JSON object for optional query params |
Promise<Organization> - A promise with a page that contains the created Organization object
let org = {
"_name": "ABC Organization",
"_orgOwner": "org_owner@xxxxorg.com",
"_shortName":"abc_org"
}
IafPassSvc.createOrganization(org);
createPermissionProfiles
Creates multiple PermissionProfile class objects
| Parameter | Required | Type | Description |
|---|---|---|---|
| permissionProfiles | Yes | Array<PermissionProfile> | Array of PermissionProfile objects totalling a maximum of 1MB of data |
| ctx | No | Ctx | Context, such as namespaces and authentication token information |
Promise<Page<PermissionProfile>> -
createPermissions
Creates Permission class objects for Passport Service resources such as Workspaces and UserGroups. You can create a maximum of 25 permissions at a time.
| Parameter | Required | Type | Description |
|---|---|---|---|
| permissions | Yes | Array<Permission> | Pass an array of Permission objects you define. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
| options | No | Options | Pass a a JSON object with one or more Page object parameters, such as "_offset" or "_pageSize". The default value for offset is 0 and for page size is 10. |
CreatePermissionsResponse - A CreatePermissionsResponse object with with separate arrays of the successful and failed permissions
// Permissions with mandatory fields
const permissions = [{
_actions: [ IafPermission.PermConst.Action.Read, IafPermission.PermConst.Action.Share, IafPermission.PermConst.Action.Delete ],
_namespace: "ProjA_HEpftR8X",
_resourceDesc:{
_irn: "passportsvc:workspace:*" // Refer {Permission} for more valid irns
},
_user: {
_id: "75b2a3d6-a3e8-498d-99dc-23538bc9a389", // Either user or usergroup, specify respective _type
_type: IafPermission.PermConst.UserType.User // Either user or usergroup, specify respective _id
}
}];
const result = IafPermission.createPassPermissions(permissions, ctx);
// Permissions with criteria
const permissions = [{
_actions: [ IafPermission.PermConst.Action.Read, IafPermission.PermConst.Action.Share, IafPermission.PermConst.Action.Delete],
_namespace: "ProjA_HEpftR8X",
_resourceDesc: {
_irn: "passportsvc:workspace:*",
_criteria: {
usertype: "project"
}
},
_user: {
_id: "75b2a3d6-a3e8-498d-99dc-23538bc9a389", // Either user or usergroup, specify respective _type
_type: IafPermission.PermConst.UserType.User // Either user or usergroup, specify respective _id
}
}];
const result = await IafPassSvc.createPermissions(permissions, ctx);
createUser
Creates a new User class object.
| Parameter | Required | Type | Description |
|---|---|---|---|
| body | Yes | User | Pass a User object that contains the User definition. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information |
| options | No | Options | Pass an Options object with your offset and page size options. The default value for "_offset" is 0 and for "_pageSize" is 10. |
Promise<User> - Returns a promise with the created User object.
// Create a new user, Please set the optional _tempPassword to true to consider _password as temporary and enforce the user to reset the password on their first login
const body = {
_firstname: "John",
_lastname: "Doe",
_email: "johndoe@mail.com",
_password: "Test@123",
_tempPassword: true
};
const user = await IafPassSvc.create(userData, ctx);
createUserGroup
Creates a UserGroup class object.
| Parameter | Required | Type | Description |
|---|---|---|---|
| userGroup | Yes | UserGroup | Pass a UserGroup object with the properties and values you define. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
| options | No | Options | Pass a JSON object for optional query params such as {_appId:'edf36978-cf47-49ac-aa88-3183705b25e0'} |
Promise<Page<UserGroup>> - A promise with a Page object that contains the created UserGroup object
let userGroup = {
_name: "user_group_for_testing_purposes",
_description: "User group for the purpose of this example"
_shortName: "test_user_group",
_namespaces: "ProjA_HEpftR8X",
_userType: "example_user_group"
};
const userGroup = await IafPassSvc.createUserGroup(userGroup);
createUserGroups
Create multiple UserGroup class objects. You can create a maximum of 25 user groups at a time.
| Parameter | Required | Type | Description |
|---|---|---|---|
| userGroups | Yes | Array<UserGroup> | Pass an array of UserGroup JSON objects you want to create. |
| ctx | Yes | Ctx | Context, such as namespaces and authentication token information |
| options | No | Options | Pass a JSON object for optional query params such as {_appId:'edf36978-cf47-49ac-aa88-3183705b25e0'} |
Promise<Page<UserGroup>> - A Page object with the UserGroup objects you create
let userGroups = [
{
_name: "user_group_for_testing_purposes",
_description:"User group for the purpose of this example"
_shortName: "test_user_group",
_namespaces: "ProjA_HEpftR8X",
_userType: "example_user_group"
},
{
_name: "second_user_group_for_testing_purposes",
_description:"Second user group for the purpose of this example"
_shortName: "test_user_group_2",
_namespaces: "ProjA_HEpftR8X",
_userType: "example_user_group"
}
];
const userGroups = await IafPassSvc.createUserGroups(userGroups);
createWorkspace
Creates a Workspace class object.
| Parameter | Required | Type | Description |
|---|---|---|---|
| workspace | Yes | Workspace | Pass a Workspace object you define. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
| options | No | Options | Pass a JSON object for optional query params such as {_appId:'edf36978-cf47-49ac-aa88-3183705b25e0'} |
Promise<Page<Workspace>> - A promise with a page that contains the created Workspace object
let workspace = {
_description: "Project A workspace",
_name: "Project A",
_shortName: "Proj_A",
_namespaces: "ProjA_HEpftR8X",
_userAttributes: {
createdDate: new Date().toISOString()
},
};
IafPassSvc.createWorkspace(workspace);
createWorkspaces
Creates multiple Workspace class objects. You can create a maximum of 25 workspaces at a time.
| Parameter | Required | Type | Description |
|---|---|---|---|
| workspaces | Yes | Array<Workspace> | Pass an array of Workspace objects you define. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
| options | No | Options | Pass a JSON object for optional query params such as {_appId:'edf36978-cf47-49ac-aa88-3183705b25e0'} |
Promise<Page<Workspace>> - A promise with a page that contains the Workspace object you create
const workspaces = {
{
_description: "Project A workspace",
_name: "Project A",
_shortName: "Proj_A",
_namespaces: "ProjA_HEpftR8X",
_userAttributes: {
createdDate: new Date().toISOString()
},
},
{
_description: "Project B workspace",
_name: "Project B",
_shortName: "Proj_B",
_namespaces: "ProjB_TGpftY3H",
_userAttributes: {
createdDate: new Date().toISOString()
},
},
};
IafPassSvc.createWorkspace(workspaces);
deleteApplicationConfigs
Deletes the applicationConfigs by applicationId (appId)
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | |
| ctx | Yes | Ctx |
Promise<String> - {ok:204} response
const applicationConfigs = await deleteApplicationConfigs(id, ctx);
deleteNotificationTemplate
Deletes a NotificationTemplate class object.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The NotificationTemplate's id |
| ctx | No | Ctx | Context, such as namespaces and authentication token information |
Promise<String> - {ok:204} response
const response = await IafPassSvc.deleteNotificationTemplate(id);
deleteOrganization
Soft deletes a organization.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | Pass the organization's id. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
Promise<String> - {ok:204} response
let id = "4e2b9de5-9a73-44f9-8153-bc0904b694c5";
IafPassSvc.deleteOrganization(id);
deleteOrganizationConfigs
Deletes the organizationConfigs by Organization Id
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | |
| ctx | Yes | Ctx |
Promise<String> - {ok:204} response
const organizationConfigs = await deleteOrganizationConfigs(id, ctx);
deletePermission
Deletes a Permission class object when you pass its id.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | Pass the permission's id. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
| options | No | Options | To pass headers, pass an object called "options" and add a "headers" property with your headers as the value. |
String - ok:204 response
IafPassSvc.deletePermission(id);
deletePermissionActions
Deletes specific permission actions based on the provided body content. This function constructs a URL for the deletion endpoint, and performs a DELETE request with the body content specifying which permission actions to remove. The body should detail the actions, service identifier, and resource identifier for which permissions are to be deleted.
| Parameter | Required | Type | Description |
|---|---|---|---|
| body | Yes | Object | The body of the request containing the details of the permission actions to delete. |
| the service identifier (_svc), and the resource identifier (_resource). | |||
| ctx | No | Ctx | Optional context object that may include namespaces and authentication token information along with other context-specific data. |
| This context is used to determine if session storage should be skipped when making the fetch request. |
Promise<void> - A promise that resolves when the deletion operation is complete. If the operation is successful, the promise resolves without any value. If there is an error during the deletion, the promise rejects with an error message.
// Example of deleting specific permission actions for a 'nameduseritem' resource in the 'itemsvc' service
const body = {
"_svc": "itemsvc",
"_resource": "nameduseritem"
};
await IafPassSvc.deletePermissionActions(body, ctx)
.then(() => console.log('Deletion successful'))
.catch(error => console.error('Deletion failed', error));
Authorization: Only Trusted clients can make this API
deletePermissionProfile
Deletes a PermissionProfile by id
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | PermissionProfile id |
| ctx | Yes | Ctx | Context, such as namespaces and authentication token information |
Promise<String> - {ok:204} response
const response = await deletePermissionProfile(id, ctx);
deleteUserGroup
Deletes a UserGroup.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | Pass the UserGroup's id. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
String - ok: 204 response
const response = await IafPassSvc.deleteUserGroup(id);
deleteUsersFromGroup
Removes Users from a UserGroup. To use this method, the current user should have delete permissions for the group.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | Pass the user group's id. |
| userIds | Yes | Array<String> | Pass an array with the user ids you want to remove. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
String - ok: 204 response
const response = await IafPassSvc.deleteUsersFromGroup(id, userIds);
deleteWorkspace
Soft deletes a Workspace class object.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | Pass the Workspace's id. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
Promise<String> - {ok:204} response
IafPassSvc.deleteWorkspace(workspace._id);
fetchTokens
This Method will be used to get the Access Token and Refresh Token either from the Authorization_Code Grant Type or Authorization_Code With PKCE Grant Type or Using the Refresh Token
| Parameter | Required | Type | Description |
|---|---|---|---|
| config | Yes | Object | |
| ctx | Yes | Ctx | Context, such as namespaces and authentication token information. |
| options | Yes | any |
//Config Example For PKCE:
cosnt config = {
redirectUri: 'http://localhost:4568/digitaltwin',
clientId: '<appId>',
code: 'Auth Code',
codeVerifier: '4cc9b165-1230-4607-873b-3a78afcf60c5',
scope: 'read write',
isRefresh: false
};
//Config Example For authorization_code:
let config = {
redirectUri: 'http://localhost:4568/digitaltwin',
clientId: '<appId>',
code: 'Auth Code',
scope: 'read write',
clientSecret: '<client_secret>'
isRefresh: false
};
Config Example For Refresh Token:
let config = {
redirectUri: 'http://localhost:4568/digitaltwin',
clientId: '<appId>',
code: 'Auth Code',
scope: 'read write',
isRefresh: true,
refreshToken: '<refresh_token>'
};
const tokens = await iafPassSvc.fetchTokens(config, ctx);
// Example response
{
access_token: 'XXXXX',
token_type: 'bearer',
refresh_token: 'XXXXX',
expires_in: 86399,
scope: 'read write',
user_name: 'e3c7a9f7-3cc7-4b25-9617-988594c33f60',
app_id: '448e4ca9-dac9-490f-8d82-f8d4a1cd3100',
jti: 'bc68d113-6565-4564-8e1b-2217eb99d561'
}
getAccountSettingsUrl
Gets the account settings URL for a user interface button you create.
| Parameter | Required | Type | Description |
|---|---|---|---|
| returnUrl | No | String | Pass the client application's URL to redirect the user to the app after they exit the account settings. |
String - A URL to the account settings
const url = IafPassSvc.getAccountSettingsUrl('https://general-dev.company.com/ipa-dt')
getAllApplicationConfigs
Get All the Available Application Configs
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | Yes | Ctx |
Promise<Array<ApplicationConfigs>> - Returns the List of Application config
const applicationConfigs = await getAllApplicationConfigs(ctx);
getAllOrganizationConfigs
Get All the Available Organization Configs
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | Yes | Ctx |
Promise<Array<OrganizationConfigs>> - Returns the List of Organization config
const organizationConfigs = await getAllOrganizationConfigs(ctx);
getAllPermissionProfiles
Get all PermissionProfile class objects.
| Parameter | Required | Type | Description |
|---|---|---|---|
| criteria | Yes | PermissionProfileCriteria | Pass a JSON object with a Workspace object property, such as "_id" or "_namespaces" or "_name", and enter the value or array of values that you want to filter. |
| ctx | Yes | Ctx | Context, such as namespaces and authentication token information |
| options | No | Options | Pass a a JSON object with one or more Page object parameters, such as "_offset" or "_pageSize". The default value for offset is 0 and for page size is 10. |
Promise<Array<PermissionProfile>> -
const criteria = {
_namespaces: project._namespaces
};
const perms = await getAllPermissionProfiles(criteria, ctx);
getApplication
Gets an Application class object when you pass its id.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The Application's id |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
| options | Yes | undefined |
Promise<Application> - A promise with the Application object, 404 response if not found
const app = await IafPassSvc.getApplication(id);
getApplicationConfigs
Gets ApplicationConfig by applicationId (appId)
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | |
| ctx | Yes | Ctx | Context, such as namespaces and authentication token information |
Promise<ApplicationConfigs> - Returns the Application config by application Id
const applicationConfigs = await getApplicationConfigs(id, ctx);
applicationConfigs = {
"usergroups.limit": "5",
"workspaces.limit": "3"
}
getApplications
Gets the session User's applications. Only applications with READ access return.
| Parameter | Required | Type | Description |
|---|---|---|---|
| criteria | Yes | ApplicationCriteria | To filter your search, pass an Application object with your criteria. This parameter is currently not supported. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information |
| options | No | Options | Pass an Options object with your offset and page size options. The default value for "_offset" is 0 and for "_pageSize" is 10. |
Promise<Page<Application>> - A promise with a page of Application objects
let criteria = { namespaces: [...namespaces] };
const applications = await IafPassSvc.getApplications(criteria);
getAppToken
Gets a token for a specific application for a user by exchanging any valid access token.
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | Yes | String | The Application's UUID |
| ctx | No | Ctx | Context, such as namespaces and authentication token information |
const appToken = await IafPassSvc.getAppToken(appId);
getAuthUrl
Gets an OAuth2 authorization URL for an implicit client.
| Parameter | Required | Type | Description |
|---|---|---|---|
| clientUrl | Yes | String | The client application's URL that you want to redirect to with an access token after a successful login |
| appId | Yes | String | The platform application's id. |
String - Auth URL as a string
let url = IafPassSvc.getAuthUrl('https://general-dev.company.com/ipa-dt')
getConfigs
Gets a theme config
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | No | Ctx | Context, such as namespaces and authentication token information |
const configs = await IafPassSvc.getConfigs(ctx);
getCurrentUser
Gets the User class object for a given OAuth token.
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
User - Returns the User object.
const currentUser = await IafPassSvc.getCurrentUser(ctx);
getNamespaces
Gets authorized namespaces for match your criteria and sorts by namespace for the logged in user.
| Parameter | Required | Type | Description |
|---|---|---|---|
| criteria | Yes | NamespaceCriteria | Pass a JSON object with a criteria _namespace |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
| options | No | Options | Pass a a JSON object with one or more Page object parameters, such as "_offset" or "_pageSize". The default value for offset is 0 and for page size is 10. |
Promise<Page<Namespace>> - A Page object with the Namespace objects that match your criteria
// Get namespaces by criteria
const criteria = { _namespace: ["test_EPIr7dyU","test_FROr6dzN"] };
const res1 = await IafPassSvc.getNamespaces(criteria, ctx);
// Get namespaces with options
const criteria = { _namespace: ["test_EPIr7dyU","test_FROr6dzN"] };
const options = { _pageSize: 25, _offset: 0 };
const res2 = await IafPassSvc.getNamespaces(criteria, ctx, options);
getNotificationTemplate
Gets a NotificationTemplate class object.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The NotificationTemplate's UUID |
| ctx | No | Ctx | Context, such as namespaces and authentication token information |
Promise<NotificationTemplate> - A promise with the NotificationTemplate object
const notificationTemplate = await IafPassSvc.getNotificationTemplate(id, ctx);
getNotificationTemplates
Gets an application's notification templates that the session user has READ access to.
| Parameter | Required | Type | Description |
|---|---|---|---|
| criteria | No | NotificationTemplateCriteria | To filter your search, pass a NotificationTemplate object with your criteria. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information |
| options | No | Options | Pass an Options object with your offset and page size options. The default value for "_offset" is 0 and for "_pageSize" is 10. |
Promise<Page<NotificationTemplate>> - A promise with a page of NotificationTemplate objects
getOrganization
Gets a Organization when you pass its id.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | Pass the organization's id. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
| options | No | JSON | Optional properties, such as withConfigs to include or not |
Promise<Organization> - The Organization object you want. If the Organization method does not find the workspace, a 404 response returns.
getOrganizationConfigs
Gets OrganizationConfig by organization Id
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | |
| ctx | Yes | Ctx | Context authentication token information |
Promise<OrganizationConfigs> - Returns the Organization config by organization Id
const organizationConfigs = await getOrganizationConfigs(id, ctx);
organizationConfigs = {
"applications.limit": "5",
"workspaces.limit": "3"
}
getOrganizations
Get Organizations for a user
| Parameter | Required | Type | Description |
|---|---|---|---|
| criteria | Yes | OrganizationCriteria | criteria to filter organizations |
| ctx | No | Ctx | Context, authentication token information. |
| options | No | Options | Pass a a JSON object with one or more Page object parameters, such as "_offset" or "_pageSize". The default value for offset is 0 and for page size is 10. |
Promise<Page<Organization>> - A Page object with the Organization objects that match your criteria
// Get organizations with options
let criteria = {_name: "ABC Organization"}
let options = {_pageSize: 25, _offset: 0}
let res2 = await IafPassSvc.getOrganizations(criteria, ctx, options);
// Get getOrganizations by partial search in name, shorrtname and description
let criteria = {query: "xxxxx"}
let res3 = await IafPassSvc.getOrganizations(criteria, ctx, options);
getOrganizationUsers
Get Organization users
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | undefined | |
| criteria | Yes | Object | It contains to do wild card search on user's first name,lastname and email |
| ctx | No | Ctx | Context, authentication token information. |
| options | No | Options | Pass a a JSON object with one or more Page object parameters, such as "_offset" or "_pageSize". The default value for offset is 0 and for page size is 10. |
Promise<Page<User>> - A Page object with the Organization objects that match your criteria
// Get organization users with query with options
let criteria = {query: "alice"}
let options = {_pageSize: 25, _offset: 0}
let res2 = await IafPassSvc.getOrganizationUsers(id, criteria, ctx, options);
getPasswordPolicies
Gets the current User's principal info.
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | No | Ctx | Context, such as namespaces and authentication token information |
| options | No | Options | Pass an Options object with your offset and page size options. |
PrincipalInfo - Returns a PrincipalInfo object with user information, such as email, first and last name, and user id
const userInfo = await IafPassSvc.getPrincipalInfo(ctx);
getPermissionActions
Retrieves permission actions based on specified criteria, context, and options. This function constructs a URL for fetching permission actions from a service, applies criteria for filtering, and includes control options such as pagination settings. It then performs a GET request to the constructed URL.
| Parameter | Required | Type | Description |
|---|---|---|---|
| criteria | Yes | Object | Criteria for filtering permission actions, such as service names or resource types. |
| This criteria is used to build the query parameters for the request URL. | |||
| ctx | No | Ctx | Optional context object that may include authentication token information and other context-specific data. |
| This context is used to determine if session storage should be skipped when making the fetch request. | |||
| options | No | Options | Optional additional options for the request, such as pagination settings. |
| "_offset" specifies the start index for pagination, with a default value of 0 if not provided. | |||
| "_pageSize" specifies the number of items per page, with a default value of 10 if not provided. | |||
| These options are used to modify the request URL with appropriate query parameters. |
Promise<Array<PermissionActions>> - A promise that resolves to an array of permission actions matching the criteria. Each permission action includes an array of actions (e.g., READ, CREATE, EDIT, DELETE), the service identifier (_svc), and the resource identifier (_resource).
// Retrieve permission actions for 'itemsvc' service with pagination options
const criteria = { _svc: "itemsvc" };
const options = { _pageSize: 5, _offset: 0 };
const ctx = { authToken: "your_auth_token_here" };
IafPassSvc.getPermissionActions(criteria, ctx, options)
.then(permissionActions => console.log(permissionActions))
.catch(error => console.error(error));
getPermissionById
Gets Permission class objects for Passport Service resources when you pass the Permission's id.
| Parameter | Required | Type | Description |
|---|---|---|---|
| permissionId | Yes | String | Pass the Permission's id. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
Promise<Permission> - A promise with the Permission object
let permissionId = "75b2a3d6-a3e8-498d-99dc-23538bc9a389";
IafPassSvc.getPermissionById(permissionId);
getPermissionProfile
Gets a PermissionProfile by its id
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | PermissionProfile id |
| ctx | Yes | Ctx | Context, such as namespaces and authentication token information |
Promise<PermissionProfile> - A promise with the PermissionProfile; 404 response if not found
const permProfile = await getPermissionProfile(id, ctx);
getPermissionProfiles
Gets PermissionProfile class objects by criteria and sorted by _name, _userType and _namespaces
| Parameter | Required | Type | Description |
|---|---|---|---|
| criteria | Yes | PermissionProfileCriteria | Pass a JSON object with a Workspace object property, such as "_id" or "_namespaces" or "_name", and enter the value or array of values that you want to filter. |
| ctx | Yes | Ctx | Context, such as namespaces and authentication token information |
| options | Yes | Options | optional parameters such as _offset and _pageSize. By default 0 and 10 respectively |
Promise<Page<PermissionProfile>> - A promise for a Page of created PermissionProfile objects
const criteria = { _name: 'perm-profile' };
const res2 = await IafPassSvc.getPermissionProfiles(criteria, ctx);
const criteria = { _name: 'perm-profile' };
const options = { _pageSize: 25, _offset: 0 };
const res2 = await IafPassSvc.getPermissionProfiles(criteria, ctx, options);
getPermissions
Gets Permission class objects for Passport Service resources.
| Parameter | Required | Type | Description |
|---|---|---|---|
| criteria | No | PermissionCriteria | Pass a PermissionCriteria object with your filter criteria. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
| options | No | Options | Pass a a JSON object with one or more Page object parameters, such as "_offset" or "_pageSize". The default value for offset is 0 and for page size is 10. |
Page<Permission> - A Page object with the Permission object you want
let criteria = { _namespace: "ProjA_HEpftR8X" };
let options = { _pageSize: 20 };
const perms = await IafPassSvc.getPermissions(criteria, ctx, options);
getPrincipalInfo
Gets the current User's principal info.
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | No | Ctx | Context, such as namespaces and authentication token information |
| options | No | Options | Pass an Options object with your offset and page size options. |
PrincipalInfo - Returns a PrincipalInfo object with user information, such as email, first and last name, and user id
const userInfo = await IafPassSvc.getPrincipalInfo(ctx);
getUserById
Gets a User class object when you pass its id.
| Parameter | Required | Type | Description |
|---|---|---|---|
| userId | Yes | String | Pass the User object's id. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
Promise<User> - A promise with the User object
const user = await IafPassSvc.getUserById(id);
getUserGroup
Gets a UserGroup class object by id.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | Pass the UserGroup's id. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
Promise<UserGroup> - A promise with the UserGroup object
const userGroup = await IafPassSvc.getUserGroup(id);
getUserGroupInvite
Gets the details of a sent user group Invite object.
| Parameter | Required | Type | Description |
|---|---|---|---|
| groupId | Yes | String | The UserGroup's UUID |
| inviteId | Yes | String | The Invite's UUID |
| ctx | No | Ctx | Context, such as namespaces and authentication token information |
Invite - The Invite object
const invite = await IafPassSvc.getUserGroupInvite(groupId, inviteId);
getUserGroupInvites
Gets a user group's sent member Invites.
| Parameter | Required | Type | Description |
|---|---|---|---|
| userGroupId | Yes | String | Pass the UserGroup's id. |
| criteria | Yes | InviteCriteria | Filter the invites by the following statuses: PENDING, EXPIRED, ACCEPTED, CANCELLED, REJECTED. |
| ctx | Yes | Ctx | Context, such as namespaces and authentication token information |
| options | Yes | InviteOptions | Pass an InviteOptions object with your pagination options. |
Promise<Page<Invite>> - A promise with a page of Invite objects
const criteria = { _status: ["PENDING"] };
const options = { _pageSize: 30 };
const invites = await IafPassSvc.getUserGroupInvites(userGroup._id, criteria);
getUsergroupPermissions
Get permissions for usergroup
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | Pass the UserGroup's id. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
| options | No | JSON | Options |
Promise<Page<Permission>> - A promise with a Page object that contains the User objects you want
const permissions = await IafPassSvc.getUsergroupPermissions(id);
getUserGroups
Retrieve all the UserGroup objects that the user is a member of by default. Use includeAll as true to retrieve both the user groups of which the user is a part and those for which the user has 'READ' access.
| Parameter | Required | Type | Description |
|---|---|---|---|
| criteria | Yes | UserGroupCriteria | Pass a UserGroup object with the properties and values you define. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
| options | No | Options | Pass one or more Page object parameters, such as "_offset" and "_pageSize", as a JSON object. The default value for offset is 0 and for page size is 10. |
Promise<Page<UserGroup>> - A promise with a Page object that contains the UserGroup objects that match your criteria
// Get user groups by criteria
let criteria = { _id: [...ids], _userType: "project" };
let res = await IafPassSvc.getUserGroups(criteria, ctx);
// Get user groups with options
let criteria = { _userType: [ "project", "user_group" ] };
let options = { _pageSize: 25, _offset: 0 };
let res = await IafPassSvc.getUserGroups(criteria, ctx, options);
// Retrieve both usergroups which user is part of and user has 'READ' access
let criteria = {};
let options = { includeAll: true };
let res2 = await IafPassSvc.getUserGroups(criteria, ctx, options);
// Get user groups by partial search
let criteria = { query: "project" };
let res3 = await IafPassSvc.getUserGroups(criteria, ctx, options);
getUserInvites
Get the current user's invites.
| Parameter | Required | Type | Description |
|---|---|---|---|
| criteria | Yes | InviteCriteria | Filter the invites by the following statuses: PENDING, EXPIRED, ACCEPTED, CANCELLED, REJECTED. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
| options | Yes | InviteOptions | Pass an InviteOptions object with your pagination options. |
Promise<Array<Invite>> - A promise with an array of Invite class objects for the user
let criteria = {_status: ["PENDING"]};
let options = {_pageSize: 30};
const invites = await IafPassSvc.getUserInvites(criteria, ctx);
getUsersInGroup
Gets a UserGroup's users.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | Pass the UserGroup's id. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
| options | No | JSON | Pass one or more Page object parameters, such as "_offset" and "_pageSize", as a JSON object. The default value for offset is 0 and for page size is 10. |
Promise<Page<User>> - A promise with a Page object that contains the User objects you want
const users = await IafPassSvc.getUsersInGroup(id);
getWorkspace
Gets a Workspace class object when you pass its id.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | Pass the Workspace object's id. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
Promise<Workpace> - The Workspace object you want. If the workspace method does not find the workspace, a 404 response returns.
const workspace = await IafPassSvc.getWorkspace(id, ctx);
getWorkspaces
Gets Workspace class objects that match your criteria and sorts by name for the logged in user.
| Parameter | Required | Type | Description |
|---|---|---|---|
| criteria | Yes | WorkspaceCriteria | Pass a JSON object with a Workspace object property, such as "_id" or "_namespaces", and enter the value or array of values that you want to filter. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
| options | No | Options | Pass a a JSON object with one or more Page object parameters, such as "_offset" or "_pageSize". The default value for offset is 0 and for page size is 10. |
Promise<Page<Workspace>> - A Page object with the Workspace objects that match your criteria
// Get workspaces by criteria
const criteria = { _id: [...ids], _userType: "project" };
const res1 = await IafPassSvc.getWorkspaces(criteria, ctx);
// Get workspaces with options
const criteria = { _userType: ["project", "user_group"] };
const options = { _pageSize: 25, _offset: 0 };
const res2 = await IafPassSvc.getWorkspaces(criteria, ctx, options);
// Get workspaces by partial search
const criteria = { query: "project" };
const res3 = await IafPassSvc.getWorkspaces(criteria, ctx, options);
hardDeleteUserGroup
Hard deletes a UserGroup.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | Pass the UserGroup's id. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
String - ok: 204 response
const response = await IafPassSvc.hardDeleteUserGroup(id);
hardDeleteWorkspace
Permanently deletes a Workspace class object.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | Pass the Workspace's id. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
Promise<String> - {ok:204} response
IafPassSvc.hardDeleteWorkspace(workspace._id);
inviteUsersToGroup
Sends invite links to users to join a user group. To use this method, the current user should have edit permissions for the group. You can send a maximum of 25 invites at a time.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The user group's id |
| invites | Yes | Array<Invite> | Pass an array of Invite object with your invite details. |
| ctx | Yes | Ctx | Context, such as namespaces and authentication token information |
Array<Invite> - The array of sent invites
let invites = [{_email: "user1@mail.com"}, {_email: "user2@mail.com"}, {_email: "user3@mail.com"}];
const invites = await IafPassSvc.inviteUsersToGroup(id, invites);
logout
Logs out the current user and invalidates the Auth token.
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
IafPassSvc.logout(ctx);
partialUpdateApplicationConfigs
Updates the applicationConfigs by applicationId (appId)
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | |
| applicationConfigs | Yes | ApplicationConfigs | |
| ctx | Yes | Ctx |
Promise<ApplicationConfigs> - Returns the Application config by application Id
const applicationConfigs = await partialUpdateApplicationConfigs(id, applicationConfigs, ctx);
* applicationConfigs = {
"usergroups.limit": "5",
}
partialUpdateOrganizationConfigs
Updates the organizationConfigs by OrganizationId
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | |
| organizationConfigs | Yes | OrganizationConfigs | |
| ctx | Yes | Ctx |
Promise<OrganizationConfigs> - Returns the Organization config by Organization Id
const organizationConfigs = await partialUpdateOrganizationConfigs(id, organizationConfigs, ctx);
applicationConfigs = {
"applications.limit": "5",
}
PlatformRoles
Platform role and respective usertype which is used identify the usergroup.
updateApplication
Updates an Application's information, such as its name, description, app owner, and namespaces.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The Application's id |
| app | Yes | Application | Pass an Application object with your updates. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information |
Promise<Application> - The updated Application object
app._appOwner = user._id;
const updateApp = await IafPassSvc.updateApplication(id, app);
updateApplicationConfigs
Creates or Updates (replaces) the applicationConfigs by applicationId (appId)
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | |
| applicationConfigs | Yes | ApplicationConfigs | |
| ctx | Yes | Ctx |
Promise<ApplicationConfigs> - Returns the Application config by application Id
const applicationConfigs = await updateApplicationConfigs(id, applicationConfigs, ctx);
applicationConfigs = {
"usergroups.limit": "5",
"workspaces.limit": "3"
}
updateNotificationTemplate
Updates a NotificationTemplate class object.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The NotificationTemplate's UUID |
| notificationTemplate | Yes | NotificationTemplate | Pass a NotificationTemplate object with your updates. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information |
Promise<Workspace> - A promise with the updated NotificationTemplate object
notificationTemplate._message = "Click the following link to join the application. If you received this message by mistake, please conntact your administator";
IafPassSvc.updateNotificationTemplate(id, notificationTemplate);
updateOrganization
Updates an existing organization.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | Pass the organization's id. |
| organization | Yes | Organization | Pass a Organization JSON object with the properties and values you want to update. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
Promise<Organization> - A promise with the updated Organization object
let id = "4e2b9de5-9a73-44f9-8153-bc0904b694c5";
let organization = {
"_description": "Organization A new description",
"_name": "Organization A new name"
},
IafPassSvc.updateOrganization(id, organization);
updateOrganizationConfigs
Creates or Updates (replaces) the OrganizationConfigs by orgId
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | |
| organizationConfigs | Yes | OrganizationConfigs | |
| ctx | Yes | Ctx |
Promise<OrganizationConfigs> - Returns the Organization configs by Organization Id
const organizationConfigs = await updateOrganizationConfigs(id, organizationConfigs, ctx);
organizationConfigs = {
"applications.limit": "5",
"workspaces.limit": "3"
}
updatePermissionProfile
Updates a PermissionProfile class object
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | PermissionProfile id |
| permissionProfile | Yes | PermissionProfile | The updated PermissionProfile object |
| ctx | Yes | Ctx | Context, such as namespaces and authentication token information |
Promise<PermissionProfile> - The updated PermissionProfile
permProfile._namespaces = project._namespaces;
const updatedPermProf = await updatePermissionProfile(id, permProfile, ctx);
updatePermissions
Updates multiple permissions for passport service resources. If a Permission object you pass doesn't exist, the method creates it. The method uses the "_resourceDesc", "_namespace", and "_user" fields to identify if a permission exists.
| Parameter | Required | Type | Description |
|---|---|---|---|
| permissions | Yes | Array<Permission> | Pass an array of the Permission objects with your updates. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
| options | No | Options | Pass a a JSON object with one or more Page object parameters, such as "_offset" or "_pageSize". The default value for offset is 0 and for page size is 10. |
CreatePermissionsResponse - A CreatePermissionsResponse object with with separate arrays of the successful and failed permissions
let permissions = [
{
_actions: [
IafPermission.PermConst.Action.Read,
IafPermission.PermConst.Action.Share,
IafPermission.PermConst.Action.Delete
],
_namespace: "ProjA_HEpftR8X",
_resourceDesc: {
_irn: IafPermission.NamedUserItemIrnAll
},
_user: {
_id: "75b2a3d6-a3e8-498d-99dc-23538bc9a389", // Either user or usergroup id, specify respective _type
_type: IafPermission.PermConst.UserType.User // Either user or usergroup, specify respective _id
}
},
{
_actions: [
IafPermission.PermConst.Action.SHARE,
],
_namespace: "ProjB_SDprfS4R",
_resourceDesc:{
_irn: IafPermission.NamedUserItemIrnAll
},
_user :{
_id: "75b2a3d6-a3e8-498d-99dc-23538bc9a389", // Either user or usergroup id, specify respective _type
_type": IafPermission.PermConst.UserType.User // Either user or usergroup, specify respective _id
}
}
];
const updatedPerms = await IafPassSvc.updatePermissions(permissions);
updateUser
Updates a User class object. Users can update their own data but not another's.
| Parameter | Required | Type | Description |
|---|---|---|---|
| user | Yes | User | Pass a User object with the properties and values you want to update. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
Promise<User> - The updated User object
user._email = "updated_email@mail.com"
const updatedUser = await IafPassSvc.updateUser(user);
updateUserGroup
Updates a UserGroup class object.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The UserGroup's id |
| userGroup | Yes | UserGroup | Pass a defined UserGroup object with the properties and values you want to update |
| ctx | Yes | Ctx | Context, such as namespaces and authentication token information |
Promise<UserGroup> - The updated UserGroup object
userGroup._name = "new user group name";
const updated userGroup = await IafPassSvc.updateUserGroup(id, userGroup);
updateUserGroupInvite
Updates a user group Invite, such as the Invite's status of PENDING, EXPIRED, ACCEPTED, CANCELLED, or REJECTED.
| Parameter | Required | Type | Description |
|---|---|---|---|
| userGroupId | Yes | String | The UserGroup's id |
| inviteId | Yes | String | The Invite's id |
| invite | Yes | Invite | Pass an Invite object with your updates. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information |
Promise<String> - {ok:204} response
let invite = [{ _status: "REJECTED" }];
const response = await IafPassSvc.updateUserGroupInvite(userGroup._id, invite._id, invite);
updateWorkspace
Updates an existing Workspace class object.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | Pass the Workspace's id. |
| workspace | Yes | Workspace | Pass a Workspace JSON object with the properties and values you want to update. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
Promise<Workspace> - A promise with the updated Workspace object
const workspace = {
_description: "Project A workspace new description",
_name: "Project A new name",
_shortName: "Proj_A_new",
_userType: "project_workspace"
};
const updatedWorkspace = await IafPassSvc.updateWorkspace(id, workspace);
upsertPermissionActions
Creates or updates permission actions by sending permission action objects to the server. This operation, often referred to as "upsert", either inserts new permission actions if they do not already exist, or updates them if they do. The decision to create or update is typically based on the uniqueness of the permission action combination of service identifier (_svc) and resource identifier (_resource).
| Parameter | Required | Type | Description |
|---|---|---|---|
| permissionActions | Yes | undefined | |
| ctx | No | Ctx | Optional context object that may include namespaces, authentication token information, and other context-specific data. |
| This context is utilized for authentication and authorization purposes, ensuring that the request is performed within the correct security context. | |||
| options | No | Options | Pass a a JSON object with one or more Page object parameters, such as "_offset" or "_pageSize". The default value for offset is 0 and for page size is 10. |
// Example of upserting permission actions for a 'nameduseritem' resource in the 'itemsvc' service
const permissionActions = {
"_svc": "itemsvc",
"_resource": "nameduseritem",
"_actions": ["READ", "CREATE", "EDIT", "DELETE"]
};
IafPassSvc.upsertPermissionActions(permissionActions, ctx)
.then(updatedActions => console.log('Upsert successful', updatedActions))
.catch(error => console.error('Upsert failed', error));
Authorization: Only Trusted clients can make this API