@temboplus/afloat 0.1.56 → 0.1.57
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/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/models/user.model.d.ts +18 -35
- package/package.json +1 -1
|
@@ -3,80 +3,63 @@ import { Profile } from "./profile.model";
|
|
|
3
3
|
* Represents a user in Afloat.
|
|
4
4
|
*
|
|
5
5
|
* This class centralizes user-related logic, simplifying interaction
|
|
6
|
-
* with user-related data and ensuring consistent
|
|
6
|
+
* with user-related data and ensuring consistent access checks across the application.
|
|
7
7
|
*/
|
|
8
8
|
export declare class User {
|
|
9
9
|
/**
|
|
10
|
-
* Logged-in user name
|
|
10
|
+
* Logged-in user name.
|
|
11
11
|
*/
|
|
12
12
|
name: string;
|
|
13
13
|
/**
|
|
14
|
-
* Logged-in identity: phone
|
|
14
|
+
* Logged-in identity: phone number or email address.
|
|
15
15
|
*/
|
|
16
16
|
identity: string;
|
|
17
17
|
/**
|
|
18
|
-
* The user's Afloat profile
|
|
18
|
+
* The user's Afloat profile.
|
|
19
19
|
*/
|
|
20
20
|
profile: Profile;
|
|
21
21
|
/**
|
|
22
|
-
* The user's authentication token.
|
|
23
|
-
* for all authenticated API endpoints.
|
|
22
|
+
* The user's authentication token.
|
|
24
23
|
*/
|
|
25
24
|
token: string;
|
|
26
25
|
/**
|
|
27
|
-
* Indicates whether the user
|
|
26
|
+
* Indicates whether the user must change their default password.
|
|
28
27
|
*/
|
|
29
28
|
resetPassword: boolean;
|
|
30
29
|
/**
|
|
31
|
-
* A
|
|
32
|
-
* to specific actions or features in the system.
|
|
30
|
+
* A list of granted access keys (permissions).
|
|
33
31
|
*/
|
|
34
|
-
|
|
32
|
+
access: string[];
|
|
35
33
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @param userData - An object containing the user's profile, token,
|
|
39
|
-
* permissions (access list), and the `resetPassword` flag.
|
|
34
|
+
* A map of access keys to boolean values for fast permission checks.
|
|
40
35
|
*/
|
|
41
|
-
private
|
|
36
|
+
private accessMap;
|
|
42
37
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* @param permission - The permission key to check.
|
|
46
|
-
* @returns `true` if the user has the specified permission, otherwise `false`.
|
|
38
|
+
* Creates a new `User` instance.
|
|
47
39
|
*/
|
|
48
|
-
|
|
40
|
+
private constructor();
|
|
49
41
|
/**
|
|
50
|
-
*
|
|
42
|
+
* Checks if the user has a specific access permission.
|
|
51
43
|
*
|
|
52
|
-
* @
|
|
44
|
+
* @param key - The access key to check.
|
|
45
|
+
* @returns `true` if the user has the specified access, otherwise `false`.
|
|
53
46
|
*/
|
|
54
|
-
|
|
47
|
+
can(key: string): boolean;
|
|
55
48
|
/**
|
|
56
49
|
* Returns a plain object representation of the user.
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* @returns An object representing the current User instance.
|
|
50
|
+
* This can safely be embedded in a JWT payload.
|
|
60
51
|
*/
|
|
61
52
|
toObject(): Record<string, any>;
|
|
62
53
|
/**
|
|
63
54
|
* Serializes the `User` instance to a JSON string.
|
|
64
|
-
*
|
|
65
|
-
* @returns A JSON string representation of the `User` instance.
|
|
66
55
|
*/
|
|
67
56
|
toJSON(): string;
|
|
68
57
|
/**
|
|
69
58
|
* Creates a new `User` instance from a JSON string.
|
|
70
|
-
*
|
|
71
|
-
* @param jsonString - A JSON string containing user data.
|
|
72
|
-
* @returns A `User` instance reconstructed from the JSON data, or `undefined` if invalid.
|
|
73
59
|
*/
|
|
74
60
|
static fromJSON(jsonString: string): User | undefined;
|
|
75
61
|
/**
|
|
76
|
-
* Creates a new `User` instance from a
|
|
77
|
-
*
|
|
78
|
-
* @param data - The data object or stringified JSON containing user information.
|
|
79
|
-
* @returns A `User` instance, or `undefined` if the data is invalid or incomplete.
|
|
62
|
+
* Creates a new `User` instance from a plain object.
|
|
80
63
|
*/
|
|
81
64
|
static from(data: any): User | undefined;
|
|
82
65
|
}
|