@nibssplc/cams-sdk-react 1.0.0-rc.130 → 1.0.0-rc.132

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.
@@ -2,6 +2,7 @@ export interface LoginPageProps {
2
2
  CredentialsAuthEndpoint?: string;
3
3
  useADLogin?: boolean;
4
4
  onADLoginSuccess?: () => void;
5
+ DisableCAMSUserProfileValidation?: boolean;
5
6
  }
6
- declare const DefaultLoginPage: ({ useADLogin, CredentialsAuthEndpoint, onADLoginSuccess, }: LoginPageProps) => import("react/jsx-runtime").JSX.Element;
7
+ declare const DefaultLoginPage: ({ useADLogin, CredentialsAuthEndpoint, onADLoginSuccess, DisableCAMSUserProfileValidation, }: LoginPageProps) => import("react/jsx-runtime").JSX.Element;
7
8
  export default DefaultLoginPage;
@@ -18,6 +18,7 @@ interface MFAGateProps {
18
18
  idToken: string;
19
19
  }) => void;
20
20
  onAuthError?: (error: any) => void;
21
+ DisableCAMSUserProfileValidation?: boolean;
21
22
  }
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;
23
+ declare const MFAGate: ({ children, fallback, usePassKey, useADLogin, CredentialsAuthEndpoint, MFAEndpoints, requiresMFA, onAuthSuccess, onAuthError, DisableCAMSUserProfileValidation, }: 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;
23
24
  export default MFAGate;
@@ -19,6 +19,7 @@ interface MSALProviderProps extends BaseProviderProps {
19
19
  idToken: string;
20
20
  }) => void;
21
21
  onAuthError?: (error: any) => void;
22
+ DisableCAMSUserProfileValidation?: boolean;
22
23
  }
23
24
  type UnifiedCAMSProviderProps = RegularProviderProps | MSALProviderProps;
24
25
  export declare function UnifiedCAMSProvider(props: UnifiedCAMSProviderProps): import("react/jsx-runtime").JSX.Element;
package/dist/index.cjs.js CHANGED
@@ -922,7 +922,7 @@ function CAMSProviderCore(props) {
922
922
  ? __assign(__assign({}, props), { appCode: appCode, idleTimeout: 0 })
923
923
  : { appCode: "" });
924
924
  var msalAuth = useCAMSMSALAuth(mode === "MSAL"
925
- ? __assign(__assign({}, props), { appCode: appCode, ValidateUserEndpoint: props.ValidateUserEndpoint, activeCookiePeriod: 1 })
925
+ ? __assign(__assign({}, props), { appCode: appCode, ValidateUserEndpoint: props.ValidateUserEndpoint, activeCookiePeriod: 1, DisableCAMSUserProfileValidation: props.DisableCAMSUserProfileValidation })
926
926
  : { appCode: "", ValidateUserEndpoint: "" });
927
927
  var auth = mode === "REGULAR" ? regularAuth : msalAuth;
928
928
  var profileStorageKey = "".concat(auth.storageKey, "-PROFILE");
@@ -1670,7 +1670,7 @@ var ADLoginModal = function (_a) {
1670
1670
  };
1671
1671
 
