@fraym/auth 0.2.1 → 0.3.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.
package/README.md CHANGED
@@ -80,8 +80,10 @@ const roles = await managementClient.getRoles("TENANT_ID");
80
80
 
81
81
  ## Upsert a role
82
82
 
83
+ You can create roles without providing a role-id. The id of the new role will be returned:
84
+
83
85
  ```typescript
84
- await managementClient.upsertRole("TENANT_ID", "ROLE_ID", [
86
+ const roleId = await managementClient.upsertRole("TENANT_ID", [
85
87
  {
86
88
  scopeName: "PERMISSION_NAME",
87
89
  // optional: clientId: If none is given the default client will be used
@@ -89,6 +91,21 @@ await managementClient.upsertRole("TENANT_ID", "ROLE_ID", [
89
91
  ]);
90
92
  ```
91
93
 
94
+ You can also upsert a role by providing the role-id:
95
+
96
+ ```typescript
97
+ const roleId = await managementClient.upsertRole(
98
+ "TENANT_ID",
99
+ [
100
+ {
101
+ scopeName: "PERMISSION_NAME",
102
+ // optional: clientId: If none is given the default client will be used
103
+ },
104
+ ],
105
+ "ROLE_ID"
106
+ );
107
+ ```
108
+
92
109
  ## Delete a role
93
110
 
94
111
  ```typescript
@@ -7,7 +7,7 @@ export interface ManagementClient {
7
7
  createScope: (name: string, clientId?: string) => Promise<void>;
8
8
  deleteScope: (name: string, clientId?: string) => Promise<void>;
9
9
  getScopes: (clientId?: string) => Promise<string[]>;
10
- upsertRole: (tenantId: string, id: string, allowedScopes: UpsertRoleScope[]) => Promise<void>;
10
+ upsertRole: (tenantId: string, allowedScopes: UpsertRoleScope[], id?: string) => Promise<string>;
11
11
  deleteRole: (tenantId: string, id: string) => Promise<void>;
12
12
  getRoles: (tenantId: string) => Promise<Role[]>;
13
13
  createUser: (tenantId: string, email: string, assignedRoleIds: string[], login?: string, displayName?: string, password?: string, active?: boolean, blockedUntil?: Date) => Promise<CreateUserResponse>;
@@ -30,7 +30,7 @@ const newManagementClient = async (config) => {
30
30
  const getScopes = async (clientId = "") => {
31
31
  return await (0, getScopes_1.getAllScopes)(clientId, serviceClient);
32
32
  };
33
- const upsertRole = async (tenantId, id, allowedScopes) => {
33
+ const upsertRole = async (tenantId, allowedScopes, id = "") => {
34
34
  return await (0, upsertRole_1.createOrUpdateRole)(tenantId, id, allowedScopes, serviceClient);
35
35
  };
36
36
  const deleteRole = async (tenantId, id) => {
@@ -3,4 +3,4 @@ export interface UpsertRoleScope {
3
3
  scopeName: string;
4
4
  clientId?: string;
5
5
  }
6
- export declare const createOrUpdateRole: (tenantId: string, id: string, allowedScopes: UpsertRoleScope[], serviceClient: ManagementServiceClient) => Promise<void>;
6
+ export declare const createOrUpdateRole: (tenantId: string, id: string, allowedScopes: UpsertRoleScope[], serviceClient: ManagementServiceClient) => Promise<string>;
@@ -13,12 +13,12 @@ const createOrUpdateRole = async (tenantId, id, allowedScopes, serviceClient) =>
13
13
  clientId: (_a = scope.clientId) !== null && _a !== void 0 ? _a : "",
14
14
  };
15
15
  }),
16
- }, error => {
16
+ }, (error, response) => {
17
17
  if (error) {
18
18
  reject(error.message);
19
19
  return;
20
20
  }
21
- resolve();
21
+ resolve(response.id);
22
22
  });
23
23
  });
24
24
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fraym/auth",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "license": "UNLICENSED",
5
5
  "homepage": "https://github.com/fraym/auth-nodejs",
6
6
  "repository": {
@@ -27,7 +27,7 @@
27
27
  "auth": "dist/cmd/auth.js"
28
28
  },
29
29
  "dependencies": {
30
- "@fraym/auth-proto": "^0.5.1",
30
+ "@fraym/auth-proto": "^0.6.0",
31
31
  "@graphql-tools/graphql-file-loader": "^7.5.11",
32
32
  "@graphql-tools/load": "^7.8.6",
33
33
  "@grpc/grpc-js": "1.7.2",