@okta/okta-auth-js 5.5.0 → 5.9.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 (424) hide show
  1. package/CHANGELOG.md +66 -4
  2. package/README.md +61 -15
  3. package/cjs/AuthStateManager.js +5 -0
  4. package/cjs/AuthStateManager.js.map +1 -1
  5. package/cjs/OktaAuth.js +78 -29
  6. package/cjs/OktaAuth.js.map +1 -1
  7. package/cjs/OktaUserAgent.js +2 -2
  8. package/cjs/StorageManager.js +16 -0
  9. package/cjs/StorageManager.js.map +1 -1
  10. package/cjs/TransactionManager.js +49 -9
  11. package/cjs/TransactionManager.js.map +1 -1
  12. package/cjs/builderUtil.js +6 -0
  13. package/cjs/builderUtil.js.map +1 -1
  14. package/cjs/constants.js +5 -1
  15. package/cjs/constants.js.map +1 -1
  16. package/cjs/features.js +1 -1
  17. package/cjs/features.js.map +1 -1
  18. package/cjs/idx/authenticate.js +3 -18
  19. package/cjs/idx/authenticate.js.map +1 -1
  20. package/cjs/idx/flow/AuthenticationFlow.js +30 -0
  21. package/cjs/idx/flow/AuthenticationFlow.js.map +1 -0
  22. package/cjs/idx/{flowMonitors → flow}/AuthenticationFlowMonitor.js +0 -0
  23. package/cjs/idx/flow/AuthenticationFlowMonitor.js.map +1 -0
  24. package/cjs/idx/{flowMonitors → flow}/FlowMonitor.js +0 -0
  25. package/cjs/idx/flow/FlowMonitor.js.map +1 -0
  26. package/cjs/idx/flow/FlowSpecification.js +49 -0
  27. package/cjs/idx/flow/FlowSpecification.js.map +1 -0
  28. package/cjs/idx/flow/PasswordRecoveryFlow.js +28 -0
  29. package/cjs/idx/flow/PasswordRecoveryFlow.js.map +1 -0
  30. package/cjs/idx/{flowMonitors → flow}/PasswordRecoveryFlowMonitor.js +0 -0
  31. package/cjs/idx/flow/PasswordRecoveryFlowMonitor.js.map +1 -0
  32. package/{esm/crypto/browser.js → cjs/idx/flow/RegistrationFlow.js} +15 -12
  33. package/cjs/idx/flow/RegistrationFlow.js.map +1 -0
  34. package/cjs/idx/{flowMonitors → flow}/RegistrationFlowMonitor.js +0 -0
  35. package/cjs/idx/flow/RegistrationFlowMonitor.js.map +1 -0
  36. package/cjs/idx/flow/RemediationFlow.js +2 -0
  37. package/{esm/types/Cookies.js.map → cjs/idx/flow/RemediationFlow.js.map} +1 -1
  38. package/cjs/idx/flow/index.js +119 -0
  39. package/cjs/idx/flow/index.js.map +1 -0
  40. package/cjs/idx/index.js +26 -0
  41. package/cjs/idx/index.js.map +1 -1
  42. package/cjs/idx/interact.js +5 -2
  43. package/cjs/idx/interact.js.map +1 -1
  44. package/cjs/idx/introspect.js +24 -7
  45. package/cjs/idx/introspect.js.map +1 -1
  46. package/cjs/idx/proceed.js +49 -0
  47. package/cjs/idx/proceed.js.map +1 -0
  48. package/cjs/idx/recoverPassword.js +3 -17
  49. package/cjs/idx/recoverPassword.js.map +1 -1
  50. package/cjs/idx/register.js +7 -16
  51. package/cjs/idx/register.js.map +1 -1
  52. package/cjs/idx/remediate.js +46 -52
  53. package/cjs/idx/remediate.js.map +1 -1
  54. package/cjs/idx/remediators/Base/AuthenticatorData.js +7 -7
  55. package/cjs/idx/remediators/Base/AuthenticatorData.js.map +1 -1
  56. package/cjs/idx/remediators/Base/Remediator.js +13 -7
  57. package/cjs/idx/remediators/Base/Remediator.js.map +1 -1
  58. package/cjs/idx/remediators/Base/SelectAuthenticator.js +6 -6
  59. package/cjs/idx/remediators/Base/SelectAuthenticator.js.map +1 -1
  60. package/cjs/idx/remediators/Base/VerifyAuthenticator.js +18 -14
  61. package/cjs/idx/remediators/Base/VerifyAuthenticator.js.map +1 -1
  62. package/cjs/idx/remediators/EnrollProfile.js +14 -0
  63. package/cjs/idx/remediators/EnrollProfile.js.map +1 -1
  64. package/cjs/idx/remediators/Identify.js +7 -3
  65. package/cjs/idx/remediators/Identify.js.map +1 -1
  66. package/cjs/idx/remediators/ReEnrollAuthenticator.js +1 -1
  67. package/cjs/idx/remediators/ReEnrollAuthenticator.js.map +1 -1
  68. package/cjs/idx/run.js +36 -8
  69. package/cjs/idx/run.js.map +1 -1
  70. package/cjs/idx/startTransaction.js +2 -0
  71. package/cjs/idx/startTransaction.js.map +1 -1
  72. package/cjs/idx/transactionMeta.js +80 -40
  73. package/cjs/idx/transactionMeta.js.map +1 -1
  74. package/cjs/idx/types/FlowIdentifier.js +2 -0
  75. package/{esm/types/AuthState.js.map → cjs/idx/types/FlowIdentifier.js.map} +1 -1
  76. package/cjs/idx/types/idx-js.js +5 -0
  77. package/cjs/idx/types/idx-js.js.map +1 -1
  78. package/cjs/idx/types/index.js +33 -6
  79. package/cjs/idx/types/index.js.map +1 -1
  80. package/cjs/oidc/endpoints/authorize.js +4 -1
  81. package/cjs/oidc/endpoints/authorize.js.map +1 -1
  82. package/cjs/oidc/getToken.js +14 -9
  83. package/cjs/oidc/getToken.js.map +1 -1
  84. package/cjs/oidc/getWithPopup.js +9 -2
  85. package/cjs/oidc/getWithPopup.js.map +1 -1
  86. package/cjs/oidc/getWithRedirect.js.map +1 -1
  87. package/cjs/oidc/parseFromUrl.js +59 -20
  88. package/cjs/oidc/parseFromUrl.js.map +1 -1
  89. package/cjs/oidc/renewTokens.js +28 -5
  90. package/cjs/oidc/renewTokens.js.map +1 -1
  91. package/cjs/oidc/util/browser.js +1 -13
  92. package/cjs/oidc/util/browser.js.map +1 -1
  93. package/cjs/oidc/util/loginRedirect.js +9 -5
  94. package/cjs/oidc/util/loginRedirect.js.map +1 -1
  95. package/cjs/oidc/util/urlParams.js +1 -1
  96. package/cjs/oidc/util/urlParams.js.map +1 -1
  97. package/cjs/options.js +15 -2
  98. package/cjs/options.js.map +1 -1
  99. package/cjs/server/serverStorage.js +2 -1
  100. package/cjs/server/serverStorage.js.map +1 -1
  101. package/cjs/tx/AuthTransaction.js +1 -3
  102. package/cjs/tx/AuthTransaction.js.map +1 -1
  103. package/cjs/tx/api.js +3 -0
  104. package/cjs/tx/api.js.map +1 -1
  105. package/cjs/types/Transaction.js.map +1 -1
  106. package/{esm/clock.js → cjs/util/emailVerify.js} +14 -18
  107. package/cjs/util/emailVerify.js.map +1 -0
  108. package/cjs/util/index.js +13 -0
  109. package/cjs/util/index.js.map +1 -1
  110. package/cjs/util/sharedStorage.js +54 -0
  111. package/cjs/util/sharedStorage.js.map +1 -0
  112. package/dist/okta-auth-js.min.js +2 -74
  113. package/dist/okta-auth-js.min.js.LICENSE.txt +32 -0
  114. package/dist/okta-auth-js.min.js.map +1 -1
  115. package/dist/okta-auth-js.polyfill.js +2 -18
  116. package/{esm/crypto/webcrypto.js → dist/okta-auth-js.polyfill.js.LICENSE.txt} +8 -4
  117. package/dist/okta-auth-js.polyfill.js.map +1 -1
  118. package/dist/okta-auth-js.umd.js +2 -74
  119. package/dist/okta-auth-js.umd.js.LICENSE.txt +32 -0
  120. package/dist/okta-auth-js.umd.js.map +1 -1
  121. package/esm/index.js +8368 -16
  122. package/esm/index.js.map +1 -1
  123. package/lib/AuthStateManager.d.ts +4 -2
  124. package/lib/OktaAuth.d.ts +9 -5
  125. package/lib/StorageManager.d.ts +2 -0
  126. package/lib/TransactionManager.d.ts +6 -1
  127. package/lib/constants.d.ts +2 -0
  128. package/lib/crypto/base64.d.ts +2 -2
  129. package/lib/crypto/oidcHash.d.ts +1 -1
  130. package/lib/crypto/verifyToken.d.ts +1 -1
  131. package/{esm/oidc/endpoints/index.js → lib/idx/flow/AuthenticationFlow.d.ts} +3 -5
  132. package/lib/idx/{flowMonitors → flow}/AuthenticationFlowMonitor.d.ts +0 -0
  133. package/lib/idx/{flowMonitors → flow}/FlowMonitor.d.ts +0 -0
  134. package/lib/idx/flow/FlowSpecification.d.ts +10 -0
  135. package/{esm/crypto/index.js → lib/idx/flow/PasswordRecoveryFlow.d.ts} +3 -6
  136. package/lib/idx/{flowMonitors → flow}/PasswordRecoveryFlowMonitor.d.ts +0 -0
  137. package/{esm/tx/TransactionState.js → lib/idx/flow/RegistrationFlow.d.ts} +3 -3
  138. package/lib/idx/{flowMonitors → flow}/RegistrationFlowMonitor.d.ts +0 -0
  139. package/lib/idx/flow/RemediationFlow.d.ts +13 -0
  140. package/lib/idx/{flowMonitors → flow}/index.d.ts +7 -2
  141. package/lib/idx/index.d.ts +2 -0
  142. package/lib/idx/introspect.d.ts +2 -1
  143. package/{esm/errors/AuthApiError.js → lib/idx/proceed.d.ts} +9 -19
  144. package/lib/idx/remediators/Base/AuthenticatorData.d.ts +2 -5
  145. package/lib/idx/remediators/Base/Remediator.d.ts +3 -6
  146. package/lib/idx/remediators/Base/SelectAuthenticator.d.ts +3 -6
  147. package/lib/idx/remediators/Base/VerifyAuthenticator.d.ts +1 -1
  148. package/lib/idx/remediators/EnrollProfile.d.ts +1 -0
  149. package/lib/idx/remediators/Identify.d.ts +2 -5
  150. package/lib/idx/run.d.ts +9 -9
  151. package/lib/idx/transactionMeta.d.ts +28 -4
  152. package/lib/idx/types/FlowIdentifier.d.ts +1 -0
  153. package/lib/idx/types/idx-js.d.ts +5 -0
  154. package/lib/idx/types/index.d.ts +28 -10
  155. package/lib/oidc/getToken.d.ts +2 -2
  156. package/lib/oidc/parseFromUrl.d.ts +4 -1
  157. package/lib/oidc/renewTokens.d.ts +0 -12
  158. package/lib/oidc/util/loginRedirect.d.ts +1 -1
  159. package/lib/types/AuthState.d.ts +1 -0
  160. package/lib/types/OktaAuthOptions.d.ts +3 -1
  161. package/lib/types/Transaction.d.ts +7 -1
  162. package/lib/types/api.d.ts +21 -5
  163. package/{esm/errors/AuthPollStopError.js → lib/util/emailVerify.d.ts} +5 -8
  164. package/lib/util/index.d.ts +1 -0
  165. package/lib/util/sharedStorage.d.ts +6 -0
  166. package/package.json +26 -13
  167. package/cjs/idx/flowMonitors/AuthenticationFlowMonitor.js.map +0 -1
  168. package/cjs/idx/flowMonitors/FlowMonitor.js.map +0 -1
  169. package/cjs/idx/flowMonitors/PasswordRecoveryFlowMonitor.js.map +0 -1
  170. package/cjs/idx/flowMonitors/RegistrationFlowMonitor.js.map +0 -1
  171. package/cjs/idx/flowMonitors/index.js +0 -54
  172. package/cjs/idx/flowMonitors/index.js.map +0 -1
  173. package/esm/AuthStateManager.js +0 -209
  174. package/esm/AuthStateManager.js.map +0 -1
  175. package/esm/OktaAuth.js +0 -665
  176. package/esm/OktaAuth.js.map +0 -1
  177. package/esm/OktaUserAgent.js +0 -49
  178. package/esm/OktaUserAgent.js.map +0 -1
  179. package/esm/PromiseQueue.js +0 -71
  180. package/esm/PromiseQueue.js.map +0 -1
  181. package/esm/SavedObject.js +0 -91
  182. package/esm/SavedObject.js.map +0 -1
  183. package/esm/StorageManager.js +0 -174
  184. package/esm/StorageManager.js.map +0 -1
  185. package/esm/TokenManager.js +0 -455
  186. package/esm/TokenManager.js.map +0 -1
  187. package/esm/TransactionManager.js +0 -289
  188. package/esm/TransactionManager.js.map +0 -1
  189. package/esm/browser/browserStorage.js +0 -256
  190. package/esm/browser/browserStorage.js.map +0 -1
  191. package/esm/browser/fingerprint.js +0 -74
  192. package/esm/browser/fingerprint.js.map +0 -1
  193. package/esm/builderUtil.js +0 -50
  194. package/esm/builderUtil.js.map +0 -1
  195. package/esm/clock.js.map +0 -1
  196. package/esm/constants.js +0 -34
  197. package/esm/constants.js.map +0 -1
  198. package/esm/crypto/base64.js +0 -66
  199. package/esm/crypto/base64.js.map +0 -1
  200. package/esm/crypto/browser.js.map +0 -1
  201. package/esm/crypto/index.js.map +0 -1
  202. package/esm/crypto/node.js +0 -54
  203. package/esm/crypto/node.js.map +0 -1
  204. package/esm/crypto/oidcHash.js +0 -27
  205. package/esm/crypto/oidcHash.js.map +0 -1
  206. package/esm/crypto/verifyToken.js +0 -39
  207. package/esm/crypto/verifyToken.js.map +0 -1
  208. package/esm/crypto/webcrypto.js.map +0 -1
  209. package/esm/errors/AuthApiError.js.map +0 -1
  210. package/esm/errors/AuthPollStopError.js.map +0 -1
  211. package/esm/errors/AuthSdkError.js +0 -29
  212. package/esm/errors/AuthSdkError.js.map +0 -1
  213. package/esm/errors/CustomError.js +0 -21
  214. package/esm/errors/CustomError.js.map +0 -1
  215. package/esm/errors/OAuthError.js +0 -22
  216. package/esm/errors/OAuthError.js.map +0 -1
  217. package/esm/errors/index.js +0 -22
  218. package/esm/errors/index.js.map +0 -1
  219. package/esm/features.js +0 -64
  220. package/esm/features.js.map +0 -1
  221. package/esm/fetch/fetchRequest.js +0 -92
  222. package/esm/fetch/fetchRequest.js.map +0 -1
  223. package/esm/http/headers.js +0 -17
  224. package/esm/http/headers.js.map +0 -1
  225. package/esm/http/index.js +0 -3
  226. package/esm/http/index.js.map +0 -1
  227. package/esm/http/request.js +0 -145
  228. package/esm/http/request.js.map +0 -1
  229. package/esm/idx/authenticate.js +0 -47
  230. package/esm/idx/authenticate.js.map +0 -1
  231. package/esm/idx/cancel.js +0 -32
  232. package/esm/idx/cancel.js.map +0 -1
  233. package/esm/idx/flowMonitors/AuthenticationFlowMonitor.js +0 -41
  234. package/esm/idx/flowMonitors/AuthenticationFlowMonitor.js.map +0 -1
  235. package/esm/idx/flowMonitors/FlowMonitor.js +0 -73
  236. package/esm/idx/flowMonitors/FlowMonitor.js.map +0 -1
  237. package/esm/idx/flowMonitors/PasswordRecoveryFlowMonitor.js +0 -57
  238. package/esm/idx/flowMonitors/PasswordRecoveryFlowMonitor.js.map +0 -1
  239. package/esm/idx/flowMonitors/RegistrationFlowMonitor.js +0 -28
  240. package/esm/idx/flowMonitors/RegistrationFlowMonitor.js.map +0 -1
  241. package/esm/idx/flowMonitors/index.js +0 -16
  242. package/esm/idx/flowMonitors/index.js.map +0 -1
  243. package/esm/idx/handleInteractionCodeRedirect.js +0 -64
  244. package/esm/idx/handleInteractionCodeRedirect.js.map +0 -1
  245. package/esm/idx/headers.js +0 -39
  246. package/esm/idx/headers.js.map +0 -1
  247. package/esm/idx/index.js +0 -20
  248. package/esm/idx/index.js.map +0 -1
  249. package/esm/idx/interact.js +0 -83
  250. package/esm/idx/interact.js.map +0 -1
  251. package/esm/idx/introspect.js +0 -45
  252. package/esm/idx/introspect.js.map +0 -1
  253. package/esm/idx/recoverPassword.js +0 -46
  254. package/esm/idx/recoverPassword.js.map +0 -1
  255. package/esm/idx/register.js +0 -63
  256. package/esm/idx/register.js.map +0 -1
  257. package/esm/idx/remediate.js +0 -303
  258. package/esm/idx/remediate.js.map +0 -1
  259. package/esm/idx/remediators/AuthenticatorEnrollmentData.js +0 -68
  260. package/esm/idx/remediators/AuthenticatorEnrollmentData.js.map +0 -1
  261. package/esm/idx/remediators/AuthenticatorVerificationData.js +0 -66
  262. package/esm/idx/remediators/AuthenticatorVerificationData.js.map +0 -1
  263. package/esm/idx/remediators/Base/AuthenticatorData.js +0 -105
  264. package/esm/idx/remediators/Base/AuthenticatorData.js.map +0 -1
  265. package/esm/idx/remediators/Base/Remediator.js +0 -216
  266. package/esm/idx/remediators/Base/Remediator.js.map +0 -1
  267. package/esm/idx/remediators/Base/SelectAuthenticator.js +0 -140
  268. package/esm/idx/remediators/Base/SelectAuthenticator.js.map +0 -1
  269. package/esm/idx/remediators/Base/VerifyAuthenticator.js +0 -62
  270. package/esm/idx/remediators/Base/VerifyAuthenticator.js.map +0 -1
  271. package/esm/idx/remediators/ChallengeAuthenticator.js +0 -18
  272. package/esm/idx/remediators/ChallengeAuthenticator.js.map +0 -1
  273. package/esm/idx/remediators/EnrollAuthenticator.js +0 -18
  274. package/esm/idx/remediators/EnrollAuthenticator.js.map +0 -1
  275. package/esm/idx/remediators/EnrollProfile.js +0 -62
  276. package/esm/idx/remediators/EnrollProfile.js.map +0 -1
  277. package/esm/idx/remediators/Identify.js +0 -85
  278. package/esm/idx/remediators/Identify.js.map +0 -1
  279. package/esm/idx/remediators/ReEnrollAuthenticator.js +0 -45
  280. package/esm/idx/remediators/ReEnrollAuthenticator.js.map +0 -1
  281. package/esm/idx/remediators/RedirectIdp.js +0 -38
  282. package/esm/idx/remediators/RedirectIdp.js.map +0 -1
  283. package/esm/idx/remediators/ResetAuthenticator.js +0 -18
  284. package/esm/idx/remediators/ResetAuthenticator.js.map +0 -1
  285. package/esm/idx/remediators/SelectAuthenticatorAuthenticate.js +0 -18
  286. package/esm/idx/remediators/SelectAuthenticatorAuthenticate.js.map +0 -1
  287. package/esm/idx/remediators/SelectAuthenticatorEnroll.js +0 -18
  288. package/esm/idx/remediators/SelectAuthenticatorEnroll.js.map +0 -1
  289. package/esm/idx/remediators/SelectEnrollProfile.js +0 -24
  290. package/esm/idx/remediators/SelectEnrollProfile.js.map +0 -1
  291. package/esm/idx/remediators/Skip.js +0 -23
  292. package/esm/idx/remediators/Skip.js.map +0 -1
  293. package/esm/idx/remediators/index.js +0 -26
  294. package/esm/idx/remediators/index.js.map +0 -1
  295. package/esm/idx/remediators/util.js +0 -35
  296. package/esm/idx/remediators/util.js.map +0 -1
  297. package/esm/idx/run.js +0 -201
  298. package/esm/idx/run.js.map +0 -1
  299. package/esm/idx/startTransaction.js +0 -27
  300. package/esm/idx/startTransaction.js.map +0 -1
  301. package/esm/idx/transactionMeta.js +0 -112
  302. package/esm/idx/transactionMeta.js.map +0 -1
  303. package/esm/idx/types/idx-js.js +0 -17
  304. package/esm/idx/types/idx-js.js.map +0 -1
  305. package/esm/idx/types/index.js +0 -34
  306. package/esm/idx/types/index.js.map +0 -1
  307. package/esm/oidc/decodeToken.js +0 -31
  308. package/esm/oidc/decodeToken.js.map +0 -1
  309. package/esm/oidc/endpoints/authorize.js +0 -61
  310. package/esm/oidc/endpoints/authorize.js.map +0 -1
  311. package/esm/oidc/endpoints/index.js.map +0 -1
  312. package/esm/oidc/endpoints/token.js +0 -97
  313. package/esm/oidc/endpoints/token.js.map +0 -1
  314. package/esm/oidc/endpoints/well-known.js +0 -58
  315. package/esm/oidc/endpoints/well-known.js.map +0 -1
  316. package/esm/oidc/exchangeCodeForTokens.js +0 -69
  317. package/esm/oidc/exchangeCodeForTokens.js.map +0 -1
  318. package/esm/oidc/getToken.js +0 -175
  319. package/esm/oidc/getToken.js.map +0 -1
  320. package/esm/oidc/getUserInfo.js +0 -82
  321. package/esm/oidc/getUserInfo.js.map +0 -1
  322. package/esm/oidc/getWithPopup.js +0 -28
  323. package/esm/oidc/getWithPopup.js.map +0 -1
  324. package/esm/oidc/getWithRedirect.js +0 -61
  325. package/esm/oidc/getWithRedirect.js.map +0 -1
  326. package/esm/oidc/getWithoutPrompt.js +0 -29
  327. package/esm/oidc/getWithoutPrompt.js.map +0 -1
  328. package/esm/oidc/handleOAuthResponse.js +0 -148
  329. package/esm/oidc/handleOAuthResponse.js.map +0 -1
  330. package/esm/oidc/index.js +0 -29
  331. package/esm/oidc/index.js.map +0 -1
  332. package/esm/oidc/parseFromUrl.js +0 -102
  333. package/esm/oidc/parseFromUrl.js.map +0 -1
  334. package/esm/oidc/renewToken.js +0 -85
  335. package/esm/oidc/renewToken.js.map +0 -1
  336. package/esm/oidc/renewTokens.js +0 -52
  337. package/esm/oidc/renewTokens.js.map +0 -1
  338. package/esm/oidc/renewTokensWithRefresh.js +0 -55
  339. package/esm/oidc/renewTokensWithRefresh.js.map +0 -1
  340. package/esm/oidc/revokeToken.js +0 -57
  341. package/esm/oidc/revokeToken.js.map +0 -1
  342. package/esm/oidc/util/browser.js +0 -85
  343. package/esm/oidc/util/browser.js.map +0 -1
  344. package/esm/oidc/util/defaultTokenParams.js +0 -42
  345. package/esm/oidc/util/defaultTokenParams.js.map +0 -1
  346. package/esm/oidc/util/errors.js +0 -31
  347. package/esm/oidc/util/errors.js.map +0 -1
  348. package/esm/oidc/util/index.js +0 -25
  349. package/esm/oidc/util/index.js.map +0 -1
  350. package/esm/oidc/util/loginRedirect.js +0 -84
  351. package/esm/oidc/util/loginRedirect.js.map +0 -1
  352. package/esm/oidc/util/oauth.js +0 -70
  353. package/esm/oidc/util/oauth.js.map +0 -1
  354. package/esm/oidc/util/pkce.js +0 -55
  355. package/esm/oidc/util/pkce.js.map +0 -1
  356. package/esm/oidc/util/prepareTokenParams.js +0 -75
  357. package/esm/oidc/util/prepareTokenParams.js.map +0 -1
  358. package/esm/oidc/util/refreshToken.js +0 -24
  359. package/esm/oidc/util/refreshToken.js.map +0 -1
  360. package/esm/oidc/util/urlParams.js +0 -54
  361. package/esm/oidc/util/urlParams.js.map +0 -1
  362. package/esm/oidc/util/validateClaims.js +0 -53
  363. package/esm/oidc/util/validateClaims.js.map +0 -1
  364. package/esm/oidc/util/validateToken.js +0 -21
  365. package/esm/oidc/util/validateToken.js.map +0 -1
  366. package/esm/oidc/verifyToken.js +0 -78
  367. package/esm/oidc/verifyToken.js.map +0 -1
  368. package/esm/options.js +0 -131
  369. package/esm/options.js.map +0 -1
  370. package/esm/server/serverStorage.js +0 -110
  371. package/esm/server/serverStorage.js.map +0 -1
  372. package/esm/services/TokenService.js +0 -103
  373. package/esm/services/TokenService.js.map +0 -1
  374. package/esm/session.js +0 -81
  375. package/esm/session.js.map +0 -1
  376. package/esm/tx/AuthTransaction.js +0 -215
  377. package/esm/tx/AuthTransaction.js.map +0 -1
  378. package/esm/tx/TransactionState.js.map +0 -1
  379. package/esm/tx/api.js +0 -84
  380. package/esm/tx/api.js.map +0 -1
  381. package/esm/tx/index.js +0 -18
  382. package/esm/tx/index.js.map +0 -1
  383. package/esm/tx/poll.js +0 -124
  384. package/esm/tx/poll.js.map +0 -1
  385. package/esm/tx/util.js +0 -26
  386. package/esm/tx/util.js.map +0 -1
  387. package/esm/types/AuthState.js +0 -3
  388. package/esm/types/Cookies.js +0 -3
  389. package/esm/types/EventEmitter.js +0 -3
  390. package/esm/types/EventEmitter.js.map +0 -1
  391. package/esm/types/JWT.js +0 -3
  392. package/esm/types/JWT.js.map +0 -1
  393. package/esm/types/OAuth.js +0 -3
  394. package/esm/types/OAuth.js.map +0 -1
  395. package/esm/types/OktaAuthOptions.js +0 -3
  396. package/esm/types/OktaAuthOptions.js.map +0 -1
  397. package/esm/types/Storage.js +0 -3
  398. package/esm/types/Storage.js.map +0 -1
  399. package/esm/types/Token.js +0 -29
  400. package/esm/types/Token.js.map +0 -1
  401. package/esm/types/TokenManager.js +0 -3
  402. package/esm/types/TokenManager.js.map +0 -1
  403. package/esm/types/Transaction.js +0 -57
  404. package/esm/types/Transaction.js.map +0 -1
  405. package/esm/types/UserClaims.js +0 -3
  406. package/esm/types/UserClaims.js.map +0 -1
  407. package/esm/types/api.js +0 -3
  408. package/esm/types/api.js.map +0 -1
  409. package/esm/types/http.js +0 -3
  410. package/esm/types/http.js.map +0 -1
  411. package/esm/types/index.js +0 -27
  412. package/esm/types/index.js.map +0 -1
  413. package/esm/util/console.js +0 -53
  414. package/esm/util/console.js.map +0 -1
  415. package/esm/util/index.js +0 -17
  416. package/esm/util/index.js.map +0 -1
  417. package/esm/util/misc.js +0 -33
  418. package/esm/util/misc.js.map +0 -1
  419. package/esm/util/object.js +0 -117
  420. package/esm/util/object.js.map +0 -1
  421. package/esm/util/types.js +0 -27
  422. package/esm/util/types.js.map +0 -1
  423. package/esm/util/url.js +0 -64
  424. package/esm/util/url.js.map +0 -1
