@nibssplc/cams-sdk-react 0.0.1-beta.53 → 0.0.1-beta.55

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/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  export * from './hooks/useCAMSAuth';
2
2
  export * from './hooks/useCAMSMSALAuth';
3
- export * from './components/CAMSProvider';
4
3
  export * from './components/ProtectedRoute';
5
4
  export { CAMSMSALProvider, useCAMSMSALContext } from './components/CAMSMSALProvider';
6
5
  export * from './components/ClientOnly';
package/dist/index.esm.js CHANGED
@@ -16707,6 +16707,7 @@ function useAccount(accountIdentifiers) {
16707
16707
  function useCAMSMSALAuth(options) {
16708
16708
  var _this = this;
16709
16709
  if (options === void 0) { options = {
16710
+ appCode: "",
16710
16711
  mfaUrl: "/auth/multi-factor",
16711
16712
  storageKey: "CAMS-MSAL-AUTH-SDK",
16712
16713
  }; }
@@ -16714,8 +16715,7 @@ function useCAMSMSALAuth(options) {
16714
16715
  var account = useAccount(accounts[0] || {});
16715
16716
  var _b = useState(null), error = _b[0], setError = _b[1];
16716
16717
  var _c = useState(""), idToken = _c[0], setIdToken = _c[1];
16717
- var _d = useState(""), appCode = _d[0], setAppCode = _d[1];
16718
- var _e = useState(""), accessToken = _e[0], setAccessToken = _e[1];
16718
+ var _d = useState(""), accessToken = _d[0], setAccessToken = _d[1];
16719
16719
  var isLoading = inProgress !== InteractionStatus.None;
16720
16720
  var isAuthenticated = !!account && !!accessToken;
16721
16721
  var scopes = options.scopes || ["openid", "profile", "email"];
@@ -16733,11 +16733,11 @@ function useCAMSMSALAuth(options) {
16733
16733
  var stored = localStorage.getItem(options.storageKey);
16734
16734
  if (stored) {
16735
16735
  try {
16736
- var _a = JSON.parse(stored), accessToken_1 = _a.accessToken, idToken_1 = _a.idToken, appCode_1 = _a.appCode;
16736
+ var _a = JSON.parse(stored), accessToken_1 = _a.accessToken, idToken_1 = _a.idToken, appCode = _a.appCode;
16737
16737
  if (accessToken_1 && isTokenValid(accessToken_1)) {
16738
16738
  setAccessToken(accessToken_1);
16739
16739
  setIdToken(idToken_1);
16740
- setAppCode(appCode_1);
16740
+ console.log("App Code >>>", appCode, options.appCode);
16741
16741
  }
16742
16742
  else {
16743
16743
  localStorage.removeItem(options.storageKey);
@@ -16924,7 +16924,6 @@ function useCAMSMSALAuth(options) {
16924
16924
  _a.sent();
16925
16925
  setAccessToken("");
16926
16926
  setIdToken("");
16927
- setAppCode("");
16928
16927
  setError(null);
16929
16928
  if (typeof window !== "undefined") {
16930
16929
  localStorage.removeItem(options.storageKey);
@@ -16948,7 +16947,7 @@ function useCAMSMSALAuth(options) {
16948
16947
  error: error,
16949
16948
  idToken: idToken,
16950
16949
  accessToken: accessToken,
16951
- appCode: appCode,
16950
+ appCode: options.appCode,
16952
16951
  };
16953
16952
  }
16954
16953
 
@@ -17372,7 +17371,7 @@ if (process.env.NODE_ENV === 'production') {
17372
17371
  var jsxRuntimeExports = jsxRuntime.exports;
17373
17372
 
17374
17373
  var CAMSContext$1 = createContext(null);
17375
- function useCAMSContext() {
17374
+ function useCAMSContext$1() {
17376
17375
  var context = useContext(CAMSContext$1);
17377
17376
  if (!context) {
17378
17377
  throw new Error('useCAMSContext must be used within a CAMSProvider');
@@ -17382,7 +17381,7 @@ function useCAMSContext() {
17382
17381
 
17383
17382
  function ProtectedRoute(_a) {
17384
17383
  var children = _a.children, fallback = _a.fallback, redirectTo = _a.redirectTo;
17385
- var _b = useCAMSContext(), isAuthenticated = _b.isAuthenticated, isLoading = _b.isLoading;
17384
+ var _b = useCAMSContext$1(), isAuthenticated = _b.isAuthenticated, isLoading = _b.isLoading;
17386
17385
  if (isLoading) {
17387
17386
  return fallback || jsxRuntimeExports.jsx("div", { children: "Loading..." });
17388
17387
  }
@@ -19233,7 +19232,9 @@ function CAMSProviderInner(props) {
19233
19232
  var regularAuth = useCAMSAuth(mode === "REGULAR"
19234
19233
  ? __assign(__assign({}, props), { appCode: appCode })
19235
19234
  : { appCode: "" });
19236
- var msalAuth = useCAMSMSALAuth(mode === "MSAL" ? props : {});
19235
+ var msalAuth = useCAMSMSALAuth(mode === "MSAL"
19236
+ ? __assign(__assign({}, props), { appCode: appCode })
19237
+ : { appCode: "" });
19237
19238
  var auth = mode === "REGULAR" ? regularAuth : msalAuth;
19238
19239
  var profileStorageKey = "".concat(auth.storageKey, "-PROFILE");
19239
19240
  var getInitialProfile = function () {
@@ -19301,6 +19302,15 @@ function UnifiedCAMSProvider(props) {
19301
19302
  }
19302
19303
  return jsxRuntimeExports.jsx(CAMSProviderInner, __assign({}, props));
19303
19304
  }
19305
+ function useCAMSContext() {
19306
+ var context = useContext(CAMSContext);
19307
+ if (!context) {
19308
+ throw new Error("useCAMSContext must be used within a UnifiedCAMSProvider");
19309
+ }
19310
+ return context;
19311
+ }
19312
+ // Backward compatibility exports
19313
+ var CAMSProvider = function (props) { return (jsxRuntimeExports.jsx(UnifiedCAMSProvider, __assign({}, props, { mode: "REGULAR" }))); };
19304
19314
 
19305
- export { CAMSMSALProvider, ClientOnly, ProtectedRoute, UnifiedCAMSProvider, useCAMSAuth, useCAMSMSALAuth, useCAMSMSALContext };
19315
+ export { CAMSMSALProvider, CAMSProvider, ClientOnly, ProtectedRoute, UnifiedCAMSProvider, useCAMSAuth, useCAMSContext, useCAMSMSALAuth, useCAMSMSALContext };
19306
19316
  //# sourceMappingURL=index.esm.js.map