export = AccessControl; /** * @license Apache Version 2 * @module AccessControl * @constructor AccessControl * @description The AccessControl is a driver to work with * TerminusDB and TerminusX access control api * for the credential you can use the JWT token, the API token or * the basic authentication with username and password * @example * //connect with the API token * //(to request a token create an account in https://terminusdb.com/) * const accessContol = new AccessControl("https://servername.com", * {organization:"my_team_name", * token:"dGVybWludXNkYjovLy9kYXRhL2tleXNfYXB........"}) * accessControl.getOrgUsers().then(result=>{ * console.log(result) * }) * * //connect with the jwt token this type of connection is only for the dashboard * //or for application integrate with our login workflow * const accessContol = new AccessControl("https://servername.com", * {organization:"my_team_name", * jwt:"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IkpXUjBIOXYyeTFORUd........"}) * accessControl.getOrgUsers().then(result=>{ * console.log(result) * }) * * //if the jwt is expired you can change it with * accessControl.setJwtToken("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IkpXUjBIOXYy * eTFORUd.......") * * //connect with the base authentication this type of connection is only for the local installation * const accessContol = new AccessControl("http://127.0.0.1:6363", * {organization:"my_team_name", user:"admin" * key:"mykey"}) * accessControl.getOrgUsers().then(result=>{ * console.log(result) * }) * */ declare function AccessControl(cloudAPIUrl: any, params: any): void; declare class AccessControl { /** * @license Apache Version 2 * @module AccessControl * @constructor AccessControl * @description The AccessControl is a driver to work with * TerminusDB and TerminusX access control api * for the credential you can use the JWT token, the API token or * the basic authentication with username and password * @example * //connect with the API token * //(to request a token create an account in https://terminusdb.com/) * const accessContol = new AccessControl("https://servername.com", * {organization:"my_team_name", * token:"dGVybWludXNkYjovLy9kYXRhL2tleXNfYXB........"}) * accessControl.getOrgUsers().then(result=>{ * console.log(result) * }) * * //connect with the jwt token this type of connection is only for the dashboard * //or for application integrate with our login workflow * const accessContol = new AccessControl("https://servername.com", * {organization:"my_team_name", * jwt:"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IkpXUjBIOXYyeTFORUd........"}) * accessControl.getOrgUsers().then(result=>{ * console.log(result) * }) * * //if the jwt is expired you can change it with * accessControl.setJwtToken("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IkpXUjBIOXYy * eTFORUd.......") * * //connect with the base authentication this type of connection is only for the local installation * const accessContol = new AccessControl("http://127.0.0.1:6363", * {organization:"my_team_name", user:"admin" * key:"mykey"}) * accessControl.getOrgUsers().then(result=>{ * console.log(result) * }) * */ constructor(cloudAPIUrl: any, params: any); baseURL: string; user: any; defaultOrganization: string; /** * Get a organization from parameters. * @param {object} params - The parameters * @return {string|undefined} - organization */ getDefaultOrganization(params: object): string | undefined; /** * Sets the Jwt token for the object * @param {string} jwt - The jwt api token to use */ setJwtToken(jwt: string): void; apiKey: any; apiType: string; /** * Sets the API token for the object, to request a token create an account in https://terminusdb.com/ * @param {string} atokenpi - The API token to use to connect with TerminusX */ setApiToken(token: any): void; /** * Sets the API token for the object, to request a token create an account in https://terminusdb.com/ * @param {string} atokenpi - The API token to use to connect with TerminusX */ setApiKey(key: any): void; /** * Get a API url from cloudAPIUrl * @param {string} cloudAPIUrl - The base url for cloud * @return {string} apiUrl */ getAPIUrl(cloudAPIUrl: string): string; dispatch(requestUrl: any, action: any, payload: any): Promise; /** * add extra headers to your request * @param {object} customHeaders * @returns {object} */ customHeaders(customHeaders: object): object; _customHeaders: any; /** * -- TerminusDB API --- * Get an organization from the TerminusDB API. * @param {string} organization - The organization * @return {object} - organization */ getOrganization(org: any): object; /** * -- TerminusDB API --- * This end point works in basic authentication, admin user * Get list of organizations * @return {Promise} A promise that returns the call response object, or an Error if rejected. */ getAllOrganizations(): Promise; /** * -- TerminusDB API --- * This end point works in basic authentication, admin user * Create an organization * @param {string} orgName - The organization name to create * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * accessControl.createOrganization("my_org_name").then(result=>{ * console.log(result) * }) */ createOrganization(orgName: string): Promise; /** * -- TerminusDB API --- * Delete an Organization * @param {string} orgName - The organization name to delete * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * accessControl.deleteOrganization("my_org_name").then(result=>{ * console.log(result) * }) */ deleteOrganization(orgName: string): Promise; /** * --TerminusDB API --- * basic authentication, admin user. * Create a new role in the system database. * @param {string} [name] - The role name. * @param {typedef.RolesActions} [actions] - A list of actions * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * accessControl.createRole("Reader",[ACTIONS.INSTANCE_READ_ACCESS]).then(result=>{ * console.log(result) * }) * */ createRole(name?: string, actions?: typedef.RolesActions): Promise; /** * -- TerminusdDB API --- * basic Authentication, admin user. * Delete role in the system database, (this api is enabled only in the local installation) * @param {string} [name] - The role name. * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * accessControl.deleteRole("Reader").then(result=>{ * console.log(result) * }) * */ deleteRole(name?: string): Promise; /** * -- TerminusdDB API --- * basic Authentication, admin user. * Return the list of all the users (this api is enabled only in the local installation) * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * accessControl.getAllUsers().then(result=>{ * console.log(result) * }) * */ getAllUsers(): Promise; /** * -- TerminusdDB API --- * basic Authentication, admin user. * Add the user into the system database * @param {string} name - the user name * @param {string} [password] - you need the password for basic authentication * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * accessControl.deleteUser(userId).then(result=>{ * console.log(result) * }) * */ createUser(name: string, password?: string): Promise; /** * -- TerminusdDB API --- * basic Authentication, admin user. * Remove the user from the system database. * @param {string} userId - the document user id * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * accessControl.deleteUser(userId).then(result=>{ * console.log(result) * }) * */ deleteUser(userId: string): Promise; /** * -- TerminusdDB API --- * Grant/Revoke Capability * @param {string} userName - the document user id * @param {string} resourceName - the name of a (database or team) * @param {array} rolesArr - the roles name list * @param {typedef.CapabilityCommand} operation - grant/revoke operation * @param {typedef.ScopeType} [scopeType] - the resource type (database or organization) * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * //we add an user to an organization and manage users' access * //the user myUser can access the Organization and all the database under the organization with "reader" Role * client.manageCapability(myUser,myteam,[reader],"grant","organization").then(result=>{ * consol.log(result) * }) * * //the user myUser can access the database db__001 under the organization myteam * //with "writer" Role * client.manageCapability(myUser,myteam/db__001,[writer],"grant","database").then(result=>{ * consol.log(result) * }) */ manageCapability(userName: string, resourceName: string, rolesArr: any[], operation: typedef.CapabilityCommand, scopeType?: typedef.ScopeType): Promise; /** * --TerminusX and TerminusDB API --- * Get all the system database roles types. * @return {Promise} A promise that returns the call response object, or an Error if rejected. */ getAccessRoles(): Promise; /** * -- TerminusX and TerminusDB API -- * Get all the organization's users and roles, * @param {string} [orgName] - The organization name. * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * accessControl.getOrgUsers().then(result=>{ * console.log(result) * }) * * //this function will return an array of capabilities with users and roles * //-- TerminusX -- response array example * //[{capability: "Capability/3ea26e1d698821c570afe9cb4fe81a3......" * // email: {@type: "xsd:string", @value: "user@terminusdb.com"} * // picture: {@type: "xsd:string",…} * // role: "Role/dataReader" * // scope: "Organization/my_org_name" * // user: "User/auth0%7C613f5dnndjdjkTTT"}] * // * // * // -- Local Installation -- response array example * //[{ "@id":"User/auth0%7C615462f8ab33f4006a6bee0c", * // "capability": [{ * // "@id":"Capability/c52af34b71f6f8916ac0115ecb5fe0e31248ead8b1e3d100852015...", * // "@type":"Capability", * // "role": [{ * // "@id":"Role/admin", * // "@type":"Role", * // "action": ["instance_read_access"], * // "name":"Admin Role" * // }], * // "scope":"Organization/@team"}]] */ getOrgUsers(orgName?: string): Promise; /** * -- TerminusX and TerminusDB API -- * Get the user roles for a given organization or the default organization, * @param {string} [userName] - The organization name. * @param {string} [orgName] - The organization name. * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * accessControl.getTeamUserRole("myUser").then(result=>{ * console.log(result) * }) * * //response object example * { * "@id": "User/myUser", * "capability": [ * { * "@id":"Capability/server_access", * "@type":"Capability", * "role": [{ * "@id":"Role/reader", * "@type":"Role", * "action": [ * "instance_read_access", * ], * "name":"reader" * }], * "scope":"Organization/myteam" * } * ], * "name": "myUser" *} */ getTeamUserRoles(userName?: string, orgName?: string): Promise; /** * -- TerminusX API --- * Check if the organization exists. it is a Head call . * IMPORTANT This does not work with the API-TOKEN. * @param {string} orgName - The organization name to check if exists. * @return {Promise} A promise that returns the call status object, 200: if the organization * exists and 404: if the organization does not exist */ ifOrganizationExists(orgName: string): Promise; /** * -- TerminusX API --- * IMPORTANT This does not work with the API-TOKEN. * Create an organization * @param {string} orgName - The organization name to create * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * accessControl.createOrganization("my_org_name").then(result=>{ * console.log(result) * }) */ createOrganizationRemote(orgName: string): Promise; /** * -- TerminusX API --- * Send a new invitation * @param {string} userEmail - The email of user. * @param {string} role - The role for user. (the document @id role like Role/collaborator) * @param {string} [note] - The note to send with the invitation. * @param {string} [orgName] - The organization name. * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * accessControl.sendOrgInvite("new_user@terminusdb.com","Role/admin", * "please join myteam").then(result=>{ * console.log(result) * }) */ sendOrgInvite(userEmail: string, role: string, note?: string, orgName?: string): Promise; /** * -- TerminusX API --- * Get the invitation info * @param {string} inviteId - The invite id to retrieve. * @param {string} [orgName] - The organization name. * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * const fullInviteId="Organization/my_team_name/invitations/Invitation/7ad0c9eb82b6175bcda9c0dfc * 2ac51161ef5ba7cb0988d992c4bce82b3fa5d25" * accessControl.getOrgInvite(fullInviteId).then(result=>{ * console.log(result) * }) */ getOrgInvite(inviteId: string, orgName?: string): Promise; /** * -- TerminusX API --- * Delete an invitation * @param {string} inviteId - The invite id to delete. * @param {string} [orgName] - The organization name. * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * const fullInviteId="Organization/my_team_name/invitations/Invitation/7ad0c9eb82b6175bcda9 * c0dfc2ac51161ef5ba7cb0988d992c4bce82b3fa5d25" * accessControl.deleteOrgInvite(fullInviteId).then(result=>{ * console.log(result) * }) */ deleteOrgInvite(inviteId: string, orgName?: string): Promise; /** * -- TerminusX API --- * Accept /Reject invitation. if the invitation has been accepted we add the current user * to the organization. * * the only user that can accept this invitation is the user registered with the invitation email, * we indentify the user with the jwt token * @param {string} inviteId - The invite id to updated. * @param {boolean} accepted - The status of the invitation. * @param {string} [orgName] - The organization name. * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * const fullInviteId="Organization/my_team_name/invitations/Invitation/7ad0c9eb82b6175bcda9 * c0dfc2ac51161ef5ba7cb0988d992c4bce82b3fa5d25" * accessControl.updateOrgInviteStatus(fullInviteId,true).then(result=>{ * console.log(result) * }) */ updateOrgInviteStatus(inviteId: string, accepted: boolean, orgName?: string): Promise; /** * -- TerminusX API --- * Get the user role for a given organization or the default organization * The user is identified by the jwt or the access token * @param {string} [orgName] - The organization name. * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * accessControl.getTeamUserRole().then(result=>{ * console.log(result) * }) * * //response object example * {"userRole":"Role/admin"} */ getTeamUserRole(orgName?: string): Promise; /** * -- TerminusX API -- * Remove an user from an organization, only an admin user can remove an user from an organization * @param {string} userId - The id of the user to be removed. (this is the document user's @id) * @param {string} [orgName] - The organization name in which the user is to be removed. * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * accessControl.removeUserFromOrg("User/auth0%7C613f5dnndjdjkTTT","my_org_name").then(result=>{ * console.log(result) * }) * */ removeUserFromOrg(userId: string, orgName?: string): Promise; /** * -- TerminusX API -- * Get the user's role for every databases under the organization * @param {string} userId - The user's id. * @param {string} [orgName] - The organization name. * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * accessControl.getDatabaseRolesOfUser('User/auth0%7C61790e366377Yu6596a').then(result=>{ * console.log(result) * }) * * //this is a capabilities list of databases and roles * //[ {capability: "Capability/b395e8523d509dec6b33aefc9baed3b2e2bfadbd4c79d4ff9b20dce2b14e2edc" * //if there is an id we have a user specific capabality for this database * // name: {@type: "xsd:string", @value: "profiles_test"} * // role: "Role/dataUpdater" * // scope: "UserDatabase/7ebdfae5a02bc7e8f6d79sjjjsa4e179b1df9d4576a3b1d2e5ff3b4859" * // user: "User/auth0%7C61790e11a3966d006906596a"}, * * //{ capability: null * // if the capability id is null the user level of access for this database is the * same of the team * //name: {@type: "xsd:string", @value: "Collab002"} * //role: "Role/dataReader" * // scope: "UserDatabase/acfcc2db02b83792sssb15239ccdf586fc5b176846ffe4878b1aea6a36c8f" * //user: "User/auth0%7C61790e11a3966d006906596a"}] */ getDatabaseRolesOfUser(userId: string, orgName?: string): Promise; /** * -- TerminusX API -- * Create a user's a role for a resource (organization/database) * @param {string} userId - The user's id. * @param {string} scope - The resource name/id. * @param {string} role - The user role to be assigned. * @param {string} [orgName] - The organization name. * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * const dbId = "UserDatabase/acfcc2db02b83792sssb15239ccdf586fc5b176846ffe4878b1aea6a36c8f" * accessControl.assignUserRole('User/auth0%7C61790e11a3966d006906596a',dbId, * "Role/collaborator").then(result=>{ * console.log(result) * * }) */ createUserRole(userId: string, scope: string, role: string, orgName?: string): Promise; /** * -- TerminusX API -- * Update user's a role for a resource (organization/database), (this api works only in terminusX) * @param {string} userId - The user's id. * @param {string} capabilityId - The capability id. * @param {string} scope - The resource name/id. * @param {string} role - The user role to be updated. * @param {string} [orgName] - The organization name. * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * const dbId = "UserDatabase/acfcc2db02b83792sssb15239ccdf586fc5b176846ffe4878b1aea6a36c8f" * const capId= "Capability/b395e8523d509dec6b33aefc9baed3b2e2bfadbd4c79d4ff9b20dce2b14e2edc" * accessControl.updateUserRole('User/auth0%7C61790e11a3966d006906596a',capId,dbId, * "Role/dataUpdater").then(result=>{ * console.log(result) * * }) */ updateUserRole(userId: string, capabilityId: string, scope: string, role: string, orgName?: string): Promise; /** * -- TerminusX API -- * Get all the access request list for a specify organization * @param {string} [orgName] - The organization name. * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * accessControl.accessRequestsList().then(result=>{ * console.log(result) * }) * */ accessRequestsList(orgName?: string): Promise; /** * -- TerminusX API -- * Get all the access request list for a specify organization * @param {string} [email] - the user email. * @param {string} [affiliation] - the user affiliation, company, university etc.. * @param {string} [note] - the message for the team admin * @param {string} [orgName] - The organization name. * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * accessControl.sendAccessRequest("myemail@terminusdb.com", * "my_company", * "please add me to your team" * ).then(result=>{ * console.log(result) * }) * */ sendAccessRequest(email?: string, affiliation?: string, note?: string, orgName?: string): Promise; /** * -- TerminusX API -- * Delete an access request to join your team, only an admin user can delete it * @param {string} [orgName] - The organization name. * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * accessControl.deleteAccessRequest("djjdshhsuuwewueueuiHYHYYW.......").then(result=>{ * console.log(result) * }) * */ deleteAccessRequest(acceId: any, orgName?: string): Promise; /** * -- TerminusX API -- * Get the userinfo teams ownership and subscription * @param {string} [orgName] - The organization name. * @return {Promise} A promise that returns the call response object, or an Error if rejected. * @example * accessControl.getUserInfo().then(result=>{ * console.log(result) * }) * */ getUserInfo(userName: any): Promise; } import typedef = require("./typedef");