@archbase/security 3.0.0 → 3.0.3

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.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +51 -0
  3. package/dist/index.d.ts +2 -0
  4. package/dist/src/ArchbaseAccessToken.d.ts +1 -0
  5. package/dist/src/ArchbaseAccessTokenService.d.ts +11 -0
  6. package/dist/src/ArchbaseApiTokenService.d.ts +12 -0
  7. package/dist/src/ArchbaseAuthenticator.d.ts +24 -0
  8. package/dist/src/ArchbaseGroupService.d.ts +10 -0
  9. package/dist/src/ArchbaseLogin.d.ts +30 -0
  10. package/dist/src/ArchbaseProfileService.d.ts +10 -0
  11. package/dist/src/ArchbaseResetPassword.d.ts +14 -0
  12. package/dist/src/ArchbaseResourceService.d.ts +16 -0
  13. package/dist/src/ArchbaseSecurityComponents.d.ts +40 -0
  14. package/dist/src/ArchbaseSecurityContext.d.ts +41 -0
  15. package/dist/src/ArchbaseSecurityHooks.d.ts +24 -0
  16. package/dist/src/ArchbaseSecurityManager.d.ts +58 -0
  17. package/dist/src/ArchbaseTenantManager.d.ts +22 -0
  18. package/dist/src/ArchbaseTokenManager.d.ts +1 -0
  19. package/dist/src/ArchbaseUser.d.ts +19 -0
  20. package/dist/src/ArchbaseUserService.d.ts +11 -0
  21. package/dist/src/DefaultArchbaseTokenManager.d.ts +20 -0
  22. package/dist/src/SecurityDomain.d.ts +221 -0
  23. package/dist/src/SecurityType.d.ts +5 -0
  24. package/dist/src/examples/ContextualAuthenticationExample.d.ts +113 -0
  25. package/dist/src/examples/SecurityExample.d.ts +2 -0
  26. package/dist/src/hooks/index.d.ts +5 -0
  27. package/dist/src/hooks/useArchbaseAuthenticationManager.d.ts +36 -0
  28. package/dist/src/hooks/useArchbaseGetCurrentToken.d.ts +4 -0
  29. package/dist/src/hooks/useArchbaseGetLoggedUser.d.ts +2 -0
  30. package/dist/src/hooks/useArchbaseResetPassword.d.ts +8 -0
  31. package/dist/src/hooks/useArchbaseSecurityManager.d.ts +11 -0
  32. package/dist/src/index.d.ts +27 -0
  33. package/dist/src/oauth2/AuthContext.d.ts +4 -0
  34. package/dist/src/oauth2/Types.d.ts +108 -0
  35. package/dist/src/oauth2/authConfig.d.ts +3 -0
  36. package/dist/src/oauth2/authentication.d.ts +9 -0
  37. package/dist/src/oauth2/decodeJWT.d.ts +5 -0
  38. package/dist/src/oauth2/errors.d.ts +5 -0
  39. package/dist/src/oauth2/hooks.d.ts +2 -0
  40. package/dist/src/oauth2/httpUtils.d.ts +2 -0
  41. package/dist/src/oauth2/index.d.ts +10 -0
  42. package/dist/src/oauth2/pkceUtils.d.ts +6 -0
  43. package/dist/src/oauth2/timeUtils.d.ts +9 -0
  44. package/dist/src/types/ArchbaseSecurityTypes.d.ts +50 -0
  45. package/dist/src/types/ContextualAuthentication.d.ts +160 -0
  46. package/package.json +23 -22
  47. package/dist/archbase-security-3.0.0.tgz +0 -0
