@bagelink/auth 1.1.39 → 1.1.43
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 +140 -179
- package/dist/index.d.cts +94 -34
- package/dist/index.d.mts +94 -34
- package/dist/index.d.ts +94 -34
- package/dist/index.mjs +136 -170
- package/package.json +13 -3
- package/src/api/auth.ts +104 -64
- package/src/composable/useAuth.ts +60 -123
- package/src/types.ts +79 -8
- package/src/api/api.ts +0 -24
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { AxiosResponse
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
import { App } from 'vue';
|
|
2
3
|
|
|
3
4
|
interface User {
|
|
4
5
|
id: string;
|
|
5
6
|
email: string;
|
|
6
|
-
first_name
|
|
7
|
-
last_name
|
|
8
|
-
is_superuser
|
|
9
|
-
is_active
|
|
7
|
+
first_name?: string;
|
|
8
|
+
last_name?: string;
|
|
9
|
+
is_superuser?: boolean;
|
|
10
|
+
is_active?: boolean;
|
|
10
11
|
}
|
|
11
12
|
interface UserRegister {
|
|
12
13
|
email: string;
|
|
@@ -22,38 +23,97 @@ interface UpdatePasswordForm {
|
|
|
22
23
|
new_password: string;
|
|
23
24
|
confirmNewPassword: string;
|
|
24
25
|
}
|
|
25
|
-
interface
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
interface ReactiveFactory {
|
|
27
|
+
<T>(initial: T): {
|
|
28
|
+
value: T;
|
|
29
|
+
set: (newValue: T) => void;
|
|
30
|
+
};
|
|
28
31
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
interface Token {
|
|
33
|
+
access_token: string;
|
|
34
|
+
}
|
|
35
|
+
interface PasswordRecovery {
|
|
36
|
+
email: string;
|
|
37
|
+
}
|
|
38
|
+
interface NewPassword {
|
|
39
|
+
new_password: string;
|
|
40
|
+
}
|
|
41
|
+
interface UserUpdate {
|
|
42
|
+
email?: string;
|
|
43
|
+
is_active?: boolean;
|
|
44
|
+
is_superuser?: boolean;
|
|
45
|
+
first_name?: string;
|
|
46
|
+
last_name?: string;
|
|
47
|
+
}
|
|
48
|
+
interface UserUpdateMe {
|
|
49
|
+
email?: string;
|
|
50
|
+
first_name?: string;
|
|
51
|
+
last_name?: string;
|
|
52
|
+
}
|
|
53
|
+
interface UpdatePassword {
|
|
54
|
+
current_password: string;
|
|
33
55
|
new_password: string;
|
|
34
56
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
57
|
+
interface UserCreate {
|
|
58
|
+
email: string;
|
|
59
|
+
password: string;
|
|
60
|
+
first_name?: string;
|
|
61
|
+
last_name?: string;
|
|
62
|
+
is_active?: boolean;
|
|
63
|
+
is_superuser?: boolean;
|
|
64
|
+
}
|
|
65
|
+
interface SanitizedUserOut {
|
|
66
|
+
email: string;
|
|
67
|
+
is_active?: boolean;
|
|
68
|
+
is_superuser?: boolean;
|
|
69
|
+
first_name?: string;
|
|
70
|
+
last_name?: string;
|
|
71
|
+
id: string;
|
|
72
|
+
}
|
|
73
|
+
interface SanitizedUserList {
|
|
74
|
+
data: SanitizedUserOut[];
|
|
75
|
+
count: number;
|
|
76
|
+
}
|
|
77
|
+
type LoginResponse = AxiosResponse<Token>;
|
|
78
|
+
type PasswordRecoveryResponse = AxiosResponse;
|
|
79
|
+
type ResetPasswordResponse = AxiosResponse;
|
|
80
|
+
type GetUserResponse = AxiosResponse<SanitizedUserOut>;
|
|
81
|
+
type UpdateUserResponse = AxiosResponse<SanitizedUserOut>;
|
|
82
|
+
type DeleteUserResponse = AxiosResponse;
|
|
83
|
+
type GetUsersResponse = AxiosResponse<SanitizedUserList>;
|
|
84
|
+
type CreateUserResponse = AxiosResponse<SanitizedUserOut>;
|
|
85
|
+
type GetMeResponse = AxiosResponse<SanitizedUserOut>;
|
|
86
|
+
type UpdateMeResponse = AxiosResponse<SanitizedUserOut>;
|
|
87
|
+
type UpdatePasswordResponse = AxiosResponse;
|
|
88
|
+
type SignupResponse = AxiosResponse<SanitizedUserOut>;
|
|
89
|
+
|
|
90
|
+
declare class AuthApi {
|
|
91
|
+
private api;
|
|
92
|
+
constructor(baseURL?: string);
|
|
93
|
+
private setupInterceptors;
|
|
94
|
+
login(username: string, password: string): Promise<LoginResponse>;
|
|
95
|
+
logout(): void;
|
|
96
|
+
passwordRecovery(email?: string): Promise<PasswordRecoveryResponse>;
|
|
97
|
+
resetPassword(newPassword: NewPassword['new_password']): Promise<ResetPasswordResponse>;
|
|
98
|
+
getCurrentUser(): Promise<GetMeResponse>;
|
|
99
|
+
signup(user: NewUser): Promise<SignupResponse>;
|
|
100
|
+
updatePassword(form: UpdatePasswordForm): Promise<UpdatePasswordResponse>;
|
|
101
|
+
updateUserProfile(user: Partial<User>): Promise<UpdateMeResponse>;
|
|
102
|
+
setUserStatus(userId: string, isActive: boolean): Promise<UpdateUserResponse>;
|
|
103
|
+
deleteUser(userId: string): Promise<DeleteUserResponse>;
|
|
104
|
+
getUsers(limit?: number, skip?: number): Promise<GetUsersResponse>;
|
|
105
|
+
createUser(user: UserCreate): Promise<CreateUserResponse>;
|
|
106
|
+
getUser(userId: string): Promise<GetUserResponse>;
|
|
107
|
+
}
|
|
45
108
|
|
|
46
|
-
declare function initAuth(
|
|
47
|
-
|
|
48
|
-
errorHandler?: (error: any) => void;
|
|
49
|
-
reactive?: ReactiveFactory;
|
|
50
|
-
}): {
|
|
51
|
-
install(app: any): void;
|
|
52
|
-
useAuth: typeof useAuth;
|
|
109
|
+
declare function initAuth(baseURL?: string): {
|
|
110
|
+
install(app: App): void;
|
|
53
111
|
};
|
|
54
112
|
declare function useAuth(): {
|
|
55
|
-
currentUser:
|
|
56
|
-
|
|
113
|
+
currentUser: {
|
|
114
|
+
value: User;
|
|
115
|
+
set: (newValue: User) => void;
|
|
116
|
+
};
|
|
57
117
|
getFullName: () => string;
|
|
58
118
|
getIsLoggedIn: () => boolean;
|
|
59
119
|
logout: () => Promise<void>;
|
|
@@ -64,11 +124,11 @@ declare function useAuth(): {
|
|
|
64
124
|
checkAuth: () => Promise<boolean>;
|
|
65
125
|
signup: (user: NewUser) => Promise<void>;
|
|
66
126
|
recoverPassword: (email: string) => Promise<void>;
|
|
67
|
-
resetPassword: (
|
|
68
|
-
updatePassword: () => Promise<void>;
|
|
127
|
+
resetPassword: (newPassword: string) => Promise<void>;
|
|
128
|
+
updatePassword: (form: UpdatePasswordForm) => Promise<void>;
|
|
69
129
|
updateProfile: (user: Partial<User>) => Promise<void>;
|
|
70
130
|
toggleUserStatus: (userId: string, isActive: boolean) => Promise<void>;
|
|
71
131
|
deleteUser: (userId: string) => Promise<void>;
|
|
72
132
|
};
|
|
73
133
|
|
|
74
|
-
export { type
|
|
134
|
+
export { AuthApi, type CreateUserResponse, type DeleteUserResponse, type GetMeResponse, type GetUserResponse, type GetUsersResponse, type LoginResponse, type NewPassword, type NewUser, type PasswordRecovery, type PasswordRecoveryResponse, type ReactiveFactory, type ResetPasswordResponse, type SanitizedUserList, type SanitizedUserOut, type SignupResponse, type Token, type UpdateMeResponse, type UpdatePassword, type UpdatePasswordForm, type UpdatePasswordResponse, type UpdateUserResponse, type User, type UserCreate, type UserRegister, type UserUpdate, type UserUpdateMe, initAuth, useAuth };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { AxiosResponse
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
import { App } from 'vue';
|
|
2
3
|
|
|
3
4
|
interface User {
|
|
4
5
|
id: string;
|
|
5
6
|
email: string;
|
|
6
|
-
first_name
|
|
7
|
-
last_name
|
|
8
|
-
is_superuser
|
|
9
|
-
is_active
|
|
7
|
+
first_name?: string;
|
|
8
|
+
last_name?: string;
|
|
9
|
+
is_superuser?: boolean;
|
|
10
|
+
is_active?: boolean;
|
|
10
11
|
}
|
|
11
12
|
interface UserRegister {
|
|
12
13
|
email: string;
|
|
@@ -22,38 +23,97 @@ interface UpdatePasswordForm {
|
|
|
22
23
|
new_password: string;
|
|
23
24
|
confirmNewPassword: string;
|
|
24
25
|
}
|
|
25
|
-
interface
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
interface ReactiveFactory {
|
|
27
|
+
<T>(initial: T): {
|
|
28
|
+
value: T;
|
|
29
|
+
set: (newValue: T) => void;
|
|
30
|
+
};
|
|
28
31
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
interface Token {
|
|
33
|
+
access_token: string;
|
|
34
|
+
}
|
|
35
|
+
interface PasswordRecovery {
|
|
36
|
+
email: string;
|
|
37
|
+
}
|
|
38
|
+
interface NewPassword {
|
|
39
|
+
new_password: string;
|
|
40
|
+
}
|
|
41
|
+
interface UserUpdate {
|
|
42
|
+
email?: string;
|
|
43
|
+
is_active?: boolean;
|
|
44
|
+
is_superuser?: boolean;
|
|
45
|
+
first_name?: string;
|
|
46
|
+
last_name?: string;
|
|
47
|
+
}
|
|
48
|
+
interface UserUpdateMe {
|
|
49
|
+
email?: string;
|
|
50
|
+
first_name?: string;
|
|
51
|
+
last_name?: string;
|
|
52
|
+
}
|
|
53
|
+
interface UpdatePassword {
|
|
54
|
+
current_password: string;
|
|
33
55
|
new_password: string;
|
|
34
56
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
57
|
+
interface UserCreate {
|
|
58
|
+
email: string;
|
|
59
|
+
password: string;
|
|
60
|
+
first_name?: string;
|
|
61
|
+
last_name?: string;
|
|
62
|
+
is_active?: boolean;
|
|
63
|
+
is_superuser?: boolean;
|
|
64
|
+
}
|
|
65
|
+
interface SanitizedUserOut {
|
|
66
|
+
email: string;
|
|
67
|
+
is_active?: boolean;
|
|
68
|
+
is_superuser?: boolean;
|
|
69
|
+
first_name?: string;
|
|
70
|
+
last_name?: string;
|
|
71
|
+
id: string;
|
|
72
|
+
}
|
|
73
|
+
interface SanitizedUserList {
|
|
74
|
+
data: SanitizedUserOut[];
|
|
75
|
+
count: number;
|
|
76
|
+
}
|
|
77
|
+
type LoginResponse = AxiosResponse<Token>;
|
|
78
|
+
type PasswordRecoveryResponse = AxiosResponse;
|
|
79
|
+
type ResetPasswordResponse = AxiosResponse;
|
|
80
|
+
type GetUserResponse = AxiosResponse<SanitizedUserOut>;
|
|
81
|
+
type UpdateUserResponse = AxiosResponse<SanitizedUserOut>;
|
|
82
|
+
type DeleteUserResponse = AxiosResponse;
|
|
83
|
+
type GetUsersResponse = AxiosResponse<SanitizedUserList>;
|
|
84
|
+
type CreateUserResponse = AxiosResponse<SanitizedUserOut>;
|
|
85
|
+
type GetMeResponse = AxiosResponse<SanitizedUserOut>;
|
|
86
|
+
type UpdateMeResponse = AxiosResponse<SanitizedUserOut>;
|
|
87
|
+
type UpdatePasswordResponse = AxiosResponse;
|
|
88
|
+
type SignupResponse = AxiosResponse<SanitizedUserOut>;
|
|
89
|
+
|
|
90
|
+
declare class AuthApi {
|
|
91
|
+
private api;
|
|
92
|
+
constructor(baseURL?: string);
|
|
93
|
+
private setupInterceptors;
|
|
94
|
+
login(username: string, password: string): Promise<LoginResponse>;
|
|
95
|
+
logout(): void;
|
|
96
|
+
passwordRecovery(email?: string): Promise<PasswordRecoveryResponse>;
|
|
97
|
+
resetPassword(newPassword: NewPassword['new_password']): Promise<ResetPasswordResponse>;
|
|
98
|
+
getCurrentUser(): Promise<GetMeResponse>;
|
|
99
|
+
signup(user: NewUser): Promise<SignupResponse>;
|
|
100
|
+
updatePassword(form: UpdatePasswordForm): Promise<UpdatePasswordResponse>;
|
|
101
|
+
updateUserProfile(user: Partial<User>): Promise<UpdateMeResponse>;
|
|
102
|
+
setUserStatus(userId: string, isActive: boolean): Promise<UpdateUserResponse>;
|
|
103
|
+
deleteUser(userId: string): Promise<DeleteUserResponse>;
|
|
104
|
+
getUsers(limit?: number, skip?: number): Promise<GetUsersResponse>;
|
|
105
|
+
createUser(user: UserCreate): Promise<CreateUserResponse>;
|
|
106
|
+
getUser(userId: string): Promise<GetUserResponse>;
|
|
107
|
+
}
|
|
45
108
|
|
|
46
|
-
declare function initAuth(
|
|
47
|
-
|
|
48
|
-
errorHandler?: (error: any) => void;
|
|
49
|
-
reactive?: ReactiveFactory;
|
|
50
|
-
}): {
|
|
51
|
-
install(app: any): void;
|
|
52
|
-
useAuth: typeof useAuth;
|
|
109
|
+
declare function initAuth(baseURL?: string): {
|
|
110
|
+
install(app: App): void;
|
|
53
111
|
};
|
|
54
112
|
declare function useAuth(): {
|
|
55
|
-
currentUser:
|
|
56
|
-
|
|
113
|
+
currentUser: {
|
|
114
|
+
value: User;
|
|
115
|
+
set: (newValue: User) => void;
|
|
116
|
+
};
|
|
57
117
|
getFullName: () => string;
|
|
58
118
|
getIsLoggedIn: () => boolean;
|
|
59
119
|
logout: () => Promise<void>;
|
|
@@ -64,11 +124,11 @@ declare function useAuth(): {
|
|
|
64
124
|
checkAuth: () => Promise<boolean>;
|
|
65
125
|
signup: (user: NewUser) => Promise<void>;
|
|
66
126
|
recoverPassword: (email: string) => Promise<void>;
|
|
67
|
-
resetPassword: (
|
|
68
|
-
updatePassword: () => Promise<void>;
|
|
127
|
+
resetPassword: (newPassword: string) => Promise<void>;
|
|
128
|
+
updatePassword: (form: UpdatePasswordForm) => Promise<void>;
|
|
69
129
|
updateProfile: (user: Partial<User>) => Promise<void>;
|
|
70
130
|
toggleUserStatus: (userId: string, isActive: boolean) => Promise<void>;
|
|
71
131
|
deleteUser: (userId: string) => Promise<void>;
|
|
72
132
|
};
|
|
73
133
|
|
|
74
|
-
export { type
|
|
134
|
+
export { AuthApi, type CreateUserResponse, type DeleteUserResponse, type GetMeResponse, type GetUserResponse, type GetUsersResponse, type LoginResponse, type NewPassword, type NewUser, type PasswordRecovery, type PasswordRecoveryResponse, type ReactiveFactory, type ResetPasswordResponse, type SanitizedUserList, type SanitizedUserOut, type SignupResponse, type Token, type UpdateMeResponse, type UpdatePassword, type UpdatePasswordForm, type UpdatePasswordResponse, type UpdateUserResponse, type User, type UserCreate, type UserRegister, type UserUpdate, type UserUpdateMe, initAuth, useAuth };
|