@amaster.ai/auth-client 1.0.0-beta.1
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 +21 -0
- package/README.md +472 -0
- package/dist/auth.d.cts +138 -0
- package/dist/auth.d.ts +138 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +41 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/oauth.d.cts +76 -0
- package/dist/oauth.d.ts +76 -0
- package/dist/permissions.d.cts +108 -0
- package/dist/permissions.d.ts +108 -0
- package/dist/sessions.d.cts +79 -0
- package/dist/sessions.d.ts +79 -0
- package/dist/types-4MBObpYA.d.cts +449 -0
- package/dist/types-4MBObpYA.d.ts +449 -0
- package/dist/user.d.cts +82 -0
- package/dist/user.d.ts +82 -0
- package/package.json +72 -0
package/dist/oauth.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ============================================================================
|
|
3
|
+
* @amaster.ai/auth-client - Type Definitions
|
|
4
|
+
* ============================================================================
|
|
5
|
+
*
|
|
6
|
+
* 🤖 AI NAVIGATION - Read these files based on your task:
|
|
7
|
+
*
|
|
8
|
+
* 1. Need LOGIN/REGISTER/LOGOUT? → Read: ./auth.d.ts
|
|
9
|
+
* 2. Need PERMISSION checks? → Read: ./permissions.d.ts
|
|
10
|
+
* 3. Need USER profile management? → Read: ./user.d.ts
|
|
11
|
+
* 4. Need OAUTH binding? → Read: ./oauth.d.ts
|
|
12
|
+
* 5. Need SESSION management? → Read: ./sessions.d.ts
|
|
13
|
+
*
|
|
14
|
+
* ============================================================================
|
|
15
|
+
*/
|
|
16
|
+
import { HttpClient, ClientResult } from '@amaster.ai/http-client';
|
|
17
|
+
import { O as OAuthBinding, h as OAuthProvider, r as SuccessResponse } from './types-4MBObpYA.js';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* OAuth Module
|
|
21
|
+
*
|
|
22
|
+
* @module oauth
|
|
23
|
+
* @category OAuth
|
|
24
|
+
*
|
|
25
|
+
* Handles OAuth account binding management:
|
|
26
|
+
* - List connected OAuth accounts
|
|
27
|
+
* - Bind new OAuth account
|
|
28
|
+
* - Unbind OAuth account
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
interface OAuthModuleDeps {
|
|
32
|
+
http: HttpClient;
|
|
33
|
+
storage: {
|
|
34
|
+
getItem: (key: string) => string | null;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
declare function createOAuthModule(deps: OAuthModuleDeps): {
|
|
38
|
+
/**
|
|
39
|
+
* Get list of OAuth accounts bound to current user
|
|
40
|
+
*
|
|
41
|
+
* @category OAuth
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const result = await oauth.getOAuthBindings();
|
|
45
|
+
* if (result.data) {
|
|
46
|
+
* result.data.forEach(binding => {
|
|
47
|
+
* console.log(`${binding.provider}: ${binding.email}`);
|
|
48
|
+
* });
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
getOAuthBindings(): Promise<ClientResult<OAuthBinding[]>>;
|
|
53
|
+
/**
|
|
54
|
+
* Bind an OAuth account to current user
|
|
55
|
+
*
|
|
56
|
+
* @category OAuth
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* oauth.bindOAuth("google"); // Redirects to Google OAuth
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
bindOAuth(provider: OAuthProvider): void;
|
|
63
|
+
/**
|
|
64
|
+
* Unbind an OAuth account from current user
|
|
65
|
+
*
|
|
66
|
+
* @category OAuth
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* await oauth.unbindOAuth("google");
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
unbindOAuth(provider: OAuthProvider): Promise<ClientResult<SuccessResponse>>;
|
|
73
|
+
};
|
|
74
|
+
type OAuthModule = ReturnType<typeof createOAuthModule>;
|
|
75
|
+
|
|
76
|
+
export { type OAuthModule, type OAuthModuleDeps, createOAuthModule };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ============================================================================
|
|
3
|
+
* @amaster.ai/auth-client - Type Definitions
|
|
4
|
+
* ============================================================================
|
|
5
|
+
*
|
|
6
|
+
* 🤖 AI NAVIGATION - Read these files based on your task:
|
|
7
|
+
*
|
|
8
|
+
* 1. Need LOGIN/REGISTER/LOGOUT? → Read: ./auth.d.ts
|
|
9
|
+
* 2. Need PERMISSION checks? → Read: ./permissions.d.ts
|
|
10
|
+
* 3. Need USER profile management? → Read: ./user.d.ts
|
|
11
|
+
* 4. Need OAUTH binding? → Read: ./oauth.d.ts
|
|
12
|
+
* 5. Need SESSION management? → Read: ./sessions.d.ts
|
|
13
|
+
*
|
|
14
|
+
* ============================================================================
|
|
15
|
+
*/
|
|
16
|
+
import { HttpClient, ClientResult } from '@amaster.ai/http-client';
|
|
17
|
+
import { s as User, j as PermissionScopeResponse } from './types-4MBObpYA.cjs';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Permissions Module
|
|
21
|
+
*
|
|
22
|
+
* @module permissions
|
|
23
|
+
* @category Permissions
|
|
24
|
+
*
|
|
25
|
+
* Handles permission and role checks:
|
|
26
|
+
* - Role-based access control (RBAC)
|
|
27
|
+
* - Permission checks (fast, local)
|
|
28
|
+
* - Data scope queries (async, server-side)
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
interface PermissionsModuleDeps {
|
|
32
|
+
http: HttpClient;
|
|
33
|
+
getCurrentUser: () => User | null;
|
|
34
|
+
storage: {
|
|
35
|
+
getItem: (key: string) => string | null;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
declare function createPermissionsModule(deps: PermissionsModuleDeps): {
|
|
39
|
+
/**
|
|
40
|
+
* Check if user has a specific role (fast, local check)
|
|
41
|
+
*
|
|
42
|
+
* @category Permissions
|
|
43
|
+
* @performance O(1) - Fast
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* if (permissions.hasRole("admin")) {
|
|
47
|
+
* showAdminPanel();
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
hasRole(roleCode: string): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Check if user has a specific permission (fast, local check)
|
|
54
|
+
*
|
|
55
|
+
* @category Permissions
|
|
56
|
+
* @performance O(1) - Fast
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* if (permissions.hasPermission("user.delete")) {
|
|
60
|
+
* showDeleteButton();
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
hasPermission(permissionName: string): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Check if user has ANY of the specified permissions
|
|
67
|
+
*
|
|
68
|
+
* @category Permissions
|
|
69
|
+
* @performance O(n) - Fast
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* if (permissions.hasAnyPermission(["user.read", "user.write"])) {
|
|
73
|
+
* showUserSection();
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
hasAnyPermission(permissionNames: string[]): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Check if user has ALL of the specified permissions
|
|
80
|
+
*
|
|
81
|
+
* @category Permissions
|
|
82
|
+
* @performance O(n) - Fast
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* if (permissions.hasAllPermissions(["user.read", "user.write"])) {
|
|
86
|
+
* showFullEditor();
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
hasAllPermissions(permissionNames: string[]): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Get data scope for a permission (async, server-side query)
|
|
93
|
+
*
|
|
94
|
+
* @category Permissions
|
|
95
|
+
* @performance Network call required
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const result = await permissions.getPermissionScope("user.read");
|
|
99
|
+
* if (result.data?.dataScope.scopeType === "department") {
|
|
100
|
+
* loadUsers({ departmentId: result.data.dataScope.scopeFilter.departmentId });
|
|
101
|
+
* }
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
getPermissionScope(permissionName: string): Promise<ClientResult<PermissionScopeResponse>>;
|
|
105
|
+
};
|
|
106
|
+
type PermissionsModule = ReturnType<typeof createPermissionsModule>;
|
|
107
|
+
|
|
108
|
+
export { type PermissionsModule, type PermissionsModuleDeps, createPermissionsModule };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ============================================================================
|
|
3
|
+
* @amaster.ai/auth-client - Type Definitions
|
|
4
|
+
* ============================================================================
|
|
5
|
+
*
|
|
6
|
+
* 🤖 AI NAVIGATION - Read these files based on your task:
|
|
7
|
+
*
|
|
8
|
+
* 1. Need LOGIN/REGISTER/LOGOUT? → Read: ./auth.d.ts
|
|
9
|
+
* 2. Need PERMISSION checks? → Read: ./permissions.d.ts
|
|
10
|
+
* 3. Need USER profile management? → Read: ./user.d.ts
|
|
11
|
+
* 4. Need OAUTH binding? → Read: ./oauth.d.ts
|
|
12
|
+
* 5. Need SESSION management? → Read: ./sessions.d.ts
|
|
13
|
+
*
|
|
14
|
+
* ============================================================================
|
|
15
|
+
*/
|
|
16
|
+
import { HttpClient, ClientResult } from '@amaster.ai/http-client';
|
|
17
|
+
import { s as User, j as PermissionScopeResponse } from './types-4MBObpYA.js';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Permissions Module
|
|
21
|
+
*
|
|
22
|
+
* @module permissions
|
|
23
|
+
* @category Permissions
|
|
24
|
+
*
|
|
25
|
+
* Handles permission and role checks:
|
|
26
|
+
* - Role-based access control (RBAC)
|
|
27
|
+
* - Permission checks (fast, local)
|
|
28
|
+
* - Data scope queries (async, server-side)
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
interface PermissionsModuleDeps {
|
|
32
|
+
http: HttpClient;
|
|
33
|
+
getCurrentUser: () => User | null;
|
|
34
|
+
storage: {
|
|
35
|
+
getItem: (key: string) => string | null;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
declare function createPermissionsModule(deps: PermissionsModuleDeps): {
|
|
39
|
+
/**
|
|
40
|
+
* Check if user has a specific role (fast, local check)
|
|
41
|
+
*
|
|
42
|
+
* @category Permissions
|
|
43
|
+
* @performance O(1) - Fast
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* if (permissions.hasRole("admin")) {
|
|
47
|
+
* showAdminPanel();
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
hasRole(roleCode: string): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Check if user has a specific permission (fast, local check)
|
|
54
|
+
*
|
|
55
|
+
* @category Permissions
|
|
56
|
+
* @performance O(1) - Fast
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* if (permissions.hasPermission("user.delete")) {
|
|
60
|
+
* showDeleteButton();
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
hasPermission(permissionName: string): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Check if user has ANY of the specified permissions
|
|
67
|
+
*
|
|
68
|
+
* @category Permissions
|
|
69
|
+
* @performance O(n) - Fast
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* if (permissions.hasAnyPermission(["user.read", "user.write"])) {
|
|
73
|
+
* showUserSection();
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
hasAnyPermission(permissionNames: string[]): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Check if user has ALL of the specified permissions
|
|
80
|
+
*
|
|
81
|
+
* @category Permissions
|
|
82
|
+
* @performance O(n) - Fast
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* if (permissions.hasAllPermissions(["user.read", "user.write"])) {
|
|
86
|
+
* showFullEditor();
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
hasAllPermissions(permissionNames: string[]): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Get data scope for a permission (async, server-side query)
|
|
93
|
+
*
|
|
94
|
+
* @category Permissions
|
|
95
|
+
* @performance Network call required
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const result = await permissions.getPermissionScope("user.read");
|
|
99
|
+
* if (result.data?.dataScope.scopeType === "department") {
|
|
100
|
+
* loadUsers({ departmentId: result.data.dataScope.scopeFilter.departmentId });
|
|
101
|
+
* }
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
getPermissionScope(permissionName: string): Promise<ClientResult<PermissionScopeResponse>>;
|
|
105
|
+
};
|
|
106
|
+
type PermissionsModule = ReturnType<typeof createPermissionsModule>;
|
|
107
|
+
|
|
108
|
+
export { type PermissionsModule, type PermissionsModuleDeps, createPermissionsModule };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ============================================================================
|
|
3
|
+
* @amaster.ai/auth-client - Type Definitions
|
|
4
|
+
* ============================================================================
|
|
5
|
+
*
|
|
6
|
+
* 🤖 AI NAVIGATION - Read these files based on your task:
|
|
7
|
+
*
|
|
8
|
+
* 1. Need LOGIN/REGISTER/LOGOUT? → Read: ./auth.d.ts
|
|
9
|
+
* 2. Need PERMISSION checks? → Read: ./permissions.d.ts
|
|
10
|
+
* 3. Need USER profile management? → Read: ./user.d.ts
|
|
11
|
+
* 4. Need OAUTH binding? → Read: ./oauth.d.ts
|
|
12
|
+
* 5. Need SESSION management? → Read: ./sessions.d.ts
|
|
13
|
+
*
|
|
14
|
+
* ============================================================================
|
|
15
|
+
*/
|
|
16
|
+
import { HttpClient, ClientResult } from '@amaster.ai/http-client';
|
|
17
|
+
import { q as Session, r as SuccessResponse, m as RevokeAllSessionsResponse } from './types-4MBObpYA.cjs';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Sessions Module
|
|
21
|
+
*
|
|
22
|
+
* @module sessions
|
|
23
|
+
* @category Sessions
|
|
24
|
+
*
|
|
25
|
+
* Handles multi-device session management:
|
|
26
|
+
* - View all active sessions
|
|
27
|
+
* - Revoke specific session
|
|
28
|
+
* - Revoke all other sessions
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
interface SessionsModuleDeps {
|
|
32
|
+
http: HttpClient;
|
|
33
|
+
storage: {
|
|
34
|
+
getItem: (key: string) => string | null;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
declare function createSessionsModule(deps: SessionsModuleDeps): {
|
|
38
|
+
/**
|
|
39
|
+
* Get all active sessions for current user
|
|
40
|
+
*
|
|
41
|
+
* @category Sessions
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const result = await sessions.getSessions();
|
|
45
|
+
* if (result.data) {
|
|
46
|
+
* result.data.forEach(session => {
|
|
47
|
+
* console.log(`${session.ip} - ${session.isCurrent ? "Current" : "Other"}`);
|
|
48
|
+
* });
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
getSessions(): Promise<ClientResult<Session[]>>;
|
|
53
|
+
/**
|
|
54
|
+
* Revoke a specific session
|
|
55
|
+
*
|
|
56
|
+
* @category Sessions
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* await sessions.revokeSession("session-id-123");
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
revokeSession(sessionId: string): Promise<ClientResult<SuccessResponse>>;
|
|
63
|
+
/**
|
|
64
|
+
* Revoke all sessions except current one
|
|
65
|
+
*
|
|
66
|
+
* @category Sessions
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const result = await sessions.revokeAllSessions();
|
|
70
|
+
* if (result.data) {
|
|
71
|
+
* console.log(`Revoked ${result.data.revokedCount} sessions`);
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
revokeAllSessions(): Promise<ClientResult<RevokeAllSessionsResponse>>;
|
|
76
|
+
};
|
|
77
|
+
type SessionsModule = ReturnType<typeof createSessionsModule>;
|
|
78
|
+
|
|
79
|
+
export { type SessionsModule, type SessionsModuleDeps, createSessionsModule };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ============================================================================
|
|
3
|
+
* @amaster.ai/auth-client - Type Definitions
|
|
4
|
+
* ============================================================================
|
|
5
|
+
*
|
|
6
|
+
* 🤖 AI NAVIGATION - Read these files based on your task:
|
|
7
|
+
*
|
|
8
|
+
* 1. Need LOGIN/REGISTER/LOGOUT? → Read: ./auth.d.ts
|
|
9
|
+
* 2. Need PERMISSION checks? → Read: ./permissions.d.ts
|
|
10
|
+
* 3. Need USER profile management? → Read: ./user.d.ts
|
|
11
|
+
* 4. Need OAUTH binding? → Read: ./oauth.d.ts
|
|
12
|
+
* 5. Need SESSION management? → Read: ./sessions.d.ts
|
|
13
|
+
*
|
|
14
|
+
* ============================================================================
|
|
15
|
+
*/
|
|
16
|
+
import { HttpClient, ClientResult } from '@amaster.ai/http-client';
|
|
17
|
+
import { q as Session, r as SuccessResponse, m as RevokeAllSessionsResponse } from './types-4MBObpYA.js';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Sessions Module
|
|
21
|
+
*
|
|
22
|
+
* @module sessions
|
|
23
|
+
* @category Sessions
|
|
24
|
+
*
|
|
25
|
+
* Handles multi-device session management:
|
|
26
|
+
* - View all active sessions
|
|
27
|
+
* - Revoke specific session
|
|
28
|
+
* - Revoke all other sessions
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
interface SessionsModuleDeps {
|
|
32
|
+
http: HttpClient;
|
|
33
|
+
storage: {
|
|
34
|
+
getItem: (key: string) => string | null;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
declare function createSessionsModule(deps: SessionsModuleDeps): {
|
|
38
|
+
/**
|
|
39
|
+
* Get all active sessions for current user
|
|
40
|
+
*
|
|
41
|
+
* @category Sessions
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const result = await sessions.getSessions();
|
|
45
|
+
* if (result.data) {
|
|
46
|
+
* result.data.forEach(session => {
|
|
47
|
+
* console.log(`${session.ip} - ${session.isCurrent ? "Current" : "Other"}`);
|
|
48
|
+
* });
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
getSessions(): Promise<ClientResult<Session[]>>;
|
|
53
|
+
/**
|
|
54
|
+
* Revoke a specific session
|
|
55
|
+
*
|
|
56
|
+
* @category Sessions
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* await sessions.revokeSession("session-id-123");
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
revokeSession(sessionId: string): Promise<ClientResult<SuccessResponse>>;
|
|
63
|
+
/**
|
|
64
|
+
* Revoke all sessions except current one
|
|
65
|
+
*
|
|
66
|
+
* @category Sessions
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const result = await sessions.revokeAllSessions();
|
|
70
|
+
* if (result.data) {
|
|
71
|
+
* console.log(`Revoked ${result.data.revokedCount} sessions`);
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
revokeAllSessions(): Promise<ClientResult<RevokeAllSessionsResponse>>;
|
|
76
|
+
};
|
|
77
|
+
type SessionsModule = ReturnType<typeof createSessionsModule>;
|
|
78
|
+
|
|
79
|
+
export { type SessionsModule, type SessionsModuleDeps, createSessionsModule };
|