@@ -0,0 +1,160 @@
1
+ import { ArchbaseAccessToken } from '@archbase/core';
2
+ /**
3
+ * Objeto de contexto com informações específicas da aplicação
4
+ */
5
+ export interface ContextObject {
6
+ /** Tipo do contexto (WEB_ADMIN, STORE_APP, CUSTOMER_APP, etc.) */
7
+ type: string;
8
+ /** ID do admin/usuário no contexto específico */
9
+ adminId?: string;
10
+ /** ID da loja (para contexto STORE_APP) */
11
+ storeId?: string;
12
+ /** ID do cliente (para contexto CUSTOMER_APP) */
13
+ customerId?: string;
14
+ /** ID do motorista (para contexto DRIVER_APP) */
15
+ driverId?: string;
16
+ /** Nome do usuário no contexto */
17
+ name?: string;
18
+ /** Email do usuário no contexto */
19
+ email?: string;
20
+ /** Foto de perfil */
21
+ profilePicture?: string;
22
+ /** Nível de acesso (PLATFORM_ADMIN, STORE_ADMIN, etc.) */
23
+ accessLevel?: string;
24
+ /** Módulos disponíveis para o usuário */
25
+ availableModules?: string[];
26
+ /** Status do usuário no contexto */
27
+ status?: string;
28
+ /** Dados adicionais específicos do contexto */
29
+ [key: string]: any;
30
+ }
31
+ /**
32
+ * Usuário completo retornado pela autenticação contextual
33
+ */
34
+ export interface ContextualUser {
35
+ id: {
36
+ identifier: string;
37
+ };
38
+ code?: string;
39
+ version?: number;
40
+ updateEntityDate?: string;
41
+ createEntityDate?: string;
42
+ createdByUser?: string;
43
+ lastModifiedByUser?: string;
44
+ name: string;
45
+ description?: string;
46
+ accessSchedule?: any;
47
+ userName: string;
48
+ password?: string;
49
+ changePasswordOnNextLogin?: boolean;
50
+ allowPasswordChange?: boolean;
51
+ allowMultipleLogins?: boolean;
52
+ passwordNeverExpires?: boolean;
53
+ accountDeactivated?: boolean;
54
+ accountLocked?: boolean;
55
+ unlimitedAccessHours?: boolean;
56
+ isAdministrator?: boolean;
57
+ groups?: any[];
58
+ profile?: any;
59
+ avatar?: string | null;
60
+ email: string;
61
+ nickname?: string;
62
+ }
63
+ /**
64
+ * Response de autenticação contextual que inclui dados específicos do contexto
65
+ */
66
+ export interface ContextualAuthenticationResponse {
67
+ /** Token de acesso JWT */
68
+ access_token: string;
69
+ /** Token de refresh JWT */
70
+ refresh_token: string;
71
+ /** Timestamp absoluto de expiração */
72
+ expires_in: number;
73
+ /** ID token (UUID) */
74
+ id_token: string;
75
+ /** Tipo do token (BEARER) */
76
+ token_type: string;
77
+ /** Informações do usuário completas */
78
+ user: ContextualUser;
79
+ /** Contexto da aplicação com dados específicos */
80
+ context: ContextObject;
81
+ }
82
+ /**
83
+ * Request para login contextual
84
+ */
85
+ export interface ContextualAuthenticationRequest {
86
+ /** Email do usuário */
87
+ email: string;
88
+ /** Senha do usuário */
89
+ password: string;
90
+ /** Tipo do contexto da aplicação (WEB_ADMIN, STORE_APP, CUSTOMER_APP, etc.) */
91
+ context?: string;
92
+ /** Dados adicionais do contexto em formato JSON string */
93
+ contextData?: string;
94
+ }
95
+ /**
96
+ * Request para login flexível (email ou telefone)
97
+ */
98
+ export interface FlexibleLoginRequest {
99
+ /** Identificador (email ou telefone) */
100
+ identifier: string;
101
+ /** Senha do usuário */
102
+ password: string;
103
+ /** Tipo do contexto da aplicação */
104
+ context?: string;
105
+ }
106
+ /**
107
+ * Request para login social
108
+ */
109
+ export interface SocialLoginRequest {
110
+ /** Provedor social (google, facebook, apple) */
111
+ provider: string;
112
+ /** Token do provedor */
113
+ token: string;
114
+ /** Tipo do contexto da aplicação */
115
+ context?: string;
116
+ /** Dados adicionais do usuário */
117
+ additionalData?: string;
118
+ }
119
+ /**
120
+ * Request para registro de usuário
121
+ */
122
+ export interface RegisterUserRequest {
123
+ /** Nome do usuário */
124
+ name: string;
125
+ /** Email do usuário */
126
+ email: string;
127
+ /** Senha do usuário */
128
+ password: string;
129
+ /** Role do usuário */
130
+ role?: string;
131
+ /** Avatar do usuário */
132
+ avatar?: string;
133
+ /** Dados adicionais para lógica de negócio */
134
+ additionalData?: Record<string, any>;
135
+ }
136
+ /**
137
+ * Response para listar contextos suportados
138
+ */
139
+ export interface SupportedContextsResponse {
140
+ /** Lista de contextos suportados */
141
+ supportedContexts: string[];
142
+ /** Contexto padrão */
143
+ defaultContext: string;
144
+ }
145
+ /**
146
+ * Response para validação de contexto
147
+ */
148
+ export interface ContextValidationResponse {
149
+ /** Contexto validado */
150
+ context: string;
151
+ /** Se o contexto é suportado */
152
+ supported: boolean;
153
+ }
154
+ /**
155
+ * Token de acesso contextual que estende o token padrão
156
+ */
157
+ export interface ContextualAccessToken extends ArchbaseAccessToken {
158
+ /** Contexto da aplicação */
159
+ context?: ContextObject;
160
+ }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@archbase/security",
3
- "version": "3.0.0",
3
+ "version": "3.0.3",
4
4
  "description": "Security and authentication components for Archbase React",
