@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.
- package/LICENSE +21 -0
- package/README.md +51 -0
- package/dist/index.d.ts +2 -0
- package/dist/src/ArchbaseAccessToken.d.ts +1 -0
- package/dist/src/ArchbaseAccessTokenService.d.ts +11 -0
- package/dist/src/ArchbaseApiTokenService.d.ts +12 -0
- package/dist/src/ArchbaseAuthenticator.d.ts +24 -0
- package/dist/src/ArchbaseGroupService.d.ts +10 -0
- package/dist/src/ArchbaseLogin.d.ts +30 -0
- package/dist/src/ArchbaseProfileService.d.ts +10 -0
- package/dist/src/ArchbaseResetPassword.d.ts +14 -0
- package/dist/src/ArchbaseResourceService.d.ts +16 -0
- package/dist/src/ArchbaseSecurityComponents.d.ts +40 -0
- package/dist/src/ArchbaseSecurityContext.d.ts +41 -0
- package/dist/src/ArchbaseSecurityHooks.d.ts +24 -0
- package/dist/src/ArchbaseSecurityManager.d.ts +58 -0
- package/dist/src/ArchbaseTenantManager.d.ts +22 -0
- package/dist/src/ArchbaseTokenManager.d.ts +1 -0
- package/dist/src/ArchbaseUser.d.ts +19 -0
- package/dist/src/ArchbaseUserService.d.ts +11 -0
- package/dist/src/DefaultArchbaseTokenManager.d.ts +20 -0
- package/dist/src/SecurityDomain.d.ts +221 -0
- package/dist/src/SecurityType.d.ts +5 -0
- package/dist/src/examples/ContextualAuthenticationExample.d.ts +113 -0
- package/dist/src/examples/SecurityExample.d.ts +2 -0
- package/dist/src/hooks/index.d.ts +5 -0
- package/dist/src/hooks/useArchbaseAuthenticationManager.d.ts +36 -0
- package/dist/src/hooks/useArchbaseGetCurrentToken.d.ts +4 -0
- package/dist/src/hooks/useArchbaseGetLoggedUser.d.ts +2 -0
- package/dist/src/hooks/useArchbaseResetPassword.d.ts +8 -0
- package/dist/src/hooks/useArchbaseSecurityManager.d.ts +11 -0
- package/dist/src/index.d.ts +27 -0
- package/dist/src/oauth2/AuthContext.d.ts +4 -0
- package/dist/src/oauth2/Types.d.ts +108 -0
- package/dist/src/oauth2/authConfig.d.ts +3 -0
- package/dist/src/oauth2/authentication.d.ts +9 -0
- package/dist/src/oauth2/decodeJWT.d.ts +5 -0
- package/dist/src/oauth2/errors.d.ts +5 -0
- package/dist/src/oauth2/hooks.d.ts +2 -0
- package/dist/src/oauth2/httpUtils.d.ts +2 -0
- package/dist/src/oauth2/index.d.ts +10 -0
- package/dist/src/oauth2/pkceUtils.d.ts +6 -0
- package/dist/src/oauth2/timeUtils.d.ts +9 -0
- package/dist/src/types/ArchbaseSecurityTypes.d.ts +50 -0
- package/dist/src/types/ContextualAuthentication.d.ts +160 -0
- package/package.json +23 -22
- package/dist/archbase-security-3.0.0.tgz +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Edson Martins
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# @archbase/security
|
|
2
|
+
|
|
3
|
+
Security and authentication components for Archbase React.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @archbase/security
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @archbase/security
|
|
11
|
+
# or
|
|
12
|
+
yarn add @archbase/security
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- **Authentication**: JWT-based authentication
|
|
18
|
+
- **Authorization**: Role-based access control
|
|
19
|
+
- **Crypto Utilities**: Crypto-js wrapper utilities
|
|
20
|
+
- **Session Management**: Session handling and persistence
|
|
21
|
+
- **Security Context**: Global security state management
|
|
22
|
+
|
|
23
|
+
## Dependencies
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"@mantine/core": "8.3.12",
|
|
28
|
+
"@mantine/hooks": "8.3.12",
|
|
29
|
+
"@tabler/icons-react": "^3.27.0",
|
|
30
|
+
"react": ">=18.0.0",
|
|
31
|
+
"react-dom": ">=18.0.0"
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import {
|
|
39
|
+
useAuth,
|
|
40
|
+
SecurityProvider,
|
|
41
|
+
ProtectedRoute
|
|
42
|
+
} from '@archbase/security';
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
|
|
47
|
+
MIT © Edson Martins
|
|
48
|
+
|
|
49
|
+
## Documentation
|
|
50
|
+
|
|
51
|
+
For full documentation, visit [https://react.archbase.dev](https://react.archbase.dev)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { ArchbaseAccessToken } from '@archbase/core';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ArchbaseEntityTransformer, ArchbaseRemoteApiClient, ArchbaseRemoteApiService } from '@archbase/data';
|
|
2
|
+
import { AccessTokenDto } from './SecurityDomain';
|
|
3
|
+
export declare class ArchbaseAccessTokenService extends ArchbaseRemoteApiService<AccessTokenDto, string> implements ArchbaseEntityTransformer<AccessTokenDto> {
|
|
4
|
+
constructor(client: ArchbaseRemoteApiClient);
|
|
5
|
+
protected configureHeaders(): Record<string, string>;
|
|
6
|
+
transform(entity: AccessTokenDto): AccessTokenDto;
|
|
7
|
+
protected getEndpoint(): string;
|
|
8
|
+
getId(entity: AccessTokenDto): string;
|
|
9
|
+
isNewRecord(entity: AccessTokenDto): boolean;
|
|
10
|
+
revoke(token: string): Promise<undefined>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ArchbaseEntityTransformer, ArchbaseRemoteApiClient, ArchbaseRemoteApiService } from '@archbase/data';
|
|
2
|
+
import { ApiTokenDto } from './SecurityDomain';
|
|
3
|
+
export declare class ArchbaseApiTokenService extends ArchbaseRemoteApiService<ApiTokenDto, string> implements ArchbaseEntityTransformer<ApiTokenDto> {
|
|
4
|
+
constructor(client: ArchbaseRemoteApiClient);
|
|
5
|
+
protected configureHeaders(): Record<string, string>;
|
|
6
|
+
transform(entity: ApiTokenDto): ApiTokenDto;
|
|
7
|
+
protected getEndpoint(): string;
|
|
8
|
+
getId(entity: ApiTokenDto): string;
|
|
9
|
+
isNewRecord(entity: ApiTokenDto): boolean;
|
|
10
|
+
create(email: string, expirationDate: string, name: string, description: string): Promise<ApiTokenDto>;
|
|
11
|
+
revoke(token: string): Promise<undefined>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ArchbaseAccessToken } from './ArchbaseAccessToken';
|
|
2
|
+
import { ContextualAuthenticationResponse, ContextualAuthenticationRequest, FlexibleLoginRequest, SocialLoginRequest, RegisterUserRequest, SupportedContextsResponse, ContextValidationResponse } from './types/ContextualAuthentication';
|
|
3
|
+
export interface ArchbaseAuthenticator {
|
|
4
|
+
login(username: string, password: string): Promise<ArchbaseAccessToken>;
|
|
5
|
+
refreshToken(refresh_token: string): Promise<ArchbaseAccessToken>;
|
|
6
|
+
sendResetPasswordEmail(email: string): Promise<void>;
|
|
7
|
+
resetPassword(email: string, passwordResetToken: string, newPassword: string): Promise<void>;
|
|
8
|
+
/** Login contextual com suporte a enrichers específicos da aplicação */
|
|
9
|
+
loginWithContext?(request: ContextualAuthenticationRequest): Promise<ContextualAuthenticationResponse>;
|
|
10
|
+
/** Login flexível com email ou telefone */
|
|
11
|
+
loginFlexible?(request: FlexibleLoginRequest): Promise<ContextualAuthenticationResponse>;
|
|
12
|
+
/** Login via provedores sociais (Google, Facebook, Apple) */
|
|
13
|
+
loginSocial?(request: SocialLoginRequest): Promise<ContextualAuthenticationResponse>;
|
|
14
|
+
/** Registro de usuário com dados adicionais de negócio */
|
|
15
|
+
register?(request: RegisterUserRequest): Promise<{
|
|
16
|
+
email: string;
|
|
17
|
+
businessId?: string;
|
|
18
|
+
message: string;
|
|
19
|
+
}>;
|
|
20
|
+
/** Lista contextos suportados pela implementação */
|
|
21
|
+
getSupportedContexts?(): Promise<SupportedContextsResponse>;
|
|
22
|
+
/** Valida se um contexto específico é suportado */
|
|
23
|
+
validateContext?(context: string): Promise<ContextValidationResponse>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ArchbaseRemoteApiService, ArchbaseEntityTransformer, ArchbaseRemoteApiClient } from '@archbase/data';
|
|
2
|
+
import { GroupDto } from './SecurityDomain';
|
|
3
|
+
export declare class ArchbaseGroupService extends ArchbaseRemoteApiService<GroupDto, string> implements ArchbaseEntityTransformer<GroupDto> {
|
|
4
|
+
constructor(client: ArchbaseRemoteApiClient);
|
|
5
|
+
protected configureHeaders(): Record<string, string>;
|
|
6
|
+
transform(entity: GroupDto): GroupDto;
|
|
7
|
+
protected getEndpoint(): string;
|
|
8
|
+
getId(entity: GroupDto): string;
|
|
9
|
+
isNewRecord(entity: GroupDto): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { CardProps } from '@mantine/core';
|
|
3
|
+
export interface MockUser {
|
|
4
|
+
email: string;
|
|
5
|
+
password: string;
|
|
6
|
+
type: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ArchbaseLoginOptions {
|
|
9
|
+
customContentBefore?: React.ReactNode;
|
|
10
|
+
afterInputs?: React.ReactNode;
|
|
11
|
+
customContentAfter?: React.ReactNode;
|
|
12
|
+
cardProps?: CardProps;
|
|
13
|
+
}
|
|
14
|
+
export interface ArchbaseLoginProps {
|
|
15
|
+
onLogin: (username: string, password: string, rememberMe: boolean) => Promise<void>;
|
|
16
|
+
error?: string;
|
|
17
|
+
onClickForgotPassword?: () => void;
|
|
18
|
+
loginLabel?: string;
|
|
19
|
+
loginPlaceholder?: string;
|
|
20
|
+
afterInputs?: ReactNode;
|
|
21
|
+
showMockUsersSelector?: boolean;
|
|
22
|
+
mockUsers?: MockUser[];
|
|
23
|
+
mockUsersGroupMap?: Record<string, string>;
|
|
24
|
+
options?: ArchbaseLoginOptions;
|
|
25
|
+
onChangeUsername?: (username: string) => void;
|
|
26
|
+
disabledLogin?: boolean;
|
|
27
|
+
isCheckingUsername?: boolean;
|
|
28
|
+
showSignIn?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare function ArchbaseLogin({ onLogin, error, onClickForgotPassword, loginLabel, loginPlaceholder, afterInputs, showMockUsersSelector, mockUsers, mockUsersGroupMap, options, onChangeUsername, disabledLogin, isCheckingUsername, showSignIn, }: ArchbaseLoginProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ArchbaseRemoteApiService, ArchbaseEntityTransformer, ArchbaseRemoteApiClient } from '@archbase/data';
|
|
2
|
+
import { ProfileDto } from './SecurityDomain';
|
|
3
|
+
export declare class ArchbaseProfileService extends ArchbaseRemoteApiService<ProfileDto, string> implements ArchbaseEntityTransformer<ProfileDto> {
|
|
4
|
+
constructor(client: ArchbaseRemoteApiClient);
|
|
5
|
+
protected configureHeaders(): Record<string, string>;
|
|
6
|
+
transform(entity: ProfileDto): ProfileDto;
|
|
7
|
+
protected getEndpoint(): string;
|
|
8
|
+
getId(entity: ProfileDto): string;
|
|
9
|
+
isNewRecord(entity: ProfileDto): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CSSProperties } from '@mantine/core';
|
|
2
|
+
export interface ArchbaseResetPasswordProps {
|
|
3
|
+
error?: string;
|
|
4
|
+
initialEmail?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
onSendResetPasswordEmail: (email: string) => Promise<void>;
|
|
7
|
+
onResetPassword: (email: string, passwordResetToken: string, newPassword: string) => Promise<void>;
|
|
8
|
+
onClickBackToLogin: () => void;
|
|
9
|
+
validatePassword?: () => string;
|
|
10
|
+
validateToken?: () => string;
|
|
11
|
+
/** Estilo do card */
|
|
12
|
+
style?: CSSProperties;
|
|
13
|
+
}
|
|
14
|
+
export declare function ArchbaseResetPassword({ error, onSendResetPasswordEmail, onResetPassword, onClickBackToLogin, validatePassword, validateToken, initialEmail, description, style }: ArchbaseResetPasswordProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ArchbaseEntityTransformer, ArchbaseRemoteApiClient, ArchbaseRemoteApiService } from '@archbase/data';
|
|
2
|
+
import { ResouceActionPermissionDto, ResoucePermissionsWithTypeDto, ResourceDto, ResourcePermissionsDto, ResourceRegisterDto } from './SecurityDomain';
|
|
3
|
+
import { SecurityType } from './SecurityType';
|
|
4
|
+
export declare class ArchbaseResourceService extends ArchbaseRemoteApiService<ResourceDto, string> implements ArchbaseEntityTransformer<ResourceDto> {
|
|
5
|
+
constructor(client: ArchbaseRemoteApiClient);
|
|
6
|
+
protected configureHeaders(): Record<string, string>;
|
|
7
|
+
transform(entity: ResourceDto): ResourceDto;
|
|
8
|
+
protected getEndpoint(): string;
|
|
9
|
+
getId(entity: ResourceDto): string;
|
|
10
|
+
isNewRecord(entity: ResourceDto): boolean;
|
|
11
|
+
getAllPermissionsAvailable(): Promise<ResoucePermissionsWithTypeDto[]>;
|
|
12
|
+
getPermissionsBySecurityId(securityId: string, type: SecurityType): Promise<ResoucePermissionsWithTypeDto[]>;
|
|
13
|
+
createPermission(securityId: string, actionId: string, type: SecurityType): Promise<ResouceActionPermissionDto>;
|
|
14
|
+
deletePermission(permissionId: string): Promise<void>;
|
|
15
|
+
registerResource(resourceRegister: ResourceRegisterDto): Promise<ResourcePermissionsDto>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
export interface ArchbaseProtectedComponentProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
actionName?: string;
|
|
5
|
+
requiredPermissions?: string[];
|
|
6
|
+
requireAll?: boolean;
|
|
7
|
+
actionDescription?: string;
|
|
8
|
+
fallback?: ReactNode;
|
|
9
|
+
autoRegister?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const ArchbaseProtectedComponent: React.FC<ArchbaseProtectedComponentProps>;
|
|
12
|
+
export interface ArchbaseSecureActionButtonProps {
|
|
13
|
+
actionName: string;
|
|
14
|
+
actionDescription: string;
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
onClick?: () => void;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
className?: string;
|
|
19
|
+
style?: React.CSSProperties;
|
|
20
|
+
variant?: 'primary' | 'secondary' | 'danger' | 'success' | 'warning';
|
|
21
|
+
size?: 'small' | 'medium' | 'large';
|
|
22
|
+
type?: 'button' | 'submit' | 'reset';
|
|
23
|
+
}
|
|
24
|
+
export declare const ArchbaseSecureActionButton: React.FC<ArchbaseSecureActionButtonProps>;
|
|
25
|
+
export interface ArchbaseSecureFormFieldProps {
|
|
26
|
+
children: ReactNode;
|
|
27
|
+
actionName?: string;
|
|
28
|
+
actionDescription?: string;
|
|
29
|
+
showLabel?: boolean;
|
|
30
|
+
label?: string;
|
|
31
|
+
fallbackText?: string;
|
|
32
|
+
fallbackComponent?: ReactNode;
|
|
33
|
+
}
|
|
34
|
+
export declare const ArchbaseSecureFormField: React.FC<ArchbaseSecureFormFieldProps>;
|
|
35
|
+
export declare function withArchbaseSecurity<P extends object>(WrappedComponent: React.ComponentType<P>, securityOptions: {
|
|
36
|
+
resourceName: string;
|
|
37
|
+
resourceDescription: string;
|
|
38
|
+
requiredPermissions?: string[];
|
|
39
|
+
fallbackComponent?: ReactNode;
|
|
40
|
+
}): (props: P) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
import { ArchbaseSecurityManager } from './ArchbaseSecurityManager';
|
|
3
|
+
import { UserDto } from './SecurityDomain';
|
|
4
|
+
export interface ArchbaseSecurityContextType {
|
|
5
|
+
user: UserDto | null;
|
|
6
|
+
isLoading: boolean;
|
|
7
|
+
hasGlobalPermission: (actionName: string) => boolean;
|
|
8
|
+
hasAnyGlobalPermission: (actions: string[]) => boolean;
|
|
9
|
+
hasAllGlobalPermissions: (actions: string[]) => boolean;
|
|
10
|
+
isAdmin: boolean;
|
|
11
|
+
error: string | null;
|
|
12
|
+
setError: (error: string | null) => void;
|
|
13
|
+
}
|
|
14
|
+
declare const ArchbaseSecurityContext: React.Context<ArchbaseSecurityContextType>;
|
|
15
|
+
export interface ArchbaseSecurityProviderProps {
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
user: UserDto | null;
|
|
18
|
+
onError?: (error: string) => void;
|
|
19
|
+
}
|
|
20
|
+
export declare const ArchbaseSecurityProvider: React.FC<ArchbaseSecurityProviderProps>;
|
|
21
|
+
export interface ArchbaseViewSecurityContextType {
|
|
22
|
+
securityManager: ArchbaseSecurityManager | null;
|
|
23
|
+
hasPermission: (actionName: string) => boolean;
|
|
24
|
+
hasAnyPermission: (actions: string[]) => boolean;
|
|
25
|
+
hasAllPermissions: (actions: string[]) => boolean;
|
|
26
|
+
registerAction: (actionName: string, actionDescription: string) => void;
|
|
27
|
+
isLoading: boolean;
|
|
28
|
+
error: string | null;
|
|
29
|
+
}
|
|
30
|
+
declare const ArchbaseViewSecurityContext: React.Context<ArchbaseViewSecurityContextType>;
|
|
31
|
+
export interface ArchbaseViewSecurityProviderProps {
|
|
32
|
+
children: ReactNode;
|
|
33
|
+
resourceName: string;
|
|
34
|
+
resourceDescription: string;
|
|
35
|
+
requiredPermissions?: string[];
|
|
36
|
+
fallbackComponent?: ReactNode;
|
|
37
|
+
onSecurityReady?: (manager: ArchbaseSecurityManager) => void;
|
|
38
|
+
onError?: (error: string) => void;
|
|
39
|
+
}
|
|
40
|
+
export declare const ArchbaseViewSecurityProvider: React.FC<ArchbaseViewSecurityProviderProps>;
|
|
41
|
+
export { ArchbaseSecurityContext, ArchbaseViewSecurityContext };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ArchbaseSecurityContextType, ArchbaseViewSecurityContextType } from './ArchbaseSecurityContext';
|
|
2
|
+
export declare const useArchbaseSecurity: () => ArchbaseSecurityContextType;
|
|
3
|
+
export declare const useArchbaseViewSecurity: () => ArchbaseViewSecurityContextType;
|
|
4
|
+
export interface UseArchbaseSecureFormReturn {
|
|
5
|
+
hasPermission: (actionName: string) => boolean;
|
|
6
|
+
hasAnyPermission: (actions: string[]) => boolean;
|
|
7
|
+
hasAllPermissions: (actions: string[]) => boolean;
|
|
8
|
+
registerAction: (actionName: string, actionDescription: string) => void;
|
|
9
|
+
securityManager: any;
|
|
10
|
+
canCreate: boolean;
|
|
11
|
+
canEdit: boolean;
|
|
12
|
+
canDelete: boolean;
|
|
13
|
+
canView: boolean;
|
|
14
|
+
canList: boolean;
|
|
15
|
+
isLoading: boolean;
|
|
16
|
+
error: string | null;
|
|
17
|
+
}
|
|
18
|
+
export declare const useArchbaseSecureForm: (resourceName?: string, resourceDescription?: string) => UseArchbaseSecureFormReturn;
|
|
19
|
+
export declare const useArchbasePermissionCheck: () => {
|
|
20
|
+
check: (actionName: string) => boolean;
|
|
21
|
+
checkAny: (actions: string[]) => boolean;
|
|
22
|
+
checkAll: (actions: string[]) => boolean;
|
|
23
|
+
isAdmin: boolean;
|
|
24
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ArchbaseResourceService } from './ArchbaseResourceService';
|
|
2
|
+
import { SimpleActionDto, SimpleResourceDto } from './SecurityDomain';
|
|
3
|
+
export interface ISecurityManager {
|
|
4
|
+
registerAction(actionName: string, actionDescription: string): void;
|
|
5
|
+
}
|
|
6
|
+
export declare class ArchbaseSecurityManager implements ISecurityManager {
|
|
7
|
+
protected resourceService: ArchbaseResourceService;
|
|
8
|
+
protected resource: SimpleResourceDto;
|
|
9
|
+
protected actions: SimpleActionDto[];
|
|
10
|
+
protected permissions: string[];
|
|
11
|
+
protected alreadyApplied: boolean;
|
|
12
|
+
protected error: string;
|
|
13
|
+
protected isAdmin: boolean;
|
|
14
|
+
constructor(resourceName: string, resourceDescription: string, isAdmin: boolean);
|
|
15
|
+
registerAction(actionName: string, actionDescription: string): void;
|
|
16
|
+
apply(callback?: Function): Promise<void>;
|
|
17
|
+
hasPermission(actionName: string): boolean;
|
|
18
|
+
isError(): boolean;
|
|
19
|
+
getError(): string;
|
|
20
|
+
/**
|
|
21
|
+
* Retorna todas as permissões atuais
|
|
22
|
+
*/
|
|
23
|
+
getPermissions(): string[];
|
|
24
|
+
/**
|
|
25
|
+
* Retorna o status de carregamento
|
|
26
|
+
*/
|
|
27
|
+
isLoading(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Verifica múltiplas permissões
|
|
30
|
+
*/
|
|
31
|
+
hasAnyPermission(permissions: string[]): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Verifica se tem todas as permissões
|
|
34
|
+
*/
|
|
35
|
+
hasAllPermissions(permissions: string[]): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Retorna informações detalhadas sobre uma permissão
|
|
38
|
+
*/
|
|
39
|
+
getPermissionInfo(actionName: string): {
|
|
40
|
+
hasPermission: boolean;
|
|
41
|
+
isAdmin: boolean;
|
|
42
|
+
reason: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Registra múltiplas ações de uma vez
|
|
46
|
+
*/
|
|
47
|
+
registerActions(actions: Array<{
|
|
48
|
+
actionName: string;
|
|
49
|
+
actionDescription: string;
|
|
50
|
+
}>): void;
|
|
51
|
+
/**
|
|
52
|
+
* Retorna todas as ações registradas
|
|
53
|
+
*/
|
|
54
|
+
getRegisteredActions(): Array<{
|
|
55
|
+
actionName: string;
|
|
56
|
+
actionDescription: string;
|
|
57
|
+
}>;
|
|
58
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface ArchbaseTenantInfo {
|
|
2
|
+
id: string;
|
|
3
|
+
code?: string;
|
|
4
|
+
descricao: string;
|
|
5
|
+
imagemApresentacao?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class ArchbaseTenantManager {
|
|
8
|
+
private static instance;
|
|
9
|
+
private _currentTenant;
|
|
10
|
+
private _availableTenants;
|
|
11
|
+
private constructor();
|
|
12
|
+
static getInstance(): ArchbaseTenantManager;
|
|
13
|
+
get currentTenant$(): import('rxjs').Observable<ArchbaseTenantInfo>;
|
|
14
|
+
get currentTenant(): ArchbaseTenantInfo | null;
|
|
15
|
+
get availableTenants$(): import('rxjs').Observable<ArchbaseTenantInfo[]>;
|
|
16
|
+
get availableTenants(): ArchbaseTenantInfo[];
|
|
17
|
+
setCurrentTenant(tenant: ArchbaseTenantInfo | null): void;
|
|
18
|
+
setAvailableTenants(tenants: ArchbaseTenantInfo[]): void;
|
|
19
|
+
clear(): void;
|
|
20
|
+
getHeaders(): Record<string, string>;
|
|
21
|
+
}
|
|
22
|
+
export declare function useArchbaseTenantManager(): ArchbaseTenantManager;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { ArchbaseTokenManager, ArchbaseAccessToken } from '@archbase/core';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ArchbaseUsernameAndPassword as IArchbaseUsernameAndPassword, ArchbaseUser as IArchbaseUser } from '@archbase/core';
|
|
2
|
+
export declare class ArchbaseUser implements IArchbaseUser {
|
|
3
|
+
id: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
email: string;
|
|
6
|
+
photo: string;
|
|
7
|
+
isAdmin: boolean;
|
|
8
|
+
constructor(data: any);
|
|
9
|
+
static newInstance(): ArchbaseUser;
|
|
10
|
+
}
|
|
11
|
+
export declare class ArchbaseUsernameAndPasswordImpl implements IArchbaseUsernameAndPassword {
|
|
12
|
+
username: string;
|
|
13
|
+
password: string;
|
|
14
|
+
remember: boolean;
|
|
15
|
+
constructor(data: any);
|
|
16
|
+
static newInstance(): ArchbaseUsernameAndPasswordImpl;
|
|
17
|
+
}
|
|
18
|
+
export { ArchbaseUsernameAndPasswordImpl as ArchbaseUsernameAndPassword };
|
|
19
|
+
export type { ArchbaseUsernameAndPassword as IArchbaseUsernameAndPassword } from '@archbase/core';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ArchbaseEntityTransformer, ArchbaseRemoteApiClient, ArchbaseRemoteApiService } from '@archbase/data';
|
|
2
|
+
import { UserDto } from './SecurityDomain';
|
|
3
|
+
export declare class ArchbaseUserService extends ArchbaseRemoteApiService<UserDto, string> implements ArchbaseEntityTransformer<UserDto> {
|
|
4
|
+
constructor(client: ArchbaseRemoteApiClient);
|
|
5
|
+
protected configureHeaders(): Record<string, string>;
|
|
6
|
+
transform(entity: UserDto): UserDto;
|
|
7
|
+
protected getEndpoint(): string;
|
|
8
|
+
getId(entity: UserDto): string;
|
|
9
|
+
isNewRecord(entity: UserDto): boolean;
|
|
10
|
+
getUserByEmail(email: string): Promise<UserDto>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ArchbaseTokenManager, ArchbaseAccessToken, ArchbaseUsernameAndPassword } from '@archbase/core';
|
|
2
|
+
export declare const ENCRYPTION_KEY = "YngzI1guK3dGaElFcFY9MywqK3xgPzg/Ojg7eD8xRmg=";
|
|
3
|
+
export declare const TOKEN_COOKIE_NAME = "c1ab58e7-c113-4225-a190-a9e59d1207fc";
|
|
4
|
+
export declare const USER_NAME_AND_PASSWORD = "6faf6932-a0b5-457b-83b1-8d89ddbd91fd";
|
|
5
|
+
export declare const USER_NAME = "602b05c5-ec46-451e-aba6-187e463bc245";
|
|
6
|
+
export declare const CONTEXT_STORAGE_KEY = "8b4a7c2d-9e5f-4163-b8a7-3f2c9d8e5a1b";
|
|
7
|
+
export declare class DefaultArchbaseTokenManager implements ArchbaseTokenManager {
|
|
8
|
+
getUsernameAndPassword(): ArchbaseUsernameAndPassword | null;
|
|
9
|
+
saveUsernameAndPassword(username: string, password: string): void;
|
|
10
|
+
getUsername(): string | null;
|
|
11
|
+
saveUsername(username: string): void;
|
|
12
|
+
isTokenExpired(token?: ArchbaseAccessToken, expirationThreshold?: number): boolean;
|
|
13
|
+
saveToken(accessToken?: ArchbaseAccessToken): void;
|
|
14
|
+
clearUsernameAndPassword(): void;
|
|
15
|
+
clearToken(): void;
|
|
16
|
+
getToken(): ArchbaseAccessToken | null;
|
|
17
|
+
saveContext(context: string): void;
|
|
18
|
+
getContext(): string | null;
|
|
19
|
+
clearContext(): void;
|
|
20
|
+
}
|