package/esm/OktaAuth.js DELETED
@@ -1,665 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
- var _excluded = ["originalUri"];
5
-
6
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
7
-
8
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
9
-
10
- /* eslint-disable max-statements */
11
-
12
- /* eslint-disable complexity */
13
-
14
- /*!
15
- * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
16
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
17
- *
18
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
19
- * Unless required by applicable law or agreed to in writing, software
20
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
21
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
- *
23
- * See the License for the specific language governing permissions and limitations under the License.
24
- */
25
-
26
- /* SDK_VERSION is defined in webpack config */
27
-
28
- /* global window, SDK_VERSION */
29
- import { DEFAULT_MAX_CLOCK_SKEW, REFERRER_PATH_STORAGE_KEY } from './constants';
30
- import * as constants from './constants';
31
- import { transactionStatus, resumeTransaction, transactionExists, introspect, postToTransaction } from './tx';
32
- import PKCE from './oidc/util/pkce';
33
- import { closeSession, sessionExists, getSession, refreshSession, setCookieAndRedirect } from './session';
34
- import { getOAuthUrls, getWithoutPrompt, getWithPopup, getWithRedirect, isLoginRedirect, parseFromUrl, decodeToken, revokeToken, renewToken, renewTokens, renewTokensWithRefresh, getUserInfo, verifyToken, prepareTokenParams, exchangeCodeForTokens, isInteractionRequiredError, isInteractionRequired } from './oidc';
35
- import { isBrowser } from './features';
36
- import * as features from './features';
37
- import browserStorage from './browser/browserStorage';
38
- import { toQueryString, toAbsoluteUrl, clone } from './util';
39
- import { getUserAgent } from './builderUtil';
40
- import { TokenManager } from './TokenManager';
41
- import { get, setRequestHeader } from './http';
42
- import PromiseQueue from './PromiseQueue';
43
- import fingerprint from './browser/fingerprint';
44
- import { AuthStateManager } from './AuthStateManager';
45
- import StorageManager from './StorageManager';
46
- import TransactionManager from './TransactionManager';
47
- import { buildOptions } from './options';
48
- import { interact, introspect as introspectV2, authenticate, cancel, register, recoverPassword, startTransaction, handleInteractionCodeRedirect } from './idx';
49
- import { createGlobalRequestInterceptor, setGlobalRequestInterceptor } from './idx/headers';
50
- import { OktaUserAgent } from './OktaUserAgent';
51
-
52
- var Emitter = require('tiny-emitter');
53
-
54
- class OktaAuth {
55
- // keep this field to compatible with released downstream SDK versions
56
- // TODO: remove in version 6
57
- // JIRA: https://oktainc.atlassian.net/browse/OKTA-419417
58
- constructor(args) {
59
- this.options = buildOptions(args);
60
- var {
61
- storageManager,
62
- cookies,
63
- storageUtil
64
- } = this.options;
65
- this.storageManager = new StorageManager(storageManager, cookies, storageUtil);
66
- this.transactionManager = new TransactionManager(Object.assign({
67
- storageManager: this.storageManager
68
- }, args.transactionManager));
69
- this._oktaUserAgent = new OktaUserAgent();
70
- this.tx = {
71
- status: transactionStatus.bind(null, this),
72
- resume: resumeTransaction.bind(null, this),
73
- exists: Object.assign(transactionExists.bind(null, this), {
74
- _get: name => {
75
- var storage = storageUtil.storage;
76
- return storage.get(name);
77
- }
78
- }),
79
- introspect: introspect.bind(null, this)
80
- };
81
- this.pkce = {
82
- DEFAULT_CODE_CHALLENGE_METHOD: PKCE.DEFAULT_CODE_CHALLENGE_METHOD,
83
- generateVerifier: PKCE.generateVerifier,
84
- computeChallenge: PKCE.computeChallenge
85
- }; // Add shims for compatibility, these will be removed in next major version. OKTA-362589
86
-
87
- Object.assign(this.options.storageUtil, {
88
- getPKCEStorage: this.storageManager.getLegacyPKCEStorage.bind(this.storageManager),
89
- getHttpCache: this.storageManager.getHttpCache.bind(this.storageManager)
90
- });
91
- this._pending = {
92
- handleLogin: false
93
- };
94
-
95
- if (isBrowser()) {
96
- this.options = Object.assign(this.options, {
97
- redirectUri: toAbsoluteUrl(args.redirectUri, window.location.origin) // allow relative URIs
98
-
99
- });
100
- this.userAgent = getUserAgent(args, "okta-auth-js/".concat("5.5.0"));
101
- } else {
102
- this.userAgent = getUserAgent(args, "okta-auth-js-server/".concat("5.5.0"));
103
- } // Digital clocks will drift over time, so the server
104
- // can misalign with the time reported by the browser.
105
- // The maxClockSkew allows relaxing the time-based
106
- // validation of tokens (in seconds, not milliseconds).
107
- // It currently defaults to 300, because 5 min is the
108
- // default maximum tolerance allowed by Kerberos.
109
- // (https://technet.microsoft.com/en-us/library/cc976357.aspx)
110
-
111
-
112
- if (!args.maxClockSkew && args.maxClockSkew !== 0) {
113
- this.options.maxClockSkew = DEFAULT_MAX_CLOCK_SKEW;
114
- } else {
115
- this.options.maxClockSkew = args.maxClockSkew;
116
- } // As some end user's devices can have their date
117
- // and time incorrectly set, allow for the disabling
118
- // of the jwt liftetime validation
119
-
120
-
121
- this.options.ignoreLifetime = !!args.ignoreLifetime;
122
- this.session = {
123
- close: closeSession.bind(null, this),
124
- exists: sessionExists.bind(null, this),
125
- get: getSession.bind(null, this),
126
- refresh: refreshSession.bind(null, this),
127
- setCookieAndRedirect: setCookieAndRedirect.bind(null, this)
128
- };
129
- this._tokenQueue = new PromiseQueue();
130
- this.token = {
131
- prepareTokenParams: prepareTokenParams.bind(null, this),
132
- exchangeCodeForTokens: exchangeCodeForTokens.bind(null, this),
133
- getWithoutPrompt: getWithoutPrompt.bind(null, this),
134
- getWithPopup: getWithPopup.bind(null, this),
135
- getWithRedirect: getWithRedirect.bind(null, this),
136
- parseFromUrl: parseFromUrl.bind(null, this),
137
- decode: decodeToken,
138
- revoke: revokeToken.bind(null, this),
139
- renew: renewToken.bind(null, this),
140
- renewTokensWithRefresh: renewTokensWithRefresh.bind(null, this),
141
- renewTokens: renewTokens.bind(null, this),
142
- getUserInfo: getUserInfo.bind(null, this),
143
- verify: verifyToken.bind(null, this),
144
- isLoginRedirect: isLoginRedirect.bind(null, this)
145
- }; // Wrap all async token API methods using MethodQueue to avoid issues with concurrency
146
-
147
- var syncMethods = ['decode', 'isLoginRedirect'];
148
- Object.keys(this.token).forEach(key => {
149
- if (syncMethods.indexOf(key) >= 0) {
150
- // sync methods should not be wrapped
151
- return;
152
- }
153
-
154
- var method = this.token[key];
155
- this.token[key] = PromiseQueue.prototype.push.bind(this._tokenQueue, method, null);
156
- });
157
- Object.assign(this.token.getWithRedirect, {
158
- // This is exposed so we can set window.location in our tests
159
- _setLocation: function _setLocation(url) {
160
- window.location = url;
161
- }
162
- });
163
- Object.assign(this.token.parseFromUrl, {
164
- // This is exposed so we can mock getting window.history in our tests
165
- _getHistory: function _getHistory() {
166
- return window.history;
167
- },
168
- // This is exposed so we can mock getting window.location in our tests
169
- _getLocation: function _getLocation() {
170
- return window.location;
171
- },
172
- // This is exposed so we can mock getting window.document in our tests
173
- _getDocument: function _getDocument() {
174
- return window.document;
175
- }
176
- }); // IDX
177
-
178
- this.idx = {
179
- interact: interact.bind(null, this),
180
- introspect: introspectV2.bind(null, this),
181
- authenticate: authenticate.bind(null, this),
182
- register: register.bind(null, this),
183
- cancel: cancel.bind(null, this),
184
- recoverPassword: recoverPassword.bind(null, this),
185
- handleInteractionCodeRedirect: handleInteractionCodeRedirect.bind(null, this),
186
- startTransaction: startTransaction.bind(null, this)
187
- };
188
- setGlobalRequestInterceptor(createGlobalRequestInterceptor(this)); // to pass custom headers to IDX endpoints
189
- // HTTP
190
-
191
- this.http = {
192
- setRequestHeader: setRequestHeader.bind(null, this)
193
- }; // Fingerprint API
194
-
195
- this.fingerprint = fingerprint.bind(null, this);
196
- this.emitter = new Emitter(); // TokenManager
197
-
198
- this.tokenManager = new TokenManager(this, args.tokenManager); // AuthStateManager
199
-
200
- this.authStateManager = new AuthStateManager(this);
201
- }
202
-
203
- start() {
204
- this.tokenManager.start();
205
-
206
- if (!this.token.isLoginRedirect()) {
207
- this.authStateManager.updateAuthState();
208
- }
209
- }
210
-
211
- stop() {
212
- this.tokenManager.stop();
213
- } // ES6 module users can use named exports to access all symbols
214
- // CommonJS module users (CDN) need all exports on this object
215
- // Utility methods for interaction code flow
216
-
217
-
218
- isInteractionRequired() {
219
- return isInteractionRequired(this);
220
- }
221
-
222
- isInteractionRequiredError(error) {
223
- return isInteractionRequiredError(error);
224
- }
225
-
226
- signIn(opts) {
227
- var _this = this;
228
-
229
- return _asyncToGenerator(function* () {
230
- // TODO: support interaction code flow
231
- // Authn V1 flow
232
- return _this.signInWithCredentials(opts);
233
- })();
234
- }
235
-
236
- signInWithCredentials(opts) {
237
- var _this2 = this;
238
-
239
- return _asyncToGenerator(function* () {
240
- opts = clone(opts || {});
241
-
242
- var _postToTransaction = options => {
243
- options = options || {};
244
- options.withCredentials = true;
245
- delete opts.sendFingerprint;
246
- return postToTransaction(_this2, '/api/v1/authn', opts, options);
247
- };
248
-
249
- if (!opts.sendFingerprint) {
250
- return _postToTransaction();
251
- }
252
-
253
- return _this2.fingerprint().then(function (fingerprint) {
254
- return _postToTransaction({
255
- headers: {
256
- 'X-Device-Fingerprint': fingerprint
257
- }
258
- });
259
- });
260
- })();
261
- }
262
-
263
- signInWithRedirect() {
264
- var _arguments = arguments,
265
- _this3 = this;
266
-
267
- return _asyncToGenerator(function* () {
268
- var opts = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : {};
269
-
270
- var {
271
- originalUri
272
- } = opts,
273
- additionalParams = _objectWithoutProperties(opts, _excluded);
274
-
275
- if (_this3._pending.handleLogin) {
276
- // Don't trigger second round
277
- return;
278
- }
279
-
280
- _this3._pending.handleLogin = true;
281
-
282
- try {
283
- // Trigger default signIn redirect flow
284
- if (originalUri) {
285
- _this3.setOriginalUri(originalUri);
286
- }
287
-
288
- var params = Object.assign({
289
- // TODO: remove this line when default scopes are changed OKTA-343294
290
- scopes: _this3.options.scopes || ['openid', 'email', 'profile']
291
- }, additionalParams);
292
- yield _this3.token.getWithRedirect(params);
293
- } finally {
294
- _this3._pending.handleLogin = false;
295
- }
296
- })();
297
- } // Ends the current Okta SSO session without redirecting to Okta.
298
-
299
-
300
- closeSession() {
301
- // Clear all local tokens
302
- this.tokenManager.clear();
303
- return this.session.close() // DELETE /api/v1/sessions/me
304
- .catch(function (e) {
305
- if (e.name === 'AuthApiError' && e.errorCode === 'E0000007') {
306
- // Session does not exist or has already been closed
307
- return null;
308
- }
309
-
310
- throw e;
311
- });
312
- } // Revokes the access token for the application session
313
-
314
-
315
- revokeAccessToken(accessToken) {
316
- var _this4 = this;
317
-
318
- return _asyncToGenerator(function* () {
319
- if (!accessToken) {
320
- accessToken = (yield _this4.tokenManager.getTokens()).accessToken;
321
-
322
- var accessTokenKey = _this4.tokenManager.getStorageKeyByType('accessToken');
323
-
324
- _this4.tokenManager.remove(accessTokenKey);
325
- } // Access token may have been removed. In this case, we will silently succeed.
326
-
327
-
328
- if (!accessToken) {
329
- return Promise.resolve(null);
330
- }
331
-
332
- return _this4.token.revoke(accessToken);
333
- })();
334
- } // Revokes the refresh token for the application session
335
-
336
-
337
- revokeRefreshToken(refreshToken) {
338
- var _this5 = this;
339
-
340
- return _asyncToGenerator(function* () {
341
- if (!refreshToken) {
342
- refreshToken = (yield _this5.tokenManager.getTokens()).refreshToken;
343
-
344
- var refreshTokenKey = _this5.tokenManager.getStorageKeyByType('refreshToken');
345
-
346
- _this5.tokenManager.remove(refreshTokenKey);
347
- } // Refresh token may have been removed. In this case, we will silently succeed.
348
-
349
-
350
- if (!refreshToken) {
351
- return Promise.resolve(null);
352
- }
353
-
354
- return _this5.token.revoke(refreshToken);
355
- })();
356
- }
357
-
358
- getSignOutRedirectUrl() {
359
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
360
- var {
361
- idToken,
362
- postLogoutRedirectUri,
363
- state
364
- } = options;
365
-
366
- if (!idToken) {
367
- idToken = this.tokenManager.getTokensSync().idToken;
368
- }
369
-
370
- if (!idToken) {
371
- return '';
372
- }
373
-
374
- if (!postLogoutRedirectUri) {
375
- postLogoutRedirectUri = this.options.postLogoutRedirectUri;
376
- }
377
-
378
- var logoutUrl = getOAuthUrls(this).logoutUrl;
379
- var idTokenHint = idToken.idToken; // a string
380
-
381
- var logoutUri = logoutUrl + '?id_token_hint=' + encodeURIComponent(idTokenHint);
382
-
383
- if (postLogoutRedirectUri) {
384
- logoutUri += '&post_logout_redirect_uri=' + encodeURIComponent(postLogoutRedirectUri);
385
- } // State allows option parameters to be passed to logout redirect uri
386
-
387
-
388
- if (state) {
389
- logoutUri += '&state=' + encodeURIComponent(state);
390
- }
391
-
392
- return logoutUri;
393
- } // Revokes refreshToken or accessToken, clears all local tokens, then redirects to Okta to end the SSO session.
394
-
395
-
396
- signOut(options) {
397
- var _this6 = this;
398
-
399
- return _asyncToGenerator(function* () {
400
- options = Object.assign({}, options); // postLogoutRedirectUri must be whitelisted in Okta Admin UI
401
-
402
- var defaultUri = window.location.origin;
403
- var currentUri = window.location.href;
404
- var postLogoutRedirectUri = options.postLogoutRedirectUri || _this6.options.postLogoutRedirectUri || defaultUri;
405
- var accessToken = options.accessToken;
406
- var refreshToken = options.refreshToken;
407
- var revokeAccessToken = options.revokeAccessToken !== false;
408
- var revokeRefreshToken = options.revokeRefreshToken !== false;
409
-
410
- if (revokeRefreshToken && typeof refreshToken === 'undefined') {
411
- refreshToken = _this6.tokenManager.getTokensSync().refreshToken;
412
- }
413
-
414
- if (revokeAccessToken && typeof accessToken === 'undefined') {
415
- accessToken = _this6.tokenManager.getTokensSync().accessToken;
416
- }
417
-
418
- if (!options.idToken) {
419
- options.idToken = _this6.tokenManager.getTokensSync().idToken;
420
- } // Clear all local tokens
421
-
422
-
423
- _this6.tokenManager.clear();
424
-
425
- if (revokeRefreshToken && refreshToken) {
426
- yield _this6.revokeRefreshToken(refreshToken);
427
- }
428
-
429
- if (revokeAccessToken && accessToken) {
430
- yield _this6.revokeAccessToken(accessToken);
431
- }
432
-
433
- var logoutUri = _this6.getSignOutRedirectUrl(_objectSpread(_objectSpread({}, options), {}, {
434
- postLogoutRedirectUri
435
- })); // No logoutUri? This can happen if the storage was cleared.
436
- // Fallback to XHR signOut, then simulate a redirect to the post logout uri
437
-
438
-
439
- if (!logoutUri) {
440
- return _this6.closeSession() // can throw if the user cannot be signed out
441
- .then(function () {
442
- if (postLogoutRedirectUri === currentUri) {
443
- window.location.reload(); // force a hard reload if URI is not changing
444
- } else {
445
- window.location.assign(postLogoutRedirectUri);
446
- }
447
- });
448
- } else {
449
- // Flow ends with logout redirect
450
- window.location.assign(logoutUri);
451
- }
452
- })();
453
- }
454
-
455
- webfinger(opts) {
456
- var url = '/.well-known/webfinger' + toQueryString(opts);
457
- var options = {
458
- headers: {
459
- 'Accept': 'application/jrd+json'
460
- }
461
- };
462
- return get(this, url, options);
463
- } //
464
- // Common Methods from downstream SDKs
465
- //
466
- // Returns true if both accessToken and idToken are not expired
467
- // If `autoRenew` option is set, will attempt to renew expired tokens before returning.
468
-
469
-
470
- isAuthenticated() {
471
- var _this7 = this;
472
-
473
- return _asyncToGenerator(function* () {
474
- var {
475
- accessToken,
476
- idToken
477
- } = _this7.tokenManager.getTokensSync();
478
-
479
- var {
480
- autoRenew,
481
- autoRemove
482
- } = _this7.tokenManager.getOptions();
483
-
484
- if (accessToken && _this7.tokenManager.hasExpired(accessToken)) {
485
- accessToken = null;
486
-
487
- if (autoRenew) {
488
- accessToken = yield _this7.tokenManager.renew('accessToken');
489
- } else if (autoRemove) {
490
- _this7.tokenManager.remove('accessToken');
491
- }
492
- }
493
-
494
- if (idToken && _this7.tokenManager.hasExpired(idToken)) {
495
- idToken = null;
496
-
497
- if (autoRenew) {
498
- idToken = yield _this7.tokenManager.renew('idToken');
499
- } else if (autoRemove) {
500
- _this7.tokenManager.remove('idToken');
501
- }
502
- }
503
-
504
- return !!(accessToken && idToken);
505
- })();
506
- }
507
-
508
- getUser() {
509
- var _this8 = this;
510
-
511
- return _asyncToGenerator(function* () {
512
- var {
513
- idToken,
514
- accessToken
515
- } = _this8.tokenManager.getTokensSync();
516
-
517
- return _this8.token.getUserInfo(accessToken, idToken);
518
- })();
519
- }
520
-
521
- getIdToken() {
522
- var {
523
- idToken
524
- } = this.tokenManager.getTokensSync();
525
- return idToken ? idToken.idToken : undefined;
526
- }
527
-
528
- getAccessToken() {
529
- var {
530
- accessToken
531
- } = this.tokenManager.getTokensSync();
532
- return accessToken ? accessToken.accessToken : undefined;
533
- }
534
-
535
- getRefreshToken() {
536
- var {
537
- refreshToken
538
- } = this.tokenManager.getTokensSync();
539
- return refreshToken ? refreshToken.refreshToken : undefined;
540
- }
541
- /**
542
- * Store parsed tokens from redirect url
543
- */
544
-
545
-
546
- storeTokensFromRedirect() {
547
- var _this9 = this;
548
-
549
- return _asyncToGenerator(function* () {
550
- var {
551
- tokens
552
- } = yield _this9.token.parseFromUrl();
553
-
554
- _this9.tokenManager.setTokens(tokens);
555
- })();
556
- }
557
-
558
- setOriginalUri(originalUri) {
559
- var storage = browserStorage.getSessionStorage();
560
- storage.setItem(REFERRER_PATH_STORAGE_KEY, originalUri);
561
- }
562
-
563
- getOriginalUri() {
564
- var storage = browserStorage.getSessionStorage();
565
- var originalUri = storage.getItem(REFERRER_PATH_STORAGE_KEY);
566
- return originalUri;
567
- }
568
-
569
- removeOriginalUri() {
570
- var storage = browserStorage.getSessionStorage();
571
- storage.removeItem(REFERRER_PATH_STORAGE_KEY);
572
- }
573
-
574
- isLoginRedirect() {
575
- return isLoginRedirect(this);
576
- }
577
-
578
- handleLoginRedirect(tokens) {
579
- var _this10 = this;
580
-
581
- return _asyncToGenerator(function* () {
582
- // Store tokens and update AuthState by the emitted events
583
- if (tokens) {
584
- _this10.tokenManager.setTokens(tokens);
585
- } else if (_this10.isLoginRedirect()) {
586
- yield _this10.storeTokensFromRedirect();
587
- } else {
588
- return; // nothing to do
589
- } // ensure auth state has been updated
590
-
591
-
592
- yield _this10.authStateManager.updateAuthState(); // Get and clear originalUri from storage
593
-
594
- var originalUri = _this10.getOriginalUri();
595
-
596
- _this10.removeOriginalUri(); // Redirect to originalUri
597
-
598
-
599
- var {
600
- restoreOriginalUri
601
- } = _this10.options;
602
-
603
- if (restoreOriginalUri) {
604
- yield restoreOriginalUri(_this10, originalUri);
605
- } else {
606
- window.location.replace(originalUri);
607
- }
608
- })();
609
- }
610
-
611
- isPKCE() {
612
- return !!this.options.pkce;
613
- }
614
-
615
- hasResponseType(responseType) {
616
- var hasResponseType = false;
617
-
618
- if (Array.isArray(this.options.responseType) && this.options.responseType.length) {
619
- hasResponseType = this.options.responseType.indexOf(responseType) >= 0;
620
- } else {
621
- hasResponseType = this.options.responseType === responseType;
622
- }
623
-
624
- return hasResponseType;
625
- }
626
-
627
- isAuthorizationCodeFlow() {
628
- return this.hasResponseType('code');
629
- } // { username, password, (relayState), (context) }
630
- // signIn(opts: SignInWithCredentialsOptions): Promise<AuthTransaction> {
631
- // return postToTransaction(this, '/api/v1/authn', opts);
632
- // }
633
-
634
-
635
- getIssuerOrigin() {
636
- // Infer the URL from the issuer URL, omitting the /oauth2/{authServerId}
637
- return this.options.issuer.split('/oauth2/')[0];
638
- } // { username, (relayState) }
639
-
640
-
641
- forgotPassword(opts) {
642
- return postToTransaction(this, '/api/v1/authn/recovery/password', opts);
643
- } // { username, (relayState) }
644
-
645
-
646
- unlockAccount(opts) {
647
- return postToTransaction(this, '/api/v1/authn/recovery/unlock', opts);
648
- } // { recoveryToken }
649
-
650
-
651
- verifyRecoveryToken(opts) {
652
- return postToTransaction(this, '/api/v1/authn/recovery/token', opts);
653
- }
654
-
655
- } // Hoist feature detection functions to static type
656
-
657
-
658
- OktaAuth.features = OktaAuth.prototype.features = features; // Also hoist values and utility functions for CommonJS users
659
-
660
- Object.assign(OktaAuth, {
661
- constants,
662
- isInteractionRequiredError
663
- });
664
- export default OktaAuth;
665
- //# sourceMappingURL=OktaAuth.js.map