@nibssplc/cams-sdk-react 0.0.1-beta.10 → 0.0.1-beta.100

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 (40) 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 +13 -5
  6. package/dist/components/CAMSProvider.d.ts +6 -6
  7. package/dist/components/ClientOnly.d.ts +6 -0
  8. package/dist/components/CoreFIDO.d.ts +29 -0
  9. package/dist/components/DefaultLoginPage.d.ts +8 -0
  10. package/dist/components/ErrorFallback.d.ts +5 -0
  11. package/dist/components/GenericOTP.d.ts +13 -0
  12. package/dist/components/Loading.d.ts +6 -0
  13. package/dist/components/MFAGate.d.ts +18 -0
  14. package/dist/components/MFAOptions.d.ts +9 -0
  15. package/dist/components/ProtectedRoute.d.ts +1 -1
  16. package/dist/components/UnifiedCAMSProvider.d.ts +22 -0
  17. package/dist/components/ui/button.d.ts +10 -0
  18. package/dist/components/ui/card.d.ts +9 -0
  19. package/dist/components/ui/dialog.d.ts +15 -0
  20. package/dist/components/ui/form.d.ts +24 -0
  21. package/dist/components/ui/input-otp.d.ts +11 -0
  22. package/dist/components/ui/input.d.ts +5 -0
  23. package/dist/components/ui/label.d.ts +4 -0
  24. package/dist/context/CAMSContext.d.ts +19 -0
  25. package/dist/hooks/useCAMSAuth.d.ts +8 -1
  26. package/dist/hooks/useCAMSMSALAuth.d.ts +17 -10
  27. package/dist/hooks/useFIDOAuth.d.ts +9 -0
  28. package/dist/hooks/useOTPHandler.d.ts +30 -0
  29. package/dist/index.cjs.js +2026 -18008
  30. package/dist/index.cjs.js.map +1 -1
  31. package/dist/index.d.ts +10 -2
  32. package/dist/index.esm.js +2024 -18017
  33. package/dist/index.esm.js.map +1 -1
  34. package/dist/lib/utils.d.ts +2 -0
  35. package/dist/utils/DeviceID.d.ts +1 -0
  36. package/dist/utils/FIDO.d.ts +11 -0
  37. package/dist/utils/cookies.d.ts +3 -0
  38. package/package.json +32 -9
  39. package/dist/index.umd.js +0 -18258
  40. package/dist/index.umd.js.map +0 -1
