@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.
@@ -8,6 +8,7 @@ export interface UseCAMSMSALAuthOptions {
8
8
  mfaUrl?: string;
9
9
  prompt?: string;
10
10
  messageOrigin?: string;
11
+ appCode: string;
11
12
  allowedOrigins?: string[];
12
13
  }
13
14
  export interface UseCAMSMSALAuthReturn {
package/dist/index.cjs.js CHANGED
@@ -16726,6 +16726,7 @@ function useAccount(accountIdentifiers) {
16726
16726
  function useCAMSMSALAuth(options) {
16727
16727
  var _this = this;
16728
16728
  if (options === void 0) { options = {
16729
+ appCode: "",
16729
16730
  mfaUrl: "/auth/multi-factor",
16730
16731
  storageKey: "CAMS-MSAL-AUTH-SDK",
16731
16732
  }; }
@@ -16733,8 +16734,7 @@ function useCAMSMSALAuth(options) {
16733
16734
  var account = useAccount(accounts[0] || {});
16734
16735
  var _b = React__default.useState(null), error = _b[0], setError = _b[1];
16735
16736
  var _c = React__default.useState(""), idToken = _c[0], setIdToken = _c[1];
16736
- var _d = React__default.useState(""), appCode = _d[0], setAppCode = _d[1];
16737
- var _e = React__default.useState(""), accessToken = _e[0], setAccessToken = _e[1];
16737
+ var _d = React__default.useState(""), accessToken = _d[0], setAccessToken = _d[1];
16738
16738
  var isLoading = inProgress !== InteractionStatus.None;
16739
16739
  var isAuthenticated = !!account && !!accessToken;
16740
16740
  var scopes = options.scopes || ["openid", "profile", "email"];
@@ -16752,11 +16752,11 @@ function useCAMSMSALAuth(options) {
16752
16752
  var stored = localStorage.getItem(options.storageKey);
16753
16753
  if (stored) {
16754
16754
  try {
16755
- var _a = JSON.parse(stored), accessToken_1 = _a.accessToken, idToken_1 = _a.idToken, appCode_1 = _a.appCode;
16755
+ var _a = JSON.parse(stored), accessToken_1 = _a.accessToken, idToken_1 = _a.idToken, appCode = _a.appCode;
16756
16756
  if (accessToken_1 && isTokenValid(accessToken_1)) {
16757
16757
  setAccessToken(accessToken_1);
16758
16758
  setIdToken(idToken_1);
16759
- setAppCode(appCode_1);
16759
+ console.log("App Code >>>", appCode, options.appCode);
16760
16760
  }
16761
16761
  else {
16762
16762
  localStorage.removeItem(options.storageKey);
@@ -16943,7 +16943,6 @@ function useCAMSMSALAuth(options) {
16943
16943
  _a.sent();
16944
16944
  setAccessToken("");
16945
16945
  setIdToken("");
16946
- setAppCode("");
16947
16946
  setError(null);
16948
16947
  if (typeof window !== "undefined") {
16949
16948
  localStorage.removeItem(options.storageKey);
@@ -16967,7 +16966,7 @@ function useCAMSMSALAuth(options) {
16967
16966
  error: error,
16968
16967
  idToken: idToken,
16969
16968
  accessToken: accessToken,
16970
- appCode: appCode,
16969
+ appCode: options.appCode,
16971
16970
  };
16972
16971
  }
16973
16972
 
@@ -17391,7 +17390,7 @@ if (process.env.NODE_ENV === 'production') {
17391
17390
  var jsxRuntimeExports = jsxRuntime.exports;
17392
17391
 
17393
17392
  var CAMSContext$1 = React__default.createContext(null);
17394
- function useCAMSContext() {
17393
+ function useCAMSContext$1() {
17395
17394
  var context = React__default.useContext(CAMSContext$1);
17396
17395
  if (!context) {
17397
17396
  throw new Error('useCAMSContext must be used within a CAMSProvider');
@@ -17401,7 +17400,7 @@ function useCAMSContext() {
17401
17400
 
17402
17401
  function ProtectedRoute(_a) {
17403
17402
  var children = _a.children, fallback = _a.fallback, redirectTo = _a.redirectTo;
17404
- var _b = useCAMSContext(), isAuthenticated = _b.isAuthenticated, isLoading = _b.isLoading;
17403
+ var _b = useCAMSContext$1(), isAuthenticated = _b.isAuthenticated, isLoading = _b.isLoading;
17405
17404
  if (isLoading) {
17406
17405
  return fallback || jsxRuntimeExports.jsx("div", { children: "Loading..." });
17407
17406
  }
@@ -19252,7 +19251,9 @@ function CAMSProviderInner(props) {
19252
19251
  var regularAuth = useCAMSAuth(mode === "REGULAR"
19253
19252
  ? __assign(__assign({}, props), { appCode: appCode })
19254
19253
  : { appCode: "" });
19255
- var msalAuth = useCAMSMSALAuth(mode === "MSAL" ? props : {});
19254
+ var msalAuth = useCAMSMSALAuth(mode === "MSAL"
19255
+ ? __assign(__assign({}, props), { appCode: appCode })
19256
+ : { appCode: "" });
19256
19257
  var auth = mode === "REGULAR" ? regularAuth : msalAuth;
19257
19258
  var profileStorageKey = "".concat(auth.storageKey, "-PROFILE");
19258
19259
  var getInitialProfile = function () {
@@ -19320,12 +19321,23 @@ function UnifiedCAMSProvider(props) {
19320
19321
  }
19321
19322
  return jsxRuntimeExports.jsx(CAMSProviderInner, __assign({}, props));
19322
19323
  }
19324
+ function useCAMSContext() {
19325
+ var context = React__default.useContext(CAMSContext);
19326
+ if (!context) {
19327
+ throw new Error("useCAMSContext must be used within a UnifiedCAMSProvider");
19328
+ }
19329
+ return context;
19330
+ }
19331
+ // Backward compatibility exports
19332
+ var CAMSProvider = function (props) { return (jsxRuntimeExports.jsx(UnifiedCAMSProvider, __assign({}, props, { mode: "REGULAR" }))); };
19323
19333
 
19324
19334
  exports.CAMSMSALProvider = CAMSMSALProvider;
19335
+ exports.CAMSProvider = CAMSProvider;
19325
19336
  exports.ClientOnly = ClientOnly;
19326
19337
  exports.ProtectedRoute = ProtectedRoute;
19327
19338
  exports.UnifiedCAMSProvider = UnifiedCAMSProvider;
19328
19339
  exports.useCAMSAuth = useCAMSAuth;
19340
+ exports.useCAMSContext = useCAMSContext;
19329
19341
  exports.useCAMSMSALAuth = useCAMSMSALAuth;
19330
19342
  exports.useCAMSMSALContext = useCAMSMSALContext;
19331
19343
  Object.keys(camsSdk).forEach(function (k) {