@okta/okta-auth-js 5.7.0 → 5.10.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 (449) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +12 -2
  3. package/cjs/OktaAuth.js +88 -43
  4. package/cjs/OktaAuth.js.map +1 -1
  5. package/cjs/OktaUserAgent.js +2 -2
  6. package/cjs/OktaUserAgent.js.map +1 -1
  7. package/cjs/StorageManager.js +8 -0
  8. package/cjs/StorageManager.js.map +1 -1
  9. package/cjs/TokenManager.js +24 -2
  10. package/cjs/TokenManager.js.map +1 -1
  11. package/cjs/TransactionManager.js +24 -12
  12. package/cjs/TransactionManager.js.map +1 -1
  13. package/cjs/constants.js +3 -1
  14. package/cjs/constants.js.map +1 -1
  15. package/cjs/features.js +1 -1
  16. package/cjs/features.js.map +1 -1
  17. package/cjs/idx/authenticate.js +3 -18
  18. package/cjs/idx/authenticate.js.map +1 -1
  19. package/cjs/idx/authenticator/Authenticator.js +14 -0
  20. package/cjs/idx/authenticator/Authenticator.js.map +1 -0
  21. package/cjs/idx/authenticator/OktaPassword.js +31 -0
  22. package/cjs/idx/authenticator/OktaPassword.js.map +1 -0
  23. package/cjs/idx/authenticator/OktaVerifyTotp.js +17 -0
  24. package/cjs/idx/authenticator/OktaVerifyTotp.js.map +1 -0
  25. package/cjs/idx/authenticator/SecurityQuestionEnrollment.js +50 -0
  26. package/cjs/idx/authenticator/SecurityQuestionEnrollment.js.map +1 -0
  27. package/cjs/idx/authenticator/SecurityQuestionVerification.js +31 -0
  28. package/cjs/idx/authenticator/SecurityQuestionVerification.js.map +1 -0
  29. package/cjs/idx/authenticator/VerificationCodeAuthenticator.js +34 -0
  30. package/cjs/idx/authenticator/VerificationCodeAuthenticator.js.map +1 -0
  31. package/cjs/idx/authenticator/getAuthenticator.js +42 -0
  32. package/cjs/idx/authenticator/getAuthenticator.js.map +1 -0
  33. package/cjs/idx/authenticator/index.js +80 -0
  34. package/cjs/idx/authenticator/index.js.map +1 -0
  35. package/cjs/idx/cancel.js +5 -0
  36. package/cjs/idx/cancel.js.map +1 -1
  37. package/cjs/idx/flow/AuthenticationFlow.js +32 -0
  38. package/cjs/idx/flow/AuthenticationFlow.js.map +1 -0
  39. package/cjs/idx/flow/FlowSpecification.js +39 -0
  40. package/cjs/idx/flow/FlowSpecification.js.map +1 -0
  41. package/cjs/idx/flow/PasswordRecoveryFlow.js +28 -0
  42. package/cjs/idx/flow/PasswordRecoveryFlow.js.map +1 -0
  43. package/{esm/crypto/browser.js → cjs/idx/flow/RegistrationFlow.js} +16 -12
  44. package/cjs/idx/flow/RegistrationFlow.js.map +1 -0
  45. package/cjs/idx/flow/RemediationFlow.js +2 -0
  46. package/{esm/types/Cookies.js.map → cjs/idx/flow/RemediationFlow.js.map} +1 -1
  47. package/cjs/idx/flow/index.js +67 -0
  48. package/cjs/idx/flow/index.js.map +1 -0
  49. package/cjs/idx/index.js +39 -0
  50. package/cjs/idx/index.js.map +1 -1
  51. package/cjs/idx/interact.js +13 -4
  52. package/cjs/idx/interact.js.map +1 -1
  53. package/cjs/idx/introspect.js +24 -7
  54. package/cjs/idx/introspect.js.map +1 -1
  55. package/cjs/idx/poll.js +59 -0
  56. package/cjs/idx/poll.js.map +1 -0
  57. package/cjs/idx/proceed.js +49 -0
  58. package/cjs/idx/proceed.js.map +1 -0
  59. package/cjs/idx/recoverPassword.js +3 -17
  60. package/cjs/idx/recoverPassword.js.map +1 -1
  61. package/cjs/idx/register.js +22 -20
  62. package/cjs/idx/register.js.map +1 -1
  63. package/cjs/idx/remediate.js +61 -118
  64. package/cjs/idx/remediate.js.map +1 -1
  65. package/cjs/idx/remediators/AuthenticatorEnrollmentData.js +9 -12
  66. package/cjs/idx/remediators/AuthenticatorEnrollmentData.js.map +1 -1
  67. package/cjs/idx/remediators/AuthenticatorVerificationData.js +6 -9
  68. package/cjs/idx/remediators/AuthenticatorVerificationData.js.map +1 -1
  69. package/cjs/idx/remediators/Base/AuthenticatorData.js +43 -32
  70. package/cjs/idx/remediators/Base/AuthenticatorData.js.map +1 -1
  71. package/cjs/idx/remediators/Base/Remediator.js +51 -20
  72. package/cjs/idx/remediators/Base/Remediator.js.map +1 -1
  73. package/cjs/idx/remediators/Base/SelectAuthenticator.js +16 -16
  74. package/cjs/idx/remediators/Base/SelectAuthenticator.js.map +1 -1
  75. package/cjs/idx/remediators/Base/VerifyAuthenticator.js +8 -28
  76. package/cjs/idx/remediators/Base/VerifyAuthenticator.js.map +1 -1
  77. package/{esm/idx/remediators/RedirectIdp.js → cjs/idx/remediators/ChallengePoll.js} +13 -25
  78. package/cjs/idx/remediators/ChallengePoll.js.map +1 -0
  79. package/cjs/idx/remediators/EnrollPoll.js +56 -0
  80. package/cjs/idx/remediators/EnrollPoll.js.map +1 -0
  81. package/cjs/idx/remediators/Identify.js +4 -36
  82. package/cjs/idx/remediators/Identify.js.map +1 -1
  83. package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js +23 -2
  84. package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js.map +1 -1
  85. package/cjs/idx/remediators/Skip.js +7 -0
  86. package/cjs/idx/remediators/Skip.js.map +1 -1
  87. package/cjs/idx/remediators/index.js +26 -0
  88. package/cjs/idx/remediators/index.js.map +1 -1
  89. package/cjs/idx/run.js +36 -16
  90. package/cjs/idx/run.js.map +1 -1
  91. package/cjs/idx/startTransaction.js +2 -0
  92. package/cjs/idx/startTransaction.js.map +1 -1
  93. package/cjs/idx/transactionMeta.js +77 -39
  94. package/cjs/idx/transactionMeta.js.map +1 -1
  95. package/cjs/idx/types/FlowIdentifier.js +2 -0
  96. package/{esm/types/AuthState.js.map → cjs/idx/types/FlowIdentifier.js.map} +1 -1
  97. package/cjs/idx/types/idx-js.js +5 -0
  98. package/cjs/idx/types/idx-js.js.map +1 -1
  99. package/cjs/idx/types/index.js +18 -1
  100. package/cjs/idx/types/index.js.map +1 -1
  101. package/cjs/oidc/endpoints/authorize.js +4 -1
  102. package/cjs/oidc/endpoints/authorize.js.map +1 -1
  103. package/cjs/oidc/getWithRedirect.js +2 -6
  104. package/cjs/oidc/getWithRedirect.js.map +1 -1
  105. package/cjs/oidc/util/loginRedirect.js +9 -5
  106. package/cjs/oidc/util/loginRedirect.js.map +1 -1
  107. package/cjs/oidc/util/urlParams.js +1 -1
  108. package/cjs/oidc/util/urlParams.js.map +1 -1
  109. package/cjs/options.js +12 -2
  110. package/cjs/options.js.map +1 -1
  111. package/cjs/server/serverStorage.js +2 -1
  112. package/cjs/server/serverStorage.js.map +1 -1
  113. package/cjs/types/Token.js.map +1 -1
  114. package/cjs/types/Transaction.js.map +1 -1
  115. package/{esm/clock.js → cjs/util/emailVerify.js} +14 -18
  116. package/cjs/util/emailVerify.js.map +1 -0
  117. package/cjs/util/index.js +13 -0
  118. package/cjs/util/index.js.map +1 -1
  119. package/dist/okta-auth-js.min.js +2 -74
  120. package/dist/okta-auth-js.min.js.LICENSE.txt +32 -0
  121. package/dist/okta-auth-js.min.js.map +1 -1
  122. package/dist/okta-auth-js.polyfill.js +2 -18
  123. package/{esm/crypto/webcrypto.js → dist/okta-auth-js.polyfill.js.LICENSE.txt} +8 -4
  124. package/dist/okta-auth-js.polyfill.js.map +1 -1
  125. package/dist/okta-auth-js.umd.js +2 -74
  126. package/dist/okta-auth-js.umd.js.LICENSE.txt +32 -0
  127. package/dist/okta-auth-js.umd.js.map +1 -1
  128. package/esm/index.js +8580 -16
  129. package/esm/index.js.map +1 -1
  130. package/lib/OktaAuth.d.ts +6 -3
  131. package/lib/StorageManager.d.ts +1 -0
  132. package/lib/TokenManager.d.ts +2 -0
  133. package/lib/TransactionManager.d.ts +5 -1
  134. package/lib/constants.d.ts +1 -0
  135. package/lib/crypto/base64.d.ts +2 -2
  136. package/lib/crypto/oidcHash.d.ts +1 -1
  137. package/lib/crypto/verifyToken.d.ts +1 -1
  138. package/lib/idx/authenticator/Authenticator.d.ts +12 -0
  139. package/lib/idx/authenticator/OktaPassword.d.ts +11 -0
  140. package/lib/idx/authenticator/OktaVerifyTotp.d.ts +9 -0
  141. package/lib/idx/authenticator/SecurityQuestionEnrollment.d.ts +28 -0
  142. package/lib/idx/authenticator/SecurityQuestionVerification.d.ts +14 -0
  143. package/lib/idx/authenticator/VerificationCodeAuthenticator.d.ts +10 -0
  144. package/lib/idx/authenticator/getAuthenticator.d.ts +3 -0
  145. package/lib/idx/authenticator/index.d.ts +6 -0
  146. package/{esm/oidc/endpoints/index.js → lib/idx/flow/AuthenticationFlow.d.ts} +3 -5
  147. package/lib/idx/flow/FlowSpecification.d.ts +8 -0
  148. package/{esm/crypto/index.js → lib/idx/flow/PasswordRecoveryFlow.d.ts} +3 -6
  149. package/{esm/tx/TransactionState.js → lib/idx/flow/RegistrationFlow.d.ts} +3 -3
  150. package/lib/idx/flow/RemediationFlow.d.ts +13 -0
  151. package/lib/idx/{flowMonitors → flow}/index.d.ts +5 -4
  152. package/lib/idx/index.d.ts +3 -0
  153. package/lib/idx/interact.d.ts +1 -0
  154. package/lib/idx/introspect.d.ts +2 -1
  155. package/lib/idx/poll.d.ts +13 -0
  156. package/lib/idx/proceed.d.ts +21 -0
  157. package/lib/idx/register.d.ts +1 -1
  158. package/lib/idx/remediators/AuthenticatorEnrollmentData.d.ts +9 -5
  159. package/lib/idx/remediators/AuthenticatorVerificationData.d.ts +0 -1
  160. package/lib/idx/remediators/Base/AuthenticatorData.d.ts +8 -3
  161. package/lib/idx/remediators/Base/Remediator.d.ts +9 -6
  162. package/lib/idx/remediators/Base/SelectAuthenticator.d.ts +5 -4
  163. package/lib/idx/remediators/Base/VerifyAuthenticator.d.ts +8 -4
  164. package/lib/idx/remediators/ChallengePoll.d.ts +15 -0
  165. package/{esm/tx/util.js → lib/idx/remediators/EnrollPoll.d.ts} +11 -13
  166. package/lib/idx/remediators/Identify.d.ts +1 -3
  167. package/lib/idx/remediators/SelectAuthenticatorAuthenticate.d.ts +6 -2
  168. package/lib/idx/remediators/Skip.d.ts +3 -0
  169. package/lib/idx/remediators/index.d.ts +2 -0
  170. package/lib/idx/run.d.ts +8 -9
  171. package/lib/idx/transactionMeta.d.ts +28 -4
  172. package/lib/idx/types/FlowIdentifier.d.ts +1 -0
  173. package/lib/idx/types/idx-js.d.ts +53 -1
  174. package/lib/idx/types/index.d.ts +18 -4
  175. package/lib/oidc/util/loginRedirect.d.ts +1 -1
  176. package/lib/types/OktaAuthOptions.d.ts +3 -0
  177. package/lib/types/Token.d.ts +1 -0
  178. package/lib/types/Transaction.d.ts +2 -0
  179. package/lib/types/api.d.ts +15 -2
  180. package/lib/{idx/flowMonitors/AuthenticationFlowMonitor.d.ts → util/emailVerify.d.ts} +5 -3
  181. package/lib/util/index.d.ts +1 -0
  182. package/package.json +22 -13
  183. package/cjs/idx/flowMonitors/AuthenticationFlowMonitor.js +0 -45
  184. package/cjs/idx/flowMonitors/AuthenticationFlowMonitor.js.map +0 -1
  185. package/cjs/idx/flowMonitors/FlowMonitor.js +0 -69
  186. package/cjs/idx/flowMonitors/FlowMonitor.js.map +0 -1
  187. package/cjs/idx/flowMonitors/PasswordRecoveryFlowMonitor.js +0 -55
  188. package/cjs/idx/flowMonitors/PasswordRecoveryFlowMonitor.js.map +0 -1
  189. package/cjs/idx/flowMonitors/RegistrationFlowMonitor.js +0 -35
  190. package/cjs/idx/flowMonitors/RegistrationFlowMonitor.js.map +0 -1
  191. package/cjs/idx/flowMonitors/index.js +0 -54
  192. package/cjs/idx/flowMonitors/index.js.map +0 -1
  193. package/esm/AuthStateManager.js +0 -214
  194. package/esm/AuthStateManager.js.map +0 -1
  195. package/esm/OktaAuth.js +0 -681
  196. package/esm/OktaAuth.js.map +0 -1
  197. package/esm/OktaUserAgent.js +0 -49
  198. package/esm/OktaUserAgent.js.map +0 -1
  199. package/esm/PromiseQueue.js +0 -71
  200. package/esm/PromiseQueue.js.map +0 -1
  201. package/esm/SavedObject.js +0 -91
  202. package/esm/SavedObject.js.map +0 -1
  203. package/esm/StorageManager.js +0 -182
  204. package/esm/StorageManager.js.map +0 -1
  205. package/esm/TokenManager.js +0 -455
  206. package/esm/TokenManager.js.map +0 -1
  207. package/esm/TransactionManager.js +0 -316
  208. package/esm/TransactionManager.js.map +0 -1
  209. package/esm/browser/browserStorage.js +0 -256
  210. package/esm/browser/browserStorage.js.map +0 -1
  211. package/esm/browser/fingerprint.js +0 -74
  212. package/esm/browser/fingerprint.js.map +0 -1
  213. package/esm/builderUtil.js +0 -56
  214. package/esm/builderUtil.js.map +0 -1
  215. package/esm/clock.js.map +0 -1
  216. package/esm/constants.js +0 -35
  217. package/esm/constants.js.map +0 -1
  218. package/esm/crypto/base64.js +0 -66
  219. package/esm/crypto/base64.js.map +0 -1
  220. package/esm/crypto/browser.js.map +0 -1
  221. package/esm/crypto/index.js.map +0 -1
  222. package/esm/crypto/node.js +0 -54
  223. package/esm/crypto/node.js.map +0 -1
  224. package/esm/crypto/oidcHash.js +0 -27
  225. package/esm/crypto/oidcHash.js.map +0 -1
  226. package/esm/crypto/verifyToken.js +0 -39
  227. package/esm/crypto/verifyToken.js.map +0 -1
  228. package/esm/crypto/webcrypto.js.map +0 -1
  229. package/esm/errors/AuthApiError.js +0 -30
  230. package/esm/errors/AuthApiError.js.map +0 -1
  231. package/esm/errors/AuthPollStopError.js +0 -20
  232. package/esm/errors/AuthPollStopError.js.map +0 -1
  233. package/esm/errors/AuthSdkError.js +0 -29
  234. package/esm/errors/AuthSdkError.js.map +0 -1
  235. package/esm/errors/CustomError.js +0 -21
  236. package/esm/errors/CustomError.js.map +0 -1
  237. package/esm/errors/OAuthError.js +0 -22
  238. package/esm/errors/OAuthError.js.map +0 -1
  239. package/esm/errors/index.js +0 -22
  240. package/esm/errors/index.js.map +0 -1
  241. package/esm/features.js +0 -64
  242. package/esm/features.js.map +0 -1
  243. package/esm/fetch/fetchRequest.js +0 -92
  244. package/esm/fetch/fetchRequest.js.map +0 -1
  245. package/esm/http/headers.js +0 -17
  246. package/esm/http/headers.js.map +0 -1
  247. package/esm/http/index.js +0 -3
  248. package/esm/http/index.js.map +0 -1
  249. package/esm/http/request.js +0 -145
  250. package/esm/http/request.js.map +0 -1
  251. package/esm/idx/authenticate.js +0 -47
  252. package/esm/idx/authenticate.js.map +0 -1
  253. package/esm/idx/cancel.js +0 -32
  254. package/esm/idx/cancel.js.map +0 -1
  255. package/esm/idx/flowMonitors/AuthenticationFlowMonitor.js +0 -41
  256. package/esm/idx/flowMonitors/AuthenticationFlowMonitor.js.map +0 -1
  257. package/esm/idx/flowMonitors/FlowMonitor.js +0 -73
  258. package/esm/idx/flowMonitors/FlowMonitor.js.map +0 -1
  259. package/esm/idx/flowMonitors/PasswordRecoveryFlowMonitor.js +0 -57
  260. package/esm/idx/flowMonitors/PasswordRecoveryFlowMonitor.js.map +0 -1
  261. package/esm/idx/flowMonitors/RegistrationFlowMonitor.js +0 -28
  262. package/esm/idx/flowMonitors/RegistrationFlowMonitor.js.map +0 -1
  263. package/esm/idx/flowMonitors/index.js +0 -16
  264. package/esm/idx/flowMonitors/index.js.map +0 -1
  265. package/esm/idx/handleInteractionCodeRedirect.js +0 -64
  266. package/esm/idx/handleInteractionCodeRedirect.js.map +0 -1
  267. package/esm/idx/headers.js +0 -39
  268. package/esm/idx/headers.js.map +0 -1
  269. package/esm/idx/index.js +0 -20
  270. package/esm/idx/index.js.map +0 -1
  271. package/esm/idx/interact.js +0 -83
  272. package/esm/idx/interact.js.map +0 -1
  273. package/esm/idx/introspect.js +0 -45
  274. package/esm/idx/introspect.js.map +0 -1
  275. package/esm/idx/recoverPassword.js +0 -46
  276. package/esm/idx/recoverPassword.js.map +0 -1
  277. package/esm/idx/register.js +0 -63
  278. package/esm/idx/register.js.map +0 -1
  279. package/esm/idx/remediate.js +0 -302
  280. package/esm/idx/remediate.js.map +0 -1
  281. package/esm/idx/remediators/AuthenticatorEnrollmentData.js +0 -68
  282. package/esm/idx/remediators/AuthenticatorEnrollmentData.js.map +0 -1
  283. package/esm/idx/remediators/AuthenticatorVerificationData.js +0 -66
  284. package/esm/idx/remediators/AuthenticatorVerificationData.js.map +0 -1
  285. package/esm/idx/remediators/Base/AuthenticatorData.js +0 -105
  286. package/esm/idx/remediators/Base/AuthenticatorData.js.map +0 -1
  287. package/esm/idx/remediators/Base/Remediator.js +0 -221
  288. package/esm/idx/remediators/Base/Remediator.js.map +0 -1
  289. package/esm/idx/remediators/Base/SelectAuthenticator.js +0 -140
  290. package/esm/idx/remediators/Base/SelectAuthenticator.js.map +0 -1
  291. package/esm/idx/remediators/Base/VerifyAuthenticator.js +0 -65
  292. package/esm/idx/remediators/Base/VerifyAuthenticator.js.map +0 -1
  293. package/esm/idx/remediators/ChallengeAuthenticator.js +0 -18
  294. package/esm/idx/remediators/ChallengeAuthenticator.js.map +0 -1
  295. package/esm/idx/remediators/EnrollAuthenticator.js +0 -18
  296. package/esm/idx/remediators/EnrollAuthenticator.js.map +0 -1
  297. package/esm/idx/remediators/EnrollProfile.js +0 -79
  298. package/esm/idx/remediators/EnrollProfile.js.map +0 -1
  299. package/esm/idx/remediators/Identify.js +0 -87
  300. package/esm/idx/remediators/Identify.js.map +0 -1
  301. package/esm/idx/remediators/ReEnrollAuthenticator.js +0 -45
  302. package/esm/idx/remediators/ReEnrollAuthenticator.js.map +0 -1
  303. package/esm/idx/remediators/RedirectIdp.js.map +0 -1
  304. package/esm/idx/remediators/ResetAuthenticator.js +0 -18
  305. package/esm/idx/remediators/ResetAuthenticator.js.map +0 -1
  306. package/esm/idx/remediators/SelectAuthenticatorAuthenticate.js +0 -18
  307. package/esm/idx/remediators/SelectAuthenticatorAuthenticate.js.map +0 -1
  308. package/esm/idx/remediators/SelectAuthenticatorEnroll.js +0 -18
  309. package/esm/idx/remediators/SelectAuthenticatorEnroll.js.map +0 -1
  310. package/esm/idx/remediators/SelectEnrollProfile.js +0 -24
  311. package/esm/idx/remediators/SelectEnrollProfile.js.map +0 -1
  312. package/esm/idx/remediators/Skip.js +0 -23
  313. package/esm/idx/remediators/Skip.js.map +0 -1
  314. package/esm/idx/remediators/index.js +0 -26
  315. package/esm/idx/remediators/index.js.map +0 -1
  316. package/esm/idx/remediators/util.js +0 -35
  317. package/esm/idx/remediators/util.js.map +0 -1
  318. package/esm/idx/run.js +0 -201
  319. package/esm/idx/run.js.map +0 -1
  320. package/esm/idx/startTransaction.js +0 -27
  321. package/esm/idx/startTransaction.js.map +0 -1
  322. package/esm/idx/transactionMeta.js +0 -114
  323. package/esm/idx/transactionMeta.js.map +0 -1
  324. package/esm/idx/types/idx-js.js +0 -17
  325. package/esm/idx/types/idx-js.js.map +0 -1
  326. package/esm/idx/types/index.js +0 -44
  327. package/esm/idx/types/index.js.map +0 -1
  328. package/esm/oidc/decodeToken.js +0 -31
  329. package/esm/oidc/decodeToken.js.map +0 -1
  330. package/esm/oidc/endpoints/authorize.js +0 -61
  331. package/esm/oidc/endpoints/authorize.js.map +0 -1
  332. package/esm/oidc/endpoints/index.js.map +0 -1
  333. package/esm/oidc/endpoints/token.js +0 -97
  334. package/esm/oidc/endpoints/token.js.map +0 -1
  335. package/esm/oidc/endpoints/well-known.js +0 -58
  336. package/esm/oidc/endpoints/well-known.js.map +0 -1
  337. package/esm/oidc/exchangeCodeForTokens.js +0 -69
  338. package/esm/oidc/exchangeCodeForTokens.js.map +0 -1
  339. package/esm/oidc/getToken.js +0 -180
  340. package/esm/oidc/getToken.js.map +0 -1
  341. package/esm/oidc/getUserInfo.js +0 -82
  342. package/esm/oidc/getUserInfo.js.map +0 -1
  343. package/esm/oidc/getWithPopup.js +0 -34
  344. package/esm/oidc/getWithPopup.js.map +0 -1
  345. package/esm/oidc/getWithRedirect.js +0 -65
  346. package/esm/oidc/getWithRedirect.js.map +0 -1
  347. package/esm/oidc/getWithoutPrompt.js +0 -29
  348. package/esm/oidc/getWithoutPrompt.js.map +0 -1
  349. package/esm/oidc/handleOAuthResponse.js +0 -148
  350. package/esm/oidc/handleOAuthResponse.js.map +0 -1
  351. package/esm/oidc/index.js +0 -29
  352. package/esm/oidc/index.js.map +0 -1
  353. package/esm/oidc/parseFromUrl.js +0 -144
  354. package/esm/oidc/parseFromUrl.js.map +0 -1
  355. package/esm/oidc/renewToken.js +0 -85
  356. package/esm/oidc/renewToken.js.map +0 -1
  357. package/esm/oidc/renewTokens.js +0 -74
  358. package/esm/oidc/renewTokens.js.map +0 -1
  359. package/esm/oidc/renewTokensWithRefresh.js +0 -55
  360. package/esm/oidc/renewTokensWithRefresh.js.map +0 -1
  361. package/esm/oidc/revokeToken.js +0 -57
  362. package/esm/oidc/revokeToken.js.map +0 -1
  363. package/esm/oidc/util/browser.js +0 -74
  364. package/esm/oidc/util/browser.js.map +0 -1
  365. package/esm/oidc/util/defaultTokenParams.js +0 -42
  366. package/esm/oidc/util/defaultTokenParams.js.map +0 -1
  367. package/esm/oidc/util/errors.js +0 -31
  368. package/esm/oidc/util/errors.js.map +0 -1
  369. package/esm/oidc/util/index.js +0 -25
  370. package/esm/oidc/util/index.js.map +0 -1
  371. package/esm/oidc/util/loginRedirect.js +0 -84
  372. package/esm/oidc/util/loginRedirect.js.map +0 -1
  373. package/esm/oidc/util/oauth.js +0 -70
  374. package/esm/oidc/util/oauth.js.map +0 -1
  375. package/esm/oidc/util/pkce.js +0 -55
  376. package/esm/oidc/util/pkce.js.map +0 -1
  377. package/esm/oidc/util/prepareTokenParams.js +0 -75
  378. package/esm/oidc/util/prepareTokenParams.js.map +0 -1
  379. package/esm/oidc/util/refreshToken.js +0 -24
  380. package/esm/oidc/util/refreshToken.js.map +0 -1
  381. package/esm/oidc/util/urlParams.js +0 -54
  382. package/esm/oidc/util/urlParams.js.map +0 -1
  383. package/esm/oidc/util/validateClaims.js +0 -53
  384. package/esm/oidc/util/validateClaims.js.map +0 -1
  385. package/esm/oidc/util/validateToken.js +0 -21
  386. package/esm/oidc/util/validateToken.js.map +0 -1
  387. package/esm/oidc/verifyToken.js +0 -78
  388. package/esm/oidc/verifyToken.js.map +0 -1
  389. package/esm/options.js +0 -134
  390. package/esm/options.js.map +0 -1
  391. package/esm/server/serverStorage.js +0 -110
  392. package/esm/server/serverStorage.js.map +0 -1
  393. package/esm/services/TokenService.js +0 -103
  394. package/esm/services/TokenService.js.map +0 -1
  395. package/esm/session.js +0 -81
  396. package/esm/session.js.map +0 -1
  397. package/esm/tx/AuthTransaction.js +0 -213
  398. package/esm/tx/AuthTransaction.js.map +0 -1
  399. package/esm/tx/TransactionState.js.map +0 -1
  400. package/esm/tx/api.js +0 -87
  401. package/esm/tx/api.js.map +0 -1
  402. package/esm/tx/index.js +0 -18
  403. package/esm/tx/index.js.map +0 -1
  404. package/esm/tx/poll.js +0 -124
  405. package/esm/tx/poll.js.map +0 -1
  406. package/esm/tx/util.js.map +0 -1
  407. package/esm/types/AuthState.js +0 -3
  408. package/esm/types/Cookies.js +0 -3
  409. package/esm/types/EventEmitter.js +0 -3
  410. package/esm/types/EventEmitter.js.map +0 -1
  411. package/esm/types/JWT.js +0 -3
  412. package/esm/types/JWT.js.map +0 -1
  413. package/esm/types/OAuth.js +0 -3
  414. package/esm/types/OAuth.js.map +0 -1
  415. package/esm/types/OktaAuthOptions.js +0 -3
  416. package/esm/types/OktaAuthOptions.js.map +0 -1
  417. package/esm/types/Storage.js +0 -3
  418. package/esm/types/Storage.js.map +0 -1
  419. package/esm/types/Token.js +0 -29
  420. package/esm/types/Token.js.map +0 -1
  421. package/esm/types/TokenManager.js +0 -3
  422. package/esm/types/TokenManager.js.map +0 -1
  423. package/esm/types/Transaction.js +0 -57
  424. package/esm/types/Transaction.js.map +0 -1
  425. package/esm/types/UserClaims.js +0 -3
  426. package/esm/types/UserClaims.js.map +0 -1
  427. package/esm/types/api.js +0 -3
  428. package/esm/types/api.js.map +0 -1
  429. package/esm/types/http.js +0 -3
  430. package/esm/types/http.js.map +0 -1
  431. package/esm/types/index.js +0 -27
  432. package/esm/types/index.js.map +0 -1
  433. package/esm/util/console.js +0 -53
  434. package/esm/util/console.js.map +0 -1
  435. package/esm/util/index.js +0 -17
  436. package/esm/util/index.js.map +0 -1
  437. package/esm/util/misc.js +0 -33
  438. package/esm/util/misc.js.map +0 -1
  439. package/esm/util/object.js +0 -117
  440. package/esm/util/object.js.map +0 -1
  441. package/esm/util/sharedStorage.js +0 -43
  442. package/esm/util/sharedStorage.js.map +0 -1
  443. package/esm/util/types.js +0 -27
  444. package/esm/util/types.js.map +0 -1
  445. package/esm/util/url.js +0 -64
  446. package/esm/util/url.js.map +0 -1
  447. package/lib/idx/flowMonitors/FlowMonitor.d.ts +0 -23
  448. package/lib/idx/flowMonitors/PasswordRecoveryFlowMonitor.d.ts +0 -16
  449. package/lib/idx/flowMonitors/RegistrationFlowMonitor.d.ts +0 -15
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../lib/idx/flowMonitors/PasswordRecoveryFlowMonitor.ts"],"names":["PasswordRecoveryFlowMonitor","FlowMonitor","isRemediatorCandidate","remediator","remediations","values","prevRemediatorName","previousRemediator","getName","remediatorName","includes","some","name","isFinished","authClient"],"mappings":";;;;AAaA;;AACA;;AAdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMO,MAAMA,2BAAN,SAA0CC,wBAA1C,CAAsD;AAC3DC,EAAAA,qBAAqB,CAACC,UAAD,EAAaC,YAAb,EAA4BC,MAA5B,EAAqC;AAAA;;AACxD,UAAMC,kBAAkB,4BAAG,KAAKC,kBAAR,0DAAG,sBAAyBC,OAAzB,EAA3B;AACA,UAAMC,cAAc,GAAGN,UAAU,CAACK,OAAX,EAAvB;;AAEA,QAAIC,cAAc,KAAK,mCAAnB,IACC,CACD,mCADC,EAED,wBAFC,EAGDC,QAHC,CAGQJ,kBAHR,CADL,EAIkC;AAChC,aAAO,KAAP;AACD;;AAED,QAAIG,cAAc,KAAK,mCAAnB,IACCL,YAAY,CAACO,IAAb,CAAkB,CAAC;AAAEC,MAAAA;AAAF,KAAD,KAAcA,IAAI,KAAK,yBAAzC,CADL,EAC0E;AACxE,aAAO,KAAP;AACD;;AAED,WAAO,MAAMV,qBAAN,CAA4BC,UAA5B,EAAwCC,YAAxC,EAAsDC,MAAtD,CAAP;AACD;;AAEe,QAAVQ,UAAU,GAAG;AACjB,UAAM;AAAET,MAAAA;AAAF,QAAoB,MAAM,yCAAmB,KAAKU,UAAxB,CAAhC;;AACA,QAAI,CAACV,YAAY,CAACM,QAAb,CAAsB,qBAAtB,CAAL,EAAmD;AACjD,aAAO,KAAP;AACD;;AAED,WAAO,MAAM,MAAMG,UAAN,EAAb;AACD;;AA5B0D","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 { FlowMonitor } from './FlowMonitor';\nimport { getTransactionMeta } from '../transactionMeta';\n\nexport class PasswordRecoveryFlowMonitor extends FlowMonitor {\n isRemediatorCandidate(remediator, remediations?, values?) {\n const prevRemediatorName = this.previousRemediator?.getName();\n const remediatorName = remediator.getName();\n \n if (remediatorName === 'select-authenticator-authenticate' \n && [\n 'select-authenticator-authenticate',\n 'reenroll-authenticator'\n ].includes(prevRemediatorName)) {\n return false;\n }\n\n if (remediatorName === 'select-authenticator-authenticate' \n && remediations.some(({ name }) => name === 'challenge-authenticator')) {\n return false;\n }\n\n return super.isRemediatorCandidate(remediator, remediations, values);\n }\n\n async isFinished() {\n const { remediations } = await getTransactionMeta(this.authClient);\n if (!remediations.includes('reset-authenticator')) {\n return false;\n }\n\n return await super.isFinished();\n }\n}\n"],"file":"PasswordRecoveryFlowMonitor.js"}
@@ -1,35 +0,0 @@
1
- "use strict";
2
-
3
- exports.RegistrationFlowMonitor = void 0;
4
-
5
- var _FlowMonitor = require("./FlowMonitor");
6
-
7
- /*!
8
- * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
9
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
10
- *
11
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- *
16
- * See the License for the specific language governing permissions and limitations under the License.
17
- */
18
- class RegistrationFlowMonitor extends _FlowMonitor.FlowMonitor {
19
- isRemediatorCandidate(remediator, remediations, values) {
20
- var _this$previousRemedia;
21
-
22
- const prevRemediatorName = (_this$previousRemedia = this.previousRemediator) === null || _this$previousRemedia === void 0 ? void 0 : _this$previousRemedia.getName();
23
- const remediatorName = remediator.getName();
24
-
25
- if (remediatorName === 'select-authenticator-enroll' && ['select-authenticator-enroll', 'authenticator-enrollment-data'].includes(prevRemediatorName)) {
26
- return false;
27
- }
28
-
29
- return super.isRemediatorCandidate(remediator, remediations, values);
30
- }
31
-
32
- }
33
-
34
- exports.RegistrationFlowMonitor = RegistrationFlowMonitor;
35
- //# sourceMappingURL=RegistrationFlowMonitor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../lib/idx/flowMonitors/RegistrationFlowMonitor.ts"],"names":["RegistrationFlowMonitor","FlowMonitor","isRemediatorCandidate","remediator","remediations","values","prevRemediatorName","previousRemediator","getName","remediatorName","includes"],"mappings":";;;;AAaA;;AAbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKO,MAAMA,uBAAN,SAAsCC,wBAAtC,CAAkD;AACvDC,EAAAA,qBAAqB,CAACC,UAAD,EAAaC,YAAb,EAA4BC,MAA5B,EAAqC;AAAA;;AACxD,UAAMC,kBAAkB,4BAAG,KAAKC,kBAAR,0DAAG,sBAAyBC,OAAzB,EAA3B;AACA,UAAMC,cAAc,GAAGN,UAAU,CAACK,OAAX,EAAvB;;AACA,QAAIC,cAAc,KAAK,6BAAnB,IACC,CACC,6BADD,EAEC,+BAFD,EAGCC,QAHD,CAGUJ,kBAHV,CADL,EAIoC;AAClC,aAAO,KAAP;AACD;;AAED,WAAO,MAAMJ,qBAAN,CAA4BC,UAA5B,EAAwCC,YAAxC,EAAsDC,MAAtD,CAAP;AACD;;AAbsD","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 { FlowMonitor } from './FlowMonitor';\n\nexport class RegistrationFlowMonitor extends FlowMonitor {\n isRemediatorCandidate(remediator, remediations?, values?) {\n const prevRemediatorName = this.previousRemediator?.getName();\n const remediatorName = remediator.getName();\n if (remediatorName === 'select-authenticator-enroll' \n && [\n 'select-authenticator-enroll', \n 'authenticator-enrollment-data'\n ].includes(prevRemediatorName)) {\n return false;\n }\n\n return super.isRemediatorCandidate(remediator, remediations, values);\n }\n}\n"],"file":"RegistrationFlowMonitor.js"}
@@ -1,54 +0,0 @@
1
- "use strict";
2
-
3
- var _FlowMonitor = require("./FlowMonitor");
4
-
5
- Object.keys(_FlowMonitor).forEach(function (key) {
6
- if (key === "default" || key === "__esModule") return;
7
- if (key in exports && exports[key] === _FlowMonitor[key]) return;
8
- Object.defineProperty(exports, key, {
9
- enumerable: true,
10
- get: function () {
11
- return _FlowMonitor[key];
12
- }
13
- });
14
- });
15
-
16
- var _RegistrationFlowMonitor = require("./RegistrationFlowMonitor");
17
-
18
- Object.keys(_RegistrationFlowMonitor).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _RegistrationFlowMonitor[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _RegistrationFlowMonitor[key];
25
- }
26
- });
27
- });
28
-
29
- var _AuthenticationFlowMonitor = require("./AuthenticationFlowMonitor");
30
-
31
- Object.keys(_AuthenticationFlowMonitor).forEach(function (key) {
32
- if (key === "default" || key === "__esModule") return;
33
- if (key in exports && exports[key] === _AuthenticationFlowMonitor[key]) return;
34
- Object.defineProperty(exports, key, {
35
- enumerable: true,
36
- get: function () {
37
- return _AuthenticationFlowMonitor[key];
38
- }
39
- });
40
- });
41
-
42
- var _PasswordRecoveryFlowMonitor = require("./PasswordRecoveryFlowMonitor");
43
-
44
- Object.keys(_PasswordRecoveryFlowMonitor).forEach(function (key) {
45
- if (key === "default" || key === "__esModule") return;
46
- if (key in exports && exports[key] === _PasswordRecoveryFlowMonitor[key]) return;
47
- Object.defineProperty(exports, key, {
48
- enumerable: true,
49
- get: function () {
50
- return _PasswordRecoveryFlowMonitor[key];
51
- }
52
- });
53
- });
54
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../lib/idx/flowMonitors/index.ts"],"names":[],"mappings":";;AAaA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","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\nexport * from './FlowMonitor';\nexport * from './RegistrationFlowMonitor';\nexport * from './AuthenticationFlowMonitor';\nexport * from './PasswordRecoveryFlowMonitor';\n"],"file":"index.js"}
@@ -1,214 +0,0 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
-
4
- 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; }
5
-
6
- 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; }
7
-
8
- /*!
9
- * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
10
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
11
- *
12
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- *
17
- * See the License for the specific language governing permissions and limitations under the License.
18
- */
19
- import { AuthSdkError } from './errors';
20
- import { getConsole } from './util';
21
- import { EVENT_ADDED, EVENT_REMOVED } from './TokenManager';
22
-
23
- var PCancelable = require('p-cancelable');
24
-
25
- export var INITIAL_AUTH_STATE = null;
26
- var DEFAULT_PENDING = {
27
- updateAuthStatePromise: null,
28
- canceledTimes: 0
29
- };
30
- var EVENT_AUTH_STATE_CHANGE = 'authStateChange';
31
- var MAX_PROMISE_CANCEL_TIMES = 10; // only compare first level of authState
32
-
33
- var isSameAuthState = (prevState, state) => {
34
- // initial state is null
35
- if (!prevState) {
36
- return false;
37
- }
38
-
39
- return prevState.isAuthenticated === state.isAuthenticated && JSON.stringify(prevState.idToken) === JSON.stringify(state.idToken) && JSON.stringify(prevState.accessToken) === JSON.stringify(state.accessToken) && prevState.error === state.error;
40
- };
41
-
42
- export class AuthStateManager {
43
- constructor(sdk) {
44
- if (!sdk.emitter) {
45
- throw new AuthSdkError('Emitter should be initialized before AuthStateManager');
46
- }
47
-
48
- this._sdk = sdk;
49
- this._pending = _objectSpread({}, DEFAULT_PENDING);
50
- this._authState = INITIAL_AUTH_STATE;
51
- this._logOptions = {}; // Listen on tokenManager events to start updateState process
52
- // "added" event is emitted in both add and renew process
53
- // Only listen on "added" event to update auth state
54
-
55
- sdk.tokenManager.on(EVENT_ADDED, (key, token) => {
56
- this._setLogOptions({
57
- event: EVENT_ADDED,
58
- key,
59
- token
60
- });
61
-
62
- this.updateAuthState();
63
- });
64
- sdk.tokenManager.on(EVENT_REMOVED, (key, token) => {
65
- this._setLogOptions({
66
- event: EVENT_REMOVED,
67
- key,
68
- token
69
- });
70
-
71
- this.updateAuthState();
72
- });
73
- }
74
-
75
- _setLogOptions(options) {
76
- this._logOptions = options;
77
- }
78
-
79
- getAuthState() {
80
- return this._authState;
81
- }
82
-
83
- getPreviousAuthState() {
84
- return this._prevAuthState;
85
- }
86
-
87
- updateAuthState() {
88
- var _this = this;
89
-
90
- return _asyncToGenerator(function* () {
91
- var {
92
- transformAuthState,
93
- devMode
94
- } = _this._sdk.options;
95
-
96
- var log = status => {
97
- var {
98
- event,
99
- key,
100
- token
101
- } = _this._logOptions;
102
- getConsole().group("OKTA-AUTH-JS:updateAuthState: Event:".concat(event, " Status:").concat(status));
103
- getConsole().log(key, token);
104
- getConsole().log('Current authState', _this._authState);
105
- getConsole().groupEnd(); // clear log options after logging
106
-
107
- _this._logOptions = {};
108
- };
109
-
110
- var emitAuthStateChange = authState => {
111
- if (isSameAuthState(_this._authState, authState)) {
112
- devMode && log('unchanged');
113
- return;
114
- }
115
-
116
- _this._prevAuthState = _this._authState;
117
- _this._authState = authState; // emit new authState object
118
-
119
- _this._sdk.emitter.emit(EVENT_AUTH_STATE_CHANGE, _objectSpread({}, authState));
120
-
121
- devMode && log('emitted');
122
- };
123
-
124
- var finalPromise = origPromise => {
125
- return _this._pending.updateAuthStatePromise.then(() => {
126
- var curPromise = _this._pending.updateAuthStatePromise;
127
-
128
- if (curPromise && curPromise !== origPromise) {
129
- return finalPromise(curPromise);
130
- }
131
-
132
- return _this.getAuthState();
133
- });
134
- };
135
-
136
- if (_this._pending.updateAuthStatePromise) {
137
- if (_this._pending.canceledTimes >= MAX_PROMISE_CANCEL_TIMES) {
138
- // stop canceling then starting a new promise
139
- // let existing promise finish to prevent running into loops
140
- devMode && log('terminated');
141
- return finalPromise(_this._pending.updateAuthStatePromise);
142
- } else {
143
- _this._pending.updateAuthStatePromise.cancel();
144
- }
145
- }
146
- /* eslint-disable complexity */
147
-
148
-
149
- var cancelablePromise = new PCancelable((resolve, _, onCancel) => {
150
- onCancel.shouldReject = false;
151
- onCancel(() => {
152
- _this._pending.updateAuthStatePromise = null;
153
- _this._pending.canceledTimes = _this._pending.canceledTimes + 1;
154
- devMode && log('canceled');
155
- });
156
-
157
- var emitAndResolve = authState => {
158
- if (cancelablePromise.isCanceled) {
159
- resolve();
160
- return;
161
- } // emit event and resolve promise
162
-
163
-
164
- emitAuthStateChange(authState);
165
- resolve(); // clear pending states after resolve
166
-
167
- _this._pending = _objectSpread({}, DEFAULT_PENDING);
168
- };
169
-
170
- _this._sdk.isAuthenticated().then(() => {
171
- if (cancelablePromise.isCanceled) {
172
- resolve();
173
- return;
174
- }
175
-
176
- var {
177
- accessToken,
178
- idToken,
179
- refreshToken
180
- } = _this._sdk.tokenManager.getTokensSync();
181
-
182
- var authState = {
183
- accessToken,
184
- idToken,
185
- refreshToken,
186
- isAuthenticated: !!(accessToken && idToken)
187
- };
188
- var promise = transformAuthState ? transformAuthState(_this._sdk, authState) : Promise.resolve(authState);
189
- promise.then(authState => emitAndResolve(authState)).catch(error => emitAndResolve({
190
- accessToken,
191
- idToken,
192
- refreshToken,
193
- isAuthenticated: false,
194
- error
195
- }));
196
- });
197
- });
198
- /* eslint-enable complexity */
199
-
200
- _this._pending.updateAuthStatePromise = cancelablePromise;
201
- return finalPromise(cancelablePromise);
202
- })();
203
- }
204
-
205
- subscribe(handler) {
206
- this._sdk.emitter.on(EVENT_AUTH_STATE_CHANGE, handler);
207
- }
208
-
209
- unsubscribe(handler) {
210
- this._sdk.emitter.off(EVENT_AUTH_STATE_CHANGE, handler);
211
- }
212
-
213
- }
214
- //# sourceMappingURL=AuthStateManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../lib/AuthStateManager.ts"],"names":["AuthSdkError","getConsole","EVENT_ADDED","EVENT_REMOVED","PCancelable","require","INITIAL_AUTH_STATE","DEFAULT_PENDING","updateAuthStatePromise","canceledTimes","EVENT_AUTH_STATE_CHANGE","MAX_PROMISE_CANCEL_TIMES","isSameAuthState","prevState","state","isAuthenticated","JSON","stringify","idToken","accessToken","error","AuthStateManager","constructor","sdk","emitter","_sdk","_pending","_authState","_logOptions","tokenManager","on","key","token","_setLogOptions","event","updateAuthState","options","getAuthState","getPreviousAuthState","_prevAuthState","transformAuthState","devMode","log","status","group","groupEnd","emitAuthStateChange","authState","emit","finalPromise","origPromise","then","curPromise","cancel","cancelablePromise","resolve","_","onCancel","shouldReject","emitAndResolve","isCanceled","refreshToken","getTokensSync","promise","Promise","catch","subscribe","handler","unsubscribe","off"],"mappings":";;;;;;;AAA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,OAAR,CAAgBR,SAAhB,CAFJ;AAIAgB,UAAAA,OAAO,CACJZ,IADH,CACQJ,SAAS,IAAIY,cAAc,CAACZ,SAAD,CADnC,EAEGkB,KAFH,CAES7C,KAAK,IAAIuC,cAAc,CAAC;AAC7BxC,YAAAA,WAD6B;AAE7BD,YAAAA,OAF6B;AAG7B2C,YAAAA,YAH6B;AAI7B9C,YAAAA,eAAe,EAAE,KAJY;AAK7BK,YAAAA;AAL6B,WAAD,CAFhC;AASD,SA3BH;AA4BD,OAjDyB,CAA1B;AAkDA;;AACA,MAAA,KAAI,CAACM,QAAL,CAAclB,sBAAd,GAAuC8C,iBAAvC;AAEA,aAAOL,YAAY,CAACK,iBAAD,CAAnB;AArG0C;AAsG3C;;AAEDY,EAAAA,SAAS,CAACC,OAAD,EAAgB;AACvB,SAAK1C,IAAL,CAAUD,OAAV,CAAkBM,EAAlB,CAAqBpB,uBAArB,EAA8CyD,OAA9C;AACD;;AAEDC,EAAAA,WAAW,CAACD,OAAD,EAAiB;AAC1B,SAAK1C,IAAL,CAAUD,OAAV,CAAkB6C,GAAlB,CAAsB3D,uBAAtB,EAA+CyD,OAA/C;AACD;;AA5J2B","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 { AuthSdkError } from './errors';\nimport { AuthState, AuthStateLogOptions } from './types';\nimport { OktaAuth } from '.';\nimport { getConsole } from './util';\nimport { EVENT_ADDED, EVENT_REMOVED } from './TokenManager';\nconst PCancelable = require('p-cancelable');\n\nexport const INITIAL_AUTH_STATE = null;\nconst DEFAULT_PENDING = {\n updateAuthStatePromise: null,\n canceledTimes: 0\n};\nconst EVENT_AUTH_STATE_CHANGE = 'authStateChange';\nconst MAX_PROMISE_CANCEL_TIMES = 10;\n\n// only compare first level of authState\nconst isSameAuthState = (prevState: AuthState, state: AuthState) => {\n // initial state is null\n if (!prevState) {\n return false;\n }\n\n return prevState.isAuthenticated === state.isAuthenticated \n && JSON.stringify(prevState.idToken) === JSON.stringify(state.idToken)\n && JSON.stringify(prevState.accessToken) === JSON.stringify(state.accessToken)\n && prevState.error === state.error;\n};\n\nexport class AuthStateManager {\n _sdk: OktaAuth;\n _pending: { \n updateAuthStatePromise: typeof PCancelable;\n canceledTimes: number; \n };\n _authState: AuthState | null;\n _prevAuthState: AuthState | null;\n _logOptions: AuthStateLogOptions;\n _lastEventTimestamp: number;\n\n constructor(sdk: OktaAuth) {\n if (!sdk.emitter) {\n throw new AuthSdkError('Emitter should be initialized before AuthStateManager');\n }\n\n this._sdk = sdk;\n this._pending = { ...DEFAULT_PENDING };\n this._authState = INITIAL_AUTH_STATE;\n this._logOptions = {};\n\n // Listen on tokenManager events to start updateState process\n // \"added\" event is emitted in both add and renew process\n // Only listen on \"added\" event to update auth state\n sdk.tokenManager.on(EVENT_ADDED, (key, token) => {\n this._setLogOptions({ event: EVENT_ADDED, key, token });\n this.updateAuthState();\n });\n sdk.tokenManager.on(EVENT_REMOVED, (key, token) => {\n this._setLogOptions({ event: EVENT_REMOVED, key, token });\n this.updateAuthState();\n });\n }\n\n _setLogOptions(options) {\n this._logOptions = options;\n }\n\n getAuthState(): AuthState | null {\n return this._authState;\n }\n\n getPreviousAuthState(): AuthState | null {\n return this._prevAuthState;\n }\n\n async updateAuthState(): Promise<AuthState> {\n const { transformAuthState, devMode } = this._sdk.options;\n\n const log = (status) => {\n const { event, key, token } = this._logOptions;\n getConsole().group(`OKTA-AUTH-JS:updateAuthState: Event:${event} Status:${status}`);\n getConsole().log(key, token);\n getConsole().log('Current authState', this._authState);\n getConsole().groupEnd();\n \n // clear log options after logging\n this._logOptions = {};\n };\n\n const emitAuthStateChange = (authState) => {\n if (isSameAuthState(this._authState, authState)) {\n devMode && log('unchanged'); \n return;\n }\n this._prevAuthState = this._authState;\n this._authState = authState;\n // emit new authState object\n this._sdk.emitter.emit(EVENT_AUTH_STATE_CHANGE, { ...authState });\n devMode && log('emitted');\n };\n\n const finalPromise = (origPromise) => { \n return this._pending.updateAuthStatePromise.then(() => {\n const curPromise = this._pending.updateAuthStatePromise;\n if (curPromise && curPromise !== origPromise) {\n return finalPromise(curPromise);\n }\n return this.getAuthState();\n });\n };\n\n if (this._pending.updateAuthStatePromise) {\n if (this._pending.canceledTimes >= MAX_PROMISE_CANCEL_TIMES) {\n // stop canceling then starting a new promise\n // let existing promise finish to prevent running into loops\n devMode && log('terminated');\n return finalPromise(this._pending.updateAuthStatePromise);\n } else {\n this._pending.updateAuthStatePromise.cancel();\n }\n }\n\n /* eslint-disable complexity */\n const cancelablePromise = new PCancelable((resolve, _, onCancel) => {\n onCancel.shouldReject = false;\n onCancel(() => {\n this._pending.updateAuthStatePromise = null;\n this._pending.canceledTimes = this._pending.canceledTimes + 1;\n devMode && log('canceled');\n });\n\n const emitAndResolve = (authState) => {\n if (cancelablePromise.isCanceled) {\n resolve();\n return;\n }\n // emit event and resolve promise \n emitAuthStateChange(authState);\n resolve();\n\n // clear pending states after resolve\n this._pending = { ...DEFAULT_PENDING };\n };\n\n this._sdk.isAuthenticated()\n .then(() => {\n if (cancelablePromise.isCanceled) {\n resolve();\n return;\n }\n\n const { accessToken, idToken, refreshToken } = this._sdk.tokenManager.getTokensSync();\n const authState = {\n accessToken,\n idToken,\n refreshToken,\n isAuthenticated: !!(accessToken && idToken)\n };\n const promise: Promise<AuthState> = transformAuthState\n ? transformAuthState(this._sdk, authState)\n : Promise.resolve(authState);\n\n promise\n .then(authState => emitAndResolve(authState))\n .catch(error => emitAndResolve({\n accessToken, \n idToken, \n refreshToken,\n isAuthenticated: false, \n error\n }));\n });\n });\n /* eslint-enable complexity */\n this._pending.updateAuthStatePromise = cancelablePromise;\n\n return finalPromise(cancelablePromise);\n }\n\n subscribe(handler): void {\n this._sdk.emitter.on(EVENT_AUTH_STATE_CHANGE, handler);\n }\n\n unsubscribe(handler?): void {\n this._sdk.emitter.off(EVENT_AUTH_STATE_CHANGE, handler);\n }\n}\n"],"file":"AuthStateManager.js"}