@nibssplc/cams-sdk-react 0.0.1-beta.9 → 0.0.1-beta.91
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/README.md +239 -104
- package/dist/components/ADLoginModal.d.ts +7 -0
- package/dist/components/AuthFailureAnimation.d.ts +5 -0
- package/dist/components/AuthSuccessAnimation.d.ts +5 -0
- package/dist/components/CAMSMSALProvider.d.ts +13 -5
- package/dist/components/CAMSProvider.d.ts +6 -6
- package/dist/components/ClientOnly.d.ts +6 -0
- package/dist/components/CoreFIDO.d.ts +20 -0
- package/dist/components/DefaultLoginPage.d.ts +2 -0
- package/dist/components/ErrorFallback.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 +12 -0
- package/dist/components/MFAOptions.d.ts +7 -0
- package/dist/components/ProtectedRoute.d.ts +1 -1
- package/dist/components/UnifiedCAMSProvider.d.ts +22 -0
- 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/input.d.ts +5 -0
- package/dist/components/ui/label.d.ts +4 -0
- package/dist/context/CAMSContext.d.ts +19 -0
- package/dist/hooks/useCAMSAuth.d.ts +8 -1
- package/dist/hooks/useCAMSMSALAuth.d.ts +17 -10
- package/dist/hooks/useFIDOAuth.d.ts +9 -0
- package/dist/hooks/useOTPHandler.d.ts +30 -0
- package/dist/index.cjs.js +1993 -18008
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +10 -2
- package/dist/index.esm.js +1999 -18025
- package/dist/index.esm.js.map +1 -1
- package/dist/lib/utils.d.ts +2 -0
- package/dist/utils/DeviceID.d.ts +1 -0
- package/dist/utils/FIDO.d.ts +10 -0
- package/dist/utils/cookies.d.ts +3 -0
- package/package.json +32 -9
- package/dist/index.umd.js +0 -18258
- package/dist/index.umd.js.map +0 -1
|
@@ -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
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
17
|
+
storageKey: string;
|
|
15
18
|
isAuthenticated: boolean;
|
|
16
19
|
isLoading: boolean;
|
|
17
|
-
isMFAPending: boolean;
|
|
18
20
|
error: CAMSError | null;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
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
|
+
};
|