@itwin/access-control-client 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +15 -0
  3. package/lib/cjs/AccessControlClient.d.ts +10 -0
  4. package/lib/cjs/AccessControlClient.d.ts.map +1 -0
  5. package/lib/cjs/AccessControlClient.js +15 -0
  6. package/lib/cjs/AccessControlClient.js.map +1 -0
  7. package/lib/cjs/access-control-client.d.ts +3 -0
  8. package/lib/cjs/access-control-client.d.ts.map +1 -0
  9. package/lib/cjs/access-control-client.js +19 -0
  10. package/lib/cjs/access-control-client.js.map +1 -0
  11. package/lib/cjs/accessControlTypes.d.ts +80 -0
  12. package/lib/cjs/accessControlTypes.d.ts.map +1 -0
  13. package/lib/cjs/accessControlTypes.js +10 -0
  14. package/lib/cjs/accessControlTypes.js.map +1 -0
  15. package/lib/cjs/subClients/BaseClient.d.ts +30 -0
  16. package/lib/cjs/subClients/BaseClient.d.ts.map +1 -0
  17. package/lib/cjs/subClients/BaseClient.js +78 -0
  18. package/lib/cjs/subClients/BaseClient.js.map +1 -0
  19. package/lib/cjs/subClients/MembersClient.d.ts +44 -0
  20. package/lib/cjs/subClients/MembersClient.d.ts.map +1 -0
  21. package/lib/cjs/subClients/MembersClient.js +66 -0
  22. package/lib/cjs/subClients/MembersClient.js.map +1 -0
  23. package/lib/cjs/subClients/PermissionsClient.d.ts +20 -0
  24. package/lib/cjs/subClients/PermissionsClient.d.ts.map +1 -0
  25. package/lib/cjs/subClients/PermissionsClient.js +25 -0
  26. package/lib/cjs/subClients/PermissionsClient.js.map +1 -0
  27. package/lib/cjs/subClients/RolesClient.d.ts +43 -0
  28. package/lib/cjs/subClients/RolesClient.d.ts.map +1 -0
  29. package/lib/cjs/subClients/RolesClient.js +57 -0
  30. package/lib/cjs/subClients/RolesClient.js.map +1 -0
  31. package/lib/esm/AccessControlClient.d.ts +10 -0
  32. package/lib/esm/AccessControlClient.d.ts.map +1 -0
  33. package/lib/esm/AccessControlClient.js +11 -0
  34. package/lib/esm/AccessControlClient.js.map +1 -0
  35. package/lib/esm/access-control-client.d.ts +3 -0
  36. package/lib/esm/access-control-client.d.ts.map +1 -0
  37. package/lib/esm/access-control-client.js +7 -0
  38. package/lib/esm/access-control-client.js.map +1 -0
  39. package/lib/esm/accessControlTypes.d.ts +80 -0
  40. package/lib/esm/accessControlTypes.d.ts.map +1 -0
  41. package/lib/esm/accessControlTypes.js +9 -0
  42. package/lib/esm/accessControlTypes.js.map +1 -0
  43. package/lib/esm/subClients/BaseClient.d.ts +30 -0
  44. package/lib/esm/subClients/BaseClient.d.ts.map +1 -0
  45. package/lib/esm/subClients/BaseClient.js +74 -0
  46. package/lib/esm/subClients/BaseClient.js.map +1 -0
  47. package/lib/esm/subClients/MembersClient.d.ts +44 -0
  48. package/lib/esm/subClients/MembersClient.d.ts.map +1 -0
  49. package/lib/esm/subClients/MembersClient.js +62 -0
  50. package/lib/esm/subClients/MembersClient.js.map +1 -0
  51. package/lib/esm/subClients/PermissionsClient.d.ts +20 -0
  52. package/lib/esm/subClients/PermissionsClient.d.ts.map +1 -0
  53. package/lib/esm/subClients/PermissionsClient.js +21 -0
  54. package/lib/esm/subClients/PermissionsClient.js.map +1 -0
  55. package/lib/esm/subClients/RolesClient.d.ts +43 -0
  56. package/lib/esm/subClients/RolesClient.d.ts.map +1 -0
  57. package/lib/esm/subClients/RolesClient.js +53 -0
  58. package/lib/esm/subClients/RolesClient.js.map +1 -0
  59. package/package.json +69 -0
