@nibssplc/cams-sdk-react 0.0.1-beta.19 → 0.0.1-beta.20

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.
@@ -7,6 +7,7 @@ export interface UseCAMSMSALAuthOptions {
7
7
  onMFARequired?: (msalToken: string, account: AccountInfo) => void;
8
8
  scopes?: string[];
9
9
  mfaUrl?: string;
10
+ prompt?: string;
10
11
  }
11
12
  export interface UseCAMSMSALAuthReturn {
12
13
  login: () => Promise<void>;
package/dist/index.cjs.js CHANGED
@@ -16721,22 +16721,20 @@ function useCAMSMSALAuth(options) {
16721
16721
  var scopes = options.scopes || ["openid", "profile", "email"];
16722
16722
  React__default.useEffect(function () {
16723
16723
  if (account && !isMFAPending) {
16724
- // Get token silently
16724
+ // Get token in foreground popup
16725
16725
  instance
16726
16726
  .acquireTokenPopup({
16727
16727
  scopes: scopes,
16728
16728
  account: account,
16729
+ prompt: options.prompt || "select_account",
16729
16730
  })
16730
16731
  .then(function (response) {
16731
16732
  var _a, _b;
16732
16733
  if (options.mfaUrl) {
16733
- // Redirect to MFA page
16734
16734
  setIsMFAPending(true);
16735
16735
  (_a = options.onMFARequired) === null || _a === void 0 ? void 0 : _a.call(options, response.accessToken, account);
16736
- window.location.href = "".concat(options.mfaUrl, "?token=").concat(encodeURIComponent(response.accessToken));
16737
16736
  }
16738
16737
  else {
16739
- // Complete auth without MFA
16740
16738
  setToken(response.accessToken);
16741
16739
  setProfile({
16742
16740
  type: "AUTH_SUCCESS",
@@ -16758,7 +16756,7 @@ function useCAMSMSALAuth(options) {
16758
16756
  })
16759
16757
  .catch(function (err) {
16760
16758
  var _a;
16761
- var camsError = new camsSdk.CAMSError(camsSdk.CAMSErrorType.API_VALIDATION_ERROR, "Failed to acquire token silently: " + err);
16759
+ var camsError = new camsSdk.CAMSError(camsSdk.CAMSErrorType.API_VALIDATION_ERROR, "Failed to acquire token: " + err);
16762
16760
  setError(camsError);
16763
16761
  (_a = options.onAuthError) === null || _a === void 0 ? void 0 : _a.call(options, camsError);
16764
16762
  });
@@ -16774,9 +16772,9 @@ function useCAMSMSALAuth(options) {
16774
16772
  _b.label = 1;
16775
16773
  case 1:
16776
16774
  _b.trys.push([1, 3, , 4]);
16777
- return [4 /*yield*/, instance.loginRedirect({
16775
+ return [4 /*yield*/, instance.loginPopup({
16778
16776
  scopes: scopes,
16779
- prompt: "select_account",
16777
+ prompt: options.prompt || "select_account",
16780
16778
  })];
16781
16779
  case 2:
16782
16780
  _b.sent();