@okta/okta-auth-js 6.3.1 → 6.4.1

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.
Files changed (156) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +6 -0
  3. package/cjs/AuthStateManager.js +1 -0
  4. package/cjs/AuthStateManager.js.map +1 -1
  5. package/cjs/OktaAuth.js +10 -11
  6. package/cjs/OktaAuth.js.map +1 -1
  7. package/cjs/OktaUserAgent.js +2 -2
  8. package/cjs/ServiceManager.js +1 -1
  9. package/cjs/ServiceManager.js.map +1 -1
  10. package/cjs/TokenManager.js.map +1 -1
  11. package/cjs/crypto/verifyToken.js +2 -1
  12. package/cjs/crypto/verifyToken.js.map +1 -1
  13. package/cjs/errors/AuthApiError.js.map +1 -1
  14. package/cjs/errors/OAuthError.js +7 -1
  15. package/cjs/errors/OAuthError.js.map +1 -1
  16. package/cjs/fetch/fetchRequest.js +17 -3
  17. package/cjs/fetch/fetchRequest.js.map +1 -1
  18. package/cjs/http/request.js +7 -3
  19. package/cjs/http/request.js.map +1 -1
  20. package/cjs/idx/idxState/index.js +55 -0
  21. package/cjs/idx/idxState/index.js.map +1 -0
  22. package/cjs/idx/{idx-js → idxState}/v1/actionParser.js +1 -0
  23. package/cjs/idx/idxState/v1/actionParser.js.map +1 -0
  24. package/cjs/idx/{idx-js → idxState}/v1/generateIdxAction.js +43 -30
  25. package/cjs/idx/idxState/v1/generateIdxAction.js.map +1 -0
  26. package/cjs/idx/{idx-js → idxState}/v1/idxResponseParser.js +8 -8
  27. package/cjs/idx/idxState/v1/idxResponseParser.js.map +1 -0
  28. package/cjs/idx/{idx-js → idxState}/v1/makeIdxState.js +3 -2
  29. package/cjs/idx/idxState/v1/makeIdxState.js.map +1 -0
  30. package/cjs/idx/{idx-js → idxState}/v1/parsers.js +1 -0
  31. package/cjs/idx/idxState/v1/parsers.js.map +1 -0
  32. package/cjs/idx/{idx-js → idxState}/v1/remediationParser.js +4 -2
  33. package/cjs/idx/idxState/v1/remediationParser.js.map +1 -0
  34. package/cjs/idx/interact.js +42 -21
  35. package/cjs/idx/interact.js.map +1 -1
  36. package/cjs/idx/introspect.js +37 -12
  37. package/cjs/idx/introspect.js.map +1 -1
  38. package/cjs/idx/remediate.js +56 -132
  39. package/cjs/idx/remediate.js.map +1 -1
  40. package/cjs/idx/remediators/AuthenticatorEnrollmentData.js.map +1 -1
  41. package/cjs/idx/remediators/AuthenticatorVerificationData.js +7 -6
  42. package/cjs/idx/remediators/AuthenticatorVerificationData.js.map +1 -1
  43. package/cjs/idx/remediators/Base/AuthenticatorData.js.map +1 -1
  44. package/cjs/idx/remediators/Base/Remediator.js +12 -2
  45. package/cjs/idx/remediators/Base/Remediator.js.map +1 -1
  46. package/cjs/idx/remediators/Base/SelectAuthenticator.js.map +1 -1
  47. package/cjs/idx/remediators/Base/VerifyAuthenticator.js.map +1 -1
  48. package/cjs/idx/remediators/ChallengeAuthenticator.js.map +1 -1
  49. package/cjs/idx/remediators/EnrollAuthenticator.js.map +1 -1
  50. package/cjs/idx/remediators/EnrollPoll.js.map +1 -1
  51. package/cjs/idx/remediators/EnrollProfile.js.map +1 -1
  52. package/cjs/idx/remediators/EnrollmentChannelData.js.map +1 -1
  53. package/cjs/idx/remediators/Identify.js.map +1 -1
  54. package/cjs/idx/remediators/ReEnrollAuthenticator.js.map +1 -1
  55. package/cjs/idx/remediators/ResetAuthenticator.js.map +1 -1
  56. package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js.map +1 -1
  57. package/cjs/idx/remediators/SelectAuthenticatorEnroll.js.map +1 -1
  58. package/cjs/idx/remediators/SelectAuthenticatorUnlockAccount.js.map +1 -1
  59. package/cjs/idx/remediators/SelectEnrollProfile.js.map +1 -1
  60. package/cjs/idx/remediators/SelectEnrollmentChannel.js.map +1 -1
  61. package/cjs/idx/remediators/Skip.js.map +1 -1
  62. package/cjs/idx/run.js +16 -12
  63. package/cjs/idx/run.js.map +1 -1
  64. package/cjs/idx/types/idx-js.js +2 -0
  65. package/cjs/idx/types/idx-js.js.map +1 -1
  66. package/cjs/idx/types/index.js +0 -138
  67. package/cjs/idx/types/index.js.map +1 -1
  68. package/cjs/idx/util.js +127 -5
  69. package/cjs/idx/util.js.map +1 -1
  70. package/cjs/server/serverStorage.js +1 -0
  71. package/cjs/server/serverStorage.js.map +1 -1
  72. package/cjs/tx/AuthTransaction.js.map +1 -1
  73. package/cjs/types/Token.js +0 -1
  74. package/cjs/types/Token.js.map +1 -1
  75. package/cjs/util/object.js.map +1 -1
  76. package/cjs/util/types.js.map +1 -1
  77. package/dist/okta-auth-js.min.js +1 -1
  78. package/dist/okta-auth-js.min.js.map +1 -1
  79. package/dist/okta-auth-js.umd.js +1 -1
  80. package/dist/okta-auth-js.umd.js.map +1 -1
  81. package/esm/esm.browser.js +744 -928
  82. package/esm/esm.browser.js.map +1 -1
  83. package/esm/esm.node.mjs +609 -730
  84. package/esm/esm.node.mjs.map +1 -1
  85. package/lib/TokenManager.d.ts +2 -2
  86. package/lib/errors/OAuthError.d.ts +2 -0
  87. package/lib/idx/flow/RemediationFlow.d.ts +2 -2
  88. package/lib/idx/idxState/index.d.ts +7 -0
  89. package/lib/idx/{idx-js → idxState}/v1/actionParser.d.ts +0 -0
  90. package/lib/idx/{idx-js → idxState}/v1/generateIdxAction.d.ts +3 -1
  91. package/lib/idx/{idx-js → idxState}/v1/idxResponseParser.d.ts +3 -2
  92. package/lib/idx/{idx-js → idxState}/v1/makeIdxState.d.ts +3 -2
  93. package/lib/idx/{idx-js → idxState}/v1/parsers.d.ts +0 -0
  94. package/lib/idx/{idx-js → idxState}/v1/remediationParser.d.ts +2 -1
  95. package/lib/idx/interact.d.ts +22 -0
  96. package/lib/idx/remediate.d.ts +9 -12
  97. package/lib/idx/remediators/AuthenticatorEnrollmentData.d.ts +1 -2
  98. package/lib/idx/remediators/AuthenticatorVerificationData.d.ts +3 -3
  99. package/lib/idx/remediators/Base/AuthenticatorData.d.ts +3 -4
  100. package/lib/idx/remediators/Base/Remediator.d.ts +8 -4
  101. package/lib/idx/remediators/Base/SelectAuthenticator.d.ts +2 -3
  102. package/lib/idx/remediators/Base/VerifyAuthenticator.d.ts +3 -4
  103. package/lib/idx/remediators/ChallengeAuthenticator.d.ts +1 -2
  104. package/lib/idx/remediators/EnrollAuthenticator.d.ts +1 -2
  105. package/lib/idx/remediators/EnrollPoll.d.ts +1 -2
  106. package/lib/idx/remediators/EnrollProfile.d.ts +1 -2
  107. package/lib/idx/remediators/EnrollmentChannelData.d.ts +1 -2
  108. package/lib/idx/remediators/Identify.d.ts +1 -2
  109. package/lib/idx/remediators/ReEnrollAuthenticator.d.ts +1 -2
  110. package/lib/idx/remediators/ResetAuthenticator.d.ts +1 -2
  111. package/lib/idx/remediators/SelectAuthenticatorAuthenticate.d.ts +1 -2
  112. package/lib/idx/remediators/SelectAuthenticatorEnroll.d.ts +1 -2
  113. package/lib/idx/remediators/SelectAuthenticatorUnlockAccount.d.ts +1 -2
  114. package/lib/idx/remediators/SelectEnrollProfile.d.ts +1 -2
  115. package/lib/idx/remediators/SelectEnrollmentChannel.d.ts +1 -2
  116. package/lib/idx/remediators/Skip.d.ts +1 -2
  117. package/lib/idx/types/idx-js.d.ts +5 -2
  118. package/lib/idx/types/index.d.ts +26 -17
  119. package/lib/idx/util.d.ts +7 -4
  120. package/lib/types/EventEmitter.d.ts +3 -3
  121. package/lib/types/Service.d.ts +6 -6
  122. package/lib/types/Storage.d.ts +6 -6
  123. package/lib/types/TokenManager.d.ts +5 -2
  124. package/lib/types/UserClaims.d.ts +1 -1
  125. package/lib/util/types.d.ts +1 -1
  126. package/package.json +10 -10
  127. package/cjs/idx/headers.js +0 -59
  128. package/cjs/idx/headers.js.map +0 -1
  129. package/cjs/idx/idx-js/client.js +0 -91
  130. package/cjs/idx/idx-js/client.js.map +0 -1
  131. package/cjs/idx/idx-js/index.js +0 -40
  132. package/cjs/idx/idx-js/index.js.map +0 -1
  133. package/cjs/idx/idx-js/interact.js +0 -83
  134. package/cjs/idx/idx-js/interact.js.map +0 -1
  135. package/cjs/idx/idx-js/introspect.js +0 -62
  136. package/cjs/idx/idx-js/introspect.js.map +0 -1
  137. package/cjs/idx/idx-js/parsers.js +0 -41
  138. package/cjs/idx/idx-js/parsers.js.map +0 -1
  139. package/cjs/idx/idx-js/util.js +0 -34
  140. package/cjs/idx/idx-js/util.js.map +0 -1
  141. package/cjs/idx/idx-js/v1/actionParser.js.map +0 -1
  142. package/cjs/idx/idx-js/v1/generateIdxAction.js.map +0 -1
  143. package/cjs/idx/idx-js/v1/idxResponseParser.js.map +0 -1
  144. package/cjs/idx/idx-js/v1/makeIdxState.js.map +0 -1
  145. package/cjs/idx/idx-js/v1/parsers.js.map +0 -1
  146. package/cjs/idx/idx-js/v1/remediationParser.js.map +0 -1
  147. package/cjs/options.js +0 -170
  148. package/cjs/options.js.map +0 -1
  149. package/lib/idx/headers.d.ts +0 -16
  150. package/lib/idx/idx-js/client.d.ts +0 -36
  151. package/lib/idx/idx-js/index.d.ts +0 -35
  152. package/lib/idx/idx-js/interact.d.ts +0 -25
  153. package/lib/idx/idx-js/introspect.d.ts +0 -21
  154. package/lib/idx/idx-js/parsers.d.ts +0 -15
  155. package/lib/idx/idx-js/util.d.ts +0 -12
  156. package/lib/options.d.ts +0 -14
package/esm/esm.node.mjs CHANGED
@@ -149,6 +149,8 @@ var OAuthError = function (_CustomError) {
149
149
  _this.name = 'OAuthError';
150
150
  _this.errorCode = errorCode;
151
151
  _this.errorSummary = summary;
152
+ _this.error = errorCode;
153
+ _this.error_description = summary;
152
154
  return _this;
153
155
  }
154
156
  return OAuthError;
