@compagnat/dc-common-ui 0.1.0 → 0.2.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.
@@ -0,0 +1,7 @@
1
+ import { default as pino } from 'pino';
2
+ export interface LoggerConfig {
3
+ level?: string;
4
+ name?: string;
5
+ }
6
+ export declare function configureLogger(options: LoggerConfig): void;
7
+ export declare const logger: pino.Logger<never, boolean>;
@@ -0,0 +1,38 @@
1
+ import { default as React, ReactNode } from 'react';
2
+ import { CognitoUser } from 'amazon-cognito-identity-js';
3
+ export declare function GetAccessToken(): string | null;
4
+ export declare function GetClientKey(): string;
5
+ export declare function GetSubClientKey(): string;
6
+ export declare function HasRole(role: string): boolean;
7
+ export declare const CODE_REQUESTED = "CODE_REQUESTED";
8
+ export interface AuthConfig {
9
+ userPoolId: string;
10
+ clientId: string;
11
+ getUserIcon?: (username: string | null | undefined) => React.ReactNode;
12
+ }
13
+ export interface AuthResult {
14
+ isFirstLogin?: boolean;
15
+ user?: CognitoUser;
16
+ userAttr?: any;
17
+ [key: string]: any;
18
+ }
19
+ interface AuthContextType {
20
+ isAuthenticated: boolean;
21
+ username: string | null;
22
+ clientKey: string | null;
23
+ subClientKey: string | null;
24
+ roles: string[];
25
+ userIcon: React.ReactNode;
26
+ login: (email: string, password: string) => Promise<AuthResult>;
27
+ logout: () => void;
28
+ changePassword: (oldPassword: string, newPassword: string, email: string) => Promise<any>;
29
+ resetPassword: (email: string) => Promise<any>;
30
+ confirmResetPassword: (email: string, code: string, newPassword: string) => Promise<any>;
31
+ }
32
+ interface AuthProviderProps {
33
+ children: ReactNode;
34
+ config: AuthConfig;
35
+ }
36
+ export declare function AuthProvider({ children, config }: AuthProviderProps): React.JSX.Element;
37
+ export declare function useAuth(): AuthContextType;
38
+ export {};
@@ -1,2 +1,6 @@
1
+ export { AuthProvider, useAuth, GetAccessToken, GetClientKey, GetSubClientKey, HasRole, CODE_REQUESTED } from './hooks/AuthProvider';
2
+ export { configureLogger, logger } from './components/Logger';
3
+ export type { LoggerConfig } from './components/Logger';
4
+ export type { AuthConfig, AuthResult } from './hooks/AuthProvider';
1
5
  export { CookieConsentProvider, useCookieConsent, CookieConsentBanner } from './hooks/CookieConsent';
2
6
  export { MessageProvider, useMessage, Severity, sendGlobalSuccessMessage, sendGlobalErrorMessage, sendGlobalMessage, } from './hooks/MessageContext';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compagnat/dc-common-ui",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -57,5 +57,9 @@
57
57
  "vite": "^8.0.16",
58
58
  "vite-plugin-dts": "^5.0.2",
59
59
  "vitest": "^4.1.8"
60
+ },
61
+ "dependencies": {
62
+ "amazon-cognito-identity-js": "^6.3.16",
63
+ "pino": "^10.3.1"
60
64
  }
61
65
  }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
File without changes