@okta/okta-auth-js 5.11.0 → 6.2.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 (421) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/README.md +63 -29
  3. package/cjs/AuthStateManager.js +15 -6
  4. package/cjs/AuthStateManager.js.map +1 -1
  5. package/cjs/OktaAuth.js +168 -108
  6. package/cjs/OktaAuth.js.map +1 -1
  7. package/cjs/OktaUserAgent.js +2 -2
  8. package/cjs/OktaUserAgent.js.map +1 -1
  9. package/cjs/PromiseQueue.js +11 -2
  10. package/cjs/PromiseQueue.js.map +1 -1
  11. package/cjs/SavedObject.js +4 -2
  12. package/cjs/SavedObject.js.map +1 -1
  13. package/cjs/ServiceManager.js +195 -0
  14. package/cjs/ServiceManager.js.map +1 -0
  15. package/cjs/StorageManager.js +16 -9
  16. package/cjs/StorageManager.js.map +1 -1
  17. package/cjs/TokenManager.js +42 -34
  18. package/cjs/TokenManager.js.map +1 -1
  19. package/cjs/TransactionManager.js +26 -7
  20. package/cjs/TransactionManager.js.map +1 -1
  21. package/cjs/browser/browserStorage.js +36 -20
  22. package/cjs/browser/browserStorage.js.map +1 -1
  23. package/cjs/browser/fingerprint.js +12 -4
  24. package/cjs/browser/fingerprint.js.map +1 -1
  25. package/cjs/builderUtil.js +7 -19
  26. package/cjs/builderUtil.js.map +1 -1
  27. package/cjs/clock.js +5 -1
  28. package/cjs/clock.js.map +1 -1
  29. package/cjs/crypto/base64.js +18 -0
  30. package/cjs/crypto/base64.js.map +1 -1
  31. package/cjs/crypto/index.js +6 -4
  32. package/cjs/crypto/index.js.map +1 -1
  33. package/cjs/crypto/node.js +19 -13
  34. package/cjs/crypto/node.js.map +1 -1
  35. package/cjs/crypto/oidcHash.js +5 -1
  36. package/cjs/crypto/oidcHash.js.map +1 -1
  37. package/cjs/crypto/webauthn.js +101 -0
  38. package/cjs/crypto/webauthn.js.map +1 -0
  39. package/cjs/crypto/webcrypto.js +3 -1
  40. package/cjs/crypto/webcrypto.js.map +1 -1
  41. package/cjs/errors/AuthApiError.js +1 -1
  42. package/cjs/errors/AuthPollStopError.js +1 -1
  43. package/cjs/errors/AuthSdkError.js +1 -1
  44. package/cjs/errors/CustomError.js +5 -1
  45. package/cjs/errors/CustomError.js.map +1 -1
  46. package/cjs/errors/OAuthError.js +1 -1
  47. package/cjs/errors/index.js +1 -1
  48. package/cjs/features.js +9 -3
  49. package/cjs/features.js.map +1 -1
  50. package/cjs/fetch/fetchRequest.js +19 -6
  51. package/cjs/fetch/fetchRequest.js.map +1 -1
  52. package/cjs/http/headers.js.map +1 -1
  53. package/cjs/http/index.js +4 -2
  54. package/cjs/http/index.js.map +1 -1
  55. package/cjs/http/request.js +11 -5
  56. package/cjs/http/request.js.map +1 -1
  57. package/cjs/idx/authenticate.js +8 -5
  58. package/cjs/idx/authenticate.js.map +1 -1
  59. package/cjs/idx/authenticator/Authenticator.js.map +1 -1
  60. package/cjs/idx/authenticator/OktaPassword.js.map +1 -1
  61. package/cjs/idx/authenticator/SecurityQuestionEnrollment.js +1 -1
  62. package/cjs/idx/authenticator/SecurityQuestionEnrollment.js.map +1 -1
  63. package/cjs/idx/authenticator/SecurityQuestionVerification.js +2 -1
  64. package/cjs/idx/authenticator/SecurityQuestionVerification.js.map +1 -1
  65. package/cjs/idx/authenticator/VerificationCodeAuthenticator.js +2 -2
  66. package/cjs/idx/authenticator/VerificationCodeAuthenticator.js.map +1 -1
  67. package/cjs/idx/authenticator/WebauthnEnrollment.js +46 -0
  68. package/cjs/idx/authenticator/WebauthnEnrollment.js.map +1 -0
  69. package/cjs/idx/authenticator/WebauthnVerification.js +55 -0
  70. package/cjs/idx/authenticator/WebauthnVerification.js.map +1 -0
  71. package/cjs/idx/authenticator/getAuthenticator.js +17 -6
  72. package/cjs/idx/authenticator/getAuthenticator.js.map +1 -1
  73. package/cjs/idx/authenticator/index.js +34 -6
  74. package/cjs/idx/authenticator/index.js.map +1 -1
  75. package/cjs/idx/cancel.js.map +1 -1
  76. package/cjs/idx/emailVerify.js +73 -0
  77. package/cjs/idx/emailVerify.js.map +1 -0
  78. package/cjs/idx/flow/AccountUnlockFlow.js +30 -0
  79. package/cjs/idx/flow/AccountUnlockFlow.js.map +1 -0
  80. package/cjs/idx/flow/FlowSpecification.js +24 -4
  81. package/cjs/idx/flow/FlowSpecification.js.map +1 -1
  82. package/cjs/idx/flow/PasswordRecoveryFlow.js +4 -1
  83. package/cjs/idx/flow/PasswordRecoveryFlow.js.map +1 -1
  84. package/cjs/idx/flow/RegistrationFlow.js +2 -0
  85. package/cjs/idx/flow/RegistrationFlow.js.map +1 -1
  86. package/cjs/idx/flow/index.js +20 -5
  87. package/cjs/idx/flow/index.js.map +1 -1
  88. package/cjs/idx/handleInteractionCodeRedirect.js +6 -1
  89. package/cjs/idx/handleInteractionCodeRedirect.js.map +1 -1
  90. package/cjs/idx/headers.js +21 -5
  91. package/cjs/idx/headers.js.map +1 -1
  92. package/cjs/idx/idx-js/client.js +91 -0
  93. package/cjs/idx/idx-js/client.js.map +1 -0
  94. package/cjs/idx/idx-js/index.js +162 -0
  95. package/cjs/idx/idx-js/index.js.map +1 -0
  96. package/cjs/idx/idx-js/interact.js +83 -0
  97. package/cjs/idx/idx-js/interact.js.map +1 -0
  98. package/cjs/idx/idx-js/introspect.js +58 -0
  99. package/cjs/idx/idx-js/introspect.js.map +1 -0
  100. package/cjs/idx/idx-js/parsers.js +41 -0
  101. package/cjs/idx/idx-js/parsers.js.map +1 -0
  102. package/cjs/idx/idx-js/util.js +34 -0
  103. package/cjs/idx/idx-js/util.js.map +1 -0
  104. package/cjs/idx/idx-js/v1/actionParser.js +90 -0
  105. package/cjs/idx/idx-js/v1/actionParser.js.map +1 -0
  106. package/cjs/idx/idx-js/v1/generateIdxAction.js +117 -0
  107. package/cjs/idx/idx-js/v1/generateIdxAction.js.map +1 -0
  108. package/cjs/idx/idx-js/v1/idxResponseParser.js +137 -0
  109. package/cjs/idx/idx-js/v1/idxResponseParser.js.map +1 -0
  110. package/cjs/idx/idx-js/v1/makeIdxState.js +64 -0
  111. package/cjs/idx/idx-js/v1/makeIdxState.js.map +1 -0
  112. package/cjs/idx/idx-js/v1/parsers.js +24 -0
  113. package/cjs/idx/idx-js/v1/parsers.js.map +1 -0
  114. package/cjs/idx/idx-js/v1/remediationParser.js +32 -0
  115. package/cjs/idx/idx-js/v1/remediationParser.js.map +1 -0
  116. package/cjs/idx/index.js +121 -109
  117. package/cjs/idx/index.js.map +1 -1
  118. package/cjs/idx/interact.js +53 -36
  119. package/cjs/idx/interact.js.map +1 -1
  120. package/cjs/idx/introspect.js +17 -19
  121. package/cjs/idx/introspect.js.map +1 -1
  122. package/cjs/idx/poll.js +13 -3
  123. package/cjs/idx/poll.js.map +1 -1
  124. package/cjs/idx/proceed.js +4 -7
  125. package/cjs/idx/proceed.js.map +1 -1
  126. package/cjs/idx/recoverPassword.js +1 -1
  127. package/cjs/idx/recoverPassword.js.map +1 -1
  128. package/cjs/idx/register.js +11 -16
  129. package/cjs/idx/register.js.map +1 -1
  130. package/cjs/idx/remediate.js +74 -27
  131. package/cjs/idx/remediate.js.map +1 -1
  132. package/cjs/idx/remediators/AuthenticatorEnrollmentData.js +12 -4
  133. package/cjs/idx/remediators/AuthenticatorEnrollmentData.js.map +1 -1
  134. package/cjs/idx/remediators/AuthenticatorVerificationData.js +52 -9
  135. package/cjs/idx/remediators/AuthenticatorVerificationData.js.map +1 -1
  136. package/cjs/idx/remediators/Base/AuthenticatorData.js +31 -13
  137. package/cjs/idx/remediators/Base/AuthenticatorData.js.map +1 -1
  138. package/cjs/idx/remediators/Base/Remediator.js +67 -31
  139. package/cjs/idx/remediators/Base/Remediator.js.map +1 -1
  140. package/cjs/idx/remediators/Base/SelectAuthenticator.js +46 -30
  141. package/cjs/idx/remediators/Base/SelectAuthenticator.js.map +1 -1
  142. package/cjs/idx/remediators/Base/VerifyAuthenticator.js +16 -4
  143. package/cjs/idx/remediators/Base/VerifyAuthenticator.js.map +1 -1
  144. package/cjs/idx/remediators/ChallengeAuthenticator.js +2 -2
  145. package/cjs/idx/remediators/ChallengeAuthenticator.js.map +1 -1
  146. package/cjs/idx/remediators/ChallengePoll.js +2 -2
  147. package/cjs/idx/remediators/EnrollAuthenticator.js +2 -2
  148. package/cjs/idx/remediators/EnrollAuthenticator.js.map +1 -1
  149. package/cjs/idx/remediators/EnrollPoll.js +18 -9
  150. package/cjs/idx/remediators/EnrollPoll.js.map +1 -1
  151. package/cjs/idx/remediators/EnrollProfile.js +24 -9
  152. package/cjs/idx/remediators/EnrollProfile.js.map +1 -1
  153. package/cjs/idx/remediators/EnrollmentChannelData.js +96 -0
  154. package/cjs/idx/remediators/EnrollmentChannelData.js.map +1 -0
  155. package/cjs/idx/remediators/Identify.js +5 -3
  156. package/cjs/idx/remediators/Identify.js.map +1 -1
  157. package/cjs/idx/remediators/ReEnrollAuthenticator.js +6 -3
  158. package/cjs/idx/remediators/ReEnrollAuthenticator.js.map +1 -1
  159. package/cjs/idx/remediators/RedirectIdp.js +2 -2
  160. package/cjs/idx/remediators/ResetAuthenticator.js +2 -2
  161. package/cjs/idx/remediators/ResetAuthenticator.js.map +1 -1
  162. package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js +7 -5
  163. package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js.map +1 -1
  164. package/cjs/idx/remediators/SelectAuthenticatorEnroll.js +2 -2
  165. package/cjs/idx/remediators/SelectAuthenticatorEnroll.js.map +1 -1
  166. package/cjs/idx/remediators/SelectAuthenticatorUnlockAccount.js +72 -0
  167. package/cjs/idx/remediators/SelectAuthenticatorUnlockAccount.js.map +1 -0
  168. package/cjs/idx/remediators/SelectEnrollProfile.js +2 -2
  169. package/cjs/idx/remediators/SelectEnrollProfile.js.map +1 -1
  170. package/cjs/idx/remediators/SelectEnrollmentChannel.js +86 -0
  171. package/cjs/idx/remediators/SelectEnrollmentChannel.js.map +1 -0
  172. package/cjs/idx/remediators/Skip.js +5 -3
  173. package/cjs/idx/remediators/Skip.js.map +1 -1
  174. package/cjs/idx/remediators/index.js +57 -16
  175. package/cjs/idx/remediators/index.js.map +1 -1
  176. package/cjs/idx/remediators/util.js +18 -3
  177. package/cjs/idx/remediators/util.js.map +1 -1
  178. package/cjs/idx/run.js +145 -49
  179. package/cjs/idx/run.js.map +1 -1
  180. package/cjs/idx/startTransaction.js +4 -2
  181. package/cjs/idx/startTransaction.js.map +1 -1
  182. package/cjs/idx/transactionMeta.js +82 -69
  183. package/cjs/idx/transactionMeta.js.map +1 -1
  184. package/cjs/idx/types/idx-js.js.map +1 -1
  185. package/cjs/idx/types/index.js +59 -7
  186. package/cjs/idx/types/index.js.map +1 -1
  187. package/cjs/idx/unlockAccount.js +48 -0
  188. package/cjs/idx/unlockAccount.js.map +1 -0
  189. package/cjs/index.js +33 -13
  190. package/cjs/index.js.map +1 -1
  191. package/cjs/oidc/endpoints/authorize.js +10 -2
  192. package/cjs/oidc/endpoints/authorize.js.map +1 -1
  193. package/cjs/oidc/endpoints/index.js +5 -3
  194. package/cjs/oidc/endpoints/index.js.map +1 -1
  195. package/cjs/oidc/endpoints/token.js +16 -3
  196. package/cjs/oidc/endpoints/token.js.map +1 -1
  197. package/cjs/oidc/endpoints/well-known.js +7 -3
  198. package/cjs/oidc/endpoints/well-known.js.map +1 -1
  199. package/cjs/oidc/exchangeCodeForTokens.js +12 -4
  200. package/cjs/oidc/exchangeCodeForTokens.js.map +1 -1
  201. package/cjs/oidc/getToken.js +12 -6
  202. package/cjs/oidc/getToken.js.map +1 -1
  203. package/cjs/oidc/getUserInfo.js +7 -3
  204. package/cjs/oidc/getUserInfo.js.map +1 -1
  205. package/cjs/oidc/getWithPopup.js +8 -2
  206. package/cjs/oidc/getWithPopup.js.map +1 -1
  207. package/cjs/oidc/getWithRedirect.js +15 -38
  208. package/cjs/oidc/getWithRedirect.js.map +1 -1
  209. package/cjs/oidc/getWithoutPrompt.js +8 -2
  210. package/cjs/oidc/getWithoutPrompt.js.map +1 -1
  211. package/cjs/oidc/handleOAuthResponse.js +87 -87
  212. package/cjs/oidc/handleOAuthResponse.js.map +1 -1
  213. package/cjs/oidc/index.js +4 -2
  214. package/cjs/oidc/index.js.map +1 -1
  215. package/cjs/oidc/parseFromUrl.js +9 -3
  216. package/cjs/oidc/parseFromUrl.js.map +1 -1
  217. package/cjs/oidc/renewToken.js.map +1 -1
  218. package/cjs/oidc/renewTokens.js +6 -2
  219. package/cjs/oidc/renewTokens.js.map +1 -1
  220. package/cjs/oidc/renewTokensWithRefresh.js +5 -1
  221. package/cjs/oidc/renewTokensWithRefresh.js.map +1 -1
  222. package/cjs/oidc/revokeToken.js +34 -31
  223. package/cjs/oidc/revokeToken.js.map +1 -1
  224. package/cjs/oidc/util/browser.js +5 -1
  225. package/cjs/oidc/util/browser.js.map +1 -1
  226. package/cjs/oidc/util/defaultTokenParams.js.map +1 -1
  227. package/cjs/oidc/util/errors.js.map +1 -1
  228. package/cjs/oidc/util/index.js +27 -11
  229. package/cjs/oidc/util/index.js.map +1 -1
  230. package/cjs/oidc/util/loginRedirect.js +10 -1
  231. package/cjs/oidc/util/loginRedirect.js.map +1 -1
  232. package/cjs/oidc/util/oauth.js +4 -2
  233. package/cjs/oidc/util/oauth.js.map +1 -1
  234. package/cjs/oidc/util/oauthMeta.js +36 -0
  235. package/cjs/oidc/util/oauthMeta.js.map +1 -0
  236. package/cjs/oidc/util/pkce.js +11 -3
  237. package/cjs/oidc/util/pkce.js.map +1 -1
  238. package/cjs/oidc/util/prepareTokenParams.js +62 -39
  239. package/cjs/oidc/util/prepareTokenParams.js.map +1 -1
  240. package/cjs/oidc/util/validateClaims.js +3 -1
  241. package/cjs/oidc/util/validateClaims.js.map +1 -1
  242. package/cjs/oidc/verifyToken.js +13 -4
  243. package/cjs/oidc/verifyToken.js.map +1 -1
  244. package/cjs/options/browser.js +81 -0
  245. package/cjs/options/browser.js.map +1 -0
  246. package/cjs/options/index.js +94 -0
  247. package/cjs/options/index.js.map +1 -0
  248. package/cjs/options/node.js +46 -0
  249. package/cjs/options/node.js.map +1 -0
  250. package/cjs/server/serverStorage.js +9 -5
  251. package/cjs/server/serverStorage.js.map +1 -1
  252. package/cjs/services/AutoRenewService.js +94 -0
  253. package/cjs/services/AutoRenewService.js.map +1 -0
  254. package/cjs/services/SyncStorageService.js +93 -0
  255. package/cjs/services/SyncStorageService.js.map +1 -0
  256. package/cjs/services/index.js +30 -0
  257. package/cjs/services/index.js.map +1 -0
  258. package/cjs/tx/AuthTransaction.js +18 -9
  259. package/cjs/tx/AuthTransaction.js.map +1 -1
  260. package/cjs/tx/TransactionState.js +0 -17
  261. package/cjs/tx/TransactionState.js.map +1 -1
  262. package/cjs/tx/api.js +11 -6
  263. package/cjs/tx/api.js.map +1 -1
  264. package/cjs/tx/index.js +7 -5
  265. package/cjs/tx/index.js.map +1 -1
  266. package/cjs/tx/poll.js +6 -4
  267. package/cjs/tx/poll.js.map +1 -1
  268. package/cjs/tx/util.js +5 -1
  269. package/cjs/tx/util.js.map +1 -1
  270. package/cjs/types/Service.js +2 -0
  271. package/cjs/types/Service.js.map +1 -0
  272. package/cjs/types/Transaction.js +10 -2
  273. package/cjs/types/Transaction.js.map +1 -1
  274. package/cjs/types/index.js +29 -14
  275. package/cjs/types/index.js.map +1 -1
  276. package/cjs/util/index.js +7 -18
  277. package/cjs/util/index.js.map +1 -1
  278. package/cjs/util/misc.js +5 -1
  279. package/cjs/util/misc.js.map +1 -1
  280. package/cjs/util/object.js +16 -6
  281. package/cjs/util/object.js.map +1 -1
  282. package/cjs/util/sharedStorage.js +5 -1
  283. package/cjs/util/sharedStorage.js.map +1 -1
  284. package/cjs/util/url.js.map +1 -1
  285. package/dist/okta-auth-js.min.js +1 -1
  286. package/dist/okta-auth-js.min.js.LICENSE.txt +0 -20
  287. package/dist/okta-auth-js.min.js.map +1 -1
  288. package/dist/okta-auth-js.polyfill.js +1 -1
  289. package/dist/okta-auth-js.polyfill.js.map +1 -1
  290. package/dist/okta-auth-js.umd.js +1 -1
  291. package/dist/okta-auth-js.umd.js.LICENSE.txt +1 -19
  292. package/dist/okta-auth-js.umd.js.map +1 -1
  293. package/esm/{index.js → esm.browser.js} +3283 -2698
  294. package/esm/esm.browser.js.map +1 -0
  295. package/esm/esm.node.mjs +9277 -0
  296. package/esm/esm.node.mjs.map +1 -0
  297. package/lib/AuthStateManager.d.ts +2 -5
  298. package/lib/OktaAuth.d.ts +14 -16
  299. package/lib/ServiceManager.d.ts +38 -0
  300. package/lib/StorageManager.d.ts +2 -2
  301. package/lib/TokenManager.d.ts +4 -5
  302. package/lib/TransactionManager.d.ts +4 -3
  303. package/lib/browser/fingerprint.d.ts +2 -3
  304. package/lib/builderUtil.d.ts +1 -2
  305. package/lib/crypto/base64.d.ts +2 -0
  306. package/lib/crypto/browser.d.ts +1 -1
  307. package/lib/crypto/webauthn.d.ts +25 -0
  308. package/lib/features.d.ts +1 -1
  309. package/lib/http/headers.d.ts +2 -2
  310. package/lib/http/request.d.ts +4 -4
  311. package/lib/idx/authenticate.d.ts +2 -2
  312. package/lib/idx/authenticator/Authenticator.d.ts +4 -5
  313. package/lib/idx/authenticator/OktaPassword.d.ts +7 -9
  314. package/lib/idx/authenticator/SecurityQuestionEnrollment.d.ts +9 -8
  315. package/lib/idx/authenticator/SecurityQuestionVerification.d.ts +7 -7
  316. package/lib/idx/authenticator/VerificationCodeAuthenticator.d.ts +6 -2
  317. package/lib/idx/authenticator/WebauthnEnrollment.d.ts +16 -0
  318. package/lib/idx/authenticator/WebauthnVerification.d.ts +17 -0
  319. package/lib/idx/authenticator/getAuthenticator.d.ts +1 -1
  320. package/lib/idx/authenticator/index.d.ts +9 -0
  321. package/lib/idx/cancel.d.ts +2 -2
  322. package/lib/idx/emailVerify.d.ts +26 -0
  323. package/lib/{util/emailVerify.d.ts → idx/flow/AccountUnlockFlow.d.ts} +2 -6
  324. package/lib/idx/flow/FlowSpecification.d.ts +3 -2
  325. package/lib/idx/flow/index.d.ts +1 -0
  326. package/lib/idx/headers.d.ts +3 -2
  327. package/lib/idx/idx-js/client.d.ts +36 -0
  328. package/lib/idx/idx-js/index.d.ts +51 -0
  329. package/lib/idx/idx-js/interact.d.ts +25 -0
  330. package/lib/idx/idx-js/introspect.d.ts +20 -0
  331. package/lib/idx/idx-js/parsers.d.ts +15 -0
  332. package/lib/idx/idx-js/util.d.ts +12 -0
  333. package/lib/idx/idx-js/v1/actionParser.d.ts +16 -0
  334. package/lib/idx/idx-js/v1/generateIdxAction.d.ts +13 -0
  335. package/lib/idx/idx-js/v1/idxResponseParser.d.ts +20 -0
  336. package/lib/idx/idx-js/v1/makeIdxState.d.ts +13 -0
  337. package/lib/idx/idx-js/v1/parsers.d.ts +16 -0
  338. package/lib/idx/idx-js/v1/remediationParser.d.ts +12 -0
  339. package/lib/idx/index.d.ts +12 -10
  340. package/lib/idx/interact.d.ts +7 -13
  341. package/lib/idx/introspect.d.ts +4 -3
  342. package/lib/idx/poll.d.ts +2 -2
  343. package/lib/idx/proceed.d.ts +8 -5
  344. package/lib/idx/recoverPassword.d.ts +2 -2
  345. package/lib/idx/register.d.ts +2 -2
  346. package/lib/idx/remediate.d.ts +10 -4
  347. package/lib/idx/remediators/AuthenticatorEnrollmentData.d.ts +3 -3
  348. package/lib/idx/remediators/AuthenticatorVerificationData.d.ts +5 -5
  349. package/lib/idx/remediators/Base/AuthenticatorData.d.ts +10 -10
  350. package/lib/idx/remediators/Base/SelectAuthenticator.d.ts +10 -7
  351. package/lib/idx/remediators/Base/VerifyAuthenticator.d.ts +8 -12
  352. package/lib/idx/remediators/EnrollProfile.d.ts +1 -1
  353. package/lib/idx/remediators/EnrollmentChannelData.d.ts +54 -0
  354. package/lib/idx/remediators/Identify.d.ts +2 -2
  355. package/lib/idx/remediators/ReEnrollAuthenticator.d.ts +2 -2
  356. package/lib/idx/remediators/RedirectIdp.d.ts +3 -3
  357. package/lib/idx/remediators/SelectAuthenticatorUnlockAccount.d.ts +38 -0
  358. package/lib/idx/remediators/SelectEnrollmentChannel.d.ts +40 -0
  359. package/lib/idx/remediators/index.d.ts +3 -0
  360. package/lib/idx/remediators/util.d.ts +2 -2
  361. package/lib/idx/run.d.ts +5 -3
  362. package/lib/idx/startTransaction.d.ts +3 -2
  363. package/lib/idx/transactionMeta.d.ts +10 -31
  364. package/lib/idx/types/FlowIdentifier.d.ts +1 -1
  365. package/lib/idx/types/idx-js.d.ts +44 -1
  366. package/lib/idx/types/index.d.ts +36 -9
  367. package/lib/idx/unlockAccount.d.ts +15 -0
  368. package/lib/index.d.ts +1 -0
  369. package/lib/oidc/endpoints/well-known.d.ts +3 -3
  370. package/lib/oidc/exchangeCodeForTokens.d.ts +14 -2
  371. package/lib/oidc/getToken.d.ts +2 -2
  372. package/lib/oidc/getWithPopup.d.ts +2 -2
  373. package/lib/oidc/getWithRedirect.d.ts +2 -2
  374. package/lib/oidc/getWithoutPrompt.d.ts +2 -2
  375. package/lib/oidc/handleOAuthResponse.d.ts +2 -2
  376. package/lib/oidc/parseFromUrl.d.ts +1 -1
  377. package/lib/oidc/renewToken.d.ts +2 -2
  378. package/lib/oidc/renewTokens.d.ts +1 -1
  379. package/lib/oidc/renewTokensWithRefresh.d.ts +2 -2
  380. package/lib/oidc/revokeToken.d.ts +2 -2
  381. package/lib/oidc/util/browser.d.ts +3 -3
  382. package/lib/oidc/util/defaultTokenParams.d.ts +2 -2
  383. package/lib/oidc/util/errors.d.ts +2 -2
  384. package/lib/oidc/util/index.d.ts +1 -0
  385. package/lib/oidc/util/loginRedirect.d.ts +4 -4
  386. package/lib/oidc/util/oauth.d.ts +4 -11
  387. package/lib/oidc/util/oauthMeta.d.ts +2 -0
  388. package/lib/oidc/util/prepareTokenParams.d.ts +5 -2
  389. package/lib/oidc/util/validateClaims.d.ts +2 -2
  390. package/lib/oidc/verifyToken.d.ts +2 -2
  391. package/lib/options/browser.d.ts +16 -0
  392. package/lib/{options.d.ts → options/index.d.ts} +1 -1
  393. package/lib/options/node.d.ts +16 -0
  394. package/lib/server/serverStorage.d.ts +1 -1
  395. package/lib/services/AutoRenewService.d.ts +27 -0
  396. package/lib/services/{TokenService.d.ts → SyncStorageService.d.ts} +8 -5
  397. package/lib/services/index.d.ts +13 -0
  398. package/lib/tx/AuthTransaction.d.ts +2 -2
  399. package/lib/tx/TransactionState.d.ts +11 -1
  400. package/lib/tx/api.d.ts +6 -6
  401. package/lib/types/OktaAuthOptions.d.ts +11 -8
  402. package/lib/types/Service.d.ts +23 -0
  403. package/lib/types/Storage.d.ts +3 -3
  404. package/lib/types/Transaction.d.ts +10 -7
  405. package/lib/types/UserClaims.d.ts +3 -3
  406. package/lib/types/api.d.ts +49 -22
  407. package/lib/types/index.d.ts +1 -1
  408. package/lib/util/console.d.ts +1 -1
  409. package/lib/util/index.d.ts +0 -1
  410. package/lib/util/sharedStorage.d.ts +1 -1
  411. package/lib/util/types.d.ts +1 -1
  412. package/lib/util/url.d.ts +2 -2
  413. package/package.json +30 -13
  414. package/polyfill/index.js +1 -0
  415. package/cjs/options.js +0 -154
  416. package/cjs/options.js.map +0 -1
  417. package/cjs/services/TokenService.js +0 -108
  418. package/cjs/services/TokenService.js.map +0 -1
  419. package/cjs/util/emailVerify.js +0 -28
  420. package/cjs/util/emailVerify.js.map +0 -1
  421. package/esm/index.js.map +0 -1
