@nibssplc/cams-sdk-react 0.0.1-beta.55 → 0.0.1-beta.58
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/dist/components/AuthFailureAnimation.d.ts +5 -0
- package/dist/components/AuthSuccessAnimation.d.ts +5 -0
- package/dist/components/GenericOTP.d.ts +13 -0
- package/dist/components/Loading.d.ts +6 -0
- package/dist/components/MFAGate.d.ts +6 -0
- package/dist/components/MFAOptions.d.ts +5 -0
- package/dist/components/UnifiedCAMSProvider.d.ts +3 -17
- package/dist/components/ui/button.d.ts +10 -0
- package/dist/components/ui/card.d.ts +9 -0
- package/dist/components/ui/dialog.d.ts +15 -0
- package/dist/components/ui/form.d.ts +24 -0
- package/dist/components/ui/input-otp.d.ts +11 -0
- package/dist/components/ui/label.d.ts +4 -0
- package/dist/context/CAMSContext.d.ts +20 -0
- package/dist/hooks/useCAMSMSALAuth.d.ts +6 -1
- package/dist/hooks/useCAMSPopupAuth.d.ts +17 -0
- package/dist/hooks/useOTPHandler.d.ts +17 -0
- package/dist/index.cjs.js +1456 -18995
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.js +1444 -18987
- package/dist/index.esm.js.map +1 -1
- package/dist/lib/utils.d.ts +2 -0
- package/package.json +22 -3
- package/README.md +0 -397
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface GenericOTPProps {
|
|
2
|
+
value: string;
|
|
3
|
+
setValue: (v: string) => void;
|
|
4
|
+
setLoading?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
5
|
+
isDisabled: boolean;
|
|
6
|
+
onChangeOTP: (val: string) => void;
|
|
7
|
+
fieldName: "AuthenticatorCode" | "EmailOTP";
|
|
8
|
+
attemptCount?: number;
|
|
9
|
+
remainingAttempts?: number;
|
|
10
|
+
isMaxAttemptsReached?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const GenericOTPVerifier: ({ value, setValue, setLoading, onChangeOTP, fieldName, attemptCount, remainingAttempts, isMaxAttemptsReached, }: GenericOTPProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
interface MFAGateProps {
|
|
2
|
+
children: React.ReactNode;
|
|
3
|
+
fallback?: React.ReactNode;
|
|
4
|
+
}
|
|
5
|
+
declare const MFAGate: ({ children, fallback }: MFAGateProps) => string | number | bigint | true | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export default MFAGate;
|
|
@@ -1,21 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { PublicClientApplication, Configuration } from "@azure/msal-browser";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { UseCAMSMSALAuthReturn, UseCAMSMSALAuthOptions } from "../hooks/useCAMSMSALAuth";
|
|
6
|
-
type AuthMode = "REGULAR" | "MSAL";
|
|
7
|
-
interface BaseCAMSContextValue {
|
|
8
|
-
userProfile: Profile | null;
|
|
9
|
-
setUserProfile: (profile: Profile | null) => void;
|
|
10
|
-
authMode: AuthMode;
|
|
11
|
-
}
|
|
12
|
-
interface RegularCAMSContextValue extends BaseCAMSContextValue, UseCAMSAuthReturn {
|
|
13
|
-
authMode: "REGULAR";
|
|
14
|
-
}
|
|
15
|
-
interface MSALCAMSContextValue extends BaseCAMSContextValue, UseCAMSMSALAuthReturn {
|
|
16
|
-
authMode: "MSAL";
|
|
17
|
-
}
|
|
18
|
-
type CAMSContextValue = RegularCAMSContextValue | MSALCAMSContextValue;
|
|
3
|
+
import { UseCAMSAuthOptions } from "../hooks/useCAMSAuth";
|
|
4
|
+
import { UseCAMSMSALAuthOptions } from "../hooks/useCAMSMSALAuth";
|
|
19
5
|
interface BaseProviderProps {
|
|
20
6
|
children: React.ReactNode;
|
|
21
7
|
appCode: string;
|
|
@@ -27,10 +13,10 @@ interface MSALProviderProps extends BaseProviderProps, UseCAMSMSALAuthOptions {
|
|
|
27
13
|
mode: "MSAL";
|
|
28
14
|
msalConfig: Configuration;
|
|
29
15
|
msalInstance?: PublicClientApplication;
|
|
16
|
+
validateTokenUrl?: string;
|
|
30
17
|
}
|
|
31
18
|
type UnifiedCAMSProviderProps = RegularProviderProps | MSALProviderProps;
|
|
32
19
|
export declare function UnifiedCAMSProvider(props: UnifiedCAMSProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
-
export declare function useCAMSContext(): CAMSContextValue;
|
|
34
20
|
export declare const CAMSProvider: (props: Omit<RegularProviderProps, "mode">) => import("react/jsx-runtime").JSX.Element;
|
|
35
21
|
export declare const CAMSMSALProvider: (props: Omit<MSALProviderProps, "mode">) => import("react/jsx-runtime").JSX.Element;
|
|
36
22
|
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
declare const buttonVariants: (props?: ({
|
|
4
|
+
variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
5
|
+
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
7
|
+
declare function Button({ className, variant, size, asChild, ...props }: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
|
|
8
|
+
asChild?: boolean;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export { Button, buttonVariants };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
declare function Card({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare function CardHeader({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare function CardTitle({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare function CardDescription({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare function CardAction({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
declare function CardContent({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare function CardFooter({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent, };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
3
|
+
declare function Dialog({ ...props }: React.ComponentProps<typeof DialogPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare function DialogTrigger({ ...props }: React.ComponentProps<typeof DialogPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare function DialogPortal({ ...props }: React.ComponentProps<typeof DialogPrimitive.Portal>): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare function DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
declare function DialogOverlay({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Overlay>): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare function DialogContent({ className, children, showCloseButton, ...props }: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
9
|
+
showCloseButton?: boolean;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
declare function DialogHeader({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
declare function DialogFooter({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
declare function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
declare function DialogDescription({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Description>): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, };
|
|
@@ -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,20 @@
|
|
|
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
|
+
validateTokenUrl?: string;
|
|
10
|
+
}
|
|
11
|
+
interface RegularCAMSContextValue extends BaseCAMSContextValue, UseCAMSAuthReturn {
|
|
12
|
+
authMode: "REGULAR";
|
|
13
|
+
}
|
|
14
|
+
interface MSALCAMSContextValue extends BaseCAMSContextValue, UseCAMSMSALAuthReturn {
|
|
15
|
+
authMode: "MSAL";
|
|
16
|
+
}
|
|
17
|
+
export type CAMSContextValue = RegularCAMSContextValue | MSALCAMSContextValue;
|
|
18
|
+
export declare const CAMSContext: import("react").Context<CAMSContextValue | null>;
|
|
19
|
+
export declare function useCAMSContext(): CAMSContextValue;
|
|
20
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CAMSError } from "@nibssplc/cams-sdk";
|
|
1
|
+
import { CAMSError, CAMSMFAAuthenticator, MFAResponse } from "@nibssplc/cams-sdk";
|
|
2
2
|
export interface UseCAMSMSALAuthOptions {
|
|
3
3
|
onAuthSuccess?: (token: string) => void;
|
|
4
4
|
onAuthError?: (error: CAMSError) => void;
|
|
@@ -10,6 +10,7 @@ export interface UseCAMSMSALAuthOptions {
|
|
|
10
10
|
messageOrigin?: string;
|
|
11
11
|
appCode: string;
|
|
12
12
|
allowedOrigins?: string[];
|
|
13
|
+
mfaApiEndpoint?: string;
|
|
13
14
|
}
|
|
14
15
|
export interface UseCAMSMSALAuthReturn {
|
|
15
16
|
login: () => Promise<void>;
|
|
@@ -21,5 +22,9 @@ export interface UseCAMSMSALAuthReturn {
|
|
|
21
22
|
idToken: string;
|
|
22
23
|
accessToken: string;
|
|
23
24
|
appCode: string;
|
|
25
|
+
mfaAuthenticator: CAMSMFAAuthenticator | null;
|
|
26
|
+
requiresMFA: boolean;
|
|
27
|
+
completeMFA: (code: string, type: 'EmailOTP' | 'AuthenticatorCode') => Promise<MFAResponse>;
|
|
28
|
+
sendEmailOTP: () => Promise<boolean>;
|
|
24
29
|
}
|
|
25
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, validateTokenUrl, onAuthComplete, }: {
|
|
2
|
+
provider: string;
|
|
3
|
+
accessToken: string;
|
|
4
|
+
idToken: string;
|
|
5
|
+
appCode: string;
|
|
6
|
+
authenticationType: "AuthenticatorCode" | "EmailOTP" | null;
|
|
7
|
+
validateTokenUrl: 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
|
+
};
|