@archbase/security 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.
Files changed (45) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/src/ArchbaseAccessToken.d.ts +1 -0
  3. package/dist/src/ArchbaseAccessTokenService.d.ts +11 -0
  4. package/dist/src/ArchbaseApiTokenService.d.ts +12 -0
  5. package/dist/src/ArchbaseAuthenticator.d.ts +24 -0
  6. package/dist/src/ArchbaseGroupService.d.ts +10 -0
  7. package/dist/src/ArchbaseLogin.d.ts +30 -0
  8. package/dist/src/ArchbaseProfileService.d.ts +10 -0
  9. package/dist/src/ArchbaseResetPassword.d.ts +14 -0
  10. package/dist/src/ArchbaseResourceService.d.ts +16 -0
  11. package/dist/src/ArchbaseSecurityComponents.d.ts +40 -0
  12. package/dist/src/ArchbaseSecurityContext.d.ts +41 -0
  13. package/dist/src/ArchbaseSecurityHooks.d.ts +24 -0
  14. package/dist/src/ArchbaseSecurityManager.d.ts +58 -0
  15. package/dist/src/ArchbaseTenantManager.d.ts +22 -0
  16. package/dist/src/ArchbaseTokenManager.d.ts +1 -0
  17. package/dist/src/ArchbaseUser.d.ts +19 -0
  18. package/dist/src/ArchbaseUserService.d.ts +11 -0
  19. package/dist/src/DefaultArchbaseTokenManager.d.ts +20 -0
  20. package/dist/src/SecurityDomain.d.ts +221 -0
  21. package/dist/src/SecurityType.d.ts +5 -0
  22. package/dist/src/examples/ContextualAuthenticationExample.d.ts +113 -0
  23. package/dist/src/examples/SecurityExample.d.ts +2 -0
  24. package/dist/src/hooks/index.d.ts +5 -0
  25. package/dist/src/hooks/useArchbaseAuthenticationManager.d.ts +36 -0
  26. package/dist/src/hooks/useArchbaseGetCurrentToken.d.ts +4 -0
  27. package/dist/src/hooks/useArchbaseGetLoggedUser.d.ts +2 -0
  28. package/dist/src/hooks/useArchbaseResetPassword.d.ts +8 -0
  29. package/dist/src/hooks/useArchbaseSecurityManager.d.ts +11 -0
  30. package/dist/src/index.d.ts +27 -0
  31. package/dist/src/oauth2/AuthContext.d.ts +4 -0
  32. package/dist/src/oauth2/Types.d.ts +108 -0
  33. package/dist/src/oauth2/authConfig.d.ts +3 -0
  34. package/dist/src/oauth2/authentication.d.ts +9 -0
  35. package/dist/src/oauth2/decodeJWT.d.ts +5 -0
  36. package/dist/src/oauth2/errors.d.ts +5 -0
  37. package/dist/src/oauth2/hooks.d.ts +2 -0
  38. package/dist/src/oauth2/httpUtils.d.ts +2 -0
  39. package/dist/src/oauth2/index.d.ts +10 -0
  40. package/dist/src/oauth2/pkceUtils.d.ts +6 -0
  41. package/dist/src/oauth2/timeUtils.d.ts +9 -0
  42. package/dist/src/types/ArchbaseSecurityTypes.d.ts +50 -0
  43. package/dist/src/types/ContextualAuthentication.d.ts +160 -0
  44. package/package.json +23 -22
  45. package/dist/archbase-security-3.0.0.tgz +0 -0
