@okta/okta-auth-js 7.3.0 → 7.3.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 (53) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/cjs/http/OktaUserAgent.js +2 -2
  3. package/cjs/idx/remediate.js +2 -2
  4. package/cjs/idx/remediate.js.map +1 -1
  5. package/cjs/idx/remediators/Base/Remediator.js +1 -1
  6. package/cjs/idx/remediators/Base/Remediator.js.map +1 -1
  7. package/cjs/idx/remediators/Base/SelectAuthenticator.js +8 -2
  8. package/cjs/idx/remediators/Base/SelectAuthenticator.js.map +1 -1
  9. package/cjs/idx/util.js +7 -3
  10. package/cjs/idx/util.js.map +1 -1
  11. package/dist/okta-auth-js.authn.min.analyzer.html +1 -1
  12. package/dist/okta-auth-js.authn.min.js +1 -1
  13. package/dist/okta-auth-js.core.min.analyzer.html +1 -1
  14. package/dist/okta-auth-js.core.min.js +1 -1
  15. package/dist/okta-auth-js.idx.min.analyzer.html +2 -2
  16. package/dist/okta-auth-js.idx.min.js +1 -1
  17. package/dist/okta-auth-js.idx.min.js.map +1 -1
  18. package/dist/okta-auth-js.min.analyzer.html +2 -2
  19. package/dist/okta-auth-js.min.js +1 -1
  20. package/dist/okta-auth-js.min.js.map +1 -1
  21. package/dist/okta-auth-js.myaccount.min.analyzer.html +2 -2
  22. package/dist/okta-auth-js.myaccount.min.js +1 -1
  23. package/esm/browser/http/OktaUserAgent.js +2 -2
  24. package/esm/browser/idx/remediate.js +2 -2
  25. package/esm/browser/idx/remediate.js.map +1 -1
  26. package/esm/browser/idx/remediators/Base/Remediator.js +1 -1
  27. package/esm/browser/idx/remediators/Base/Remediator.js.map +1 -1
  28. package/esm/browser/idx/remediators/Base/SelectAuthenticator.js +7 -2
  29. package/esm/browser/idx/remediators/Base/SelectAuthenticator.js.map +1 -1
  30. package/esm/browser/idx/util.js +4 -3
  31. package/esm/browser/idx/util.js.map +1 -1
  32. package/esm/browser/package.json +1 -1
  33. package/esm/node/http/OktaUserAgent.js +2 -2
  34. package/esm/node/idx/remediate.js +2 -2
  35. package/esm/node/idx/remediate.js.map +1 -1
  36. package/esm/node/idx/remediators/Base/Remediator.js +1 -1
  37. package/esm/node/idx/remediators/Base/Remediator.js.map +1 -1
  38. package/esm/node/idx/remediators/Base/SelectAuthenticator.js +7 -2
  39. package/esm/node/idx/remediators/Base/SelectAuthenticator.js.map +1 -1
  40. package/esm/node/idx/util.js +4 -3
  41. package/esm/node/idx/util.js.map +1 -1
  42. package/esm/node/package.json +1 -1
  43. package/package.json +3 -3
  44. package/types/lib/idx/remediators/Base/Remediator.d.ts +1 -1
  45. package/types/lib/idx/remediators/Base/SelectAuthenticator.d.ts +3 -3
  46. package/types/lib/idx/util.d.ts +2 -2
  47. package/umd/authn.js +1 -1
  48. package/umd/core.js +1 -1
  49. package/umd/default.js +1 -1
  50. package/umd/default.js.map +1 -1
  51. package/umd/idx.js +1 -1
  52. package/umd/idx.js.map +1 -1
  53. package/umd/myaccount.js +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 7.3.1
