@nibssplc/cams-sdk-react 1.0.0-rc.135 → 1.0.0-rc.136

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 CHANGED
@@ -293,6 +293,105 @@ export default function RootLayout({ children }) {
293
293
  }
294
294
  ```
295
295
 
296
+ ## Sample Implementation - MSAL Mode with MFA
297
+
298
+ ### Environment Variables
299
+
300
+ ```bash
301
+ # .env.local
302
+ NEXT_PUBLIC_AZURE_MSAL_CLIENT_ID=your-client-id
303
+ NEXT_PUBLIC_AZURE_MSAL_ALLOWED_TENANT_GROUP=your-tenant-id
304
+ NEXTAUTH_URL=http://localhost:3000
305
+ NEXT_PUBLIC_CAMS_APP_ID=your-app-guid
306
+ NEXT_PUBLIC_CAMS_SDK_BASE_URL=https://your-cams-api-endpoint.com
307
+ AUTH_MAX_TIMEOUT=60000
308
+ ```
309
+
310
+ ### Configuration Setup
311
+
312
+ ```tsx
313
+ // lib/msalConfig.ts
314
+ import { Configuration } from '@azure/msal-browser';
315
+
316
+ export const msalConfig: Configuration = {
317
+ auth: {
318
+ clientId: process.env.NEXT_PUBLIC_AZURE_MSAL_CLIENT_ID ?? "",
319
+ authority: `https://login.microsoftonline.com/${process.env.NEXT_PUBLIC_AZURE_MSAL_ALLOWED_TENANT_GROUP}`,
320
+ redirectUri: process.env.NEXTAUTH_URL || (typeof window !== "undefined" ? window.location.origin : ""),
321
+ },
322
+ system: {
323
+ loadFrameTimeout: Number(process.env.AUTH_MAX_TIMEOUT) || 60000,
324
+ allowNativeBroker: false,
325
+ },
326
+ };
327
+ ```
328
+
329
+ ### Provider Setup with MFA
330
+
331
+ ```tsx
332
+ // app/providers.tsx
333
+ 'use client';
334
+
335
+ import { UnifiedCAMSProvider, MFAGate } from '@nibssplc/cams-sdk-react';
336
+ import { msalConfig } from '@/lib/msalConfig';
337
+ import { toast } from 'sonner'; // or your preferred toast library
338
+
339
+ export function Providers({ children }: { children: React.ReactNode }) {
340
+ return (
341
+ <UnifiedCAMSProvider
342
+ mode="MSAL"
343
+ appCode={process.env.NEXT_PUBLIC_CAMS_APP_ID!}
344
+ ValidateUserEndpoint={`${process.env.NEXT_PUBLIC_CAMS_SDK_BASE_URL}/api/Auth/AuthenticateUserMFA`}
345
+ msalConfig={msalConfig}
346
+ DisableCAMSUserProfileValidation={true}
347
+ >
348
+ <MFAGate
349
+ requiresMFA={false}
350
+ DisableCAMSUserProfileValidation={true}
351
+ MFAEndpoints={{
352
+ ValidateUserMFA: `${process.env.NEXT_PUBLIC_CAMS_SDK_BASE_URL}/api/Auth/AuthenticateUserMFA`,
353
+ RetrieveAuthChallenge: `${process.env.NEXT_PUBLIC_CAMS_SDK_BASE_URL}/api/Auth/RetrieveAuthChallenge`,
354
+ AuthChallengeVerify: `${process.env.NEXT_PUBLIC_CAMS_SDK_BASE_URL}/api/Auth/AuthChallengeVerification`,
355
+ }}
356
+ onAuthError={(err) =>
357
+ toast.error(`Authentication Error: ${err.message || "An Error Occurred During Authentication."}`)
358
+ }
359
+ onAuthSuccess={async (tokens) => {
360
+ toast.success("Authentication successful!");
361
+ // Handle successful authentication
362
+ }}
363
+ >
364
+ {children}
365
+ </MFAGate>
366
+ </UnifiedCAMSProvider>
367
+ );
368
+ }
369
+ ```
370
+
371
+ ### Usage in Components
372
+
373
+ ```tsx
374
+ // app/dashboard.tsx
375
+ 'use client';
376
+
377
+ import { useCAMSContext } from '@nibssplc/cams-sdk-react';
378
+
379
+ export default function Dashboard() {
380
+ const { isAuthenticated, userProfile, logout } = useCAMSContext();
381
+
382
+ if (!isAuthenticated) {
383
+ return <div>Loading...</div>;
384
+ }
385
+
386
+ return (
387
+ <div>
388
+ <h1>Welcome, {userProfile?.name}!</h1>
389
+ <button onClick={logout}>Logout</button>
390
+ </div>
391
+ );
392
+ }
393
+ ```
394
+
296
395
  ## Styling
297
396
 
298
397
  The SDK bundles all required Tailwind CSS, so you don't need to configure Tailwind in your project. Simply import the styles:
@@ -312,12 +411,6 @@ import '@nibssplc/cams-sdk-react/dist/styles.css';
312
411
 
313
412
  If your project already uses Tailwind, the SDK styles will work alongside your existing configuration.
314
413
 
315
- ## Examples
316
-
317
- See the [examples](../../examples) directory for complete implementations:
318
- - `integrated-mfa-example.tsx` - MSAL mode with MFA
319
- - `popup-auth-example.tsx` - Regular popup authentication
320
-
321
414
  ## License
322
415
 
323
416
  MIT
package/dist/index.cjs.js CHANGED
@@ -1763,7 +1763,7 @@ var DefaultLoginPage = function (_a) {
1763
1763
  // variant="outline"
1764
1764
  , {
1765
1765
  // variant="outline"
1766
- className: "w-full flex items-center justify-center cursor-pointer bg-[#506f4a] hover:bg-[#506f4a] rounded-lg border border-transparent px-5 py-8 text-base font-medium transition-colors duration-250", onClick: handleMSALLogin, disabled: isLoading, children: [jsxRuntime.jsx("img", { src: MicrosoftLogo, alt: "Microsoft Logo", width: 35, height: 35 }), jsxRuntime.jsx("span", { className: "ml-2", children: isLoading ? "Logging in..." : "Sign in with Microsoft" })] }), useADLogin && (jsxRuntime.jsxs(Button, { className: "w-full flex items-center justify-center cursor-pointer bg-[#506f4a] hover:bg-[#506f4a] rounded-lg border border-transparent px-5 py-8 text-base font-medium transition-colors duration-250", onClick: function () { return setShowADModal(true); }, disabled: isLoading, children: [jsxRuntime.jsx(lucideReact.KeyIcon, { className: "text-[#506f4a]", size: 64 }), jsxRuntime.jsx("span", { children: isLoading
1766
+ className: "w-full flex items-center justify-center cursor-pointer bg-[#506f4a] hover:bg-[#506f4a] text-white rounded-lg border border-transparent px-5 py-8 text-base font-medium transition-colors duration-250", onClick: handleMSALLogin, disabled: isLoading, children: [jsxRuntime.jsx("img", { src: MicrosoftLogo, alt: "Microsoft Logo", width: 35, height: 35 }), jsxRuntime.jsx("span", { className: "ml-2", children: isLoading ? "Logging in..." : "Sign in with Microsoft" })] }), useADLogin && (jsxRuntime.jsxs(Button, { className: "w-full flex items-center justify-center cursor-pointer bg-[#506f4a] hover:bg-[#506f4a] rounded-lg border border-transparent px-5 py-8 text-base font-medium transition-colors duration-250", onClick: function () { return setShowADModal(true); }, disabled: isLoading, children: [jsxRuntime.jsx(lucideReact.KeyIcon, { className: "text-[#506f4a]", size: 64 }), jsxRuntime.jsx("span", { children: isLoading
1767
1767
  ? "Logging in..."
1768
1768
  : "Sign in with Active Directory" })] }))] }), jsxRuntime.jsxs(CardFooter, { className: "flex items-center justify-center mt-6 space-x-2 text-gray-400 text-sm", children: [jsxRuntime.jsx(lucideReact.ShieldCheck, { className: "w-6 h-6 text-[#506f4a] pulse-glow" }), jsxRuntime.jsx("span", { className: "font-semibold", children: "Powered By NIBSS" })] })] }) }) }, "landing"), jsxRuntime.jsx(ADLoginModal, { open: showADModal, onOpenChange: setShowADModal, isLoading: context.isLoading || isCredAuthLoading, setIsLoading: setIsCredAuthLoading, onLogin: function (_a) { return __awaiter$1(void 0, [_a], void 0, function (_b) {
1769
1769
  var username = _b.username, password = _b.password, MFACode = _b.MFACode, appCode = _b.appCode;