package/cjs/OktaAuth.js CHANGED
@@ -1,9 +1,21 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
4
+
5
+ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
6
+
7
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
8
 
5
9
  exports.default = void 0;
6
10
 
11
+ var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
12
+
13
+ var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
14
+
15
+ var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
16
+
17
+ var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
18
+
7
19
  var constants = _interopRequireWildcard(require("./constants"));
8
20
 
9
21
  var _tx = require("./tx");
@@ -16,14 +28,18 @@ var _oidc = require("./oidc");
16
28
 
17
29
  var features = _interopRequireWildcard(require("./features"));
18
30
 
31
+ var crypto = _interopRequireWildcard(require("./crypto"));
32
+
33
+ var webauthn = _interopRequireWildcard(require("./crypto/webauthn"));
34
+
19
35
  var _browserStorage = _interopRequireDefault(require("./browser/browserStorage"));
20
36
 
21
37
  var _util = require("./util");
22
38
 
23
- var _builderUtil = require("./builderUtil");
24
-
25
39
  var _TokenManager = require("./TokenManager");
26
40
 
41
+ var _ServiceManager = require("./ServiceManager");
42
+
27
43
  var _http = require("./http");
28
44
 
29
45
  var _PromiseQueue = _interopRequireDefault(require("./PromiseQueue"));