4
+
5
+ ### Fixes
6
+
7
+ - [#1426](https://github.com/okta/okta-auth-js/pull/1426) fix: Don't auto remediate SelectAuthenticator with current authenticator
8
+
3
9
  ## 7.3.0
4
10
 
5
11
  ### Features
@@ -20,7 +20,7 @@ var _features = require("../features");
20
20
  class OktaUserAgent {
21
21
  constructor() {
22
22
  // add base sdk env
23
- this.environments = [`okta-auth-js/${"7.3.0"}`];
23
+ this.environments = [`okta-auth-js/${"7.3.1"}`];
24
24
  }
25
25
  addEnvironment(env) {
26
26
  this.environments.push(env);
@@ -32,7 +32,7 @@ class OktaUserAgent {
32
32
  };
33
33
  }
34
34
  getVersion() {
35
- return "7.3.0";
35
+ return "7.3.1";
36
36
  }
37
37
  maybeAddNodeEnvironment() {
38
38
  if ((0, _features.isBrowser)() || !process || !process.versions) {
@@ -58,7 +58,7 @@ async function remediate(authClient, idxResponse, values, options) {
58
58
  idxResponse
59
59
  };
60
60
  }
61
- const remediator = (0, _util.getRemediator)(neededToProceed, values, options);
61
+ const remediator = (0, _util.getRemediator)(idxResponse, values, options);
62
62
 
63
63
  // Try actions in idxResponse first
64
64
  const actionFromValues = getActionFromValues(values, idxResponse);
@@ -161,7 +161,7 @@ async function remediate(authClient, idxResponse, values, options) {
161
161
  // return nextStep directly
162
162
  if (options.useGenericRemediator && !idxResponse.interactionCode && !(0, _util.isTerminalResponse)(idxResponse)) {
163
163
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
164
- const gr = (0, _util.getRemediator)(idxResponse.neededToProceed, values, options);
164
+ const gr = (0, _util.getRemediator)(idxResponse, values, options);
165
165
  const nextStep = (0, _util.getNextStep)(authClient, gr, idxResponse);
166
166
  return {
167
167
  idxResponse,
@@ -1 +1 @@
1
- {"version":3,"file":"remediate.js","names":["getActionFromValues","values","idxResponse","Object","keys","actions","find","action","resend","includes","removeActionFromValues","undefined","removeActionFromOptions","options","actionName","filter","entry","name","remediate","authClient","neededToProceed","interactionCode","flow","remediator","getRemediator","actionFromValues","actionFromOptions","params","valuesWithoutExecutedAction","optionsWithoutExecutedAction","requestDidSucceed","handleFailedResponse","canceled","remediationAction","proceed","terminal","isTerminalResponse","step","filterValuesForRemediation","AuthSdkError","reduce","acc","curr","canRemediate","nextStep","getNextStep","getName","data","getData","getValuesAfterProceed","useGenericRemediator","gr"],"sources":["../../../lib/idx/remediate.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n\n/* eslint-disable max-statements, max-depth, complexity */\nimport { AuthSdkError } from '../errors';\nimport { RemediationValues } from './remediators';\nimport { OktaAuthIdxInterface, RemediateOptions, RemediationResponse } from './types';\nimport { \n IdxResponse,\n IdxActionParams, \n} from './types/idx-js';\nimport {\n isTerminalResponse,\n filterValuesForRemediation,\n getRemediator,\n getNextStep,\n handleFailedResponse\n} from './util';\n\nexport interface RemediateActionWithOptionalParams {\n name: string;\n params?: IdxActionParams;\n}\n\nexport type RemediateAction = string | RemediateActionWithOptionalParams;\n\n\nfunction getActionFromValues(values: RemediationValues, idxResponse: IdxResponse): string | undefined {\n // Currently support resend actions only\n return Object.keys(idxResponse.actions).find(action => !!values.resend && action.includes('-resend'));\n}\n\nfunction removeActionFromValues(values: RemediationValues): RemediationValues {\n // Currently support resend actions only\n return {\n ...values,\n resend: undefined\n };\n}\n\nfunction removeActionFromOptions(options: RemediateOptions, actionName: string): RemediateOptions {\n let actions = options.actions || [];\n actions = actions.filter(entry => {\n if (typeof entry === 'string') {\n return entry !== actionName;\n }\n return entry.name !== actionName;\n });\n\n return { ...options, actions };\n}\n\n// This function is called recursively until it reaches success or cannot be remediated\nexport async function remediate(\n authClient: OktaAuthIdxInterface,\n idxResponse: IdxResponse,\n values: RemediationValues,\n options: RemediateOptions\n): Promise<RemediationResponse> {\n let { neededToProceed, interactionCode } = idxResponse;\n const { flow } = options;\n\n // If the response contains an interaction code, there is no need to remediate\n if (interactionCode) {\n return { idxResponse };\n }\n\n const remediator = getRemediator(neededToProceed, values, options);\n\n // Try actions in idxResponse first\n const actionFromValues = getActionFromValues(values, idxResponse);\n const actionFromOptions = options.actions || [];\n const actions = [\n ...actionFromOptions,\n ...(actionFromValues && [actionFromValues] || []),\n ];\n if (actions) {\n for (let action of actions) {\n // Action can either be specified as a string, or as an object with name and optional params\n let params: IdxActionParams = {};\n if (typeof action !== 'string') {\n params = action.params || {};\n action = action.name;\n }\n let valuesWithoutExecutedAction = removeActionFromValues(values);\n let optionsWithoutExecutedAction = removeActionFromOptions(options, action);\n\n if (typeof idxResponse.actions[action] === 'function') {\n idxResponse = await idxResponse.actions[action](params);\n if (idxResponse.requestDidSucceed === false) {\n return handleFailedResponse(authClient, idxResponse, options);\n }\n if (action === 'cancel') {\n return { idxResponse, canceled: true };\n }\n return remediate(\n authClient, \n idxResponse, \n valuesWithoutExecutedAction, \n optionsWithoutExecutedAction\n ); // recursive call\n }\n\n // search for action in remediation list\n const remediationAction = neededToProceed.find(({ name }) => name === action);\n if (remediationAction) {\n idxResponse = await idxResponse.proceed(action, params);\n if (idxResponse.requestDidSucceed === false) {\n return handleFailedResponse(authClient, idxResponse, options);\n }\n return remediate(authClient, idxResponse, values, optionsWithoutExecutedAction); // recursive call\n }\n }\n }\n\n // Do not attempt to remediate if response is in terminal state\n const terminal = isTerminalResponse(idxResponse);\n if (terminal) {\n return { idxResponse, terminal };\n }\n\n if (!remediator) {\n // With options.step, remediator is not required\n if (options.step) {\n values = filterValuesForRemediation(idxResponse, options.step, values); // include only requested values\n idxResponse = await idxResponse.proceed(options.step, values);\n if (idxResponse.requestDidSucceed === false) {\n return handleFailedResponse(authClient, idxResponse, options);\n }\n return { idxResponse };\n }\n\n // With default flow, remediator is not required\n if (flow === 'default') {\n return { idxResponse };\n }\n throw new AuthSdkError(`\n No remediation can match current flow, check policy settings in your org.\n Remediations: [${neededToProceed.reduce((acc, curr) => acc ? acc + ' ,' + curr.name : curr.name, '')}]\n `);\n }\n\n // Return next step to the caller\n if (!remediator.canRemediate()) {\n const nextStep = getNextStep(authClient, remediator, idxResponse);\n return {\n idxResponse,\n nextStep,\n };\n }\n\n const name = remediator.getName();\n const data = remediator.getData();\n\n idxResponse = await idxResponse.proceed(name, data);\n if (idxResponse.requestDidSucceed === false) {\n return handleFailedResponse(authClient, idxResponse, options);\n }\n // We may want to trim the values bag for the next remediation\n // Let the remediator decide what the values should be (default to current values)\n values = remediator.getValuesAfterProceed();\n options = { ...options, step: undefined }; // do not re-use the step\n\n // generic remediator should not auto proceed in pending status\n // return nextStep directly\n if (options.useGenericRemediator && !idxResponse.interactionCode && !isTerminalResponse(idxResponse)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const gr = getRemediator(idxResponse.neededToProceed, values, options)!;\n const nextStep = getNextStep(authClient, gr, idxResponse);\n return {\n idxResponse,\n nextStep,\n };\n }\n \n return remediate(authClient, idxResponse, values, options); // recursive call\n\n}\n"],"mappings":";;;AAcA;AAOA;AArBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;;AAwBA,SAASA,mBAAmB,CAACC,MAAyB,EAAEC,WAAwB,EAAsB;EACpG;EACA,OAAOC,MAAM,CAACC,IAAI,CAACF,WAAW,CAACG,OAAO,CAAC,CAACC,IAAI,CAACC,MAAM,IAAI,CAAC,CAACN,MAAM,CAACO,MAAM,IAAID,MAAM,CAACE,QAAQ,CAAC,SAAS,CAAC,CAAC;AACvG;AAEA,SAASC,sBAAsB,CAACT,MAAyB,EAAqB;EAC5E;EACA,OAAO;IACL,GAAGA,MAAM;IACTO,MAAM,EAAEG;EACV,CAAC;AACH;AAEA,SAASC,uBAAuB,CAACC,OAAyB,EAAEC,UAAkB,EAAoB;EAChG,IAAIT,OAAO,GAAGQ,OAAO,CAACR,OAAO,IAAI,EAAE;EACnCA,OAAO,GAAGA,OAAO,CAACU,MAAM,CAACC,KAAK,IAAI;IAChC,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;MAC7B,OAAOA,KAAK,KAAKF,UAAU;IAC7B;IACA,OAAOE,KAAK,CAACC,IAAI,KAAKH,UAAU;EAClC,CAAC,CAAC;EAEF,OAAO;IAAE,GAAGD,OAAO;IAAER;EAAQ,CAAC;AAChC;;AAEA;AACO,eAAea,SAAS,CAC7BC,UAAgC,EAChCjB,WAAwB,EACxBD,MAAyB,EACzBY,OAAyB,EACK;EAC9B,IAAI;IAAEO,eAAe;IAAEC;EAAgB,CAAC,G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AAC,iBAAW,EAAC1B,UAAU,EAAEgC,EAAE,EAAEjD,WAAW,CAAC;IACzD,OAAO;MACLA,WAAW;MACX0C;IACF,CAAC;EACH;EAEA,OAAO1B,SAAS,CAACC,UAAU,EAAEjB,WAAW,EAAED,MAAM,EAAEY,OAAO,CAAC,CAAC,CAAC;AAE9D"}
1
+ {"version":3,"file":"remediate.js","names":["getActionFromValues","values","idxResponse","Object","keys","actions","find","action","resend","includes","removeActionFromValues","undefined","removeActionFromOptions","options","actionName","filter","entry","name","remediate","authClient","neededToProceed","interactionCode","flow","remediator","getRemediator","actionFromValues","actionFromOptions","params","valuesWithoutExecutedAction","optionsWithoutExecutedAction","requestDidSucceed","handleFailedResponse","canceled","remediationAction","proceed","terminal","isTerminalResponse","step","filterValuesForRemediation","AuthSdkError","reduce","acc","curr","canRemediate","nextStep","getNextStep","getName","data","getData","getValuesAfterProceed","useGenericRemediator","gr"],"sources":["../../../lib/idx/remediate.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n\n/* eslint-disable max-statements, max-depth, complexity */\nimport { AuthSdkError } from '../errors';\nimport { RemediationValues } from './remediators';\nimport { OktaAuthIdxInterface, RemediateOptions, RemediationResponse } from './types';\nimport { \n IdxResponse,\n IdxActionParams, \n} from './types/idx-js';\nimport {\n isTerminalResponse,\n filterValuesForRemediation,\n getRemediator,\n getNextStep,\n handleFailedResponse\n} from './util';\n\nexport interface RemediateActionWithOptionalParams {\n name: string;\n params?: IdxActionParams;\n}\n\nexport type RemediateAction = string | RemediateActionWithOptionalParams;\n\n\nfunction getActionFromValues(values: RemediationValues, idxResponse: IdxResponse): string | undefined {\n // Currently support resend actions only\n return Object.keys(idxResponse.actions).find(action => !!values.resend && action.includes('-resend'));\n}\n\nfunction removeActionFromValues(values: RemediationValues): RemediationValues {\n // Currently support resend actions only\n return {\n ...values,\n resend: undefined\n };\n}\n\nfunction removeActionFromOptions(options: RemediateOptions, actionName: string): RemediateOptions {\n let actions = options.actions || [];\n actions = actions.filter(entry => {\n if (typeof entry === 'string') {\n return entry !== actionName;\n }\n return entry.name !== actionName;\n });\n\n return { ...options, actions };\n}\n\n// This function is called recursively until it reaches success or cannot be remediated\nexport async function remediate(\n authClient: OktaAuthIdxInterface,\n idxResponse: IdxResponse,\n values: RemediationValues,\n options: RemediateOptions\n): Promise<RemediationResponse> {\n let { neededToProceed, interactionCode } = idxResponse;\n const { flow } = options;\n\n // If the response contains an interaction code, there is no need to remediate\n if (interactionCode) {\n return { idxResponse };\n }\n\n const remediator = getRemediator(idxResponse, values, options);\n\n // Try actions in idxResponse first\n const actionFromValues = getActionFromValues(values, idxResponse);\n const actionFromOptions = options.actions || [];\n const actions = [\n ...actionFromOptions,\n ...(actionFromValues && [actionFromValues] || []),\n ];\n if (actions) {\n for (let action of actions) {\n // Action can either be specified as a string, or as an object with name and optional params\n let params: IdxActionParams = {};\n if (typeof action !== 'string') {\n params = action.params || {};\n action = action.name;\n }\n let valuesWithoutExecutedAction = removeActionFromValues(values);\n let optionsWithoutExecutedAction = removeActionFromOptions(options, action);\n\n if (typeof idxResponse.actions[action] === 'function') {\n idxResponse = await idxResponse.actions[action](params);\n if (idxResponse.requestDidSucceed === false) {\n return handleFailedResponse(authClient, idxResponse, options);\n }\n if (action === 'cancel') {\n return { idxResponse, canceled: true };\n }\n return remediate(\n authClient, \n idxResponse, \n valuesWithoutExecutedAction, \n optionsWithoutExecutedAction\n ); // recursive call\n }\n\n // search for action in remediation list\n const remediationAction = neededToProceed.find(({ name }) => name === action);\n if (remediationAction) {\n idxResponse = await idxResponse.proceed(action, params);\n if (idxResponse.requestDidSucceed === false) {\n return handleFailedResponse(authClient, idxResponse, options);\n }\n return remediate(authClient, idxResponse, values, optionsWithoutExecutedAction); // recursive call\n }\n }\n }\n\n // Do not attempt to remediate if response is in terminal state\n const terminal = isTerminalResponse(idxResponse);\n if (terminal) {\n return { idxResponse, terminal };\n }\n\n if (!remediator) {\n // With options.step, remediator is not required\n if (options.step) {\n values = filterValuesForRemediation(idxResponse, options.step, values); // include only requested values\n idxResponse = await idxResponse.proceed(options.step, values);\n if (idxResponse.requestDidSucceed === false) {\n return handleFailedResponse(authClient, idxResponse, options);\n }\n return { idxResponse };\n }\n\n // With default flow, remediator is not required\n if (flow === 'default') {\n return { idxResponse };\n }\n throw new AuthSdkError(`\n No remediation can match current flow, check policy settings in your org.\n Remediations: [${neededToProceed.reduce((acc, curr) => acc ? acc + ' ,' + curr.name : curr.name, '')}]\n `);\n }\n\n // Return next step to the caller\n if (!remediator.canRemediate()) {\n const nextStep = getNextStep(authClient, remediator, idxResponse);\n return {\n idxResponse,\n nextStep,\n };\n }\n\n const name = remediator.getName();\n const data = remediator.getData();\n\n idxResponse = await idxResponse.proceed(name, data);\n if (idxResponse.requestDidSucceed === false) {\n return handleFailedResponse(authClient, idxResponse, options);\n }\n // We may want to trim the values bag for the next remediation\n // Let the remediator decide what the values should be (default to current values)\n values = remediator.getValuesAfterProceed();\n options = { ...options, step: undefined }; // do not re-use the step\n\n // generic remediator should not auto proceed in pending status\n // return nextStep directly\n if (options.useGenericRemediator && !idxResponse.interactionCode && !isTerminalResponse(idxResponse)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const gr = getRemediator(idxResponse, values, options)!;\n const nextStep = getNextStep(authClient, gr, idxResponse);\n return {\n idxResponse,\n nextStep,\n };\n }\n \n return remediate(authClient, idxResponse, values, options); // recursive call\n\n}\n"],"mappings":";;;AAcA;AAOA;AArBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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B,MAAMC,QAAQ,GAAG,IAAAC,iBAAW,EAAC1B,UAAU,EAAEI,UAAU,EAAErB,WAAW,CAAC;IACjE,OAAO;MACLA,WAAW;MACX0C;IACF,CAAC;EACH;EAEA,MAAM3B,IAAI,GAAGM,UAAU,CAACuB,OAAO,EAAE;EACjC,MAAMC,IAAI,GAAGxB,UAAU,CAACyB,OAAO,EAAE;EAEjC9C,WAAW,GAAG,MAAMA,WAAW,CAACgC,OAAO,CAACjB,IAAI,EAAE8B,IAAI,CAAC;EACnD,IAAI7C,WAAW,CAAC4B,iBAAiB,KAAK,KAAK,EAAE;IAC3C,OAAO,IAAAC,0BAAoB,EAACZ,UAAU,EAAEjB,WAAW,EAAEW,OAAO,CAAC;EAC/D;EACA;EACA;EACAZ,MAAM,GAAGsB,UAAU,CAAC0B,qBAAqB,EAAE;EAC3CpC,OAAO,GAAG;IAAE,GAAGA,OAAO;IAAEwB,IAAI,EAAE1B;EAAU,CAAC,CAAC,CAAC;;EAE3C;EACA;EACA,IAAIE,OAAO,CAACqC,oBAAoB,IAAI,CAAChD,WAAW,CAACmB,eAAe,IAAI,CAAC,IAAAe,wBAAkB,EAAClC,WAAW,CAAC,EAAE;IACpG;IACA,MAAMiD,EAAE,GAAG,IAAA3B,mBAAa,EAACtB,WAAW,EAAED,MAAM,EAAEY,OAAO,CAAE;IACvD,MAAM+B,QAAQ,GAAG,IAAAC,iBAAW,EAAC1B,UAAU,EAAEgC,EAAE,EAAEjD,WAAW,CAAC;IACzD,OAAO;MACLA,WAAW;MACX0C;IACF,CAAC;EACH;EAEA,OAAO1B,SAAS,CAACC,UAAU,EAAEjB,WAAW,EAAED,MAAM,EAAEY,OAAO,CAAC,CAAC,CAAC;AAE9D"}
@@ -66,7 +66,7 @@ class Remediator {
66
66
 
67
67
  // Override this method to provide custom check
68
68
  /* eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars */
69
- canRemediate() {
69
+ canRemediate(context) {
70
70
  const required = (0, _util.getRequiredValues)(this.remediation);
71
71
  const needed = required.find(key => !this.hasData(key));
72
72
  if (needed) {
@@ -1 +1 @@
1
- {"version":3,"file":"Remediator.js","names":["Remediator","constructor","remediation","values","options","formatAuthenticators","authenticators","map","authenticator","formatAuthenticator","hasAuthenticatorInList","some","existing","compareAuthenticators","push","authenticatorsData","reduce","acc","Object","keys","length","getName","name","canRemediate","required","getRequiredValues","needed","find","key","hasData","getData","allValues","getAllValues","res","data","titleCase","val","value","entry","i","getNextStep","_authClient","_context","inputs","getInputs","getAuthenticator","type","inputsFromRemediation","forEach","inputFromRemediation","input","visible","messages","alias","aliases","includes","Array","isArray","getMessages","form","field","getValuesAfterProceed","inputsFromRemediator","relatesTo","authenticatorFromRemediation","getAuthenticatorFromRemediation","id","enrollmentId"],"sources":["../../../../../lib/idx/remediators/Base/Remediator.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\n/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n\n/* eslint-disable complexity */\nimport { OktaAuthIdxInterface, NextStep, IdxMessage, Authenticator, Input, RemediateOptions } from '../../types';\nimport { IdxAuthenticator, IdxRemediation, IdxContext } from '../../types/idx-js';\nimport { getAllValues, getRequiredValues, titleCase, getAuthenticatorFromRemediation } from '../util';\nimport { formatAuthenticator, compareAuthenticators } from '../../authenticator/util';\n\n// A map from IDX data values (server spec) to RemediationValues (client spec)\nexport type IdxToRemediationValueMap = Record<string, string[]>;\n\nexport interface RemediationValues {\n stateHandle?: string;\n authenticators?: (Authenticator | string)[];\n authenticator?: string | Authenticator;\n authenticatorsData?: Authenticator[];\n resend?: boolean;\n}\n\nexport interface RemediatorConstructor {\n new<T extends RemediationValues>(\n remediation: IdxRemediation, \n values?: T, \n options?: RemediateOptions\n ): any;\n}\n\n// Base class - DO NOT expose static remediationName\nexport class Remediator<T extends RemediationValues = RemediationValues> {\n static remediationName: string;\n\n remediation: IdxRemediation;\n values: T;\n options: RemediateOptions;\n map?: IdxToRemediationValueMap;\n\n constructor(\n remediation: IdxRemediation, \n values: T = {} as T, \n options: RemediateOptions = {}\n ) {\n // assign fields to the instance\n this.values = { ...values };\n this.options = { ...options };\n this.formatAuthenticators();\n this.remediation = remediation;\n }\n\n private formatAuthenticators() {\n this.values.authenticators = (this.values.authenticators || []) as Authenticator[];\n\n // ensure authenticators are in the correct format\n this.values.authenticators = this.values.authenticators.map(authenticator => {\n return formatAuthenticator(authenticator);\n });\n\n // add authenticator (if any) to \"authenticators\"\n if (this.values.authenticator) {\n const authenticator = formatAuthenticator(this.values.authenticator);\n const hasAuthenticatorInList = this.values.authenticators.some(existing => {\n return compareAuthenticators(authenticator, existing);\n });\n if (!hasAuthenticatorInList) {\n this.values.authenticators.push(authenticator);\n }\n }\n\n // save non-key meta to \"authenticatorsData\" field\n // authenticators will be removed after selection to avoid select-authenticator loop\n this.values.authenticatorsData = this.values.authenticators.reduce((acc, authenticator) => {\n if (typeof authenticator === 'object' && Object.keys(authenticator).length > 1) {\n // save authenticator meta into authenticator data\n acc.push(authenticator);\n }\n return acc;\n }, this.values.authenticatorsData || []);\n }\n\n getName(): string {\n return this.remediation.name;\n }\n\n // Override this method to provide custom check\n /* eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars */\n canRemediate(): boolean {\n const required = getRequiredValues(this.remediation);\n const needed = required!.find((key) => !this.hasData(key));\n if (needed) {\n return false; // missing data for a required field\n }\n return true; // all required fields have available data\n }\n\n // returns an object for the entire remediation form, or just a part\n getData(key?: string) {\n if (!key) {\n let allValues = getAllValues(this.remediation);\n let res = allValues!.reduce((data, key) => {\n data[key] = this.getData(key); // recursive\n return data;\n }, {});\n return res;\n }\n\n // Map value by \"map${Property}\" function in each subClass\n if (typeof this[`map${titleCase(key)}`] === 'function') {\n const val = this[`map${titleCase(key)}`](\n this.remediation.value!.find(({name}) => name === key)\n );\n if (val) {\n return val;\n }\n }\n\n // If a map is defined for this key, return the first aliased property that returns a truthy value\n if (this.map && this.map[key]) {\n const entry = this.map[key];\n for (let i = 0; i < entry.length; i++) {\n let val = this.values[entry[i]];\n if (val) {\n return val;\n }\n }\n }\n\n // fallback: return the value by key\n return this.values[key];\n }\n\n hasData(\n key: string // idx name\n ): boolean \n {\n // no attempt to format, we want simple true/false\n return !!this.getData(key);\n }\n\n getNextStep(_authClient: OktaAuthIdxInterface, _context?: IdxContext): NextStep {\n const name = this.getName();\n const inputs = this.getInputs();\n const authenticator = this.getAuthenticator();\n // TODO: remove type field in the next major version change\n // https://oktainc.atlassian.net/browse/OKTA-431749\n const type = authenticator?.type;\n return { \n name, \n inputs, \n ...(type && { type }),\n ...(authenticator && { authenticator }),\n };\n }\n\n // Get inputs for the next step\n getInputs(): Input[] {\n const inputs: Input[] = [];\n const inputsFromRemediation = this.remediation.value || [];\n inputsFromRemediation.forEach(inputFromRemediation => {\n let input;\n let { name, type, visible, messages } = inputFromRemediation;\n if (visible === false) {\n return; // Filter out invisible inputs, like stateHandle\n }\n if (typeof this[`getInput${titleCase(name)}`] === 'function') {\n input = this[`getInput${titleCase(name)}`](inputFromRemediation);\n } else if (type !== 'object') {\n // handle general primitive types\n let alias;\n const aliases = (this.map ? this.map[name] : null) || [];\n if (aliases.length === 1) {\n alias = aliases[0];\n } else {\n // try find key from values\n alias = aliases.find(name => Object.keys(this.values).includes(name));\n }\n if (alias) {\n input = { ...inputFromRemediation, name: alias };\n }\n }\n if (!input) {\n input = inputFromRemediation;\n }\n if (Array.isArray(input)) {\n input.forEach(i => inputs.push(i));\n } else {\n // guarantees field-level messages are passed back\n if (messages) {\n input.messages = messages;\n }\n inputs.push(input);\n }\n });\n return inputs;\n }\n\n static getMessages(remediation: IdxRemediation): IdxMessage[] | undefined {\n if (!remediation.value) {\n return;\n }\n return remediation.value[0]?.form?.value.reduce((messages: IdxMessage[], field) => {\n if (field.messages) {\n messages = [...messages, ...field.messages.value];\n }\n return messages;\n }, []);\n }\n\n // Prepare values for the next remediation\n // In general, remove used values from inputs for the current remediation\n // Override this method if special cases need be handled\n getValuesAfterProceed(): T {\n const inputsFromRemediation = this.remediation.value || []; // \"raw\" inputs from server response\n const inputsFromRemediator = this.getInputs(); // \"aliased\" inputs from SDK remediator\n const inputs = [\n ...inputsFromRemediation,\n ...inputsFromRemediator\n ];\n // scrub all values related to this remediation\n for (const input of inputs) {\n delete this.values[input.name];\n }\n return this.values;\n }\n\n protected getAuthenticator(): IdxAuthenticator | undefined {\n // relatesTo value may be an authenticator or an authenticatorEnrollment\n const relatesTo = this.remediation.relatesTo?.value;\n if (!relatesTo) {\n return;\n }\n\n const authenticatorFromRemediation = getAuthenticatorFromRemediation(this.remediation);\n if (!authenticatorFromRemediation) {\n // Hopefully value is an authenticator\n return relatesTo;\n }\n\n // If relatesTo is an authenticatorEnrollment, the id is actually the enrollmentId\n // Let's get the correct authenticator id from the form value\n const id = authenticatorFromRemediation.form!.value\n .find(({ name }) => name === 'id')!.value as string;\n const enrollmentId = authenticatorFromRemediation.form!.value\n .find(({ name }) => name === 'enrollmentId')?.value as string;\n\n return {\n ...relatesTo,\n id,\n enrollmentId\n };\n }\n}\n"],"mappings":";;;AAiBA;AACA;AAlBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;;AAyBA;AACO,MAAMA,UAAU,CAAkD;EAQvEC,WAAW,CACTC,WAA2B,EAC3BC,MAAS,GAAG,CAAC,CAAM,EACnBC,OAAyB,GAAG,CAAC,CAAC,EAC9B;IACA;IACA,IAAI,CAACD,MAAM,GAAG;MAAE,GAAGA;IAAO,CAAC;IAC3B,IAAI,CAACC,OAAO,G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;IAAK,CAAC,KAAKA,IAAI,KAAK,IAAI,CAAC,CAAEe,KAAe;IACrD,MAAM8B,YAAY,kBAAGH,4BAA4B,CAACL,IAAI,CAAEtB,KAAK,CAC1DV,IAAI,CAAC,CAAC;MAAEL;IAAK,CAAC,KAAKA,IAAI,KAAK,cAAc,CAAC,gDADzB,YAC2Be,KAAe;IAE/D,OAAO;MACL,GAAG0B,SAAS;MACZG,EAAE;MACFC;IACF,CAAC;EACH;AACF;AAAC"}
1
+ {"version":3,"file":"Remediator.js","names":["Remediator","constructor","remediation","values","options","formatAuthenticators","authenticators","map","authenticator","formatAuthenticator","hasAuthenticatorInList","some","existing","compareAuthenticators","push","authenticatorsData","reduce","acc","Object","keys","length","getName","name","canRemediate","context","required","getRequiredValues","needed","find","key","hasData","getData","allValues","getAllValues","res","data","titleCase","val","value","entry","i","getNextStep","_authClient","_context","inputs","getInputs","getAuthenticator","type","inputsFromRemediation","forEach","inputFromRemediation","input","visible","messages","alias","aliases","includes","Array","isArray","getMessages","form","field","getValuesAfterProceed","inputsFromRemediator","relatesTo","authenticatorFromRemediation","getAuthenticatorFromRemediation","id","enrollmentId"],"sources":["../../../../../lib/idx/remediators/Base/Remediator.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\n/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n\n/* eslint-disable complexity */\nimport { OktaAuthIdxInterface, NextStep, IdxMessage, Authenticator, Input, RemediateOptions } from '../../types';\nimport { IdxAuthenticator, IdxRemediation, IdxContext } from '../../types/idx-js';\nimport { getAllValues, getRequiredValues, titleCase, getAuthenticatorFromRemediation } from '../util';\nimport { formatAuthenticator, compareAuthenticators } from '../../authenticator/util';\n\n// A map from IDX data values (server spec) to RemediationValues (client spec)\nexport type IdxToRemediationValueMap = Record<string, string[]>;\n\nexport interface RemediationValues {\n stateHandle?: string;\n authenticators?: (Authenticator | string)[];\n authenticator?: string | Authenticator;\n authenticatorsData?: Authenticator[];\n resend?: boolean;\n}\n\nexport interface RemediatorConstructor {\n new<T extends RemediationValues>(\n remediation: IdxRemediation, \n values?: T, \n options?: RemediateOptions\n ): any;\n}\n\n// Base class - DO NOT expose static remediationName\nexport class Remediator<T extends RemediationValues = RemediationValues> {\n static remediationName: string;\n\n remediation: IdxRemediation;\n values: T;\n options: RemediateOptions;\n map?: IdxToRemediationValueMap;\n\n constructor(\n remediation: IdxRemediation, \n values: T = {} as T, \n options: RemediateOptions = {}\n ) {\n // assign fields to the instance\n this.values = { ...values };\n this.options = { ...options };\n this.formatAuthenticators();\n this.remediation = remediation;\n }\n\n private formatAuthenticators() {\n this.values.authenticators = (this.values.authenticators || []) as Authenticator[];\n\n // ensure authenticators are in the correct format\n this.values.authenticators = this.values.authenticators.map(authenticator => {\n return formatAuthenticator(authenticator);\n });\n\n // add authenticator (if any) to \"authenticators\"\n if (this.values.authenticator) {\n const authenticator = formatAuthenticator(this.values.authenticator);\n const hasAuthenticatorInList = this.values.authenticators.some(existing => {\n return compareAuthenticators(authenticator, existing);\n });\n if (!hasAuthenticatorInList) {\n this.values.authenticators.push(authenticator);\n }\n }\n\n // save non-key meta to \"authenticatorsData\" field\n // authenticators will be removed after selection to avoid select-authenticator loop\n this.values.authenticatorsData = this.values.authenticators.reduce((acc, authenticator) => {\n if (typeof authenticator === 'object' && Object.keys(authenticator).length > 1) {\n // save authenticator meta into authenticator data\n acc.push(authenticator);\n }\n return acc;\n }, this.values.authenticatorsData || []);\n }\n\n getName(): string {\n return this.remediation.name;\n }\n\n // Override this method to provide custom check\n /* eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars */\n canRemediate(context?: IdxContext): boolean {\n const required = getRequiredValues(this.remediation);\n const needed = required!.find((key) => !this.hasData(key));\n if (needed) {\n return false; // missing data for a required field\n }\n return true; // all required fields have available data\n }\n\n // returns an object for the entire remediation form, or just a part\n getData(key?: string) {\n if (!key) {\n let allValues = getAllValues(this.remediation);\n let res = allValues!.reduce((data, key) => {\n data[key] = this.getData(key); // recursive\n return data;\n }, {});\n return res;\n }\n\n // Map value by \"map${Property}\" function in each subClass\n if (typeof this[`map${titleCase(key)}`] === 'function') {\n const val = this[`map${titleCase(key)}`](\n this.remediation.value!.find(({name}) => name === key)\n );\n if (val) {\n return val;\n }\n }\n\n // If a map is defined for this key, return the first aliased property that returns a truthy value\n if (this.map && this.map[key]) {\n const entry = this.map[key];\n for (let i = 0; i < entry.length; i++) {\n let val = this.values[entry[i]];\n if (val) {\n return val;\n }\n }\n }\n\n // fallback: return the value by key\n return this.values[key];\n }\n\n hasData(\n key: string // idx name\n ): boolean \n {\n // no attempt to format, we want simple true/false\n return !!this.getData(key);\n }\n\n getNextStep(_authClient: OktaAuthIdxInterface, _context?: IdxContext): NextStep {\n const name = this.getName();\n const inputs = this.getInputs();\n const authenticator = this.getAuthenticator();\n // TODO: remove type field in the next major version change\n // https://oktainc.atlassian.net/browse/OKTA-431749\n const type = authenticator?.type;\n return { \n name, \n inputs, \n ...(type && { type }),\n ...(authenticator && { authenticator }),\n };\n }\n\n // Get inputs for the next step\n getInputs(): Input[] {\n const inputs: Input[] = [];\n const inputsFromRemediation = this.remediation.value || [];\n inputsFromRemediation.forEach(inputFromRemediation => {\n let input;\n let { name, type, visible, messages } = inputFromRemediation;\n if (visible === false) {\n return; // Filter out invisible inputs, like stateHandle\n }\n if (typeof this[`getInput${titleCase(name)}`] === 'function') {\n input = this[`getInput${titleCase(name)}`](inputFromRemediation);\n } else if (type !== 'object') {\n // handle general primitive types\n let alias;\n const aliases = (this.map ? this.map[name] : null) || [];\n if (aliases.length === 1) {\n alias = aliases[0];\n } else {\n // try find key from values\n alias = aliases.find(name => Object.keys(this.values).includes(name));\n }\n if (alias) {\n input = { ...inputFromRemediation, name: alias };\n }\n }\n if (!input) {\n input = inputFromRemediation;\n }\n if (Array.isArray(input)) {\n input.forEach(i => inputs.push(i));\n } else {\n // guarantees field-level messages are passed back\n if (messages) {\n input.messages = messages;\n }\n inputs.push(input);\n }\n });\n return inputs;\n }\n\n static getMessages(remediation: IdxRemediation): IdxMessage[] | undefined {\n if (!remediation.value) {\n return;\n }\n return remediation.value[0]?.form?.value.reduce((messages: IdxMessage[], field) => {\n if (field.messages) {\n messages = [...messages, ...field.messages.value];\n }\n return messages;\n }, []);\n }\n\n // Prepare values for the next remediation\n // In general, remove used values from inputs for the current remediation\n // Override this method if special cases need be handled\n getValuesAfterProceed(): T {\n const inputsFromRemediation = this.remediation.value || []; // \"raw\" inputs from server response\n const inputsFromRemediator = this.getInputs(); // \"aliased\" inputs from SDK remediator\n const inputs = [\n ...inputsFromRemediation,\n ...inputsFromRemediator\n ];\n // scrub all values related to this remediation\n for (const input of inputs) {\n delete this.values[input.name];\n }\n return this.values;\n }\n\n protected getAuthenticator(): IdxAuthenticator | undefined {\n // relatesTo value may be an authenticator or an authenticatorEnrollment\n const relatesTo = this.remediation.relatesTo?.value;\n if (!relatesTo) {\n return;\n }\n\n const authenticatorFromRemediation = getAuthenticatorFromRemediation(this.remediation);\n if (!authenticatorFromRemediation) {\n // Hopefully value is an authenticator\n return relatesTo;\n }\n\n // If relatesTo is an authenticatorEnrollment, the id is actually the enrollmentId\n // Let's get the correct authenticator id from the form value\n const id = authenticatorFromRemediation.form!.value\n .find(({ name }) => name === 'id')!.value as string;\n const enrollmentId = authenticatorFromRemediation.form!.value\n .find(({ name }) => name === 'enrollmentId')?.value as string;\n\n return {\n ...relatesTo,\n id,\n enrollmentId\n };\n }\n}\n"],"mappings":";;;AAiBA;AACA;AAlBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,EAAE;MACd;IACF;IAEA,MAAMC,4BAA4B,GAAG,IAAAC,qCAA+B,EAAC,IAAI,CAAChE,WAAW,CAAC;IACtF,IAAI,CAAC+D,4BAA4B,EAAE;MACjC;MACA,OAAOD,SAAS;IAClB;;IAEA;IACA;IACA,MAAMG,EAAE,GAAGF,4BAA4B,CAACL,IAAI,CAAEtB,KAAK,CAChDV,IAAI,CAAC,CAAC;MAAEN;IAAK,CAAC,KAAKA,IAAI,KAAK,IAAI,CAAC,CAAEgB,KAAe;IACrD,MAAM8B,YAAY,kBAAGH,4BAA4B,CAACL,IAAI,CAAEtB,KAAK,CAC1DV,IAAI,CAAC,CAAC;MAAEN;IAAK,CAAC,KAAKA,IAAI,KAAK,cAAc,CAAC,gDADzB,YAC2BgB,KAAe;IAE/D,OAAO;MACL,GAAG0B,SAAS;MACZG,EAAE;MACFC;IACF,CAAC;EACH;AACF;AAAC"}
@@ -33,7 +33,9 @@ class SelectAuthenticator extends _Remediator.Remediator {
33
33
  }
34
34
  return option;
35
35
  }
36
- canRemediate() {
36
+
37
+ /* eslint complexity:[0,9] */
38
+ canRemediate(context) {
37
39
  const {
38
40
  authenticators,
39
41
  authenticator
@@ -55,7 +57,11 @@ class SelectAuthenticator extends _Remediator.Remediator {
55
57
  // Proceed with provided authenticators
56
58
  const matchedOption = this.findMatchedOption(authenticators, options);
57
59
  if (matchedOption) {
58
- return true;
60
+ var _matchedOption$relate, _matchedOption$relate2;
61
+ // Don't select current authenticator (OKTA-612939)
62
+ const isCurrentAuthenticator = (context === null || context === void 0 ? void 0 : context.currentAuthenticator) && (context === null || context === void 0 ? void 0 : context.currentAuthenticator.value.id) === ((_matchedOption$relate = matchedOption.relatesTo) === null || _matchedOption$relate === void 0 ? void 0 : _matchedOption$relate.id);
63
+ const isCurrentAuthenticatorEnrollment = (context === null || context === void 0 ? void 0 : context.currentAuthenticatorEnrollment) && (context === null || context === void 0 ? void 0 : context.currentAuthenticatorEnrollment.value.id) === ((_matchedOption$relate2 = matchedOption.relatesTo) === null || _matchedOption$relate2 === void 0 ? void 0 : _matchedOption$relate2.id);
64
+ return !isCurrentAuthenticator && !isCurrentAuthenticatorEnrollment;
59
65
  }
60
66
  return false;
61
67
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SelectAuthenticator.js","names":["SelectAuthenticator","Remediator","findMatchedOption","authenticators","options","option","authenticator","find","relatesTo","key","canRemediate","values","authenticatorFromRemediation","getAuthenticatorFromRemediation","remediation","length","isAuthenticator","id","matchedOption","mapAuthenticator","remediationValue","selectedAuthenticator","selectedOption","value","form","name","getInputAuthenticator","map","label","type","getValuesAfterProceed","filter","compareAuthenticators"],"sources":["../../../../../lib/idx/remediators/Base/SelectAuthenticator.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\n/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n\nimport { Remediator, RemediationValues } from './Remediator';\nimport { getAuthenticatorFromRemediation } from '../util';\nimport { IdxRemediationValue } from '../../types/idx-js';\nimport { Authenticator, isAuthenticator } from '../../types/api';\nimport { compareAuthenticators, findMatchedOption} from '../../authenticator/util';\n\nexport type SelectAuthenticatorValues = RemediationValues & {\n authenticator?: string | Authenticator;\n};\n\n// Base class - DO NOT expose static remediationName\nexport class SelectAuthenticator<T extends SelectAuthenticatorValues = SelectAuthenticatorValues>\n extends Remediator<T> {\n selectedAuthenticator?: Authenticator;\n selectedOption?: any;\n\n // Find matched authenticator in provided order\n findMatchedOption(authenticators, options) {\n let option;\n for (let authenticator of authenticators) {\n option = options\n .find(({ relatesTo }) => relatesTo.key === authenticator.key);\n if (option) {\n break;\n }\n }\n return option;\n }\n\n canRemediate() {\n const { authenticators, authenticator } = this.values;\n const authenticatorFromRemediation = getAuthenticatorFromRemediation(this.remediation);\n const { options } = authenticatorFromRemediation;\n // Let users select authenticator if no input is provided\n if (!authenticators || !authenticators.length) {\n return false;\n }\n\n // Authenticator is explicitly specified by id\n if (isAuthenticator(authenticator) && authenticator.id) {\n return true;\n }\n\n // Proceed with provided authenticators\n const matchedOption = this.findMatchedOption(authenticators, options);\n if (matchedOption) {\n return true;\n }\n \n return false;\n }\n\n mapAuthenticator(remediationValue: IdxRemediationValue) {\n const { authenticators, authenticator } = this.values;\n\n // Authenticator is explicitly specified by id\n if (isAuthenticator(authenticator) && authenticator.id) {\n this.selectedAuthenticator = authenticator; // track the selected authenticator\n return authenticator;\n }\n\n const { options } = remediationValue;\n const selectedOption = findMatchedOption(authenticators, options);\n this.selectedAuthenticator = selectedOption.relatesTo; // track the selected authenticator\n this.selectedOption = selectedOption;\n return {\n id: selectedOption?.value.form.value.find(({ name }) => name === 'id').value\n };\n }\n\n getInputAuthenticator(remediation) {\n const options = remediation.options.map(({ label, relatesTo }) => {\n return {\n label,\n value: relatesTo.key\n };\n });\n return { name: 'authenticator', type: 'string', options };\n }\n\n getValuesAfterProceed(): T {\n this.values = super.getValuesAfterProceed();\n // remove used authenticators\n const authenticators = (this.values.authenticators as Authenticator[])\n .filter(authenticator => {\n return compareAuthenticators(authenticator, this.selectedAuthenticator) !== true;\n });\n return { ...this.values, authenticators };\n }\n\n}\n"],"mappings":";;;AAcA;AACA;AAEA;AACA;AAlBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA;AACO,MAAMA,mBAAmB,SACtBC,sBAAU,CAAI;EAItB;EACAC,iBAAiB,CAACC,cAAc,EAAEC,OAAO,EAAE;IACzC,IAAIC,MAAM;IACV,KAAK,IAAIC,aAAa,IAAIH,cAAc,EAAE;MACxCE,MAAM,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AAO;MACLL,EAAE,EAAEK,cAAc,aAAdA,cAAc,uBAAdA,cAAc,CAAEC,KAAK,CAACC,IAAI,CAACD,KAAK,CAAChB,IAAI,CAAC,CAAC;QAAEkB;MAAK,CAAC,KAAKA,IAAI,KAAK,IAAI,CAAC,CAACF;IACzE,CAAC;EACH;EAEAG,qBAAqB,CAACZ,WAAW,EAAE;IACjC,MAAMV,OAAO,GAAGU,WAAW,CAACV,OAAO,CAACuB,GAAG,CAAC,CAAC;MAAEC,KAAK;MAAEpB;IAAU,CAAC,KAAK;MAChE,OAAO;QACLoB,KAAK;QACLL,KAAK,EAAEf,SAAS,CAACC;MACnB,CAAC;IACH,CAAC,CAAC;IACF,OAAO;MAAEgB,IAAI,EAAE,eAAe;MAAEI,IAAI,EAAE,QAAQ;MAAEzB;IAAQ,CAAC;EAC3D;EAEA0B,qBAAqB,GAAM;IACzB,IAAI,CAACnB,MAAM,GAAG,KAAK,CAACmB,qBAAqB,EAAE;IAC3C;IACA,MAAM3B,cAAc,GAAI,IAAI,CAACQ,MAAM,CAACR,cAAc,CAC/C4B,MAAM,CAACzB,aAAa,IAAI;MACvB,OAAO,IAAA0B,4BAAqB,EAAC1B,aAAa,EAAE,IAAI,CAACe,qBAAqB,CAAC,KAAK,IAAI;IAClF,CAAC,CAAC;IACJ,OAAO;MAAE,GAAG,IAAI,CAACV,MAAM;MAAER;IAAe,CAAC;EAC3C;AAEF;AAAC"}
1
+ {"version":3,"file":"SelectAuthenticator.js","names":["SelectAuthenticator","Remediator","findMatchedOption","authenticators","options","option","authenticator","find","relatesTo","key","canRemediate","context","values","authenticatorFromRemediation","getAuthenticatorFromRemediation","remediation","length","isAuthenticator","id","matchedOption","isCurrentAuthenticator","currentAuthenticator","value","isCurrentAuthenticatorEnrollment","currentAuthenticatorEnrollment","mapAuthenticator","remediationValue","selectedAuthenticator","selectedOption","form","name","getInputAuthenticator","map","label","type","getValuesAfterProceed","filter","compareAuthenticators"],"sources":["../../../../../lib/idx/remediators/Base/SelectAuthenticator.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\n/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n\nimport { Remediator, RemediationValues } from './Remediator';\nimport { getAuthenticatorFromRemediation } from '../util';\nimport { IdxRemediationValue, IdxContext, IdxOption } from '../../types/idx-js';\nimport { Authenticator, isAuthenticator } from '../../types/api';\nimport { compareAuthenticators, findMatchedOption} from '../../authenticator/util';\n\nexport type SelectAuthenticatorValues = RemediationValues & {\n authenticator?: string | Authenticator;\n};\n\n// Base class - DO NOT expose static remediationName\nexport class SelectAuthenticator<T extends SelectAuthenticatorValues = SelectAuthenticatorValues>\n extends Remediator<T> {\n selectedAuthenticator?: Authenticator;\n selectedOption?: any;\n\n // Find matched authenticator in provided order\n findMatchedOption(authenticators, options) {\n let option: IdxOption | undefined;\n for (let authenticator of authenticators) {\n option = options\n .find(({ relatesTo }) => relatesTo.key === authenticator.key);\n if (option) {\n break;\n }\n }\n return option;\n }\n\n /* eslint complexity:[0,9] */\n canRemediate(context?: IdxContext) {\n const { authenticators, authenticator } = this.values;\n const authenticatorFromRemediation = getAuthenticatorFromRemediation(this.remediation);\n const { options } = authenticatorFromRemediation;\n // Let users select authenticator if no input is provided\n if (!authenticators || !authenticators.length) {\n return false;\n }\n\n // Authenticator is explicitly specified by id\n if (isAuthenticator(authenticator) && authenticator.id) {\n return true;\n }\n\n // Proceed with provided authenticators\n const matchedOption = this.findMatchedOption(authenticators, options!);\n if (matchedOption) {\n // Don't select current authenticator (OKTA-612939)\n const isCurrentAuthenticator = context?.currentAuthenticator\n && context?.currentAuthenticator.value.id === matchedOption.relatesTo?.id;\n const isCurrentAuthenticatorEnrollment = context?.currentAuthenticatorEnrollment\n && context?.currentAuthenticatorEnrollment.value.id === matchedOption.relatesTo?.id;\n return !isCurrentAuthenticator && !isCurrentAuthenticatorEnrollment;\n }\n \n return false;\n }\n\n mapAuthenticator(remediationValue: IdxRemediationValue) {\n const { authenticators, authenticator } = this.values;\n\n // Authenticator is explicitly specified by id\n if (isAuthenticator(authenticator) && authenticator.id) {\n this.selectedAuthenticator = authenticator; // track the selected authenticator\n return authenticator;\n }\n\n const { options } = remediationValue;\n const selectedOption = findMatchedOption(authenticators, options);\n this.selectedAuthenticator = selectedOption.relatesTo; // track the selected authenticator\n this.selectedOption = selectedOption;\n return {\n id: selectedOption?.value.form.value.find(({ name }) => name === 'id').value\n };\n }\n\n getInputAuthenticator(remediation) {\n const options = remediation.options.map(({ label, relatesTo }) => {\n return {\n label,\n value: relatesTo.key\n };\n });\n return { name: 'authenticator', type: 'string', options };\n }\n\n getValuesAfterProceed(): T {\n this.values = super.getValuesAfterProceed();\n // remove used authenticators\n const authenticators = (this.values.authenticators as Authenticator[])\n .filter(authenticator => {\n return compareAuthenticators(authenticator, this.selectedAuthenticator) !== true;\n });\n return { ...this.values, authenticators };\n }\n\n}\n"],"mappings":";;;AAcA;AACA;AAEA;AACA;AAlBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA;AACO,MAAMA,mBAAmB,SACtBC,sBAAU,CAAI;EAItB;EACAC,iBAAiB,CAACC,cAAc,EAAEC,OAAO,EAAE;IACzC,IAAIC,MAA6B;IACjC,KAAK,IAAIC,aAAa,IAAIH,cAAc,EAAE;MACxCE,MAAM,GAAGD,OAAO,CACbG,IAAI,CAAC,CAAC;QAAEC;MAAU,CAAC,KAAKA,SAAS,CAACC,GAAG,KAAKH,aAAa,CAACG,GAAG,CAAC;MAC/D,IAAIJ,MAAM,EAAE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CAAC;EAC3C;AAEF;AAAC"}
package/cjs/idx/util.js CHANGED
@@ -225,10 +225,14 @@ function getRemediatorClass(remediation, options) {
225
225
 
226
226
  // Return first match idxRemediation in allowed remediators
227
227
  // eslint-disable-next-line complexity
228
- function getRemediator(idxRemediations, values, options) {
228
+ function getRemediator(idxResponse, values, options) {
229
229
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
230
230
  const remediators = options.remediators;
231
231
  const useGenericRemediator = options.useGenericRemediator;
232
+ const {
233
+ neededToProceed: idxRemediations,
234
+ context
235
+ } = idxResponse;
232
236
  let remediator;
233
237
  // remediation name specified by caller - fast-track remediator lookup
234
238
  if (options.step) {
@@ -259,7 +263,7 @@ function getRemediator(idxRemediations, values, options) {
259
263
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
260
264
  const T = getRemediatorClass(remediation, options);
261
265
  remediator = new T(remediation, values, options);
262
- if (remediator.canRemediate()) {
266
+ if (remediator.canRemediate(context)) {
263
267
  // found the remediator
264
268
  return remediator;
265
269
  }
@@ -294,7 +298,7 @@ function handleFailedResponse(authClient, idxResponse, options = {}) {
294
298
  messages
295
299
  };
296
300
  } else {
297
- const remediator = getRemediator(idxResponse.neededToProceed, {}, options);
301
+ const remediator = getRemediator(idxResponse, {}, options);
298
302
  const nextStep = remediator && getNextStep(authClient, remediator, idxResponse);
299
303
  return {
300
304
  idxResponse,
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","names":["isTerminalResponse","idxResponse","neededToProceed","interactionCode","length","canSkipFn","some","name","canResendFn","Object","keys","actions","actionName","includes","getMessagesFromIdxRemediationValue","value","Array","isArray","reduce","messages","form","messagesFromForm","options","optionValues","forEach","option","messagesFromOptions","getMessagesFromResponse","rawIdxState","globalMessages","map","message","useGenericRemediator","remediation","fieldMessages","seen","filtered","key","i18n","getEnabledFeatures","res","push","IdxFeature","PASSWORD_RECOVERY","REGISTRATION","SOCIAL_IDP","ACCOUNT_UNLOCK","getAvailableSteps","authClient","remediatorMap","values","remediators","remediatorClass","remediationName","T","getRemediatorClass","remediator","getNextStep","context","entries","stepObj","action","params","idx","proceed","startsWith","part1","part2","split2","actionObj","href","method","rel","accepts","produces","rest","filter","item","filterValuesForRemediation","remediations","find","r","warn","valuesForRemediation","entry","undefined","GenericRemediator","getRemediator","idxRemediations","step","remediatorCandidates","isRemeditionInFlow","canRemediate","nextStep","canSkip","canResend","handleFailedResponse","terminal"],"sources":["../../../lib/idx/util.ts"],"sourcesContent":["import { warn, split2 } from '../util';\nimport * as remediators from './remediators';\nimport { RemediationValues, Remediator, RemediatorConstructor } from './remediators';\nimport { GenericRemediator } from './remediators/GenericRemediator';\nimport { OktaAuthIdxInterface, IdxFeature, NextStep, RemediateOptions, RemediationResponse, RunOptions } from './types';\nimport { IdxMessage, IdxRemediation, IdxRemediationValue, IdxResponse } from './types/idx-js';\n\nexport function isTerminalResponse(idxResponse: IdxResponse) {\n const { neededToProceed, interactionCode } = idxResponse;\n return !neededToProceed.length && !interactionCode;\n}\n\nexport function canSkipFn(idxResponse: IdxResponse) {\n return idxResponse.neededToProceed.some(({ name }) => name === 'skip');\n}\n\nexport function canResendFn(idxResponse: IdxResponse) {\n return Object.keys(idxResponse.actions).some(actionName => actionName.includes('resend'));\n}\n\nexport function getMessagesFromIdxRemediationValue(\n value?: IdxRemediationValue[]\n): IdxMessage[] | undefined {\n if (!value || !Array.isArray(value)) {\n return;\n }\n return value.reduce((messages, value) => {\n if (value.messages) {\n messages = [...messages, ...value.messages.value] as never;\n }\n if (value.form) {\n const messagesFromForm = getMessagesFromIdxRemediationValue(value.form.value) || [];\n messages = [...messages, ...messagesFromForm] as never;\n } \n if (value.options) {\n let optionValues = [];\n value.options.forEach(option => {\n if (!option.value || typeof option.value === 'string') {\n return;\n }\n optionValues = [...optionValues, option.value] as never;\n });\n const messagesFromOptions = getMessagesFromIdxRemediationValue(optionValues) || [];\n messages = [...messages, ...messagesFromOptions] as never;\n }\n return messages;\n }, []);\n}\n\nexport function getMessagesFromResponse(idxResponse: IdxResponse, options: RunOptions): IdxMessage[] {\n let messages: IdxMessage[] = [];\n const { rawIdxState, neededToProceed } = idxResponse;\n\n // Handle global messages\n const globalMessages = rawIdxState.messages?.value.map(message => message);\n if (globalMessages) {\n messages = [...messages, ...globalMessages] as never;\n }\n\n // Handle field messages for current flow\n // Preserve existing logic for general cases, remove in the next major version\n // Follow ion response format for top level messages when useGenericRemediator is true\n if (!options.useGenericRemediator) {\n for (let remediation of neededToProceed) {\n const fieldMessages = getMessagesFromIdxRemediationValue(remediation.value);\n if (fieldMessages) {\n messages = [...messages, ...fieldMessages] as never;\n }\n }\n }\n\n // API may return identical error on same field, filter by i18n key\n const seen = {};\n messages = messages.reduce((filtered, message) => {\n const key = message.i18n?.key;\n if (key && seen[key]) {\n return filtered;\n }\n seen[key] = message;\n filtered = [...filtered, message] as never;\n return filtered;\n }, []);\n return messages;\n}\n\n\nexport function getEnabledFeatures(idxResponse: IdxResponse): IdxFeature[] {\n const res = [];\n const { actions, neededToProceed } = idxResponse;\n\n if (actions['currentAuthenticator-recover']) {\n res.push(IdxFeature.PASSWORD_RECOVERY as never);\n }\n\n if (neededToProceed.some(({ name }) => name === 'select-enroll-profile')) {\n res.push(IdxFeature.REGISTRATION as never);\n }\n\n if (neededToProceed.some(({ name }) => name === 'redirect-idp')) {\n res.push(IdxFeature.SOCIAL_IDP as never);\n }\n\n if (neededToProceed.some(({ name }) => name === 'unlock-account')) {\n res.push(IdxFeature.ACCOUNT_UNLOCK as never);\n }\n\n return res;\n}\n\nexport function getAvailableSteps(\n authClient: OktaAuthIdxInterface, \n idxResponse: IdxResponse, \n useGenericRemediator?: boolean\n): NextStep[] {\n const res: NextStep[] = [];\n\n const remediatorMap: Record<string, RemediatorConstructor> = Object.values(remediators)\n .reduce((map, remediatorClass) => {\n // Only add concrete subclasses to the map\n if (remediatorClass.remediationName) {\n map[remediatorClass.remediationName] = remediatorClass;\n }\n return map;\n }, {});\n\n for (let remediation of idxResponse.neededToProceed) {\n const T = getRemediatorClass(remediation, { useGenericRemediator, remediators: remediatorMap });\n if (T) {\n const remediator: Remediator = new T(remediation);\n res.push (remediator.getNextStep(authClient, idxResponse.context) as never);\n }\n }\n\n for (const [name] of Object.entries((idxResponse.actions || {}))) {\n let stepObj = {\n name, \n action: async (params?) => {\n return authClient.idx.proceed({ \n actions: [{ name, params }] \n });\n }\n };\n if (name.startsWith('currentAuthenticator')) {\n const [part1, part2] = split2(name, '-');\n const actionObj = idxResponse.rawIdxState[part1].value[part2];\n /* eslint-disable no-unused-vars, @typescript-eslint/no-unused-vars */\n const {\n href, \n method, \n rel, \n accepts, \n produces, \n ...rest\n } = actionObj;\n /* eslint-enable no-unused-vars, @typescript-eslint/no-unused-vars */\n const value = actionObj.value?.filter(item => item.name !== 'stateHandle');\n stepObj = { \n ...rest, \n ...(value && { value }),\n ...stepObj,\n };\n }\n res.push(stepObj);\n }\n\n return res;\n}\n\nexport function filterValuesForRemediation(\n idxResponse: IdxResponse,\n remediationName: string,\n values: RemediationValues\n): RemediationValues {\n const remediations = idxResponse.neededToProceed || [];\n const remediation = remediations.find(r => r.name === remediationName);\n if (!remediation) {\n // step was specified, but remediation was not found. This is unexpected!\n warn(`filterValuesForRemediation: \"${remediationName}\" did not match any remediations`);\n return values;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const valuesForRemediation = remediation.value!.reduce((res, entry) => {\n const { name, value } = entry;\n if (name === 'stateHandle') {\n res[name] = value; // use the stateHandle value in the remediation\n } else {\n res[name] = values[name]; // use the value provided by the caller\n }\n return res;\n }, {});\n return valuesForRemediation;\n}\n\nfunction getRemediatorClass(remediation: IdxRemediation, options: RemediateOptions) {\n const { useGenericRemediator, remediators } = options;\n \n if (!remediation) {\n return undefined;\n }\n\n if (useGenericRemediator) {\n return GenericRemediator;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return remediators![remediation.name];\n}\n\n// Return first match idxRemediation in allowed remediators\n// eslint-disable-next-line complexity\nexport function getRemediator(\n idxRemediations: IdxRemediation[],\n values: RemediationValues,\n options: RemediateOptions,\n): Remediator | undefined {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const remediators = options.remediators!;\n const useGenericRemediator = options.useGenericRemediator;\n\n let remediator: Remediator;\n // remediation name specified by caller - fast-track remediator lookup \n if (options.step) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const remediation = idxRemediations.find(({ name }) => name === options.step)!;\n if (remediation) {\n const T = getRemediatorClass(remediation, options);\n return T ? new T(remediation, values, options) : undefined;\n } else {\n // step was specified, but remediation was not found. This is unexpected!\n warn(`step \"${options.step}\" did not match any remediations`);\n return;\n }\n }\n\n const remediatorCandidates: Remediator[] = [];\n if (useGenericRemediator) {\n // always pick the first remediation for when use GenericRemediator\n remediatorCandidates.push(new GenericRemediator(idxRemediations[0], values, options));\n } else {\n for (let remediation of idxRemediations) {\n const isRemeditionInFlow = Object.keys(remediators as object).includes(remediation.name);\n if (!isRemeditionInFlow) {\n continue;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const T = getRemediatorClass(remediation, options)!;\n remediator = new T(remediation, values, options);\n if (remediator.canRemediate()) {\n // found the remediator\n return remediator;\n }\n // remediator cannot handle the current values\n // maybe return for next step\n remediatorCandidates.push(remediator); \n }\n }\n \n return remediatorCandidates[0];\n}\n\n\nexport function getNextStep(\n authClient: OktaAuthIdxInterface, remediator: Remediator, idxResponse: IdxResponse\n): NextStep {\n const nextStep = remediator.getNextStep(authClient, idxResponse.context);\n const canSkip = canSkipFn(idxResponse);\n const canResend = canResendFn(idxResponse);\n return {\n ...nextStep,\n ...(canSkip && {canSkip}),\n ...(canResend && {canResend}),\n };\n}\n\nexport function handleFailedResponse(\n authClient: OktaAuthIdxInterface,\n idxResponse: IdxResponse,\n options = {}\n): RemediationResponse {\n const terminal = isTerminalResponse(idxResponse);\n const messages = getMessagesFromResponse(idxResponse, options);\n if (terminal) {\n return { idxResponse, terminal, messages };\n } else {\n const remediator = getRemediator(idxResponse.neededToProceed, {}, options);\n const nextStep = remediator && getNextStep(authClient, remediator, idxResponse);\n return {\n idxResponse,\n messages,\n ...(nextStep && { nextStep }),\n };\n }\n \n}\n"],"mappings":";;;;;;;;;;;;;AAAA;AACA;AAEA;AACA;AAAwH;AAAA;AAGjH,SAASA,kBAAkB,CAACC,WAAwB,EAAE;EAC3D,MAAM;IAAEC,eAAe;IAAEC;EAAgB,CAAC,GAAGF,WAAW;EACxD,OAAO,CAACC,eAAe,CAACE,MAAM,IAAI,CAACD,eAAe;AACpD;AAEO,SAASE,SAAS,CAACJ,WAAwB,EAAE;EAClD,OAAOA,WAAW,CAACC,eAAe,CAACI,IAAI,CAAC,CAAC;IAAEC;EAAK,CAAC,KAAKA,IAAI,KAAK,MAAM,CAAC;AACxE;AAEO,SAASC,WAAW,CAACP,WAAwB,EAAE;EACpD,OAAOQ,MAAM,CAACC,IAAI,CAACT,WAAW,CAACU,OAAO,CAAC,CAACL,IAAI,CAACM,UAAU,IAAIA,UAAU,CAACC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC3F;AAEO,SAASC,kCAAkC,CAChDC,KAA6B,EACH;EAC1B,IAAI,CAACA,KAAK,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE;IACnC;EACF;EACA,OAAOA,KAAK,CAACG,MAAM,CAAC,CAACC,QAAQ,EAAEJ,KAAK,KAAK;IACvC,IAAIA,KAAK,CAACI,QAAQ,EAAE;MAClBA,QAAQ,GAAG,CAAC,GAAGA,QAAQ,EAAE,GAAGJ,KAAK,CAACI,QAAQ,CAACJ,KAAK,CAAU;IAC5D;IACA,IAAIA,KAAK,CAACK,IAAI,EAAE;MACd,MAAMC,gBAAgB,GAAGP,kCAAkC,CAACC,KAAK,CAACK,IAAI,CAACL,KAAK,CAAC,IAAI,EAAE;MACnFI,QAAQ,GAAG,CAAC,GAAGA,QAAQ,EAAE,GAAGE,gBAAgB,CAAU;IACxD;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CAAC1B,WAAW,EAAEqB,OAAO,CAAC;EAC9D,IAAI2E,QAAQ,EAAE;IACZ,OAAO;MAAEhG,WAAW;MAAEgG,QAAQ;MAAE9E;IAAS,CAAC;EAC5C,CAAC,MAAM;IACL,MAAMqC,UAAU,GAAG+B,aAAa,CAACtF,WAAW,CAACC,eAAe,EAAE,CAAC,CAAC,EAAEoB,OAAO,CAAC;IAC1E,MAAMuE,QAAQ,GAAGrC,UAAU,IAAIC,WAAW,CAACT,UAAU,EAAEQ,UAAU,EAAEvD,WAAW,CAAC;IAC/E,OAAO;MACLA,WAAW;MACXkB,QAAQ;MACR,IAAI0E,QAAQ,IAAI;QAAEA;MAAS,CAAC;IAC9B,CAAC;EACH;AAEF"}
1
+ {"version":3,"file":"util.js","names":["isTerminalResponse","idxResponse","neededToProceed","interactionCode","length","canSkipFn","some","name","canResendFn","Object","keys","actions","actionName","includes","getMessagesFromIdxRemediationValue","value","Array","isArray","reduce","messages","form","messagesFromForm","options","optionValues","forEach","option","messagesFromOptions","getMessagesFromResponse","rawIdxState","globalMessages","map","message","useGenericRemediator","remediation","fieldMessages","seen","filtered","key","i18n","getEnabledFeatures","res","push","IdxFeature","PASSWORD_RECOVERY","REGISTRATION","SOCIAL_IDP","ACCOUNT_UNLOCK","getAvailableSteps","authClient","remediatorMap","values","remediators","remediatorClass","remediationName","T","getRemediatorClass","remediator","getNextStep","context","entries","stepObj","action","params","idx","proceed","startsWith","part1","part2","split2","actionObj","href","method","rel","accepts","produces","rest","filter","item","filterValuesForRemediation","remediations","find","r","warn","valuesForRemediation","entry","undefined","GenericRemediator","getRemediator","idxRemediations","step","remediatorCandidates","isRemeditionInFlow","canRemediate","nextStep","canSkip","canResend","handleFailedResponse","terminal"],"sources":["../../../lib/idx/util.ts"],"sourcesContent":["import { warn, split2 } from '../util';\nimport * as remediators from './remediators';\nimport { RemediationValues, Remediator, RemediatorConstructor } from './remediators';\nimport { GenericRemediator } from './remediators/GenericRemediator';\nimport { OktaAuthIdxInterface, IdxFeature, NextStep, RemediateOptions, RemediationResponse, RunOptions } from './types';\nimport { IdxMessage, IdxRemediation, IdxRemediationValue, IdxResponse } from './types/idx-js';\n\nexport function isTerminalResponse(idxResponse: IdxResponse) {\n const { neededToProceed, interactionCode } = idxResponse;\n return !neededToProceed.length && !interactionCode;\n}\n\nexport function canSkipFn(idxResponse: IdxResponse) {\n return idxResponse.neededToProceed.some(({ name }) => name === 'skip');\n}\n\nexport function canResendFn(idxResponse: IdxResponse) {\n return Object.keys(idxResponse.actions).some(actionName => actionName.includes('resend'));\n}\n\nexport function getMessagesFromIdxRemediationValue(\n value?: IdxRemediationValue[]\n): IdxMessage[] | undefined {\n if (!value || !Array.isArray(value)) {\n return;\n }\n return value.reduce((messages, value) => {\n if (value.messages) {\n messages = [...messages, ...value.messages.value] as never;\n }\n if (value.form) {\n const messagesFromForm = getMessagesFromIdxRemediationValue(value.form.value) || [];\n messages = [...messages, ...messagesFromForm] as never;\n } \n if (value.options) {\n let optionValues = [];\n value.options.forEach(option => {\n if (!option.value || typeof option.value === 'string') {\n return;\n }\n optionValues = [...optionValues, option.value] as never;\n });\n const messagesFromOptions = getMessagesFromIdxRemediationValue(optionValues) || [];\n messages = [...messages, ...messagesFromOptions] as never;\n }\n return messages;\n }, []);\n}\n\nexport function getMessagesFromResponse(idxResponse: IdxResponse, options: RunOptions): IdxMessage[] {\n let messages: IdxMessage[] = [];\n const { rawIdxState, neededToProceed } = idxResponse;\n\n // Handle global messages\n const globalMessages = rawIdxState.messages?.value.map(message => message);\n if (globalMessages) {\n messages = [...messages, ...globalMessages] as never;\n }\n\n // Handle field messages for current flow\n // Preserve existing logic for general cases, remove in the next major version\n // Follow ion response format for top level messages when useGenericRemediator is true\n if (!options.useGenericRemediator) {\n for (let remediation of neededToProceed) {\n const fieldMessages = getMessagesFromIdxRemediationValue(remediation.value);\n if (fieldMessages) {\n messages = [...messages, ...fieldMessages] as never;\n }\n }\n }\n\n // API may return identical error on same field, filter by i18n key\n const seen = {};\n messages = messages.reduce((filtered, message) => {\n const key = message.i18n?.key;\n if (key && seen[key]) {\n return filtered;\n }\n seen[key] = message;\n filtered = [...filtered, message] as never;\n return filtered;\n }, []);\n return messages;\n}\n\n\nexport function getEnabledFeatures(idxResponse: IdxResponse): IdxFeature[] {\n const res = [];\n const { actions, neededToProceed } = idxResponse;\n\n if (actions['currentAuthenticator-recover']) {\n res.push(IdxFeature.PASSWORD_RECOVERY as never);\n }\n\n if (neededToProceed.some(({ name }) => name === 'select-enroll-profile')) {\n res.push(IdxFeature.REGISTRATION as never);\n }\n\n if (neededToProceed.some(({ name }) => name === 'redirect-idp')) {\n res.push(IdxFeature.SOCIAL_IDP as never);\n }\n\n if (neededToProceed.some(({ name }) => name === 'unlock-account')) {\n res.push(IdxFeature.ACCOUNT_UNLOCK as never);\n }\n\n return res;\n}\n\nexport function getAvailableSteps(\n authClient: OktaAuthIdxInterface, \n idxResponse: IdxResponse, \n useGenericRemediator?: boolean\n): NextStep[] {\n const res: NextStep[] = [];\n\n const remediatorMap: Record<string, RemediatorConstructor> = Object.values(remediators)\n .reduce((map, remediatorClass) => {\n // Only add concrete subclasses to the map\n if (remediatorClass.remediationName) {\n map[remediatorClass.remediationName] = remediatorClass;\n }\n return map;\n }, {});\n\n for (let remediation of idxResponse.neededToProceed) {\n const T = getRemediatorClass(remediation, { useGenericRemediator, remediators: remediatorMap });\n if (T) {\n const remediator: Remediator = new T(remediation);\n res.push (remediator.getNextStep(authClient, idxResponse.context) as never);\n }\n }\n\n for (const [name] of Object.entries((idxResponse.actions || {}))) {\n let stepObj = {\n name, \n action: async (params?) => {\n return authClient.idx.proceed({ \n actions: [{ name, params }] \n });\n }\n };\n if (name.startsWith('currentAuthenticator')) {\n const [part1, part2] = split2(name, '-');\n const actionObj = idxResponse.rawIdxState[part1].value[part2];\n /* eslint-disable no-unused-vars, @typescript-eslint/no-unused-vars */\n const {\n href, \n method, \n rel, \n accepts, \n produces, \n ...rest\n } = actionObj;\n /* eslint-enable no-unused-vars, @typescript-eslint/no-unused-vars */\n const value = actionObj.value?.filter(item => item.name !== 'stateHandle');\n stepObj = { \n ...rest, \n ...(value && { value }),\n ...stepObj,\n };\n }\n res.push(stepObj);\n }\n\n return res;\n}\n\nexport function filterValuesForRemediation(\n idxResponse: IdxResponse,\n remediationName: string,\n values: RemediationValues\n): RemediationValues {\n const remediations = idxResponse.neededToProceed || [];\n const remediation = remediations.find(r => r.name === remediationName);\n if (!remediation) {\n // step was specified, but remediation was not found. This is unexpected!\n warn(`filterValuesForRemediation: \"${remediationName}\" did not match any remediations`);\n return values;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const valuesForRemediation = remediation.value!.reduce((res, entry) => {\n const { name, value } = entry;\n if (name === 'stateHandle') {\n res[name] = value; // use the stateHandle value in the remediation\n } else {\n res[name] = values[name]; // use the value provided by the caller\n }\n return res;\n }, {});\n return valuesForRemediation;\n}\n\nfunction getRemediatorClass(remediation: IdxRemediation, options: RemediateOptions) {\n const { useGenericRemediator, remediators } = options;\n \n if (!remediation) {\n return undefined;\n }\n\n if (useGenericRemediator) {\n return GenericRemediator;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return remediators![remediation.name];\n}\n\n// Return first match idxRemediation in allowed remediators\n// eslint-disable-next-line complexity\nexport function getRemediator(\n idxResponse: IdxResponse,\n values: RemediationValues,\n options: RemediateOptions,\n): Remediator | undefined {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const remediators = options.remediators!;\n const useGenericRemediator = options.useGenericRemediator;\n const {neededToProceed: idxRemediations, context} = idxResponse;\n\n let remediator: Remediator;\n // remediation name specified by caller - fast-track remediator lookup \n if (options.step) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const remediation = idxRemediations.find(({ name }) => name === options.step)!;\n if (remediation) {\n const T = getRemediatorClass(remediation, options);\n return T ? new T(remediation, values, options) : undefined;\n } else {\n // step was specified, but remediation was not found. This is unexpected!\n warn(`step \"${options.step}\" did not match any remediations`);\n return;\n }\n }\n\n const remediatorCandidates: Remediator[] = [];\n if (useGenericRemediator) {\n // always pick the first remediation for when use GenericRemediator\n remediatorCandidates.push(new GenericRemediator(idxRemediations[0], values, options));\n } else {\n for (let remediation of idxRemediations) {\n const isRemeditionInFlow = Object.keys(remediators as object).includes(remediation.name);\n if (!isRemeditionInFlow) {\n continue;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const T = getRemediatorClass(remediation, options)!;\n remediator = new T(remediation, values, options);\n if (remediator.canRemediate(context)) {\n // found the remediator\n return remediator;\n }\n // remediator cannot handle the current values\n // maybe return for next step\n remediatorCandidates.push(remediator); \n }\n }\n \n return remediatorCandidates[0];\n}\n\n\nexport function getNextStep(\n authClient: OktaAuthIdxInterface, remediator: Remediator, idxResponse: IdxResponse\n): NextStep {\n const nextStep = remediator.getNextStep(authClient, idxResponse.context);\n const canSkip = canSkipFn(idxResponse);\n const canResend = canResendFn(idxResponse);\n return {\n ...nextStep,\n ...(canSkip && {canSkip}),\n ...(canResend && {canResend}),\n };\n}\n\nexport function handleFailedResponse(\n authClient: OktaAuthIdxInterface,\n idxResponse: IdxResponse,\n options = {}\n): RemediationResponse {\n const terminal = isTerminalResponse(idxResponse);\n const messages = getMessagesFromResponse(idxResponse, options);\n if (terminal) {\n return { idxResponse, terminal, messages };\n } else {\n const remediator = getRemediator(idxResponse, {}, options);\n const nextStep = remediator && getNextStep(authClient, remediator, idxResponse);\n return {\n idxResponse,\n messages,\n ...(nextStep && { nextStep }),\n };\n }\n \n}\n"],"mappings":";;;;;;;;;;;;;AAAA;AACA;AAEA;AACA;AAAwH;AAAA;AAGjH,SAASA,kBAAkB,CAACC,WAAwB,EAAE;EAC3D,MAAM;IAAEC,eAAe;IAAEC;EAAgB,CAAC,GAAGF,WAAW;EACxD,OAAO,CAACC,eAAe,CAACE,MAAM,IAAI,CAACD,eAAe;AACpD;AAEO,SAASE,SAAS,CAACJ,WAAwB,EAAE;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AAEvD,WAAW,CAAC;IAC/E,OAAO;MACLA,WAAW;MACXkB,QAAQ;MACR,IAAI0E,QAAQ,IAAI;QAAEA;MAAS,CAAC;IAC9B,CAAC;EACH;AAEF"}
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8"/>
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
6
- <title>@okta/okta-auth-js [28 Apr 2023 at 16:14]</title>
6
+ <title>@okta/okta-auth-js [18 Jul 2023 at 16:52]</title>
7
7
  <link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9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