@abpjs/identity-pro 0.7.2

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/LICENSE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version of
113
+ the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
package/README.md ADDED
@@ -0,0 +1,402 @@
1
+ # @abpjs/identity-pro
2
+
3
+ > Enhanced user, role, and claim management UI components for ABP Framework in React
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@abpjs/identity-pro.svg)](https://www.npmjs.com/package/@abpjs/identity-pro)
6
+ [![License: LGPL-3.0](https://img.shields.io/badge/License-LGPL--3.0-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)
7
+
8
+ ## Overview
9
+
10
+ `@abpjs/identity-pro` provides enhanced identity management components for ABP-based React applications. It extends the basic identity module with advanced features like claim type management, user/role claims, and organization units.
11
+
12
+ This package is a React translation of the original `@volo/abp.ng.identity` Angular package, bringing pro-level identity management to React applications.
13
+
14
+ ## Features
15
+
16
+ - **User Management** - Create, read, update, and delete users with enhanced options
17
+ - **Role Management** - Create, read, update, and delete roles
18
+ - **Claim Types** - Manage custom claim types for users and roles
19
+ - **User Claims** - Assign and manage claims on individual users
20
+ - **Role Claims** - Assign and manage claims on roles
21
+ - **Role Assignment** - Assign roles to users with checkbox interface
22
+ - **Permission Integration** - Seamlessly integrates with permission management
23
+ - **Pagination** - Built-in pagination for all list views
24
+ - **Search & Filter** - Filter users, roles, and claims
25
+ - **Localization** - Full i18n support using ABP localization
26
+ - **Chakra UI** - Beautiful, accessible components
27
+ - **TypeScript** - Full type safety with comprehensive definitions
28
+
29
+ ## Installation
30
+
31
+ ```bash
32
+ # Using npm
33
+ npm install @abpjs/identity-pro
34
+
35
+ # Using yarn
36
+ yarn add @abpjs/identity-pro
37
+
38
+ # Using pnpm
39
+ pnpm add @abpjs/identity-pro
40
+ ```
41
+
42
+ ### Required Dependencies
43
+
44
+ This package requires the following peer dependencies:
45
+
46
+ ```bash
47
+ npm install @abpjs/core @abpjs/theme-shared @abpjs/permission-management @chakra-ui/react @emotion/react react-icons react-router-dom
48
+ ```
49
+
50
+ ## Quick Start
51
+
52
+ ### Using Pre-built Components
53
+
54
+ ```tsx
55
+ import { RolesComponent, UsersComponent, ClaimsComponent } from '@abpjs/identity-pro';
56
+ import { Tabs, TabList, TabPanels, Tab, TabPanel } from '@chakra-ui/react';
57
+
58
+ function IdentityProManagement() {
59
+ return (
60
+ <Tabs>
61
+ <TabList>
62
+ <Tab>Users</Tab>
63
+ <Tab>Roles</Tab>
64
+ <Tab>Claim Types</Tab>
65
+ </TabList>
66
+
67
+ <TabPanels>
68
+ <TabPanel>
69
+ <UsersComponent
70
+ onUserCreated={(user) => console.log('User created:', user)}
71
+ onUserDeleted={(id) => console.log('User deleted:', id)}
72
+ />
73
+ </TabPanel>
74
+ <TabPanel>
75
+ <RolesComponent
76
+ onRoleCreated={(role) => console.log('Role created:', role)}
77
+ onRoleDeleted={(id) => console.log('Role deleted:', id)}
78
+ />
79
+ </TabPanel>
80
+ <TabPanel>
81
+ <ClaimsComponent
82
+ onClaimTypeCreated={(claim) => console.log('Claim type created:', claim)}
83
+ onClaimTypeDeleted={(id) => console.log('Claim type deleted:', id)}
84
+ />
85
+ </TabPanel>
86
+ </TabPanels>
87
+ </Tabs>
88
+ );
89
+ }
90
+ ```
91
+
92
+ ### Using Hooks for Custom UI
93
+
94
+ ```tsx
95
+ import { useUsers, useRoles, useClaims } from '@abpjs/identity-pro';
96
+ import { useEffect } from 'react';
97
+
98
+ function CustomIdentityPage() {
99
+ const { users, fetchUsers } = useUsers();
100
+ const { roles, fetchRoles } = useRoles();
101
+ const { claimTypes, fetchClaimTypes } = useClaims();
102
+
103
+ useEffect(() => {
104
+ fetchUsers();
105
+ fetchRoles();
106
+ fetchClaimTypes();
107
+ }, [fetchUsers, fetchRoles, fetchClaimTypes]);
108
+
109
+ return (
110
+ <div>
111
+ <h2>Users: {users.length}</h2>
112
+ <h2>Roles: {roles.length}</h2>
113
+ <h2>Claim Types: {claimTypes.length}</h2>
114
+ </div>
115
+ );
116
+ }
117
+ ```
118
+
119
+ ## Components
120
+
121
+ ### UsersComponent
122
+
123
+ Complete user management component with enhanced pro features.
124
+
125
+ ```tsx
126
+ import { UsersComponent } from '@abpjs/identity-pro';
127
+
128
+ <UsersComponent
129
+ onUserCreated={(user) => console.log('Created:', user)}
130
+ onUserUpdated={(user) => console.log('Updated:', user)}
131
+ onUserDeleted={(id) => console.log('Deleted:', id)}
132
+ />
133
+ ```
134
+
135
+ **Features:**
136
+ - User table with actions menu
137
+ - Search/filter by username
138
+ - Pagination controls
139
+ - Create/Edit modal with tabs for user info, role assignment, and claims
140
+ - Permission management integration
141
+ - Delete confirmation dialog
142
+
143
+ ### RolesComponent
144
+
145
+ Complete role management component with claim support.
146
+
147
+ ```tsx
148
+ import { RolesComponent } from '@abpjs/identity-pro';
149
+
150
+ <RolesComponent
151
+ onRoleCreated={(role) => console.log('Created:', role)}
152
+ onRoleUpdated={(role) => console.log('Updated:', role)}
153
+ onRoleDeleted={(id) => console.log('Deleted:', id)}
154
+ />
155
+ ```
156
+
157
+ **Features:**
158
+ - Role table with actions menu
159
+ - Search/filter by role name
160
+ - Create/Edit modal with isDefault and isPublic options
161
+ - Role claims management
162
+ - Permission management integration
163
+ - Static role protection
164
+ - Delete confirmation dialog
165
+
166
+ ### ClaimsComponent
167
+
168
+ Claim type management component.
169
+
170
+ ```tsx
171
+ import { ClaimsComponent } from '@abpjs/identity-pro';
172
+
173
+ <ClaimsComponent
174
+ onClaimTypeCreated={(claim) => console.log('Created:', claim)}
175
+ onClaimTypeUpdated={(claim) => console.log('Updated:', claim)}
176
+ onClaimTypeDeleted={(id) => console.log('Deleted:', id)}
177
+ />
178
+ ```
179
+
180
+ **Features:**
181
+ - Claim types table
182
+ - Search/filter by claim name
183
+ - Create/Edit modal with value type selection
184
+ - Required field configuration
185
+ - Regex validation pattern support
186
+ - Delete confirmation dialog
187
+
188
+ ## Hooks
189
+
190
+ ### useUsers
191
+
192
+ Hook for managing users with full CRUD and pagination support.
193
+
194
+ ```tsx
195
+ import { useUsers } from '@abpjs/identity-pro';
196
+
197
+ const {
198
+ users, // Array of users
199
+ totalCount, // Total user count
200
+ selectedUser, // Currently selected user
201
+ selectedUserRoles, // Roles of selected user
202
+ isLoading, // Loading state
203
+ error, // Error message
204
+ fetchUsers, // Fetch users with optional params
205
+ getUserById, // Get single user
206
+ getUserRoles, // Get user's roles
207
+ createUser, // Create new user
208
+ updateUser, // Update existing user
209
+ deleteUser, // Delete user
210
+ reset, // Reset all state
211
+ } = useUsers();
212
+ ```
213
+
214
+ ### useRoles
215
+
216
+ Hook for managing roles with full CRUD support.
217
+
218
+ ```tsx
219
+ import { useRoles } from '@abpjs/identity-pro';
220
+
221
+ const {
222
+ roles, // Array of roles
223
+ totalCount, // Total role count
224
+ selectedRole, // Currently selected role
225
+ isLoading, // Loading state
226
+ error, // Error message
227
+ fetchRoles, // Fetch all roles
228
+ getRoleById, // Get single role
229
+ createRole, // Create new role
230
+ updateRole, // Update existing role
231
+ deleteRole, // Delete role
232
+ reset, // Reset all state
233
+ } = useRoles();
234
+ ```
235
+
236
+ ### useClaims
237
+
238
+ Hook for managing claim types.
239
+
240
+ ```tsx
241
+ import { useClaims } from '@abpjs/identity-pro';
242
+
243
+ const {
244
+ claimTypes, // Array of claim types
245
+ totalCount, // Total claim type count
246
+ selectedClaimType, // Currently selected claim type
247
+ isLoading, // Loading state
248
+ error, // Error message
249
+ fetchClaimTypes, // Fetch claim types with optional params
250
+ getClaimTypeById, // Get single claim type
251
+ createClaimType, // Create new claim type
252
+ updateClaimType, // Update existing claim type
253
+ deleteClaimType, // Delete claim type
254
+ reset, // Reset all state
255
+ } = useClaims();
256
+ ```
257
+
258
+ ### useIdentity
259
+
260
+ Combined hook for managing users and roles.
261
+
262
+ ```tsx
263
+ import { useIdentity } from '@abpjs/identity-pro';
264
+
265
+ const {
266
+ roles,
267
+ users,
268
+ fetchRoles,
269
+ fetchUsers,
270
+ } = useIdentity();
271
+ ```
272
+
273
+ ## Services
274
+
275
+ ### IdentityProService
276
+
277
+ Service class for identity pro API operations.
278
+
279
+ ```tsx
280
+ import { IdentityProService } from '@abpjs/identity-pro';
281
+ import { useRestService } from '@abpjs/core';
282
+
283
+ function MyComponent() {
284
+ const restService = useRestService();
285
+ const service = new IdentityProService(restService);
286
+
287
+ // User operations
288
+ await service.getUsers({ maxResultCount: 10, skipCount: 0 });
289
+ await service.getUserById(userId);
290
+ await service.createUser(userData);
291
+ await service.updateUser(userId, userData);
292
+ await service.deleteUser(userId);
293
+
294
+ // Role operations
295
+ await service.getRoles();
296
+ await service.createRole(roleData);
297
+
298
+ // Claim type operations
299
+ await service.getClaimTypes();
300
+ await service.createClaimType(claimData);
301
+ }
302
+ ```
303
+
304
+ ## Data Models
305
+
306
+ ### User Types
307
+
308
+ ```typescript
309
+ interface UserItem {
310
+ id: string;
311
+ tenantId: string;
312
+ userName: string;
313
+ name: string;
314
+ surname: string;
315
+ email: string;
316
+ emailConfirmed: boolean;
317
+ phoneNumber: string;
318
+ phoneNumberConfirmed: boolean;
319
+ twoFactorEnabled: boolean;
320
+ lockoutEnabled: boolean;
321
+ isLockedOut: boolean;
322
+ concurrencyStamp: string;
323
+ }
324
+ ```
325
+
326
+ ### Role Types
327
+
328
+ ```typescript
329
+ interface RoleItem {
330
+ id: string;
331
+ name: string;
332
+ isDefault: boolean;
333
+ isPublic: boolean;
334
+ isStatic: boolean;
335
+ concurrencyStamp: string;
336
+ }
337
+ ```
338
+
339
+ ### Claim Types
340
+
341
+ ```typescript
342
+ interface ClaimType {
343
+ id: string;
344
+ name: string;
345
+ required: boolean;
346
+ isStatic: boolean;
347
+ regex: string;
348
+ regexDescription: string;
349
+ description: string;
350
+ valueType: ClaimValueType;
351
+ valueTypeAsString: string;
352
+ }
353
+
354
+ enum ClaimValueType {
355
+ String = 0,
356
+ Int = 1,
357
+ Boolean = 2,
358
+ DateTime = 3,
359
+ }
360
+ ```
361
+
362
+ ## ABP Permissions
363
+
364
+ This package respects ABP's identity pro permissions:
365
+
366
+ | Permission | Description |
367
+ |------------|-------------|
368
+ | `AbpIdentity.Users` | View users |
369
+ | `AbpIdentity.Users.Create` | Create users |
370
+ | `AbpIdentity.Users.Update` | Update users |
371
+ | `AbpIdentity.Users.Delete` | Delete users |
372
+ | `AbpIdentity.Users.ManagePermissions` | Manage user permissions |
373
+ | `AbpIdentity.Roles` | View roles |
374
+ | `AbpIdentity.Roles.Create` | Create roles |
375
+ | `AbpIdentity.Roles.Update` | Update roles |
376
+ | `AbpIdentity.Roles.Delete` | Delete roles |
377
+ | `AbpIdentity.Roles.ManagePermissions` | Manage role permissions |
378
+ | `AbpIdentity.ClaimTypes` | View claim types |
379
+ | `AbpIdentity.ClaimTypes.Create` | Create claim types |
380
+ | `AbpIdentity.ClaimTypes.Update` | Update claim types |
381
+ | `AbpIdentity.ClaimTypes.Delete` | Delete claim types |
382
+
383
+ ## Related Packages
384
+
385
+ - [@abpjs/core](https://www.npmjs.com/package/@abpjs/core) - Core infrastructure (required)
386
+ - [@abpjs/theme-shared](https://www.npmjs.com/package/@abpjs/theme-shared) - Shared UI components (required)
387
+ - [@abpjs/permission-management](https://www.npmjs.com/package/@abpjs/permission-management) - Permission management (required)
388
+ - [@abpjs/identity](https://www.npmjs.com/package/@abpjs/identity) - Basic identity module
389
+ - [@abpjs/account-pro](https://www.npmjs.com/package/@abpjs/account-pro) - Account Pro features
390
+ - [@abpjs/saas](https://www.npmjs.com/package/@abpjs/saas) - SaaS module
391
+
392
+ ## Contributing
393
+
394
+ This package is part of the [ABP React](https://github.com/abpjs/abp-react) monorepo. Contributions are welcome!
395
+
396
+ ## License
397
+
398
+ LGPL-3.0 - See [LICENSE](https://github.com/abpjs/abp-react/blob/main/LICENSE) for details.
399
+
400
+ ---
401
+
402
+ **[View Full Documentation](https://docs.abpjs.io/docs/packages/identity-pro/overview)** | **[Report Issues](https://github.com/abpjs/abp-react/issues)** | **[View Source](https://github.com/abpjs/abp-react/tree/main/packages/identity-pro)**