5
- "main": "dist/index.js",
6
- "module": "dist/index.js",
7
- "types": "dist/index.d.ts",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
10
  "types": "./dist/index.d.ts",
@@ -25,41 +25,42 @@
25
25
  "author": "Edson Martins",
26
26
  "license": "MIT",
27
27
  "dependencies": {
28
- "react": "^19.0.0",
29
- "react-dom": "^19.0.0",
30
- "react-i18next": "^15.1.2",
28
+ "@archbase/components": "3.0.3",
29
+ "@archbase/core": "3.0.3",
30
+ "@archbase/data": "3.0.3",
31
+ "@archbase/layout": "3.0.3",
32
+ "crypto-js": "^4.1.1",
31
33
  "i18next": "^25.3.1",
32
- "lodash": "4.17.21",
33
34
  "inversify": "^6.0.1",
34
- "reflect-metadata": "^0.1.13",
35
- "crypto-js": "^4.1.1",
36
- "jwt-decode": "^4.0.0",
37
35
  "inversify-react": "^1.1.0",
36
+ "jwt-decode": "^4.0.0",
37
+ "lodash": "4.17.21",
38
+ "react": "^19.2.3",
39
+ "react-dom": "^19.2.3",
40
+ "react-i18next": "^15.1.2",
41
+ "reflect-metadata": "^0.1.13",
38
42
  "rxjs": "^7.8.2",
39
- "uuid": "^9.0.1",
40
- "@archbase/core": "3.0.0",
41
- "@archbase/data": "3.0.0",
42
- "@archbase/components": "3.0.0",
43
- "@archbase/layout": "3.0.0"
43
+ "uuid": "^9.0.1"
44
44
  },
45
45
  "devDependencies": {
46
- "@types/react": "^19.0.0",
47
- "@types/react-dom": "^19.0.0",
48
- "@types/lodash": "^4.14.200",
49
46
  "@types/crypto-js": "^4.1.1",
47
+ "@types/lodash": "^4.14.200",
48
+ "@types/react": "^19.0.6",
49
+ "@types/react-dom": "^19.0.2",
50
50
  "typescript": "^5.7.0",
51
51
  "vite": "^6.3.5",
52
+ "vite-plugin-dts": "^4.5.4",
52
53
  "vitest": "^2.0.0"
53
54
  },
54
55
  "peerDependencies": {
55
- "react": ">=18.0.0",
56
- "react-dom": ">=18.0.0",
57
56
  "@mantine/core": "8.3.12",
58
57
  "@mantine/dates": "8.3.12",
59
58
  "@mantine/hooks": "8.3.12",
60
59
  "@mantine/modals": "8.3.12",
61
60
  "@mantine/notifications": "8.3.12",
62
- "@tabler/icons-react": "^3.27.0"
61
+ "@tabler/icons-react": "^3.27.0",
62
+ "react": ">=18.0.0",
63
+ "react-dom": ">=18.0.0"
63
64
  },
64
65
  "scripts": {
65
66
  "build": "NODE_OPTIONS=\"--max-old-space-size=8192\" vite build",
Binary file