@nibssplc/cams-sdk-react 0.0.1-beta.24 → 0.0.1-beta.26

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.esm.js CHANGED
@@ -16690,13 +16690,16 @@ function useAccount(accountIdentifiers) {
16690
16690
 
16691
16691
  function useCAMSMSALAuth(options) {
16692
16692
  var _this = this;
16693
- if (options === void 0) { options = {}; }
16693
+ if (options === void 0) { options = {
16694
+ mfaUrl: "/auth/multi-factor",
16695
+ }; }
16694
16696
  var _a = useMsal(), instance = _a.instance, inProgress = _a.inProgress, accounts = _a.accounts;
16695
16697
  var account = useAccount(accounts[0] || {});
16696
16698
  var _b = useState(null), error = _b[0], setError = _b[1];
16697
16699
  var _c = useState(null), token = _c[0], setToken = _c[1];
16698
- var _d = useState(null), profile = _d[0], setProfile = _d[1];
16699
- var _e = useState(false), isMFAPending = _e[0], setIsMFAPending = _e[1];
16700
+ var _d = useState(null), idToken = _d[0], setIdToken = _d[1];
16701
+ var _e = useState(null), accessToken = _e[0], setAccessToken = _e[1];
16702
+ var _f = useState(false), isMFAPending = _f[0], setIsMFAPending = _f[1];
16700
16703
  var isLoading = inProgress !== InteractionStatus.None;
16701
16704
  var isAuthenticated = !!account && !!token && !isMFAPending;
16702
16705
  var scopes = options.scopes || ["openid", "profile", "email"];
@@ -16711,32 +16714,15 @@ function useCAMSMSALAuth(options) {
16711
16714
  })
16712
16715
  .then(function (response) {
16713
16716
  var _a, _b;
16714
- if (options.mfaUrl) {
16715
- setIsMFAPending(true);
16716
- (_a = options.onMFARequired) === null || _a === void 0 ? void 0 : _a.call(options, response.accessToken, account);
16717
- if (typeof window !== "undefined") {
16718
- window.location.href = options.mfaUrl;
16719
- }
16720
- }
16721
- else {
16722
- setToken(response.accessToken);
16723
- setProfile({
16724
- type: "AUTH_SUCCESS",
16725
- userProfile: {
16726
- name: account.name || "",
16727
- email: account.username || "",
16728
- isAuthenticated: true,
16729
- mfaIsEnabled: true,
16730
- message: "Authentication successful",
16731
- userType: "USER",
16732
- tokens: {
16733
- Nonce: "",
16734
- Bearer: response.accessToken,
16735
- },
16736
- },
16737
- });
16738
- (_b = options.onAuthSuccess) === null || _b === void 0 ? void 0 : _b.call(options, response.accessToken);
16717
+ setToken(response.accessToken);
16718
+ setAccessToken(response.accessToken);
16719
+ setIdToken(response.idToken);
16720
+ setIsMFAPending(true);
16721
+ (_a = options.onMFARequired) === null || _a === void 0 ? void 0 : _a.call(options, response.accessToken, account);
16722
+ if (typeof window !== "undefined") {
16723
+ window.location.href = options.mfaUrl;
16739
16724
  }
16725
+ (_b = options.onAuthSuccess) === null || _b === void 0 ? void 0 : _b.call(options, response.accessToken);
16740
16726
  })
16741
16727
  .catch(function (err) {
16742
16728
  var _a;
@@ -16802,7 +16788,6 @@ function useCAMSMSALAuth(options) {
16802
16788
  case 1:
16803
16789
  _a.sent();
16804
16790
  setToken(null);
16805
- setProfile(null);
16806
16791
  setError(null);
16807
16792
  setIsMFAPending(false);
16808
16793
  return [3 /*break*/, 3];
@@ -16815,40 +16800,16 @@ function useCAMSMSALAuth(options) {
16815
16800
  }
16816
16801
  });
16817
16802
  }); }, [instance]);
16818
- var completeMFA = useCallback(function (mfaToken) {
16819
- var _a;
16820
- setToken(mfaToken);
16821
- setIsMFAPending(false);
16822
- if (account) {
16823
- setProfile({
16824
- type: "AUTH_SUCCESS",
16825
- userProfile: {
16826
- name: account.name || "",
16827
- email: account.username || "",
16828
- isAuthenticated: true,
16829
- mfaIsEnabled: true,
16830
- message: "Authentication successful",
16831
- userType: "USER",
16832
- tokens: {
16833
- Nonce: "",
16834
- Bearer: token !== null && token !== void 0 ? token : "",
16835
- },
16836
- },
16837
- });
16838
- }
16839
- (_a = options.onAuthSuccess) === null || _a === void 0 ? void 0 : _a.call(options, mfaToken);
16840
- }, [account, options]);
16841
16803
  return {
16842
16804
  login: login,
16843
16805
  logout: logout,
16844
- completeMFA: completeMFA,
16845
16806
  isAuthenticated: isAuthenticated,
16846
16807
  isLoading: isLoading,
16847
16808
  isMFAPending: isMFAPending,
16848
16809
  error: error,
16849
16810
  token: token,
16850
- profile: profile,
16851
- account: account,
16811
+ idToken: idToken,
16812
+ accessToken: accessToken,
16852
16813
  };
16853
16814
  }
16854
16815