@okta/okta-auth-js 6.7.7 → 6.8.0

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 (177) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/README.md +3 -2
  3. package/cjs/AuthStateManager.js +1 -1
  4. package/cjs/AuthStateManager.js.map +1 -1
  5. package/cjs/OktaAuth.js.map +1 -1
  6. package/cjs/OktaUserAgent.js +2 -2
  7. package/cjs/OktaUserAgent.js.map +1 -1
  8. package/cjs/PromiseQueue.js.map +1 -1
  9. package/cjs/SavedObject.js.map +1 -1
  10. package/cjs/ServiceManager.js.map +1 -1
  11. package/cjs/StorageManager.js.map +1 -1
  12. package/cjs/TokenManager.js.map +1 -1
  13. package/cjs/TransactionManager.js.map +1 -1
  14. package/cjs/browser/browserStorage.js.map +1 -1
  15. package/cjs/browser/fingerprint.js.map +1 -1
  16. package/cjs/constants.js +1 -1
  17. package/cjs/crypto/base64.js +4 -4
  18. package/cjs/crypto/base64.js.map +1 -1
  19. package/cjs/crypto/oidcHash.js.map +1 -1
  20. package/cjs/crypto/verifyToken.js.map +1 -1
  21. package/cjs/crypto/webauthn.js +1 -1
  22. package/cjs/crypto/webauthn.js.map +1 -1
  23. package/cjs/errors/index.js +2 -2
  24. package/cjs/features.js +6 -6
  25. package/cjs/features.js.map +1 -1
  26. package/cjs/http/request.js +1 -1
  27. package/cjs/http/request.js.map +1 -1
  28. package/cjs/idx/authenticate.js.map +1 -1
  29. package/cjs/idx/authenticator/OktaPassword.js +5 -4
  30. package/cjs/idx/authenticator/OktaPassword.js.map +1 -1
  31. package/cjs/idx/authenticator/getAuthenticator.js.map +1 -1
  32. package/cjs/idx/authenticator/util.js +1 -1
  33. package/cjs/idx/authenticator/util.js.map +1 -1
  34. package/cjs/idx/cancel.js.map +1 -1
  35. package/cjs/idx/emailVerify.js +3 -3
  36. package/cjs/idx/emailVerify.js.map +1 -1
  37. package/cjs/idx/idxState/index.js +1 -1
  38. package/cjs/idx/idxState/v1/generateIdxAction.js.map +1 -1
  39. package/cjs/idx/idxState/v1/idxResponseParser.js +1 -1
  40. package/cjs/idx/idxState/v1/idxResponseParser.js.map +1 -1
  41. package/cjs/idx/idxState/v1/makeIdxState.js.map +1 -1
  42. package/cjs/idx/idxState/v1/remediationParser.js.map +1 -1
  43. package/cjs/idx/index.js +24 -24
  44. package/cjs/idx/interact.js.map +1 -1
  45. package/cjs/idx/introspect.js.map +1 -1
  46. package/cjs/idx/poll.js.map +1 -1
  47. package/cjs/idx/proceed.js.map +1 -1
  48. package/cjs/idx/recoverPassword.js.map +1 -1
  49. package/cjs/idx/register.js.map +1 -1
  50. package/cjs/idx/remediate.js.map +1 -1
  51. package/cjs/idx/remediators/AuthenticatorEnrollmentData.js.map +1 -1
  52. package/cjs/idx/remediators/Base/AuthenticatorData.js.map +1 -1
  53. package/cjs/idx/remediators/Base/Remediator.js.map +1 -1
  54. package/cjs/idx/remediators/Base/SelectAuthenticator.js.map +1 -1
  55. package/cjs/idx/remediators/Base/VerifyAuthenticator.js.map +1 -1
  56. package/cjs/idx/remediators/EnrollProfile.js +46 -4
  57. package/cjs/idx/remediators/EnrollProfile.js.map +1 -1
  58. package/cjs/idx/remediators/GenericRemediator/util.js +1 -1
  59. package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js.map +1 -1
  60. package/cjs/idx/remediators/SelectEnrollmentChannel.js.map +1 -1
  61. package/cjs/idx/remediators/util.js +1 -1
  62. package/cjs/idx/run.js.map +1 -1
  63. package/cjs/idx/startTransaction.js.map +1 -1
  64. package/cjs/idx/transactionMeta.js +3 -3
  65. package/cjs/idx/transactionMeta.js.map +1 -1
  66. package/cjs/idx/types/api.js +1 -1
  67. package/cjs/idx/types/idx-js.js +1 -1
  68. package/cjs/idx/types/idx-js.js.map +1 -1
  69. package/cjs/idx/unlockAccount.js.map +1 -1
  70. package/cjs/idx/util.js +6 -6
  71. package/cjs/idx/util.js.map +1 -1
  72. package/cjs/myaccount/emailApi.js +1 -1
  73. package/cjs/myaccount/emailApi.js.map +1 -1
  74. package/cjs/myaccount/phoneApi.js +1 -1
  75. package/cjs/myaccount/phoneApi.js.map +1 -1
  76. package/cjs/myaccount/profileApi.js +1 -1
  77. package/cjs/myaccount/profileApi.js.map +1 -1
  78. package/cjs/myaccount/request.js +1 -1
  79. package/cjs/myaccount/request.js.map +1 -1
  80. package/cjs/myaccount/transactions/EmailChallengeTransaction.js.map +1 -1
  81. package/cjs/myaccount/transactions/EmailTransaction.js.map +1 -1
  82. package/cjs/myaccount/transactions/PhoneTransaction.js.map +1 -1
  83. package/cjs/myaccount/transactions/index.js +14 -14
  84. package/cjs/myaccount/types.js +14 -13
  85. package/cjs/myaccount/types.js.map +1 -1
  86. package/cjs/oidc/decodeToken.js.map +1 -1
  87. package/cjs/oidc/endpoints/authorize.js +1 -1
  88. package/cjs/oidc/endpoints/authorize.js.map +1 -1
  89. package/cjs/oidc/endpoints/token.js +1 -1
  90. package/cjs/oidc/endpoints/token.js.map +1 -1
  91. package/cjs/oidc/endpoints/well-known.js +1 -1
  92. package/cjs/oidc/endpoints/well-known.js.map +1 -1
  93. package/cjs/oidc/exchangeCodeForTokens.js.map +1 -1
  94. package/cjs/oidc/getToken.js.map +1 -1
  95. package/cjs/oidc/getUserInfo.js.map +1 -1
  96. package/cjs/oidc/getWithPopup.js.map +1 -1
  97. package/cjs/oidc/getWithRedirect.js.map +1 -1
  98. package/cjs/oidc/getWithoutPrompt.js.map +1 -1
  99. package/cjs/oidc/handleOAuthResponse.js.map +1 -1
  100. package/cjs/oidc/index.js +24 -24
  101. package/cjs/oidc/parseFromUrl.js +2 -2
  102. package/cjs/oidc/parseFromUrl.js.map +1 -1
  103. package/cjs/oidc/renewToken.js.map +1 -1
  104. package/cjs/oidc/renewTokens.js.map +1 -1
  105. package/cjs/oidc/renewTokensWithRefresh.js.map +1 -1
  106. package/cjs/oidc/revokeToken.js.map +1 -1
  107. package/cjs/oidc/util/browser.js +2 -2
  108. package/cjs/oidc/util/defaultTokenParams.js.map +1 -1
  109. package/cjs/oidc/util/errors.js +1 -1
  110. package/cjs/oidc/util/errors.js.map +1 -1
  111. package/cjs/oidc/util/loginRedirect.js +5 -5
  112. package/cjs/oidc/util/oauth.js +1 -1
  113. package/cjs/oidc/util/oauth.js.map +1 -1
  114. package/cjs/oidc/util/oauthMeta.js.map +1 -1
  115. package/cjs/oidc/util/pkce.js.map +1 -1
  116. package/cjs/oidc/util/prepareTokenParams.js +1 -1
  117. package/cjs/oidc/util/prepareTokenParams.js.map +1 -1
  118. package/cjs/oidc/util/refreshToken.js +1 -1
  119. package/cjs/oidc/util/refreshToken.js.map +1 -1
  120. package/cjs/oidc/util/validateToken.js.map +1 -1
  121. package/cjs/oidc/verifyToken.js.map +1 -1
  122. package/cjs/options/browser.js +2 -2
  123. package/cjs/options/browser.js.map +1 -1
  124. package/cjs/options/index.js +1 -1
  125. package/cjs/options/index.js.map +1 -1
  126. package/cjs/options/node.js +2 -2
  127. package/cjs/services/AutoRenewService.js.map +1 -1
  128. package/cjs/services/LeaderElectionService.js.map +1 -1
  129. package/cjs/services/SyncStorageService.js.map +1 -1
  130. package/cjs/session.js +2 -2
  131. package/cjs/session.js.map +1 -1
  132. package/cjs/tx/AuthTransaction.js.map +1 -1
  133. package/cjs/tx/api.js +4 -4
  134. package/cjs/tx/api.js.map +1 -1
  135. package/cjs/tx/poll.js.map +1 -1
  136. package/cjs/types/Token.js +1 -1
  137. package/cjs/types/TokenManager.js +1 -1
  138. package/cjs/types/Transaction.js +2 -2
  139. package/cjs/util/console.js +3 -3
  140. package/cjs/util/misc.js +2 -2
  141. package/cjs/util/object.js +3 -3
  142. package/cjs/util/sharedStorage.js +2 -2
  143. package/cjs/util/sharedStorage.js.map +1 -1
  144. package/cjs/util/types.js +3 -3
  145. package/cjs/util/url.js +3 -3
  146. package/cjs/util/url.js.map +1 -1
  147. package/dist/myaccount.umd.js +1 -1
  148. package/dist/myaccount.umd.js.map +1 -1
  149. package/dist/okta-auth-js.min.js +1 -1
  150. package/dist/okta-auth-js.min.js.map +1 -1
  151. package/dist/okta-auth-js.polyfill.js +1 -1
  152. package/dist/okta-auth-js.polyfill.js.map +1 -1
  153. package/dist/okta-auth-js.umd.js +1 -1
  154. package/dist/okta-auth-js.umd.js.map +1 -1
  155. package/esm/browser/OktaUserAgent.js +2 -2
  156. package/esm/browser/idx/authenticator/OktaPassword.js +4 -4
  157. package/esm/browser/idx/authenticator/OktaPassword.js.map +1 -1
  158. package/esm/browser/idx/remediators/Base/Remediator.js.map +1 -1
  159. package/esm/browser/idx/remediators/EnrollProfile.js +26 -0
  160. package/esm/browser/idx/remediators/EnrollProfile.js.map +1 -1
  161. package/esm/browser/idx/types/idx-js.js.map +1 -1
  162. package/esm/browser/util/url.js +1 -1
  163. package/esm/browser/util/url.js.map +1 -1
  164. package/esm/node/OktaUserAgent.js +2 -2
  165. package/esm/node/idx/authenticator/OktaPassword.js +4 -4
  166. package/esm/node/idx/authenticator/OktaPassword.js.map +1 -1
  167. package/esm/node/idx/remediators/Base/Remediator.js.map +1 -1
  168. package/esm/node/idx/remediators/EnrollProfile.js +26 -0
  169. package/esm/node/idx/remediators/EnrollProfile.js.map +1 -1
  170. package/esm/node/idx/types/idx-js.js.map +1 -1
  171. package/esm/node/util/url.js +1 -1
  172. package/esm/node/util/url.js.map +1 -1
  173. package/esm/package.json +1 -1
  174. package/lib/idx/authenticator/OktaPassword.d.ts +1 -0
  175. package/lib/idx/remediators/EnrollProfile.d.ts +11 -0
  176. package/lib/idx/types/idx-js.d.ts +4 -0
  177. package/package.json +14 -25
