@okta/okta-auth-js 6.0.0 → 6.3.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 (398) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.md +58 -27
  3. package/cjs/AuthStateManager.js +21 -7
  4. package/cjs/AuthStateManager.js.map +1 -1
  5. package/cjs/OktaAuth.js +96 -40
  6. package/cjs/OktaAuth.js.map +1 -1
  7. package/cjs/OktaUserAgent.js +2 -2
  8. package/cjs/PromiseQueue.js +14 -3
  9. package/cjs/PromiseQueue.js.map +1 -1
  10. package/cjs/SavedObject.js +4 -2
  11. package/cjs/SavedObject.js.map +1 -1
  12. package/cjs/ServiceManager.js +195 -0
  13. package/cjs/ServiceManager.js.map +1 -0
  14. package/cjs/StorageManager.js +13 -8
  15. package/cjs/StorageManager.js.map +1 -1
  16. package/cjs/TokenManager.js +34 -32
  17. package/cjs/TokenManager.js.map +1 -1
  18. package/cjs/TransactionManager.js +17 -5
  19. package/cjs/TransactionManager.js.map +1 -1
  20. package/cjs/browser/browserStorage.js +48 -33
  21. package/cjs/browser/browserStorage.js.map +1 -1
  22. package/cjs/browser/fingerprint.js +9 -3
  23. package/cjs/browser/fingerprint.js.map +1 -1
  24. package/cjs/builderUtil.js +4 -2
  25. package/cjs/builderUtil.js.map +1 -1
  26. package/cjs/clock.js +5 -1
  27. package/cjs/clock.js.map +1 -1
  28. package/cjs/crypto/base64.js +18 -0
  29. package/cjs/crypto/base64.js.map +1 -1
  30. package/cjs/crypto/index.js +6 -4
  31. package/cjs/crypto/index.js.map +1 -1
  32. package/cjs/crypto/node.js +19 -13
  33. package/cjs/crypto/node.js.map +1 -1
  34. package/cjs/crypto/oidcHash.js +5 -1
  35. package/cjs/crypto/oidcHash.js.map +1 -1
  36. package/cjs/crypto/webauthn.js +101 -0
  37. package/cjs/crypto/webauthn.js.map +1 -0
  38. package/cjs/crypto/webcrypto.js +3 -1
  39. package/cjs/crypto/webcrypto.js.map +1 -1
  40. package/cjs/errors/AuthApiError.js +1 -1
  41. package/cjs/errors/AuthPollStopError.js +1 -1
  42. package/cjs/errors/AuthSdkError.js +1 -1
  43. package/cjs/errors/CustomError.js +5 -1
  44. package/cjs/errors/CustomError.js.map +1 -1
  45. package/cjs/errors/OAuthError.js +1 -1
  46. package/cjs/errors/index.js +1 -1
  47. package/cjs/fetch/fetchRequest.js +18 -6
  48. package/cjs/fetch/fetchRequest.js.map +1 -1
  49. package/cjs/http/headers.js.map +1 -1
  50. package/cjs/http/index.js +4 -2
  51. package/cjs/http/index.js.map +1 -1
  52. package/cjs/http/request.js +9 -5
  53. package/cjs/http/request.js.map +1 -1
  54. package/cjs/idx/authenticate.js.map +1 -1
  55. package/cjs/idx/authenticator/Authenticator.js.map +1 -1
  56. package/cjs/idx/authenticator/OktaPassword.js +12 -3
  57. package/cjs/idx/authenticator/OktaPassword.js.map +1 -1
  58. package/cjs/idx/authenticator/OktaVerifyTotp.js +9 -1
  59. package/cjs/idx/authenticator/OktaVerifyTotp.js.map +1 -1
  60. package/cjs/idx/authenticator/SecurityQuestionEnrollment.js +15 -2
  61. package/cjs/idx/authenticator/SecurityQuestionEnrollment.js.map +1 -1
  62. package/cjs/idx/authenticator/SecurityQuestionVerification.js +10 -2
  63. package/cjs/idx/authenticator/SecurityQuestionVerification.js.map +1 -1
  64. package/cjs/idx/authenticator/VerificationCodeAuthenticator.js +13 -3
  65. package/cjs/idx/authenticator/VerificationCodeAuthenticator.js.map +1 -1
  66. package/cjs/idx/authenticator/WebauthnEnrollment.js +51 -0
  67. package/cjs/idx/authenticator/WebauthnEnrollment.js.map +1 -0
  68. package/cjs/idx/authenticator/WebauthnVerification.js +60 -0
  69. package/cjs/idx/authenticator/WebauthnVerification.js.map +1 -0
  70. package/cjs/idx/authenticator/getAuthenticator.js +13 -1
  71. package/cjs/idx/authenticator/getAuthenticator.js.map +1 -1
  72. package/cjs/idx/authenticator/index.js +34 -6
  73. package/cjs/idx/authenticator/index.js.map +1 -1
  74. package/cjs/idx/authenticator/util.js +64 -0
  75. package/cjs/idx/authenticator/util.js.map +1 -0
  76. package/cjs/idx/cancel.js.map +1 -1
  77. package/cjs/idx/emailVerify.js +1 -1
  78. package/cjs/idx/emailVerify.js.map +1 -1
  79. package/cjs/idx/flow/AccountUnlockFlow.js +30 -0
  80. package/cjs/idx/flow/AccountUnlockFlow.js.map +1 -0
  81. package/cjs/idx/flow/FlowSpecification.js +8 -0
  82. package/cjs/idx/flow/FlowSpecification.js.map +1 -1
  83. package/cjs/idx/flow/PasswordRecoveryFlow.js +4 -1
  84. package/cjs/idx/flow/PasswordRecoveryFlow.js.map +1 -1
  85. package/cjs/idx/flow/index.js +20 -5
  86. package/cjs/idx/flow/index.js.map +1 -1
  87. package/cjs/idx/handleInteractionCodeRedirect.js +5 -1
  88. package/cjs/idx/handleInteractionCodeRedirect.js.map +1 -1
  89. package/cjs/idx/headers.js +21 -5
  90. package/cjs/idx/headers.js.map +1 -1
  91. package/cjs/idx/idx-js/client.js +91 -0
  92. package/cjs/idx/idx-js/client.js.map +1 -0
  93. package/cjs/idx/idx-js/index.js +40 -0
  94. package/cjs/idx/idx-js/index.js.map +1 -0
  95. package/cjs/idx/idx-js/interact.js +83 -0
  96. package/cjs/idx/idx-js/interact.js.map +1 -0
  97. package/cjs/idx/idx-js/introspect.js +62 -0
  98. package/cjs/idx/idx-js/introspect.js.map +1 -0
  99. package/cjs/idx/idx-js/parsers.js +41 -0
  100. package/cjs/idx/idx-js/parsers.js.map +1 -0
  101. package/cjs/idx/idx-js/util.js +34 -0
  102. package/cjs/idx/idx-js/util.js.map +1 -0
  103. package/cjs/idx/idx-js/v1/actionParser.js +90 -0
  104. package/cjs/idx/idx-js/v1/actionParser.js.map +1 -0
  105. package/cjs/idx/idx-js/v1/generateIdxAction.js +111 -0
  106. package/cjs/idx/idx-js/v1/generateIdxAction.js.map +1 -0
  107. package/cjs/idx/idx-js/v1/idxResponseParser.js +137 -0
  108. package/cjs/idx/idx-js/v1/idxResponseParser.js.map +1 -0
  109. package/cjs/idx/idx-js/v1/makeIdxState.js +65 -0
  110. package/cjs/idx/idx-js/v1/makeIdxState.js.map +1 -0
  111. package/cjs/idx/idx-js/v1/parsers.js +24 -0
  112. package/cjs/idx/idx-js/v1/parsers.js.map +1 -0
  113. package/cjs/idx/idx-js/v1/remediationParser.js +32 -0
  114. package/cjs/idx/idx-js/v1/remediationParser.js.map +1 -0
  115. package/cjs/idx/index.js +120 -121
  116. package/cjs/idx/index.js.map +1 -1
  117. package/cjs/idx/interact.js +9 -4
  118. package/cjs/idx/interact.js.map +1 -1
  119. package/cjs/idx/introspect.js +19 -9
  120. package/cjs/idx/introspect.js.map +1 -1
  121. package/cjs/idx/poll.js +13 -3
  122. package/cjs/idx/poll.js.map +1 -1
  123. package/cjs/idx/proceed.js +14 -11
  124. package/cjs/idx/proceed.js.map +1 -1
  125. package/cjs/idx/recoverPassword.js.map +1 -1
  126. package/cjs/idx/register.js +5 -1
  127. package/cjs/idx/register.js.map +1 -1
  128. package/cjs/idx/remediate.js +112 -88
  129. package/cjs/idx/remediate.js.map +1 -1
  130. package/cjs/idx/remediators/AuthenticatorEnrollmentData.js +16 -6
  131. package/cjs/idx/remediators/AuthenticatorEnrollmentData.js.map +1 -1
  132. package/cjs/idx/remediators/AuthenticatorVerificationData.js +61 -16
  133. package/cjs/idx/remediators/AuthenticatorVerificationData.js.map +1 -1
  134. package/cjs/idx/remediators/Base/AuthenticatorData.js +44 -20
  135. package/cjs/idx/remediators/Base/AuthenticatorData.js.map +1 -1
  136. package/cjs/idx/remediators/Base/Remediator.js +116 -82
  137. package/cjs/idx/remediators/Base/Remediator.js.map +1 -1
  138. package/cjs/idx/remediators/Base/SelectAuthenticator.js +58 -34
  139. package/cjs/idx/remediators/Base/SelectAuthenticator.js.map +1 -1
  140. package/cjs/idx/remediators/Base/VerifyAuthenticator.js +30 -7
  141. package/cjs/idx/remediators/Base/VerifyAuthenticator.js.map +1 -1
  142. package/cjs/idx/remediators/ChallengeAuthenticator.js +2 -2
  143. package/cjs/idx/remediators/ChallengePoll.js +10 -3
  144. package/cjs/idx/remediators/ChallengePoll.js.map +1 -1
  145. package/cjs/idx/remediators/EnrollAuthenticator.js +2 -2
  146. package/cjs/idx/remediators/EnrollPoll.js +16 -6
  147. package/cjs/idx/remediators/EnrollPoll.js.map +1 -1
  148. package/cjs/idx/remediators/EnrollProfile.js +34 -16
  149. package/cjs/idx/remediators/EnrollProfile.js.map +1 -1
  150. package/cjs/idx/remediators/EnrollmentChannelData.js +25 -17
  151. package/cjs/idx/remediators/EnrollmentChannelData.js.map +1 -1
  152. package/cjs/idx/remediators/Identify.js +16 -7
  153. package/cjs/idx/remediators/Identify.js.map +1 -1
  154. package/cjs/idx/remediators/ReEnrollAuthenticator.js +13 -10
  155. package/cjs/idx/remediators/ReEnrollAuthenticator.js.map +1 -1
  156. package/cjs/idx/remediators/RedirectIdp.js +2 -2
  157. package/cjs/idx/remediators/ResetAuthenticator.js +2 -2
  158. package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js +9 -6
  159. package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js.map +1 -1
  160. package/cjs/idx/remediators/SelectAuthenticatorEnroll.js +2 -2
  161. package/cjs/idx/remediators/SelectAuthenticatorUnlockAccount.js +71 -0
  162. package/cjs/idx/remediators/SelectAuthenticatorUnlockAccount.js.map +1 -0
  163. package/cjs/idx/remediators/SelectEnrollProfile.js +2 -2
  164. package/cjs/idx/remediators/SelectEnrollmentChannel.js +22 -10
  165. package/cjs/idx/remediators/SelectEnrollmentChannel.js.map +1 -1
  166. package/cjs/idx/remediators/Skip.js +5 -10
  167. package/cjs/idx/remediators/Skip.js.map +1 -1
  168. package/cjs/idx/remediators/index.js +33 -18
  169. package/cjs/idx/remediators/index.js.map +1 -1
  170. package/cjs/idx/remediators/util.js +13 -3
  171. package/cjs/idx/remediators/util.js.map +1 -1
  172. package/cjs/idx/run.js +276 -177
  173. package/cjs/idx/run.js.map +1 -1
  174. package/cjs/idx/startTransaction.js.map +1 -1
  175. package/cjs/idx/transactionMeta.js.map +1 -1
  176. package/cjs/idx/types/idx-js.js.map +1 -1
  177. package/cjs/idx/types/index.js +82 -9
  178. package/cjs/idx/types/index.js.map +1 -1
  179. package/cjs/idx/unlockAccount.js +48 -0
  180. package/cjs/idx/unlockAccount.js.map +1 -0
  181. package/cjs/idx/util.js +198 -0
  182. package/cjs/idx/util.js.map +1 -0
  183. package/cjs/index.js +20 -14
  184. package/cjs/index.js.map +1 -1
  185. package/cjs/oidc/endpoints/authorize.js +8 -2
  186. package/cjs/oidc/endpoints/authorize.js.map +1 -1
  187. package/cjs/oidc/endpoints/index.js +5 -3
  188. package/cjs/oidc/endpoints/index.js.map +1 -1
  189. package/cjs/oidc/endpoints/token.js +15 -3
  190. package/cjs/oidc/endpoints/token.js.map +1 -1
  191. package/cjs/oidc/endpoints/well-known.js +7 -3
  192. package/cjs/oidc/endpoints/well-known.js.map +1 -1
  193. package/cjs/oidc/exchangeCodeForTokens.js +10 -2
  194. package/cjs/oidc/exchangeCodeForTokens.js.map +1 -1
  195. package/cjs/oidc/getToken.js +9 -5
  196. package/cjs/oidc/getToken.js.map +1 -1
  197. package/cjs/oidc/getUserInfo.js +7 -3
  198. package/cjs/oidc/getUserInfo.js.map +1 -1
  199. package/cjs/oidc/getWithPopup.js +8 -2
  200. package/cjs/oidc/getWithPopup.js.map +1 -1
  201. package/cjs/oidc/getWithRedirect.js +5 -1
  202. package/cjs/oidc/getWithRedirect.js.map +1 -1
  203. package/cjs/oidc/getWithoutPrompt.js +8 -2
  204. package/cjs/oidc/getWithoutPrompt.js.map +1 -1
  205. package/cjs/oidc/handleOAuthResponse.js +9 -3
  206. package/cjs/oidc/handleOAuthResponse.js.map +1 -1
  207. package/cjs/oidc/index.js +4 -2
  208. package/cjs/oidc/index.js.map +1 -1
  209. package/cjs/oidc/parseFromUrl.js +9 -3
  210. package/cjs/oidc/parseFromUrl.js.map +1 -1
  211. package/cjs/oidc/renewToken.js.map +1 -1
  212. package/cjs/oidc/renewTokens.js +5 -1
  213. package/cjs/oidc/renewTokens.js.map +1 -1
  214. package/cjs/oidc/renewTokensWithRefresh.js +5 -1
  215. package/cjs/oidc/renewTokensWithRefresh.js.map +1 -1
  216. package/cjs/oidc/revokeToken.js +7 -3
  217. package/cjs/oidc/revokeToken.js.map +1 -1
  218. package/cjs/oidc/util/browser.js +5 -1
  219. package/cjs/oidc/util/browser.js.map +1 -1
  220. package/cjs/oidc/util/defaultTokenParams.js.map +1 -1
  221. package/cjs/oidc/util/errors.js.map +1 -1
  222. package/cjs/oidc/util/index.js +14 -12
  223. package/cjs/oidc/util/index.js.map +1 -1
  224. package/cjs/oidc/util/loginRedirect.js +5 -1
  225. package/cjs/oidc/util/loginRedirect.js.map +1 -1
  226. package/cjs/oidc/util/oauth.js +4 -2
  227. package/cjs/oidc/util/oauth.js.map +1 -1
  228. package/cjs/oidc/util/oauthMeta.js.map +1 -1
  229. package/cjs/oidc/util/pkce.js +11 -3
  230. package/cjs/oidc/util/pkce.js.map +1 -1
  231. package/cjs/oidc/util/prepareTokenParams.js +7 -5
  232. package/cjs/oidc/util/prepareTokenParams.js.map +1 -1
  233. package/cjs/oidc/util/validateClaims.js +1 -1
  234. package/cjs/oidc/util/validateClaims.js.map +1 -1
  235. package/cjs/oidc/verifyToken.js +11 -3
  236. package/cjs/oidc/verifyToken.js.map +1 -1
  237. package/cjs/options/browser.js +86 -0
  238. package/cjs/options/browser.js.map +1 -0
  239. package/cjs/options/index.js +94 -0
  240. package/cjs/options/index.js.map +1 -0
  241. package/cjs/options/node.js +45 -0
  242. package/cjs/options/node.js.map +1 -0
  243. package/cjs/options.js +17 -5
  244. package/cjs/options.js.map +1 -1
  245. package/cjs/server/serverStorage.js +8 -4
  246. package/cjs/server/serverStorage.js.map +1 -1
  247. package/cjs/services/AutoRenewService.js +94 -0
  248. package/cjs/services/AutoRenewService.js.map +1 -0
  249. package/cjs/services/SyncStorageService.js +93 -0
  250. package/cjs/services/SyncStorageService.js.map +1 -0
  251. package/cjs/services/index.js +30 -0
  252. package/cjs/services/index.js.map +1 -0
  253. package/cjs/tx/AuthTransaction.js +15 -9
  254. package/cjs/tx/AuthTransaction.js.map +1 -1
  255. package/cjs/tx/api.js +8 -4
  256. package/cjs/tx/api.js.map +1 -1
  257. package/cjs/tx/index.js +7 -5
  258. package/cjs/tx/index.js.map +1 -1
  259. package/cjs/tx/poll.js +6 -4
  260. package/cjs/tx/poll.js.map +1 -1
  261. package/cjs/tx/util.js +5 -1
  262. package/cjs/tx/util.js.map +1 -1
  263. package/cjs/types/Service.js +2 -0
  264. package/cjs/types/Service.js.map +1 -0
  265. package/cjs/types/Transaction.js +10 -2
  266. package/cjs/types/Transaction.js.map +1 -1
  267. package/cjs/types/index.js +29 -14
  268. package/cjs/types/index.js.map +1 -1
  269. package/cjs/util/index.js +7 -5
  270. package/cjs/util/index.js.map +1 -1
  271. package/cjs/util/misc.js +5 -1
  272. package/cjs/util/misc.js.map +1 -1
  273. package/cjs/util/object.js +16 -6
  274. package/cjs/util/object.js.map +1 -1
  275. package/cjs/util/sharedStorage.js +5 -1
  276. package/cjs/util/sharedStorage.js.map +1 -1
  277. package/dist/okta-auth-js.min.js +1 -1
  278. package/dist/okta-auth-js.min.js.LICENSE.txt +0 -20
  279. package/dist/okta-auth-js.min.js.map +1 -1
  280. package/dist/okta-auth-js.polyfill.js +1 -1
  281. package/dist/okta-auth-js.polyfill.js.map +1 -1
  282. package/dist/okta-auth-js.umd.js +1 -1
  283. package/dist/okta-auth-js.umd.js.LICENSE.txt +1 -19
  284. package/dist/okta-auth-js.umd.js.map +1 -1
  285. package/esm/{index.js → esm.browser.js} +2978 -2585
  286. package/esm/esm.browser.js.map +1 -0
  287. package/esm/esm.node.mjs +9595 -0
  288. package/esm/esm.node.mjs.map +1 -0
  289. package/lib/AuthStateManager.d.ts +3 -3
  290. package/lib/OktaAuth.d.ts +10 -6
  291. package/lib/PromiseQueue.d.ts +6 -2
  292. package/lib/ServiceManager.d.ts +38 -0
  293. package/lib/StorageManager.d.ts +1 -1
  294. package/lib/TokenManager.d.ts +2 -3
  295. package/lib/TransactionManager.d.ts +4 -5
  296. package/lib/browser/fingerprint.d.ts +2 -3
  297. package/lib/crypto/base64.d.ts +2 -0
  298. package/lib/crypto/webauthn.d.ts +25 -0
  299. package/lib/http/headers.d.ts +2 -2
  300. package/lib/http/request.d.ts +4 -4
  301. package/lib/idx/authenticate.d.ts +2 -2
  302. package/lib/idx/authenticator/Authenticator.d.ts +4 -5
  303. package/lib/idx/authenticator/OktaPassword.d.ts +8 -9
  304. package/lib/idx/authenticator/OktaVerifyTotp.d.ts +1 -1
  305. package/lib/idx/authenticator/SecurityQuestionEnrollment.d.ts +11 -12
  306. package/lib/idx/authenticator/SecurityQuestionVerification.d.ts +7 -7
  307. package/lib/idx/authenticator/VerificationCodeAuthenticator.d.ts +8 -3
  308. package/lib/idx/authenticator/WebauthnEnrollment.d.ts +16 -0
  309. package/lib/idx/authenticator/WebauthnVerification.d.ts +17 -0
  310. package/lib/idx/authenticator/getAuthenticator.d.ts +1 -1
  311. package/lib/idx/authenticator/index.d.ts +9 -0
  312. package/lib/idx/authenticator/util.d.ts +4 -0
  313. package/lib/idx/cancel.d.ts +2 -2
  314. package/lib/idx/emailVerify.d.ts +2 -2
  315. package/lib/idx/flow/AccountUnlockFlow.d.ts +13 -0
  316. package/lib/idx/flow/FlowSpecification.d.ts +2 -2
  317. package/lib/idx/flow/index.d.ts +1 -0
  318. package/lib/idx/headers.d.ts +3 -2
  319. package/lib/idx/idx-js/client.d.ts +36 -0
  320. package/lib/idx/idx-js/index.d.ts +35 -0
  321. package/lib/idx/idx-js/interact.d.ts +25 -0
  322. package/lib/idx/idx-js/introspect.d.ts +21 -0
  323. package/lib/idx/idx-js/parsers.d.ts +15 -0
  324. package/lib/idx/idx-js/util.d.ts +12 -0
  325. package/lib/idx/idx-js/v1/actionParser.d.ts +16 -0
  326. package/lib/idx/idx-js/v1/generateIdxAction.d.ts +13 -0
  327. package/lib/idx/idx-js/v1/idxResponseParser.d.ts +20 -0
  328. package/lib/idx/idx-js/v1/makeIdxState.d.ts +13 -0
  329. package/lib/idx/idx-js/v1/parsers.d.ts +16 -0
  330. package/lib/idx/idx-js/v1/remediationParser.d.ts +12 -0
  331. package/lib/idx/index.d.ts +12 -11
  332. package/lib/idx/interact.d.ts +3 -2
  333. package/lib/idx/introspect.d.ts +2 -2
  334. package/lib/idx/poll.d.ts +2 -2
  335. package/lib/idx/proceed.d.ts +5 -6
  336. package/lib/idx/recoverPassword.d.ts +2 -2
  337. package/lib/idx/register.d.ts +2 -2
  338. package/lib/idx/remediate.d.ts +2 -2
  339. package/lib/idx/remediators/AuthenticatorVerificationData.d.ts +6 -5
  340. package/lib/idx/remediators/Base/AuthenticatorData.d.ts +5 -8
  341. package/lib/idx/remediators/Base/Remediator.d.ts +6 -5
  342. package/lib/idx/remediators/Base/SelectAuthenticator.d.ts +9 -8
  343. package/lib/idx/remediators/Base/VerifyAuthenticator.d.ts +9 -16
  344. package/lib/idx/remediators/ChallengePoll.d.ts +1 -0
  345. package/lib/idx/remediators/EnrollProfile.d.ts +0 -3
  346. package/lib/idx/remediators/EnrollmentChannelData.d.ts +1 -4
  347. package/lib/idx/remediators/Identify.d.ts +3 -5
  348. package/lib/idx/remediators/ReEnrollAuthenticator.d.ts +2 -5
  349. package/lib/idx/remediators/SelectAuthenticatorAuthenticate.d.ts +2 -1
  350. package/lib/idx/remediators/SelectAuthenticatorUnlockAccount.d.ts +37 -0
  351. package/lib/idx/remediators/SelectEnrollmentChannel.d.ts +1 -0
  352. package/lib/idx/remediators/Skip.d.ts +0 -3
  353. package/lib/idx/remediators/index.d.ts +1 -0
  354. package/lib/idx/run.d.ts +2 -2
  355. package/lib/idx/startTransaction.d.ts +2 -2
  356. package/lib/idx/transactionMeta.d.ts +7 -7
  357. package/lib/idx/types/FlowIdentifier.d.ts +1 -1
  358. package/lib/idx/types/idx-js.d.ts +41 -1
  359. package/lib/idx/types/index.d.ts +27 -7
  360. package/lib/idx/unlockAccount.d.ts +15 -0
  361. package/lib/idx/util.d.ts +11 -0
  362. package/lib/oidc/endpoints/well-known.d.ts +3 -3
  363. package/lib/oidc/exchangeCodeForTokens.d.ts +2 -2
  364. package/lib/oidc/getToken.d.ts +2 -2
  365. package/lib/oidc/getWithPopup.d.ts +2 -2
  366. package/lib/oidc/getWithRedirect.d.ts +2 -2
  367. package/lib/oidc/getWithoutPrompt.d.ts +2 -2
  368. package/lib/oidc/handleOAuthResponse.d.ts +2 -2
  369. package/lib/oidc/renewToken.d.ts +2 -2
  370. package/lib/oidc/renewTokensWithRefresh.d.ts +2 -2
  371. package/lib/oidc/revokeToken.d.ts +2 -2
  372. package/lib/oidc/util/browser.d.ts +2 -2
  373. package/lib/oidc/util/defaultTokenParams.d.ts +2 -2
  374. package/lib/oidc/util/errors.d.ts +2 -2
  375. package/lib/oidc/util/loginRedirect.d.ts +4 -4
  376. package/lib/oidc/util/oauth.d.ts +4 -4
  377. package/lib/oidc/util/oauthMeta.d.ts +2 -2
  378. package/lib/oidc/util/prepareTokenParams.d.ts +5 -5
  379. package/lib/oidc/util/validateClaims.d.ts +2 -2
  380. package/lib/oidc/verifyToken.d.ts +2 -2
  381. package/lib/options/browser.d.ts +16 -0
  382. package/lib/options/index.d.ts +14 -0
  383. package/lib/options/node.d.ts +16 -0
  384. package/lib/services/AutoRenewService.d.ts +27 -0
  385. package/lib/services/{TokenService.d.ts → SyncStorageService.d.ts} +8 -5
  386. package/lib/services/index.d.ts +13 -0
  387. package/lib/types/OktaAuthOptions.d.ts +6 -2
  388. package/lib/types/Service.d.ts +23 -0
  389. package/lib/types/Storage.d.ts +7 -5
  390. package/lib/types/Transaction.d.ts +2 -10
  391. package/lib/types/api.d.ts +23 -10
  392. package/lib/types/index.d.ts +1 -1
  393. package/lib/util/sharedStorage.d.ts +1 -1
  394. package/package.json +32 -14
  395. package/polyfill/index.js +1 -0
  396. package/cjs/services/TokenService.js +0 -111
  397. package/cjs/services/TokenService.js.map +0 -1
  398. package/esm/index.js.map +0 -1
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
4
 
