@nibssplc/cams-sdk-react 1.0.0-rc.48 → 1.0.0-rc.49

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.
@@ -16,6 +16,11 @@ interface MFAGateProps {
16
16
  PassKeysRegisterProps?: Record<string, unknown>;
17
17
  MFAEndpoints?: MFAEndpoints;
18
18
  requiresMFA?: boolean;
19
+ onAuthSuccess?: (tokens: {
20
+ accessToken: string;
21
+ idToken: string;
22
+ }) => void;
23
+ onAuthError?: (error: any) => void;
19
24
  }
20
- declare const MFAGate: ({ children, fallback, usePassKey, useADLogin, CredentialsAuthEndpoint, PassKeysRegisterProps, MFAEndpoints, requiresMFA, }: 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;
21
26
  export default MFAGate;
package/dist/index.cjs.js CHANGED
@@ -2410,7 +2410,7 @@ var MFAGate = function (_a) {
2410
2410
  // loginComponent: LoginComponent = DefaultLoginPage,
2411
2411
  _c = _a.usePassKey,
2412
2412
  // loginComponent: LoginComponent = DefaultLoginPage,
2413
- usePassKey = _c === void 0 ? false : _c, _d = _a.useADLogin, useADLogin = _d === void 0 ? false : _d, CredentialsAuthEndpoint = _a.CredentialsAuthEndpoint, PassKeysRegisterProps = _a.PassKeysRegisterProps, MFAEndpoints = _a.MFAEndpoints, requiresMFA = _a.requiresMFA;
2413
+ usePassKey = _c === void 0 ? false : _c, _d = _a.useADLogin, useADLogin = _d === void 0 ? false : _d, CredentialsAuthEndpoint = _a.CredentialsAuthEndpoint, PassKeysRegisterProps = _a.PassKeysRegisterProps, MFAEndpoints = _a.MFAEndpoints, requiresMFA = _a.requiresMFA, onAuthSuccess = _a.onAuthSuccess, onAuthError = _a.onAuthError;
2414
2414
  var context = useCAMSContext();
2415
2415
  var validatedMFAEndpoints = React.useMemo(function () {
2416
2416
  var parsed = MFAEndpointsSchema.safeParse(MFAEndpoints);
@@ -2423,21 +2423,24 @@ var MFAGate = function (_a) {
2423
2423
  var handleComplete = React.useCallback(function (success) {
2424
2424
  var _a;
2425
2425
  if (success && context.authMode === "MSAL") {
2426
- (_a = context.onAuthSuccess) === null || _a === void 0 ? void 0 : _a.call(context, {
2426
+ var tokens = {
2427
2427
  accessToken: context.accessToken,
2428
2428
  idToken: context.idToken,
2429
- });
2429
+ };
2430
+ onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess(tokens);
2431
+ (_a = context.onAuthSuccess) === null || _a === void 0 ? void 0 : _a.call(context, tokens);
2430
2432
  }
2431
2433
  else if (!success) {
2432
2434
  camsSdk.Logger.error("MFA authentication failed");
2433
2435
  }
2434
- }, [context]);
2436
+ }, [context, onAuthSuccess]);
2435
2437
  var handleAuthFailed = React.useCallback(function () { return __awaiter$1(void 0, void 0, void 0, function () {
2436
2438
  var _a;
2437
2439
  return __generator$1(this, function (_b) {
2438
2440
  switch (_b.label) {
2439
2441
  case 0:
2440
2442
  if (context.authMode === "MSAL" && context.error) {
2443
+ onAuthError === null || onAuthError === void 0 ? void 0 : onAuthError(context.error);
2441
2444
  (_a = context.onAuthError) === null || _a === void 0 ? void 0 : _a.call(context, context.error);
2442
2445
  }
2443
2446
  return [4 /*yield*/, context.logout()];
@@ -2446,7 +2449,7 @@ var MFAGate = function (_a) {
2446
2449
  return [2 /*return*/];
2447
2450
  }
2448
2451
  });
2449
- }); }, [context]);
2452
+ }); }, [context, onAuthError]);
2450
2453
  if (useADLogin && !CredentialsAuthEndpoint)
2451
2454
  return jsxRuntimeExports.jsx(ErrorFallback, { message: "Invalid AD Login Configuration." });
2452
2455
  if (!validatedMFAEndpoints)