@drax/identity-front 0.8.5 → 0.10.0

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.8.5",
6
+ "version": "0.10.0",
7
7
  "type": "module",
8
8
  "main": "./src/index.ts",
9
9
  "module": "./src/index.ts",
@@ -25,9 +25,9 @@
25
25
  "format": "prettier --write src/"
26
26
  },
27
27
  "dependencies": {
28
- "@drax/common-front": "^0.8.3",
29
- "@drax/crud-share": "^0.8.5",
30
- "@drax/identity-share": "^0.8.3"
28
+ "@drax/common-front": "^0.10.0",
29
+ "@drax/crud-share": "^0.10.0",
30
+ "@drax/identity-share": "^0.10.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@rushstack/eslint-patch": "^1.8.0",
@@ -49,5 +49,5 @@
49
49
  "vite-plugin-dts": "^3.9.1",
50
50
  "vitest": "^1.4.0"
51
51
  },
52
- "gitHead": "df40172e28cb654c26d622d16d6aef53e2db8a78"
52
+ "gitHead": "bc1b8a35563ccffdf7719cfcc588f12df0e012bb"
53
53
  }
@@ -10,6 +10,7 @@ const messages = {
10
10
  rememberMe: 'Remember Me',
11
11
  forgotPassword: 'Forgot Password?',
12
12
  invalidCredentials: 'Invalid credentials',
13
+ recoveryPassword: 'Recovery Password',
13
14
  }
14
15
  },
15
16
  es: {
@@ -21,8 +22,9 @@ const messages = {
21
22
  username: 'Usuario',
22
23
  password: 'Clave',
23
24
  rememberMe: 'Recordarme',
24
- forgotPassword: '¿Olvidaste tu clave?',
25
+ forgotPassword: '¿Olvidaste tu Contraseña?',
25
26
  invalidCredentials: 'Credenciales Inválidas',
27
+ recoveryPassword: 'Recuperar Contraseña',
26
28
  }
27
29
  }
28
30
  }
@@ -8,9 +8,18 @@ const messages = {
8
8
  operation: {
9
9
  changePassword: "Changing User Password",
10
10
  },
11
+ events: {
12
+ passwordChanged: "Password Changed",
13
+ recoveryPasswordInfo: "Password recovery information has been sent",
14
+ registrationComplete: "Registration Complete",
15
+ },
11
16
  action: {
12
17
  changePassword: "Change Password",
13
18
  changeOwnPassword: "Change Password",
19
+ recoveryPassword: "Recovery Password",
20
+ recoveryPasswordRequest: "Recovery Password Request",
21
+ recoveryPasswordComplete: "Recovery Password Complete",
22
+ register: "Register",
14
23
  login:'Login',
15
24
  logout:'Logout',
16
25
  },
@@ -28,6 +37,7 @@ const messages = {
28
37
  currentPassword: "Current Password",
29
38
  newPassword: "New Password",
30
39
  confirmPassword: "Confirm Password",
40
+ recoveryCode: "Recovery Code",
31
41
  }
32
42
  }
33
43
  },
@@ -37,15 +47,25 @@ const messages = {
37
47
 
38
48
  profile:'Perfil',
39
49
  code: "Codigo",
40
- passwordChanged: "Clave Cambiada",
50
+ passwordChanged: "Contraseña Cambiada",
41
51
  operation: {
42
- changePassword: "Cambiando Clave de Usuario",
52
+ changePassword: "Cambiando Contraseña de Usuario",
53
+ },
54
+ events: {
55
+ passwordChanged: "Se ha cambiado la Contraseña",
56
+ recoveryPasswordInfo: "Se ha enviado información de recuperación de Contraseña",
57
+ registrationComplete: "Revisa tu correo electrónico para completar el registro.",
43
58
  },
44
59
  action: {
45
- changePassword: "Cambiar Clave",
46
- changeOwnPassword: "Cambiar Clave",
60
+ changePassword: "Cambiar Contraseña",
61
+ changeOwnPassword: "Cambiar Contraseña",
62
+ recoveryPassword: "Recuperar Contraseña",
63
+ recoveryPasswordRequest: "Petición de Recuperación de Contraseña",
64
+ recoveryPasswordComplete: "Completar Recuperación de Contraseña",
65
+ register: "Registro",
47
66
  login:'Iniciar Sesión',
48
67
  logout:'Cerrar Sesión',
68
+
49
69
  },
50
70
  field: {
51
71
  name: "Nombre",
@@ -61,6 +81,7 @@ const messages = {
61
81
  currentPassword: "Clave Actual",
62
82
  newPassword: "Nueva Clave",
63
83
  confirmPassword: "Confirmar Clave",
84
+ recoveryCode: "Código de Recuperación",
64
85
  }
65
86
  }
66
87
  }