@@ -0,0 +1,53 @@
1
+ import { BaseClient } from "./BaseClient";
2
+ export class RolesClient extends BaseClient {
3
+ /** Retrieves a list of available user roles that are defined for a specified iTwin
4
+ * @param accessToken The client access token string
5
+ * @param iTwinId The id of the iTwin
6
+ * @returns Roles
7
+ */
8
+ async getITwinRolesAsync(accessToken, iTwinId) {
9
+ const url = `${this._baseUrl}/${iTwinId}/roles`;
10
+ return this.sendGenericAPIRequest(accessToken, "GET", url, undefined, "roles");
11
+ }
12
+ /** Retrieves the specified role for the specified iTwin
13
+ * @param accessToken The client access token string
14
+ * @param iTwinId The id of the iTwin
15
+ * @returns Role
16
+ */
17
+ async getITwinRoleAsync(accessToken, iTwinId, roleId) {
18
+ const url = `${this._baseUrl}/${iTwinId}/roles/${roleId}`;
19
+ return this.sendGenericAPIRequest(accessToken, "GET", url);
20
+ }
21
+ /** Creates a new iTwin Role
22
+ * @param accessToken The client access token string
23
+ * @param iTwinId The id of the iTwin
24
+ * @param role The role to be created
25
+ * @returns Role
26
+ */
27
+ async createITwinRoleAsync(accessToken, iTwinId, role) {
28
+ const url = `${this._baseUrl}/${iTwinId}/roles`;
29
+ return this.sendGenericAPIRequest(accessToken, "POST", url, role, "role");
30
+ }
31
+ /** Delete the specified iTwin role
32
+ * @param accessToken The client access token string
33
+ * @param iTwinId The id of the iTwin
34
+ * @param roleId The id of the role to remove
35
+ * @returns No Content
36
+ */
37
+ async deleteITwinRoleAsync(accessToken, iTwinId, roleId) {
38
+ const url = `${this._baseUrl}/${iTwinId}/roles/${roleId}`;
39
+ return this.sendGenericAPIRequest(accessToken, "DELETE", url);
40
+ }
41
+ /** Update the specified iTwin role
42
+ * @param accessToken The client access token string
43
+ * @param iTwinId The id of the iTwin
44
+ * @param roleId The id of the role to update
45
+ * @param role The updated role
46
+ * @returns Role
47
+ */
48
+ async updateITwinRoleAsync(accessToken, iTwinId, roleId, role) {
49
+ const url = `${this._baseUrl}/${iTwinId}/roles/${roleId}`;
50
+ return this.sendGenericAPIRequest(accessToken, "PATCH", url, role, "role");
51
+ }
52
+ }
53
+ //# sourceMappingURL=RolesClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RolesClient.js","sourceRoot":"","sources":["../../../src/subClients/RolesClient.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,OAAO,WAAY,SAAQ,UAAU;IACzC;;;;Q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,qBAAqB,CAAC,WAAW,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAC7E,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module AccessControlClient\r\n */\r\nimport type { AccessToken } from \"@itwin/core-bentley\";\r\nimport type { AccessControlAPIResponse, IRolesClient, NewRole, Role } from \"../accessControlTypes\";\r\nimport { BaseClient } from \"./BaseClient\";\r\n\r\nexport class RolesClient extends BaseClient implements IRolesClient{\r\n /** Retrieves a list of available user roles that are defined for a specified iTwin\r\n * @param accessToken The client access token string\r\n * @param iTwinId The id of the iTwin\r\n * @returns Roles\r\n */\r\n public async getITwinRolesAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n ): Promise<AccessControlAPIResponse<Role[]>>{\r\n const url = `${this._baseUrl}/${iTwinId}/roles`;\r\n return this.sendGenericAPIRequest(accessToken, \"GET\", url, undefined, \"roles\");\r\n }\r\n\r\n /** Retrieves the specified role for the specified iTwin\r\n * @param accessToken The client access token string\r\n * @param iTwinId The id of the iTwin\r\n * @returns Role\r\n */\r\n public async getITwinRoleAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n roleId: string,\r\n ): Promise<AccessControlAPIResponse<Role>>{\r\n const url = `${this._baseUrl}/${iTwinId}/roles/${roleId}`;\r\n return this.sendGenericAPIRequest(accessToken, \"GET\", url);\r\n }\r\n\r\n /** Creates a new iTwin Role\r\n * @param accessToken The client access token string\r\n * @param iTwinId The id of the iTwin\r\n * @param role The role to be created\r\n * @returns Role\r\n */\r\n public async createITwinRoleAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n role: NewRole\r\n ): Promise<AccessControlAPIResponse<Role>>{\r\n const url = `${this._baseUrl}/${iTwinId}/roles`;\r\n return this.sendGenericAPIRequest(accessToken, \"POST\", url, role, \"role\");\r\n }\r\n\r\n /** Delete the specified iTwin role\r\n * @param accessToken The client access token string\r\n * @param iTwinId The id of the iTwin\r\n * @param roleId The id of the role to remove\r\n * @returns No Content\r\n */\r\n public async deleteITwinRoleAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n roleId: string,\r\n ): Promise<AccessControlAPIResponse<undefined>>{\r\n const url = `${this._baseUrl}/${iTwinId}/roles/${roleId}`;\r\n return this.sendGenericAPIRequest(accessToken, \"DELETE\", url);\r\n }\r\n\r\n /** Update the specified iTwin role\r\n * @param accessToken The client access token string\r\n * @param iTwinId The id of the iTwin\r\n * @param roleId The id of the role to update\r\n * @param role The updated role\r\n * @returns Role\r\n */\r\n public async updateITwinRoleAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n roleId: string,\r\n role: NewRole\r\n ): Promise<AccessControlAPIResponse<Role>>{\r\n const url = `${this._baseUrl}/${iTwinId}/roles/${roleId}`;\r\n return this.sendGenericAPIRequest(accessToken, \"PATCH\", url, role, \"role\");\r\n }\r\n}\r\n"]}
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@itwin/access-control-client",
3
+ "version": "0.1.0",
4
+ "description": "Access control client for the iTwin platform",
5
+ "main": "lib/cjs/access-control-client.js",
6
+ "module": "lib/esm/access-control-client.js",
7
+ "typings": "lib/cjs/access-control-client",
8
+ "scripts": {
9
+ "build": "npm run -s build:cjs && npm run -s build:esm",
10
+ "build:cjs": "tsc 1>&2 --outDir lib/cjs",
11
+ "build:esm": "tsc 1>&2 --module ES2020 --outDir lib/esm",
12
+ "clean": "rimraf lib",
13
+ "lint": "eslint -f visualstudio \"./src/**/*.ts\" 1>&2",
14
+ "lint:fix": "npm run lint -- --fix",
15
+ "webpackTests": "webpack --config ./src/test/utils/webpack.config.js 1>&2",
16
+ "test": "npm run -s webpackTests && npm run -s test:chrome",
17
+ "test:chrome": "certa -r chrome",
18
+ "test:electron": "certa -r electron",
19
+ "pack": "npm pack"
20
+ },
21
+ "dependencies": {
22
+ "axios": "^0.27.2"
23
+ },
24
+ "devDependencies": {
25
+ "@itwin/build-tools": "^3.0.0",
26
+ "@itwin/certa": "^3.0.0",
27
+ "@itwin/core-bentley": "^3.0.0",
28
+ "@itwin/eslint-plugin": "^3.0.0",
29
+ "@itwin/oidc-signin-tool": "^3.2.0",
30
+ "@types/chai": "^4.1.4",
31
+ "@types/jest": "^28.1.6",
32
+ "@types/mocha": "^8.2.2",
33
+ "@types/node": "14.14.31",
34
+ "chai": "^4.1.2",
35
+ "dotenv": "^10.0.0",
36
+ "dotenv-expand": "^5.1.0",
37
+ "eslint": "^7.11.0",
38
+ "mocha": "^8.3.2",
39
+ "rimraf": "^3.0.2",
40
+ "source-map-loader": "^1.0.0",
41
+ "typescript": "~4.4.0",
42
+ "webpack": "4.42.0",
43
+ "webpack-cli": "^4.9.0"
44
+ },
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "https://github.com/iTwin/access-control-client"
48
+ },
49
+ "author": {
50
+ "name": "Bentley Systems, Inc",
51
+ "url": "http://www.bentley.com"
52
+ },
53
+ "license": "MIT",
54
+ "keywords": [
55
+ "Bentley",
56
+ "iTwin",
57
+ "access-control"
58
+ ],
59
+ "eslintConfig": {
60
+ "plugins": [
61
+ "@itwin"
62
+ ],
63
+ "extends": "plugin:@itwin/itwinjs-recommended",
64
+ "rules": {
65
+ "no-duplicate-imports": "off",
66
+ "@typescript-eslint/consistent-type-imports": "error"
67
+ }
68
+ }
69
+ }