@@ -0,0 +1,24 @@
1
+ import * as React from "react";
2
+ import * as LabelPrimitive from "@radix-ui/react-label";
3
+ import { Slot } from "@radix-ui/react-slot";
4
+ import { type ControllerProps, type FieldPath, type FieldValues } from "react-hook-form";
5
+ declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>(props: import("react-hook-form").FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React.JSX.Element;
6
+ declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ ...props }: ControllerProps<TFieldValues, TName>) => import("react/jsx-runtime").JSX.Element;
7
+ declare const useFormField: () => {
8
+ invalid: boolean;
9
+ isDirty: boolean;
10
+ isTouched: boolean;
11
+ isValidating: boolean;
12
+ error?: import("react-hook-form").FieldError;
13
+ id: string;
14
+ name: string;
15
+ formItemId: string;
16
+ formDescriptionId: string;
17
+ formMessageId: string;
18
+ };
19
+ declare function FormItem({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
20
+ declare function FormLabel({ className, ...props }: React.ComponentProps<typeof LabelPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
21
+ declare function FormControl({ ...props }: React.ComponentProps<typeof Slot>): import("react/jsx-runtime").JSX.Element;
22
+ declare function FormDescription({ className, ...props }: React.ComponentProps<"p">): import("react/jsx-runtime").JSX.Element;
23
+ declare function FormMessage({ className, ...props }: React.ComponentProps<"p">): import("react/jsx-runtime").JSX.Element | null;
24
+ export { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField, };
@@ -0,0 +1,11 @@
1
+ import * as React from "react";
2
+ import { OTPInput } from "input-otp";
3
+ declare function InputOTP({ className, containerClassName, ...props }: React.ComponentProps<typeof OTPInput> & {
4
+ containerClassName?: string;
5
+ }): import("react/jsx-runtime").JSX.Element;
6
+ declare function InputOTPGroup({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
7
+ declare function InputOTPSlot({ index, className, ...props }: React.ComponentProps<"div"> & {
8
+ index: number;
9
+ }): import("react/jsx-runtime").JSX.Element;
10
+ declare function InputOTPSeparator({ ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
11
+ export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator };
@@ -0,0 +1,5 @@
1
+ import * as React from "react";
2
+ export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
3
+ }
4
+ declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
5
+ export { Input };
@@ -0,0 +1,4 @@
1
+ import * as React from "react";
2
+ import * as LabelPrimitive from "@radix-ui/react-label";
3
+ declare function Label({ className, ...props }: React.ComponentProps<typeof LabelPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
4
+ export { Label };
@@ -0,0 +1,19 @@
1
+ import { Profile } from "@nibssplc/cams-sdk";
2
+ import { UseCAMSAuthReturn } from "../hooks/useCAMSAuth";
3
+ import { UseCAMSMSALAuthReturn } from "../hooks/useCAMSMSALAuth";
4
+ type AuthMode = "REGULAR" | "MSAL";
5
+ interface BaseCAMSContextValue {
6
+ userProfile: Profile | null;
7
+ setUserProfile: (profile: Profile | null) => void;
8
+ authMode: AuthMode;
9
+ }
10
+ interface RegularCAMSContextValue extends BaseCAMSContextValue, UseCAMSAuthReturn {
11
+ authMode: "REGULAR";
12
+ }
13
+ interface MSALCAMSContextValue extends BaseCAMSContextValue, UseCAMSMSALAuthReturn {
14
+ authMode: "MSAL";
15
+ }
16
+ export type CAMSContextValue = RegularCAMSContextValue | MSALCAMSContextValue;
17
+ export declare const CAMSContext: import("react").Context<CAMSContextValue | null>;
18
+ export declare function useCAMSContext(): CAMSContextValue;
19
+ export {};
@@ -1,9 +1,13 @@
1
- import { CAMSConfig, CAMSError, Profile } from '@nibssplc/cams-sdk';
1
+ import { CAMSConfig, CAMSError, Profile } from "@nibssplc/cams-sdk";
2
2
  export interface UseCAMSAuthOptions {
3
+ appCode: string;
3
4
  storageKey?: string;
4
5
  onAuthSuccess?: (token: string) => void;
5
6
  onAuthError?: (error: CAMSError) => void;
6
7
  onTokenExpired?: () => void;
8
+ autoClose?: boolean;
9
+ idleTimeout?: number;
10
+ loginExpiry?: number;
7
11
  }
8
12
  export interface UseCAMSAuthReturn {
9
13
  login: (config: CAMSConfig) => Promise<void>;
@@ -13,5 +17,8 @@ export interface UseCAMSAuthReturn {
13
17
  error: CAMSError | null;
14
18
  token: string | null;
15
19
  profile: Profile | null;
20
+ appCode: string;
21
+ storageKey: string;
22
+ loginExpiry: number;
16
23
  }
17
24
  export declare function useCAMSAuth(options?: UseCAMSAuthOptions): UseCAMSAuthReturn;
@@ -1,23 +1,30 @@
1
- import { AccountInfo } from "@azure/msal-browser";
2
- import { CAMSError, Profile } from "@nibssplc/cams-sdk";
1
+ import { CAMSError, CAMSMFAAuthenticator, MFAResponse } from "@nibssplc/cams-sdk";
3
2
  export interface UseCAMSMSALAuthOptions {
4
3
  onAuthSuccess?: (token: string) => void;
5
4
  onAuthError?: (error: CAMSError) => void;
6
5
  onTokenExpired?: () => void;
7
- onMFARequired?: (msalToken: string, account: AccountInfo) => void;
8
6
  scopes?: string[];
9
- mfaUrl?: string;
7
+ storageKey?: string;
8
+ prompt?: string;
9
+ messageOrigin?: string;
10
+ appCode: string;
11
+ allowedOrigins?: string[];
12
+ MFAEndpoint?: string;
10
13
  }
11
14
  export interface UseCAMSMSALAuthReturn {
12
15
  login: () => Promise<void>;
13
16
  logout: () => Promise<void>;
14
- completeMFA: (mfaToken: string) => void;
17
+ storageKey: string;
15
18
  isAuthenticated: boolean;
16
19
  isLoading: boolean;
17
- isMFAPending: boolean;
18
20
  error: CAMSError | null;
19
- token: string | null;
20
- profile: Profile | null;
21
- account: AccountInfo | 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>;
22
29
  }
23
- export declare function useCAMSMSALAuth(options?: UseCAMSMSALAuthOptions): UseCAMSMSALAuthReturn;
30
+ export declare function useCAMSMSALAuth(options: UseCAMSMSALAuthOptions): UseCAMSMSALAuthReturn;
@@ -0,0 +1,9 @@
1
+ import { register, authenticate } from '../components/CoreFIDO';
2
+ /**
3
+ * A React hook that provides access to the WebAuthn `register` and `authenticate` functions.
4
+ * @returns An object containing the `register` and `authenticate` functions.
5
+ */
6
+ export declare const useWebAuthn: () => {
7
+ register: typeof register;
8
+ authenticate: typeof authenticate;
9
+ };
@@ -0,0 +1,30 @@
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
+ };
18
+ export declare const useCredentialsHandler: (credentials: Credentials, appCode: string, CredAuthEndpoint: string, onAuthComplete: (state: boolean, data: UserValidatedResponse | null) => void) => {
19
+ handleSubmitCredentials: ({ username, password, MFACode, appCode, }: {
20
+ username: string;
21
+ password: string;
22
+ MFACode: string;
23
+ appCode: string;
24
+ }) => Promise<boolean>;
25
+ loading: boolean;
26
+ setLoading: import("react").Dispatch<import("react").SetStateAction<boolean>>;
27
+ attemptCount: number;
28
+ isMaxAttemptsReached: boolean;
29
+ remainingAttempts: number;
30
+ };