@nibssplc/cams-sdk-react 0.0.1-beta.8 → 0.0.1-beta.82

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 (36) hide show
  1. package/README.md +239 -104
  2. package/dist/components/ADLoginModal.d.ts +7 -0
  3. package/dist/components/AuthFailureAnimation.d.ts +5 -0
  4. package/dist/components/AuthSuccessAnimation.d.ts +5 -0
  5. package/dist/components/CAMSMSALProvider.d.ts +16 -0
  6. package/dist/components/CAMSProvider.d.ts +13 -0
  7. package/dist/components/ClientOnly.d.ts +6 -0
  8. package/dist/components/DefaultLoginPage.d.ts +2 -0
  9. package/dist/components/ErrorFallback.d.ts +5 -0
  10. package/dist/components/GenericOTP.d.ts +13 -0
  11. package/dist/components/Loading.d.ts +6 -0
  12. package/dist/components/MFAGate.d.ts +8 -0
  13. package/dist/components/MFAOptions.d.ts +7 -0
  14. package/dist/components/ProtectedRoute.d.ts +7 -0
  15. package/dist/components/UnifiedCAMSProvider.d.ts +22 -0
  16. package/dist/components/ui/button.d.ts +10 -0
  17. package/dist/components/ui/card.d.ts +9 -0
  18. package/dist/components/ui/dialog.d.ts +15 -0
  19. package/dist/components/ui/form.d.ts +24 -0
  20. package/dist/components/ui/input-otp.d.ts +11 -0
  21. package/dist/components/ui/input.d.ts +5 -0
  22. package/dist/components/ui/label.d.ts +4 -0
  23. package/dist/context/CAMSContext.d.ts +19 -0
  24. package/dist/hooks/useCAMSAuth.d.ts +24 -0
  25. package/dist/hooks/useCAMSMSALAuth.d.ts +30 -0
  26. package/dist/hooks/useCAMSPopupAuth.d.ts +17 -0
  27. package/dist/hooks/useOTPHandler.d.ts +17 -0
  28. package/dist/index.cjs.js +2063 -0
  29. package/dist/index.cjs.js.map +1 -0
  30. package/dist/index.d.ts +13 -0
  31. package/dist/index.esm.js +2024 -0
  32. package/dist/index.esm.js.map +1 -0
  33. package/dist/lib/utils.d.ts +2 -0
  34. package/dist/utils/DeviceID.d.ts +1 -0
  35. package/dist/utils/cookies.d.ts +3 -0
  36. package/package.json +36 -13
@@ -0,0 +1,24 @@
1
+ import { CAMSConfig, CAMSError, Profile } from "@nibssplc/cams-sdk";
2
+ export interface UseCAMSAuthOptions {
3
+ appCode: string;
4
+ storageKey?: string;
5
+ onAuthSuccess?: (token: string) => void;
6
+ onAuthError?: (error: CAMSError) => void;
7
+ onTokenExpired?: () => void;
8
+ autoClose?: boolean;
9
+ idleTimeout?: number;
10
+ loginExpiry?: number;
11
+ }
12
+ export interface UseCAMSAuthReturn {
13
+ login: (config: CAMSConfig) => Promise<void>;
14
+ logout: () => Promise<void>;
15
+ isAuthenticated: boolean;
16
+ isLoading: boolean;
17
+ error: CAMSError | null;
18
+ token: string | null;
19
+ profile: Profile | null;
20
+ appCode: string;
21
+ storageKey: string;
22
+ loginExpiry: number;
23
+ }
24
+ export declare function useCAMSAuth(options?: UseCAMSAuthOptions): UseCAMSAuthReturn;
@@ -0,0 +1,30 @@
1
+ import { CAMSError, CAMSMFAAuthenticator, MFAResponse } from "@nibssplc/cams-sdk";
2
+ export interface UseCAMSMSALAuthOptions {
3
+ onAuthSuccess?: (token: string) => void;
4
+ onAuthError?: (error: CAMSError) => void;
5
+ onTokenExpired?: () => void;
6
+ scopes?: string[];
7
+ storageKey?: string;
8
+ prompt?: string;
9
+ messageOrigin?: string;
10
+ appCode: string;
11
+ allowedOrigins?: string[];
12
+ MFAEndpoint?: string;
13
+ }
14
+ export interface UseCAMSMSALAuthReturn {
15
+ login: () => Promise<void>;
16
+ logout: () => Promise<void>;
17
+ storageKey: string;
18
+ isAuthenticated: boolean;
19
+ isLoading: boolean;
20
+ error: CAMSError | null;
21
+ idToken: string;
22
+ accessToken: string;
23
+ appCode: string;
24
+ mfaAuthenticator: CAMSMFAAuthenticator | null;
25
+ requiresMFA: boolean;
26
+ completeMFA: (data: UserValidatedResponse) => Promise<MFAResponse>;
27
+ setRequiresMFA: React.Dispatch<React.SetStateAction<boolean>>;
28
+ sendEmailOTP: () => Promise<boolean>;
29
+ }
30
+ export declare function useCAMSMSALAuth(options: UseCAMSMSALAuthOptions): UseCAMSMSALAuthReturn;
@@ -0,0 +1,17 @@
1
+ import { Profile } from "@nibssplc/cams-sdk";
2
+ export interface UseCAMSPopupAuthOptions {
3
+ storageKey?: string;
4
+ targetOrigin?: string;
5
+ onAuthComplete?: (profile: Profile) => void;
6
+ onAuthError?: (error: any) => void;
7
+ }
8
+ export interface UseCAMSPopupAuthReturn {
9
+ completeAuth: (profile: Profile) => void;
10
+ errorAuth: (error: any) => void;
11
+ isPopup: boolean;
12
+ }
13
+ /**
14
+ * Hook for handling authentication in popup windows
15
+ * This should be used by the popup app to complete authentication
16
+ */
17
+ export declare function useCAMSPopupAuth(options?: UseCAMSPopupAuthOptions): UseCAMSPopupAuthReturn;
@@ -0,0 +1,17 @@
1
+ export declare const useOTPHandler: ({ provider, accessToken, idToken, appCode, authenticationType, MFAEndpoint, onAuthComplete, }: {
2
+ provider: string;
3
+ accessToken: string;
4
+ idToken: string;
5
+ appCode: string;
6
+ authenticationType: "AuthenticatorCode" | "EmailOTP" | null;
7
+ MFAEndpoint?: string;
8
+ onAuthComplete: (state: boolean, data: UserValidatedResponse | null) => void;
9
+ }) => {
10
+ handleSubmitOTP: (authenticationValue: string) => Promise<boolean>;
11
+ loading: boolean;
12
+ setLoading: import("react").Dispatch<import("react").SetStateAction<boolean>>;
13
+ attemptCount: number;
14
+ isMaxAttemptsReached: boolean;
15
+ resetAttempts: () => void;
16
+ remainingAttempts: number;
17
+ };