package/src/index.ts CHANGED
@@ -39,6 +39,7 @@ import type {IUserApiKeyProvider} from "./interfaces/IUserApiKeyProvider"
39
39
  import type {IAuthUser} from "./interfaces/IAuthUser"
40
40
  import type {IUserPassword} from "./interfaces/IUserPassword"
41
41
  import type {ILoginResponse} from "./interfaces/ILoginResponse"
42
+ import type {IUserRegistration} from "./interfaces/IUserRegistration"
42
43
 
43
44
  export type {
44
45
  IAuthProvider,
@@ -48,7 +49,8 @@ export type {
48
49
  IUserApiKeyProvider,
49
50
  IAuthUser,
50
51
  IUserPassword,
51
- ILoginResponse
52
+ ILoginResponse,
53
+ IUserRegistration
52
54
  }
53
55
 
54
56
  export {
@@ -1,11 +1,15 @@
1
1
  import type {IAuthUser} from "./IAuthUser";
2
2
  import type {ILoginResponse} from "./ILoginResponse";
3
+ import type {IUserRegistration} from "./IUserRegistration";
3
4
 
4
5
  interface IAuthProvider {
5
6
  login(username: string, password: string): Promise<ILoginResponse>
6
7
  me(): Promise<IAuthUser>
7
8
  logout(): void
8
9
  changeOwnPassword(currentPassword:string, newPassword:string):Promise<boolean>
10
+ recoveryPasswordRequest(email:string):Promise<boolean>
11
+ recoveryPasswordComplete(recoveryCode:string, newPassword:string):Promise<boolean>
12
+ register(form:IUserRegistration):Promise<boolean>
9
13
  changeAvatar(file: File): Promise<boolean>
10
14
  }
11
15
 
@@ -0,0 +1,9 @@
1
+ interface IUserRegistration {
2
+ name: string
3
+ username: string
4
+ email: string
5
+ phone: string
6
+ avatar: string
7
+ }
8
+
9
+ export type {IUserRegistration}
@@ -2,6 +2,9 @@ import type {IGqlClient} from '@drax/common-front'
2
2
  import type {IAuthProvider} from "../../interfaces/IAuthProvider.ts";
3
3
  import type {IAuthUser} from "../../interfaces/IAuthUser";
4
4
  import type {ILoginResponse} from "../../interfaces/ILoginResponse";
5
+ import type {IUserRegistration} from "../../interfaces/IUserRegistration";
6
+ import type {Promise} from "cypress/types/cy-bluebird";
7
+ import type {File} from "vitest";
5
8
 
6
9
  class AuthGqlProvider implements IAuthProvider {
7
10
 
@@ -66,6 +69,18 @@ class AuthGqlProvider implements IAuthProvider {
66
69
  let r = await this.gqlClient.upload(data)
67
70
  return /true/i.test(r as string)
68
71
  }
72
+
73
+ recoveryPasswordComplete(recoveryCode: string, newPassword: string): Promise<boolean> {
74
+ throw new Error('Not implemented')
75
+ }
76
+
77
+ recoveryPasswordRequest(email: string): Promise<boolean> {
78
+ throw new Error('Not implemented')
79
+ }
80
+
81
+ register(form: IUserRegistration): Promise<boolean> {
82
+ throw new Error('Not implemented')
83
+ }
69
84
  }
70
85
 
71
86
  export default AuthGqlProvider
@@ -3,6 +3,7 @@ import type {IHttpClient} from '@drax/common-front'
3
3
  import type {IAuthProvider} from "../../interfaces/IAuthProvider";
4
4
  import type {IAuthUser} from "../../interfaces/IAuthUser";
5
5
  import type {ILoginResponse} from "../../interfaces/ILoginResponse";
6
+ import type {IUserRegistration} from "@/interfaces/IUserRegistration";
6
7
 
7
8
 
8
9
  class AuthRestProvider implements IAuthProvider {
@@ -22,7 +23,7 @@ class AuthRestProvider implements IAuthProvider {
22
23
  }
23
24
 
24
25
  async login(username: string, password: string): Promise<ILoginResponse> {
25
- const url = '/api/auth'
26
+ const url = '/api/auth/login'
26
27
  const data = {username, password}
27
28
  let {accessToken} = await this.httpClient.post(url, data) as ILoginResponse
28
29
  this.setHttpClientToken(accessToken)
@@ -34,20 +35,41 @@ class AuthRestProvider implements IAuthProvider {
34
35
  }
35
36
 
36
37
  async me(): Promise<IAuthUser> {
37
- const url = '/api/me'
38
+ const url = '/api/auth/me'
38
39
  let r = await this.httpClient.get(url) as IAuthUser
39
40
  return r
40
41
  }
41
42
 
42
43
  async changeOwnPassword(currentPassword: string, newPassword: string): Promise<boolean> {
43
- const url = '/api/password'
44
+ const url = '/api/users/password/change'
44
45
  const data = {currentPassword, newPassword}
45
46
  let r = await this.httpClient.post(url, data)
46
47
  return /true/i.test(r as string)
47
48
  }
48
49
 
50
+ async recoveryPasswordRequest(email: string): Promise<boolean> {
51
+ const url = '/api/users/password/recovery/request'
52
+ const data = {email}
53
+ let r = await this.httpClient.post(url, data)
54
+ return /true/i.test(r as string)
55
+ }
56
+
57
+
58
+ async recoveryPasswordComplete(recoveryCode: string, newPassword: string): Promise<boolean> {
59
+ const url = '/api/users/password/recovery/complete'
60
+ const data = {recoveryCode, newPassword}
61
+ let r = await this.httpClient.post(url, data)
62
+ return /true/i.test(r as string)
63
+ }
64
+
65
+ async register(form: IUserRegistration): Promise<boolean> {
66
+ const url = '/api/users/register'
67
+ let r = await this.httpClient.post(url, form)
68
+ return /true/i.test(r as string)
69
+ }
70
+
49
71
  async changeAvatar(file: File): Promise<boolean> {
50
- const url = '/api/user/avatar'
72
+ const url = '/api/users/avatar'
51
73
  const data = new FormData()
52
74
  data.append('file', file)
53
75
  let r = await this.httpClient.post(url, data, {removeHeaders: ['content-type']})
@@ -52,7 +52,7 @@ class UserRestProvider implements IUserProvider {
52
52
  }
53
53
 
54
54
  async changeUserPassword(userId: string, newPassword: string): Promise<boolean> {
55
- const url = '/api/password/' + userId
55
+ const url = '/api/users/password/change/' + userId
56
56
  const data = {userId, newPassword}
57
57
  let r = await this.httpClient.post(url, data)
58
58
  return /true/i.test(r as string)
@@ -1,6 +1,7 @@
1
1
  import type {IAuthProvider} from "../interfaces/IAuthProvider";
2
2
  import type {IAuthUser} from "../interfaces/IAuthUser";
3
3
  import type {ILoginResponse} from "../interfaces/ILoginResponse";
4
+ import type {IUserRegistration} from "@/interfaces/IUserRegistration";
4
5
 
5
6
  class AuthSystem implements IAuthProvider {
6
7
 
@@ -30,6 +31,21 @@ class AuthSystem implements IAuthProvider {
30
31
  return result
31
32
  }
32
33
 
34
+ async recoveryPasswordRequest(email:string):Promise<boolean> {
35
+ const result: boolean = await this._provider.recoveryPasswordRequest(email)
36
+ return result
37
+ }
38
+
39
+ async recoveryPasswordComplete(recoveryCode:string, newPassword:string):Promise<boolean> {
40
+ const result: boolean = await this._provider.recoveryPasswordComplete(recoveryCode,newPassword)
41
+ return result
42
+ }
43
+
44
+ async register(form: IUserRegistration):Promise<boolean> {
45
+ const result: boolean = await this._provider.register(form)
46
+ return result
47
+ }
48
+
33
49
  async changeAvatar(file: File):Promise<boolean> {
34
50
  const result: boolean = await this._provider.changeAvatar(file)
35
51
  return result