@@ -32,7 +48,7 @@ var _fingerprint = _interopRequireDefault(require("./browser/fingerprint"));
32
48
 
33
49
  var _AuthStateManager = require("./AuthStateManager");
34
50
 
35
- var _StorageManager = _interopRequireDefault(require("./StorageManager"));
51
+ var _StorageManager = require("./StorageManager");
36
52
 
37
53
  var _TransactionManager = _interopRequireDefault(require("./TransactionManager"));
38
54
 
@@ -46,9 +62,13 @@ var _OktaUserAgent = require("./OktaUserAgent");
46
62
 
47
63
  var _parseFromUrl = require("./oidc/parseFromUrl");
48
64
 
49
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
65
+ var _transactionMeta = require("./idx/transactionMeta");
66
+
67
+ var _tinyEmitter = _interopRequireDefault(require("tiny-emitter"));
68
+
69
+ function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
50
70
 
51
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
71
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
52
72
 
53
73
  /* eslint-disable max-statements */
54
74
 
@@ -66,32 +86,29 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
66
86
  * See the License for the specific language governing permissions and limitations under the License.
67
87
  */
68
88
 
69
- /* SDK_VERSION is defined in webpack config */
70
-
71
- /* global window, SDK_VERSION */
72
- const Emitter = require('tiny-emitter');
73
-
89
+ /* global window */
90
+ // @ts-ignore
91
+ // Do not use this type in code, so it won't be emitted in the declaration output
74
92
  class OktaAuth {
75
- // keep this field to compatible with released downstream SDK versions
76
- // TODO: remove in version 6
77
- // JIRA: https://oktainc.atlassian.net/browse/OKTA-419417
78
93
  constructor(args) {
79
- const options = this.options = (0, _options.buildOptions)(args);
80
- this.storageManager = new _StorageManager.default(options.storageManager, options.cookies, options.storageUtil);
81
- this.transactionManager = new _TransactionManager.default(Object.assign({
94
+ const options = this.options = (0, _options.buildOptions)(args); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
95
+
96
+ this.storageManager = new _StorageManager.StorageManager(options.storageManager, options.cookies, options.storageUtil);
97
+ this.transactionManager = new _TransactionManager.default((0, _assign.default)({
82
98
  storageManager: this.storageManager
83
99
  }, options.transactionManager));
84
100
  this._oktaUserAgent = new _OktaUserAgent.OktaUserAgent();
85
101
  this.tx = {
86
102
  status: _tx.transactionStatus.bind(null, this),
87
103
  resume: _tx.resumeTransaction.bind(null, this),
88
- exists: Object.assign(_tx.transactionExists.bind(null, this), {
104
+ exists: (0, _assign.default)(_tx.transactionExists.bind(null, this), {
89
105
  _get: name => {
106
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
90
107
  const storage = options.storageUtil.storage;
91
108
  return storage.get(name);
92
109
  }
93
110
  }),
94
- introspect: _tx.introspect.bind(null, this)
111
+ introspect: _tx.introspectAuthn.bind(null, this)
95
112
  };
96
113
  this.pkce = {
97
114
  DEFAULT_CODE_CHALLENGE_METHOD: _pkce.default.DEFAULT_CODE_CHALLENGE_METHOD,
@@ -99,7 +116,7 @@ class OktaAuth {
99
116
  computeChallenge: _pkce.default.computeChallenge
100
117
  }; // Add shims for compatibility, these will be removed in next major version. OKTA-362589
101
118
 
102
- Object.assign(this.options.storageUtil, {
119
+ (0, _assign.default)(this.options.storageUtil, {
103
120
  getPKCEStorage: this.storageManager.getLegacyPKCEStorage.bind(this.storageManager),
104
121
  getHttpCache: this.storageManager.getHttpCache.bind(this.storageManager)
105
122
  });
@@ -108,13 +125,10 @@ class OktaAuth {
108
125
  };
109
126
 
110
127
  if ((0, features.isBrowser)()) {
111
- this.options = Object.assign(this.options, {
128
+ this.options = (0, _assign.default)(this.options, {
112
129
  redirectUri: (0, _util.toAbsoluteUrl)(args.redirectUri, window.location.origin) // allow relative URIs
113
130
 
114
131
  });
115
- this.userAgent = (0, _builderUtil.getUserAgent)(args, `okta-auth-js/${"5.11.0"}`);
116
- } else {
117
- this.userAgent = (0, _builderUtil.getUserAgent)(args, `okta-auth-js-server/${"5.11.0"}`);
118
132
  } // Digital clocks will drift over time, so the server
119
133
  // can misalign with the time reported by the browser.
120
134
  // The maxClockSkew allows relaxing the time-based
@@ -142,13 +156,42 @@ class OktaAuth {
142
156
  setCookieAndRedirect: _session.setCookieAndRedirect.bind(null, this)
143
157
  };
144
158
  this._tokenQueue = new _PromiseQueue.default();
159
+
160
+ const useQueue = method => {
161
+ return _PromiseQueue.default.prototype.push.bind(this._tokenQueue, method, null);
162
+ }; // eslint-disable-next-line max-len
163
+
164
+
165
+ const getWithRedirectFn = useQueue(_oidc.getWithRedirect.bind(null, this));
166
+ const getWithRedirectApi = (0, _assign.default)(getWithRedirectFn, {
167
+ // This is exposed so we can set window.location in our tests
168
+ _setLocation: function (url) {
169
+ window.location = url;
170
+ }
171
+ }); // eslint-disable-next-line max-len
172
+
173
+ const parseFromUrlFn = useQueue(_oidc.parseFromUrl.bind(null, this));
174
+ const parseFromUrlApi = (0, _assign.default)(parseFromUrlFn, {
175
+ // This is exposed so we can mock getting window.history in our tests
176
+ _getHistory: function () {
177
+ return window.history;
178
+ },
179
+ // This is exposed so we can mock getting window.location in our tests
180
+ _getLocation: function () {
181
+ return window.location;
182
+ },
183
+ // This is exposed so we can mock getting window.document in our tests
184
+ _getDocument: function () {
185
+ return window.document;
186
+ }
187
+ });
145
188
  this.token = {
146
189
  prepareTokenParams: _oidc.prepareTokenParams.bind(null, this),
147
190
  exchangeCodeForTokens: _oidc.exchangeCodeForTokens.bind(null, this),
148
191
  getWithoutPrompt: _oidc.getWithoutPrompt.bind(null, this),
149
192
  getWithPopup: _oidc.getWithPopup.bind(null, this),
150
- getWithRedirect: _oidc.getWithRedirect.bind(null, this),
151
- parseFromUrl: _oidc.parseFromUrl.bind(null, this),
193
+ getWithRedirect: getWithRedirectApi,
194
+ parseFromUrl: parseFromUrlApi,
152
195
  decode: _oidc.decodeToken,
153
196
  revoke: _oidc.revokeToken.bind(null, this),
154
197
  renew: _oidc.renewToken.bind(null, this),
@@ -159,55 +202,57 @@ class OktaAuth {
159
202
  isLoginRedirect: _oidc.isLoginRedirect.bind(null, this)
160
203
  }; // Wrap all async token API methods using MethodQueue to avoid issues with concurrency
161
204
 
162
- const syncMethods = ['decode', 'isLoginRedirect'];
163
- Object.keys(this.token).forEach(key => {
164
- if (syncMethods.indexOf(key) >= 0) {
205
+ const syncMethods = [// sync methods
206
+ 'decode', 'isLoginRedirect', // already bound
207
+ 'getWithRedirect', 'parseFromUrl'];
208
+ (0, _keys.default)(this.token).forEach(key => {
209
+ if ((0, _indexOf.default)(syncMethods).call(syncMethods, key) >= 0) {
165
210
  // sync methods should not be wrapped
166
211
  return;
167
212
  }
168
213
 
169
214
  var method = this.token[key];
170
215
  this.token[key] = _PromiseQueue.default.prototype.push.bind(this._tokenQueue, method, null);
171
- });
172
- Object.assign(this.token.getWithRedirect, {
173
- // This is exposed so we can set window.location in our tests
174
- _setLocation: function (url) {
175
- window.location = url;
176
- }
177
- });
178
- Object.assign(this.token.parseFromUrl, {
179
- // This is exposed so we can mock getting window.history in our tests
180
- _getHistory: function () {
181
- return window.history;
182
- },
183
- // This is exposed so we can mock getting window.location in our tests
184
- _getLocation: function () {
185
- return window.location;
186
- },
187
- // This is exposed so we can mock getting window.document in our tests
188
- _getDocument: function () {
189
- return window.document;
190
- }
191
216
  }); // IDX
192
217
 
218
+ const boundStartTransaction = _idx.startTransaction.bind(null, this);
219
+
193
220
  this.idx = {
194
221
  interact: _idx.interact.bind(null, this),
195
222
  introspect: _idx.introspect.bind(null, this),
196
223
  authenticate: _idx.authenticate.bind(null, this),
197
224
  register: _idx.register.bind(null, this),
225
+ start: boundStartTransaction,
226
+ startTransaction: boundStartTransaction,
227
+ // Use `start` instead. `startTransaction` will be removed in 7.0
198
228
  poll: _idx.poll.bind(null, this),
199
229
  proceed: _idx.proceed.bind(null, this),
200
230
  cancel: _idx.cancel.bind(null, this),
201
231
  recoverPassword: _idx.recoverPassword.bind(null, this),
232
+ // oauth redirect callback
202
233
  handleInteractionCodeRedirect: _idx.handleInteractionCodeRedirect.bind(null, this),
203
- startTransaction: _idx.startTransaction.bind(null, this),
234
+ // interaction required callback
235
+ isInteractionRequired: _oidc.isInteractionRequired.bind(null, this),
236
+ isInteractionRequiredError: _oidc.isInteractionRequiredError,
237
+ // email verify callback
238
+ handleEmailVerifyCallback: _idx.handleEmailVerifyCallback.bind(null, this),
239
+ isEmailVerifyCallback: _idx.isEmailVerifyCallback,
240
+ parseEmailVerifyCallback: _idx.parseEmailVerifyCallback,
241
+ isEmailVerifyCallbackError: _idx.isEmailVerifyCallbackError,
242
+ getSavedTransactionMeta: _transactionMeta.getSavedTransactionMeta.bind(null, this),
243
+ createTransactionMeta: _transactionMeta.createTransactionMeta.bind(null, this),
244
+ getTransactionMeta: _transactionMeta.getTransactionMeta.bind(null, this),
245
+ saveTransactionMeta: _transactionMeta.saveTransactionMeta.bind(null, this),
246
+ clearTransactionMeta: _transactionMeta.clearTransactionMeta.bind(null, this),
247
+ isTransactionMetaValid: _transactionMeta.isTransactionMetaValid,
204
248
  setFlow: flow => {
205
249
  this.options.flow = flow;
206
250
  },
207
251
  getFlow: () => {
208
252
  return this.options.flow;
209
253
  },
210
- canProceed: _idx.canProceed.bind(null, this)
254
+ canProceed: _idx.canProceed.bind(null, this),
255
+ unlockAccount: _idx.unlockAccount.bind(null, this)
211
256
  };
212
257
  (0, _headers.setGlobalRequestInterceptor)((0, _headers.createGlobalRequestInterceptor)(this)); // to pass custom headers to IDX endpoints
213
258
  // HTTP
@@ -217,54 +262,41 @@ class OktaAuth {
217
262
  }; // Fingerprint API
218
263
 
219
264
  this.fingerprint = _fingerprint.default.bind(null, this);
220
- this.emitter = new Emitter(); // TokenManager
265
+ this.emitter = new _tinyEmitter.default(); // TokenManager
221
266
 
222
267
  this.tokenManager = new _TokenManager.TokenManager(this, args.tokenManager); // AuthStateManager
223
268
 
224
- this.authStateManager = new _AuthStateManager.AuthStateManager(this);
269
+ this.authStateManager = new _AuthStateManager.AuthStateManager(this); // ServiceManager
270
+
271
+ this.serviceManager = new _ServiceManager.ServiceManager(this, args.services);
225
272
  }
226
273
 
227
274
  start() {
275
+ // TODO: review tokenManager.start
228
276
  this.tokenManager.start();
229
277
 
230
278
  if (!this.token.isLoginRedirect()) {
231
279
  this.authStateManager.updateAuthState();
232
280
  }
281
+
282
+ this.serviceManager.start();
233
283
  }
234
284
 
235
285
  stop() {
286
+ // TODO: review tokenManager.stop
236
287
  this.tokenManager.stop();
288
+ this.serviceManager.stop();
237
289
  }
238
290
 
239
291
  setHeaders(headers) {
240
- this.options.headers = Object.assign({}, this.options.headers, headers);
241
- } // ES6 module users can use named exports to access all symbols
242
- // CommonJS module users (CDN) need all exports on this object
243
- // Utility methods for interaction code flow
292
+ this.options.headers = (0, _assign.default)({}, this.options.headers, headers);
293
+ } // Authn V1
244
294
 
245
295
 
246
- isInteractionRequired(hashOrSearch) {
247
- return (0, _oidc.isInteractionRequired)(this, hashOrSearch);
248
- }
249
-
250
- isInteractionRequiredError(error) {
251
- return (0, _oidc.isInteractionRequiredError)(error);
252
- } // Utility methods for email verify callback
253
-
254
-
255
- isEmailVerifyCallback(urlPath) {
256
- return (0, _util.isEmailVerifyCallback)(urlPath);
257
- }
258
-
259
- parseEmailVerifyCallback(urlPath) {
260
- return (0, _util.parseEmailVerifyCallback)(urlPath);
261
- }
262
-
263
296
  async signIn(opts) {
264
- // TODO: support interaction code flow
265
- // Authn V1 flow
266
297
  return this.signInWithCredentials(opts);
267
- }
298
+ } // Authn V1
299
+
268
300
 
269
301
  async signInWithCredentials(opts) {
270
302
  opts = (0, _util.clone)(opts || {});
@@ -306,7 +338,7 @@ class OktaAuth {
306
338
  this.setOriginalUri(originalUri);
307
339
  }
308
340
 
309
- const params = Object.assign({
341
+ const params = (0, _assign.default)({
310
342
  // TODO: remove this line when default scopes are changed OKTA-343294
311
343
  scopes: this.options.scopes || ['openid', 'email', 'profile']
312
344
  }, additionalParams);
@@ -342,7 +374,7 @@ class OktaAuth {
342
374
 
343
375
 
344
376
  if (!accessToken) {
345
- return Promise.resolve(null);
377
+ return _promise.default.resolve(null);
346
378
  }
347
379
 
348
380
  return this.token.revoke(accessToken);
@@ -358,7 +390,7 @@ class OktaAuth {
358
390
 
359
391
 
360
392
  if (!refreshToken) {
361
- return Promise.resolve(null);
393
+ return _promise.default.resolve(null);
362
394
  }
363
395
 
364
396
  return this.token.revoke(refreshToken);
@@ -402,7 +434,7 @@ class OktaAuth {
402
434
 
403
435
 
404
436
  async signOut(options) {
405
- options = Object.assign({}, options); // postLogoutRedirectUri must be whitelisted in Okta Admin UI
437
+ options = (0, _assign.default)({}, options); // postLogoutRedirectUri must be whitelisted in Okta Admin UI
406
438
 
407
439
  var defaultUri = window.location.origin;
408
440
  var currentUri = window.location.href;
@@ -448,11 +480,11 @@ class OktaAuth {
448
480
  }
449
481
  });
450
482
  } else {
451
- if (options.clearTokensAfterRedirect) {
452
- this.tokenManager.addPendingRemoveFlags();
453
- } else {
483
+ if (options.clearTokensBeforeRedirect) {
454
484
  // Clear all local tokens
455
485
  this.tokenManager.clear();
486
+ } else {
487
+ this.tokenManager.addPendingRemoveFlags();
456
488
  } // Flow ends with logout redirect
457
489
 
458
490
 
@@ -475,38 +507,44 @@ class OktaAuth {
475
507
  // If `autoRenew` option is set, will attempt to renew expired tokens before returning.
476
508
 
477
509
 
478
- async isAuthenticated() {
479
- let {
480
- accessToken,
481
- idToken
482
- } = this.tokenManager.getTokensSync();
510
+ async isAuthenticated(options = {}) {
511
+ // TODO: remove dependency on tokenManager options in next major version - OKTA-473815
483
512
  const {
484
513
  autoRenew,
485
514
  autoRemove
486
515
  } = this.tokenManager.getOptions();
516
+ const shouldRenew = options.onExpiredToken ? options.onExpiredToken === 'renew' : autoRenew;
517
+ const shouldRemove = options.onExpiredToken ? options.onExpiredToken === 'remove' : autoRemove;
518
+ let {
519
+ accessToken
520
+ } = this.tokenManager.getTokensSync();
487
521
 
488
522
  if (accessToken && this.tokenManager.hasExpired(accessToken)) {
489
- accessToken = null;
523
+ accessToken = undefined;
490
524
 
491
- if (autoRenew) {
525
+ if (shouldRenew) {
492
526
  try {
493
527
  accessToken = await this.tokenManager.renew('accessToken');
494
528
  } catch {// Renew errors will emit an "error" event
495
529
  }
496
- } else if (autoRemove) {
530
+ } else if (shouldRemove) {
497
531
  this.tokenManager.remove('accessToken');
498
532
  }
499
533
  }
500
534
 
535
+ let {
536
+ idToken
537
+ } = this.tokenManager.getTokensSync();
538
+
501
539
  if (idToken && this.tokenManager.hasExpired(idToken)) {
502
- idToken = null;
540
+ idToken = undefined;
503
541
 
504
- if (autoRenew) {
542
+ if (shouldRenew) {
505
543
  try {
506
544
  idToken = await this.tokenManager.renew('idToken');
507
545
  } catch {// Renew errors will emit an "error" event
508
546
  }
509
- } else if (autoRemove) {
547
+ } else if (shouldRemove) {
510
548
  this.tokenManager.remove('idToken');
511
549
  }
512
550
  }
@@ -584,7 +622,7 @@ class OktaAuth {
584
622
 
585
623
  const storage = _browserStorage.default.getSessionStorage();
586
624
 
587
- return storage ? storage.getItem(constants.REFERRER_PATH_STORAGE_KEY) : undefined;
625
+ return storage ? storage.getItem(constants.REFERRER_PATH_STORAGE_KEY) || undefined : undefined;
588
626
  }
589
627
 
590
628
  removeOriginalUri(state) {
@@ -597,7 +635,7 @@ class OktaAuth {
597
635
 
598
636
  if (state) {
599
637
  const sharedStorage = this.storageManager.getOriginalUriStorage();
600
- sharedStorage.removeItem(state);
638
+ sharedStorage.removeItem && sharedStorage.removeItem(state);
601
639
  }
602
640
  }
603
641
 
@@ -612,11 +650,17 @@ class OktaAuth {
612
650
  this.tokenManager.setTokens(tokens);
613
651
  originalUri = originalUri || this.getOriginalUri(this.options.state);
614
652
  } else if (this.isLoginRedirect()) {
615
- // For redirect flow, get state from the URL and use it to retrieve the originalUri
616
- const oAuthResponse = await (0, _parseFromUrl.parseOAuthResponseFromUrl)(this, {});
617
- state = oAuthResponse.state;
618
- originalUri = originalUri || this.getOriginalUri(state);
619
- await this.storeTokensFromRedirect();
653
+ try {
654
+ // For redirect flow, get state from the URL and use it to retrieve the originalUri
655
+ const oAuthResponse = await (0, _parseFromUrl.parseOAuthResponseFromUrl)(this, {});
656
+ state = oAuthResponse.state;
657
+ originalUri = originalUri || this.getOriginalUri(state);
658
+ await this.storeTokensFromRedirect();
659
+ } catch (e) {
660
+ // auth state should be updated
661
+ await this.authStateManager.updateAuthState();
662
+ throw e;
663
+ }
620
664
  } else {
621
665
  return; // nothing to do
622
666
  } // ensure auth state has been updated
@@ -632,7 +676,7 @@ class OktaAuth {
632
676
 
633
677
  if (restoreOriginalUri) {
634
678
  await restoreOriginalUri(this, originalUri);
635
- } else {
679
+ } else if (originalUri) {
636
680
  window.location.replace(originalUri);
637
681
  }
638
682
  }
@@ -645,7 +689,9 @@ class OktaAuth {
645
689
  let hasResponseType = false;
646
690
 
647
691
  if (Array.isArray(this.options.responseType) && this.options.responseType.length) {
648
- hasResponseType = this.options.responseType.indexOf(responseType) >= 0;
692
+ var _context;
693
+
694
+ hasResponseType = (0, _indexOf.default)(_context = this.options.responseType).call(_context, responseType) >= 0;
649
695
  } else {
650
696
  hasResponseType = this.options.responseType === responseType;
651
697
  }
@@ -663,6 +709,7 @@ class OktaAuth {
663
709
 
664
710
  getIssuerOrigin() {
665
711
  // Infer the URL from the issuer URL, omitting the /oauth2/{authServerId}
712
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
666
713
  return this.options.issuer.split('/oauth2/')[0];
667
714
  } // { username, (relayState) }
668
715
 
@@ -679,16 +726,29 @@ class OktaAuth {
679
726
 
680
727
  verifyRecoveryToken(opts) {
681
728
  return (0, _tx.postToTransaction)(this, '/api/v1/authn/recovery/token', opts);
729
+ } // Escape hatch method to make arbitrary OKTA API call
730
+
731
+
732
+ async invokeApiMethod(options) {
733
+ if (!options.accessToken) {
734
+ const accessToken = (await this.tokenManager.getTokens()).accessToken;
735
+ options.accessToken = accessToken === null || accessToken === void 0 ? void 0 : accessToken.accessToken;
736
+ }
737
+
738
+ return (0, _http.httpRequest)(this, options);
682
739
  }
683
740
 
684
741
  } // Hoist feature detection functions to static type
685
742
 
686
743
 
687
- OktaAuth.features = OktaAuth.prototype.features = features; // Also hoist values and utility functions for CommonJS users
744
+ OktaAuth.features = OktaAuth.prototype.features = features; // Hoist crypto utils to static type
745
+
746
+ OktaAuth.crypto = crypto; // Hoist webauthn utils to static type
747
+
748
+ OktaAuth.webauthn = webauthn; // Also hoist constants for CommonJS users
688
749
 
689
- Object.assign(OktaAuth, {
690
- constants,
691
- isInteractionRequiredError: _oidc.isInteractionRequiredError
750
+ (0, _assign.default)(OktaAuth, {
751
+ constants
692
752
  });
693
753
  var _default = OktaAuth;
694
754
  exports.default = _default;