5
5
  exports.introspect = introspect;
6
6
 
7
- var _oktaIdxJs = _interopRequireDefault(require("@okta/okta-idx-js"));
7
+ var _idxJs = _interopRequireDefault(require("./idx-js"));
8
8
 
9
- var _idxJs = require("./types/idx-js");
9
+ var _idxJs2 = require("./types/idx-js");
10
10
 
11
11
  var _oidc = require("../oidc");
12
12
 
@@ -24,22 +24,32 @@ var _constants = require("../constants");
24
24
  * See the License for the specific language governing permissions and limitations under the License.
25
25
  */
26
26
  async function introspect(authClient, options = {}) {
27
- // try load from storage first
28
- let rawIdxResponse = authClient.transactionManager.loadIdxResponse(); // call idx.introspect if no existing idx response available in storage
27
+ let rawIdxResponse;
28
+ let requestDidSucceed; // try load from storage first
29
+
30
+ const savedIdxResponse = authClient.transactionManager.loadIdxResponse();
31
+
32
+ if (savedIdxResponse) {
33
+ rawIdxResponse = savedIdxResponse.rawIdxResponse;
34
+ requestDidSucceed = savedIdxResponse.requestDidSucceed;
35
+ } // call idx.introspect if no existing idx response available in storage
36
+
29
37
 
30
38
  if (!rawIdxResponse) {
31
39
  const version = options.version || _constants.IDX_API_VERSION;
32
40
  const domain = (0, _oidc.getOAuthDomain)(authClient);
33
41
 
34
42
  try {
35
- rawIdxResponse = await _oktaIdxJs.default.introspect({
43
+ rawIdxResponse = await _idxJs.default.introspect({
36
44
  domain,
37
45
  ...options,
38
46
  version
39
47
  });
48
+ requestDidSucceed = true;
40
49
  } catch (err) {
41
- if ((0, _idxJs.isRawIdxResponse)(err)) {
50
+ if ((0, _idxJs2.isRawIdxResponse)(err)) {
42
51
  rawIdxResponse = err;
52
+ requestDidSucceed = false;
43
53
  } else {
44
54
  throw err;
45
55
  }
@@ -49,8 +59,8 @@ async function introspect(authClient, options = {}) {
49
59
  const {
50
60
  withCredentials
51
61
  } = options;
52
- return _oktaIdxJs.default.makeIdxState(rawIdxResponse, {
62
+ return _idxJs.default.makeIdxState(rawIdxResponse, {
53
63
  withCredentials
54
- });
64
+ }, requestDidSucceed);
55
65
  }
56
66
  //# sourceMappingURL=introspect.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../lib/idx/introspect.ts"],"names":["introspect","authClient","options","rawIdxResponse","transactionManager","loadIdxResponse","version","IDX_API_VERSION","domain","idx","err","withCredentials","makeIdxState"],"mappings":";;;;;;AAYA;;AAEA;;AACA;;AACA;;AAhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAeO,eAAeA,UAAf,CAA2BC,UAA3B,EAAiDC,OAA0B,GAAG,EAA9E,EAAwG;AAC7G;AACA,MAAIC,cAAc,GAAGF,UAAU,CAACG,kBAAX,CAA8BC,eAA9B,EAArB,CAF6G,CAI7G;;AACA,MAAI,CAACF,cAAL,EAAqB;AACnB,UAAMG,OAAO,GAAGJ,OAAO,CAACI,OAAR,IAAmBC,0BAAnC;AACA,UAAMC,MAAM,GAAG,0BAAeP,UAAf,CAAf;;AACA,QAAI;AACFE,MAAAA,cAAc,GAAG,MAAMM,mBAAIT,UAAJ,CAAe;AAAEQ,QAAAA,MAAF;AAAU,WAAGN,OAAb;AAAsBI,QAAAA;AAAtB,OAAf,CAAvB;AACD,KAFD,CAEE,OAAOI,GAAP,EAAY;AACZ,UAAI,6BAAiBA,GAAjB,CAAJ,EAA2B;AACzBP,QAAAA,cAAc,GAAGO,GAAjB;AACD,OAFD,MAEO;AACL,cAAMA,GAAN;AACD;AACF;AACF;;AAED,QAAM;AAAEC,IAAAA;AAAF,MAAsBT,OAA5B;AACA,SAAOO,mBAAIG,YAAJ,CAAiBT,cAAjB,EAAiC;AAAEQ,IAAAA;AAAF,GAAjC,CAAP;AACD","sourcesContent":["/*!\n * Copyright (c) 2021, 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\nimport idx from '@okta/okta-idx-js';\nimport { OktaAuth } from '../types';\nimport { IdxResponse, isRawIdxResponse } from './types/idx-js';\nimport { getOAuthDomain } from '../oidc';\nimport { IDX_API_VERSION } from '../constants';\n\nexport interface IntrospectOptions {\n withCredentials?: boolean;\n interactionHandle?: string;\n stateHandle?: string;\n version?: string;\n}\n\nexport async function introspect (authClient: OktaAuth, options: IntrospectOptions = {}): Promise<IdxResponse> {\n // try load from storage first\n let rawIdxResponse = authClient.transactionManager.loadIdxResponse();\n \n // call idx.introspect if no existing idx response available in storage\n if (!rawIdxResponse) {\n const version = options.version || IDX_API_VERSION;\n const domain = getOAuthDomain(authClient);\n try {\n rawIdxResponse = await idx.introspect({ domain, ...options, version });\n } catch (err) {\n if (isRawIdxResponse(err)) {\n rawIdxResponse = err;\n } else {\n throw err;\n }\n }\n }\n\n const { withCredentials } = options;\n return idx.makeIdxState(rawIdxResponse, { withCredentials });\n}\n"],"file":"introspect.js"}
1
+ {"version":3,"sources":["../../../lib/idx/introspect.ts"],"names":["introspect","authClient","options","rawIdxResponse","requestDidSucceed","savedIdxResponse","transactionManager","loadIdxResponse","version","IDX_API_VERSION","domain","idx","err","withCredentials","makeIdxState"],"mappings":";;;;;;AAYA;;AAEA;;AACA;;AACA;;AAhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAeO,eAAeA,UAAf,CACLC,UADK,EAELC,OAA0B,GAAG,EAFxB,EAGiB;AACtB,MAAIC,cAAJ;AACA,MAAIC,iBAAJ,CAFsB,CAItB;;AACA,QAAMC,gBAAgB,GAAGJ,UAAU,CAACK,kBAAX,CAA8BC,eAA9B,EAAzB;;AACA,MAAIF,gBAAJ,EAAsB;AACpBF,IAAAA,cAAc,GAAGE,gBAAgB,CAACF,cAAlC;AACAC,IAAAA,iBAAiB,GAAGC,gBAAgB,CAACD,iBAArC;AACD,GATqB,CAWtB;;;AACA,MAAI,CAACD,cAAL,EAAqB;AACnB,UAAMK,OAAO,GAAGN,OAAO,CAACM,OAAR,IAAmBC,0BAAnC;AACA,UAAMC,MAAM,GAAG,0BAAeT,UAAf,CAAf;;AACA,QAAI;AACFE,MAAAA,cAAc,GAAG,MAAMQ,eAAIX,UAAJ,CAAe;AAAEU,QAAAA,MAAF;AAAU,WAAGR,OAAb;AAAsBM,QAAAA;AAAtB,OAAf,CAAvB;AACAJ,MAAAA,iBAAiB,GAAG,IAApB;AACD,KAHD,CAGE,OAAOQ,GAAP,EAAY;AACZ,UAAI,8BAAiBA,GAAjB,CAAJ,EAA2B;AACzBT,QAAAA,cAAc,GAAGS,GAAjB;AACAR,QAAAA,iBAAiB,GAAG,KAApB;AACD,OAHD,MAGO;AACL,cAAMQ,GAAN;AACD;AACF;AACF;;AAED,QAAM;AAAEC,IAAAA;AAAF,MAAsBX,OAA5B;AACA,SAAOS,eAAIG,YAAJ,CAAiBX,cAAjB,EAAiC;AAAEU,IAAAA;AAAF,GAAjC,EAAsDT,iBAAtD,CAAP;AACD","sourcesContent":["/*!\n * Copyright (c) 2021, 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\nimport idx from './idx-js';\nimport { OktaAuthInterface } from '../types';\nimport { IdxResponse, isRawIdxResponse } from './types/idx-js';\nimport { getOAuthDomain } from '../oidc';\nimport { IDX_API_VERSION } from '../constants';\n\nexport interface IntrospectOptions {\n withCredentials?: boolean;\n interactionHandle?: string;\n stateHandle?: string;\n version?: string;\n}\n\nexport async function introspect (\n authClient: OktaAuthInterface, \n options: IntrospectOptions = {}\n): Promise<IdxResponse> {\n let rawIdxResponse;\n let requestDidSucceed;\n\n // try load from storage first\n const savedIdxResponse = authClient.transactionManager.loadIdxResponse();\n if (savedIdxResponse) {\n rawIdxResponse = savedIdxResponse.rawIdxResponse;\n requestDidSucceed = savedIdxResponse.requestDidSucceed;\n }\n\n // call idx.introspect if no existing idx response available in storage\n if (!rawIdxResponse) {\n const version = options.version || IDX_API_VERSION;\n const domain = getOAuthDomain(authClient);\n try {\n rawIdxResponse = await idx.introspect({ domain, ...options, version });\n requestDidSucceed = true;\n } catch (err) {\n if (isRawIdxResponse(err)) {\n rawIdxResponse = err;\n requestDidSucceed = false;\n } else {\n throw err;\n }\n }\n }\n\n const { withCredentials } = options;\n return idx.makeIdxState(rawIdxResponse, { withCredentials }, requestDidSucceed);\n}\n"],"file":"introspect.js"}
package/cjs/idx/poll.js CHANGED
@@ -1,7 +1,17 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+
3
5
  exports.poll = poll;
4
6
 
7
+ var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
8
+
9
+ var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
10
+
11
+ var _isInteger = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/number/is-integer"));
12
+
13
+ var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
14
+
5
15
  var _proceed = require("./proceed");
6
16
 
7
17
  var _transactionMeta = require("./transactionMeta");
@@ -26,14 +36,14 @@ async function poll(authClient, options = {}) {
26
36
  startPolling: true
27
37
  });
28
38
  const meta = (0, _transactionMeta.getSavedTransactionMeta)(authClient);
29
- let availablePollingRemeditaions = meta === null || meta === void 0 ? void 0 : (_meta$remediations = meta.remediations) === null || _meta$remediations === void 0 ? void 0 : _meta$remediations.find(remediation => remediation.includes('poll'));
39
+ let availablePollingRemeditaions = meta === null || meta === void 0 ? void 0 : (_meta$remediations = meta.remediations) === null || _meta$remediations === void 0 ? void 0 : (0, _find.default)(_meta$remediations).call(_meta$remediations, remediation => (0, _includes.default)(remediation).call(remediation, 'poll'));
30
40
 
31
41
  if (!(availablePollingRemeditaions !== null && availablePollingRemeditaions !== void 0 && availablePollingRemeditaions.length)) {
32
42
  (0, _util.warn)('No polling remediations available at the current IDX flow stage');
33
43
  }
34
44
 
35
- if (Number.isInteger(options.refresh)) {
36
- return new Promise(function (resolve, reject) {
45
+ if ((0, _isInteger.default)(options.refresh)) {
46
+ return new _promise.default(function (resolve, reject) {
37
47
  setTimeout(async function () {
38
48
  try {
39
49
  var _transaction$nextStep, _transaction$nextStep2;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../lib/idx/poll.ts"],"names":["poll","authClient","options","transaction","startPolling","meta","availablePollingRemeditaions","remediations","find","remediation","includes","length","Number","isInteger","refresh","Promise","resolve","reject","setTimeout","nextStep","err"],"mappings":";;;;AAYA;;AAOA;;AACA;;AApBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAYO,eAAeA,IAAf,CAAoBC,UAApB,EAA0CC,OAAuB,GAAG,EAApE,EAAiG;AAAA;;AACtG,MAAIC,WAAW,GAAG,MAAM,sBAAQF,UAAR,EAAoB;AAC1CG,IAAAA,YAAY,EAAE;AAD4B,GAApB,CAAxB;AAIA,QAAMC,IAAI,GAAG,8CAAwBJ,UAAxB,CAAb;AACA,MAAIK,4BAA4B,GAAGD,IAAH,aAAGA,IAAH,6CAAGA,IAAI,CAAEE,YAAT,uDAAG,mBAAoBC,IAApB,CAAyBC,WAAW,IAAIA,WAAW,CAACC,QAAZ,CAAqB,MAArB,CAAxC,CAAnC;;AACA,MAAI,EAACJ,4BAAD,aAACA,4BAAD,eAACA,4BAA4B,CAAEK,MAA/B,CAAJ,EAA2C;AACzC,oBAAK,iEAAL;AACD;;AAED,MAAIC,MAAM,CAACC,SAAP,CAAiBX,OAAO,CAACY,OAAzB,CAAJ,EAAuC;AACrC,WAAO,IAAIC,OAAJ,CAAY,UAAUC,OAAV,EAAmBC,MAAnB,EAA2B;AAC5CC,MAAAA,UAAU,CAAC,kBAAkB;AAC3B,YAAI;AAAA;;AACF,gBAAMJ,OAAO,4BAAGX,WAAW,CAACgB,QAAf,oFAAG,sBAAsBnB,IAAzB,2DAAG,uBAA4Bc,OAA5C;;AACA,cAAIA,OAAJ,EAAa;AACXE,YAAAA,OAAO,CAAChB,IAAI,CAACC,UAAD,EAAa;AACvBa,cAAAA;AADuB,aAAb,CAAL,CAAP;AAGD,WAJD,MAIO;AACLE,YAAAA,OAAO,CAACb,WAAD,CAAP;AACD;AACF,SATD,CASE,OAAOiB,GAAP,EAAY;AACZH,UAAAA,MAAM,CAACG,GAAD,CAAN;AACD;AACF,OAbS,EAaPlB,OAAO,CAACY,OAbD,CAAV;AAcD,KAfM,CAAP;AAgBD;;AAED,SAAOX,WAAP;AACD","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\nimport { proceed } from './proceed';\n\nimport { \n IdxPollOptions,\n IdxTransaction,\n OktaAuth,\n} from '../types';\nimport { getSavedTransactionMeta } from './transactionMeta';\nimport { warn } from '../util';\n\nexport async function poll(authClient: OktaAuth, options: IdxPollOptions = {}): Promise<IdxTransaction> {\n let transaction = await proceed(authClient, {\n startPolling: true\n });\n\n const meta = getSavedTransactionMeta(authClient);\n let availablePollingRemeditaions = meta?.remediations?.find(remediation => remediation.includes('poll'));\n if (!availablePollingRemeditaions?.length) {\n warn('No polling remediations available at the current IDX flow stage');\n }\n\n if (Number.isInteger(options.refresh)) {\n return new Promise(function (resolve, reject) {\n setTimeout(async function () {\n try {\n const refresh = transaction.nextStep?.poll?.refresh;\n if (refresh) {\n resolve(poll(authClient, {\n refresh\n }));\n } else {\n resolve(transaction);\n }\n } catch (err) {\n reject(err);\n }\n }, options.refresh);\n });\n }\n\n return transaction;\n}\n"],"file":"poll.js"}
1
+ {"version":3,"sources":["../../../lib/idx/poll.ts"],"names":["poll","authClient","options","transaction","startPolling","meta","availablePollingRemeditaions","remediations","remediation","length","refresh","resolve","reject","setTimeout","nextStep","err"],"mappings":";;;;;;;;;;;;;;AAYA;;AAOA;;AACA;;AApBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAYO,eAAeA,IAAf,CAAoBC,UAApB,EAAmDC,OAAuB,GAAG,EAA7E,EAA0G;AAAA;;AAC/G,MAAIC,WAAW,GAAG,MAAM,sBAAQF,UAAR,EAAoB;AAC1CG,IAAAA,YAAY,EAAE;AAD4B,GAApB,CAAxB;AAIA,QAAMC,IAAI,GAAG,8CAAwBJ,UAAxB,CAAb;AACA,MAAIK,4BAA4B,GAAGD,IAAH,aAAGA,IAAH,6CAAGA,IAAI,CAAEE,YAAT,uDAAG,gEAAyBC,WAAW,IAAI,uBAAAA,WAAW,MAAX,CAAAA,WAAW,EAAU,MAAV,CAAnD,CAAnC;;AACA,MAAI,EAACF,4BAAD,aAACA,4BAAD,eAACA,4BAA4B,CAAEG,MAA/B,CAAJ,EAA2C;AACzC,oBAAK,iEAAL;AACD;;AAED,MAAI,wBAAiBP,OAAO,CAACQ,OAAzB,CAAJ,EAAuC;AACrC,WAAO,qBAAY,UAAUC,OAAV,EAAmBC,MAAnB,EAA2B;AAC5CC,MAAAA,UAAU,CAAC,kBAAkB;AAC3B,YAAI;AAAA;;AACF,gBAAMH,OAAO,4BAAGP,WAAW,CAACW,QAAf,oFAAG,sBAAsBd,IAAzB,2DAAG,uBAA4BU,OAA5C;;AACA,cAAIA,OAAJ,EAAa;AACXC,YAAAA,OAAO,CAACX,IAAI,CAACC,UAAD,EAAa;AACvBS,cAAAA;AADuB,aAAb,CAAL,CAAP;AAGD,WAJD,MAIO;AACLC,YAAAA,OAAO,CAACR,WAAD,CAAP;AACD;AACF,SATD,CASE,OAAOY,GAAP,EAAY;AACZH,UAAAA,MAAM,CAACG,GAAD,CAAN;AACD;AACF,OAbS,EAaPb,OAAO,CAACQ,OAbD,CAAV;AAcD,KAfM,CAAP;AAgBD;;AAED,SAAOP,WAAP;AACD","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\nimport { proceed } from './proceed';\n\nimport { \n IdxPollOptions,\n IdxTransaction,\n OktaAuthInterface,\n} from '../types';\nimport { getSavedTransactionMeta } from './transactionMeta';\nimport { warn } from '../util';\n\nexport async function poll(authClient: OktaAuthInterface, options: IdxPollOptions = {}): Promise<IdxTransaction> {\n let transaction = await proceed(authClient, {\n startPolling: true\n });\n\n const meta = getSavedTransactionMeta(authClient);\n let availablePollingRemeditaions = meta?.remediations?.find(remediation => remediation.includes('poll'));\n if (!availablePollingRemeditaions?.length) {\n warn('No polling remediations available at the current IDX flow stage');\n }\n\n if (Number.isInteger(options.refresh)) {\n return new Promise(function (resolve, reject) {\n setTimeout(async function () {\n try {\n const refresh = transaction.nextStep?.poll?.refresh;\n if (refresh) {\n resolve(poll(authClient, {\n refresh\n }));\n } else {\n resolve(transaction);\n }\n } catch (err) {\n reject(err);\n }\n }, options.refresh);\n });\n }\n\n return transaction;\n}\n"],"file":"poll.js"}
@@ -20,25 +20,28 @@ var _errors = require("../errors");
20
20
  *
21
21
  * See the License for the specific language governing permissions and limitations under the License.
22
22
  */
23
- function canProceed(authClient, options) {
23
+ function canProceed(authClient, options = {}) {
24
24
  const meta = (0, _transactionMeta.getSavedTransactionMeta)(authClient, options);
25
- return !!meta;
25
+ return !!(meta || options.stateHandle);
26
26
  }
27
27
 
28
28
  async function proceed(authClient, options = {}) {
29
- const {
29
+ if (!canProceed(authClient, options)) {
30
+ throw new _errors.AuthSdkError('Unable to proceed: saved transaction could not be loaded');
31
+ }
32
+
33
+ let {
34
+ flow,
30
35
  state
31
36
  } = options;
32
- const meta = (0, _transactionMeta.getSavedTransactionMeta)(authClient, {
33
- state
34
- }); // Proceed always needs saved transaction meta
35
-
36
- if (!meta) {
37
- throw new _errors.AuthSdkError('Unable to proceed: saved transaction could not be loaded');
38
- } // Determine the flow specification based on the saved flow
39
37
 
38
+ if (!flow) {
39
+ const meta = (0, _transactionMeta.getSavedTransactionMeta)(authClient, {
40
+ state
41
+ });
42
+ flow = meta === null || meta === void 0 ? void 0 : meta.flow;
43
+ }
40
44
 
41
- const flow = meta === null || meta === void 0 ? void 0 : meta.flow;
42
45
  return (0, _run.run)(authClient, { ...options,
43
46
  flow
44
47
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../lib/idx/proceed.ts"],"names":["canProceed","authClient","options","meta","proceed","state","AuthSdkError","flow"],"mappings":";;;;;AAiBA;;AAQA;;AACA;;AA1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAyBO,SAASA,UAAT,CAAoBC,UAApB,EAA0CC,OAA1C,EAAwE;AAC7E,QAAMC,IAAI,GAAG,8CAAwBF,UAAxB,EAAoCC,OAApC,CAAb;AACA,SAAO,CAAC,CAACC,IAAT;AACD;;AAEM,eAAeC,OAAf,CACLH,UADK,EAELC,OAAuB,GAAG,EAFrB,EAGoB;AACzB,QAAM;AAAEG,IAAAA;AAAF,MAAYH,OAAlB;AACA,QAAMC,IAAI,GAAG,8CAAwBF,UAAxB,EAAoC;AAAEI,IAAAA;AAAF,GAApC,CAAb,CAFyB,CAIzB;;AACA,MAAI,CAACF,IAAL,EAAW;AACT,UAAM,IAAIG,oBAAJ,CAAiB,0DAAjB,CAAN;AACD,GAPwB,CASzB;;;AACA,QAAMC,IAAI,GAAGJ,IAAH,aAAGA,IAAH,uBAAGA,IAAI,CAAEI,IAAnB;AAEA,SAAO,cAAIN,UAAJ,EAAgB,EACrB,GAAGC,OADkB;AAErBK,IAAAA;AAFqB,GAAhB,CAAP;AAID","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 { \n OktaAuth,\n IdxTransaction,\n} from '../types';\nimport { run } from './run';\nimport { AuthenticationOptions } from './authenticate';\nimport {\n EnrollPollValues as EnrollPollOptions,\n SelectEnrollmentChannelValues as SelectEnrollmentChannelOptions\n} from './remediators';\nimport { RegistrationOptions } from './register';\nimport { PasswordRecoveryOptions } from './recoverPassword';\nimport { getSavedTransactionMeta } from './transactionMeta';\nimport { AuthSdkError } from '../errors';\n\nexport type ProceedOptions = AuthenticationOptions\n & RegistrationOptions\n & PasswordRecoveryOptions\n & EnrollPollOptions\n & SelectEnrollmentChannelOptions\n & { step?: string };\n\nexport function canProceed(authClient: OktaAuth, options?: { state?: string }) {\n const meta = getSavedTransactionMeta(authClient, options);\n return !!meta;\n}\n\nexport async function proceed(\n authClient: OktaAuth,\n options: ProceedOptions = {}\n): Promise<IdxTransaction> {\n const { state } = options;\n const meta = getSavedTransactionMeta(authClient, { state });\n\n // Proceed always needs saved transaction meta\n if (!meta) {\n throw new AuthSdkError('Unable to proceed: saved transaction could not be loaded');\n }\n\n // Determine the flow specification based on the saved flow\n const flow = meta?.flow;\n\n return run(authClient, { \n ...options, \n flow\n });\n}\n"],"file":"proceed.js"}
1
+ {"version":3,"sources":["../../../lib/idx/proceed.ts"],"names":["canProceed","authClient","options","meta","stateHandle","proceed","AuthSdkError","flow","state"],"mappings":";;;;;AAiBA;;AASA;;AACA;;AA3BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA2BO,SAASA,UAAT,CAAoBC,UAApB,EAAmDC,OAAuB,GAAG,EAA7E,EAA0F;AAC/F,QAAMC,IAAI,GAAG,8CAAwBF,UAAxB,EAAoCC,OAApC,CAAb;AACA,SAAO,CAAC,EAAEC,IAAI,IAAID,OAAO,CAACE,WAAlB,CAAR;AACD;;AAEM,eAAeC,OAAf,CACLJ,UADK,EAELC,OAAuB,GAAG,EAFrB,EAGoB;AAEzB,MAAI,CAACF,UAAU,CAACC,UAAD,EAAaC,OAAb,CAAf,EAAsC;AACpC,UAAM,IAAII,oBAAJ,CAAiB,0DAAjB,CAAN;AACD;;AAED,MAAI;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,MAAkBN,OAAtB;;AACA,MAAI,CAACK,IAAL,EAAW;AACT,UAAMJ,IAAI,GAAG,8CAAwBF,UAAxB,EAAoC;AAAEO,MAAAA;AAAF,KAApC,CAAb;AACAD,IAAAA,IAAI,GAAGJ,IAAH,aAAGA,IAAH,uBAAGA,IAAI,CAAEI,IAAb;AACD;;AAED,SAAO,cAAIN,UAAJ,EAAgB,EACrB,GAAGC,OADkB;AAErBK,IAAAA;AAFqB,GAAhB,CAAP;AAID","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 { \n OktaAuthInterface,\n IdxTransaction,\n} from '../types';\nimport { run } from './run';\nimport { AuthenticationOptions } from './authenticate';\nimport {\n EnrollPollValues as EnrollPollOptions,\n SelectEnrollmentChannelValues as SelectEnrollmentChannelOptions\n} from './remediators';\nimport { RegistrationOptions } from './register';\nimport { PasswordRecoveryOptions } from './recoverPassword';\nimport { AccountUnlockOptions } from './unlockAccount';\nimport { getSavedTransactionMeta } from './transactionMeta';\nimport { AuthSdkError } from '../errors';\n\nexport type ProceedOptions = AuthenticationOptions\n & RegistrationOptions\n & PasswordRecoveryOptions\n & AccountUnlockOptions\n & EnrollPollOptions\n & SelectEnrollmentChannelOptions\n & { step?: string };\n\nexport function canProceed(authClient: OktaAuthInterface, options: ProceedOptions = {}): boolean {\n const meta = getSavedTransactionMeta(authClient, options);\n return !!(meta || options.stateHandle);\n}\n\nexport async function proceed(\n authClient: OktaAuthInterface,\n options: ProceedOptions = {}\n): Promise<IdxTransaction> {\n\n if (!canProceed(authClient, options)) {\n throw new AuthSdkError('Unable to proceed: saved transaction could not be loaded');\n }\n\n let { flow, state } = options;\n if (!flow) {\n const meta = getSavedTransactionMeta(authClient, { state });\n flow = meta?.flow;\n }\n\n return run(authClient, { \n ...options, \n flow\n });\n}\n"],"file":"proceed.js"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../lib/idx/recoverPassword.ts"],"names":["recoverPassword","authClient","options","flowSpec"],"mappings":";;;;AAaA;;AASA;;AAtBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA2BO,eAAeA,eAAf,CACLC,UADK,EACiBC,OAAgC,GAAG,EADpD,EAEoB;AACzB,QAAMC,QAAQ,GAAG,gCAAqBF,UAArB,EAAiC,iBAAjC,CAAjB;AACA,SAAO,cACLA,UADK,EAEL,EACE,GAAGC,OADL;AAEE,OAAGC;AAFL,GAFK,CAAP;AAOD","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 {\n IdentifyValues,\n SelectAuthenticatorAuthenticateValues,\n ChallengeAuthenticatorValues,\n AuthenticatorVerificationDataValues,\n ResetAuthenticatorValues,\n ReEnrollAuthenticatorValues,\n} from './remediators';\nimport { getFlowSpecification } from './flow';\nimport { \n OktaAuth, \n IdxOptions, \n IdxTransaction,\n} from '../types';\n\nexport type PasswordRecoveryOptions = IdxOptions \n & IdentifyValues \n & SelectAuthenticatorAuthenticateValues \n & ChallengeAuthenticatorValues \n & ResetAuthenticatorValues\n & AuthenticatorVerificationDataValues\n & ReEnrollAuthenticatorValues;\n\nexport async function recoverPassword(\n authClient: OktaAuth, options: PasswordRecoveryOptions = {}\n): Promise<IdxTransaction> {\n const flowSpec = getFlowSpecification(authClient, 'recoverPassword');\n return run(\n authClient, \n { \n ...options,\n ...flowSpec,\n }\n );\n}\n"],"file":"recoverPassword.js"}
1
+ {"version":3,"sources":["../../../lib/idx/recoverPassword.ts"],"names":["recoverPassword","authClient","options","flowSpec"],"mappings":";;;;AAaA;;AASA;;AAtBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA2BO,eAAeA,eAAf,CACLC,UADK,EAC0BC,OAAgC,GAAG,EAD7D,EAEoB;AACzB,QAAMC,QAAQ,GAAG,gCAAqBF,UAArB,EAAiC,iBAAjC,CAAjB;AACA,SAAO,cACLA,UADK,EAEL,EACE,GAAGC,OADL;AAEE,OAAGC;AAFL,GAFK,CAAP;AAOD","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 {\n IdentifyValues,\n SelectAuthenticatorAuthenticateValues,\n ChallengeAuthenticatorValues,\n AuthenticatorVerificationDataValues,\n ResetAuthenticatorValues,\n ReEnrollAuthenticatorValues,\n} from './remediators';\nimport { getFlowSpecification } from './flow';\nimport { \n OktaAuthInterface, \n IdxOptions, \n IdxTransaction,\n} from '../types';\n\nexport type PasswordRecoveryOptions = IdxOptions \n & IdentifyValues \n & SelectAuthenticatorAuthenticateValues \n & ChallengeAuthenticatorValues \n & ResetAuthenticatorValues\n & AuthenticatorVerificationDataValues\n & ReEnrollAuthenticatorValues;\n\nexport async function recoverPassword(\n authClient: OktaAuthInterface, options: PasswordRecoveryOptions = {}\n): Promise<IdxTransaction> {\n const flowSpec = getFlowSpecification(authClient, 'recoverPassword');\n return run(\n authClient, \n { \n ...options,\n ...flowSpec,\n }\n );\n}\n"],"file":"recoverPassword.js"}
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+
3
5
  exports.register = register;
4
6
 
7
+ var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
8
+
5
9
  var _run = require("./run");
6
10
 
7
11
  var _transactionMeta = require("./transactionMeta");
@@ -34,7 +38,7 @@ async function register(authClient, options = {}) {
34
38
  autoRemediate: false
35
39
  });
36
40
 
37
- if (!options.activationToken && enabledFeatures && !enabledFeatures.includes(_types.IdxFeature.REGISTRATION)) {
41
+ if (!options.activationToken && enabledFeatures && !(0, _includes.default)(enabledFeatures).call(enabledFeatures, _types.IdxFeature.REGISTRATION)) {
38
42
  const error = new _errors.AuthSdkError('Registration is not supported based on your current org configuration.');
39
43
  throw error; // return { status: IdxStatus.FAILURE, error } as unknown as IdxTransaction; // TODO: wny not just throw the error?
40
44
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../lib/idx/register.ts"],"names":["register","authClient","options","enabledFeatures","availableSteps","flow","autoRemediate","activationToken","includes","IdxFeature","REGISTRATION","error","AuthSdkError","some","name"],"mappings":";;;;AAaA;;AACA;;AACA;;AAQA;;AACA;;AAxBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA4BO,eAAeA,QAAf,CACLC,UADK,EACiBC,OAA4B,GAAG,EADhD,EAEoB;AAEzB;AACA,MAAI,CAAC,gDAA0BD,UAA1B,CAAL,EAA4C;AAC1C,UAAM;AAAEE,MAAAA,eAAF;AAAmBC,MAAAA;AAAnB,QAAsC,MAAM,wCAAiBH,UAAjB,EAA6B,EAC7E,GAAGC,OAD0E;AAE7EG,MAAAA,IAAI,EAAE,UAFuE;AAG7EC,MAAAA,aAAa,EAAE;AAH8D,KAA7B,CAAlD;;AAKA,QAAI,CAACJ,OAAO,CAACK,eAAT,IAA4BJ,eAA5B,IAA+C,CAACA,eAAe,CAACK,QAAhB,CAAyBC,kBAAWC,YAApC,CAApD,EAAuG;AACrG,YAAMC,KAAK,GAAG,IAAIC,oBAAJ,CAAiB,wEAAjB,CAAd;AACA,YAAMD,KAAN,CAFqG,CAGvG;AACC;;AACD,QAAIT,OAAO,CAACK,eAAR,IAA2BH,cAA3B,aAA2BA,cAA3B,eAA2BA,cAAc,CAAES,IAAhB,CAAqB,CAAC;AAAEC,MAAAA;AAAF,KAAD,KAAcA,IAAI,KAAK,UAA5C,CAA/B,EAAwF;AACtF,YAAMH,KAAK,GAAG,IAAIC,oBAAJ,CAAiB,2EAAjB,CAAd;AACA,YAAMD,KAAN,CAFsF,CAGxF;AACC;AACF;;AAED,SAAO,cAAIV,UAAJ,EAAgB,EACrB,GAAGC,OADkB;AAErBG,IAAAA,IAAI,EAAE;AAFe,GAAhB,CAAP;AAID","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 { \n EnrollProfileValues,\n SelectAuthenticatorEnrollValues,\n EnrollAuthenticatorValues,\n AuthenticatorEnrollmentDataValues,\n SkipValues,\n} from './remediators';\nimport { AuthSdkError } from '../errors';\nimport { \n IdxOptions, \n IdxTransaction, \n OktaAuth, \n IdxFeature,\n} from '../types';\n\nexport type RegistrationOptions = IdxOptions \n & EnrollProfileValues \n & SelectAuthenticatorEnrollValues \n & EnrollAuthenticatorValues \n & AuthenticatorEnrollmentDataValues \n & SkipValues;\n\nexport async function register(\n authClient: OktaAuth, 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"],"file":"register.js"}
1
+ {"version":3,"sources":["../../../lib/idx/register.ts"],"names":["register","authClient","options","enabledFeatures","availableSteps","flow","autoRemediate","activationToken","IdxFeature","REGISTRATION","error","AuthSdkError","some","name"],"mappings":";;;;;;;;AAaA;;AACA;;AACA;;AAQA;;AACA;;AAxBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA4BO,eAAeA,QAAf,CACLC,UADK,EAC0BC,OAA4B,GAAG,EADzD,EAEoB;AAEzB;AACA,MAAI,CAAC,gDAA0BD,UAA1B,CAAL,EAA4C;AAC1C,UAAM;AAAEE,MAAAA,eAAF;AAAmBC,MAAAA;AAAnB,QAAsC,MAAM,wCAAiBH,UAAjB,EAA6B,EAC7E,GAAGC,OAD0E;AAE7EG,MAAAA,IAAI,EAAE,UAFuE;AAG7EC,MAAAA,aAAa,EAAE;AAH8D,KAA7B,CAAlD;;AAKA,QAAI,CAACJ,OAAO,CAACK,eAAT,IAA4BJ,eAA5B,IAA+C,CAAC,uBAAAA,eAAe,MAAf,CAAAA,eAAe,EAAUK,kBAAWC,YAArB,CAAnE,EAAuG;AACrG,YAAMC,KAAK,GAAG,IAAIC,oBAAJ,CAAiB,wEAAjB,CAAd;AACA,YAAMD,KAAN,CAFqG,CAGvG;AACC;;AACD,QAAIR,OAAO,CAACK,eAAR,IAA2BH,cAA3B,aAA2BA,cAA3B,eAA2BA,cAAc,CAAEQ,IAAhB,CAAqB,CAAC;AAAEC,MAAAA;AAAF,KAAD,KAAcA,IAAI,KAAK,UAA5C,CAA/B,EAAwF;AACtF,YAAMH,KAAK,GAAG,IAAIC,oBAAJ,CAAiB,2EAAjB,CAAd;AACA,YAAMD,KAAN,CAFsF,CAGxF;AACC;AACF;;AAED,SAAO,cAAIT,UAAJ,EAAgB,EACrB,GAAGC,OADkB;AAErBG,IAAAA,IAAI,EAAE;AAFe,GAAhB,CAAP;AAID","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 { \n EnrollProfileValues,\n SelectAuthenticatorEnrollValues,\n EnrollAuthenticatorValues,\n AuthenticatorEnrollmentDataValues,\n SkipValues,\n} from './remediators';\nimport { AuthSdkError } from '../errors';\nimport { \n IdxOptions, \n IdxTransaction, \n OktaAuthInterface, \n IdxFeature,\n} from '../types';\n\nexport type RegistrationOptions = IdxOptions \n & EnrollProfileValues \n & SelectAuthenticatorEnrollValues \n & EnrollAuthenticatorValues \n & AuthenticatorEnrollmentDataValues \n & SkipValues;\n\nexport async function register(\n authClient: OktaAuthInterface, 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"],"file":"register.js"}
@@ -1,14 +1,28 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+
3
5
  exports.getRemediator = getRemediator;
4
6
  exports.remediate = remediate;
5
7
 
6
- var _errors = require("../errors");
8
+ var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
9
+
10
+ var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
11
+
12
+ var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
13
+
14
+ var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
15
+
16
+ var _reduce = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
7
17
 
8
- var _remediators = require("./remediators");
18
+ var _errors = require("../errors");
9
19
 
10
20
  var _idxJs = require("./types/idx-js");
11
21
 
22
+ var _util = require("./util");
23
+
24
+ var _util2 = require("../util");
25
+
12
26
  /*!
13
27
  * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
14
28
  * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
@@ -30,24 +44,33 @@ function getRemediator(idxRemediations, values, options) {
30
44
 
31
45
  if (options.step) {
32
46
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
33
- const remediation = idxRemediations.find(({
47
+ const remediation = (0, _find.default)(idxRemediations).call(idxRemediations, ({
34
48
  name
35
49
  }) => name === options.step);
36
- const T = remediators[remediation.name];
37
- return new T(remediation, values);
50
+
51
+ if (remediation) {
52
+ const T = remediation ? remediators[remediation.name] : undefined;
53
+ return T ? new T(remediation, values, options) : undefined;
54
+ } else {
55
+ // step was specified, but remediation was not found. This is unexpected!
56
+ (0, _util2.warn)(`step "${options.step}" did not match any remediations`);
57
+ return;
58
+ }
38
59
  }
39
60
 
40
61
  const remediatorCandidates = [];
41
62
 
42
63
  for (let remediation of idxRemediations) {
43
- const isRemeditionInFlow = Object.keys(remediators).includes(remediation.name);
64
+ var _context;
65
+
66
+ const isRemeditionInFlow = (0, _includes.default)(_context = (0, _keys.default)(remediators)).call(_context, remediation.name);
44
67
 
45
68
  if (!isRemeditionInFlow) {
46
69
  continue;
47
70
  }
48
71
 
49
72
  const T = remediators[remediation.name];
50
- remediator = new T(remediation, values);
73
+ remediator = new T(remediation, values, options);
51
74
 
52
75
  if (remediator.canRemediate()) {
53
76
  // found the remediator
@@ -62,55 +85,10 @@ function getRemediator(idxRemediations, values, options) {
62
85
  return remediatorCandidates[0];
63
86
  }
64
87
 
65
- function isTerminalResponse(idxResponse) {
66
- const {
67
- neededToProceed,
68
- interactionCode
69
- } = idxResponse;
70
- return !neededToProceed.length && !interactionCode;
71
- }
72
-
73
- function canSkipFn(idxResponse) {
74
- return idxResponse.neededToProceed.some(({
75
- name
76
- }) => name === 'skip');
77
- }
78
-
79
- function canResendFn(idxResponse) {
80
- return Object.keys(idxResponse.actions).some(actionName => actionName.includes('resend'));
81
- }
82
-
83
- function getIdxMessages(idxResponse) {
84
- var _rawIdxState$messages;
85
-
86
- let messages = [];
87
- const {
88
- rawIdxState,
89
- neededToProceed
90
- } = idxResponse; // Handle global messages
91
-
92
- const globalMessages = (_rawIdxState$messages = rawIdxState.messages) === null || _rawIdxState$messages === void 0 ? void 0 : _rawIdxState$messages.value.map(message => message);
93
-
94
- if (globalMessages) {
95
- messages = [...messages, ...globalMessages];
96
- } // Handle field messages for current flow
97
-
98
-
99
- for (let remediation of neededToProceed) {
100
- const fieldMessages = _remediators.Remediator.getMessages(remediation);
101
-
102
- if (fieldMessages) {
103
- messages = [...messages, ...fieldMessages];
104
- }
105
- }
106
-
107
- return messages;
108
- }
109
-
110
88
  function getNextStep(remediator, idxResponse) {
111
89
  const nextStep = remediator.getNextStep(idxResponse.context);
112
- const canSkip = canSkipFn(idxResponse);
113
- const canResend = canResendFn(idxResponse);
90
+ const canSkip = (0, _util.canSkipFn)(idxResponse);
91
+ const canResend = (0, _util.canResendFn)(idxResponse);
114
92
  return { ...nextStep,
115
93
  ...(canSkip && {
116
94
  canSkip
@@ -123,24 +101,27 @@ function getNextStep(remediator, idxResponse) {
123
101
 
124
102
  function handleIdxError(e, remediator) {
125
103
  // Handle idx messages
126
- const idxState = (0, _idxJs.isIdxResponse)(e) ? e : null;
104
+ const idxResponse = (0, _idxJs.isIdxResponse)(e) ? e : null;
127
105
 
128
- if (!idxState) {
106
+ if (!idxResponse) {
129
107
  // Thrown error terminates the interaction with idx
130
108
  throw e;
131
109
  }
132
110
 
133
- const terminal = isTerminalResponse(idxState);
134
- const messages = getIdxMessages(idxState);
111
+ idxResponse.requestDidSucceed = false;
112
+ const terminal = (0, _util.isTerminalResponse)(idxResponse);
113
+ const messages = (0, _util.getMessagesFromResponse)(idxResponse);
135
114
 
136
115
  if (terminal) {
137
116
  return {
117
+ idxResponse,
138
118
  terminal,
139
119
  messages
140
120
  };
141
121
  } else {
142
- const nextStep = remediator && getNextStep(remediator, idxState);
122
+ const nextStep = remediator && getNextStep(remediator, idxResponse);
143
123
  return {
124
+ idxResponse,
144
125
  messages,
145
126
  ...(nextStep && {
146
127
  nextStep
@@ -150,8 +131,10 @@ function handleIdxError(e, remediator) {
150
131
  }
151
132
 
152
133
  function getActionFromValues(values, idxResponse) {
134
+ var _context2;
135
+
153
136
  // Currently support resend actions only
154
- return Object.keys(idxResponse.actions).find(action => !!values.resend && action.includes('-resend'));
137
+ return (0, _find.default)(_context2 = (0, _keys.default)(idxResponse.actions)).call(_context2, action => !!values.resend && (0, _includes.default)(action).call(action, '-resend'));
155
138
  }
156
139
 
157
140
  function removeActionFromValues(values) {
@@ -178,63 +161,101 @@ async function remediate(idxResponse, values, options) {
178
161
  } // Reach to terminal state
179
162
 
180
163
 
181
- const terminal = isTerminalResponse(idxResponse);
182
- const messages = getIdxMessages(idxResponse);
164
+ const terminal = (0, _util.isTerminalResponse)(idxResponse);
165
+ const messages = (0, _util.getMessagesFromResponse)(idxResponse);
183
166
 
184
167
  if (terminal) {
185
168
  return {
169
+ idxResponse,
186
170
  terminal,
187
171
  messages
188
172
  };
189
- }
190
-
191
- const remediator = getRemediator(neededToProceed, values, options);
192
-
193
- if (!remediator && flow === 'default') {
194
- return {
195
- idxResponse
196
- };
197
- }
198
-
199
- if (!remediator) {
200
- throw new _errors.AuthSdkError(`
201
- No remediation can match current flow, check policy settings in your org.
202
- Remediations: [${neededToProceed.reduce((acc, curr) => acc ? acc + ' ,' + curr.name : curr.name, '')}]
203
- `);
204
- }
205
-
206
- if (messages.length) {
207
- const nextStep = getNextStep(remediator, idxResponse);
208
- return {
209
- nextStep,
210
- messages
211
- };
212
173
  } // Try actions in idxResponse first
213
174
 
214
175
 
215
176
  const actionFromValues = getActionFromValues(values, idxResponse);
216
- const actions = [...(options.actions || []), ...(actionFromValues && [actionFromValues] || [])];
177
+ const actionFromOptions = options.actions || [];
178
+ const actions = [...actionFromOptions, ...(actionFromValues && [actionFromValues] || [])];
217
179
 
218
180
  if (actions) {
219
181
  for (let action of actions) {
220
182
  let valuesWithoutExecutedAction = removeActionFromValues(values);
183
+ let optionsWithoutExecutedAction = { ...options,
184
+ actions: (0, _filter.default)(actionFromOptions).call(actionFromOptions, entry => entry !== action)
185
+ };
221
186
 
222
187
  if (typeof idxResponse.actions[action] === 'function') {
223
188
  try {
224
189
  idxResponse = await idxResponse.actions[action]();
190
+ idxResponse.requestDidSucceed = true;
225
191
  } catch (e) {
226
192
  return handleIdxError(e, remediators);
227
193
  }
228
194
 
229
195
  if (action === 'cancel') {
230
196
  return {
197
+ idxResponse,
231
198
  canceled: true
232
199
  };
233
200
  }
234
201
 
235
- return remediate(idxResponse, valuesWithoutExecutedAction, options); // recursive call
202
+ return remediate(idxResponse, valuesWithoutExecutedAction, optionsWithoutExecutedAction); // recursive call
203
+ } // search for action in remediation list
204
+
205
+
206
+ const remediationAction = (0, _find.default)(neededToProceed).call(neededToProceed, ({
207
+ name
208
+ }) => name === action);
209
+
210
+ if (remediationAction) {
211
+ try {
212
+ idxResponse = await idxResponse.proceed(action, {});
213
+ idxResponse.requestDidSucceed = true;
214
+ } catch (e) {
215
+ return handleIdxError(e, remediators);
216
+ }
217
+
218
+ return remediate(idxResponse, values, optionsWithoutExecutedAction); // recursive call
236
219
  }
237
220
  }
221
+ }
222
+
223
+ const remediator = getRemediator(neededToProceed, values, options);
224
+
225
+ if (!remediator) {
226
+ if (options.step) {
227
+ values = (0, _util.filterValuesForRemediation)(idxResponse, values); // include only requested values
228
+
229
+ try {
230
+ idxResponse = await idxResponse.proceed(options.step, values);
231
+ idxResponse.requestDidSucceed = true;
232
+ return {
233
+ idxResponse
234
+ };
235
+ } catch (e) {
236
+ return handleIdxError(e);
237
+ }
238
+ }
239
+
240
+ if (flow === 'default') {
241
+ return {
242
+ idxResponse
243
+ };
244
+ }
245
+
246
+ throw new _errors.AuthSdkError(`
247
+ No remediation can match current flow, check policy settings in your org.
248
+ Remediations: [${(0, _reduce.default)(neededToProceed).call(neededToProceed, (acc, curr) => acc ? acc + ' ,' + curr.name : curr.name, '')}]
249
+ `);
250
+ }
251
+
252
+ if (messages.length) {
253
+ const nextStep = getNextStep(remediator, idxResponse);
254
+ return {
255
+ idxResponse,
256
+ nextStep,
257
+ messages
258
+ };
238
259
  } // Return next step to the caller
239
260
 
240
261
 
@@ -250,10 +271,13 @@ async function remediate(idxResponse, values, options) {
250
271
  const data = remediator.getData();
251
272
 
252
273
  try {
253
- idxResponse = await idxResponse.proceed(name, data); // We may want to trim the values bag for the next remediation
274
+ idxResponse = await idxResponse.proceed(name, data);
275
+ idxResponse.requestDidSucceed = true; // We may want to trim the values bag for the next remediation
254
276
  // Let the remediator decide what the values should be (default to current values)
255
277
 
256
278
  values = remediator.getValuesAfterProceed();
279
+ delete options.step; // do not re-use the step
280
+
257
281
  return remediate(idxResponse, values, options); // recursive call
258
282
  } catch (e) {
259
283
  return handleIdxError(e, remediator);