@@ -656,7 +658,11 @@ function httpRequest(sdk, options) {
656
658
  if (sdk.options.transformErrorXHR) {
657
659
  resp = sdk.options.transformErrorXHR(clone(resp));
658
660
  }
659
- err = new AuthApiError(serverErr, resp);
661
+ if (serverErr.error && serverErr.error_description) {
662
+ err = new OAuthError(serverErr.error, serverErr.error_description);
663
+ } else {
664
+ err = new AuthApiError(serverErr, resp);
665
+ }
660
666
  if (err.errorCode === 'E0000011') {
661
667
  storage.delete(STATE_TOKEN_KEY_NAME);
662
668
  }
@@ -3561,7 +3567,7 @@ var ServiceManager = function () {
3561
3567
  key: "start",
3562
3568
  value: function start() {
3563
3569
  if (this.started) {
3564
- this.stop();
3570
+ return;
3565
3571
  }
3566
3572
  if (this.isLeaderRequired()) {
3567
3573
  this.startElector();
@@ -4529,8 +4535,9 @@ function assertValidConfig(args) {
4529
4535
  }
4530
4536
 
4531
4537
  function _createForOfIteratorHelper$6(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$6(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
4532
- function _unsupportedIterableToArray$6(o, minLen) { var _context3; if (!o) return; if (typeof o === "string") return _arrayLikeToArray$6(o, minLen); var n = _sliceInstanceProperty(_context3 = Object.prototype.toString.call(o)).call(_context3, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$6(o, minLen); }
4538
+ function _unsupportedIterableToArray$6(o, minLen) { var _context5; if (!o) return; if (typeof o === "string") return _arrayLikeToArray$6(o, minLen); var n = _sliceInstanceProperty(_context5 = Object.prototype.toString.call(o)).call(_context5, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$6(o, minLen); }
4533
4539
  function _arrayLikeToArray$6(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
4540
+ var appJsonContentTypeRegex = /application\/\w*\+?json/;
4534
4541
  function readData(response) {
4535
4542
  var _context;
4536
4543
  if (response.headers.get('Content-Type') &&
@@ -4577,8 +4584,19 @@ function fetchRequest(method, url, args) {
4577
4584
  var body = args.data;
4578
4585
  var headers = args.headers || {};
4579
4586
  var contentType = headers['Content-Type'] || headers['content-type'] || '';
4580
- if (contentType === 'application/json' && body && typeof body !== 'string') {
4581
- body = _JSON$stringify(body);
4587
+ if (body && typeof body !== 'string') {
4588
+ if (appJsonContentTypeRegex.test(contentType)) {
4589
+ body = _JSON$stringify(body);
4590
+ } else if (contentType === 'application/x-www-form-urlencoded') {
4591
+ var _context3;
4592
+ body = _mapInstanceProperty(_context3 = _Object$entries(body)).call(_context3, function (_ref) {
4593
+ var _context4;
4594
+ var _ref2 = _slicedToArray(_ref, 2),
4595
+ param = _ref2[0],
4596
+ value = _ref2[1];
4597
+ return _concatInstanceProperty(_context4 = "".concat(param, "=")).call(_context4, encodeURIComponent(value));
4598
+ }).join('&');
4599
+ }
4582
4600
  }
4583
4601
  var fetch = window.fetch || crossFetch;
4584
4602
  var fetchPromise = fetch(url, {
@@ -4689,26 +4707,12 @@ var ServerStorage = function () {
4689
4707
  }]);
4690
4708
  return ServerStorage;
4691
4709
  }();
4692
- var serverStorage = new ServerStorage(sharedStorage);
4710
+ var storage = new ServerStorage(sharedStorage);
4693
4711
 
4694
- var BROWSER_STORAGE = {
4695
- token: {
4696
- storageTypes: ['localStorage', 'sessionStorage', 'cookie']
4697
- },
4698
- cache: {
4699
- storageTypes: ['localStorage', 'sessionStorage', 'cookie']
4700
- },
4701
- transaction: {
4702
- storageTypes: ['sessionStorage', 'localStorage', 'cookie']
4703
- },
4704
- 'shared-transaction': {
4705
- storageTypes: ['localStorage']
4706
- },
4707
- 'original-uri': {
4708
- storageTypes: ['localStorage']
4709
- }
4710
- };
4711
- var SERVER_STORAGE = {
4712
+ function getStorage() {
4713
+ return storage;
4714
+ }
4715
+ var STORAGE_MANAGER_OPTIONS = {
4712
4716
  token: {
4713
4717
  storageTypes: ['memory']
4714
4718
  },
@@ -4719,45 +4723,23 @@ var SERVER_STORAGE = {
4719
4723
  storageTypes: ['memory']
4720
4724
  }
4721
4725
  };
4726
+ var enableSharedStorage = false;
4722
4727
  function getCookieSettings() {
4723
4728
  var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4724
- var isHTTPS = arguments.length > 1 ? arguments[1] : undefined;
4725
- var cookieSettings = args.cookies || {};
4726
- if (typeof cookieSettings.secure === 'undefined') {
4727
- cookieSettings.secure = isHTTPS;
4728
- }
4729
- if (typeof cookieSettings.sameSite === 'undefined') {
4730
- cookieSettings.sameSite = cookieSettings.secure ? 'none' : 'lax';
4731
- }
4732
- if (cookieSettings.secure && !isHTTPS) {
4733
- warn('The current page is not being served with the HTTPS protocol.\n' + 'For security reasons, we strongly recommend using HTTPS.\n' + 'If you cannot use HTTPS, set "cookies.secure" option to false.');
4734
- cookieSettings.secure = false;
4735
- }
4736
- if (cookieSettings.sameSite === 'none' && !cookieSettings.secure) {
4737
- cookieSettings.sameSite = 'lax';
4738
- }
4739
- return cookieSettings;
4729
+ return args.cookies;
4740
4730
  }
4731
+
4741
4732
  function getDefaultOptions() {
4742
- var storageUtil$1;
4743
- if (isBrowser()) {
4744
- storageUtil$1 = _Object$assign({}, storageUtil, {
4745
- inMemoryStore: {}
4746
- });
4747
- } else {
4748
- storageUtil$1 = serverStorage;
4749
- }
4750
- var storageManager = isBrowser() ? BROWSER_STORAGE : SERVER_STORAGE;
4751
- var enableSharedStorage = isBrowser() ? true : false;
4752
- return {
4733
+ var options = {
4753
4734
  devMode: false,
4754
4735
  httpRequestClient: fetchRequest,
4755
- storageUtil: storageUtil$1,
4756
- storageManager: storageManager,
4736
+ storageUtil: getStorage(),
4737
+ storageManager: STORAGE_MANAGER_OPTIONS,
4757
4738
  transactionManager: {
4758
4739
  enableSharedStorage: enableSharedStorage
4759
4740
  }
4760
4741
  };
4742
+ return options;
4761
4743
  }
4762
4744
  function mergeOptions(options, args) {
4763
4745
  return _Object$assign({}, options, removeNils(args), {
@@ -4794,7 +4776,7 @@ function buildOptions() {
4794
4776
  devMode: !!args.devMode,
4795
4777
  storageManager: args.storageManager,
4796
4778
  transactionManager: args.transactionManager,
4797
- cookies: isBrowser() ? getCookieSettings(args, isHTTPS()) : args.cookies,
4779
+ cookies: getCookieSettings(args, isHTTPS()),
4798
4780
  flow: args.flow,
4799
4781
  codeChallenge: args.codeChallenge,
4800
4782
  codeChallengeMethod: args.codeChallengeMethod,
@@ -4805,65 +4787,248 @@ function buildOptions() {
4805
4787
  });
4806
4788
  }
4807
4789
 
4808
- var Interceptor = function () {
4809
- function Interceptor() {
4810
- _classCallCheck(this, Interceptor);
4811
- this.handlers = [];
4790
+ function createTransactionMeta(_x) {
4791
+ return _createTransactionMeta.apply(this, arguments);
4792
+ }
4793
+ function _createTransactionMeta() {
4794
+ _createTransactionMeta = _asyncToGenerator( _regeneratorRuntime.mark(function _callee(authClient) {
4795
+ var options,
4796
+ tokenParams,
4797
+ pkceMeta,
4798
+ _Object$assign2,
4799
+ _Object$assign2$flow,
4800
+ flow,
4801
+ _Object$assign2$withC,
4802
+ withCredentials,
4803
+ _Object$assign2$activ,
4804
+ activationToken,
4805
+ _Object$assign2$recov,
4806
+ recoveryToken,
4807
+ meta,
4808
+ _args = arguments;
4809
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
4810
+ while (1) {
4811
+ switch (_context.prev = _context.next) {
4812
+ case 0:
4813
+ options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
4814
+ _context.next = 3;
4815
+ return authClient.token.prepareTokenParams(options);
4816
+ case 3:
4817
+ tokenParams = _context.sent;
4818
+ pkceMeta = createOAuthMeta(authClient, tokenParams);
4819
+ _Object$assign2 = _Object$assign(_Object$assign({}, authClient.options), options), _Object$assign2$flow = _Object$assign2.flow, flow = _Object$assign2$flow === void 0 ? 'default' : _Object$assign2$flow, _Object$assign2$withC = _Object$assign2.withCredentials, withCredentials = _Object$assign2$withC === void 0 ? true : _Object$assign2$withC, _Object$assign2$activ = _Object$assign2.activationToken, activationToken = _Object$assign2$activ === void 0 ? undefined : _Object$assign2$activ, _Object$assign2$recov = _Object$assign2.recoveryToken, recoveryToken = _Object$assign2$recov === void 0 ? undefined : _Object$assign2$recov;
4820
+ meta = _Object$assign(_Object$assign({}, pkceMeta), {
4821
+ flow: flow,
4822
+ withCredentials: withCredentials,
4823
+ activationToken: activationToken,
4824
+ recoveryToken: recoveryToken
4825
+ });
4826
+ return _context.abrupt("return", meta);
4827
+ case 8:
4828
+ case "end":
4829
+ return _context.stop();
4830
+ }
4831
+ }
4832
+ }, _callee);
4833
+ }));
4834
+ return _createTransactionMeta.apply(this, arguments);
4835
+ }
4836
+ function hasSavedInteractionHandle(authClient, options) {
4837
+ var savedMeta = getSavedTransactionMeta(authClient, options);
4838
+ if (savedMeta === null || savedMeta === void 0 ? void 0 : savedMeta.interactionHandle) {
4839
+ return true;
4812
4840
  }
4813
- _createClass(Interceptor, [{
4814
- key: "use",
4815
- value: function use(before) {
4816
- this.handlers.push({
4817
- before: before
4818
- });
4819
- }
4820
- }, {
4821
- key: "clear",
4822
- value: function clear() {
4823
- this.handlers = [];
4841
+ return false;
4842
+ }
4843
+ function getSavedTransactionMeta(authClient, options) {
4844
+ options = removeNils(options);
4845
+ options = _Object$assign(_Object$assign({}, authClient.options), options);
4846
+ var savedMeta;
4847
+ try {
4848
+ savedMeta = authClient.transactionManager.load(options);
4849
+ } catch (e) {
4850
+ }
4851
+ if (!savedMeta) {
4852
+ return;
4853
+ }
4854
+ if (isTransactionMetaValid(savedMeta, options)) {
4855
+ return savedMeta;
4856
+ }
4857
+ warn('Saved transaction meta does not match the current configuration. ' + 'This may indicate that two apps are sharing a storage key.');
4858
+ }
4859
+ function getTransactionMeta(_x2, _x3) {
4860
+ return _getTransactionMeta.apply(this, arguments);
4861
+ }
4862
+ function _getTransactionMeta() {
4863
+ _getTransactionMeta = _asyncToGenerator( _regeneratorRuntime.mark(function _callee2(authClient, options) {
4864
+ var validExistingMeta;
4865
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
4866
+ while (1) {
4867
+ switch (_context2.prev = _context2.next) {
4868
+ case 0:
4869
+ options = removeNils(options);
4870
+ options = _Object$assign(_Object$assign({}, authClient.options), options);
4871
+ validExistingMeta = getSavedTransactionMeta(authClient, options);
4872
+ if (!validExistingMeta) {
4873
+ _context2.next = 5;
4874
+ break;
4875
+ }
4876
+ return _context2.abrupt("return", validExistingMeta);
4877
+ case 5:
4878
+ return _context2.abrupt("return", createTransactionMeta(authClient, options));
4879
+ case 6:
4880
+ case "end":
4881
+ return _context2.stop();
4882
+ }
4883
+ }
4884
+ }, _callee2);
4885
+ }));
4886
+ return _getTransactionMeta.apply(this, arguments);
4887
+ }
4888
+ function saveTransactionMeta(authClient, meta) {
4889
+ authClient.transactionManager.save(meta, {
4890
+ muteWarning: true
4891
+ });
4892
+ }
4893
+ function clearTransactionMeta(authClient) {
4894
+ authClient.transactionManager.clear();
4895
+ }
4896
+ function isTransactionMetaValid(meta) {
4897
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4898
+ var keys = ['issuer', 'clientId', 'redirectUri', 'state', 'codeChallenge', 'codeChallengeMethod', 'activationToken', 'recoveryToken'];
4899
+ if (isTransactionMetaValidForOptions(meta, options, keys) === false) {
4900
+ return false;
4901
+ }
4902
+ var flow = options.flow;
4903
+ if (isTransactionMetaValidForFlow(meta, flow) === false) {
4904
+ return false;
4905
+ }
4906
+ return true;
4907
+ }
4908
+ function isTransactionMetaValidForFlow(meta, flow) {
4909
+ var shouldValidateFlow = flow && flow !== 'default' && flow !== 'proceed';
4910
+ if (shouldValidateFlow) {
4911
+ if (flow !== meta.flow) {
4912
+ return false;
4824
4913
  }
4825
- }]);
4826
- return Interceptor;
4827
- }();
4828
- var HttpClient = {
4829
- interceptors: {
4830
- request: new Interceptor()
4831
4914
  }
4832
- };
4833
- var request = function () {
4834
- var _ref2 = _asyncToGenerator( _regeneratorRuntime.mark(function _callee(target, _ref) {
4835
- var _ref$method, method, _ref$headers, headers, _ref$credentials, credentials, body, requestOptions, url;
4915
+ return true;
4916
+ }
4917
+ function isTransactionMetaValidForOptions(meta, options, keys) {
4918
+ var mismatch = keys.some(function (key) {
4919
+ var value = options[key];
4920
+ if (value && value !== meta[key]) {
4921
+ return true;
4922
+ }
4923
+ });
4924
+ return !mismatch;
4925
+ }
4926
+
4927
+ function getResponse(meta) {
4928
+ return {
4929
+ meta: meta,
4930
+ interactionHandle: meta.interactionHandle,
4931
+ state: meta.state
4932
+ };
4933
+ }
4934
+ function interact(_x) {
4935
+ return _interact.apply(this, arguments);
4936
+ }
4937
+ function _interact() {
4938
+ _interact = _asyncToGenerator( _regeneratorRuntime.mark(function _callee(authClient) {
4939
+ var options,
4940
+ meta,
4941
+ baseUrl,
4942
+ _meta,
4943
+ clientId,
4944
+ redirectUri,
4945
+ state,
4946
+ scopes,
4947
+ withCredentials,
4948
+ codeChallenge,
4949
+ codeChallengeMethod,
4950
+ activationToken,
4951
+ recoveryToken,
4952
+ clientSecret,
4953
+ url,
4954
+ params,
4955
+ headers,
4956
+ resp,
4957
+ interactionHandle,
4958
+ newMeta,
4959
+ _args = arguments;
4836
4960
  return _regeneratorRuntime.wrap(function _callee$(_context) {
4837
4961
  while (1) {
4838
4962
  switch (_context.prev = _context.next) {
4839
4963
  case 0:
4840
- _ref$method = _ref.method, method = _ref$method === void 0 ? 'POST' : _ref$method, _ref$headers = _ref.headers, headers = _ref$headers === void 0 ? {} : _ref$headers, _ref$credentials = _ref.credentials, credentials = _ref$credentials === void 0 ? 'include' : _ref$credentials, body = _ref.body;
4841
- requestOptions = {
4842
- url: target,
4843
- method: method,
4844
- headers: _Object$assign({}, headers),
4845
- credentials: credentials,
4846
- body: body
4964
+ options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
4965
+ options = removeNils(options);
4966
+ meta = getSavedTransactionMeta(authClient, options);
4967
+ if (!(meta === null || meta === void 0 ? void 0 : meta.interactionHandle)) {
4968
+ _context.next = 5;
4969
+ break;
4970
+ }
4971
+ return _context.abrupt("return", getResponse(meta));
4972
+ case 5:
4973
+ _context.next = 7;
4974
+ return createTransactionMeta(authClient, _Object$assign(_Object$assign({}, meta), options));
4975
+ case 7:
4976
+ meta = _context.sent;
4977
+ baseUrl = getOAuthBaseUrl(authClient);
4978
+ _meta = meta, clientId = _meta.clientId, redirectUri = _meta.redirectUri, state = _meta.state, scopes = _meta.scopes, withCredentials = _meta.withCredentials, codeChallenge = _meta.codeChallenge, codeChallengeMethod = _meta.codeChallengeMethod, activationToken = _meta.activationToken, recoveryToken = _meta.recoveryToken;
4979
+ clientSecret = options.clientSecret || authClient.options.clientSecret;
4980
+ withCredentials = withCredentials !== null && withCredentials !== void 0 ? withCredentials : true;
4981
+ url = "".concat(baseUrl, "/v1/interact");
4982
+ params = {
4983
+ client_id: clientId,
4984
+ scope: scopes.join(' '),
4985
+ redirect_uri: redirectUri,
4986
+ code_challenge: codeChallenge,
4987
+ code_challenge_method: codeChallengeMethod,
4988
+ state: state
4847
4989
  };
4848
- if (HttpClient.interceptors) {
4849
- HttpClient.interceptors.request.handlers.forEach(function (interceptor) {
4850
- interceptor.before(requestOptions);
4851
- });
4990
+ if (activationToken) {
4991
+ params.activation_token = activationToken;
4852
4992
  }
4853
- url = requestOptions.url;
4854
- delete requestOptions.url;
4855
- return _context.abrupt("return", crossFetch(url, requestOptions));
4856
- case 6:
4993
+ if (recoveryToken) {
4994
+ params.recovery_token = recoveryToken;
4995
+ }
4996
+ if (clientSecret) {
4997
+ params.client_secret = clientSecret;
4998
+ }
4999
+ headers = {
5000
+ 'Content-Type': 'application/x-www-form-urlencoded'
5001
+ };
5002
+ _context.next = 20;
5003
+ return httpRequest(authClient, {
5004
+ method: 'POST',
5005
+ url: url,
5006
+ headers: headers,
5007
+ withCredentials: withCredentials,
5008
+ args: params
5009
+ });
5010
+ case 20:
5011
+ resp = _context.sent;
5012
+ interactionHandle = resp.interaction_handle;
5013
+ newMeta = _Object$assign(_Object$assign({}, meta), {
5014
+ interactionHandle: interactionHandle,
5015
+ withCredentials: withCredentials,
5016
+ state: state,
5017
+ scopes: scopes,
5018
+ recoveryToken: recoveryToken,
5019
+ activationToken: activationToken
5020
+ });
5021
+ saveTransactionMeta(authClient, newMeta);
5022
+ return _context.abrupt("return", getResponse(newMeta));
5023
+ case 25:
4857
5024
  case "end":
4858
5025
  return _context.stop();
4859
5026
  }
4860
5027
  }
4861
5028
  }, _callee);
4862
5029
  }));
4863
- return function request(_x, _x2) {
4864
- return _ref2.apply(this, arguments);
4865
- };
4866
- }();
5030
+ return _interact.apply(this, arguments);
5031
+ }
4867
5032
 
4868
5033
  function _createForOfIteratorHelper$5(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$5(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
4869
5034
  function _unsupportedIterableToArray$5(o, minLen) { var _context; if (!o) return; if (typeof o === "string") return _arrayLikeToArray$5(o, minLen); var n = _sliceInstanceProperty(_context = Object.prototype.toString.call(o)).call(_context, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$5(o, minLen); }
@@ -4939,71 +5104,80 @@ var divideActionParamsByMutability = function divideActionParamsByMutability(act
4939
5104
  };
4940
5105
  };
4941
5106
 
4942
- var generateDirectFetch = function generateDirectFetch(_ref) {
5107
+ var generateDirectFetch = function generateDirectFetch(authClient, _ref) {
4943
5108
  var actionDefinition = _ref.actionDefinition,
4944
5109
  _ref$defaultParamsFor = _ref.defaultParamsForAction,
4945
5110
  defaultParamsForAction = _ref$defaultParamsFor === void 0 ? {} : _ref$defaultParamsFor,
4946
5111
  _ref$immutableParamsF = _ref.immutableParamsForAction,
4947
5112
  immutableParamsForAction = _ref$immutableParamsF === void 0 ? {} : _ref$immutableParamsF,
4948
- toPersist = _ref.toPersist;
5113
+ _ref$toPersist = _ref.toPersist,
5114
+ toPersist = _ref$toPersist === void 0 ? {} : _ref$toPersist;
4949
5115
  var target = actionDefinition.href;
4950
- return function () {
4951
- var _ref2 = _asyncToGenerator( _regeneratorRuntime.mark(function _callee(params) {
4952
- var headers, body, credentials, response, responseJSON, requestDidSucceed, idxResponse;
4953
- return _regeneratorRuntime.wrap(function _callee$(_context) {
4954
- while (1) {
4955
- switch (_context.prev = _context.next) {
4956
- case 0:
4957
- headers = {
4958
- 'content-type': 'application/json',
4959
- 'accept': actionDefinition.accepts || 'application/ion+json'
4960
- };
4961
- body = _JSON$stringify(_Object$assign(_Object$assign(_Object$assign({}, defaultParamsForAction), params), immutableParamsForAction));
4962
- credentials = toPersist && toPersist.withCredentials === false ? 'omit' : 'include';
4963
- _context.next = 5;
4964
- return request(target, {
4965
- method: actionDefinition.method,
4966
- headers: headers,
4967
- body: body,
4968
- credentials: credentials
4969
- });
4970
- case 5:
4971
- response = _context.sent;
4972
- _context.next = 8;
4973
- return response.json();
4974
- case 8:
4975
- responseJSON = _context.sent;
4976
- requestDidSucceed = response.ok;
4977
- idxResponse = makeIdxState$1(responseJSON, toPersist, requestDidSucceed);
4978
- if (response.status === 401 && response.headers.get('WWW-Authenticate') === 'Oktadevicejwt realm="Okta Device"') {
4979
- idxResponse.stepUp = true;
4980
- }
4981
- if (requestDidSucceed) {
4982
- _context.next = 14;
4983
- break;
4984
- }
4985
- throw idxResponse;
4986
- case 14:
4987
- return _context.abrupt("return", idxResponse);
4988
- case 15:
4989
- case "end":
4990
- return _context.stop();
4991
- }
5116
+ return _asyncToGenerator( _regeneratorRuntime.mark(function _callee() {
5117
+ var params,
5118
+ _a,
5119
+ headers,
5120
+ body,
5121
+ response,
5122
+ _response,
5123
+ payload,
5124
+ wwwAuthHeader,
5125
+ idxResponse,
5126
+ _args = arguments;
5127
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
5128
+ while (1) {
5129
+ switch (_context.prev = _context.next) {
5130
+ case 0:
5131
+ params = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
5132
+ headers = {
5133
+ 'Content-Type': 'application/json',
5134
+ 'Accept': actionDefinition.accepts || 'application/ion+json'
5135
+ };
5136
+ body = _JSON$stringify(_Object$assign(_Object$assign(_Object$assign({}, defaultParamsForAction), params), immutableParamsForAction));
5137
+ _context.prev = 3;
5138
+ _context.next = 6;
5139
+ return httpRequest(authClient, {
5140
+ url: target,
5141
+ method: actionDefinition.method,
5142
+ headers: headers,
5143
+ args: body,
5144
+ withCredentials: (_a = toPersist === null || toPersist === void 0 ? void 0 : toPersist.withCredentials) !== null && _a !== void 0 ? _a : true
5145
+ });
5146
+ case 6:
5147
+ response = _context.sent;
5148
+ return _context.abrupt("return", makeIdxState$1(authClient, _Object$assign({}, response), toPersist, true));
5149
+ case 10:
5150
+ _context.prev = 10;
5151
+ _context.t0 = _context["catch"](3);
5152
+ if (!(!(_context.t0 instanceof AuthApiError) || !(_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.xhr))) {
5153
+ _context.next = 14;
5154
+ break;
5155
+ }
5156
+ throw _context.t0;
5157
+ case 14:
5158
+ _response = _context.t0.xhr;
5159
+ payload = _response.responseJSON || JSON.parse(_response.responseText);
5160
+ wwwAuthHeader = _response.headers['WWW-Authenticate'] || _response.headers['www-authenticate'];
5161
+ idxResponse = makeIdxState$1(authClient, _Object$assign({}, payload), toPersist, false);
5162
+ if (_response.status === 401 && wwwAuthHeader === 'Oktadevicejwt realm="Okta Device"') {
5163
+ idxResponse.stepUp = true;
5164
+ }
5165
+ throw idxResponse;
5166
+ case 20:
5167
+ case "end":
5168
+ return _context.stop();
4992
5169
  }
4993
- }, _callee);
4994
- }));
4995
- return function (_x) {
4996
- return _ref2.apply(this, arguments);
4997
- };
4998
- }();
5170
+ }
5171
+ }, _callee, null, [[3, 10]]);
5172
+ }));
4999
5173
  };
5000
- var generateIdxAction = function generateIdxAction(actionDefinition, toPersist) {
5174
+ var generateIdxAction = function generateIdxAction(authClient, actionDefinition, toPersist) {
5001
5175
  var generator = generateDirectFetch;
5002
5176
  var _divideActionParamsBy = divideActionParamsByMutability(actionDefinition),
5003
5177
  defaultParams = _divideActionParamsBy.defaultParams,
5004
5178
  neededParams = _divideActionParamsBy.neededParams,
5005
5179
  immutableParams = _divideActionParamsBy.immutableParams;
5006
- var action = generator({
5180
+ var action = generator(authClient, {
5007
5181
  actionDefinition: actionDefinition,
5008
5182
  defaultParamsForAction: defaultParams[actionDefinition.name],
5009
5183
  immutableParamsForAction: immutableParams[actionDefinition.name],
@@ -5013,10 +5187,10 @@ var generateIdxAction = function generateIdxAction(actionDefinition, toPersist)
5013
5187
  return action;
5014
5188
  };
5015
5189
 
5016
- var generateRemediationFunctions = function generateRemediationFunctions(remediationValue) {
5017
- var toPersist = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5190
+ var generateRemediationFunctions = function generateRemediationFunctions(authClient, remediationValue) {
5191
+ var toPersist = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
5018
5192
  return _Object$fromEntries(_mapInstanceProperty(remediationValue).call(remediationValue, function (remediation) {
5019
- return [remediation.name, generateIdxAction(remediation, toPersist)];
5193
+ return [remediation.name, generateIdxAction(authClient, remediation, toPersist)];
5020
5194
  }));
5021
5195
  };
5022
5196
 
@@ -5025,9 +5199,9 @@ var SKIP_FIELDS = _Object$fromEntries(_mapInstanceProperty(_context = ['remediat
5025
5199
  ]).call(_context, function (field) {
5026
5200
  return [field, !!'skip this field'];
5027
5201
  }));
5028
- var parseNonRemediations = function parseNonRemediations(idxResponse) {
5202
+ var parseNonRemediations = function parseNonRemediations(authClient, idxResponse) {
5029
5203
  var _context2;
5030
- var toPersist = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5204
+ var toPersist = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
5031
5205
  var actions = {};
5032
5206
  var context = {};
5033
5207
  _filterInstanceProperty(_context2 = _Object$keys(idxResponse)).call(_context2, function (field) {
@@ -5039,7 +5213,7 @@ var parseNonRemediations = function parseNonRemediations(idxResponse) {
5039
5213
  return;
5040
5214
  }
5041
5215
  if (idxResponse[field].rel) {
5042
- actions[idxResponse[field].name] = generateIdxAction(idxResponse[field], toPersist);
5216
+ actions[idxResponse[field].name] = generateIdxAction(authClient, idxResponse[field], toPersist);
5043
5217
  return;
5044
5218
  }
5045
5219
  var _a = idxResponse[field],
@@ -5060,7 +5234,7 @@ var parseNonRemediations = function parseNonRemediations(idxResponse) {
5060
5234
  value = _ref2[1];
5061
5235
  if (value.rel) {
5062
5236
  var _context3;
5063
- actions[_concatInstanceProperty(_context3 = "".concat(field, "-")).call(_context3, subField.name || subField)] = generateIdxAction(value, toPersist);
5237
+ actions[_concatInstanceProperty(_context3 = "".concat(field, "-")).call(_context3, subField.name || subField)] = generateIdxAction(authClient, value, toPersist);
5064
5238
  } else {
5065
5239
  context[field].value[subField] = value;
5066
5240
  }
@@ -5093,24 +5267,24 @@ var expandRelatesTo = function expandRelatesTo(idxResponse, value) {
5093
5267
  }
5094
5268
  });
5095
5269
  };
5096
- var convertRemediationAction = function convertRemediationAction(remediation, toPersist) {
5097
- var remediationActions = generateRemediationFunctions([remediation], toPersist);
5270
+ var convertRemediationAction = function convertRemediationAction(authClient, remediation, toPersist) {
5271
+ var remediationActions = generateRemediationFunctions(authClient, [remediation], toPersist);
5098
5272
  var actionFn = remediationActions[remediation.name];
5099
5273
  return _Object$assign(_Object$assign({}, remediation), {
5100
5274
  action: actionFn
5101
5275
  });
5102
5276
  };
5103
- var parseIdxResponse = function parseIdxResponse(idxResponse) {
5104
- var toPersist = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5277
+ var parseIdxResponse = function parseIdxResponse(authClient, idxResponse) {
5278
+ var toPersist = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
5105
5279
  var _a;
5106
5280
  var remediationData = ((_a = idxResponse.remediation) === null || _a === void 0 ? void 0 : _a.value) || [];
5107
5281
  remediationData.forEach(function (remediation) {
5108
5282
  return expandRelatesTo(idxResponse, remediation);
5109
5283
  });
5110
5284
  var remediations = _mapInstanceProperty(remediationData).call(remediationData, function (remediation) {
5111
- return convertRemediationAction(remediation, toPersist);
5285
+ return convertRemediationAction(authClient, remediation, toPersist);
5112
5286
  });
5113
- var _parseNonRemediations = parseNonRemediations(idxResponse, toPersist),
5287
+ var _parseNonRemediations = parseNonRemediations(authClient, idxResponse, toPersist),
5114
5288
  context = _parseNonRemediations.context,
5115
5289
  actions = _parseNonRemediations.actions;
5116
5290
  return {
@@ -5120,10 +5294,10 @@ var parseIdxResponse = function parseIdxResponse(idxResponse) {
5120
5294
  };
5121
5295
  };
5122
5296
 
5123
- function makeIdxState$1(idxResponse, toPersist, requestDidSucceed) {
5297
+ function makeIdxState$1(authClient, idxResponse, toPersist, requestDidSucceed) {
5124
5298
  var _a, _b, _c;
5125
5299
  var rawIdxResponse = idxResponse;
5126
- var _parseIdxResponse = parseIdxResponse(idxResponse, toPersist),
5300
+ var _parseIdxResponse = parseIdxResponse(authClient, idxResponse, toPersist),
5127
5301
  remediations = _parseIdxResponse.remediations,
5128
5302
  context = _parseIdxResponse.context,
5129
5303
  actions = _parseIdxResponse.actions;
@@ -5190,7 +5364,6 @@ var parsersForVersion = function parsersForVersion(version) {
5190
5364
  throw new Error("Unknown api version: ".concat(version, ". Use an exact semver version."));
5191
5365
  }
5192
5366
  };
5193
-
5194
5367
  function validateVersionConfig(version) {
5195
5368
  if (!version) {
5196
5369
  throw new Error('version is required');
@@ -5201,356 +5374,15 @@ function validateVersionConfig(version) {
5201
5374
  }
5202
5375
  parsersForVersion(version);
5203
5376
  }
5204
-
5205
- var introspect$1 = function () {
5206
- var _introspect = _asyncToGenerator( _regeneratorRuntime.mark(function _callee(_ref) {
5207
- var withCredentials, domain, interactionHandle, stateHandle, version, target, body, headers, credentials, response, requestDidSucceed, rawIdxResponse;
5208
- return _regeneratorRuntime.wrap(function _callee$(_context) {
5209
- while (1) {
5210
- switch (_context.prev = _context.next) {
5211
- case 0:
5212
- withCredentials = _ref.withCredentials, domain = _ref.domain, interactionHandle = _ref.interactionHandle, stateHandle = _ref.stateHandle, version = _ref.version;
5213
- validateVersionConfig(version);
5214
- target = "".concat(domain, "/idp/idx/introspect");
5215
- body = stateHandle ? {
5216
- stateToken: stateHandle
5217
- } : {
5218
- interactionHandle: interactionHandle
5219
- };
5220
- headers = {
5221
- 'content-type': "application/ion+json; okta-version=".concat(version),
5222
- accept: "application/ion+json; okta-version=".concat(version)
5223
- };
5224
- credentials = withCredentials === false ? 'omit' : 'include';
5225
- _context.next = 8;
5226
- return request(target, {
5227
- credentials: credentials,
5228
- headers: headers,
5229
- body: _JSON$stringify(body)
5230
- });
5231
- case 8:
5232
- response = _context.sent;
5233
- requestDidSucceed = response.ok;
5234
- _context.next = 12;
5235
- return response.json();
5236
- case 12:
5237
- rawIdxResponse = _context.sent;
5238
- if (requestDidSucceed) {
5239
- _context.next = 15;
5240
- break;
5241
- }
5242
- throw rawIdxResponse;
5243
- case 15:
5244
- return _context.abrupt("return", rawIdxResponse);
5245
- case 16:
5246
- case "end":
5247
- return _context.stop();
5248
- }
5249
- }
5250
- }, _callee);
5251
- }));
5252
- function introspect(_x) {
5253
- return _introspect.apply(this, arguments);
5254
- }
5255
- return introspect;
5256
- }();
5257
-
5258
- var parseAndReject = function parseAndReject(response) {
5259
- return response.json().then(function (err) {
5260
- return _Promise.reject(err);
5261
- });
5262
- };
5263
- var interact$1 = function () {
5264
- var _interact = _asyncToGenerator( _regeneratorRuntime.mark(function _callee(_ref) {
5265
- var _context;
5266
- var withCredentials, clientId, baseUrl, _ref$scopes, scopes, redirectUri, codeChallenge, codeChallengeMethod, state, activationToken, recoveryToken, clientSecret, target, params, body, headers, credentials;
5267
- return _regeneratorRuntime.wrap(function _callee$(_context3) {
5268
- while (1) {
5269
- switch (_context3.prev = _context3.next) {
5270
- case 0:
5271
- withCredentials = _ref.withCredentials, clientId = _ref.clientId, baseUrl = _ref.baseUrl, _ref$scopes = _ref.scopes, scopes = _ref$scopes === void 0 ? ['openid', 'email'] : _ref$scopes, redirectUri = _ref.redirectUri, codeChallenge = _ref.codeChallenge, codeChallengeMethod = _ref.codeChallengeMethod, state = _ref.state, activationToken = _ref.activationToken, recoveryToken = _ref.recoveryToken, clientSecret = _ref.clientSecret;
5272
- target = "".concat(baseUrl, "/v1/interact");
5273
- params = {
5274
- client_id: clientId,
5275
- scope: scopes.join(' '),
5276
- redirect_uri: redirectUri,
5277
- code_challenge: codeChallenge,
5278
- code_challenge_method: codeChallengeMethod,
5279
- state: state
5280
- };
5281
- if (activationToken) {
5282
- params.activation_token = activationToken;
5283
- }
5284
- if (recoveryToken) {
5285
- params.recovery_token = recoveryToken;
5286
- }
5287
- if (clientSecret) {
5288
- params.client_secret = clientSecret;
5289
- }
5290
- body = _mapInstanceProperty(_context = _Object$entries(params)).call(_context, function (_ref2) {
5291
- var _context2;
5292
- var _ref3 = _slicedToArray(_ref2, 2),
5293
- param = _ref3[0],
5294
- value = _ref3[1];
5295
- return _concatInstanceProperty(_context2 = "".concat(param, "=")).call(_context2, encodeURIComponent(value));
5296
- }).join('&');
5297
- headers = {
5298
- 'content-type': 'application/x-www-form-urlencoded'
5299
- };
5300
- credentials = withCredentials === false ? 'omit' : 'include';
5301
- return _context3.abrupt("return", request(target, {
5302
- credentials: credentials,
5303
- headers: headers,
5304
- body: body
5305
- }).then(function (response) {
5306
- return response.ok ? response.json() : parseAndReject(response);
5307
- }).then(function (data) {
5308
- return data.interaction_handle;
5309
- }));
5310
- case 10:
5311
- case "end":
5312
- return _context3.stop();
5313
- }
5314
- }
5315
- }, _callee);
5316
- }));
5317
- function interact(_x) {
5318
- return _interact.apply(this, arguments);
5319
- }
5320
- return interact;
5321
- }();
5322
-
5323
- var LATEST_SUPPORTED_IDX_API_VERSION = '1.0.0';
5324
- var _parsersForVersion = parsersForVersion(LATEST_SUPPORTED_IDX_API_VERSION),
5325
- makeIdxState = _parsersForVersion.makeIdxState;
5326
- var idx = {
5327
- introspect: introspect$1,
5328
- interact: interact$1,
5329
- makeIdxState: makeIdxState,
5330
- client: HttpClient,
5331
- LATEST_SUPPORTED_IDX_API_VERSION: LATEST_SUPPORTED_IDX_API_VERSION
5332
- };
5333
-
5334
- function createTransactionMeta(_x) {
5335
- return _createTransactionMeta.apply(this, arguments);
5336
- }
5337
- function _createTransactionMeta() {
5338
- _createTransactionMeta = _asyncToGenerator( _regeneratorRuntime.mark(function _callee(authClient) {
5339
- var options,
5340
- tokenParams,
5341
- pkceMeta,
5342
- _Object$assign2,
5343
- _Object$assign2$flow,
5344
- flow,
5345
- _Object$assign2$withC,
5346
- withCredentials,
5347
- _Object$assign2$activ,
5348
- activationToken,
5349
- _Object$assign2$recov,
5350
- recoveryToken,
5351
- meta,
5352
- _args = arguments;
5353
- return _regeneratorRuntime.wrap(function _callee$(_context) {
5354
- while (1) {
5355
- switch (_context.prev = _context.next) {
5356
- case 0:
5357
- options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
5358
- _context.next = 3;
5359
- return authClient.token.prepareTokenParams(options);
5360
- case 3:
5361
- tokenParams = _context.sent;
5362
- pkceMeta = createOAuthMeta(authClient, tokenParams);
5363
- _Object$assign2 = _Object$assign(_Object$assign({}, authClient.options), options), _Object$assign2$flow = _Object$assign2.flow, flow = _Object$assign2$flow === void 0 ? 'default' : _Object$assign2$flow, _Object$assign2$withC = _Object$assign2.withCredentials, withCredentials = _Object$assign2$withC === void 0 ? true : _Object$assign2$withC, _Object$assign2$activ = _Object$assign2.activationToken, activationToken = _Object$assign2$activ === void 0 ? undefined : _Object$assign2$activ, _Object$assign2$recov = _Object$assign2.recoveryToken, recoveryToken = _Object$assign2$recov === void 0 ? undefined : _Object$assign2$recov;
5364
- meta = _Object$assign(_Object$assign({}, pkceMeta), {
5365
- flow: flow,
5366
- withCredentials: withCredentials,
5367
- activationToken: activationToken,
5368
- recoveryToken: recoveryToken
5369
- });
5370
- return _context.abrupt("return", meta);
5371
- case 8:
5372
- case "end":
5373
- return _context.stop();
5374
- }
5375
- }
5376
- }, _callee);
5377
- }));
5378
- return _createTransactionMeta.apply(this, arguments);
5379
- }
5380
- function hasSavedInteractionHandle(authClient, options) {
5381
- var savedMeta = getSavedTransactionMeta(authClient, options);
5382
- if (savedMeta === null || savedMeta === void 0 ? void 0 : savedMeta.interactionHandle) {
5383
- return true;
5384
- }
5385
- return false;
5386
- }
5387
- function getSavedTransactionMeta(authClient, options) {
5388
- options = removeNils(options);
5389
- options = _Object$assign(_Object$assign({}, authClient.options), options);
5390
- var savedMeta;
5391
- try {
5392
- savedMeta = authClient.transactionManager.load(options);
5393
- } catch (e) {
5394
- }
5395
- if (!savedMeta) {
5396
- return;
5397
- }
5398
- if (isTransactionMetaValid(savedMeta, options)) {
5399
- return savedMeta;
5400
- }
5401
- warn('Saved transaction meta does not match the current configuration. ' + 'This may indicate that two apps are sharing a storage key.');
5402
- }
5403
- function getTransactionMeta(_x2, _x3) {
5404
- return _getTransactionMeta.apply(this, arguments);
5405
- }
5406
- function _getTransactionMeta() {
5407
- _getTransactionMeta = _asyncToGenerator( _regeneratorRuntime.mark(function _callee2(authClient, options) {
5408
- var validExistingMeta;
5409
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
5410
- while (1) {
5411
- switch (_context2.prev = _context2.next) {
5412
- case 0:
5413
- options = removeNils(options);
5414
- options = _Object$assign(_Object$assign({}, authClient.options), options);
5415
- validExistingMeta = getSavedTransactionMeta(authClient, options);
5416
- if (!validExistingMeta) {
5417
- _context2.next = 5;
5418
- break;
5419
- }
5420
- return _context2.abrupt("return", validExistingMeta);
5421
- case 5:
5422
- return _context2.abrupt("return", createTransactionMeta(authClient, options));
5423
- case 6:
5424
- case "end":
5425
- return _context2.stop();
5426
- }
5427
- }
5428
- }, _callee2);
5429
- }));
5430
- return _getTransactionMeta.apply(this, arguments);
5431
- }
5432
- function saveTransactionMeta(authClient, meta) {
5433
- authClient.transactionManager.save(meta, {
5434
- muteWarning: true
5435
- });
5436
- }
5437
- function clearTransactionMeta(authClient) {
5438
- authClient.transactionManager.clear();
5439
- }
5440
- function isTransactionMetaValid(meta) {
5441
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5442
- var keys = ['issuer', 'clientId', 'redirectUri', 'state', 'codeChallenge', 'codeChallengeMethod', 'activationToken', 'recoveryToken'];
5443
- if (isTransactionMetaValidForOptions(meta, options, keys) === false) {
5444
- return false;
5445
- }
5446
- var flow = options.flow;
5447
- if (isTransactionMetaValidForFlow(meta, flow) === false) {
5448
- return false;
5449
- }
5450
- return true;
5451
- }
5452
- function isTransactionMetaValidForFlow(meta, flow) {
5453
- var shouldValidateFlow = flow && flow !== 'default' && flow !== 'proceed';
5454
- if (shouldValidateFlow) {
5455
- if (flow !== meta.flow) {
5456
- return false;
5457
- }
5458
- }
5459
- return true;
5460
- }
5461
- function isTransactionMetaValidForOptions(meta, options, keys) {
5462
- var mismatch = keys.some(function (key) {
5463
- var value = options[key];
5464
- if (value && value !== meta[key]) {
5465
- return true;
5466
- }
5467
- });
5468
- return !mismatch;
5469
- }
5470
-
5471
- function getResponse(meta) {
5472
- return {
5473
- meta: meta,
5474
- interactionHandle: meta.interactionHandle,
5475
- state: meta.state
5476
- };
5477
- }
5478
- function interact(_x) {
5479
- return _interact.apply(this, arguments);
5480
- }
5481
- function _interact() {
5482
- _interact = _asyncToGenerator( _regeneratorRuntime.mark(function _callee(authClient) {
5483
- var options,
5484
- meta,
5485
- baseUrl,
5486
- _meta,
5487
- clientId,
5488
- redirectUri,
5489
- state,
5490
- scopes,
5491
- withCredentials,
5492
- codeChallenge,
5493
- codeChallengeMethod,
5494
- activationToken,
5495
- recoveryToken,
5496
- clientSecret,
5497
- interactionHandle,
5498
- newMeta,
5499
- _args = arguments;
5500
- return _regeneratorRuntime.wrap(function _callee$(_context) {
5501
- while (1) {
5502
- switch (_context.prev = _context.next) {
5503
- case 0:
5504
- options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
5505
- options = removeNils(options);
5506
- meta = getSavedTransactionMeta(authClient, options);
5507
- if (!(meta === null || meta === void 0 ? void 0 : meta.interactionHandle)) {
5508
- _context.next = 5;
5509
- break;
5510
- }
5511
- return _context.abrupt("return", getResponse(meta));
5512
- case 5:
5513
- _context.next = 7;
5514
- return createTransactionMeta(authClient, _Object$assign(_Object$assign({}, meta), options));
5515
- case 7:
5516
- meta = _context.sent;
5517
- baseUrl = getOAuthBaseUrl(authClient);
5518
- _meta = meta, clientId = _meta.clientId, redirectUri = _meta.redirectUri, state = _meta.state, scopes = _meta.scopes, withCredentials = _meta.withCredentials, codeChallenge = _meta.codeChallenge, codeChallengeMethod = _meta.codeChallengeMethod, activationToken = _meta.activationToken, recoveryToken = _meta.recoveryToken;
5519
- clientSecret = options.clientSecret || authClient.options.clientSecret;
5520
- _context.next = 13;
5521
- return idx.interact({
5522
- withCredentials: withCredentials,
5523
- clientId: clientId,
5524
- baseUrl: baseUrl,
5525
- scopes: scopes,
5526
- state: state,
5527
- redirectUri: redirectUri,
5528
- codeChallenge: codeChallenge,
5529
- codeChallengeMethod: codeChallengeMethod,
5530
- activationToken: activationToken,
5531
- recoveryToken: recoveryToken,
5532
- clientSecret: clientSecret
5533
- });
5534
- case 13:
5535
- interactionHandle = _context.sent;
5536
- newMeta = _Object$assign(_Object$assign({}, meta), {
5537
- interactionHandle: interactionHandle,
5538
- withCredentials: withCredentials,
5539
- state: state,
5540
- scopes: scopes,
5541
- recoveryToken: recoveryToken,
5542
- activationToken: activationToken
5543
- });
5544
- saveTransactionMeta(authClient, newMeta);
5545
- return _context.abrupt("return", getResponse(newMeta));
5546
- case 17:
5547
- case "end":
5548
- return _context.stop();
5549
- }
5550
- }
5551
- }, _callee);
5552
- }));
5553
- return _interact.apply(this, arguments);
5377
+ function makeIdxState(authClient, rawIdxResponse) {
5378
+ var toPersist = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
5379
+ var requestDidSucceed = arguments.length > 3 ? arguments[3] : undefined;
5380
+ var _a;
5381
+ var version = (_a = rawIdxResponse === null || rawIdxResponse === void 0 ? void 0 : rawIdxResponse.version) !== null && _a !== void 0 ? _a : IDX_API_VERSION;
5382
+ validateVersionConfig(version);
5383
+ var _parsersForVersion = parsersForVersion(version),
5384
+ makeIdxState = _parsersForVersion.makeIdxState;
5385
+ return makeIdxState(authClient, rawIdxResponse, toPersist, requestDidSucceed);
5554
5386
  }
5555
5387
 
5556
5388
  function introspect(_x) {
@@ -5559,11 +5391,18 @@ function introspect(_x) {
5559
5391
  function _introspect() {
5560
5392
  _introspect = _asyncToGenerator( _regeneratorRuntime.mark(function _callee(authClient) {
5561
5393
  var options,
5394
+ _a,
5562
5395
  rawIdxResponse,
5563
5396
  requestDidSucceed,
5564
5397
  savedIdxResponse,
5565
5398
  version,
5566
5399
  domain,
5400
+ interactionHandle,
5401
+ stateHandle,
5402
+ _withCredentials,
5403
+ url,
5404
+ body,
5405
+ headers,
5567
5406
  withCredentials,
5568
5407
  _args = arguments;
5569
5408
  return _regeneratorRuntime.wrap(function _callee$(_context) {
@@ -5577,47 +5416,62 @@ function _introspect() {
5577
5416
  requestDidSucceed = savedIdxResponse.requestDidSucceed;
5578
5417
  }
5579
5418
  if (rawIdxResponse) {
5580
- _context.next = 21;
5419
+ _context.next = 27;
5581
5420
  break;
5582
5421
  }
5583
5422
  version = options.version || IDX_API_VERSION;
5584
5423
  domain = getOAuthDomain(authClient);
5585
- _context.prev = 6;
5586
- _context.next = 9;
5587
- return idx.introspect(_Object$assign(_Object$assign({
5588
- domain: domain
5589
- }, options), {
5590
- version: version
5591
- }));
5592
- case 9:
5593
- rawIdxResponse = _context.sent;
5424
+ interactionHandle = options.interactionHandle, stateHandle = options.stateHandle;
5425
+ _withCredentials = (_a = options.withCredentials) !== null && _a !== void 0 ? _a : true;
5426
+ _context.prev = 8;
5594
5427
  requestDidSucceed = true;
5595
- _context.next = 21;
5428
+ validateVersionConfig(version);
5429
+ url = "".concat(domain, "/idp/idx/introspect");
5430
+ body = stateHandle ? {
5431
+ stateToken: stateHandle
5432
+ } : {
5433
+ interactionHandle: interactionHandle
5434
+ };
5435
+ headers = {
5436
+ 'Content-Type': "application/ion+json; okta-version=".concat(version),
5437
+ Accept: "application/ion+json; okta-version=".concat(version)
5438
+ };
5439
+ _context.next = 16;
5440
+ return httpRequest(authClient, {
5441
+ method: 'POST',
5442
+ url: url,
5443
+ headers: headers,
5444
+ withCredentials: _withCredentials,
5445
+ args: body
5446
+ });
5447
+ case 16:
5448
+ rawIdxResponse = _context.sent;
5449
+ _context.next = 27;
5596
5450
  break;
5597
- case 13:
5598
- _context.prev = 13;
5599
- _context.t0 = _context["catch"](6);
5600
- if (!isRawIdxResponse(_context.t0)) {
5601
- _context.next = 20;
5451
+ case 19:
5452
+ _context.prev = 19;
5453
+ _context.t0 = _context["catch"](8);
5454
+ if (!(isAuthApiError(_context.t0) && _context.t0.xhr && isRawIdxResponse(_context.t0.xhr.responseJSON))) {
5455
+ _context.next = 26;
5602
5456
  break;
5603
5457
  }
5604
- rawIdxResponse = _context.t0;
5458
+ rawIdxResponse = _context.t0.xhr.responseJSON;
5605
5459
  requestDidSucceed = false;
5606
- _context.next = 21;
5460
+ _context.next = 27;
5607
5461
  break;
5608
- case 20:
5462
+ case 26:
5609
5463
  throw _context.t0;
5610
- case 21:
5464
+ case 27:
5611
5465
  withCredentials = options.withCredentials;
5612
- return _context.abrupt("return", idx.makeIdxState(rawIdxResponse, {
5466
+ return _context.abrupt("return", makeIdxState(authClient, rawIdxResponse, {
5613
5467
  withCredentials: withCredentials
5614
5468
  }, requestDidSucceed));
5615
- case 23:
5469
+ case 29:
5616
5470
  case "end":
5617
5471
  return _context.stop();
5618
5472
  }
5619
5473
  }
5620
- }, _callee, null, [[6, 13]]);
5474
+ }, _callee, null, [[8, 19]]);
5621
5475
  }));
5622
5476
  return _introspect.apply(this, arguments);
5623
5477
  }
@@ -5704,7 +5558,7 @@ function findMatchedOption(authenticators, options) {
5704
5558
  }
5705
5559
 
5706
5560
  function _createForOfIteratorHelper$3(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$3(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
5707
- function _unsupportedIterableToArray$3(o, minLen) { var _context10; if (!o) return; if (typeof o === "string") return _arrayLikeToArray$3(o, minLen); var n = _sliceInstanceProperty(_context10 = Object.prototype.toString.call(o)).call(_context10, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen); }
5561
+ function _unsupportedIterableToArray$3(o, minLen) { var _context11; if (!o) return; if (typeof o === "string") return _arrayLikeToArray$3(o, minLen); var n = _sliceInstanceProperty(_context11 = Object.prototype.toString.call(o)).call(_context11, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen); }
5708
5562
  function _arrayLikeToArray$3(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
5709
5563
  var Remediator = function () {
5710
5564
  function Remediator(remediation) {
@@ -5823,7 +5677,8 @@ var Remediator = function () {
5823
5677
  var input;
5824
5678
  var name = inputFromRemediation.name,
5825
5679
  type = inputFromRemediation.type,
5826
- visible = inputFromRemediation.visible;
5680
+ visible = inputFromRemediation.visible,
5681
+ messages = inputFromRemediation.messages;
5827
5682
  if (visible === false) {
5828
5683
  return;
5829
5684
  }
@@ -5854,6 +5709,9 @@ var Remediator = function () {
5854
5709
  return inputs.push(i);
5855
5710
  });
5856
5711
  } else {
5712
+ if (messages) {
5713
+ input.messages = messages;
5714
+ }
5857
5715
  inputs.push(input);
5858
5716
  }
5859
5717
  });
@@ -5863,7 +5721,10 @@ var Remediator = function () {
5863
5721
  key: "getValuesAfterProceed",
5864
5722
  value:
5865
5723
  function getValuesAfterProceed() {
5866
- var inputs = this.getInputs();
5724
+ var _context6;
5725
+ var inputsFromRemediation = this.remediation.value || [];
5726
+ var inputsFromRemediator = this.getInputs();
5727
+ var inputs = _concatInstanceProperty(_context6 = []).call(_context6, _toConsumableArray(inputsFromRemediation), _toConsumableArray(inputsFromRemediator));
5867
5728
  var _iterator = _createForOfIteratorHelper$3(inputs),
5868
5729
  _step;
5869
5730
  try {
@@ -5881,7 +5742,7 @@ var Remediator = function () {
5881
5742
  }, {
5882
5743
  key: "getAuthenticator",
5883
5744
  value: function getAuthenticator() {
5884
- var _context6, _context7;
5745
+ var _context7, _context8;
5885
5746
  var _a, _b;
5886
5747
  var relatesTo = (_a = this.remediation.relatesTo) === null || _a === void 0 ? void 0 : _a.value;
5887
5748
  if (!relatesTo) {
@@ -5891,11 +5752,11 @@ var Remediator = function () {
5891
5752
  if (!authenticatorFromRemediation) {
5892
5753
  return relatesTo;
5893
5754
  }
5894
- var id = _findInstanceProperty(_context6 = authenticatorFromRemediation.form.value).call(_context6, function (_ref2) {
5755
+ var id = _findInstanceProperty(_context7 = authenticatorFromRemediation.form.value).call(_context7, function (_ref2) {
5895
5756
  var name = _ref2.name;
5896
5757
  return name === 'id';
5897
5758
  }).value;
5898
- var enrollmentId = (_b = _findInstanceProperty(_context7 = authenticatorFromRemediation.form.value).call(_context7, function (_ref3) {
5759
+ var enrollmentId = (_b = _findInstanceProperty(_context8 = authenticatorFromRemediation.form.value).call(_context8, function (_ref3) {
5899
5760
  var name = _ref3.name;
5900
5761
  return name === 'enrollmentId';
5901
5762
  })) === null || _b === void 0 ? void 0 : _b.value;
@@ -5907,15 +5768,15 @@ var Remediator = function () {
5907
5768
  }], [{
5908
5769
  key: "getMessages",
5909
5770
  value: function getMessages(remediation) {
5910
- var _context8;
5771
+ var _context9;
5911
5772
  var _a, _b;
5912
5773
  if (!remediation.value) {
5913
5774
  return;
5914
5775
  }
5915
- return (_b = (_a = remediation.value[0]) === null || _a === void 0 ? void 0 : _a.form) === null || _b === void 0 ? void 0 : _reduceInstanceProperty(_context8 = _b.value).call(_context8, function (messages, field) {
5776
+ return (_b = (_a = remediation.value[0]) === null || _a === void 0 ? void 0 : _a.form) === null || _b === void 0 ? void 0 : _reduceInstanceProperty(_context9 = _b.value).call(_context9, function (messages, field) {
5916
5777
  if (field.messages) {
5917
- var _context9;
5918
- messages = _concatInstanceProperty(_context9 = []).call(_context9, _toConsumableArray(messages), _toConsumableArray(field.messages.value));
5778
+ var _context10;
5779
+ messages = _concatInstanceProperty(_context10 = []).call(_context10, _toConsumableArray(messages), _toConsumableArray(field.messages.value));
5919
5780
  }
5920
5781
  return messages;
5921
5782
  }, []);
@@ -7110,15 +6971,16 @@ var AuthenticatorVerificationData = function (_AuthenticatorData) {
7110
6971
  function AuthenticatorVerificationData(remediation) {
7111
6972
  var _this;
7112
6973
  var values = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6974
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
7113
6975
  _classCallCheck(this, AuthenticatorVerificationData);
7114
6976
  _this = _super.call(this, remediation, values);
7115
- _this.shouldProceedWithEmailAuthenticator = _this.authenticator.methods.length === 1 && _this.authenticator.methods[0].type === 'email';
6977
+ _this.shouldProceedWithEmailAuthenticator = options.shouldProceedWithEmailAuthenticator !== false && _this.authenticator.methods.length === 1 && _this.authenticator.methods[0].type === 'email';
7116
6978
  return _this;
7117
6979
  }
7118
6980
  _createClass(AuthenticatorVerificationData, [{
7119
6981
  key: "canRemediate",
7120
6982
  value: function canRemediate() {
7121
- if (this.shouldProceedWithEmailAuthenticator) {
6983
+ if (this.shouldProceedWithEmailAuthenticator !== false) {
7122
6984
  return true;
7123
6985
  }
7124
6986
  return _get(_getPrototypeOf(AuthenticatorVerificationData.prototype), "canRemediate", this).call(this);
@@ -7127,7 +6989,7 @@ var AuthenticatorVerificationData = function (_AuthenticatorData) {
7127
6989
  key: "mapAuthenticator",
7128
6990
  value: function mapAuthenticator() {
7129
6991
  var _a;
7130
- if (this.shouldProceedWithEmailAuthenticator) {
6992
+ if (this.shouldProceedWithEmailAuthenticator !== false) {
7131
6993
  var _context;
7132
6994
  var authenticatorFromRemediation = this.getAuthenticatorFromRemediation();
7133
6995
  return (_a = authenticatorFromRemediation.form) === null || _a === void 0 ? void 0 : _reduceInstanceProperty(_context = _a.value).call(_context, function (acc, curr) {
@@ -7278,7 +7140,7 @@ var remediators = /*#__PURE__*/Object.freeze({
7278
7140
  });
7279
7141
 
7280
7142
  function _createForOfIteratorHelper$1(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
7281
- function _unsupportedIterableToArray$1(o, minLen) { var _context11; if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = _sliceInstanceProperty(_context11 = Object.prototype.toString.call(o)).call(_context11, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
7143
+ function _unsupportedIterableToArray$1(o, minLen) { var _context12; if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = _sliceInstanceProperty(_context12 = Object.prototype.toString.call(o)).call(_context12, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
7282
7144
  function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
7283
7145
  function isTerminalResponse(idxResponse) {
7284
7146
  var neededToProceed = idxResponse.neededToProceed,
@@ -7423,25 +7285,34 @@ function getAvailableSteps(idxResponse) {
7423
7285
  }
7424
7286
  return res;
7425
7287
  }
7426
- function filterValuesForRemediation(idxResponse, values) {
7288
+ function filterValuesForRemediation(idxResponse, remediationName, values) {
7427
7289
  var _context10;
7428
- var valuesForRemediation = _reduceInstanceProperty(_context10 = idxResponse.neededToProceed[0].value).call(_context10, function (res, entry) {
7429
- var name = entry.name;
7430
- res[name] = values[name];
7290
+ var remediations = idxResponse.neededToProceed || [];
7291
+ var remediation = _findInstanceProperty(remediations).call(remediations, function (r) {
7292
+ return r.name === remediationName;
7293
+ });
7294
+ if (!remediation) {
7295
+ warn("filterValuesForRemediation: \"".concat(remediationName, "\" did not match any remediations"));
7296
+ return values;
7297
+ }
7298
+ var valuesForRemediation = _reduceInstanceProperty(_context10 = remediation.value).call(_context10, function (res, entry) {
7299
+ var name = entry.name,
7300
+ value = entry.value;
7301
+ if (name === 'stateHandle') {
7302
+ res[name] = value;
7303
+ } else {
7304
+ res[name] = values[name];
7305
+ }
7431
7306
  return res;
7432
7307
  }, {});
7433
7308
  return valuesForRemediation;
7434
7309
  }
7435
-
7436
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
7437
- function _unsupportedIterableToArray(o, minLen) { var _context6; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context6 = Object.prototype.toString.call(o)).call(_context6, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7438
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
7439
7310
  function getRemediator(idxRemediations, values, options) {
7440
7311
  var remediators = options.remediators;
7441
7312
  var remediator;
7442
7313
  if (options.step) {
7443
- var remediation = _findInstanceProperty(idxRemediations).call(idxRemediations, function (_ref) {
7444
- var name = _ref.name;
7314
+ var remediation = _findInstanceProperty(idxRemediations).call(idxRemediations, function (_ref5) {
7315
+ var name = _ref5.name;
7445
7316
  return name === options.step;
7446
7317
  });
7447
7318
  if (remediation) {
@@ -7453,13 +7324,13 @@ function getRemediator(idxRemediations, values, options) {
7453
7324
  }
7454
7325
  }
7455
7326
  var remediatorCandidates = [];
7456
- var _iterator = _createForOfIteratorHelper(idxRemediations),
7457
- _step;
7327
+ var _iterator3 = _createForOfIteratorHelper$1(idxRemediations),
7328
+ _step3;
7458
7329
  try {
7459
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
7460
- var _context;
7461
- var _remediation = _step.value;
7462
- var isRemeditionInFlow = _includesInstanceProperty(_context = _Object$keys(remediators)).call(_context, _remediation.name);
7330
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
7331
+ var _context11;
7332
+ var _remediation = _step3.value;
7333
+ var isRemeditionInFlow = _includesInstanceProperty(_context11 = _Object$keys(remediators)).call(_context11, _remediation.name);
7463
7334
  if (!isRemeditionInFlow) {
7464
7335
  continue;
7465
7336
  }
@@ -7471,9 +7342,9 @@ function getRemediator(idxRemediations, values, options) {
7471
7342
  remediatorCandidates.push(remediator);
7472
7343
  }
7473
7344
  } catch (err) {
7474
- _iterator.e(err);
7345
+ _iterator3.e(err);
7475
7346
  } finally {
7476
- _iterator.f();
7347
+ _iterator3.f();
7477
7348
  }
7478
7349
  return remediatorCandidates[0];
7479
7350
  }
@@ -7492,7 +7363,9 @@ function handleIdxError(e, remediator) {
7492
7363
  if (!idxResponse) {
7493
7364
  throw e;
7494
7365
  }
7495
- idxResponse.requestDidSucceed = false;
7366
+ idxResponse = _Object$assign(_Object$assign({}, idxResponse), {
7367
+ requestDidSucceed: false
7368
+ });
7496
7369
  var terminal = isTerminalResponse(idxResponse);
7497
7370
  var messages = getMessagesFromResponse(idxResponse);
7498
7371
  if (terminal) {
@@ -7511,44 +7384,61 @@ function handleIdxError(e, remediator) {
7511
7384
  });
7512
7385
  }
7513
7386
  }
7387
+
7388
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
7389
+ function _unsupportedIterableToArray(o, minLen) { var _context5; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context5 = Object.prototype.toString.call(o)).call(_context5, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7390
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
7514
7391
  function getActionFromValues(values, idxResponse) {
7515
- var _context2;
7516
- return _findInstanceProperty(_context2 = _Object$keys(idxResponse.actions)).call(_context2, function (action) {
7392
+ var _context;
7393
+ return _findInstanceProperty(_context = _Object$keys(idxResponse.actions)).call(_context, function (action) {
7517
7394
  return !!values.resend && _includesInstanceProperty(action).call(action, '-resend');
7518
7395
  });
7519
7396
  }
7520
7397
  function removeActionFromValues(values) {
7521
- values.resend = undefined;
7522
- return values;
7398
+ return _Object$assign(_Object$assign({}, values), {
7399
+ resend: undefined
7400
+ });
7401
+ }
7402
+ function removeActionFromOptions(options, actionName) {
7403
+ var actions = options.actions || [];
7404
+ actions = _filterInstanceProperty(actions).call(actions, function (entry) {
7405
+ if (typeof entry === 'string') {
7406
+ return entry !== actionName;
7407
+ }
7408
+ return entry.name !== actionName;
7409
+ });
7410
+ return _Object$assign(_Object$assign({}, options), {
7411
+ actions: actions
7412
+ });
7523
7413
  }
7524
7414
  function remediate(_x, _x2, _x3) {
7525
7415
  return _remediate.apply(this, arguments);
7526
7416
  }
7527
7417
  function _remediate() {
7528
7418
  _remediate = _asyncToGenerator( _regeneratorRuntime.mark(function _callee(idxResponse, values, options) {
7529
- var _context3;
7530
- var _idxResponse, neededToProceed, interactionCode, flow, terminal, messages, remediator, actionFromValues, actionFromOptions, actions, _iterator2, _step2, _loop, _ret, nextStep, _nextStep, name, data;
7531
- return _regeneratorRuntime.wrap(function _callee$(_context5) {
7419
+ var _context2;
7420
+ var _idxResponse, neededToProceed, interactionCode, _options, flow, terminal, messages, remediator, actionFromValues, actionFromOptions, actions, _iterator, _step, _loop, _ret, nextStep, name, data;
7421
+ return _regeneratorRuntime.wrap(function _callee$(_context4) {
7532
7422
  while (1) {
7533
- switch (_context5.prev = _context5.next) {
7423
+ switch (_context4.prev = _context4.next) {
7534
7424
  case 0:
7535
7425
  _idxResponse = idxResponse, neededToProceed = _idxResponse.neededToProceed, interactionCode = _idxResponse.interactionCode;
7536
- flow = options.flow;
7426
+ _options = options, flow = _options.flow;
7537
7427
  if (!interactionCode) {
7538
- _context5.next = 4;
7428
+ _context4.next = 4;
7539
7429
  break;
7540
7430
  }
7541
- return _context5.abrupt("return", {
7431
+ return _context4.abrupt("return", {
7542
7432
  idxResponse: idxResponse
7543
7433
  });
7544
7434
  case 4:
7545
7435
  terminal = isTerminalResponse(idxResponse);
7546
7436
  messages = getMessagesFromResponse(idxResponse);
7547
7437
  if (!terminal) {
7548
- _context5.next = 8;
7438
+ _context4.next = 8;
7549
7439
  break;
7550
7440
  }
7551
- return _context5.abrupt("return", {
7441
+ return _context4.abrupt("return", {
7552
7442
  idxResponse: idxResponse,
7553
7443
  terminal: terminal,
7554
7444
  messages: messages
@@ -7557,150 +7447,157 @@ function _remediate() {
7557
7447
  remediator = getRemediator(neededToProceed, values, options);
7558
7448
  actionFromValues = getActionFromValues(values, idxResponse);
7559
7449
  actionFromOptions = options.actions || [];
7560
- actions = _concatInstanceProperty(_context3 = []).call(_context3, _toConsumableArray(actionFromOptions), _toConsumableArray(actionFromValues && [actionFromValues] || []));
7450
+ actions = _concatInstanceProperty(_context2 = []).call(_context2, _toConsumableArray(actionFromOptions), _toConsumableArray(actionFromValues && [actionFromValues] || []));
7561
7451
  if (!actions) {
7562
- _context5.next = 32;
7452
+ _context4.next = 32;
7563
7453
  break;
7564
7454
  }
7565
- _iterator2 = _createForOfIteratorHelper(actions);
7566
- _context5.prev = 14;
7455
+ _iterator = _createForOfIteratorHelper(actions);
7456
+ _context4.prev = 14;
7567
7457
  _loop = _regeneratorRuntime.mark(function _loop() {
7568
- var action, valuesWithoutExecutedAction, optionsWithoutExecutedAction, remediationAction;
7569
- return _regeneratorRuntime.wrap(function _loop$(_context4) {
7458
+ var action, params, valuesWithoutExecutedAction, optionsWithoutExecutedAction, remediationAction;
7459
+ return _regeneratorRuntime.wrap(function _loop$(_context3) {
7570
7460
  while (1) {
7571
- switch (_context4.prev = _context4.next) {
7461
+ switch (_context3.prev = _context3.next) {
7572
7462
  case 0:
7573
- action = _step2.value;
7463
+ action = _step.value;
7464
+ params = {};
7465
+ if (typeof action !== 'string') {
7466
+ params = action.params || {};
7467
+ action = action.name;
7468
+ }
7574
7469
  valuesWithoutExecutedAction = removeActionFromValues(values);
7575
- optionsWithoutExecutedAction = _Object$assign(_Object$assign({}, options), {
7576
- actions: _filterInstanceProperty(actionFromOptions).call(actionFromOptions, function (entry) {
7577
- return entry !== action;
7578
- })
7579
- });
7470
+ optionsWithoutExecutedAction = removeActionFromOptions(options, action);
7580
7471
  if (!(typeof idxResponse.actions[action] === 'function')) {
7581
- _context4.next = 17;
7472
+ _context3.next = 19;
7582
7473
  break;
7583
7474
  }
7584
- _context4.prev = 4;
7585
- _context4.next = 7;
7586
- return idxResponse.actions[action]();
7587
- case 7:
7588
- idxResponse = _context4.sent;
7589
- idxResponse.requestDidSucceed = true;
7590
- _context4.next = 14;
7475
+ _context3.prev = 6;
7476
+ _context3.next = 9;
7477
+ return idxResponse.actions[action](params);
7478
+ case 9:
7479
+ idxResponse = _context3.sent;
7480
+ idxResponse = _Object$assign(_Object$assign({}, idxResponse), {
7481
+ requestDidSucceed: true
7482
+ });
7483
+ _context3.next = 16;
7591
7484
  break;
7592
- case 11:
7593
- _context4.prev = 11;
7594
- _context4.t0 = _context4["catch"](4);
7595
- return _context4.abrupt("return", {
7596
- v: handleIdxError(_context4.t0, remediator)
7485
+ case 13:
7486
+ _context3.prev = 13;
7487
+ _context3.t0 = _context3["catch"](6);
7488
+ return _context3.abrupt("return", {
7489
+ v: handleIdxError(_context3.t0, remediator)
7597
7490
  });
7598
- case 14:
7491
+ case 16:
7599
7492
  if (!(action === 'cancel')) {
7600
- _context4.next = 16;
7493
+ _context3.next = 18;
7601
7494
  break;
7602
7495
  }
7603
- return _context4.abrupt("return", {
7496
+ return _context3.abrupt("return", {
7604
7497
  v: {
7605
7498
  idxResponse: idxResponse,
7606
7499
  canceled: true
7607
7500
  }
7608
7501
  });
7609
- case 16:
7610
- return _context4.abrupt("return", {
7502
+ case 18:
7503
+ return _context3.abrupt("return", {
7611
7504
  v: remediate(idxResponse, valuesWithoutExecutedAction, optionsWithoutExecutedAction)
7612
7505
  });
7613
- case 17:
7614
- remediationAction = _findInstanceProperty(neededToProceed).call(neededToProceed, function (_ref2) {
7615
- var name = _ref2.name;
7506
+ case 19:
7507
+ remediationAction = _findInstanceProperty(neededToProceed).call(neededToProceed, function (_ref) {
7508
+ var name = _ref.name;
7616
7509
  return name === action;
7617
7510
  });
7618
7511
  if (!remediationAction) {
7619
- _context4.next = 30;
7512
+ _context3.next = 32;
7620
7513
  break;
7621
7514
  }
7622
- _context4.prev = 19;
7623
- _context4.next = 22;
7624
- return idxResponse.proceed(action, {});
7625
- case 22:
7626
- idxResponse = _context4.sent;
7627
- idxResponse.requestDidSucceed = true;
7628
- _context4.next = 29;
7515
+ _context3.prev = 21;
7516
+ _context3.next = 24;
7517
+ return idxResponse.proceed(action, params);
7518
+ case 24:
7519
+ idxResponse = _context3.sent;
7520
+ idxResponse = _Object$assign(_Object$assign({}, idxResponse), {
7521
+ requestDidSucceed: true
7522
+ });
7523
+ _context3.next = 31;
7629
7524
  break;
7630
- case 26:
7631
- _context4.prev = 26;
7632
- _context4.t1 = _context4["catch"](19);
7633
- return _context4.abrupt("return", {
7634
- v: handleIdxError(_context4.t1, remediator)
7525
+ case 28:
7526
+ _context3.prev = 28;
7527
+ _context3.t1 = _context3["catch"](21);
7528
+ return _context3.abrupt("return", {
7529
+ v: handleIdxError(_context3.t1, remediator)
7635
7530
  });
7636
- case 29:
7637
- return _context4.abrupt("return", {
7531
+ case 31:
7532
+ return _context3.abrupt("return", {
7638
7533
  v: remediate(idxResponse, values, optionsWithoutExecutedAction)
7639
7534
  });
7640
- case 30:
7535
+ case 32:
7641
7536
  case "end":
7642
- return _context4.stop();
7537
+ return _context3.stop();
7643
7538
  }
7644
7539
  }
7645
- }, _loop, null, [[4, 11], [19, 26]]);
7540
+ }, _loop, null, [[6, 13], [21, 28]]);
7646
7541
  });
7647
- _iterator2.s();
7542
+ _iterator.s();
7648
7543
  case 17:
7649
- if ((_step2 = _iterator2.n()).done) {
7650
- _context5.next = 24;
7544
+ if ((_step = _iterator.n()).done) {
7545
+ _context4.next = 24;
7651
7546
  break;
7652
7547
  }
7653
- return _context5.delegateYield(_loop(), "t0", 19);
7548
+ return _context4.delegateYield(_loop(), "t0", 19);
7654
7549
  case 19:
7655
- _ret = _context5.t0;
7550
+ _ret = _context4.t0;
7656
7551
  if (!(_typeof(_ret) === "object")) {
7657
- _context5.next = 22;
7552
+ _context4.next = 22;
7658
7553
  break;
7659
7554
  }
7660
- return _context5.abrupt("return", _ret.v);
7555
+ return _context4.abrupt("return", _ret.v);
7661
7556
  case 22:
7662
- _context5.next = 17;
7557
+ _context4.next = 17;
7663
7558
  break;
7664
7559
  case 24:
7665
- _context5.next = 29;
7560
+ _context4.next = 29;
7666
7561
  break;
7667
7562
  case 26:
7668
- _context5.prev = 26;
7669
- _context5.t1 = _context5["catch"](14);
7670
- _iterator2.e(_context5.t1);
7563
+ _context4.prev = 26;
7564
+ _context4.t1 = _context4["catch"](14);
7565
+ _iterator.e(_context4.t1);
7671
7566
  case 29:
7672
- _context5.prev = 29;
7673
- _iterator2.f();
7674
- return _context5.finish(29);
7567
+ _context4.prev = 29;
7568
+ _iterator.f();
7569
+ return _context4.finish(29);
7675
7570
  case 32:
7676
7571
  if (remediator) {
7677
- _context5.next = 49;
7572
+ _context4.next = 49;
7678
7573
  break;
7679
7574
  }
7680
7575
  if (!options.step) {
7681
- _context5.next = 46;
7576
+ _context4.next = 46;
7682
7577
  break;
7683
7578
  }
7684
- values = filterValuesForRemediation(idxResponse, values);
7685
- _context5.prev = 35;
7686
- _context5.next = 38;
7579
+ values = filterValuesForRemediation(idxResponse, options.step, values);
7580
+ _context4.prev = 35;
7581
+ _context4.next = 38;
7687
7582
  return idxResponse.proceed(options.step, values);
7688
7583
  case 38:
7689
- idxResponse = _context5.sent;
7690
- idxResponse.requestDidSucceed = true;
7691
- return _context5.abrupt("return", {
7584
+ idxResponse = _context4.sent;
7585
+ idxResponse = _Object$assign(_Object$assign({}, idxResponse), {
7586
+ requestDidSucceed: true
7587
+ });
7588
+ return _context4.abrupt("return", {
7692
7589
  idxResponse: idxResponse
7693
7590
  });
7694
7591
  case 43:
7695
- _context5.prev = 43;
7696
- _context5.t2 = _context5["catch"](35);
7697
- return _context5.abrupt("return", handleIdxError(_context5.t2));
7592
+ _context4.prev = 43;
7593
+ _context4.t2 = _context4["catch"](35);
7594
+ return _context4.abrupt("return", handleIdxError(_context4.t2));
7698
7595
  case 46:
7699
7596
  if (!(flow === 'default')) {
7700
- _context5.next = 48;
7597
+ _context4.next = 48;
7701
7598
  break;
7702
7599
  }
7703
- return _context5.abrupt("return", {
7600
+ return _context4.abrupt("return", {
7704
7601
  idxResponse: idxResponse
7705
7602
  });
7706
7603
  case 48:
@@ -7708,48 +7605,42 @@ function _remediate() {
7708
7605
  return acc ? acc + ' ,' + curr.name : curr.name;
7709
7606
  }, ''), "]\n "));
7710
7607
  case 49:
7711
- if (!messages.length) {
7712
- _context5.next = 52;
7608
+ if (remediator.canRemediate()) {
7609
+ _context4.next = 52;
7713
7610
  break;
7714
7611
  }
7715
7612
  nextStep = getNextStep(remediator, idxResponse);
7716
- return _context5.abrupt("return", {
7613
+ return _context4.abrupt("return", {
7717
7614
  idxResponse: idxResponse,
7718
7615
  nextStep: nextStep,
7719
- messages: messages
7616
+ messages: messages.length ? messages : undefined
7720
7617
  });
7721
7618
  case 52:
7722
- if (remediator.canRemediate()) {
7723
- _context5.next = 55;
7724
- break;
7725
- }
7726
- _nextStep = getNextStep(remediator, idxResponse);
7727
- return _context5.abrupt("return", {
7728
- idxResponse: idxResponse,
7729
- nextStep: _nextStep
7730
- });
7731
- case 55:
7732
7619
  name = remediator.getName();
7733
7620
  data = remediator.getData();
7734
- _context5.prev = 57;
7735
- _context5.next = 60;
7621
+ _context4.prev = 54;
7622
+ _context4.next = 57;
7736
7623
  return idxResponse.proceed(name, data);
7737
- case 60:
7738
- idxResponse = _context5.sent;
7739
- idxResponse.requestDidSucceed = true;
7624
+ case 57:
7625
+ idxResponse = _context4.sent;
7626
+ idxResponse = _Object$assign(_Object$assign({}, idxResponse), {
7627
+ requestDidSucceed: true
7628
+ });
7740
7629
  values = remediator.getValuesAfterProceed();
7741
- delete options.step;
7742
- return _context5.abrupt("return", remediate(idxResponse, values, options));
7630
+ options = _Object$assign(_Object$assign({}, options), {
7631
+ step: undefined
7632
+ });
7633
+ return _context4.abrupt("return", remediate(idxResponse, values, options));
7634
+ case 64:
7635
+ _context4.prev = 64;
7636
+ _context4.t3 = _context4["catch"](54);
7637
+ return _context4.abrupt("return", handleIdxError(_context4.t3, remediator));
7743
7638
  case 67:
7744
- _context5.prev = 67;
7745
- _context5.t3 = _context5["catch"](57);
7746
- return _context5.abrupt("return", handleIdxError(_context5.t3, remediator));
7747
- case 70:
7748
7639
  case "end":
7749
- return _context5.stop();
7640
+ return _context4.stop();
7750
7641
  }
7751
7642
  }
7752
- }, _callee, null, [[14, 26, 29, 32], [35, 43], [57, 67]]);
7643
+ }, _callee, null, [[14, 26, 29, 32], [35, 43], [54, 64]]);
7753
7644
  }));
7754
7645
  return _remediate.apply(this, arguments);
7755
7646
  }
@@ -7844,7 +7735,7 @@ function getFlowSpecification(oktaAuth) {
7844
7735
  }
7845
7736
 
7846
7737
  function initializeValues(options) {
7847
- var knownOptions = ['flow', 'remediators', 'actions', 'withCredentials', 'step'];
7738
+ var knownOptions = ['flow', 'remediators', 'actions', 'withCredentials', 'step', 'shouldProceedWithEmailAuthenticator'];
7848
7739
  var values = _Object$assign({}, options);
7849
7740
  knownOptions.forEach(function (option) {
7850
7741
  delete values[option];
@@ -7888,26 +7779,26 @@ function _getDataFromIntrospect() {
7888
7779
  case 0:
7889
7780
  options = data.options;
7890
7781
  stateHandle = options.stateHandle, withCredentials = options.withCredentials, version = options.version, state = options.state, scopes = options.scopes, recoveryToken = options.recoveryToken, activationToken = options.activationToken;
7782
+ meta = getSavedTransactionMeta(authClient, {
7783
+ state: state,
7784
+ recoveryToken: recoveryToken,
7785
+ activationToken: activationToken
7786
+ });
7891
7787
  if (!stateHandle) {
7892
- _context.next = 8;
7788
+ _context.next = 9;
7893
7789
  break;
7894
7790
  }
7895
- _context.next = 5;
7791
+ _context.next = 6;
7896
7792
  return introspect(authClient, {
7897
7793
  withCredentials: withCredentials,
7898
7794
  version: version,
7899
7795
  stateHandle: stateHandle
7900
7796
  });
7901
- case 5:
7797
+ case 6:
7902
7798
  idxResponse = _context.sent;
7903
7799
  _context.next = 20;
7904
7800
  break;
7905
- case 8:
7906
- meta = getSavedTransactionMeta(authClient, {
7907
- state: state,
7908
- recoveryToken: recoveryToken,
7909
- activationToken: activationToken
7910
- });
7801
+ case 9:
7911
7802
  interactionHandle = meta === null || meta === void 0 ? void 0 : meta.interactionHandle;
7912
7803
  if (interactionHandle) {
7913
7804
  _context.next = 17;
@@ -7954,13 +7845,13 @@ function getDataFromRemediate(_x3) {
7954
7845
  }
7955
7846
  function _getDataFromRemediate() {
7956
7847
  _getDataFromRemediate = _asyncToGenerator( _regeneratorRuntime.mark(function _callee2(data) {
7957
- var idxResponse, options, values, autoRemediate, remediators, actions, flow, step, shouldRemediate, _yield$remediate, idxResponseFromRemediation, nextStep, canceled;
7848
+ var idxResponse, options, values, autoRemediate, remediators, actions, flow, step, shouldProceedWithEmailAuthenticator, shouldRemediate, _yield$remediate, idxResponseFromRemediation, nextStep, canceled;
7958
7849
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
7959
7850
  while (1) {
7960
7851
  switch (_context2.prev = _context2.next) {
7961
7852
  case 0:
7962
7853
  idxResponse = data.idxResponse, options = data.options, values = _valuesInstanceProperty(data);
7963
- autoRemediate = options.autoRemediate, remediators = options.remediators, actions = options.actions, flow = options.flow, step = options.step;
7854
+ autoRemediate = options.autoRemediate, remediators = options.remediators, actions = options.actions, flow = options.flow, step = options.step, shouldProceedWithEmailAuthenticator = options.shouldProceedWithEmailAuthenticator;
7964
7855
  shouldRemediate = autoRemediate !== false && (remediators || actions || step);
7965
7856
  if (shouldRemediate) {
7966
7857
  _context2.next = 5;
@@ -7976,7 +7867,8 @@ function _getDataFromRemediate() {
7976
7867
  remediators: remediators,
7977
7868
  actions: actions,
7978
7869
  flow: flow,
7979
- step: step
7870
+ step: step,
7871
+ shouldProceedWithEmailAuthenticator: shouldProceedWithEmailAuthenticator
7980
7872
  });
7981
7873
  case 8:
7982
7874
  _yield$remediate = _context2.sent;
@@ -8150,13 +8042,14 @@ function _run() {
8150
8042
  error,
8151
8043
  interactionCode,
8152
8044
  rawIdxResponse,
8153
- requestDidSucceed,
8045
+ _requestDidSucceed,
8154
8046
  _ref,
8155
8047
  actions,
8156
8048
  context,
8157
8049
  neededToProceed,
8158
8050
  proceed,
8159
8051
  rawIdxState,
8052
+ requestDidSucceed,
8160
8053
  _args5 = arguments;
8161
8054
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
8162
8055
  while (1) {
@@ -8196,14 +8089,14 @@ function _run() {
8196
8089
  } else {
8197
8090
  saveTransactionMeta(authClient, _Object$assign({}, meta));
8198
8091
  if (idxResponse) {
8199
- rawIdxResponse = idxResponse.rawIdxState, requestDidSucceed = idxResponse.requestDidSucceed;
8092
+ rawIdxResponse = idxResponse.rawIdxState, _requestDidSucceed = idxResponse.requestDidSucceed;
8200
8093
  authClient.transactionManager.saveIdxResponse({
8201
8094
  rawIdxResponse: rawIdxResponse,
8202
- requestDidSucceed: requestDidSucceed
8095
+ requestDidSucceed: _requestDidSucceed
8203
8096
  });
8204
8097
  }
8205
8098
  }
8206
- _ref = idxResponse || {}, actions = _ref.actions, context = _ref.context, neededToProceed = _ref.neededToProceed, proceed = _ref.proceed, rawIdxState = _ref.rawIdxState;
8099
+ _ref = idxResponse || {}, actions = _ref.actions, context = _ref.context, neededToProceed = _ref.neededToProceed, proceed = _ref.proceed, rawIdxState = _ref.rawIdxState, requestDidSucceed = _ref.requestDidSucceed;
8207
8100
  return _context5.abrupt("return", _Object$assign(_Object$assign(_Object$assign(_Object$assign(_Object$assign(_Object$assign(_Object$assign(_Object$assign({
8208
8101
  status: status
8209
8102
  }, meta && {
@@ -8226,7 +8119,8 @@ function _run() {
8226
8119
  context: context,
8227
8120
  neededToProceed: neededToProceed,
8228
8121
  proceed: proceed,
8229
- rawIdxState: rawIdxState
8122
+ rawIdxState: rawIdxState,
8123
+ requestDidSucceed: requestDidSucceed
8230
8124
  }));
8231
8125
  case 22:
8232
8126
  case "end":
@@ -8687,26 +8581,10 @@ function _unlockAccount() {
8687
8581
  return _unlockAccount.apply(this, arguments);
8688
8582
  }
8689
8583
 
8690
- function setGlobalRequestInterceptor(fn) {
8691
- idx.client.interceptors.request.use(fn);
8692
- }
8693
- function createGlobalRequestInterceptor(sdk) {
8694
- return function (requestConfig) {
8695
- var oktaUserAgentHeader = sdk._oktaUserAgent.getHttpHeader();
8696
- var headers = _Object$assign(_Object$assign({}, oktaUserAgentHeader), sdk.options.headers);
8697
- _Object$keys(headers).forEach(function (name) {
8698
- if (!sdk.options.clientSecret && name === 'X-Device-Token') {
8699
- return;
8700
- }
8701
- requestConfig.headers[name] = headers[name];
8702
- });
8703
- };
8704
- }
8705
-
8706
8584
  var OktaUserAgent = function () {
8707
8585
  function OktaUserAgent() {
8708
8586
  _classCallCheck(this, OktaUserAgent);
8709
- this.environments = ["okta-auth-js/".concat("6.3.1")];
8587
+ this.environments = ["okta-auth-js/".concat("6.4.1")];
8710
8588
  }
8711
8589
  _createClass(OktaUserAgent, [{
8712
8590
  key: "addEnvironment",
@@ -8724,7 +8602,7 @@ var OktaUserAgent = function () {
8724
8602
  }, {
8725
8603
  key: "getVersion",
8726
8604
  value: function getVersion() {
8727
- return "6.3.1";
8605
+ return "6.4.1";
8728
8606
  }
8729
8607
  }, {
8730
8608
  key: "maybeAddNodeEnvironment",
@@ -8743,6 +8621,7 @@ var OktaAuth = function () {
8743
8621
  function OktaAuth(args) {
8744
8622
  var _this = this;
8745
8623
  _classCallCheck(this, OktaAuth);
8624
+ this.features = features;
8746
8625
  var options = this.options = buildOptions(args);
8747
8626
  this.storageManager = new StorageManager(options.storageManager, options.cookies, options.storageUtil);
8748
8627
  this.transactionManager = new TransactionManager(_Object$assign({
@@ -8872,7 +8751,6 @@ var OktaAuth = function () {
8872
8751
  canProceed: canProceed.bind(null, this),
8873
8752
  unlockAccount: unlockAccount.bind(null, this)
8874
8753
  };
8875
- setGlobalRequestInterceptor(createGlobalRequestInterceptor(this));
8876
8754
  this.http = {
8877
8755
  setRequestHeader: setRequestHeader.bind(null, this)
8878
8756
  };
@@ -9584,9 +9462,10 @@ var OktaAuth = function () {
9584
9462
  }]);
9585
9463
  return OktaAuth;
9586
9464
  }();
9587
- OktaAuth.features = OktaAuth.prototype.features = features;
9465
+ OktaAuth.features = features;
9588
9466
  OktaAuth.crypto = crypto;
9589
9467
  OktaAuth.webauthn = webauthn;
9468
+ OktaAuth.features = OktaAuth.prototype.features = features;
9590
9469
  _Object$assign(OktaAuth, {
9591
9470
  constants: constants
9592
9471
  });