@@ -1 +1 @@
1
- {"version":3,"file":"register.js","names":["register","authClient","options","enabledFeatures","availableSteps","flow","autoRemediate","activationToken","IdxFeature","REGISTRATION","error","AuthSdkError","some","name"],"sources":["../../../lib/idx/register.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\nimport { run } from './run';\nimport { hasSavedInteractionHandle } from './transactionMeta';\nimport { startTransaction } from './startTransaction';\nimport { AuthSdkError } from '../errors';\nimport { \n RegistrationOptions, \n IdxTransaction, \n OktaAuthIdxInterface, \n IdxFeature,\n} from '../types';\n\nexport async function register(\n authClient: OktaAuthIdxInterface, options: RegistrationOptions = {}\n): Promise<IdxTransaction> {\n\n // Only check at the beginning of the transaction\n if (!hasSavedInteractionHandle(authClient)) {\n const { enabledFeatures, availableSteps } = await startTransaction(authClient, {\n ...options,\n flow: 'register',\n autoRemediate: false\n });\n if (!options.activationToken && enabledFeatures && !enabledFeatures.includes(IdxFeature.REGISTRATION)) {\n const error = new AuthSdkError('Registration is not supported based on your current org configuration.');\n throw error;\n // return { status: IdxStatus.FAILURE, error } as unknown as IdxTransaction; // TODO: wny not just throw the error?\n }\n if (options.activationToken && availableSteps?.some(({ name }) => name === 'identify')) {\n const error = new AuthSdkError('activationToken is not supported based on your current org configuration.');\n throw error;\n // return { status: IdxStatus.FAILURE, error } as unknown as IdxTransaction; // TODO: wny not just throw the error?\n }\n }\n\n return run(authClient, {\n ...options,\n flow: 'register'\n });\n}\n"],"mappings":";;;;;;;;AAaA;;AACA;;AACA;;AACA;;AACA;;AAjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAcO,eAAeA,QAAf,CACLC,UADK,EAC6BC,OAA4B,GAAG,EAD5D,EAEoB;EAEzB;EACA,IAAI,CAAC,gDAA0BD,UAA1B,CAAL,EAA4C;IAC1C,MAAM;MAAEE,eAAF;MAAmBC;IAAnB,IAAsC,MAAM,wCAAiBH,UAAjB,EAA6B,EAC7E,GAAGC,OAD0E;MAE7EG,IAAI,EAAE,UAFuE;MAG7EC,aAAa,EAAE;IAH8D,CAA7B,CAAlD;;IAKA,IAAI,CAACJ,OAAO,CAACK,eAAT,IAA4BJ,eAA5B,IAA+C,CAAC,uBAAAA,eAAe,MAAf,CAAAA,eAAe,EAAUK,kBAAWC,YAArB,CAAnE,EAAuG;MACrG,MAAMC,KAAK,GAAG,IAAIC,oBAAJ,CAAiB,wEAAjB,CAAd;MACA,MAAMD,KAAN,CAFqG,CAGvG;IACC;;IACD,IAAIR,OAAO,CAACK,eAAR,IAA2BH,cAA3B,aAA2BA,cAA3B,eAA2BA,cAAc,CAAEQ,IAAhB,CAAqB,CAAC;MAAEC;IAAF,CAAD,KAAcA,IAAI,KAAK,UAA5C,CAA/B,EAAwF;MACtF,MAAMH,KAAK,GAAG,IAAIC,oBAAJ,CAAiB,2EAAjB,CAAd;MACA,MAAMD,KAAN,CAFsF,CAGxF;IACC;EACF;;EAED,OAAO,cAAIT,UAAJ,EAAgB,EACrB,GAAGC,OADkB;IAErBG,IAAI,EAAE;EAFe,CAAhB,CAAP;AAID"}
1
+ {"version":3,"file":"register.js","names":["register","authClient","options","hasSavedInteractionHandle","enabledFeatures","availableSteps","startTransaction","flow","autoRemediate","activationToken","IdxFeature","REGISTRATION","error","AuthSdkError","some","name","run"],"sources":["../../../lib/idx/register.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\nimport { run } from './run';\nimport { hasSavedInteractionHandle } from './transactionMeta';\nimport { startTransaction } from './startTransaction';\nimport { AuthSdkError } from '../errors';\nimport { \n RegistrationOptions, \n IdxTransaction, \n OktaAuthIdxInterface, \n IdxFeature,\n} from '../types';\n\nexport async function register(\n authClient: OktaAuthIdxInterface, options: RegistrationOptions = {}\n): Promise<IdxTransaction> {\n\n // Only check at the beginning of the transaction\n if (!hasSavedInteractionHandle(authClient)) {\n const { enabledFeatures, availableSteps } = await startTransaction(authClient, {\n ...options,\n flow: 'register',\n autoRemediate: false\n });\n if (!options.activationToken && enabledFeatures && !enabledFeatures.includes(IdxFeature.REGISTRATION)) {\n const error = new AuthSdkError('Registration is not supported based on your current org configuration.');\n throw error;\n // return { status: IdxStatus.FAILURE, error } as unknown as IdxTransaction; // TODO: wny not just throw the error?\n }\n if (options.activationToken && availableSteps?.some(({ name }) => name === 'identify')) {\n const error = new AuthSdkError('activationToken is not supported based on your current org configuration.');\n throw error;\n // return { status: IdxStatus.FAILURE, error } as unknown as IdxTransaction; // TODO: wny not just throw the error?\n }\n }\n\n return run(authClient, {\n ...options,\n flow: 'register'\n });\n}\n"],"mappings":";;;;;;;;AAaA;;AACA;;AACA;;AACA;;AACA;;AAjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAcO,eAAeA,QAAf,CACLC,UADK,EAC6BC,OAA4B,GAAG,EAD5D,EAEoB;EAEzB;EACA,IAAI,CAAC,IAAAC,0CAAA,EAA0BF,UAA1B,CAAL,EAA4C;IAC1C,MAAM;MAAEG,eAAF;MAAmBC;IAAnB,IAAsC,MAAM,IAAAC,kCAAA,EAAiBL,UAAjB,EAA6B,EAC7E,GAAGC,OAD0E;MAE7EK,IAAI,EAAE,UAFuE;MAG7EC,aAAa,EAAE;IAH8D,CAA7B,CAAlD;;IAKA,IAAI,CAACN,OAAO,CAACO,eAAT,IAA4BL,eAA5B,IAA+C,CAAC,uBAAAA,eAAe,MAAf,CAAAA,eAAe,EAAUM,iBAAA,CAAWC,YAArB,CAAnE,EAAuG;MACrG,MAAMC,KAAK,GAAG,IAAIC,oBAAJ,CAAiB,wEAAjB,CAAd;MACA,MAAMD,KAAN,CAFqG,CAGvG;IACC;;IACD,IAAIV,OAAO,CAACO,eAAR,IAA2BJ,cAA3B,aAA2BA,cAA3B,eAA2BA,cAAc,CAAES,IAAhB,CAAqB,CAAC;MAAEC;IAAF,CAAD,KAAcA,IAAI,KAAK,UAA5C,CAA/B,EAAwF;MACtF,MAAMH,KAAK,GAAG,IAAIC,oBAAJ,CAAiB,2EAAjB,CAAd;MACA,MAAMD,KAAN,CAFsF,CAGxF;IACC;EACF;;EAED,OAAO,IAAAI,QAAA,EAAIf,UAAJ,EAAgB,EACrB,GAAGC,OADkB;IAErBK,IAAI,EAAE;EAFe,CAAhB,CAAP;AAID"}
@@ -1 +1 @@
1
- {"version":3,"file":"remediate.js","names":["getActionFromValues","values","idxResponse","actions","action","resend","removeActionFromValues","undefined","removeActionFromOptions","options","actionName","entry","name","remediate","authClient","neededToProceed","interactionCode","flow","remediator","actionFromValues","actionFromOptions","params","valuesWithoutExecutedAction","optionsWithoutExecutedAction","requestDidSucceed","e","canceled","remediationAction","proceed","terminal","step","AuthSdkError","acc","curr","canRemediate","nextStep","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 { OktaAuthIdxInterface } from '../types';\nimport { AuthSdkError } from '../errors';\nimport { RemediationValues } from './remediators';\nimport { RemediateOptions, RemediationResponse } from './types';\nimport { \n IdxResponse,\n IdxActionParams, \n} from './types/idx-js';\nimport {\n isTerminalResponse,\n filterValuesForRemediation,\n getRemediator,\n getNextStep,\n handleIdxError\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 try {\n idxResponse = await idxResponse.actions[action](params);\n idxResponse = { ...idxResponse, requestDidSucceed: true };\n } catch (e) {\n return handleIdxError(authClient, e, 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 try {\n idxResponse = await idxResponse.proceed(action, params);\n idxResponse = { ...idxResponse, requestDidSucceed: true };\n }\n catch (e) {\n return handleIdxError(authClient, e, options);\n }\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 if (options.step) {\n values = filterValuesForRemediation(idxResponse, options.step, values); // include only requested values\n try {\n idxResponse = await idxResponse.proceed(options.step, values);\n idxResponse = { ...idxResponse, requestDidSucceed: true };\n return { idxResponse };\n } catch(e) {\n return handleIdxError(authClient, e, options);\n }\n }\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 try {\n idxResponse = await idxResponse.proceed(name, data);\n idxResponse = { ...idxResponse, requestDidSucceed: true };\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 } catch (e) {\n return handleIdxError(authClient, e, options);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAeA;;AAOA;;AAtBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AAyBA,SAASA,mBAAT,CAA6BC,MAA7B,EAAwDC,WAAxD,EAAsG;EAAA;;EACpG;EACA,OAAO,iDAAYA,WAAW,CAACC,OAAxB,kBAAsCC,MAAM,IAAI,CAAC,CAACH,MAAM,CAACI,MAAT,IAAmB,uBAAAD,MAAM,MAAN,CAAAA,MAAM,EAAU,SAAV,CAAzE,CAAP;AACD;;AAED,SAASE,sBAAT,CAAgCL,MAAhC,EAA8E;EAC5E;EACA,OAAO,EACL,GAAGA,MADE;IAELI,MAAM,EAAEE;EAFH,CAAP;AAID;;AAED,SAASC,uBAAT,CAAiCC,OAAjC,EAA4DC,UAA5D,EAAkG;EAChG,IAAIP,OAAO,GAAGM,OAAO,CAACN,OAAR,IAAmB,EAAjC;EACAA,OAAO,GAAG,qBAAAA,OAAO,MAAP,CAAAA,OAAO,EAAQQ,KAAK,IAAI;IAChC,IAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;MAC7B,OAAOA,KAAK,KAAKD,UAAjB;IACD;;IACD,OAAOC,KAAK,CAACC,IAAN,KAAeF,UAAtB;EACD,CALgB,CAAjB;EAOA,OAAO,EAAE,GAAGD,OAAL;IAAcN;EAAd,CAAP;AACD,C,CAED;;;AACO,eAAeU,SAAf,CACLC,UADK,EAELZ,WAFK,EAGLD,MAHK,EAILQ,OAJK,EAKyB;EAC9B,IAAI;IAAEM,eAAF;IAAmBC;EAAnB,IAAuCd,WAA3C;EACA,MAAM;IAAEe;EAAF,IAAWR,OAAjB,CAF8B,CAI9B;;EACA,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G,yBAAcvC,WAAW,CAACa,eAA1B,EAA2Cd,MAA3C,EAAmDQ,OAAnD,CAAX;MACA,MAAM0B,QAAQ,GAAG,uBAAYrB,UAAZ,EAAwB2B,EAAxB,EAA4BvC,WAA5B,CAAjB;MACA,OAAO;QACLA,WADK;QAELiC;MAFK,CAAP;IAID;;IAED,OAAOtB,SAAS,CAACC,UAAD,EAAaZ,WAAb,EAA0BD,MAA1B,EAAkCQ,OAAlC,CAAhB,CApBE,CAoB0D;EAC7D,CArBD,CAqBE,OAAOgB,CAAP,EAAU;IACV,OAAO,0BAAeX,UAAf,EAA2BW,CAA3B,EAA8BhB,OAA9B,CAAP;EACD;AACF"}
1
+ {"version":3,"file":"remediate.js","names":["getActionFromValues","values","idxResponse","actions","action","resend","removeActionFromValues","undefined","removeActionFromOptions","options","actionName","entry","name","remediate","authClient","neededToProceed","interactionCode","flow","remediator","getRemediator","actionFromValues","actionFromOptions","params","valuesWithoutExecutedAction","optionsWithoutExecutedAction","requestDidSucceed","e","handleIdxError","canceled","remediationAction","proceed","terminal","isTerminalResponse","step","filterValuesForRemediation","AuthSdkError","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 { OktaAuthIdxInterface } from '../types';\nimport { AuthSdkError } from '../errors';\nimport { RemediationValues } from './remediators';\nimport { RemediateOptions, RemediationResponse } from './types';\nimport { \n IdxResponse,\n IdxActionParams, \n} from './types/idx-js';\nimport {\n isTerminalResponse,\n filterValuesForRemediation,\n getRemediator,\n getNextStep,\n handleIdxError\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 try {\n idxResponse = await idxResponse.actions[action](params);\n idxResponse = { ...idxResponse, requestDidSucceed: true };\n } catch (e) {\n return handleIdxError(authClient, e, 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 try {\n idxResponse = await idxResponse.proceed(action, params);\n idxResponse = { ...idxResponse, requestDidSucceed: true };\n }\n catch (e) {\n return handleIdxError(authClient, e, options);\n }\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 if (options.step) {\n values = filterValuesForRemediation(idxResponse, options.step, values); // include only requested values\n try {\n idxResponse = await idxResponse.proceed(options.step, values);\n idxResponse = { ...idxResponse, requestDidSucceed: true };\n return { idxResponse };\n } catch(e) {\n return handleIdxError(authClient, e, options);\n }\n }\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 try {\n idxResponse = await idxResponse.proceed(name, data);\n idxResponse = { ...idxResponse, requestDidSucceed: true };\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 } catch (e) {\n return handleIdxError(authClient, e, options);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAeA;;AAOA;;AAtBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AAyBA,SAASA,mBAAT,CAA6BC,MAA7B,EAAwDC,WAAxD,EAAsG;EAAA;;EACpG;EACA,OAAO,iDAAYA,WAAW,CAACC,OAAxB,kBAAsCC,MAAM,IAAI,CAAC,CAACH,MAAM,CAACI,MAAT,IAAmB,uBAAAD,MAAM,MAAN,CAAAA,MAAM,EAAU,SAAV,CAAzE,CAAP;AACD;;AAED,SAASE,sBAAT,CAAgCL,MAAhC,EAA8E;EAC5E;EACA,OAAO,EACL,GAAGA,MADE;IAELI,MAAM,EAAEE;EAFH,CAAP;AAID;;AAED,SAASC,uBAAT,CAAiCC,OAAjC,EAA4DC,UAA5D,EAAkG;EAChG,IAAIP,OAAO,GAAGM,OAAO,CAACN,OAAR,IAAmB,EAAjC;EACAA,OAAO,GAAG,qBAAAA,OAAO,MAAP,CAAAA,OAAO,EAAQQ,KAAK,IAAI;IAChC,IAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;MAC7B,OAAOA,KAAK,KAAKD,UAAjB;IACD;;IACD,OAAOC,KAAK,CAACC,IAAN,KAAeF,UAAtB;EACD,CALgB,CAAjB;EAOA,OAAO,EAAE,GAAGD,OAAL;IAAcN;EAAd,CAAP;AACD,C,CAED;;;AACO,eAAeU,SAAf,CACLC,UADK,EAELZ,WAFK,EAGLD,MAHK,EAILQ,OAJK,EAKyB;EAC9B,IAAI;IAAEM,eAAF;IAAmBC;EAAnB,IAAuCd,WAA3C;EACA,MAAM;IAAEe;EAAF,IAAWR,OAAjB,CAF8B,CAI9B;;EACA,IAAIO,eAAJ,EAAqB;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IAAgE,CAAC,IAAAgB,wBAAA,EAAmB9B,WAAnB,CAArE,EAAsG;MACpG;MACA,MAAM4C,EAAE,GAAG,IAAA3B,mBAAA,EAAcjB,WAAW,CAACa,eAA1B,EAA2Cd,MAA3C,EAAmDQ,OAAnD,CAAX;MACA,MAAM8B,QAAQ,GAAG,IAAAC,iBAAA,EAAY1B,UAAZ,EAAwBgC,EAAxB,EAA4B5C,WAA5B,CAAjB;MACA,OAAO;QACLA,WADK;QAELqC;MAFK,CAAP;IAID;;IAED,OAAO1B,SAAS,CAACC,UAAD,EAAaZ,WAAb,EAA0BD,MAA1B,EAAkCQ,OAAlC,CAAhB,CApBE,CAoB0D;EAC7D,CArBD,CAqBE,OAAOiB,CAAP,EAAU;IACV,OAAO,IAAAC,oBAAA,EAAeb,UAAf,EAA2BY,CAA3B,EAA8BjB,OAA9B,CAAP;EACD;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"AuthenticatorEnrollmentData.js","names":["AuthenticatorEnrollmentData","AuthenticatorData","mapAuthenticator","authenticatorData","getAuthenticatorData","authenticatorFromRemediation","remediation","id","form","value","name","methodType","phoneNumber","getInputAuthenticator","type","label","item","val","mapAuthenticatorDataFromValues","data"],"sources":["../../../../lib/idx/remediators/AuthenticatorEnrollmentData.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 { AuthenticatorData, AuthenticatorDataValues } from './Base/AuthenticatorData';\nimport { getAuthenticatorFromRemediation } from './util';\n\nexport type AuthenticatorEnrollmentDataValues = AuthenticatorDataValues & {\n phoneNumber?: string;\n resend?: boolean; // resend is not a remediator value - revise when IdxResponse structure is updated\n}\nexport class AuthenticatorEnrollmentData extends AuthenticatorData<AuthenticatorEnrollmentDataValues> {\n static remediationName = 'authenticator-enrollment-data';\n\n mapAuthenticator() {\n const authenticatorData = this.getAuthenticatorData();\n const authenticatorFromRemediation = getAuthenticatorFromRemediation(this.remediation)!;\n return { \n id: authenticatorFromRemediation.form!.value\n .find(({ name }) => name === 'id')!.value,\n methodType: authenticatorData!.methodType,\n phoneNumber: authenticatorData!.phoneNumber,\n };\n }\n\n getInputAuthenticator(remediation) {\n return [\n { name: 'methodType', type: 'string' }, \n { name: 'phoneNumber', label: 'Phone Number', type: 'string' }\n ].map(item => {\n const value = remediation.form.value.find(val => val.name === item.name);\n return { ...value, ...item };\n });\n }\n\n protected mapAuthenticatorDataFromValues(data?) {\n // get mapped authenticator from base class\n data = super.mapAuthenticatorDataFromValues(data);\n // add phoneNumber to authenticator if it exists in values\n const { phoneNumber } = this.values;\n if (!data && !phoneNumber) {\n return;\n }\n\n return { \n ...(data && data), \n ...(phoneNumber && { phoneNumber }) \n };\n }\n\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA;;AACA;;AAfA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAUO,MAAMA,2BAAN,SAA0CC,oCAA1C,CAA+F;EAGpGC,gBAAgB,GAAG;IAAA;;IACjB,MAAMC,iBAAiB,GAAG,KAAKC,oBAAL,EAA1B;IACA,MAAMC,4BAA4B,GAAG,2CAAgC,KAAKC,WAArC,CAArC;IACA,OAAO;MACLC,EAAE,EAAE,8BAAAF,4BAA4B,CAACG,IAA7B,CAAmCC,KAAnC,iBACI,CAAC;QAAEC;MAAF,CAAD,KAAcA,IAAI,KAAK,IAD3B,EACkCD,KAFjC;MAGLE,UAAU,EAAER,iBAAiB,CAAEQ,UAH1B;MAILC,WAAW,EAAET,iBAAiB,CAAES;IAJ3B,CAAP;EAMD;;EAEDC,qBAAqB,CAACP,WAAD,EAAc;IAAA;;IACjC,OAAO,+BACL;MAAEI,IAAI,EAAE,YAAR;MAAsBI,IAAI,EAAE;IAA5B,CADK,EAEL;MAAEJ,IAAI,EAAE,aAAR;MAAuBK,KAAK,EAAE,cAA9B;MAA8CD,IAAI,EAAE;IAApD,CAFK,mBAGDE,IAAI,IAAI;MAAA;;MACZ,MAAMP,KAAK,GAAG,+BAAAH,WAAW,CAACE,IAAZ,CAAiBC,KAAjB,kBAA4BQ,GAAG,IAAIA,GAAG,CAACP,IAAJ,KAAaM,IAAI,CAACN,IAArD,CAAd;MACA,OAAO,EAAE,GAAGD,KAAL;QAAY,GAAGO;MAAf,CAAP;IACD,CANM,CAAP;EAOD;;EAESE,8BAA8B,CAACC,IAAD,EAAQ;IAC9C;IACAA,IAAI,GAAG,MAAMD,8BAAN,CAAqCC,IAArC,CAAP,CAF8C,CAG9C;;IACA,MAAM;MAAEP;IAAF,yBAAkB,IAAlB,CAAN;;IACA,IAAI,CAACO,IAAD,IAAS,CAACP,WAAd,EAA2B;MACzB;IACD;;IAED,OAAO,EACL,IAAIO,IAAI,IAAIA,IAAZ,CADK;MAEL,IAAIP,WAAW,IAAI;QAAEA;MAAF,CAAnB;IAFK,CAAP;EAID;;AArCmG;;;8BAAzFZ,2B,qBACc,+B"}
1
+ {"version":3,"file":"AuthenticatorEnrollmentData.js","names":["AuthenticatorEnrollmentData","AuthenticatorData","mapAuthenticator","authenticatorData","getAuthenticatorData","authenticatorFromRemediation","getAuthenticatorFromRemediation","remediation","id","form","value","name","methodType","phoneNumber","getInputAuthenticator","type","label","item","val","mapAuthenticatorDataFromValues","data"],"sources":["../../../../lib/idx/remediators/AuthenticatorEnrollmentData.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 { AuthenticatorData, AuthenticatorDataValues } from './Base/AuthenticatorData';\nimport { getAuthenticatorFromRemediation } from './util';\n\nexport type AuthenticatorEnrollmentDataValues = AuthenticatorDataValues & {\n phoneNumber?: string;\n resend?: boolean; // resend is not a remediator value - revise when IdxResponse structure is updated\n}\nexport class AuthenticatorEnrollmentData extends AuthenticatorData<AuthenticatorEnrollmentDataValues> {\n static remediationName = 'authenticator-enrollment-data';\n\n mapAuthenticator() {\n const authenticatorData = this.getAuthenticatorData();\n const authenticatorFromRemediation = getAuthenticatorFromRemediation(this.remediation)!;\n return { \n id: authenticatorFromRemediation.form!.value\n .find(({ name }) => name === 'id')!.value,\n methodType: authenticatorData!.methodType,\n phoneNumber: authenticatorData!.phoneNumber,\n };\n }\n\n getInputAuthenticator(remediation) {\n return [\n { name: 'methodType', type: 'string' }, \n { name: 'phoneNumber', label: 'Phone Number', type: 'string' }\n ].map(item => {\n const value = remediation.form.value.find(val => val.name === item.name);\n return { ...value, ...item };\n });\n }\n\n protected mapAuthenticatorDataFromValues(data?) {\n // get mapped authenticator from base class\n data = super.mapAuthenticatorDataFromValues(data);\n // add phoneNumber to authenticator if it exists in values\n const { phoneNumber } = this.values;\n if (!data && !phoneNumber) {\n return;\n }\n\n return { \n ...(data && data), \n ...(phoneNumber && { phoneNumber }) \n };\n }\n\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA;;AACA;;AAfA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAUO,MAAMA,2BAAN,SAA0CC,oCAA1C,CAA+F;EAGpGC,gBAAgB,GAAG;IAAA;;IACjB,MAA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remediator","constructor","remediation","values","authenticator","getAuthenticator","formatAuthenticatorData","authenticatorData","getAuthenticatorData","authenticatorsData","data","mapAuthenticatorDataFromValues","push","canRemediate","some","getNextStep","authClient","common","options","getMethodTypes","methodType","id","enrollmentId","getAuthenticatorFromRemediation","value","name","form","getValuesAfterProceed"],"sources":["../../../../../lib/idx/remediators/Base/AuthenticatorData.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 { IdxRemediationValue, IdxOption, IdxRemediation, IdxAuthenticator } from '../../types/idx-js';\nimport { isAuthenticator } from '../../types';\nimport { compareAuthenticators } from '../../authenticator/util';\nimport { OktaAuthIdxInterface } from '../../../types';\n\nexport type AuthenticatorDataValues = RemediationValues & {\n methodType?: string;\n};\n\n// Base class - DO NOT expose static remediationName\nexport class AuthenticatorData<T extends AuthenticatorDataValues = AuthenticatorDataValues> extends Remediator<T> {\n authenticator: IdxAuthenticator;\n\n constructor(remediation: IdxRemediation, values: T = {} as T) {\n super(remediation, values);\n\n // set before other data calculation\n this.authenticator = this.getAuthenticator()!;\n\n this.formatAuthenticatorData();\n }\n\n protected formatAuthenticatorData() {\n const authenticatorData = this.getAuthenticatorData();\n if (authenticatorData) {\n this.values.authenticatorsData = this.values.authenticatorsData!.map(data => {\n if (compareAuthenticators(this.authenticator, data)) {\n return this.mapAuthenticatorDataFromValues(data);\n }\n return data;\n });\n } else {\n const data = this.mapAuthenticatorDataFromValues();\n if (data) {\n this.values.authenticatorsData!.push(data);\n }\n }\n }\n\n protected getAuthenticatorData() {\n return this.values.authenticatorsData!\n .find((data) => compareAuthenticators(this.authenticator, data));\n }\n\n canRemediate() {\n return this.values.authenticatorsData!\n .some(data => compareAuthenticators(this.authenticator, data));\n }\n\n // TODO: remove this override method in the next major version - OKTA-491236\n getNextStep(authClient: OktaAuthIdxInterface) {\n const common = super.getNextStep(authClient);\n const options = this.getMethodTypes();\n return { \n ...common, \n ...(options && { options }) \n };\n }\n\n protected mapAuthenticatorDataFromValues(authenticatorData?) {\n // add methodType to authenticatorData if it exists in values\n let { methodType, authenticator } = this.values;\n if (!methodType && isAuthenticator(authenticator)) {\n methodType = authenticator?.methodType;\n }\n \n const { id, enrollmentId } = this.authenticator;\n const data = { \n id,\n enrollmentId,\n ...(authenticatorData && authenticatorData),\n ...(methodType && { methodType }) \n };\n\n return data.methodType ? data : null;\n }\n\n protected getAuthenticatorFromRemediation(): IdxRemediationValue {\n const authenticator = this.remediation.value!\n .find(({ name }) => name === 'authenticator') as IdxRemediationValue;\n return authenticator;\n }\n\n private getMethodTypes(): IdxOption[] {\n const authenticator: IdxRemediationValue = this.getAuthenticatorFromRemediation();\n return authenticator.form!.value.find(({ name }) => name === 'methodType')?.options as IdxOption[];\n }\n\n getValuesAfterProceed(): T {\n this.values = super.getValuesAfterProceed();\n // remove used authenticatorData\n const authenticatorsData = this.values.authenticatorsData!\n .filter(data => compareAuthenticators(this.authenticator, data) !== true);\n return { ...this.values, authenticatorsData };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA;;AAEA;;AACA;;AAjBA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAaA;AACO,MAAMA,iBAAN,SAA6FC,sBAA7F,CAA2G;EAGhHC,WAAW,CAACC,WAAD,EAA8BC,MAAS,GAAG,EAA1C,EAAmD;IAC5D,MAAMD,WAAN,EAAmBC,MAAnB,EAD4D,CAG5D;;IACA,KAAKC,aAAL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GhB,aAAH,aAAGA,aAAH,uBAAGA,aAAa,CAAEgB,UAA5B;IACA;;IAED,MAAM;MAAEC,EAAF;MAAMC;IAAN,IAAuB,KAAKlB,aAAlC;IACA,MAAMM,IAAI,GAAG;MACXW,EADW;MAEXC,YAFW;MAGX,IAAIf,iBAAiB,IAAIA,iBAAzB,CAHW;MAIX,IAAIa,UAAU,IAAI;QAAEA;MAAF,CAAlB;IAJW,CAAb;IAOA,OAAOV,IAAI,CAACU,UAAL,GAAkBV,IAAlB,GAAyB,IAAhC;EACD;;EAESa,+BAA+B,GAAwB;IAAA;;IAC/D,MAAMnB,aAAa,GAAG,oCAAKF,WAAL,CAAiBsB,KAAjB,kBACd,CAAC;MAAEC;IAAF,CAAD,KAAcA,IAAI,KAAK,eADT,CAAtB;IAEA,OAAOrB,aAAP;EACD;;EAEOe,cAAc,GAAgB;IAAA;;IACpC,MAAMf,aAAkC,GAAG,KAAKmB,+BAAL,EAA3C;IACA,sBAAO,+BAAAnB,aAAa,CAACsB,IAAd,CAAoBF,KAApB,kBAA+B,CAAC;MAAEC;IAAF,CAAD,KAAcA,IAAI,KAAK,YAAtD,CAAP,gDAAO,YAAqEP,OAA5E;EACD;;EAEDS,qBAAqB,GAAM;IAAA;;IACzB,KAAKxB,MAAL,GAAc,MAAMwB,qBAAN,EAAd,CADyB,CAEzB;;IACA,MAAMlB,kBAAkB,GAAG,4DAAYA,kBAAZ,kBACjBC,IAAI,IAAI,iCAAsB,KAAKN,aAA3B,EAA0CM,IAA1C,MAAoD,IAD3C,CAA3B;IAEA,OAAO,EAAE,wBAAG,IAAH,CAAF;MAAkBD;IAAlB,CAAP;EACD;;AApF+G"}
1
+ {"version":3,"file":"AuthenticatorData.js","names":["AuthenticatorData","Remediator","constructor","remediation","values","authenticator","getAuthenticator","formatAuthenticatorData","authenticatorData","getAuthenticatorData","authenticatorsData","data","compareAuthenticators","mapAuthenticatorDataFromValues","push","canRemediate","some","getNextStep","authClient","common","options","getMethodTypes","methodType","isAuthenticator","id","enrollmentId","getAuthenticatorFromRemediation","value","name","form","getValuesAfterProceed"],"sources":["../../../../../lib/idx/remediators/Base/AuthenticatorData.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 { IdxRemediationValue, IdxOption, IdxRemediation, IdxAuthenticator } from '../../types/idx-js';\nimport { isAuthenticator } from '../../types';\nimport { compareAuthenticators } from '../../authenticator/util';\nimport { OktaAuthIdxInterface } from '../../../types';\n\nexport type AuthenticatorDataValues = RemediationValues & {\n methodType?: string;\n};\n\n// Base class - DO NOT expose static remediationName\nexport class AuthenticatorData<T extends AuthenticatorDataValues = AuthenticatorDataValues> extends Remediator<T> {\n authenticator: IdxAuthenticator;\n\n constructor(remediation: IdxRemediation, values: T = {} as T) {\n super(remediation, values);\n\n // set before other data calculation\n this.authenticator = this.getAuthenticator()!;\n\n this.formatAuthenticatorData();\n }\n\n protected formatAuthenticatorData() {\n const authenticatorData = this.getAuthenticatorData();\n if (authenticatorData) {\n this.values.authenticatorsData = this.values.authenticatorsData!.map(data => {\n if (compareAuthenticators(this.authenticator, data)) {\n return this.mapAuthenticatorDataFromValues(data);\n }\n return data;\n });\n } else {\n const data = this.mapAuthenticatorDataFromValues();\n if (data) {\n this.values.authenticatorsData!.push(data);\n }\n }\n }\n\n protected getAuthenticatorData() {\n return this.values.authenticatorsData!\n .find((data) => compareAuthenticators(this.authenticator, data));\n }\n\n canRemediate() {\n return this.values.authenticatorsData!\n .some(data => compareAuthenticators(this.authenticator, data));\n }\n\n // TODO: remove this override method in the next major version - OKTA-491236\n getNextStep(authClient: OktaAuthIdxInterface) {\n const common = super.getNextStep(authClient);\n const options = this.getMethodTypes();\n return { \n ...common, \n ...(options && { options }) \n };\n }\n\n protected mapAuthenticatorDataFromValues(authenticatorData?) {\n // add methodType to authenticatorData if it exists in values\n let { methodType, authenticator } = this.values;\n if (!methodType && isAuthenticator(authenticator)) {\n methodType = authenticator?.methodType;\n }\n \n const { id, enrollmentId } = this.authenticator;\n const data = { \n id,\n enrollmentId,\n ...(authenticatorData && authenticatorData),\n ...(methodType && { methodType }) \n };\n\n return data.methodType ? data : null;\n }\n\n protected getAuthenticatorFromRemediation(): IdxRemediationValue {\n const authenticator = this.remediation.value!\n .find(({ name }) => name === 'authenticator') as IdxRemediationValue;\n return authenticator;\n }\n\n private getMethodTypes(): IdxOption[] {\n const authenticator: IdxRemediationValue = this.getAuthenticatorFromRemediation();\n return authenticator.form!.value.find(({ name }) => name === 'methodType')?.options as IdxOption[];\n }\n\n getValuesAfterProceed(): T {\n this.values = super.getValuesAfterProceed();\n // remove used authenticatorData\n const authenticatorsData = this.values.authenticatorsData!\n .filter(data => compareAuthenticators(this.authenticator, data) !== true);\n return { ...this.values, authenticatorsData };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA;;AAEA;;AACA;;AAjBA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAaA;AACO,MAAMA,iBAAN,SAA6FC,sBAA7F,CAA2G;EAGhHC,WAAW,CAACC,WAAD,EAA8BC,MAAS,GAAG,EAA1C,EAAmD;IAC5D,MAAMD,WAAN,EAAmBC,MAAnB,EAD4D,CAG5D;;IACA,KAAKC,aAAL,GAAqB,KAAKC,gBAAL,EAArB;IAEA,KAAKC,uBAAL;EACD;;EAESA,uBAAuB,GAAG;IAClC,MAAMC,iBAAiB,GAAG,KAAKC,oBAAL,EAA1B;;IACA,IA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F;MAAMC;IAAN,IAAuB,KAAKpB,aAAlC;IACA,MAAMM,IAAI,GAAG;MACXa,EADW;MAEXC,YAFW;MAGX,IAAIjB,iBAAiB,IAAIA,iBAAzB,CAHW;MAIX,IAAIc,UAAU,IAAI;QAAEA;MAAF,CAAlB;IAJW,CAAb;IAOA,OAAOX,IAAI,CAACW,UAAL,GAAkBX,IAAlB,GAAyB,IAAhC;EACD;;EAESe,+BAA+B,GAAwB;IAAA;;IAC/D,MAAMrB,aAAa,GAAG,oCAAKF,WAAL,CAAiBwB,KAAjB,kBACd,CAAC;MAAEC;IAAF,CAAD,KAAcA,IAAI,KAAK,eADT,CAAtB;IAEA,OAAOvB,aAAP;EACD;;EAEOgB,cAAc,GAAgB;IAAA;;IACpC,MAAMhB,aAAkC,GAAG,KAAKqB,+BAAL,EAA3C;IACA,sBAAO,+BAAArB,aAAa,CAACwB,IAAd,CAAoBF,KAApB,kBAA+B,CAAC;MAAEC;IAAF,CAAD,KAAcA,IAAI,KAAK,YAAtD,CAAP,gDAAO,YAAqER,OAA5E;EACD;;EAEDU,qBAAqB,GAAM;IAAA;;IACzB,KAAK1B,MAAL,GAAc,MAAM0B,qBAAN,EAAd,CADyB,CAEzB;;IACA,MAAMpB,kBAAkB,GAAG,4DAAYA,kBAAZ,kBACjBC,IAAI,IAAI,IAAAC,2BAAA,EAAsB,KAAKP,aAA3B,EAA0CM,IAA1C,MAAoD,IAD3C,CAA3B;IAEA,OAAO,EAAE,wBAAG,IAAH,CAAF;MAAkBD;IAAlB,CAAP;EACD;;AApF+G"}
@@ -1 +1 @@
1
- {"version":3,"file":"Remediator.js","names":["Remediator","constructor","remediation","values","options","formatAuthenticators","authenticators","authenticator","hasAuthenticatorInList","some","existing","push","authenticatorsData","acc","length","getName","name","canRemediate","required","needed","key","hasData","getData","allValues","res","data","val","value","entry","i","getNextStep","_authClient","_context","inputs","getInputs","getAuthenticator","type","inputsFromRemediation","forEach","inputFromRemediation","input","visible","messages","alias","aliases","Array","isArray","getMessages","form","field","getValuesAfterProceed","inputsFromRemediator","relatesTo","authenticatorFromRemediation","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 { 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';\nimport { OktaAuthIdxInterface } from '../../../types';\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\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;AA0BA;AACO,MAAMA,UAAN,CAAkE;EAQvEC,WAAW,CACTC,WADS,EAETC,MAAS,GAAG,EAFH,EAGTC,OAAyB,GAAG,EAHnB,EAIT;IACA;IACA,KAAKD,MAAL,GAAc,EAAE,GAAGA;IAAL,CAAd;IACA,KAAKC,OAAL,GAAe,EAAE,GAAGA;IAAL,CAAf;IACA,KAAKC,oBAAL;IACA,KAAKH,WAAL,GAAmBA,WAAnB;EACD;;EAEOG,oBAAoB,GAAG;IAAA;;IAC7B,2BAAYC,cAAZ,GAA8B,2BAAYA,cAAZ,IAA8B,EAA5D,CAD6B,CAG7B;;IACA,2BAAYA,cAAZ,GAA6B,yDAAYA,cAAZ,kBAA+BC,aAAa,IAAI;MAC3E,OAAO,gCAAoBA,aAApB,CAAP;IACD,CAF4B,CAA7B,CAJ6B,CAQ7B;;IACA,IAAI,2BAAYA,aAAhB,EAA+B;MAC7B,MAAMA,aAAa,GAAG,gCA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lB,CAAP;IACD;;IACD,4BAAO,IAAP;EACD;;EAESmB,gBAAgB,GAAiC;IAAA;;IACzD;IACA,MAAMiB,SAAS,4BAAG,KAAKlD,WAAL,CAAiBkD,SAApB,0DAAG,sBAA4BzB,KAA9C;;IACA,IAAI,CAACyB,SAAL,EAAgB;MACd;IACD;;IAED,MAAMC,4BAA4B,GAAG,2CAAgC,KAAKnD,WAArC,CAArC;;IACA,IAAI,CAACmD,4BAAL,EAAmC;MACjC;MACA,OAAOD,SAAP;IACD,CAXwD,CAazD;IACA;;;IACA,MAAME,EAAE,GAAG,+BAAAD,4BAA4B,CAACL,IAA7B,CAAmCrB,KAAnC,kBACH,CAAC;MAAEX;IAAF,CAAD,KAAcA,IAAI,KAAK,IADpB,EAC2BW,KADtC;IAEA,MAAM4B,YAAY,kBAAG,gCAAAF,4BAA4B,CAACL,IAA7B,CAAmCrB,KAAnC,mBACb,CAAC;MAAEX;IAAF,CAAD,KAAcA,IAAI,KAAK,cADV,CAAH,gDAAG,YAC2BW,KADhD;IAGA,OAAO,EACL,GAAGyB,SADE;MAELE,EAFK;MAGLC;IAHK,CAAP;EAKD;;AA7NsE"}
1
+ {"version":3,"file":"Remediator.js","names":["Remediator","constructor","remediation","values","options","formatAuthenticators","authenticators","authenticator","formatAuthenticator","hasAuthenticatorInList","some","existing","compareAuthenticators","push","authenticatorsData","acc","length","getName","name","canRemediate","required","getRequiredValues","needed","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","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 { 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';\nimport { OktaAuthIdxInterface } from '../../../types';\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;AA0BA;AACO,MAAMA,UAAN,CAAkE;EAQvEC,WAAW,CACTC,WADS,EAETC,MAAS,GAAG,EAFH,EAGTC,OAAyB,GAAG,EAHnB,EAIT;IACA;IACA,KAAKD,MAAL,GAAc,EAAE,GAAGA;IAAL,CAAd;IACA,KAAKC,OAAL,GAAe,EAAE,GAAGA;IAAL,CAAf;IACA,KAAKC,oBAAL;IACA,KAAKH,WAAL,GAAmBA,WAAnB;EACD;;EAEOG,oBAAoB,GAAG;IAAA;;IAC7B,2BAAYC,cAAZ,GAA8B,2BAAYA,cAAZ,IAA8B,EAA5D,CAD6B,CAG7B;;IACA,2BAAYA,cAAZ,GAA6B,yDAAYA,cAAZ,kBAA+BC,aAAa,IAAI;MAC3E,OAAO,IAAAC,0BAAA,EAAoBD,aAApB,CAAP;IACD,CAF4B,CAA7B,CAJ6B,CAQ7B;;IACA,IAAI,2BAAYA,aAAhB,EAA+B;MAC7B,MAAMA,aAAa,GAAG,IAAAC,0BAAA,EAAoB,2BAAYD,aAAhC,CAAtB;MACA,MAAME,sBAAsB,GAAG,2BAAYH,cAAZ,CAA2BI,IAA3B,CAAgCC,QAAQ,IAAI;QACzE,OAAO,IAAAC,4BAAA,EAAsBL,aAAtB,EAAqCI,QAArC,CAAP;MACD,C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MAAMiB,SAAS,4BAAG,KAAKvD,WAAL,CAAiBuD,SAApB,0DAAG,sBAA4BzB,KAA9C;;IACA,IAAI,CAACyB,SAAL,EAAgB;MACd;IACD;;IAED,MAAMC,4BAA4B,GAAG,IAAAC,qCAAA,EAAgC,KAAKzD,WAArC,CAArC;;IACA,IAAI,CAACwD,4BAAL,EAAmC;MACjC;MACA,OAAOD,SAAP;IACD,CAXwD,CAazD;IACA;;;IACA,MAAMG,EAAE,GAAG,+BAAAF,4BAA4B,CAACL,IAA7B,CAAmCrB,KAAnC,kBACH,CAAC;MAAEd;IAAF,CAAD,KAAcA,IAAI,KAAK,IADpB,EAC2Bc,KADtC;IAEA,MAAM6B,YAAY,kBAAG,gCAAAH,4BAA4B,CAACL,IAA7B,CAAmCrB,KAAnC,mBACb,CAAC;MAAEd;IAAF,CAAD,KAAcA,IAAI,KAAK,cADV,CAAH,gDAAG,YAC2Bc,KADhD;IAGA,OAAO,EACL,GAAGyB,SADE;MAELG,EAFK;MAGLC;IAHK,CAAP;EAKD;;AA5NsE"}
@@ -1 +1 @@
1
- {"version":3,"file":"SelectAuthenticator.js","names":["SelectAuthenticator","Remediator","findMatchedOption","authenticators","options","option","authenticator","relatesTo","key","canRemediate","authenticatorFromRemediation","remediation","length","id","matchedOption","getNextStep","authClient","common","label","value","mapAuthenticator","remediationValue","selectedAuthenticator","selectedOption","form","name","getInputAuthenticator","type","getValuesAfterProceed","values"],"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 { IdxOption, IdxRemediationValue } from '../../types/idx-js';\nimport { Authenticator, isAuthenticator } from '../../types';\nimport { compareAuthenticators, findMatchedOption} from '../../authenticator/util';\nimport { OktaAuthIdxInterface } from '../../../types';\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 // TODO: remove this override method in the next major version - OKTA-491236\n getNextStep(authClient: OktaAuthIdxInterface) {\n const common = super.getNextStep(authClient);\n const authenticatorFromRemediation = getAuthenticatorFromRemediation(this.remediation);\n const options = authenticatorFromRemediation.options!.map(option => {\n const { \n label, \n relatesTo\n } = option as IdxOption;\n const key = relatesTo!.key!;\n return { label, value: key };\n });\n return { ...common, options };\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;AAcA;AACO,MAAMA,mBAAN,SACGC,sBADH,CACiB;EAItB;EACAC,iBAAiB,CAACC,cAAD,EAAiBC,OAAjB,EAA0B;IACzC,IAAIC,MAAJ;;IACA,KAAK,IAAIC,aAAT,IAA0BH,cAA1B,EAA0C;MACxCE,MAAM,GAAG,mBAAAD,OAAO,MAAP,CAAAA,OAAO,EACR,CAAC;QAAEG;MAAF,CAAD,KAAmBA,SAAS,CAACC,GAAV,KAAkBF,aAAa,CAACE,GAD3C,CAAhB;;MAEA,IAAIH,MAAJ,EAAY;QACV;MACD;IACF;;IACD,OAAOA,MAAP;EACD;;EAEDI,YAAY,GAAG;IACb,MAAM;MAAEN,cAAF;MAAkBG;IAAlB,yBAAoC,IAApC,CAAN;IACA,MAAMI,4BAA4B,GAAG,2CAAgC,KAAKC,WAArC,CAArC;IACA,MAAM;MAAEP;IAAF,IAAcM,4BAApB,CAHa,CAIb;;IACA,IAAI,CAACP,cAAD,IAAmB,CAACA,cAAc,CAACS,MAAvC,EAA+C;MA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MACLV,EAAE,EAAEU,cAAF,aAAEA,cAAF,uBAAE,+BAAAA,cAAc,CAAEJ,KAAhB,CAAsBK,IAAtB,CAA2BL,KAA3B,kBAAsC,CAAC;QAAEM;MAAF,CAAD,KAAcA,IAAI,KAAK,IAA7D,EAAmEN;IADlE,CAAP;EAGD;;EAEDO,qBAAqB,CAACf,WAAD,EAAc;IAAA;;IACjC,MAAMP,OAAO,GAAG,8BAAAO,WAAW,CAACP,OAAZ,kBAAwB,CAAC;MAAEc,KAAF;MAASX;IAAT,CAAD,KAA0B;MAChE,OAAO;QACLW,KADK;QAELC,KAAK,EAAEZ,SAAS,CAACC;MAFZ,CAAP;IAID,CALe,CAAhB;IAMA,OAAO;MAAEiB,IAAI,EAAE,eAAR;MAAyBE,IAAI,EAAE,QAA/B;MAAyCvB;IAAzC,CAAP;EACD;;EAEDwB,qBAAqB,GAAM;IAAA;;IACzB,KAAKC,MAAL,GAAc,MAAMD,qBAAN,EAAd,CADyB,CAEzB;;IACA,MAAMzB,cAAc,GAAG,iCAAC,2BAAYA,cAAb,kBACbG,aAAa,IAAI;MACvB,OAAO,kCAAsBA,aAAtB,EAAqC,KAAKgB,qBAA1C,MAAqE,IAA5E;IACD,CAHoB,CAAvB;IAIA,OAAO,EAAE,wBAAG,IAAH,CAAF;MAAkBnB;IAAlB,CAAP;EACD;;AA3FqB"}
1
+ {"version":3,"file":"SelectAuthenticator.js","names":["SelectAuthenticator","Remediator","findMatchedOption","authenticators","options","option","authenticator","relatesTo","key","canRemediate","authenticatorFromRemediation","getAuthenticatorFromRemediation","remediation","length","isAuthenticator","id","matchedOption","getNextStep","authClient","common","label","value","mapAuthenticator","remediationValue","selectedAuthenticator","selectedOption","form","name","getInputAuthenticator","type","getValuesAfterProceed","values","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 { IdxOption, IdxRemediationValue } from '../../types/idx-js';\nimport { Authenticator, isAuthenticator } from '../../types';\nimport { compareAuthenticators, findMatchedOption} from '../../authenticator/util';\nimport { OktaAuthIdxInterface } from '../../../types';\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 // TODO: remove this override method in the next major version - OKTA-491236\n getNextStep(authClient: OktaAuthIdxInterface) {\n const common = super.getNextStep(authClient);\n const authenticatorFromRemediation = getAuthenticatorFromRemediation(this.remediation);\n const options = authenticatorFromRemediation.options!.map(option => {\n const { \n label, \n relatesTo\n } = option as IdxOption;\n const key = relatesTo!.key!;\n return { label, value: key };\n });\n return { ...common, options };\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;AAcA;AACO,MAAMA,mBAAN,SACGC,sBADH,CACiB;EAItB;EACAC,iBAAiB,CAACC,cAAD,EAAiBC,OAAjB,EAA0B;IACzC,IAAIC,MAAJ;;IACA,KAAK,IAAIC,aAAT,IAA0BH,cAA1B,EAA0C;MACxCE,MAAM,GAAG,mBAAAD,OAAO,MAAP,CAAAA,OAAO,EACR,CAAC;QAAEG;MAAF,CAAD,KAAmBA,SAAS,CAACC,GAAV,KAAkBF,aAAa,CAACE,GAD3C,CAAhB;;MAEA,IAAIH,MAAJ,EAAY;QACV;MACD;IACF;;IACD,OAAOA,MAAP;EACD;;EAEDI,YAAY,GAAG;IACb,MAAM;MAAEN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GAA6BlB,aAA7B,CADsD,CACV;;MAC5C,OAAOA,aAAP;IACD;;IAED,MAAM;MAAEF;IAAF,IAAcmB,gBAApB;IACA,MAAME,cAAc,GAAG,IAAAvB,wBAAA,EAAkBC,cAAlB,EAAkCC,OAAlC,CAAvB;IACA,KAAKoB,qBAAL,GAA6BC,cAAc,CAAClB,SAA5C,CAXsD,CAWC;;IACvD,KAAKkB,cAAL,GAAsBA,cAAtB;IACA,OAAO;MACLV,EAAE,EAAEU,cAAF,aAAEA,cAAF,uBAAE,+BAAAA,cAAc,CAAEJ,KAAhB,CAAsBK,IAAtB,CAA2BL,KAA3B,kBAAsC,CAAC;QAAEM;MAAF,CAAD,KAAcA,IAAI,KAAK,IAA7D,EAAmEN;IADlE,CAAP;EAGD;;EAEDO,qBAAqB,CAAChB,WAAD,EAAc;IAAA;;IACjC,MAAMR,OAAO,GAAG,8BAAAQ,WAAW,CAACR,OAAZ,kBAAwB,CAAC;MAAEgB,KAAF;MAASb;IAAT,CAAD,KAA0B;MAChE,OAAO;QACLa,KADK;QAELC,KAAK,EAAEd,SAAS,CAACC;MAFZ,CAAP;IAID,CALe,CAAhB;IAMA,OAAO;MAAEmB,IAAI,EAAE,eAAR;MAAyBE,IAAI,EAAE,QAA/B;MAAyCzB;IAAzC,CAAP;EACD;;EAED0B,qBAAqB,GAAM;IAAA;;IACzB,KAAKC,MAAL,GAAc,MAAMD,qBAAN,EAAd,CADyB,CAEzB;;IACA,MAAM3B,cAAc,GAAG,iCAAC,2BAAYA,cAAb,kBACbG,aAAa,IAAI;MACvB,OAAO,IAAA0B,4BAAA,EAAsB1B,aAAtB,EAAqC,KAAKkB,qBAA1C,MAAqE,IAA5E;IACD,CAHoB,CAAvB;IAIA,OAAO,EAAE,wBAAG,IAAH,CAAF;MAAkBrB;IAAlB,CAAP;EACD;;AA3FqB"}
@@ -1 +1 @@
1
- {"version":3,"file":"VerifyAuthenticator.js","names":["VerifyAuthenticator","Remediator","constructor","remediation","values","authenticator","getNextStep","authClient","context","nextStep","authenticatorEnrollments","value","canRemediate","canVerify","mapCredentials","getInputCredentials","input","getInputs","getValuesAfterProceed","trimmedValues","valueKey"],"sources":["../../../../../lib/idx/remediators/Base/VerifyAuthenticator.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\nimport { Remediator, RemediationValues } from './Remediator';\nimport { getAuthenticator, Authenticator, AuthenticatorValues } from '../../authenticator';\nimport { IdxRemediation, IdxContext } from '../../types/idx-js';\nimport { NextStep } from '../../types';\nimport { OktaAuthIdxInterface } from '../../../types';\n\nexport type VerifyAuthenticatorValues = AuthenticatorValues & RemediationValues;\n\n// Base class - DO NOT expose static remediationName\nexport class VerifyAuthenticator<T extends VerifyAuthenticatorValues = VerifyAuthenticatorValues>\n extends Remediator<T> {\n\n authenticator: Authenticator<VerifyAuthenticatorValues>;\n\n constructor(remediation: IdxRemediation, values: T = {} as T) {\n super(remediation, values);\n this.authenticator = getAuthenticator(remediation);\n }\n\n getNextStep(authClient: OktaAuthIdxInterface, context?: IdxContext): NextStep {\n const nextStep = super.getNextStep(authClient, context);\n const authenticatorEnrollments = context?.authenticatorEnrollments?.value;\n\n return {\n ...nextStep,\n authenticatorEnrollments\n };\n }\n\n canRemediate() {\n return this.authenticator.canVerify(this.values);\n }\n\n mapCredentials() {\n return this.authenticator.mapCredentials(this.values);\n }\n\n getInputCredentials(input) {\n return this.authenticator.getInputs(input);\n }\n\n getValuesAfterProceed(): T {\n this.values = super.getValuesAfterProceed();\n let trimmedValues = Object.keys(this.values).filter(valueKey => valueKey !== 'credentials');\n return trimmedValues.reduce((values, valueKey) => ({...values, [valueKey]: this.values[valueKey]}), {} as T);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAaA;;AACA;;AAdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAWA;AACO,MAAMA,mBAAN,SACGC,sBADH,CACiB;EAItBC,WAAW,CAACC,WAAD,EAA8BC,MAAS,GAAG,EAA1C,EAAmD;IAC5D,MAAMD,WAAN,EAAmBC,MAAnB;IACA,KAAKC,aAAL,GAAqB,qCAAiBF,WAAjB,CAArB;EACD;;EAEDG,WAAW,CAACC,UAAD,EAAmCC,OAAnC,EAAmE;IAAA;;IAC5E,MAAMC,QAAQ,GAAG,MAAMH,WAAN,CAAkBC,UAAlB,EAA8BC,OAA9B,CAAjB;IACA,MAAME,wBAAwB,GAAGF,OAAH,aAAGA,OAAH,gDAAGA,OAAO,CAAEE,wBAAZ,0DAAG,sBAAmCC,KAApE;IAEA,OAAO,EACL,GAAGF,QADE;MAELC;IAFK,CAAP;EAID;;EAEDE,YAAY,GAAG;IACb,OAAO,KAAKP,aAAL,CAAmBQ,SAAnB,sBAA6B,IAA7B,EAAP;EACD;;EAEDC,cAAc,GAAG;IACf,OAAO,KAAKT,aAAL,CAAmBS,cAAnB,sBAAkC,IAAlC,EAAP;EACD;;EAEDC,mBAAmB,CAACC,KAAD,EAAQ;IACzB,OAAO,KAAKX,aAAL,CAAmBY,SAAnB,CAA6BD,KAA7B,CAAP;EACD;;EAEDE,qBAAqB,GAAM;IAAA;;IACzB,KAAKd,MAAL,GAAc,MAAMc,qBAAN,EAAd;IACA,IAAIC,aAAa,GAAG,wEAAY,IAAZ,mBAAgCC,QAAQ,IAAIA,QAAQ,KAAK,aAAzD,CAApB;IACA,OAAO,qBAAAD,aAAa,MAAb,CAAAA,aAAa,EAAQ,CAACf,MAAD,EAASgB,QAAT,MAAuB,EAAC,GAAGhB,MAAJ;MAAY,CAACgB,QAAD,GAAY,2BAAYA,QAAZ;IAAxB,CAAvB,CAAR,EAAgF,EAAhF,CAApB;EACD;;AAnCqB"}
1
+ {"version":3,"file":"VerifyAuthenticator.js","names":["VerifyAuthenticator","Remediator","constructor","remediation","values","authenticator","getAuthenticator","getNextStep","authClient","context","nextStep","authenticatorEnrollments","value","canRemediate","canVerify","mapCredentials","getInputCredentials","input","getInputs","getValuesAfterProceed","trimmedValues","valueKey"],"sources":["../../../../../lib/idx/remediators/Base/VerifyAuthenticator.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\nimport { Remediator, RemediationValues } from './Remediator';\nimport { getAuthenticator, Authenticator, AuthenticatorValues } from '../../authenticator';\nimport { IdxRemediation, IdxContext } from '../../types/idx-js';\nimport { NextStep } from '../../types';\nimport { OktaAuthIdxInterface } from '../../../types';\n\nexport type VerifyAuthenticatorValues = AuthenticatorValues & RemediationValues;\n\n// Base class - DO NOT expose static remediationName\nexport class VerifyAuthenticator<T extends VerifyAuthenticatorValues = VerifyAuthenticatorValues>\n extends Remediator<T> {\n\n authenticator: Authenticator<VerifyAuthenticatorValues>;\n\n constructor(remediation: IdxRemediation, values: T = {} as T) {\n super(remediation, values);\n this.authenticator = getAuthenticator(remediation);\n }\n\n getNextStep(authClient: OktaAuthIdxInterface, context?: IdxContext): NextStep {\n const nextStep = super.getNextStep(authClient, context);\n const authenticatorEnrollments = context?.authenticatorEnrollments?.value;\n\n return {\n ...nextStep,\n authenticatorEnrollments\n };\n }\n\n canRemediate() {\n return this.authenticator.canVerify(this.values);\n }\n\n mapCredentials() {\n return this.authenticator.mapCredentials(this.values);\n }\n\n getInputCredentials(input) {\n return this.authenticator.getInputs(input);\n }\n\n getValuesAfterProceed(): T {\n this.values = super.getValuesAfterProceed();\n let trimmedValues = Object.keys(this.values).filter(valueKey => valueKey !== 'credentials');\n return trimmedValues.reduce((values, valueKey) => ({...values, [valueKey]: this.values[valueKey]}), {} as T);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAaA;;AACA;;AAdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAWA;AACO,MAAMA,mBAAN,SACGC,sBADH,CACiB;EAItBC,WAAW,CAACC,WAAD,EAA8BC,MAAS,GAAG,EAA1C,EAAmD;IAC5D,MAAMD,WAAN,EAAmBC,MAAnB;IACA,KAAKC,aAAL,GAAqB,IAAAC,+BAAA,EAAiBH,WAAjB,CAArB;EACD;;EAEDI,WAAW,CAACC,UAAD,EAAmCC,OAAnC,EAAmE;IAAA;;IAC5E,MAAMC,QAAQ,GAAG,MAAMH,WAAN,CAAkBC,UAAlB,EAA8BC,OAA9B,CAAjB;IACA,MAAME,wBAAwB,GAAGF,OAAH,aAAGA,OAAH,gDAAGA,OAAO,CAAEE,wBAAZ,0DAAG,sBAAmCC,KAApE;IAEA,OAAO,EACL,GAAGF,QADE;MAELC;IAFK,CAAP;EAID;;EAEDE,YAAY,GAAG;IACb,OAAO,KAAKR,aAAL,CAAmBS,SAAnB,sBAA6B,IAA7B,EAAP;EACD;;EAEDC,cAAc,GAAG;IACf,OAAO,KAAKV,aAAL,CAAmBU,cAAnB,sBAAkC,IAAlC,EAAP;EACD;;EAEDC,mBAAmB,CAACC,KAAD,EAAQ;IACzB,OAAO,KAAKZ,aAAL,CAAmBa,SAAnB,CAA6BD,KAA7B,CAAP;EACD;;EAEDE,qBAAqB,GAAM;IAAA;;IACzB,KAAKf,MAAL,GAAc,MAAMe,qBAAN,EAAd;IACA,IAAIC,aAAa,GAAG,wEAAY,IAAZ,mBAAgCC,QAAQ,IAAIA,QAAQ,KAAK,aAAzD,CAApB;IACA,OAAO,qBAAAD,aAAa,MAAb,CAAAA,aAAa,EAAQ,CAAChB,MAAD,EAASiB,QAAT,MAAuB,EAAC,GAAGjB,MAAJ;MAAY,CAACiB,QAAD,GAAY,2BAAYA,QAAZ;IAAxB,CAAvB,CAAR,EAAgF,EAAhF,CAApB;EACD;;AAnCqB"}
@@ -4,20 +4,22 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
4
4
 
5
5
  exports.EnrollProfile = void 0;
6
6
 
7
+ var _values = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/values"));
8
+
7
9
  var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
8
10
 
9
11
  var _reduce = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
10
12
 
11
13
  var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
12
14
 
13
- var _values = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/values"));
14
-
15
15
  var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
16
16
 
17
17
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
18
18
 
19
19
  var _Remediator = require("./Base/Remediator");
20
20
 
21
+ var _authenticator = require("../authenticator");
22
+
21
23
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
22
24
 
23
25
  /*!
@@ -32,9 +34,27 @@ var _Remediator = require("./Base/Remediator");
32
34
  * See the License for the specific language governing permissions and limitations under the License.
33
35
  */
34
36
  class EnrollProfile extends _Remediator.Remediator {
37
+ constructor(remediation, values = {}, options = {}) {
38
+ super(remediation, values, options); // credentials are only required when Profile Enrollment policy requires them
39
+ // if credentials are included in the remediation, they are considered required
40
+ // otherwise it will be omitted
41
+
42
+ (0, _defineProperty2.default)(this, "authenticator", null);
43
+ const credentials = this.getCredentialsFromRemediation();
44
+
45
+ if (credentials) {
46
+ this.authenticator = this.authenticator = new _authenticator.OktaPassword({});
47
+ }
48
+ }
49
+
35
50
  canRemediate() {
36
51
  var _context, _context2;
37
52
 
53
+ // ensure credentials can be verified, if required
54
+ if (this.authenticator && !this.authenticator.canVerify((0, _values.default)(this))) {
55
+ return false;
56
+ }
57
+
38
58
  const userProfileFromValues = this.getData().userProfile;
39
59
 
40
60
  if (!userProfileFromValues) {
@@ -54,6 +74,14 @@ class EnrollProfile extends _Remediator.Remediator {
54
74
  }, true);
55
75
  }
56
76
 
77
+ getCredentialsFromRemediation() {
78
+ var _context3;
79
+
80
+ return (0, _find.default)(_context3 = this.remediation.value).call(_context3, ({
81
+ name
82
+ }) => name === 'credentials');
83
+ }
84
+
57
85
  mapUserProfile({
58
86
  form: {
59
87
  value: profileAttributes
@@ -73,14 +101,28 @@ class EnrollProfile extends _Remediator.Remediator {
73
101
  return data;
74
102
  }
75
103
 
104
+ mapCredentials() {
105
+ const val = this.authenticator && this.authenticator.mapCredentials((0, _values.default)(this));
106
+
107
+ if (!val) {
108
+ return;
109
+ }
110
+
111
+ return val;
112
+ }
113
+
76
114
  getInputUserProfile(input) {
77
115
  return [...input.form.value];
78
116
  }
79
117
 
118
+ getInputCredentials(input) {
119
+ return [...input.form.value];
120
+ }
121
+
80
122
  getErrorMessages(errorRemediation) {
81
- var _context3;
123
+ var _context4;
82
124
 
83
- return (0, _reduce.default)(_context3 = errorRemediation.value[0].form.value).call(_context3, (errors, field) => {
125
+ return (0, _reduce.default)(_context4 = errorRemediation.value[0].form.value).call(_context4, (errors, field) => {
84
126
  if (field.messages) {
85
127
  errors.push(field.messages.value[0].message);
86
128
  }
@@ -1 +1 @@
1
- {"version":3,"file":"EnrollProfile.js","names":["EnrollProfile","Remediator","canRemediate","userProfileFromValues","getData","userProfile","userProfileFromRemediation","remediation","value","name","form","curr","required","mapUserProfile","profileAttributes","attributeNames","data","attributeValues","attributeName","length","getInputUserProfile","input","getErrorMessages","errorRemediation","errors","field","messages","push","message"],"sources":["../../../../lib/idx/remediators/EnrollProfile.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 { IdxRemediationValue } from '../types/idx-js';\nimport { Remediator, RemediationValues } from './Base/Remediator';\n\nexport interface EnrollProfileValues extends RemediationValues {\n firstName?: string;\n lastName?: string;\n email?: string;\n}\n\nexport class EnrollProfile extends Remediator<EnrollProfileValues> {\n static remediationName = 'enroll-profile';\n\n canRemediate() {\n const userProfileFromValues = this.getData().userProfile;\n if (!userProfileFromValues) {\n return false;\n }\n // eslint-disable-next-line max-len\n const userProfileFromRemediation = this.remediation.value!.find(({ name }) => name === 'userProfile') as IdxRemediationValue;\n return userProfileFromRemediation.form!.value.reduce((canRemediate, curr) => {\n if (curr.required) {\n canRemediate = canRemediate && !!userProfileFromValues[curr.name];\n }\n return canRemediate;\n }, true);\n }\n\n mapUserProfile({form: { value: profileAttributes }}) {\n const attributeNames = profileAttributes.map(({name}) => name);\n const data = attributeNames.reduce((attributeValues, attributeName) => (\n this.values[attributeName] ? {\n ...attributeValues,\n [attributeName]: this.values[attributeName]\n } : attributeValues), {});\n if (Object.keys(data).length === 0) {\n return;\n }\n return data;\n }\n\n getInputUserProfile(input) {\n return [...input.form.value];\n }\n\n getErrorMessages(errorRemediation) {\n return errorRemediation.value[0].form.value.reduce((errors, field) => {\n if (field.messages) {\n errors.push(field.messages.value[0].message);\n }\n return errors;\n }, []);\n }\n}"],"mappings":";;;;;;;;;;;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AAD,EAAQ;IACzB,OAAO,CAAC,GAAGA,KAAK,CAACX,IAAN,CAAWF,KAAf,CAAP;EACD;;EAEDc,gBAAgB,CAACC,gBAAD,EAAmB;IAAA;;IACjC,OAAO,iCAAAA,gBAAgB,CAACf,KAAjB,CAAuB,CAAvB,EAA0BE,IAA1B,CAA+BF,KAA/B,kBAA4C,CAACgB,MAAD,EAASC,KAAT,KAAmB;MACpE,IAAIA,KAAK,CAACC,QAAV,EAAoB;QAClBF,MAAM,CAACG,IAAP,CAAYF,KAAK,CAACC,QAAN,CAAelB,KAAf,CAAqB,CAArB,EAAwBoB,OAApC;MACD;;MACD,OAAOJ,MAAP;IACD,CALM,EAKJ,EALI,CAAP;EAMD;;AA1CgE;;;8BAAtDxB,a,qBACc,gB"}
1
+ {"version":3,"file":"EnrollProfile.js","names":["EnrollProfile","Remediator","constructor","remediation","values","options","credentials","getCredentialsFromRemediation","authenticator","OktaPassword","canRemediate","canVerify","userProfileFromValues","getData","userProfile","userProfileFromRemediation","value","name","form","curr","required","mapUserProfile","profileAttributes","attributeNames","data","attributeValues","attributeName","length","mapCredentials","val","getInputUserProfile","input","getInputCredentials","getErrorMessages","errorRemediation","errors","field","messages","push","message"],"sources":["../../../../lib/idx/remediators/EnrollProfile.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 { IdxRemediation, IdxRemediationValue, IdxAuthenticator } from '../types/idx-js';\nimport { RemediateOptions } from '../../types';\nimport { Remediator, RemediationValues } from './Base/Remediator';\nimport { Authenticator, Credentials, OktaPassword } from '../authenticator';\n\nexport interface EnrollProfileValues extends RemediationValues {\n firstName?: string;\n lastName?: string;\n email?: string;\n credentials?: Credentials;\n password?: string;\n passcode?: string;\n}\n\nexport class EnrollProfile extends Remediator<EnrollProfileValues> {\n static remediationName = 'enroll-profile';\n\n authenticator: Authenticator<any> | null = null;\n\n constructor(\n remediation: IdxRemediation,\n values: EnrollProfileValues = {},\n options: RemediateOptions = {}\n ) {\n super(remediation, values, options);\n\n // credentials are only required when Profile Enrollment policy requires them\n // if credentials are included in the remediation, they are considered required\n // otherwise it will be omitted\n const credentials = this.getCredentialsFromRemediation();\n if (credentials) {\n this.authenticator = this.authenticator = new OktaPassword({} as IdxAuthenticator);\n }\n }\n\n canRemediate() {\n // ensure credentials can be verified, if required\n if (this.authenticator && !this.authenticator.canVerify(this.values)) {\n return false;\n }\n\n const userProfileFromValues = this.getData().userProfile;\n if (!userProfileFromValues) {\n return false;\n }\n // eslint-disable-next-line max-len\n const userProfileFromRemediation = this.remediation.value!.find(({ name }) => name === 'userProfile') as IdxRemediationValue;\n return userProfileFromRemediation.form!.value.reduce((canRemediate, curr) => {\n if (curr.required) {\n canRemediate = canRemediate && !!userProfileFromValues[curr.name];\n }\n return canRemediate;\n }, true);\n }\n\n getCredentialsFromRemediation () {\n return this.remediation.value!.find(({ name }) => name === 'credentials');\n }\n\n mapUserProfile({form: { value: profileAttributes }}) {\n const attributeNames = profileAttributes.map(({name}) => name);\n const data = attributeNames.reduce((attributeValues, attributeName) => (\n this.values[attributeName] ? {\n ...attributeValues,\n [attributeName]: this.values[attributeName]\n } : attributeValues), {});\n if (Object.keys(data).length === 0) {\n return;\n }\n return data;\n }\n\n mapCredentials() {\n const val = this.authenticator && this.authenticator.mapCredentials(this.values);\n if (!val) {\n return;\n }\n return val;\n }\n\n getInputUserProfile(input) {\n return [...input.form.value];\n }\n\n getInputCredentials(input) {\n return [...input.form.value];\n }\n\n getErrorMessages(errorRemediation) {\n return errorRemediation.value[0].form.value.reduce((errors, field) => {\n if (field.messages) {\n errors.push(field.messages.value[0].message);\n }\n return errors;\n }, []);\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;AAgBA;;AACA;;AAjBA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAiBO,MAAMA,aAAN,SAA4BC,sBAA5B,CAA4D;EAKjEC,WAAW,CACTC,WADS,EAETC,MAA2B,GAAG,EAFrB,EAGTC,OAAyB,GAAG,EAHnB,EAIT;IACA,MAAMF,WAAN,EAAmBC,MAAnB,EAA2BC,OAA3B,EADA,CAGA;IACA;IACA;;IALA,qDANyC,IAMzC;IAMA,MAAMC,WAAW,GAAG,KAAKC,6BAAL,EAApB;;IACA,IAAID,WAAJ,EAAiB;MACf,KAAKE,aAAL,GAAqB,KAAKA,aAAL,GAAqB,IAAIC,2BAAJ,CAAiB,EAAjB,CAA1C;IACD;EACF;;EAEDC,YAAY,GAAG;IAAA;;IACb;IACA,IAAI,KAAKF,aAAL,IAAsB,CAAC,KAAKA,aAAL,CAAmBG,SAAnB,sBAA6B,IAA7B,EAA3B,EAAsE;MACpE,OAAO,KAAP;IACD;;IAED,MAAMC,qBAAqB,GAAG,KAAKC,OAAL,GAAeC,WAA7C;;IACA,IAAI,CAACF,qBAAL,EAA4B;MAC1B,OAAO,KAAP;IACD,CATY,CAUb;;;IACA,MAAMG,0BAA0B,GAAG,mCAAKZ,WAAL,CAAiBa,KAAjB,iBAA6B,CAAC;MAAEC;IAAF,CAAD,KAAcA,IAAI,KAAK,aAApD,CAAnC;IACA,OAAO,iCAAAF,0BAA0B,CAACG,IAA3B,CAAiCF,KAAjC,kBAA8C,CAACN,YAAD,EAAeS,IAAf,KAAwB;MAC3E,IAAIA,IAAI,CAACC,QAAT,EAAmB;QACjBV,YAAY,GAAGA,YAAY,IAAI,CAAC,CAACE,qBAAqB,CAACO,IAAI,CAACF,IAAN,CAAtD;MACD;;MACD,OAAOP,YAA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KAA/B,kBAA4C,CAACmB,MAAD,EAASC,KAAT,KAAmB;MACpE,IAAIA,KAAK,CAACC,QAAV,EAAoB;QAClBF,MAAM,CAACG,IAAP,CAAYF,KAAK,CAACC,QAAN,CAAerB,KAAf,CAAqB,CAArB,EAAwBuB,OAApC;MACD;;MACD,OAAOJ,MAAP;IACD,CALM,EAKJ,EALI,CAAP;EAMD;;AAjFgE;;;8BAAtDnC,a,qBACc,gB"}
@@ -2,8 +2,8 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
4
 
5
- exports.unwrapFormValue = unwrapFormValue;
6
5
  exports.hasValidInputValue = hasValidInputValue;
6
+ exports.unwrapFormValue = unwrapFormValue;
7
7
 
8
8
  var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
9
9
 
@@ -1 +1 @@
1
- {"version":3,"file":"SelectAuthenticatorAuthenticate.js","names":["SelectAuthenticatorAuthenticate","SelectAuthenticator","constructor","remediation","values","options","isRecoveryFlow","flow","hasPasswordInOptions","some","relatesTo","key","AuthenticatorKey","OKTA_PASSWORD","password","authenticators"],"sources":["../../../../lib/idx/remediators/SelectAuthenticatorAuthenticate.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\nimport { SelectAuthenticator, SelectAuthenticatorValues } from './Base/SelectAuthenticator';\nimport { getAuthenticatorFromRemediation } from './util';\nimport { IdxRemediation } from '../types/idx-js';\nimport { AuthenticatorKey, Authenticator, RemediateOptions } from '../types';\n\nexport type SelectAuthenticatorAuthenticateValues = SelectAuthenticatorValues & {\n password?: string;\n};\n\nexport class SelectAuthenticatorAuthenticate extends SelectAuthenticator<SelectAuthenticatorAuthenticateValues> {\n static remediationName = 'select-authenticator-authenticate';\n\n constructor(\n remediation: IdxRemediation, \n values: SelectAuthenticatorValues = {}, \n options: RemediateOptions = {}\n ) {\n super(remediation, values, options);\n\n // Preset password authenticator to trigger recover action\n const isRecoveryFlow = this.options.flow === 'recoverPassword';\n const hasPasswordInOptions = getAuthenticatorFromRemediation(remediation)\n .options?.some(({ relatesTo }) => relatesTo?.key === AuthenticatorKey.OKTA_PASSWORD);\n if (hasPasswordInOptions && (isRecoveryFlow || this.values.password)) {\n this.values.authenticators = [\n ...this.values.authenticators || [],\n { key: AuthenticatorKey.OKTA_PASSWORD }\n ] as Authenticator[];\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAaA;;AACA;;AAEA;;AAhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAYO,MAAMA,+BAAN,SAA8CC,wCAA9C,CAAyG;EAG9GC,WAAW,CACTC,WADS,EAETC,MAAiC,GAAG,EAF3B,EAGTC,OAAyB,GAAG,EAHnB,EAIT;IAAA;;IACA,MAAMF,WAAN,EAAmBC,MAAnB,EAA2BC,OAA3B,EADA,CAGA;;IACA,MAAMC,cAAc,GAAG,KAAKD,OAAL,CAAaE,IAAb,KAAsB,iBAA7C;IACA,MAAMC,oBAAoB,4BAAG,2CAAgCL,WAAhC,EAC1BE,OADuB,0DAAG,sBACjBI,IADiB,CACZ,CAAC;MAAEC;IAAF,CAAD,KAAmB,CAAAA,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAEC,GAAX,MAAmBC,wBAAiBC,aAD3C,CAA7B;;IAEA,IAAIL,oBAAoB,KAAKF,cAAc,IAAI,2BAAYQ,QAAnC,CAAxB,EAAsE;MACpE,2BAAYC,cAAZ,GAA6B,CAC3B,IAAG,2BAAYA,cAAZ,IAA8B,EAAjC,CAD2B,EAE3B;QAAEJ,GAAG,EAAEC,wBAAiBC;MAAxB,CAF2B,CAA7B;IAID;EACF;;AApB6G;;;8BAAnGb,+B,qBACc,mC"}
1
+ {"version":3,"file":"SelectAuthenticatorAuthenticate.js","names":["SelectAuthenticatorAuthenticate","SelectAuthenticator","constructor","remediation","values","options","isRecoveryFlow","flow","hasPasswordInOptions","getAuthenticatorFromRemediation","some","relatesTo","key","AuthenticatorKey","OKTA_PASSWORD","password","authenticators"],"sources":["../../../../lib/idx/remediators/SelectAuthenticatorAuthenticate.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\nimport { SelectAuthenticator, SelectAuthenticatorValues } from './Base/SelectAuthenticator';\nimport { getAuthenticatorFromRemediation } from './util';\nimport { IdxRemediation } from '../types/idx-js';\nimport { AuthenticatorKey, Authenticator, RemediateOptions } from '../types';\n\nexport type SelectAuthenticatorAuthenticateValues = SelectAuthenticatorValues & {\n password?: string;\n};\n\nexport class SelectAuthenticatorAuthenticate extends SelectAuthenticator<SelectAuthenticatorAuthenticateValues> {\n static remediationName = 'select-authenticator-authenticate';\n\n constructor(\n remediation: IdxRemediation, \n values: SelectAuthenticatorValues = {}, \n options: RemediateOptions = {}\n ) {\n super(remediation, values, options);\n\n // Preset password authenticator to trigger recover action\n const isRecoveryFlow = this.options.flow === 'recoverPassword';\n const hasPasswordInOptions = getAuthenticatorFromRemediation(remediation)\n .options?.some(({ relatesTo }) => relatesTo?.key === AuthenticatorKey.OKTA_PASSWORD);\n if (hasPasswordInOptions && (isRecoveryFlow || this.values.password)) {\n this.values.authenticators = [\n ...this.values.authenticators || [],\n { key: AuthenticatorKey.OKTA_PASSWORD }\n ] as Authenticator[];\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAaA;;AACA;;AAEA;;AAhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAYO,MAAMA,+BAAN,SAA8CC,wCAA9C,CAAyG;EAG9GC,WAAW,CACTC,WADS,EAETC,MAAiC,GAAG,EAF3B,EAGTC,OAAyB,GAAG,EAHnB,EAIT;IAAA;;IACA,MAAMF,WAAN,EAAmBC,MAAnB,EAA2BC,OAA3B,EADA,CAGA;;IACA,MAAMC,cAAc,GAAG,KAAKD,OAAL,CAAaE,IAAb,KAAsB,iBAA7C;IACA,MAAMC,oBAAoB,4BAAG,IAAAC,qCAAA,EAAgCN,WAAhC,EAC1BE,OADuB,0DAAG,sBACjBK,IADiB,CACZ,CAAC;MAAEC;IAAF,CAAD,KAAmB,CAAAA,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAEC,GAAX,MAAmBC,uBAAA,CAAiBC,aAD3C,CAA7B;;IAEA,IAAIN,oBAAoB,KAAKF,cAAc,IAAI,2BAAYS,QAAnC,CAAxB,EAAsE;MACpE,2BAAYC,cAAZ,GAA6B,CAC3B,IAAG,2BAAYA,cAAZ,IAA8B,EAAjC,CAD2B,EAE3B;QAAEJ,GAAG,EAAEC,uBAAA,CAAiBC;MAAxB,CAF2B,CAA7B;IAID;EACF;;AApB6G;;;8BAAnGd,+B,qBACc,mC"}
@@ -1 +1 @@
1
- {"version":3,"file":"SelectEnrollmentChannel.js","names":["SelectEnrollmentChannel","Remediator","canRemediate","channel","authenticator","id","getNextStep","authClient","context","common","options","getChannels","currentAuthenticator","value","remediation","remediationValue","form","name","getData","stateHandle","getValuesAfterProceed","values","authenticators","filterKey","trimmedValues","valueKey"],"sources":["../../../../lib/idx/remediators/SelectEnrollmentChannel.ts"],"sourcesContent":["/*!\n * Copyright (c) 2021-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 './Base/Remediator';\nimport { IdxRemediationValueForm, IdxOption, IdxRemediationValue, IdxContext } from '../types/idx-js';\nimport { Authenticator } from '../types';\nimport { getAuthenticatorFromRemediation } from './util';\nimport { OktaAuthIdxInterface } from '../../types';\n\n\nexport type SelectEnrollmentChannelValues = RemediationValues & {\n channel?: string;\n};\n\nexport class SelectEnrollmentChannel extends Remediator<SelectEnrollmentChannelValues> {\n static remediationName = 'select-enrollment-channel';\n\n canRemediate() {\n if (this.values.channel) {\n return true;\n }\n\n if (this.values.authenticator) {\n const { id, channel } = this.values.authenticator as Authenticator;\n if (!!id && !!channel) {\n return true;\n }\n }\n\n return false;\n }\n\n getNextStep(authClient: OktaAuthIdxInterface, context: IdxContext) {\n const common = super.getNextStep(authClient, context);\n const options = this.getChannels();\n const authenticator = context.currentAuthenticator.value;\n return {\n ...common,\n // TODO: remove options field in the next major version - OKTA-491236\n ...(options && { options }),\n authenticator,\n };\n }\n\n private getChannels(): IdxOption[] | undefined {\n const authenticator: IdxRemediationValue = getAuthenticatorFromRemediation(this.remediation);\n const remediationValue = authenticator.value as IdxRemediationValueForm;\n return remediationValue.form.value.find(({ name }) => name === 'channel')?.options;\n }\n\n getData() {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const remediationValue = this.remediation!.value![0].value as IdxRemediationValueForm;\n return {\n authenticator: {\n id: remediationValue.form.value[0].value,\n channel: (this.values.authenticator as Authenticator)?.channel || this.values.channel,\n },\n stateHandle: this.values.stateHandle,\n\n };\n }\n\n getValuesAfterProceed(): SelectEnrollmentChannelValues {\n this.values = super.getValuesAfterProceed();\n delete this.values.authenticators; // required to prevent infinite loops from auto-remediating via values\n const filterKey = this.values.channel ? 'channel' : 'authenticator';\n let trimmedValues = Object.keys(this.values).filter(valueKey => valueKey !== filterKey);\n return trimmedValues.reduce((values, valueKey) => ({...values, [valueKey]: this.values[valueKey]}), {});\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAaA;;AAGA;;AAhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAcO,MAAMA,uBAAN,SAAsCC,sBAAtC,CAAgF;EAGrFC,YAAY,GAAG;IACb,IAAI,2BAAYC,OAAhB,EAAyB;MACvB,OAAO,IAAP;IACD;;IAED,IAAI,2BAAYC,aAAhB,EAA+B;MAC7B,MAAM;QAAEC,EAAF;QAAMF;MAAN,IAAkB,2BAAYC,aAApC;;MACA,IAAI,CAAC,CAACC,EAAF,IAAQ,CAAC,CAACF,OAAd,EAAuB;QACrB,OAAO,IAAP;MACD;IACF;;IAED,OAAO,KAAP;EACD;;EAEDG,WAAW,CAACC,UAAD,EAAmCC,OAAnC,EAAwD;IACjE,MAAMC,MAAM,GAAG,MAAMH,WAAN,CAAkBC,UAAlB,EAA8BC,OAA9B,CAAf;IACA,MAAME,OAAO,GAAG,KAAKC,WAAL,EAAhB;IACA,MAAMP,aAAa,GAAGI,OAAO,CAACI,oBAAR,CAA6BC,KAAnD;IACA,OAAO,EACL,GAAGJ,MADE;MAEL;MACA,IAAIC,OAAO,IAAI;QAAEA;MAAF,CAAf,CAHK;MAILN;IAJK,CAAP;EAMD;;EAEOO,WAAW,GAA4B;IAAA;;IAC7C,MAAMP,aAAkC,GAAG,2CAAgC,KAAKU,WAArC,CAA3C;IACA,MAAMC,gBAAgB,GAAGX,aAAa,CAACS,KAAvC;IACA,gCAAO,8BAAAE,gBAAgB,CAACC,IAAjB,CAAsBH,KAAtB,iBAAiC,CAAC;MAAEI;IAAF,CAAD,KAAcA,IAAI,KAAK,SAAxD,CAAP,0DAAO,sBAAoEP,OAA3E;EACD;;EAEDQ,OAAO,GAAG;IAAA;;IACR;IACA,MAAMH,gBAAgB,GAAG,KAAKD,WAAL,CAAkBD,KAAlB,CAAyB,CAAzB,EAA4BA,KAArD;IACA,OAAO;MACLT,aAAa,EAAE;QACbC,EAAE,EAAEU,gBAAgB,CAACC,IAAjB,CAAsBH,KAAtB,CAA4B,CAA5B,EAA+BA,KADtB;QAEbV,OAAO,EAAE,0BAAC,2BAAYC,aAAb,gFAA8CD,OAA9C,KAAyD,2BAAYA;MAFjE,CADV;MAKLgB,WAAW,EAAE,2BAAYA;IALpB,CAAP;EAQD;;EAEDC,qBAAqB,GAAkC;IAAA;;IACrD,KAAKC,MAAL,GAAc,MAAMD,qBAAN,EAAd;IACA,OAAO,2BAAYE,cAAnB,CAFqD,CAEf;;IACtC,MAAMC,SAAS,GAAG,2BAAYpB,OAAZ,GAAsB,SAAtB,GAAkC,eAApD;IACA,IAAIqB,aAAa,GAAG,yEAAY,IAAZ,oBAAgCC,QAAQ,IAAIA,QAAQ,KAAKF,SAAzD,CAApB;IACA,OAAO,qBAAAC,aAAa,MAAb,CAAAA,aAAa,EAAQ,CAACH,MAAD,EAASI,QAAT,MAAuB,EAAC,GAAGJ,MAAJ;MAAY,CAACI,QAAD,GAAY,2BAAYA,QAAZ;IAAxB,CAAvB,CAAR,EAAgF,EAAhF,CAApB;EACD;;AAvDoF;;;8BAA1EzB,uB,qBACc,2B"}
1
+ {"version":3,"file":"SelectEnrollmentChannel.js","names":["SelectEnrollmentChannel","Remediator","canRemediate","channel","authenticator","id","getNextStep","authClient","context","common","options","getChannels","currentAuthenticator","value","getAuthenticatorFromRemediation","remediation","remediationValue","form","name","getData","stateHandle","getValuesAfterProceed","values","authenticators","filterKey","trimmedValues","valueKey"],"sources":["../../../../lib/idx/remediators/SelectEnrollmentChannel.ts"],"sourcesContent":["/*!\n * Copyright (c) 2021-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 './Base/Remediator';\nimport { IdxRemediationValueForm, IdxOption, IdxRemediationValue, IdxContext } from '../types/idx-js';\nimport { Authenticator } from '../types';\nimport { getAuthenticatorFromRemediation } from './util';\nimport { OktaAuthIdxInterface } from '../../types';\n\n\nexport type SelectEnrollmentChannelValues = RemediationValues & {\n channel?: string;\n};\n\nexport class SelectEnrollmentChannel extends Remediator<SelectEnrollmentChannelValues> {\n static remediationName = 'select-enrollment-channel';\n\n canRemediate() {\n if (this.values.channel) {\n return true;\n }\n\n if (this.values.authenticator) {\n const { id, channel } = this.values.authenticator as Authenticator;\n if (!!id && !!channel) {\n return true;\n }\n }\n\n return false;\n }\n\n getNextStep(authClient: OktaAuthIdxInterface, context: IdxContext) {\n const common = super.getNextStep(authClient, context);\n const options = this.getChannels();\n const authenticator = context.currentAuthenticator.value;\n return {\n ...common,\n // TODO: remove options field in the next major version - OKTA-491236\n ...(options && { options }),\n authenticator,\n };\n }\n\n private getChannels(): IdxOption[] | undefined {\n const authenticator: IdxRemediationValue = getAuthenticatorFromRemediation(this.remediation);\n const remediationValue = authenticator.value as IdxRemediationValueForm;\n return remediationValue.form.value.find(({ name }) => name === 'channel')?.options;\n }\n\n getData() {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const remediationValue = this.remediation!.value![0].value as IdxRemediationValueForm;\n return {\n authenticator: {\n id: remediationValue.form.value[0].value,\n channel: (this.values.authenticator as Authenticator)?.channel || this.values.channel,\n },\n stateHandle: this.values.stateHandle,\n\n };\n }\n\n getValuesAfterProceed(): SelectEnrollmentChannelValues {\n this.values = super.getValuesAfterProceed();\n delete this.values.authenticators; // required to prevent infinite loops from auto-remediating via values\n const filterKey = this.values.channel ? 'channel' : 'authenticator';\n let trimmedValues = Object.keys(this.values).filter(valueKey => valueKey !== filterKey);\n return trimmedValues.reduce((values, valueKey) => ({...values, [valueKey]: this.values[valueKey]}), {});\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAaA;;AAGA;;AAhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAcO,MAAMA,uBAAN,SAAsCC,sBAAtC,CAAgF;EAGrFC,YAAY,GAAG;IACb,IAAI,2BAAYC,OAAhB,EAAyB;MACvB,OAAO,IAAP;IACD;;IAED,IAAI,2BAAYC,aAAhB,EAA+B;MAC7B,MAAM;QAAEC,EAAF;QAAMF;MAAN,IAAkB,2BAAYC,aAApC;;MACA,IAAI,CAAC,CAACC,EAAF,IAAQ,CAAC,CAACF,OAAd,EAAuB;QACrB,OAAO,IAAP;MACD;IACF;;IAED,OAAO,KAAP;EACD;;EAEDG,WAAW,CAACC,UAAD,EAAmCC,OAAnC,EAAwD;IACjE,MAAMC,MAAM,GAAG,MAAMH,WAAN,CAAkBC,UAAlB,EAA8BC,OAA9B,CAAf;IACA,MAAME,OAAO,GAAG,KAAKC,WAAL,EAAhB;IACA,MAAMP,aAAa,GAAGI,OAAO,CAACI,oBAAR,CAA6BC,KAAnD;IACA,OAAO,EACL,GAAGJ,MADE;MAEL;MACA,IAAIC,OAAO,IAAI;QAAEA;MAAF,CAAf,CAHK;MAILN;IAJK,CAAP;EAMD;;EAEOO,WAAW,GAA4B;IAAA;;IAC7C,MAAMP,aAAkC,GAAG,IAAAU,qCAAA,EAAgC,KAAKC,WAArC,CAA3C;IACA,MAAMC,gBAAgB,GAAGZ,aAAa,CAACS,KAAvC;IACA,gCAAO,8BAAAG,gBAAgB,CAACC,IAAjB,CAAsBJ,KAAtB,iBAAiC,CAAC;MAAEK;IAAF,CAAD,KAAcA,IAAI,KAAK,SAAxD,CAAP,0DAAO,sBAAoER,OAA3E;EACD;;EAEDS,OAAO,GAAG;IAAA;;IACR;IACA,MAAMH,gBAAgB,GAAG,KAAKD,WAAL,CAAkBF,KAAlB,CAAyB,CAAzB,EAA4BA,KAArD;IACA,OAAO;MACLT,aAAa,EAAE;QACbC,EAAE,EAAEW,gBAAgB,CAACC,IAAjB,CAAsBJ,KAAtB,CAA4B,CAA5B,EAA+BA,KADtB;QAEbV,OAAO,EAAE,0BAAC,2BAAYC,aAAb,gFAA8CD,OAA9C,KAAyD,2BAAYA;MAFjE,CADV;MAKLiB,WAAW,EAAE,2BAAYA;IALpB,CAAP;EAQD;;EAEDC,qBAAqB,GAAkC;IAAA;;IACrD,KAAKC,MAAL,GAAc,MAAMD,qBAAN,EAAd;IACA,OAAO,2BAAYE,cAAnB,CAFqD,CAEf;;IACtC,MAAMC,SAAS,GAAG,2BAAYrB,OAAZ,GAAsB,SAAtB,GAAkC,eAApD;IACA,IAAIsB,aAAa,GAAG,yEAAY,IAAZ,oBAAgCC,QAAQ,IAAIA,QAAQ,KAAKF,SAAzD,CAApB;IACA,OAAO,qBAAAC,aAAa,MAAb,CAAAA,aAAa,EAAQ,CAACH,MAAD,EAASI,QAAT,MAAuB,EAAC,GAAGJ,MAAJ;MAAY,CAACI,QAAD,GAAY,2BAAYA,QAAZ;IAAxB,CAAvB,CAAR,EAAgF,EAAhF,CAApB;EACD;;AAvDoF;;;8BAA1E1B,uB,qBACc,2B"}
@@ -3,9 +3,9 @@
3
3
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
4
 
5
5
  exports.getAllValues = getAllValues;
6
+ exports.getAuthenticatorFromRemediation = getAuthenticatorFromRemediation;
6
7
  exports.getRequiredValues = getRequiredValues;
7
8
  exports.titleCase = titleCase;
8
- exports.getAuthenticatorFromRemediation = getAuthenticatorFromRemediation;
9
9
 
10
10
  var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
11
11