@nibssplc/cams-sdk-react 1.0.0-rc.8 → 1.0.0-rc.81
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 +18 -4
- package/dist/components/ADLoginModal.d.ts +1 -0
- package/dist/components/CoreFIDO.d.ts +1 -9
- package/dist/components/MFAGate.d.ts +8 -2
- package/dist/components/UnifiedCAMSProvider.d.ts +7 -2
- package/dist/context/CAMSContext.d.ts +8 -2
- package/dist/hooks/useCAMSMSALAuth.d.ts +8 -7
- package/dist/hooks/useOTPHandler.d.ts +7 -8
- package/dist/index.cjs.js +519 -914
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +522 -917
- package/dist/index.esm.js.map +1 -1
- package/dist/styles.css +1 -0
- package/package.json +10 -7
- package/dist/lib/actions/Axiosinstance.d.ts +0 -1
- package/dist/utils/DeviceID.d.ts +0 -4
package/README.md
CHANGED
|
@@ -13,6 +13,19 @@ 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
|
+
|
|
16
29
|
## Features
|
|
17
30
|
|
|
18
31
|
- ⚛️ React hooks for authentication
|
|
@@ -273,13 +286,14 @@ export default function RootLayout({ children }) {
|
|
|
273
286
|
|
|
274
287
|
## Styling
|
|
275
288
|
|
|
276
|
-
|
|
289
|
+
The SDK bundles all required Tailwind CSS, so you don't need to configure Tailwind in your project. Simply import the styles:
|
|
277
290
|
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
npx tailwindcss init
|
|
291
|
+
```tsx
|
|
292
|
+
import '@nibssplc/cams-sdk-react/dist/styles.css';
|
|
281
293
|
```
|
|
282
294
|
|
|
295
|
+
If your project already uses Tailwind, the SDK styles will work alongside your existing configuration.
|
|
296
|
+
|
|
283
297
|
## Examples
|
|
284
298
|
|
|
285
299
|
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,6 +1,6 @@
|
|
|
1
1
|
import z from "zod";
|
|
2
2
|
declare const MFAEndpointsSchema: z.ZodObject<{
|
|
3
|
-
|
|
3
|
+
ValidateUserMFA: z.ZodURL;
|
|
4
4
|
RegisterNewChallenge: z.ZodURL;
|
|
5
5
|
RegisterVerify: z.ZodURL;
|
|
6
6
|
RetrieveAuthChallenge: z.ZodURL;
|
|
@@ -15,6 +15,12 @@ interface MFAGateProps {
|
|
|
15
15
|
CredentialsAuthEndpoint?: string;
|
|
16
16
|
PassKeysRegisterProps?: Record<string, unknown>;
|
|
17
17
|
MFAEndpoints?: MFAEndpoints;
|
|
18
|
+
requiresMFA?: boolean;
|
|
19
|
+
onAuthSuccess?: (tokens: {
|
|
20
|
+
accessToken: string;
|
|
21
|
+
idToken: string;
|
|
22
|
+
}) => void;
|
|
23
|
+
onAuthError?: (error: any) => void;
|
|
18
24
|
}
|
|
19
|
-
declare const MFAGate: ({ children, fallback, usePassKey, useADLogin, CredentialsAuthEndpoint, PassKeysRegisterProps, MFAEndpoints, }: 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;
|
|
25
|
+
declare const MFAGate: ({ children, fallback, usePassKey, useADLogin, CredentialsAuthEndpoint, PassKeysRegisterProps, 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
26
|
export default MFAGate;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { PublicClientApplication, Configuration } from "@azure/msal-browser";
|
|
3
3
|
import { UseCAMSAuthOptions } from "../hooks/useCAMSAuth";
|
|
4
|
-
import { UseCAMSMSALAuthOptions } from "../hooks/useCAMSMSALAuth";
|
|
5
4
|
import { useCAMSContext } from "../context/CAMSContext";
|
|
6
5
|
interface BaseProviderProps {
|
|
7
6
|
children: React.ReactNode;
|
|
@@ -10,10 +9,16 @@ interface BaseProviderProps {
|
|
|
10
9
|
interface RegularProviderProps extends BaseProviderProps, Omit<UseCAMSAuthOptions, "appCode"> {
|
|
11
10
|
mode: "REGULAR";
|
|
12
11
|
}
|
|
13
|
-
interface MSALProviderProps extends BaseProviderProps
|
|
12
|
+
interface MSALProviderProps extends BaseProviderProps {
|
|
14
13
|
mode: "MSAL";
|
|
14
|
+
ValidateUserEndpoint: string;
|
|
15
15
|
msalConfig: Configuration;
|
|
16
16
|
msalInstance?: PublicClientApplication;
|
|
17
|
+
onAuthSuccess?: (tokens: {
|
|
18
|
+
accessToken: string;
|
|
19
|
+
idToken: string;
|
|
20
|
+
}) => void;
|
|
21
|
+
onAuthError?: (error: any) => void;
|
|
17
22
|
}
|
|
18
23
|
type UnifiedCAMSProviderProps = RegularProviderProps | MSALProviderProps;
|
|
19
24
|
export declare function UnifiedCAMSProvider(props: UnifiedCAMSProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -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,7 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../utils/crypto-polyfill";
|
|
2
|
+
import { CAMSError, type MFAAuthenticatedResponse } from "@nibssplc/cams-sdk";
|
|
2
3
|
export interface UseCAMSMSALAuthOptions {
|
|
3
|
-
onAuthSuccess?: (token: string) => void;
|
|
4
|
-
onAuthError?: (error: CAMSError) => void;
|
|
5
4
|
onTokenExpired?: () => void;
|
|
6
5
|
scopes?: string[];
|
|
7
6
|
storageKey?: string;
|
|
@@ -9,7 +8,8 @@ export interface UseCAMSMSALAuthOptions {
|
|
|
9
8
|
messageOrigin?: string;
|
|
10
9
|
appCode: string;
|
|
11
10
|
allowedOrigins?: string[];
|
|
12
|
-
|
|
11
|
+
ValidateUserEndpoint: string;
|
|
12
|
+
activeCookiePeriod?: number;
|
|
13
13
|
}
|
|
14
14
|
export interface UseCAMSMSALAuthReturn {
|
|
15
15
|
login: () => Promise<void>;
|
|
@@ -21,10 +21,11 @@ export interface UseCAMSMSALAuthReturn {
|
|
|
21
21
|
idToken: string;
|
|
22
22
|
accessToken: string;
|
|
23
23
|
appCode: string;
|
|
24
|
-
|
|
24
|
+
email: string;
|
|
25
25
|
requiresMFA: boolean;
|
|
26
|
-
completeMFA: (data:
|
|
26
|
+
completeMFA: (data: MFAAuthenticatedResponse) => Promise<MFAAuthenticatedResponse>;
|
|
27
27
|
setRequiresMFA: React.Dispatch<React.SetStateAction<boolean>>;
|
|
28
|
-
|
|
28
|
+
LoginADCredentials: () => Promise<MFAAuthenticatedResponse>;
|
|
29
|
+
activeCookiePeriod: number;
|
|
29
30
|
}
|
|
30
31
|
export declare function useCAMSMSALAuth(options: UseCAMSMSALAuthOptions): UseCAMSMSALAuthReturn;
|
|
@@ -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) => 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;
|