@@ -0,0 +1,113 @@
1
+ import { ArchbaseAuthenticator, ArchbaseAccessToken, ContextualAuthenticationRequest, ContextualAuthenticationResponse, FlexibleLoginRequest, SocialLoginRequest, RegisterUserRequest } from '@archbase/security';
2
+ /**
3
+ * Exemplo de implementação de um ArchbaseAuthenticator com métodos contextuais opcionais
4
+ */
5
+ export declare class ExampleContextualAuthenticator implements ArchbaseAuthenticator {
6
+ login(username: string, password: string): Promise<ArchbaseAccessToken>;
7
+ refreshToken(refresh_token: string): Promise<ArchbaseAccessToken>;
8
+ sendResetPasswordEmail(email: string): Promise<void>;
9
+ resetPassword(email: string, passwordResetToken: string, newPassword: string): Promise<void>;
10
+ loginWithContext(request: ContextualAuthenticationRequest): Promise<{
11
+ access_token: string;
12
+ refresh_token: string;
13
+ expires_in: number;
14
+ id_token: string;
15
+ token_type: string;
16
+ user: {
17
+ id: {
18
+ identifier: string;
19
+ };
20
+ name: string;
21
+ description: string;
22
+ userName: string;
23
+ email: string;
24
+ createEntityDate: string;
25
+ version: number;
26
+ changePasswordOnNextLogin: boolean;
27
+ allowPasswordChange: boolean;
28
+ allowMultipleLogins: boolean;
29
+ passwordNeverExpires: boolean;
30
+ accountDeactivated: boolean;
31
+ accountLocked: boolean;
32
+ unlimitedAccessHours: boolean;
33
+ isAdministrator: boolean;
34
+ groups: any[];
35
+ profile: any;
36
+ avatar: any;
37
+ nickname: any;
38
+ };
39
+ context: {
40
+ type: any;
41
+ adminId: string;
42
+ name: string;
43
+ email: string;
44
+ profilePicture: any;
45
+ accessLevel: string;
46
+ availableModules: string[];
47
+ status: string;
48
+ };
49
+ }>;
50
+ loginFlexible(request: FlexibleLoginRequest): Promise<{
51
+ access_token: string;
52
+ refresh_token: string;
53
+ expires_in: number;
54
+ id_token: string;
55
+ token_type: string;
56
+ user: {
57
+ id: {
58
+ identifier: string;
59
+ };
60
+ name: string;
61
+ description: string;
62
+ userName: string;
63
+ email: string;
64
+ createEntityDate: string;
65
+ version: number;
66
+ changePasswordOnNextLogin: boolean;
67
+ allowPasswordChange: boolean;
68
+ allowMultipleLogins: boolean;
69
+ passwordNeverExpires: boolean;
70
+ accountDeactivated: boolean;
71
+ accountLocked: boolean;
72
+ unlimitedAccessHours: boolean;
73
+ isAdministrator: boolean;
74
+ groups: any[];
75
+ profile: any;
76
+ avatar: any;
77
+ nickname: any;
78
+ };
79
+ context: {
80
+ type: any;
81
+ adminId: string;
82
+ name: string;
83
+ email: string;
84
+ profilePicture: any;
85
+ accessLevel: string;
86
+ availableModules: string[];
87
+ status: string;
88
+ };
89
+ }>;
90
+ loginSocial(request: SocialLoginRequest): Promise<ContextualAuthenticationResponse>;
91
+ register(request: RegisterUserRequest): Promise<{
92
+ email: any;
93
+ businessId: string;
94
+ message: string;
95
+ }>;
96
+ getSupportedContexts(): Promise<{
97
+ supportedContexts: string[];
98
+ defaultContext: string;
99
+ }>;
100
+ validateContext(context: string): Promise<{
101
+ context: string;
102
+ supported: boolean;
103
+ }>;
104
+ private resolveEmailFromIdentifier;
105
+ }
106
+ /**
107
+ * Exemplo de uso do hook com recursos contextuais
108
+ */
109
+ export declare function ExampleUsageComponent(): any;
110
+ /**
111
+ * Exemplo de como verificar capacidades antes de usar
112
+ */
113
+ export declare function CapabilitiesExample(): any;
@@ -0,0 +1,2 @@
1
+ import { default as React } from 'react';
2
+ export declare const SecurityExample: React.FC;
@@ -0,0 +1,5 @@
1
+ export * from './useArchbaseSecurityManager';
2
+ export * from './useArchbaseGetLoggedUser';
3
+ export * from './useArchbaseAuthenticationManager';
4
+ export * from './useArchbaseGetCurrentToken';
5
+ export * from './useArchbaseResetPassword';
@@ -0,0 +1,36 @@
1
+ import { ContextualAuthenticationRequest, FlexibleLoginRequest, SocialLoginRequest, RegisterUserRequest, SupportedContextsResponse, ContextValidationResponse, ContextObject } from '../types/ContextualAuthentication';
2
+ export interface AuthenticationManagerReturnType {
3
+ login: (username: string, password: string, rememberMe: boolean) => void;
4
+ logout: (clearRememberMe?: boolean) => void;
5
+ username: string;
6
+ isAuthenticating: boolean;
7
+ isInitializing: boolean;
8
+ isAuthenticated: boolean;
9
+ isError: boolean;
10
+ error: any;
11
+ clearError: () => void;
12
+ accessToken?: string | null;
13
+ loginWithContext?: (request: ContextualAuthenticationRequest, rememberMe?: boolean) => Promise<void>;
14
+ loginFlexible?: (request: FlexibleLoginRequest, rememberMe?: boolean) => Promise<void>;
15
+ loginSocial?: (request: SocialLoginRequest) => Promise<void>;
16
+ register?: (request: RegisterUserRequest) => Promise<{
17
+ email: string;
18
+ businessId?: string;
19
+ message: string;
20
+ }>;
21
+ getSupportedContexts?: () => Promise<SupportedContextsResponse>;
22
+ validateContext?: (context: string) => Promise<ContextValidationResponse>;
23
+ context?: ContextObject | null;
24
+ capabilities: {
25
+ hasContextualLogin: boolean;
26
+ hasFlexibleLogin: boolean;
27
+ hasSocialLogin: boolean;
28
+ hasRegistration: boolean;
29
+ hasContextSupport: boolean;
30
+ };
31
+ }
32
+ export interface ArchbaseAuthenticationManagerProps {
33
+ checkIntervalTokenHasExpired?: number;
34
+ expirationThresholdOfToken?: number;
35
+ }
36
+ export declare const useArchbaseAuthenticationManager: ({ checkIntervalTokenHasExpired, expirationThresholdOfToken }: ArchbaseAuthenticationManagerProps) => AuthenticationManagerReturnType;
@@ -0,0 +1,4 @@
1
+ export interface GetCurrentTokenReturnType {
2
+ token: string | null;
3
+ }
4
+ export declare const useArchbaseGetCurrentToken: () => GetCurrentTokenReturnType;
@@ -0,0 +1,2 @@
1
+ import { ArchbaseUser } from '../ArchbaseUser';
2
+ export declare const useArchbaseGetLoggedUser: () => ArchbaseUser | null;
@@ -0,0 +1,8 @@
1
+ export interface ResetPasswordReturnType {
2
+ sendResetPasswordEmail: (email: string) => Promise<void>;
3
+ resetPassword: (email: string, passwordResetToken: string, newPassword: string) => Promise<void>;
4
+ isError: boolean;
5
+ error: any;
6
+ clearError: () => void;
7
+ }
8
+ export declare const useArchbaseResetPassword: () => ResetPasswordReturnType;
@@ -0,0 +1,11 @@
1
+ import { ArchbaseSecurityManager } from '../ArchbaseSecurityManager';
2
+ export declare const ARCHBASE_SECURITY_MANAGER_STORE = "archbaseSecurityManagerStore";
3
+ export type UseArchbaseSecurityManagerProps = {
4
+ resourceName: string;
5
+ resourceDescription: string;
6
+ enableSecurity?: boolean;
7
+ };
8
+ export type UseArchbaseSecurityManagerReturnType = {
9
+ securityManager: ArchbaseSecurityManager;
10
+ };
11
+ export declare const useArchbaseSecurityManager: ({ resourceName, resourceDescription, enableSecurity }: UseArchbaseSecurityManagerProps) => UseArchbaseSecurityManagerReturnType;
@@ -0,0 +1,27 @@
1
+ export * from './ArchbaseAccessToken';
2
+ export * from './ArchbaseAuthenticator';
3
+ export * from './ArchbaseTokenManager';
4
+ export * from './ArchbaseUser';
5
+ export * from './DefaultArchbaseTokenManager';
6
+ export * from './types/ContextualAuthentication';
7
+ export * from './oauth2';
8
+ export * from './ArchbaseSecurityManager';
9
+ export * from './ArchbaseTenantManager';
10
+ export * from './ArchbaseUserService';
11
+ export * from './ArchbaseGroupService';
12
+ export * from './ArchbaseProfileService';
13
+ export * from './ArchbaseApiTokenService';
14
+ export * from './ArchbaseAccessTokenService';
15
+ export * from './ArchbaseResourceService';
16
+ export * from './ArchbaseLogin';
17
+ export * from './ArchbaseResetPassword';
18
+ export * from './SecurityType';
19
+ export * from './SecurityDomain';
20
+ export * from './hooks';
21
+ export { ArchbaseSecurityProvider, ArchbaseViewSecurityProvider } from './ArchbaseSecurityContext';
22
+ export { useArchbaseSecurity, useArchbaseViewSecurity, useArchbaseSecureForm, useArchbasePermissionCheck } from './ArchbaseSecurityHooks';
23
+ export { ArchbaseProtectedComponent, ArchbaseSecureActionButton, ArchbaseSecureFormField, withArchbaseSecurity } from './ArchbaseSecurityComponents';
24
+ export type { ArchbaseSecurityContextType, ArchbaseViewSecurityContextType, ArchbaseSecurityProviderProps, ArchbaseViewSecurityProviderProps } from './ArchbaseSecurityContext';
25
+ export type { ArchbaseProtectedComponentProps, ArchbaseSecureActionButtonProps, ArchbaseSecureFormFieldProps } from './ArchbaseSecurityComponents';
26
+ export type { UseArchbaseSecureFormReturn } from './ArchbaseSecurityHooks';
27
+ export type * from './types/ArchbaseSecurityTypes';
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+ import { IArchbaseAuthContext, IArchbaseAuthProvider } from './Types';
3
+ export declare const ArchbaseAuthContext: React.Context<IArchbaseAuthContext>;
4
+ export declare const ArchbaseAuthProvider: ({ authConfig, children }: IArchbaseAuthProvider) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,108 @@
1
+ import { ReactNode } from 'react';
2
+ interface TTokenRqBase {
3
+ grant_type: string;
4
+ scope?: string;
5
+ client_id: string;
6
+ redirect_uri: string;
7
+ }
8
+ export interface TTokenRequestWithCodeAndVerifier extends TTokenRqBase {
9
+ code: string;
10
+ code_verifier: string;
11
+ }
12
+ export interface TTokenRequestForRefresh extends TTokenRqBase {
13
+ refresh_token: string;
14
+ }
15
+ export type TTokenRequest = TTokenRequestWithCodeAndVerifier | TTokenRequestForRefresh;
16
+ export type TTokenData = {
17
+ [x: string]: any;
18
+ };
19
+ export type TTokenResponse = {
20
+ access_token: string;
21
+ scope: string;
22
+ token_type: string;
23
+ expires_in?: number;
24
+ refresh_token?: string;
25
+ refresh_token_expires_in?: number;
26
+ refresh_expires_in?: number;
27
+ id_token?: string;
28
+ };
29
+ export interface IArchbaseAuthProvider {
30
+ authConfig: TArchbaseAuthConfig;
31
+ children: ReactNode;
32
+ }
33
+ export interface IArchbaseAuthContext {
34
+ token: string;
35
+ logOut: (state?: string, logoutHint?: string) => void;
36
+ login: (state?: string) => void;
37
+ error: string | null;
38
+ tokenData?: TTokenData;
39
+ idToken?: string;
40
+ idTokenData?: TTokenData;
41
+ loginInProgress: boolean;
42
+ }
43
+ export type TArchbaseAuthConfig = {
44
+ clientId: string;
45
+ authorizationEndpoint: string;
46
+ tokenEndpoint: string;
47
+ redirectUri: string;
48
+ scope?: string;
49
+ state?: string;
50
+ logoutEndpoint?: string;
51
+ logoutRedirect?: string;
52
+ preLogin?: () => void;
53
+ postLogin?: () => void;
54
+ onRefreshTokenExpire?: (event: TArchbaseRefreshTokenExpiredEvent) => void;
55
+ decodeToken?: boolean;
56
+ autoLogin?: boolean;
57
+ clearURL?: boolean;
58
+ extraAuthParams?: {
59
+ [key: string]: string | boolean | number;
60
+ };
61
+ extraAuthParameters?: {
62
+ [key: string]: string | boolean | number;
63
+ };
64
+ extraTokenParameters?: {
65
+ [key: string]: string | boolean | number;
66
+ };
67
+ extraLogoutParameters?: {
68
+ [key: string]: string | boolean | number;
69
+ };
70
+ tokenExpiresIn?: number;
71
+ refreshTokenExpiresIn?: number;
72
+ storage?: 'session' | 'local';
73
+ };
74
+ export type TArchbaseRefreshTokenExpiredEvent = {
75
+ login: () => void;
76
+ };
77
+ export type TInternalConfig = {
78
+ clientId: string;
79
+ authorizationEndpoint: string;
80
+ tokenEndpoint: string;
81
+ redirectUri: string;
82
+ scope?: string;
83
+ state?: string;
84
+ logoutEndpoint?: string;
85
+ logoutRedirect?: string;
86
+ preLogin?: () => void;
87
+ postLogin?: () => void;
88
+ onRefreshTokenExpire?: (event: TArchbaseRefreshTokenExpiredEvent) => void;
89
+ decodeToken: boolean;
90
+ autoLogin: boolean;
91
+ clearURL: boolean;
92
+ extraAuthParams?: {
93
+ [key: string]: string | boolean | number;
94
+ };
95
+ extraAuthParameters?: {
96
+ [key: string]: string | boolean | number;
97
+ };
98
+ extraTokenParameters?: {
99
+ [key: string]: string | boolean | number;
100
+ };
101
+ extraLogoutParameters?: {
102
+ [key: string]: string | boolean | number;
103
+ };
104
+ tokenExpiresIn?: number;
105
+ refreshTokenExpiresIn?: number;
106
+ storage: 'session' | 'local';
107
+ };
108
+ export {};
@@ -0,0 +1,3 @@
1
+ import { TArchbaseAuthConfig, TInternalConfig } from './Types';
2
+ export declare function createInternalConfig(passedConfig: TArchbaseAuthConfig): TInternalConfig;
3
+ export declare function validateConfig(config: TInternalConfig): void;
@@ -0,0 +1,9 @@
1
+ import { TInternalConfig, TTokenResponse } from './Types';
2
+ export declare function redirectToLogin(config: TInternalConfig, customState?: string): Promise<void>;
3
+ export declare const fetchTokens: (config: TInternalConfig) => Promise<TTokenResponse>;
4
+ export declare const fetchWithRefreshToken: (props: {
5
+ config: TInternalConfig;
6
+ refreshToken: string;
7
+ }) => Promise<TTokenResponse>;
8
+ export declare function redirectToLogout(config: TInternalConfig, token: string, refresh_token?: string, idToken?: string, state?: string, logoutHint?: string): void;
9
+ export declare function validateState(urlParams: URLSearchParams): void;
@@ -0,0 +1,5 @@
1
+ import { TTokenData } from './Types';
2
+ /**
3
+ * Decodifica o JWT codificado em base64. Retorna um TToken.
4
+ */
5
+ export declare const decodeJWT: (token: string) => TTokenData;
@@ -0,0 +1,5 @@
1
+ export declare class FetchError extends Error {
2
+ status: number;
3
+ statusText: string;
4
+ constructor(status: number, statusText: string, message: string);
5
+ }
@@ -0,0 +1,2 @@
1
+ declare function useBrowserStorage<T>(key: string, initialValue: T, type: 'session' | 'local'): [T, (v: T) => void];
2
+ export default useBrowserStorage;
@@ -0,0 +1,2 @@
1
+ import { TTokenRequest } from './Types';
2
+ export declare function postWithXForm(url: string, request: TTokenRequest): Promise<Response>;
@@ -0,0 +1,10 @@
1
+ export { ArchbaseAuthProvider, ArchbaseAuthContext } from './AuthContext';
2
+ export type { TArchbaseAuthConfig, IArchbaseAuthProvider, IArchbaseAuthContext, TArchbaseRefreshTokenExpiredEvent, TTokenRequestWithCodeAndVerifier, TTokenRequestForRefresh, TTokenRequest, TTokenData, TTokenResponse, TInternalConfig, } from './Types';
3
+ export { epochAtSecondsFromNow, epochTimeIsPast, getRefreshExpiresIn } from './timeUtils';
4
+ export { getRandomInteger, generateRandomString, generateCodeChallenge } from './pkceUtils';
5
+ export { postWithXForm } from './httpUtils';
6
+ export * as useBrowserStorage from './hooks';
7
+ export { FetchError } from './errors';
8
+ export { decodeJWT } from './decodeJWT';
9
+ export { redirectToLogin, fetchTokens, fetchWithRefreshToken, redirectToLogout, validateState } from './authentication';
10
+ export { createInternalConfig, validateConfig } from './authConfig';
@@ -0,0 +1,6 @@
1
+ export declare function getRandomInteger(range: number): number;
2
+ export declare function generateRandomString(length: number): string;
3
+ /**
4
+ * PKCE Code Challenge = base64url(hash(codeVerifier))
5
+ */
6
+ export declare function generateCodeChallenge(codeVerifier: string): Promise<string>;
@@ -0,0 +1,9 @@
1
+ import { TTokenResponse } from './Types';
2
+ export declare const FALLBACK_EXPIRE_TIME = 600;
3
+ export declare const epochAtSecondsFromNow: (secondsFromNow: number) => number;
4
+ /**
5
+ * Verifique se o token de acesso expirou.
6
+ * Retornará True se o token expirou OU falta menos de 30 segundos para expirar.
7
+ */
8
+ export declare function epochTimeIsPast(timestamp: number): boolean;
9
+ export declare function getRefreshExpiresIn(tokenExpiresIn: number, response: TTokenResponse): number;
@@ -0,0 +1,50 @@
1
+ import { ReactNode } from 'react';
2
+ import { ArchbaseSecurityManager } from '../ArchbaseSecurityManager';
3
+ import { UserDto } from '../SecurityDomain';
4
+ export interface ArchbaseSecurityError {
5
+ code: string;
6
+ message: string;
7
+ details?: any;
8
+ }
9
+ export type ArchbasePermissionAction = string;
10
+ export type ArchbasePermissionList = ArchbasePermissionAction[];
11
+ export interface ArchbaseGlobalSecurityState {
12
+ user: UserDto | null;
13
+ isAuthenticated: boolean;
14
+ isLoading: boolean;
15
+ error: ArchbaseSecurityError | null;
16
+ }
17
+ export interface ArchbaseViewSecurityConfig {
18
+ resourceName: string;
19
+ resourceDescription: string;
20
+ requiredPermissions?: ArchbasePermissionList;
21
+ autoRegisterActions?: boolean;
22
+ strictMode?: boolean;
23
+ }
24
+ export interface ArchbaseProtectionConfig {
25
+ actionName?: ArchbasePermissionAction;
26
+ requiredPermissions?: ArchbasePermissionList;
27
+ requireAll?: boolean;
28
+ fallback?: ReactNode;
29
+ autoRegister?: boolean;
30
+ }
31
+ export type ArchbaseSecurityCallback = (manager: ArchbaseSecurityManager) => void;
32
+ export type ArchbaseErrorCallback = (error: string) => void;
33
+ export interface ArchbasePermissionCheckResult {
34
+ hasAccess: boolean;
35
+ missingPermissions?: ArchbasePermissionList;
36
+ reason?: string;
37
+ }
38
+ export declare enum ArchbaseFallbackType {
39
+ HIDDEN = "hidden",
40
+ DISABLED = "disabled",
41
+ MESSAGE = "message",
42
+ CUSTOM = "custom"
43
+ }
44
+ export interface ArchbaseAdvancedSecurityConfig extends ArchbaseViewSecurityConfig {
45
+ fallbackType?: ArchbaseFallbackType;
46
+ customFallback?: ReactNode;
47
+ onAccessDenied?: (missingPermissions: ArchbasePermissionList) => void;
48
+ onError?: ArchbaseErrorCallback;
49
+ debugMode?: boolean;
50
+ }
@@ -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
+ }