@service_laboratory/auth 3.0.0 → 3.0.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/dist/index.d.ts CHANGED
@@ -7,6 +7,8 @@ import { ReactElement } from 'react';
7
7
  import { ReactNode } from 'react';
8
8
  import { ReactPortal } from 'react';
9
9
  import { Store } from '@tanstack/store';
10
+ import { UseFormReturn } from 'react-hook-form';
11
+ import * as z from 'zod';
10
12
 
11
13
  declare interface AccountData {
12
14
  user: AccountUser;
@@ -31,21 +33,21 @@ export declare class Auth {
31
33
  accountStore: Store<AccountData, (cb: AccountData) => AccountData>;
32
34
  httpClient: Axios;
33
35
  constructor(httpClient: Axios);
34
- initAuthData(): void;
35
- load(): Promise<void>;
36
- login(values: LoginRequest): Promise<any>;
37
- signup(values: RegisterRequest): Promise<AxiosResponse<any, any, {}>>;
38
- verifyEmail(values: ActivateRequest): Promise<void>;
39
- logout(): void;
40
- startResetPassword(values: StartResetPasswordRequest): Promise<AxiosResponse<any, any, {}>>;
41
- resetPassword(values: ResetPasswordRequest): Promise<void>;
42
- _initUserData({ user, token, sessionID, }: {
36
+ initAuthData: () => void;
37
+ load: () => Promise<void>;
38
+ login: (values: LoginRequest) => Promise<any>;
39
+ signup: (values: RegisterRequest) => Promise<AxiosResponse<any, any, {}>>;
40
+ verifyEmail: (values: ActivateRequest) => Promise<void>;
41
+ logout: () => void;
42
+ startResetPassword: (values: StartResetPasswordRequest) => Promise<AxiosResponse<any, any, {}>>;
43
+ confirmResetPassword: (values: ConfirmResetPasswordRequest) => Promise<void>;
44
+ _initUserData: ({ user, token, sessionID, }: {
43
45
  user: AccountUser;
44
46
  token: string;
45
47
  sessionID: string;
46
- }): void;
47
- _setAuthData(token: string): void;
48
- _clearAuthData(): void;
48
+ }) => void;
49
+ _setAuthData: (token: string) => void;
50
+ _clearAuthData: () => void;
49
51
  }
50
52
 
51
53
  export declare const authE2EConfig: {
@@ -54,6 +56,7 @@ export declare const authE2EConfig: {
54
56
  passwordInput: string;
55
57
  submitButton: string;
56
58
  signUpFormLink: string;
59
+ resetPasswordLink: string;
57
60
  };
58
61
  signupForm: {
59
62
  emailInput: string;
@@ -64,6 +67,15 @@ export declare const authE2EConfig: {
64
67
  authCodeInput: string;
65
68
  submitButton: string;
66
69
  };
70
+ startResetPasswordForm: {
71
+ emailInput: string;
72
+ submitButton: string;
73
+ };
74
+ confirmResetPasswordForm: {
75
+ authCodeInput: string;
76
+ newPasswordInput: string;
77
+ submitButton: string;
78
+ };
67
79
  };
68
80
 
69
81
  export declare const AuthWrapper: ({ auth, children, }: {
@@ -71,7 +83,23 @@ export declare const AuthWrapper: ({ auth, children, }: {
71
83
  children: ReactNode;
72
84
  }) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | ReactPortal | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | JSX.Element | null | undefined;
73
85
 
74
- export declare const DevPanel: ({ reset, processing }: {
86
+ declare interface ConfirmPasswordFormProps {
87
+ submit: ({ code, password }: {
88
+ code: string;
89
+ password: string;
90
+ }) => void;
91
+ i18n: any;
92
+ form: any;
93
+ }
94
+
95
+ export declare function ConfirmResetPasswordForm(props: ConfirmPasswordFormProps): JSX.Element;
96
+
97
+ declare interface ConfirmResetPasswordRequest {
98
+ code: string;
99
+ password: string;
100
+ }
101
+
102
+ export declare const DevPanel: ({ reset, processing, }: {
75
103
  reset: () => void;
76
104
  processing: boolean;
77
105
  }) => JSX.Element;
@@ -86,6 +114,8 @@ export declare const locale: {
86
114
  "Invalid password": string;
87
115
  "Email is already used": string;
88
116
  "Wrong verification code": string;
117
+ "Start reset password failed, email not found": string;
118
+ "Confirm reset password failed, wrong code": string;
89
119
  };
90
120
  fieldsErrorsMap: {
91
121
  "User is not enabled": string;
@@ -93,8 +123,57 @@ export declare const locale: {
93
123
  "Email not found": string;
94
124
  "Invalid password": string;
95
125
  "Email is already used": string;
126
+ "Start reset password failed, email not found": string;
96
127
  };
97
128
  ru: {
129
+ confirmResetPasswordForm: {
130
+ form: {
131
+ title: string;
132
+ description: string;
133
+ passwordInputLabel: string;
134
+ authCodeInputLabel: string;
135
+ submitButtonLabel: string;
136
+ loginLinkMessage: string;
137
+ loginLink: string;
138
+ };
139
+ success: {
140
+ notifications: {
141
+ confirmResetPasswordSuccess: string;
142
+ };
143
+ };
144
+ errors: {
145
+ fields: {
146
+ passwordToSmall: string;
147
+ };
148
+ notifications: {
149
+ unknownError: string;
150
+ unknownErrorDescription: string;
151
+ wrongAuthCode: string;
152
+ };
153
+ };
154
+ };
155
+ startResetPasswordForm: {
156
+ form: {
157
+ title: string;
158
+ description: string;
159
+ emailLabel: string;
160
+ submitButtonLabel: string;
161
+ loginLinkMessage: string;
162
+ loginLink: string;
163
+ };
164
+ errors: {
165
+ notifications: {
166
+ unknownError: string;
167
+ unknownErrorDescription: string;
168
+ emailNotFound: string;
169
+ };
170
+ };
171
+ success: {
172
+ notifications: {
173
+ startResetPasswordSuccess: string;
174
+ };
175
+ };
176
+ };
98
177
  verifyEmailForm: {
99
178
  form: {
100
179
  title: string;
@@ -254,12 +333,7 @@ declare interface LoginFormProps {
254
333
  email: string;
255
334
  password: string;
256
335
  }) => void;
257
- loginFormTitle: string;
258
- loginFormDescription: string;
259
- emailLabel: string;
260
- passwordLabel: string;
261
- forgotPasswordMessage: string;
262
- submitButtonLabel: string;
336
+ i18n: any;
263
337
  form: any;
264
338
  resetPasswordLinkComponent?: () => ReactNode;
265
339
  signUpLinkComponent?: () => ReactNode;
@@ -280,11 +354,6 @@ declare interface RegisterRequest {
280
354
  password: string;
281
355
  }
282
356
 
283
- declare interface ResetPasswordRequest {
284
- code: string;
285
- password: string;
286
- }
287
-
288
357
  declare interface Role {
289
358
  name: string;
290
359
  permissions: Permission[];
@@ -297,33 +366,111 @@ declare interface SignUpFormProps {
297
366
  email: string;
298
367
  password: string;
299
368
  }) => void;
300
- signUpFormTitle: string;
301
- signUpFormDescription: string;
302
- emailLabel: string;
303
- passwordLabel: string;
304
- forgotPasswordMessage: string;
305
- submitButtonLabel: string;
369
+ i18n: any;
370
+ form: any;
371
+ }
372
+
373
+ export declare function StartResetPasswordForm(props: StartResetPasswordFormProps): JSX.Element;
374
+
375
+ declare interface StartResetPasswordFormProps {
376
+ submit: ({ email }: {
377
+ email: string;
378
+ }) => void;
379
+ i18n: any;
306
380
  form: any;
307
- resetPasswordLinkComponent?: () => ReactNode;
308
- loginLinkComponent?: () => ReactNode;
309
381
  }
310
382
 
311
383
  declare interface StartResetPasswordRequest {
312
384
  email: string;
313
385
  }
314
386
 
387
+ export declare const useConfirmResetPasswordForm: ({ i18n, auth, }: {
388
+ i18n: any;
389
+ auth: Auth;
390
+ }) => {
391
+ submit: (values: z.infer<z.ZodObject<{
392
+ code: z.ZodString;
393
+ password: z.ZodString;
394
+ }, z.core.$strip>>) => void;
395
+ form: UseFormReturn< {
396
+ code: string;
397
+ password: string;
398
+ }, unknown, {
399
+ code: string;
400
+ password: string;
401
+ }>;
402
+ };
403
+
404
+ export declare const useLoginForm: ({ auth, i18n }: {
405
+ auth: Auth;
406
+ i18n: any;
407
+ }) => {
408
+ form: UseFormReturn< {
409
+ email: string;
410
+ password: string;
411
+ }, any, {
412
+ email: string;
413
+ password: string;
414
+ }>;
415
+ submit: (values: {
416
+ email: string;
417
+ password: string;
418
+ }) => void;
419
+ };
420
+
421
+ export declare const useSignUpForm: ({ auth, i18n }: {
422
+ auth: Auth;
423
+ i18n: any;
424
+ }) => {
425
+ submit: (values: z.infer<z.ZodObject<{
426
+ email: z.ZodEmail;
427
+ password: z.ZodString;
428
+ }, z.core.$strip>>) => void;
429
+ form: UseFormReturn< {
430
+ email: string;
431
+ password: string;
432
+ }, unknown, {
433
+ email: string;
434
+ password: string;
435
+ }>;
436
+ };
437
+
438
+ export declare const useStartResetPasswordForm: ({ i18n, auth, }: {
439
+ i18n: any;
440
+ auth: Auth;
441
+ }) => {
442
+ form: UseFormReturn< {
443
+ email: string;
444
+ }, unknown, {
445
+ email: string;
446
+ }>;
447
+ submit: (values: z.infer<z.ZodObject<{
448
+ email: z.ZodEmail;
449
+ }, z.core.$strip>>) => void;
450
+ };
451
+
452
+ export declare const useVerifyEmailForm: ({ auth, i18n, }: {
453
+ auth: Auth;
454
+ i18n: any;
455
+ }) => {
456
+ submit: (values: {
457
+ code: string;
458
+ }) => void;
459
+ form: UseFormReturn< {
460
+ code: string;
461
+ }, any, {
462
+ code: string;
463
+ }>;
464
+ };
465
+
315
466
  export declare function VerifyEmailForm(props: VerifyEmailFormProps): JSX.Element;
316
467
 
317
468
  declare interface VerifyEmailFormProps {
318
469
  submit: ({ code }: {
319
470
  code: string;
320
471
  }) => void;
321
- verifyEmailTitle: string;
322
- codeLabel: string;
323
- verifyEmailDescription: string;
324
- submitButtonLabel: string;
472
+ i18n: any;
325
473
  form: any;
326
- loginLinkComponent?: () => ReactNode;
327
474
  }
328
475
 
329
476
  export { }