1672
1672
  var DefaultLoginPage = function (_a) {
1673
- var useADLogin = _a.useADLogin, CredentialsAuthEndpoint = _a.CredentialsAuthEndpoint, onADLoginSuccess = _a.onADLoginSuccess;
1673
+ var useADLogin = _a.useADLogin, CredentialsAuthEndpoint = _a.CredentialsAuthEndpoint, onADLoginSuccess = _a.onADLoginSuccess; _a.DisableCAMSUserProfileValidation;
1674
1674
  var cardVariants = {
1675
1675
  hidden: { opacity: 0, scale: 0.8, y: 50 },
1676
1676
  visible: {
@@ -1766,7 +1766,7 @@ var MFAEndpointsSchema = z.object({
1766
1766
  AuthChallengeVerify: z.url("MFA AuthChallengeVerify must be a valid URL"),
1767
1767
  });
1768
1768
  var MFAGate = function (_a) {
1769
- var children = _a.children, _b = _a.fallback, fallback = _b === void 0 ? (jsxRuntime.jsx("div", { className: "h-screen flex items-center justify-center", children: jsxRuntime.jsx(LoadingScreen, {}) })) : _b; _a.usePassKey; var _d = _a.useADLogin, useADLogin = _d === void 0 ? false : _d, CredentialsAuthEndpoint = _a.CredentialsAuthEndpoint, MFAEndpoints = _a.MFAEndpoints, requiresMFA = _a.requiresMFA, onAuthSuccess = _a.onAuthSuccess, onAuthError = _a.onAuthError;
1769
+ var children = _a.children, _b = _a.fallback, fallback = _b === void 0 ? (jsxRuntime.jsx("div", { className: "h-screen flex items-center justify-center", children: jsxRuntime.jsx(LoadingScreen, {}) })) : _b; _a.usePassKey; var _d = _a.useADLogin, useADLogin = _d === void 0 ? false : _d, CredentialsAuthEndpoint = _a.CredentialsAuthEndpoint, MFAEndpoints = _a.MFAEndpoints, requiresMFA = _a.requiresMFA, onAuthSuccess = _a.onAuthSuccess, onAuthError = _a.onAuthError, DisableCAMSUserProfileValidation = _a.DisableCAMSUserProfileValidation;
1770
1770
  var context = useCAMSContext();
1771
1771
  var _e = React.useState("Loading"), authState = _e[0], setAuthState = _e[1];
1772
1772
  var ValidatedMFAEndpoints = React.useMemo(function () {
@@ -1780,24 +1780,42 @@ var MFAGate = function (_a) {
1780
1780
  // Extract the specific values we need from context for dependencies
1781
1781
  var contextRequiresMFA = "requiresMFA" in context ? context.requiresMFA : false;
1782
1782
  var contextAccessToken = "accessToken" in context ? context.accessToken : "";
1783
- var handleComplete = React.useCallback(function (success) {
1783
+ var fireOnAuthSuccess = React.useCallback(function (tokens) { return __awaiter$1(void 0, void 0, void 0, function () {
1784
1784
  var _a;
1785
- if (success) {
1786
- var accessToken = "accessToken" in context ? context.accessToken : "";
1787
- var idToken = "idToken" in context ? context.idToken : "";
1788
- camsSdk.Logger.info("MFA Authentication Successful");
1789
- setAuthState("Authenticated");
1790
- var tokens = { accessToken: accessToken, idToken: idToken };
1791
- console.log("[MFAGate] Calling onAuthSuccess callbacks", { tokens: tokens, hasLocalCallback: !!onAuthSuccess, hasContextCallback: "onAuthSuccess" in context && !!context.onAuthSuccess });
1792
- onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess(tokens);
1793
- if ("onAuthSuccess" in context) {
1794
- (_a = context.onAuthSuccess) === null || _a === void 0 ? void 0 : _a.call(context, tokens);
1785
+ return __generator$1(this, function (_b) {
1786
+ switch (_b.label) {
1787
+ case 0: return [4 /*yield*/, Promise.all([
1788
+ onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess(tokens),
1789
+ "onAuthSuccess" in context ? (_a = context.onAuthSuccess) === null || _a === void 0 ? void 0 : _a.call(context, tokens) : undefined,
1790
+ ])];
1791
+ case 1:
1792
+ _b.sent();
1793
+ return [2 /*return*/];
1795
1794
  }
1796
- }
1797
- else {
1798
- camsSdk.Logger.error("MFA Authentication Failed");
1799
- }
1800
- }, [context, onAuthSuccess]);
1795
+ });
1796
+ }); }, [context, onAuthSuccess]);
1797
+ var handleComplete = React.useCallback(function (success) { return __awaiter$1(void 0, void 0, void 0, function () {
1798
+ var accessToken, idToken;
1799
+ return __generator$1(this, function (_a) {
1800
+ switch (_a.label) {
1801
+ case 0:
1802
+ if (!success) return [3 /*break*/, 2];
1803
+ accessToken = "accessToken" in context ? context.accessToken : "";
1804
+ idToken = "idToken" in context ? context.idToken : "";
1805
+ camsSdk.Logger.info("MFA Authentication Successful");
1806
+ setAuthState("Completing");
1807
+ return [4 /*yield*/, fireOnAuthSuccess({ accessToken: accessToken, idToken: idToken })];
1808
+ case 1:
1809
+ _a.sent();
1810
+ setAuthState("Authenticated");
1811
+ return [3 /*break*/, 3];
1812
+ case 2:
1813
+ camsSdk.Logger.error("MFA Authentication Failed");
1814
+ _a.label = 3;
1815
+ case 3: return [2 /*return*/];
1816
+ }
1817
+ });
1818
+ }); }, [context, fireOnAuthSuccess]);
1801
1819
  var handleAuthFailed = React.useCallback(function () { return __awaiter$1(void 0, void 0, void 0, function () {
1802
1820
  var _a;
1803
1821
  return __generator$1(this, function (_b) {
@@ -1830,13 +1848,22 @@ var MFAGate = function (_a) {
1830
1848
  return;
1831
1849
  }
1832
1850
  var shouldRequireMFA = requiresMFA !== null && requiresMFA !== void 0 ? requiresMFA : contextRequiresMFA;
1833
- setAuthState(shouldRequireMFA ? "MFA_Required" : "Authenticated");
1851
+ if (shouldRequireMFA) {
1852
+ setAuthState("MFA_Required");
1853
+ }
1854
+ else {
1855
+ var accessToken = "accessToken" in context ? context.accessToken : "";
1856
+ var idToken = "idToken" in context ? context.idToken : "";
1857
+ setAuthState("Completing");
1858
+ fireOnAuthSuccess({ accessToken: accessToken, idToken: idToken }).then(function () { return setAuthState("Authenticated"); });
1859
+ }
1834
1860
  }, [
1835
1861
  context.isLoading,
1836
1862
  context.user,
1837
1863
  contextRequiresMFA,
1838
1864
  contextAccessToken,
1839
1865
  requiresMFA,
1866
+ fireOnAuthSuccess,
1840
1867
  ]);
1841
1868
  if (useADLogin && !CredentialsAuthEndpoint)
1842
1869
  return jsxRuntime.jsx(ErrorFallback, { message: "Invalid AD Login Configuration." });
@@ -1846,18 +1873,20 @@ var MFAGate = function (_a) {
1846
1873
  // For REGULAR mode, check if user is authenticated
1847
1874
  if (context.user)
1848
1875
  return jsxRuntime.jsx(jsxRuntime.Fragment, { children: children });
1849
- return (jsxRuntime.jsx(DefaultLoginPage, { useADLogin: useADLogin, CredentialsAuthEndpoint: CredentialsAuthEndpoint, onADLoginSuccess: function () { return setAuthState("Authenticated"); } }));
1876
+ return (jsxRuntime.jsx(DefaultLoginPage, { useADLogin: useADLogin, CredentialsAuthEndpoint: CredentialsAuthEndpoint, onADLoginSuccess: function () { return setAuthState("Authenticated"); }, DisableCAMSUserProfileValidation: DisableCAMSUserProfileValidation }));
1850
1877
  }
1851
1878
  switch (authState) {
1852
1879
  case "Loading":
1853
1880
  return fallback;
1854
1881
  case "MFA_Required":
1855
1882
  return (jsxRuntime.jsx(MFAOptions, { MFAEndpoints: ValidatedMFAEndpoints, onComplete: handleComplete, onAuthFailed: handleAuthFailed }));
1883
+ case "Completing":
1884
+ return fallback;
1856
1885
  case "Authenticated":
1857
1886
  return jsxRuntime.jsx(jsxRuntime.Fragment, { children: children });
1858
1887
  case "Unauthenticated":
1859
1888
  default:
1860
- return (jsxRuntime.jsx(DefaultLoginPage, { useADLogin: useADLogin, CredentialsAuthEndpoint: CredentialsAuthEndpoint, onADLoginSuccess: function () { return setAuthState("Authenticated"); } }));
1889
+ return (jsxRuntime.jsx(DefaultLoginPage, { useADLogin: useADLogin, CredentialsAuthEndpoint: CredentialsAuthEndpoint, onADLoginSuccess: function () { return setAuthState("Authenticated"); }, DisableCAMSUserProfileValidation: DisableCAMSUserProfileValidation }));
1861
1890
  }
1862
1891
  };
1863
1892