@nibssplc/cams-sdk-react 1.0.0-rc.13 → 1.0.0-rc.130
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 +36 -4
- package/dist/components/ADLoginModal.d.ts +1 -0
- package/dist/components/CoreFIDO.d.ts +1 -9
- package/dist/components/DefaultLoginPage.d.ts +3 -7
- package/dist/components/GenericOTP.d.ts +2 -1
- package/dist/components/Loading.d.ts +2 -4
- package/dist/components/MFAGate.d.ts +8 -5
- package/dist/components/MFAOptions.d.ts +3 -3
- package/dist/context/CAMSContext.d.ts +8 -2
- package/dist/{components → context}/CAMSMSALProvider.d.ts +0 -1
- package/dist/{components → context}/UnifiedCAMSProvider.d.ts +7 -3
- package/dist/hooks/useCAMSMSALAuth.d.ts +8 -7
- package/dist/hooks/useFIDOAuth.d.ts +1 -1
- package/dist/hooks/useOTPHandler.d.ts +7 -8
- package/dist/index.cjs.js +676 -1202
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.esm.js +679 -1205
- package/dist/index.esm.js.map +1 -1
- package/dist/styles.css +0 -0
- package/dist/utils/cookies.d.ts +1 -1
- package/package.json +21 -14
- package/dist/lib/actions/Axiosinstance.d.ts +0 -1
- package/dist/utils/DeviceID.d.ts +0 -4
- /package/dist/{components → context}/CAMSProvider.d.ts +0 -0
package/README.md
CHANGED
|
@@ -13,6 +13,28 @@ For MSAL mode, also install:
|
|
|
13
13
|
npm install @azure/msal-browser @azure/msal-react
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
### Importing Styles
|
|
17
|
+
|
|
18
|
+
The SDK includes bundled Tailwind CSS. Import it in your app entry point:
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import '@nibssplc/cams-sdk-react/dist/styles.css';
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
For Next.js, add to `app/layout.tsx` or `pages/_app.tsx`:
|
|
25
|
+
```tsx
|
|
26
|
+
import '@nibssplc/cams-sdk-react/dist/styles.css';
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Important:** For complete Tailwind CSS support, add this script to your `index.html`:
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<script
|
|
33
|
+
async
|
|
34
|
+
src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"
|
|
35
|
+
></script>
|
|
36
|
+
```
|
|
37
|
+
|
|
16
38
|
## Features
|
|
17
39
|
|
|
18
40
|
- ⚛️ React hooks for authentication
|
|
@@ -273,13 +295,23 @@ export default function RootLayout({ children }) {
|
|
|
273
295
|
|
|
274
296
|
## Styling
|
|
275
297
|
|
|
276
|
-
|
|
298
|
+
The SDK bundles all required Tailwind CSS, so you don't need to configure Tailwind in your project. Simply import the styles:
|
|
277
299
|
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
npx tailwindcss init
|
|
300
|
+
```tsx
|
|
301
|
+
import '@nibssplc/cams-sdk-react/dist/styles.css';
|
|
281
302
|
```
|
|
282
303
|
|
|
304
|
+
**For complete Tailwind CSS functionality**, add the Tailwind browser script to your HTML:
|
|
305
|
+
|
|
306
|
+
```html
|
|
307
|
+
<script
|
|
308
|
+
async
|
|
309
|
+
src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"
|
|
310
|
+
></script>
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
If your project already uses Tailwind, the SDK styles will work alongside your existing configuration.
|
|
314
|
+
|
|
283
315
|
## Examples
|
|
284
316
|
|
|
285
317
|
See the [examples](../../examples) directory for complete implementations:
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
id: string;
|
|
3
|
-
rawId: string;
|
|
4
|
-
type: string;
|
|
5
|
-
response: {
|
|
6
|
-
clientDataJSON: string;
|
|
7
|
-
attestationObject: string;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
1
|
+
import { AttestationResult } from "@nibssplc/cams-sdk";
|
|
10
2
|
/**
|
|
11
3
|
* Initiates the WebAuthn registration process.
|
|
12
4
|
* It takes server-provided options, converts them for the browser API,
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import { MFAEndpoints } from "./MFAGate";
|
|
3
|
-
interface LoginPageProps {
|
|
4
|
-
usePassKey?: boolean;
|
|
1
|
+
export interface LoginPageProps {
|
|
5
2
|
CredentialsAuthEndpoint?: string;
|
|
6
3
|
useADLogin?: boolean;
|
|
7
|
-
|
|
8
|
-
PassKeysRegisterProps?: Record<string, unknown>;
|
|
4
|
+
onADLoginSuccess?: () => void;
|
|
9
5
|
}
|
|
10
|
-
declare const DefaultLoginPage: ({
|
|
6
|
+
declare const DefaultLoginPage: ({ useADLogin, CredentialsAuthEndpoint, onADLoginSuccess, }: LoginPageProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
7
|
export default DefaultLoginPage;
|
|
@@ -8,6 +8,7 @@ interface GenericOTPProps {
|
|
|
8
8
|
attemptCount?: number;
|
|
9
9
|
remainingAttempts?: number;
|
|
10
10
|
isMaxAttemptsReached?: boolean;
|
|
11
|
+
maxOTPDigits?: number;
|
|
11
12
|
}
|
|
12
|
-
export declare const GenericOTPVerifier: ({ value, setValue, setLoading, onChangeOTP, fieldName, attemptCount, remainingAttempts, isMaxAttemptsReached, }: GenericOTPProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare const GenericOTPVerifier: ({ value, setValue, setLoading, onChangeOTP, fieldName, attemptCount, remainingAttempts, isMaxAttemptsReached, maxOTPDigits, }: GenericOTPProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
14
|
export {};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import "ldrs/react/Waveform.css";
|
|
3
|
-
declare const LoadingSpinner: ({ loadingText }: {
|
|
1
|
+
declare const LoadingScreen: ({ loadingText }: {
|
|
4
2
|
loadingText?: string;
|
|
5
3
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
export default
|
|
4
|
+
export default LoadingScreen;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import z from "zod";
|
|
2
2
|
declare const MFAEndpointsSchema: z.ZodObject<{
|
|
3
|
-
|
|
4
|
-
RegisterNewChallenge: z.ZodURL;
|
|
5
|
-
RegisterVerify: z.ZodURL;
|
|
3
|
+
ValidateUserMFA: z.ZodURL;
|
|
6
4
|
RetrieveAuthChallenge: z.ZodURL;
|
|
7
5
|
AuthChallengeVerify: z.ZodURL;
|
|
8
6
|
}, z.core.$strip>;
|
|
@@ -13,8 +11,13 @@ interface MFAGateProps {
|
|
|
13
11
|
usePassKey?: boolean;
|
|
14
12
|
useADLogin?: boolean;
|
|
15
13
|
CredentialsAuthEndpoint?: string;
|
|
16
|
-
PassKeysRegisterProps?: Record<string, unknown>;
|
|
17
14
|
MFAEndpoints?: MFAEndpoints;
|
|
15
|
+
requiresMFA?: boolean;
|
|
16
|
+
onAuthSuccess?: (tokens: {
|
|
17
|
+
accessToken: string;
|
|
18
|
+
idToken: string;
|
|
19
|
+
}) => void;
|
|
20
|
+
onAuthError?: (error: any) => void;
|
|
18
21
|
}
|
|
19
|
-
declare const MFAGate: ({ children, fallback, usePassKey, useADLogin, CredentialsAuthEndpoint,
|
|
22
|
+
declare const MFAGate: ({ children, fallback, usePassKey, useADLogin, CredentialsAuthEndpoint, MFAEndpoints, requiresMFA, onAuthSuccess, onAuthError, }: MFAGateProps) => string | number | bigint | boolean | 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 | null;
|
|
20
23
|
export default MFAGate;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { MFAEndpoints } from "./MFAGate";
|
|
2
2
|
interface MFAOptionsProps {
|
|
3
|
-
onComplete
|
|
3
|
+
onComplete: (success: boolean) => void;
|
|
4
4
|
onAuthFailed?: () => void;
|
|
5
5
|
MFAEndpoints: MFAEndpoints;
|
|
6
|
-
|
|
6
|
+
usePassKeys?: boolean;
|
|
7
7
|
}
|
|
8
|
-
declare const MFAOptions: ({ onComplete, onAuthFailed, MFAEndpoints,
|
|
8
|
+
declare const MFAOptions: ({ onComplete, onAuthFailed, MFAEndpoints, usePassKeys, }: MFAOptionsProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
export default MFAOptions;
|
|
@@ -3,15 +3,21 @@ import { UseCAMSAuthReturn } from "../hooks/useCAMSAuth";
|
|
|
3
3
|
import { UseCAMSMSALAuthReturn } from "../hooks/useCAMSMSALAuth";
|
|
4
4
|
type AuthMode = "REGULAR" | "MSAL";
|
|
5
5
|
interface BaseCAMSContextValue {
|
|
6
|
-
|
|
7
|
-
setUserProfile: (
|
|
6
|
+
user: Profile | null;
|
|
7
|
+
setUserProfile: (user: Profile | null) => void;
|
|
8
8
|
authMode: AuthMode;
|
|
9
9
|
}
|
|
10
10
|
interface RegularCAMSContextValue extends BaseCAMSContextValue, UseCAMSAuthReturn {
|
|
11
11
|
authMode: "REGULAR";
|
|
12
12
|
}
|
|
13
13
|
interface MSALCAMSContextValue extends BaseCAMSContextValue, UseCAMSMSALAuthReturn {
|
|
14
|
+
email: string;
|
|
14
15
|
authMode: "MSAL";
|
|
16
|
+
onAuthSuccess?: (tokens: {
|
|
17
|
+
accessToken: string;
|
|
18
|
+
idToken: string;
|
|
19
|
+
}) => void;
|
|
20
|
+
onAuthError?: (error: any) => void;
|
|
15
21
|
}
|
|
16
22
|
export type CAMSContextValue = RegularCAMSContextValue | MSALCAMSContextValue;
|
|
17
23
|
export declare const CAMSContext: import("react").Context<CAMSContextValue | null>;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import "../utils/crypto-polyfill";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import { PublicClientApplication, Configuration } from "@azure/msal-browser";
|
|
4
3
|
import { UseCAMSAuthOptions } from "../hooks/useCAMSAuth";
|
|
5
|
-
import { UseCAMSMSALAuthOptions } from "../hooks/useCAMSMSALAuth";
|
|
6
4
|
import { useCAMSContext } from "../context/CAMSContext";
|
|
7
5
|
interface BaseProviderProps {
|
|
8
6
|
children: React.ReactNode;
|
|
@@ -11,10 +9,16 @@ interface BaseProviderProps {
|
|
|
11
9
|
interface RegularProviderProps extends BaseProviderProps, Omit<UseCAMSAuthOptions, "appCode"> {
|
|
12
10
|
mode: "REGULAR";
|
|
13
11
|
}
|
|
14
|
-
interface MSALProviderProps extends BaseProviderProps
|
|
12
|
+
interface MSALProviderProps extends BaseProviderProps {
|
|
15
13
|
mode: "MSAL";
|
|
14
|
+
ValidateUserEndpoint: string;
|
|
16
15
|
msalConfig: Configuration;
|
|
17
16
|
msalInstance?: PublicClientApplication;
|
|
17
|
+
onAuthSuccess?: (tokens: {
|
|
18
|
+
accessToken: string;
|
|
19
|
+
idToken: string;
|
|
20
|
+
}) => void;
|
|
21
|
+
onAuthError?: (error: any) => void;
|
|
18
22
|
}
|
|
19
23
|
type UnifiedCAMSProviderProps = RegularProviderProps | MSALProviderProps;
|
|
20
24
|
export declare function UnifiedCAMSProvider(props: UnifiedCAMSProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import "../utils/crypto-polyfill";
|
|
2
|
-
import { CAMSError,
|
|
2
|
+
import { CAMSError, type MFAAuthenticatedResponse, type Credentials } from "@nibssplc/cams-sdk";
|
|
3
3
|
export interface UseCAMSMSALAuthOptions {
|
|
4
|
-
onAuthSuccess?: (token: string) => void;
|
|
5
|
-
onAuthError?: (error: CAMSError) => void;
|
|
6
4
|
onTokenExpired?: () => void;
|
|
7
5
|
scopes?: string[];
|
|
8
6
|
storageKey?: string;
|
|
@@ -10,7 +8,9 @@ export interface UseCAMSMSALAuthOptions {
|
|
|
10
8
|
messageOrigin?: string;
|
|
11
9
|
appCode: string;
|
|
12
10
|
allowedOrigins?: string[];
|
|
13
|
-
|
|
11
|
+
ValidateUserEndpoint: string;
|
|
12
|
+
activeCookiePeriod?: number;
|
|
13
|
+
DisableCAMSUserProfileValidation?: boolean;
|
|
14
14
|
}
|
|
15
15
|
export interface UseCAMSMSALAuthReturn {
|
|
16
16
|
login: () => Promise<void>;
|
|
@@ -22,10 +22,11 @@ export interface UseCAMSMSALAuthReturn {
|
|
|
22
22
|
idToken: string;
|
|
23
23
|
accessToken: string;
|
|
24
24
|
appCode: string;
|
|
25
|
-
|
|
25
|
+
email: string;
|
|
26
26
|
requiresMFA: boolean;
|
|
27
|
-
completeMFA: (data:
|
|
27
|
+
completeMFA: (data: MFAAuthenticatedResponse) => Promise<MFAAuthenticatedResponse>;
|
|
28
28
|
setRequiresMFA: React.Dispatch<React.SetStateAction<boolean>>;
|
|
29
|
-
|
|
29
|
+
LoginADCredentials: (credentials: Credentials, appCode: string, endpoint: string) => Promise<MFAAuthenticatedResponse>;
|
|
30
|
+
activeCookiePeriod: number;
|
|
30
31
|
}
|
|
31
32
|
export declare function useCAMSMSALAuth(options: UseCAMSMSALAuthOptions): UseCAMSMSALAuthReturn;
|
|
@@ -3,7 +3,7 @@ import { register, authenticate } from '../components/CoreFIDO';
|
|
|
3
3
|
* A React hook that provides access to the WebAuthn `register` and `authenticate` functions.
|
|
4
4
|
* @returns An object containing the `register` and `authenticate` functions.
|
|
5
5
|
*/
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const useWebAuthN: () => {
|
|
7
7
|
register: typeof register;
|
|
8
8
|
authenticate: typeof authenticate;
|
|
9
9
|
};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
idToken: string;
|
|
1
|
+
import { type Credentials, MFAAuthenticatedResponse } from "@nibssplc/cams-sdk";
|
|
2
|
+
export declare const useOTPHandler: ({ email, appCode, instCode, MFAEndpoint, onAuthComplete, }: {
|
|
3
|
+
email: string;
|
|
5
4
|
appCode: string;
|
|
6
|
-
|
|
5
|
+
instCode?: string;
|
|
7
6
|
MFAEndpoint?: string;
|
|
8
|
-
onAuthComplete: (state: boolean, data:
|
|
7
|
+
onAuthComplete: (state: boolean, data: MFAAuthenticatedResponse | null) => Promise<void>;
|
|
9
8
|
}) => {
|
|
10
9
|
handleSubmitOTP: (authenticationValue: string) => Promise<boolean>;
|
|
11
10
|
loading: boolean;
|
|
@@ -15,8 +14,8 @@ export declare const useOTPHandler: ({ provider, accessToken, idToken, appCode,
|
|
|
15
14
|
resetAttempts: () => void;
|
|
16
15
|
remainingAttempts: number;
|
|
17
16
|
};
|
|
18
|
-
export declare const useCredentialsHandler: (onAuthComplete: (state: boolean, data:
|
|
19
|
-
handleSubmitCredentials: (
|
|
17
|
+
export declare const useCredentialsHandler: (onAuthComplete: (state: boolean, data: MFAAuthenticatedResponse | null) => void) => {
|
|
18
|
+
handleSubmitCredentials: (CredentialsAuthEndpoint: string, credentials: Credentials) => Promise<boolean>;
|
|
20
19
|
loading: boolean;
|
|
21
20
|
setLoading: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
22
21
|
attemptCount: number;
|